From 249e0e0027c4949456972f1a314922f085585284 Mon Sep 17 00:00:00 2001 From: Celtic Minstrel Date: Thu, 24 Sep 2015 10:13:36 -0400 Subject: [PATCH] Add UI for scenario init special and hail townsperson special --- rsrc/dialogs/edit-scenario-details.xml | 21 ++++++++++++--------- rsrc/dialogs/edit-townperson-advanced.xml | 16 +++++++++++----- src/scenedit/scen.core.cpp | 11 +++++++++++ src/scenedit/scen.townout.cpp | 17 +++++++++++++++-- 4 files changed, 49 insertions(+), 16 deletions(-) diff --git a/rsrc/dialogs/edit-scenario-details.xml b/rsrc/dialogs/edit-scenario-details.xml index 22766f94..5fe7b1f3 100644 --- a/rsrc/dialogs/edit-scenario-details.xml +++ b/rsrc/dialogs/edit-scenario-details.xml @@ -7,7 +7,7 @@ - + This is where you can define the various pieces of information the user will see when deciding whether or not to play your scenario. @@ -36,18 +36,21 @@ Very High Level (30+) Adjust difficulty if played by a party stronger than recommended - Campaign ID: - - + Special on Start: + + + Campaign ID: + + If your scenario is part of a campaign of several scenarios, the ID specified here makes it easy to carry information from one scenario to the next. It should be the same in each scenario in the series. - Default backgrounds:
+ Default backgrounds:
Set the default patterns to be shown behind the game screen.
- - - - + + + + \ No newline at end of file diff --git a/rsrc/dialogs/edit-townperson-advanced.xml b/rsrc/dialogs/edit-townperson-advanced.xml index e93eba82..efd3cbc1 100644 --- a/rsrc/dialogs/edit-townperson-advanced.xml +++ b/rsrc/dialogs/edit-townperson-advanced.xml @@ -7,8 +7,8 @@ - - + + Townsperson/monster advanced Creature type: @@ -20,15 +20,21 @@ (-1 for none) - + + Number of town special node to call before talking to creature: + (-1 for none) + + + + Stuff done flag creature's life is linked to: (0 - alive, 1 - dead), if either is -1, this is ignored. Creature and special encs. - - + + Creature number: diff --git a/src/scenedit/scen.core.cpp b/src/scenedit/scen.core.cpp index 376dd0f8..62ce5ac2 100644 --- a/src/scenedit/scen.core.cpp +++ b/src/scenedit/scen.core.cpp @@ -2774,6 +2774,7 @@ static bool save_scen_details(cDialog& me, std::string, eKeyMod) { scenario.bg_town = boost::lexical_cast(me["bg-town"].getText().substr(10)); scenario.bg_dungeon = boost::lexical_cast(me["bg-dungeon"].getText().substr(13)); scenario.bg_fight = boost::lexical_cast(me["bg-fight"].getText().substr(11)); + scenario.init_spec = me["oninit"].getTextAsNum(); return true; } @@ -2791,6 +2792,15 @@ static void put_scen_details_in_dlog(cDialog& me) { me["bg-town"].setText("In towns: " + std::to_string(scenario.bg_town)); me["bg-dungeon"].setText("In dungeons: " + std::to_string(scenario.bg_dungeon)); me["bg-fight"].setText("In combat: " + std::to_string(scenario.bg_fight)); + me["oninit"].setTextToNum(scenario.init_spec); +} + +static bool edit_scen_init_spec(cDialog& me, std::string, eKeyMod) { + int spec = me["oninit"].getTextAsNum(); + if(spec < 0) spec = get_fresh_spec(0); + if(edit_spec_enc(spec, 0, &me)) + me["oninit"].setTextToNum(spec); + return true; } static bool edit_scen_default_bgs(cDialog& me, std::string which, eKeyMod) { @@ -2821,6 +2831,7 @@ void edit_scen_details() { cDialog info_dlg("edit-scenario-details"); info_dlg["okay"].attachClickHandler(save_scen_details); info_dlg.attachClickHandlers(edit_scen_default_bgs, {"bg-out", "bg-town", "bg-dungeon", "bg-fight"}); + info_dlg["pickinit"].attachClickHandler(edit_scen_init_spec); put_scen_details_in_dlog(info_dlg); diff --git a/src/scenedit/scen.townout.cpp b/src/scenedit/scen.townout.cpp index 0c6d3276..844b2b04 100644 --- a/src/scenedit/scen.townout.cpp +++ b/src/scenedit/scen.townout.cpp @@ -131,6 +131,7 @@ static void put_placed_monst_adv_in_dlog(cDialog& me, cTownperson& monst, const me["extra2"].setTextToNum(monst.time_code); me["group"].setTextToNum(monst.spec_enc_code); me["death"].setTextToNum(monst.special_on_kill); + me["hail"].setTextToNum(monst.special_on_talk); me["sdfx"].setTextToNum(monst.spec1); me["sdfy"].setTextToNum(monst.spec2); } @@ -153,6 +154,8 @@ static bool get_placed_monst_adv_in_dlog(cDialog& me, cTownperson& monst) { if(cre(monst.time_code,0,10,"Event code must be 0 (for no event) or from 1 to 10.","",&me)) return false; monst.special_on_kill = me["death"].getTextAsNum(); if(cre(monst.special_on_kill,-1,town->specials.size(),"Town special node number must be from 0 to 99 (or -1 for no special).","",&me)) return false; + monst.special_on_talk = me["hail"].getTextAsNum(); + if(cre(monst.special_on_talk,-1,town->specials.size(),"Town special node number must be from 0 to 99 (or -1 for no special).","",&me)) return false; monst.spec1 = me["sdfx"].getTextAsNum(); if(cre(monst.spec1,-1,299,"First part of special flag must be -1 (if this is to be ignored) or from 0 to 299.","",&me)) return false; monst.spec2 = me["sdfy"].getTextAsNum(); @@ -183,7 +186,7 @@ static bool edit_placed_monst_adv_time_flag(cDialog& me, std::string, bool losin return true; } -static bool edit_placed_monst_adv_death(cDialog& me, cTownperson& monst) { +static bool edit_placed_monst_adv_death(cDialog& me) { short spec = me["death"].getTextAsNum(); if(spec < 0) spec = get_fresh_spec(2); @@ -192,13 +195,23 @@ static bool edit_placed_monst_adv_death(cDialog& me, cTownperson& monst) { return true; } +static bool edit_placed_monst_adv_hail(cDialog& me) { + short spec = me["hail"].getTextAsNum(); + if(spec < 0) + spec = get_fresh_spec(2); + if(edit_spec_enc(spec,2,&me)) + me["hail"].setTextToNum(spec); + return true; +} + cTownperson edit_placed_monst_adv(cTownperson initial, short which, cDialog& parent) { using namespace std::placeholders; cDialog edit("edit-townperson-advanced", &parent); edit["okay"].attachClickHandler(std::bind(edit_placed_monst_adv_event_filter, _1, _2, std::ref(initial))); edit["cancel"].attachClickHandler(std::bind(edit_placed_monst_adv_event_filter, _1, _2, std::ref(initial))); - edit["editdeath"].attachClickHandler(std::bind(edit_placed_monst_adv_death, _1, std::ref(initial))); + edit["editdeath"].attachClickHandler(std::bind(edit_placed_monst_adv_death, _1)); + edit["edithail"].attachClickHandler(std::bind(edit_placed_monst_adv_hail, _1)); edit["time"].attachFocusHandler(edit_placed_monst_adv_time_flag); put_placed_monst_adv_in_dlog(edit,initial,which);