feat: Set loading screen image based on context
This commit is contained in:
parent
516de927d1
commit
a7cc87c359
4 changed files with 29 additions and 15 deletions
|
@ -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<void()> &block) {
|
||||
void Game::withLoadingScreen(const string &imageResRef, const function<void()> &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();
|
||||
}
|
||||
|
|
|
@ -302,7 +302,7 @@ private:
|
|||
|
||||
// Helper methods
|
||||
|
||||
void withLoadingScreen(const std::function<void()> &block);
|
||||
void withLoadingScreen(const std::string &imageResRef, const std::function<void()> &block);
|
||||
|
||||
// END Helper methods
|
||||
};
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue