From bd648a936a43516b15123a2b204c745ac789c8d3 Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Sun, 2 Feb 2025 19:55:05 -0600 Subject: [PATCH] quick implementation of previewing dialogxml for #564 --- src/dialogxml/dialogs/dialog.cpp | 13 +++++++++++++ src/dialogxml/dialogs/dialog.hpp | 3 +++ src/game/boe.actions.cpp | 3 +++ 3 files changed, 19 insertions(+) diff --git a/src/dialogxml/dialogs/dialog.cpp b/src/dialogxml/dialogs/dialog.cpp index 1979c3279..039a95da6 100644 --- a/src/dialogxml/dialogs/dialog.cpp +++ b/src/dialogxml/dialogs/dialog.cpp @@ -1147,3 +1147,16 @@ void cDialogIterator::increment() { parent = nullptr; } } + +void preview_dialog_xml() { + fs::path dialog_xml = nav_get_rsrc({"xml"}); + std::unique_ptr defn(load_dialog_defn(dialog_xml)); + cDialog dialog(*defn); + // Make every control's click event close the dialog + for (auto control : dialog){ + control.second->attachClickHandler([](cDialog& me, std::string item_hit, eKeyMod mod) -> bool { + me.toast(false); + }); + } + dialog.run(); +} diff --git a/src/dialogxml/dialogs/dialog.hpp b/src/dialogxml/dialogs/dialog.hpp index a93b799f8..eac29fd76 100644 --- a/src/dialogxml/dialogs/dialog.hpp +++ b/src/dialogxml/dialogs/dialog.hpp @@ -377,4 +377,7 @@ public: // } //} +// For development/debugging only. +void preview_dialog_xml(); + #endif diff --git a/src/game/boe.actions.cpp b/src/game/boe.actions.cpp index 7a758b937..487083aee 100644 --- a/src/game/boe.actions.cpp +++ b/src/game/boe.actions.cpp @@ -2367,6 +2367,9 @@ void init_debug_actions() { add_debug_action({'H'}, "Heal", debug_heal); // This one was missing from the old help dialog: add_debug_action({'I'}, "Give item", debug_give_item); + // TODO this is not recorded or replayed because the rsrc you pick might not even be packaged + // in the build + add_debug_action({'J'}, "Preview a dialog's layout", preview_dialog_xml); add_debug_action({'K'}, "Kill everything", debug_kill); add_debug_action({'N'}, "End scenario", []() -> void {handle_victory(true);}); add_debug_action({'O'}, "Print your location", debug_print_location);