From 99565b5cefed46f41fc9ff403a96a26a8b820c56 Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Sat, 24 Aug 2024 11:49:39 -0500 Subject: [PATCH] record and replay File->Abort --- src/game/boe.actions.cpp | 15 +++++++++++++++ src/game/boe.actions.hpp | 1 + src/game/boe.main.cpp | 15 +++++---------- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/game/boe.actions.cpp b/src/game/boe.actions.cpp index b973eb35..f4ce79eb 100644 --- a/src/game/boe.actions.cpp +++ b/src/game/boe.actions.cpp @@ -2280,6 +2280,21 @@ void do_save(short mode) { redraw_screen(REFRESH_TEXT); } +void do_abort() { + if(recording){ + record_action("do_abort", ""); + } + if(overall_mode != MODE_STARTUP) { + std::string choice = cChoiceDlog("abort-game",{"okay","cancel"}).show(); + if (choice=="cancel") return; + reload_startup(); + overall_mode = MODE_STARTUP; + } + party_in_memory = false; + draw_startup(0); + menu_activate(); +} + void do_rest(long length, int hp_restore, int mp_restore) { unsigned long age_before = univ.party.age; univ.party.age += length; diff --git a/src/game/boe.actions.hpp b/src/game/boe.actions.hpp index 62f30d3f..ea5a4f1e 100644 --- a/src/game/boe.actions.hpp +++ b/src/game/boe.actions.hpp @@ -21,6 +21,7 @@ bool handle_scroll(const sf::Event& event); void do_load(); void post_load(); void do_save(short mode); +void do_abort(); void increase_age(); void handle_hunting(); void switch_pc(short which); diff --git a/src/game/boe.main.cpp b/src/game/boe.main.cpp index 10c75341..3d33e834 100644 --- a/src/game/boe.main.cpp +++ b/src/game/boe.main.cpp @@ -342,8 +342,12 @@ static void replay_next_action() { new_party(); }else if(t == "pick_preferences"){ pick_preferences(); + }else if(t == "do_abort"){ + do_abort(); } + // TODO some of these actions shouldn't call advance_time(). They should return + // from the function early advance_time(did_something, need_redraw, need_reprint); } @@ -658,16 +662,7 @@ void handle_menu_choice(eMenu item_hit) { new_party(); break; case eMenu::FILE_ABORT: - // TODO record and replay - if(overall_mode != MODE_STARTUP) { - std::string choice = cChoiceDlog("abort-game",{"okay","cancel"}).show(); - if (choice=="cancel") return; - reload_startup(); - overall_mode = MODE_STARTUP; - } - party_in_memory = false; - draw_startup(0); - menu_activate(); + do_abort(); break; case eMenu::PREFS: pick_preferences();