Debug action: Preview every dialog layout
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
|
||||
#include <cmath>
|
||||
#include <queue>
|
||||
#include <boost/algorithm/string/replace.hpp>
|
||||
|
||||
#include "boe.global.hpp"
|
||||
#include "tools/replay.hpp"
|
||||
@@ -2396,6 +2397,7 @@ void init_debug_actions() {
|
||||
// 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({'U'}, "Preview EVERY dialog's layout", preview_every_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);
|
||||
@@ -3934,3 +3936,33 @@ void handle_rename_pc() {
|
||||
put_pc_screen();
|
||||
put_item_screen(stat_window);
|
||||
}
|
||||
|
||||
void preview_dialog_xml() {
|
||||
fs::path dialog_xml = nav_get_rsrc({"xml"});
|
||||
preview_dialog_xml(dialog_xml);
|
||||
}
|
||||
|
||||
void preview_every_dialog_xml() {
|
||||
if(recording){
|
||||
record_action("preview_every_dialog_xml", "");
|
||||
}
|
||||
std::vector<fs::path> dialog_paths;
|
||||
fs::path dialogs_path = "data/dialogs";
|
||||
for(fs::directory_iterator it{dialogs_path}; it != fs::directory_iterator{}; ++it) {
|
||||
fs::path path = it->path();
|
||||
if(path.extension() != ".xml") continue;
|
||||
dialog_paths.push_back(path);
|
||||
}
|
||||
cChoiceDlog dlog("preview-dialogs-confirm",{"yes","no"});
|
||||
std::string text = dlog->getControl("msg").getText();
|
||||
boost::replace_first(text, "{{num}}", boost::lexical_cast<std::string>(dialog_paths.size()));
|
||||
dlog->getControl("msg").setText(text);
|
||||
std::string confirm = dlog.show();
|
||||
if(confirm == "yes"){
|
||||
std::for_each(dialog_paths.begin(), dialog_paths.end(), [](fs::path path) -> void {
|
||||
ASB("Previewing dialog: " + path.stem().string());
|
||||
print_buf();
|
||||
preview_dialog_xml(path);
|
||||
});
|
||||
}
|
||||
}
|
@@ -115,5 +115,7 @@ void close_map(bool record = false);
|
||||
void cancel_item_target(bool& did_something, bool& need_redraw, bool& need_reprint);
|
||||
void update_item_stats_area(bool& need_reprint);
|
||||
void easter_egg(int idx);
|
||||
void preview_dialog_xml();
|
||||
void preview_every_dialog_xml();
|
||||
|
||||
#endif
|
||||
|
@@ -904,6 +904,8 @@ static void replay_action(Element& action) {
|
||||
show_debug_help();
|
||||
}else if(t == "debug_fight_encounter"){
|
||||
debug_fight_encounter(str_to_bool(action.GetText()));
|
||||
}else if(t == "preview_every_dialog_xml"){
|
||||
preview_every_dialog_xml();
|
||||
}else if(t == "advance_time"){
|
||||
// This is bad regardless of strictness, because visual changes may have occurred which won't get redrawn/reprinted
|
||||
throw std::string { "Replay system internal error! advance_time() was supposed to be called by the last action, but wasn't: " } + _last_action_type;
|
||||
|
Reference in New Issue
Block a user