From 2513fc113b0d203627303d83eb8dc8eefc421780 Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Fri, 23 Aug 2024 21:00:05 -0500 Subject: [PATCH] record and replay several help dialogs --- src/game/boe.actions.cpp | 20 ++++++++++++++------ src/game/boe.actions.hpp | 1 + src/game/boe.main.cpp | 2 ++ 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/game/boe.actions.cpp b/src/game/boe.actions.cpp index 873f64a3..12c3447c 100644 --- a/src/game/boe.actions.cpp +++ b/src/game/boe.actions.cpp @@ -237,6 +237,14 @@ void init_screen_locs() { pc_help_button.right = 267; } +// Some actions directly show a dialog. This handles that, and records it. +void show_dialog_action(std::string xml_file) { + if(recording){ + record_action("show_dialog_action", xml_file); + } + cChoiceDlog(xml_file).show(); +} + bool prime_time() { return overall_mode == MODE_OUTDOORS || overall_mode == MODE_TOWN || overall_mode == MODE_COMBAT; } @@ -1343,7 +1351,7 @@ bool handle_action(const sf::Event& event, cFramerateLimiter& fps_limiter) { rectangle help_button = pc_help_button; help_button.offset(pc_win_ul); arrow_button_click(help_button); - cChoiceDlog("help-party").show(); + show_dialog_action("help-party"); } for(int i = 0; i < 6; i++) for(auto j : pc_buttons[i].keys()) @@ -1415,7 +1423,7 @@ bool handle_action(const sf::Event& event, cFramerateLimiter& fps_limiter) { set_stat_window(ITEM_WIN_QUESTS); break; case 8: // help - cChoiceDlog("help-inventory").show(); + show_dialog_action("help-inventory"); break; default: handle_switch_pc_items(i, need_redraw); @@ -1778,9 +1786,9 @@ bool handle_keystroke(const sf::Event& event, cFramerateLimiter& fps_limiter){ give_help(205,6); break; } - if(is_out()) cChoiceDlog("help-outdoor").show(); - if(is_town()) cChoiceDlog("help-town").show(); - if(is_combat()) cChoiceDlog("help-combat").show(); + if(is_out()) show_dialog_action("help-outdoor"); + if(is_town()) show_dialog_action("help-town"); + if(is_combat()) show_dialog_action("help-combat"); break; case '1': case '2': case '3': case '4': case '5': case '6': @@ -2066,7 +2074,7 @@ bool handle_keystroke(const sf::Event& event, cFramerateLimiter& fps_limiter){ break; case '/': if(!univ.debug_mode) break; - cChoiceDlog("help-debug").show(); + show_dialog_action("help-debug"); break; case 'a': // Show automap if(overall_mode == MODE_TOWN || overall_mode == MODE_OUTDOORS) diff --git a/src/game/boe.actions.hpp b/src/game/boe.actions.hpp index fe86ace9..a469922f 100644 --- a/src/game/boe.actions.hpp +++ b/src/game/boe.actions.hpp @@ -52,5 +52,6 @@ void handle_get_items(bool& did_something, bool& need_redraw, bool& need_reprint void handle_drop_item(short item_hit, bool& need_redraw); void handle_drop_item(location destination, bool& need_redraw); void handle_give_item(short item_hit, bool& did_something, bool& need_redraw); +void show_dialog_action(std::string xml_file); #endif diff --git a/src/game/boe.main.cpp b/src/game/boe.main.cpp index bb8427d8..a8c9e61a 100644 --- a/src/game/boe.main.cpp +++ b/src/game/boe.main.cpp @@ -334,6 +334,8 @@ static void replay_next_action() { std::istringstream sstr(next_action.GetText()); sstr >> button_rect; arrow_button_click(button_rect); + }else if(t == "show_dialog_action"){ + show_dialog_action(next_action.GetText()); } advance_time(did_something, need_redraw, need_reprint);