From 75145a753d0c78fdd60b10d7ae41513ebdc95a9a Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Tue, 13 May 2025 11:00:00 -0500 Subject: [PATCH] Preview button reflect node field changes immediately --- src/scenedit/scen.keydlgs.cpp | 65 ++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 31 deletions(-) diff --git a/src/scenedit/scen.keydlgs.cpp b/src/scenedit/scen.keydlgs.cpp index c65b0b7b..f5cfa785 100644 --- a/src/scenedit/scen.keydlgs.cpp +++ b/src/scenedit/scen.keydlgs.cpp @@ -39,36 +39,6 @@ extern cScenario scenario; extern cOutdoors* current_terrain; extern cCustomGraphics spec_scen_g; -static bool preview_spec_enc_dlog(cDialog& me, std::string item_hit, cSpecial& special, short mode) { - eSpecCtxType cur_type = static_cast(mode); - - // Not pretty, but works: - cUniverse univ; - univ.scenario = scenario; - univ.party.town_num = cur_town; - univ.party.outdoor_corner = cur_out; - univ.party.i_w_c = {0, 0}; - - switch(special.type){ - case eSpecType::ONCE_DIALOG: - once_dialog(univ, special, cur_type, &me); - break; - default:{ - std::string str1; - std::string str2; - univ.get_strs(str1, str2, cur_type, special.m1, special.m2); - - if(str1.empty() && str2.empty()) break; - - short defaultBackground = cDialog::defaultBackground; - cDialog::defaultBackground = cDialog::BG_DARK; - cStrDlog(str1, str2, "", scenario.intro_pic, PIC_SCEN, &me).show(); - cDialog::defaultBackground = defaultBackground; - }break; - } - return true; -} - std::vector field_pics = {0,3,5,6,7,8,9,10,11,12,13,14,15,24,25,26,27,28,29,30,31,4}; std::vector static_boom_pics = {0,1,2,3,4,5}; std::vector boom_pics = {0,1,2,3,4,5,8,9,10,11,12,13}; @@ -853,6 +823,39 @@ static void save_spec_enc(cDialog& me, node_stack_t& edit_stack) { the_node.jumpto = me["jump"].getTextAsNum(); } +static bool preview_spec_enc_dlog(cDialog& me, std::string item_hit, node_stack_t& edit_stack, short mode) { + save_spec_enc(me, edit_stack); + cSpecial& special = edit_stack.top().node; + + eSpecCtxType cur_type = static_cast(mode); + + // Not pretty, but works: + cUniverse univ; + univ.scenario = scenario; + univ.party.town_num = cur_town; + univ.party.outdoor_corner = cur_out; + univ.party.i_w_c = {0, 0}; + + switch(special.type){ + case eSpecType::ONCE_DIALOG: + once_dialog(univ, special, cur_type, &me); + break; + default:{ + std::string str1; + std::string str2; + univ.get_strs(str1, str2, cur_type, special.m1, special.m2); + + if(str1.empty() && str2.empty()) break; + + short defaultBackground = cDialog::defaultBackground; + cDialog::defaultBackground = cDialog::BG_DARK; + cStrDlog(str1, str2, "", scenario.intro_pic, PIC_SCEN, &me).show(); + cDialog::defaultBackground = defaultBackground; + }break; + } + return true; +} + static bool commit_spec_enc(cDialog& me, std::string item_hit, node_stack_t& edit_stack) { if(item_hit != "unwind") save_spec_enc(me, edit_stack); @@ -1429,7 +1432,7 @@ bool edit_spec_enc(short which_node,short mode,cDialog* parent) { special["back"].hide(); edit_stack.push({which_node,mode,the_node}); - special["preview-dialog"].attachClickHandler(std::bind(preview_spec_enc_dlog, _1, _2, std::ref(edit_stack.top().node), mode)); + special["preview-dialog"].attachClickHandler(std::bind(preview_spec_enc_dlog, _1, _2, std::ref(edit_stack), mode)); put_spec_enc_in_dlog(special, edit_stack);