quick implementation of previewing dialogxml for #564 (#565)

This commit is contained in:
2025-02-03 08:20:42 -06:00
committed by GitHub
parent 9fd468f578
commit bc5f42a870
3 changed files with 21 additions and 1 deletions

View File

@@ -1147,3 +1147,17 @@ void cDialogIterator::increment() {
parent = nullptr;
}
}
void preview_dialog_xml() {
fs::path dialog_xml = nav_get_rsrc({"xml"});
std::unique_ptr<DialogDefn> 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);
return true;
});
}
dialog.run();
}

View File

@@ -377,4 +377,7 @@ public:
// }
//}
// For development/debugging only.
void preview_dialog_xml();
#endif

View File

@@ -2356,7 +2356,7 @@ void show_debug_help() {
}
// Non-comprehensive list of unused keys:
// JUXYZ chijklnoqvy @#$-_+[]{},.'"`~/\|;:
// UXYZ chijklnoqvy @#$-_+[]{},.'"`~/\|;:
void init_debug_actions() {
add_debug_action({'B'}, "Leave town", debug_leave_town);
add_debug_action({'C'}, "Get cleaned up (lose negative status effects)", debug_clean_up);
@@ -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);