From aa85865697a3be54829a2c27762c4ccd5447ba9a Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Wed, 3 Jul 2024 22:16:34 -0600 Subject: [PATCH] replay control clicks in open dialogs --- src/dialogxml/dialogs/dialog.cpp | 12 +++++++++++- src/dialogxml/widgets/control.cpp | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/dialogxml/dialogs/dialog.cpp b/src/dialogxml/dialogs/dialog.cpp index e1ab712dc..786ffb34a 100644 --- a/src/dialogxml/dialogs/dialog.cpp +++ b/src/dialogxml/dialogs/dialog.cpp @@ -26,6 +26,7 @@ #include "tools/cursors.hpp" #include "tools/prefs.hpp" #include "tools/framerate_limiter.hpp" +#include "replay.hpp" using namespace std; using namespace ticpp; @@ -560,7 +561,16 @@ void cDialog::handle_events() { cFramerateLimiter fps_limiter; while(dialogNotToast) { - while(win.pollEvent(currentEvent)) handle_one_event(currentEvent); + if(replaying){ + if(next_action_type() == "control_click"){ + Element* next_action = pop_next_action(); + auto info = info_from_action(next_action); + eKeyMod mods = static_cast(atoi(info["mods"].c_str())); + controls[info["id"]]->triggerClickHandler(*this, info["id"], mods); + } + }else{ + while(win.pollEvent(currentEvent)) handle_one_event(currentEvent); + } // Ideally, this should be the only draw call that is done in a cycle. draw(); diff --git a/src/dialogxml/widgets/control.cpp b/src/dialogxml/widgets/control.cpp index 404d5f299..bfe2972fc 100644 --- a/src/dialogxml/widgets/control.cpp +++ b/src/dialogxml/widgets/control.cpp @@ -18,6 +18,7 @@ #include "mathutil.hpp" #include "tools/prefs.hpp" #include "tools/cursors.hpp" +#include "replay.hpp" void cControl::setText(std::string l){ lbl = l;