Skip to content

Commit

Permalink
Game_Browser - Autorun a specific game
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jetrotal committed Oct 26, 2023
1 parent 7741d74 commit 6e72644
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/scene_gamebrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,18 @@ void Scene_GameBrowser::CreateWindows() {
about_window = std::make_unique<Window_About>(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() {
Expand Down
2 changes: 2 additions & 0 deletions src/window_gamelist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
3 changes: 3 additions & 0 deletions src/window_gamelist.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ class Window_GameList : public Window_Selectable {
*/
std::pair<FilesystemView, std::string> GetGameFilesystem() const;

int max_directories;
std::string last_directory_name;

private:
FilesystemView base_fs;
std::vector<std::string> game_directories;
Expand Down

0 comments on commit 6e72644

Please sign in to comment.