diff --git a/rsrc/dialogs/confirm-interrupt-replay.xml b/rsrc/dialogs/confirm-interrupt-replay.xml new file mode 100644 index 00000000..7385a54c --- /dev/null +++ b/rsrc/dialogs/confirm-interrupt-replay.xml @@ -0,0 +1,9 @@ + + + + + + Are you sure you wish to stop this replay? + + + diff --git a/rsrc/dialogs/confirm-interrupt.xml b/rsrc/dialogs/confirm-interrupt-special.xml similarity index 100% rename from rsrc/dialogs/confirm-interrupt.xml rename to rsrc/dialogs/confirm-interrupt-special.xml diff --git a/src/dialogxml/dialogs/dialog.cpp b/src/dialogxml/dialogs/dialog.cpp index 25685905..4916309b 100644 --- a/src/dialogxml/dialogs/dialog.cpp +++ b/src/dialogxml/dialogs/dialog.cpp @@ -45,6 +45,8 @@ cDialog* cDialog::topWindow = nullptr; void (*cDialog::redraw_everything)() = nullptr; std::mt19937 cDialog::ui_rand; +extern bool check_for_interrupt(std::string); + std::string cDialog::generateRandomString(){ // Not bothering to seed, because it doesn't actually matter if it's truly random. int n_chars = ui_rand() % 100; @@ -564,7 +566,10 @@ void cDialog::handle_events() { cFramerateLimiter fps_limiter; while(dialogNotToast) { - if(replaying && has_next_action("click_control")){ + if(replaying && check_for_interrupt("confirm-interrupt-replay")){ + replaying = false; + return; + }else if(replaying && has_next_action("click_control")){ Element& next_action = pop_next_action(); auto info = info_from_action(next_action); if(info["id"].empty()) continue; diff --git a/src/game/boe.actions.cpp b/src/game/boe.actions.cpp index 0913bbe1..3f6ebe1f 100644 --- a/src/game/boe.actions.cpp +++ b/src/game/boe.actions.cpp @@ -3757,11 +3757,11 @@ bool is_sign(ter_num_t ter) { return false; } -bool check_for_interrupt(){ +bool check_for_interrupt(std::string confirm_dialog){ using kb = sf::Keyboard; bool interrupt = false; sf::Event evt; - if(replaying && has_next_action() && next_action_type() == "handle_interrupt"){ + if(replaying && confirm_dialog == "confirm-interrupt-special" && has_next_action() && next_action_type() == "handle_interrupt"){ pop_next_action(); interrupt = true; } @@ -3778,7 +3778,7 @@ bool check_for_interrupt(){ if(recording){ record_action("handle_interrupt", ""); } - cChoiceDlog confirm("confirm-interrupt", {"quit","cancel"}); + cChoiceDlog confirm(confirm_dialog, {"quit","cancel"}); if(confirm.show() == "quit") return true; } return false; diff --git a/src/game/boe.actions.hpp b/src/game/boe.actions.hpp index c81587a8..e9c2b35e 100644 --- a/src/game/boe.actions.hpp +++ b/src/game/boe.actions.hpp @@ -40,7 +40,7 @@ void setup_outdoors(location where); short get_outdoor_num(); short count_walls(location loc); bool is_sign(ter_num_t ter); -bool check_for_interrupt(); +bool check_for_interrupt(std::string confirm_dialog = "confirm-interrupt-special"); void handle_startup_button_click(eStartButton btn, eKeyMod mods); void handle_switch_pc(short which_pc, bool& need_redraw, bool& need_reprint); diff --git a/src/game/boe.main.cpp b/src/game/boe.main.cpp index 5e5f5043..1f304cbb 100644 --- a/src/game/boe.main.cpp +++ b/src/game/boe.main.cpp @@ -863,6 +863,10 @@ void handle_events() { while(!All_Done) { if(replaying && has_next_action()){ + if(check_for_interrupt("confirm-interrupt-replay")){ + replaying = false; + continue; + } replay_next_action(); }else{ #ifdef __APPLE__ diff --git a/src/pcedit/pc.action.cpp b/src/pcedit/pc.action.cpp index e4d9d9b2..ebbc6e05 100644 --- a/src/pcedit/pc.action.cpp +++ b/src/pcedit/pc.action.cpp @@ -29,6 +29,8 @@ extern rectangle name_rect; extern rectangle pc_race_rect; extern rectangle edit_rect[5]; +bool check_for_interrupt(std::string) {} + bool handle_action(const sf::Event & event) { location the_point = translate_mouse_coordinates({event.mouseButton.x, event.mouseButton.y}); diff --git a/src/scenedit/scen.actions.cpp b/src/scenedit/scen.actions.cpp index b88c4a6a..e77ef64f 100644 --- a/src/scenedit/scen.actions.cpp +++ b/src/scenedit/scen.actions.cpp @@ -102,6 +102,8 @@ short special_to_paste = -1; bool monst_on_space(location loc,short m_num); static bool terrain_matches(unsigned char x, unsigned char y, ter_num_t ter); +bool check_for_interrupt(std::string) {} + void init_screen_locs() { for(short i = 0; i < 4; i++) border_rect[i] = terrain_rect;