diff --git a/src/game/game.cpp b/src/game/game.cpp index bed78469..ab60b558 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -184,7 +184,7 @@ void Game::loadMainMenu() { void Game::loadModule(const string &name, string entry) { info("Game: load module: " + name); - withLoadingScreen([this, &name, &entry]() { + withLoadingScreen("load_" + name, [this, &name, &entry]() { if (!_hud) { loadHUD(); } @@ -241,10 +241,11 @@ void Game::loadModule(const string &name, string entry) { }); } -void Game::withLoadingScreen(const function &block) { +void Game::withLoadingScreen(const string &imageResRef, const function &block) { if (!_loadScreen) { loadLoadingScreen(); } + _loadScreen->setImage(imageResRef); changeScreen(GameScreen::Loading); drawAll(); block(); @@ -511,7 +512,7 @@ float Game::measureFrameTime() { } void Game::loadLoadingScreen() { - _loadScreen.reset(new LoadingScreen(_version, _options.graphics)); + _loadScreen.reset(new LoadingScreen(this)); _loadScreen->load(); } @@ -531,7 +532,8 @@ void Game::deinit() { } void Game::startCharacterGeneration() { - withLoadingScreen([this]() { + string imageResRef(_version == GameVersion::TheSithLords ? "load_default" : "load_chargen"); + withLoadingScreen(imageResRef, [this]() { if (!_charGen) { loadCharacterGeneration(); } diff --git a/src/game/game.h b/src/game/game.h index 5cec61ac..03ec0f07 100644 --- a/src/game/game.h +++ b/src/game/game.h @@ -302,7 +302,7 @@ private: // Helper methods - void withLoadingScreen(const std::function &block); + void withLoadingScreen(const std::string &imageResRef, const std::function &block); // END Helper methods }; diff --git a/src/game/gui/loadscreen.cpp b/src/game/gui/loadscreen.cpp index 56c416c5..660f1f17 100644 --- a/src/game/gui/loadscreen.cpp +++ b/src/game/gui/loadscreen.cpp @@ -19,6 +19,8 @@ #include "../../resource/resources.h" +#include "../game.h" + using namespace std; using namespace reone::gui; @@ -29,26 +31,29 @@ namespace reone { namespace game { -LoadingScreen::LoadingScreen(GameVersion version, const GraphicsOptions &opts) : GUI(version, opts) { - _resRef = getResRef("loadscreen"); - _backgroundType = BackgroundType::Load; +LoadingScreen::LoadingScreen(Game *game) : + GUI(game->version(), game->options().graphics), + _game(game) { - if (version == GameVersion::TheSithLords) { + _resRef = getResRef("loadscreen"); + + if (_version == GameVersion::TheSithLords) { _resolutionX = 800; _resolutionY = 600; + } else { + _backgroundType = BackgroundType::Load; } } void LoadingScreen::load() { GUI::load(); - - configureRootContol([this](Control &ctrl) { - string resRef(_version == GameVersion::TheSithLords ? "load_default" : "load_chargen"); - ctrl.setBorderFill(resRef); - }); setControlText("LBL_HINT", ""); } +void LoadingScreen::setImage(const string &resRef) { + configureRootContol([&resRef](Control &ctrl) { ctrl.setBorderFill(resRef); }); +} + } // namespace game } // namespace reone diff --git a/src/game/gui/loadscreen.h b/src/game/gui/loadscreen.h index 8873ef8e..2e380b6a 100644 --- a/src/game/gui/loadscreen.h +++ b/src/game/gui/loadscreen.h @@ -23,11 +23,18 @@ namespace reone { namespace game { +class Game; + class LoadingScreen : public gui::GUI { public: - LoadingScreen(resource::GameVersion version, const render::GraphicsOptions &opts); + LoadingScreen(Game *game); void load() override; + + void setImage(const std::string &resRef); + +private: + Game *_game; }; } // namespace game