From 6e7264405d27c985a55e00fe69237b7adce0a996 Mon Sep 17 00:00:00 2001 From: Mauro Junior <45118493+jetrotal@users.noreply.github.com> Date: Thu, 26 Oct 2023 03:56:50 -0300 Subject: [PATCH] Game_Browser - Autorun a specific game If a game file starts with `gamedata.easyrpg` and there's only one game in player's folder, the player will autorun it. It would be better if I could skip the game_browser scene or hide the screen with default system. But this suggestion is also fine. --- src/scene_gamebrowser.cpp | 12 ++++++++++++ src/window_gamelist.cpp | 2 ++ src/window_gamelist.h | 3 +++ 3 files changed, 17 insertions(+) diff --git a/src/scene_gamebrowser.cpp b/src/scene_gamebrowser.cpp index 77be95d7490..f75ecc3c7ab 100644 --- a/src/scene_gamebrowser.cpp +++ b/src/scene_gamebrowser.cpp @@ -115,6 +115,18 @@ void Scene_GameBrowser::CreateWindows() { about_window = std::make_unique(0, 64, Player::screen_width, Player::screen_height - 64); about_window->Refresh(); about_window->SetVisible(false); + + // Output::Warning("conditions {} - {}", gamelist_window->max_directories, gamelist_window->last_directory_name); + if (gamelist_window->max_directories == 1 && gamelist_window->last_directory_name.find("gamedata.easyrpg") == 0) { + + command_window->SetVisible(false); + gamelist_window->SetVisible(false); + help_window->SetVisible(false); + load_window->SetVisible(true); + + gamelist_window->SetIndex(old_gamelist_index); + game_loading = true; + } } void Scene_GameBrowser::UpdateCommand() { diff --git a/src/window_gamelist.cpp b/src/window_gamelist.cpp index eec944888be..a89b1f6b3f5 100644 --- a/src/window_gamelist.cpp +++ b/src/window_gamelist.cpp @@ -75,6 +75,8 @@ bool Window_GameList::Refresh(FilesystemView filesystem_base, bool show_dotdot) if (HasValidEntry()) { item_max = game_directories.size(); + max_directories = item_max; + last_directory_name = Utils::LowerCase(game_directories[item_max - 1]); CreateContents(); diff --git a/src/window_gamelist.h b/src/window_gamelist.h index a3809c6f860..4c16c3c560d 100644 --- a/src/window_gamelist.h +++ b/src/window_gamelist.h @@ -59,6 +59,9 @@ class Window_GameList : public Window_Selectable { */ std::pair GetGameFilesystem() const; + int max_directories; + std::string last_directory_name; + private: FilesystemView base_fs; std::vector game_directories;