Skip to content

Commit

Permalink
Logo: Allow opening the settings after one logo is shown
Browse files Browse the repository at this point in the history
The engine objects are created by then so this is safe
  • Loading branch information
Ghabry committed Oct 21, 2023
1 parent 0c3b3ea commit 42ab89e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/scene_gamebrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ void Scene_GameBrowser::BootGame() {

if (!FileFinder::FindImage("Logo", "LOGO1").empty()) {
// Delegate to Scene_Logo when a startup graphic was found
Scene::Push(std::make_shared<Scene_Logo>(1), true);
Scene::Push(std::make_shared<Scene_Logo>(1));
return;
}

Expand Down
23 changes: 16 additions & 7 deletions src/scene_logo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "player.h"
#include "scene_title.h"
#include "scene_gamebrowser.h"
#include "scene_settings.h"
#include "output.h"
#include "generated/logo.h"
#include "generated/logo2.h"
Expand All @@ -42,10 +43,12 @@ Scene_Logo::Scene_Logo(unsigned current_logo_index) :
if (current_logo_index > 0) {
detected_game = true;
}

skip_logos = Player::debug_flag || Game_Battle::battle_test.enabled;
}

void Scene_Logo::Start() {
if (!Player::debug_flag && !Game_Battle::battle_test.enabled) {
if (!skip_logos) {
logo_img = LoadLogo();
DrawTextOnLogo(false);
DrawLogo(logo_img);
Expand All @@ -67,20 +70,26 @@ void Scene_Logo::vUpdate() {
--frame_counter;
}

// Allow calling the settings when the first logo was shown (startup completed)
if (current_logo_index > 0 && Input::IsTriggered(Input::SETTINGS_MENU)) {
Scene::Push(std::make_shared<Scene_Settings>());
}

// other logos do not invoke the slow CreateGameObjects: display them longer
bool frame_limit_reached = (frame_counter == (current_logo_index == 0 ? 60 : 90));

if (Player::debug_flag ||
Game_Battle::battle_test.enabled ||
if (skip_logos ||
frame_limit_reached ||
Input::IsTriggered(Input::DECISION) ||
Input::IsTriggered(Input::CANCEL)) {

if (detected_game) {
// Check for another logo
if (!FileFinder::FindImage("Logo", "LOGO" + std::to_string(current_logo_index + 1)).empty()) {
Scene::Push(std::make_shared<Scene_Logo>(current_logo_index + 1), true);
return;
if (!skip_logos) {
// Check for another logo
if (!FileFinder::FindImage("Logo", "LOGO" + std::to_string(current_logo_index + 1)).empty()) {
Scene::Push(std::make_shared<Scene_Logo>(current_logo_index + 1), true);
return;
}
}

if (!Player::startup_language.empty()) {
Expand Down
1 change: 1 addition & 0 deletions src/scene_logo.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class Scene_Logo : public Scene {
BitmapRef logo_img;
int frame_counter;
unsigned current_logo_index;
bool skip_logos = false;
bool detected_game = false;

void OnIndexReady(FileRequestResult* result);
Expand Down

0 comments on commit 42ab89e

Please sign in to comment.