Debug action: Preview every dialog layout
This commit is contained in:
12
rsrc/dialogs/preview-dialogs-confirm.xml
Normal file
12
rsrc/dialogs/preview-dialogs-confirm.xml
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version='1.0' encoding='UTF-8' standalone='no'?>
|
||||
<?xml-stylesheet href="dialog.xsl" type="text/xsl"?>
|
||||
<dialog defbtn='no'>
|
||||
<pict type='dlog' num='7' top='6' left='6'/>
|
||||
<text name='msg' top='6' left='48' width='249' height='67'>
|
||||
You are about to preview all {{num}} dialog layouts in the game and its editors.<br/>
|
||||
<br/>
|
||||
Are you sure you want to do this?
|
||||
</text>
|
||||
<button name='no' type='regular' def-key='n' top='84' left='239'>No</button>
|
||||
<button name='yes' type='regular' def-key='y' top='84' left='172'>Yes</button>
|
||||
</dialog>
|
@@ -16,6 +16,7 @@
|
||||
#include "gfx/tiling.hpp" // for bg
|
||||
#include "fileio/resmgr/res_dialog.hpp"
|
||||
#include "sounds.hpp"
|
||||
#include "dialogxml/dialogs/choicedlog.hpp"
|
||||
#include "dialogxml/widgets/pict.hpp"
|
||||
#include "dialogxml/widgets/button.hpp"
|
||||
#include "dialogxml/widgets/field.hpp"
|
||||
@@ -1154,8 +1155,7 @@ void cDialogIterator::increment() {
|
||||
}
|
||||
}
|
||||
|
||||
void preview_dialog_xml() {
|
||||
fs::path dialog_xml = nav_get_rsrc({"xml"});
|
||||
void preview_dialog_xml(fs::path dialog_xml) {
|
||||
std::unique_ptr<DialogDefn> defn(load_dialog_defn(dialog_xml));
|
||||
cDialog dialog(*defn);
|
||||
// Make every clickable control's click event close the dialog
|
||||
@@ -1168,4 +1168,4 @@ void preview_dialog_xml() {
|
||||
}catch(...){}
|
||||
}
|
||||
dialog.run();
|
||||
}
|
||||
}
|
@@ -28,6 +28,7 @@
|
||||
#include "location.hpp"
|
||||
#include <boost/any.hpp>
|
||||
#include <boost/iterator/iterator_facade.hpp>
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include "tools/prefs.hpp"
|
||||
#include "tools/framerate_limiter.hpp"
|
||||
|
||||
@@ -380,6 +381,6 @@ public:
|
||||
//}
|
||||
|
||||
// For development/debugging only.
|
||||
void preview_dialog_xml();
|
||||
void preview_dialog_xml(fs::path dialog_xml);
|
||||
|
||||
#endif
|
||||
|
@@ -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