Add scene stack menu flow and restore stable TFT sync refresh

This commit is contained in:
Adolfo Reyna
2026-02-18 15:10:20 -05:00
parent a06e0d69fe
commit ebc58d7e4d
4 changed files with 366 additions and 69 deletions

View File

@@ -129,6 +129,7 @@ bool GameLauncher::update(const InputEvent& event) {
if (event.y >= y - 5 && event.y < y + MENU_ITEM_HEIGHT - 5) {
// Game selected - create instance
printf("Selected game: %s\n", games[i].name);
selected_index = i;
selected_game = games[i].factory(width, height, renderer, gui, input_manager);
if (selected_game) {
selected_game->init();
@@ -298,6 +299,30 @@ bool GameLauncher::select_game_by_name(const char* name) {
return false;
}
bool GameLauncher::restart_selected_game() {
if (selected_index < 0 || selected_index >= (int)games.size()) {
return false;
}
if (selected_game) {
delete selected_game;
selected_game = nullptr;
}
selected_game = games[selected_index].factory(width, height, renderer, gui, input_manager);
if (!selected_game) {
return false;
}
selected_game->init();
current_page = selected_index / GAMES_PER_PAGE;
return true;
}
void GameLauncher::return_to_menu() {
reset();
}
int GameLauncher::get_total_pages() const {
if (games.empty()) return 1;
return (games.size() + GAMES_PER_PAGE - 1) / GAMES_PER_PAGE;