From b76aa0e87149765a0244431e8e5da2645fb0c68e Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Mon, 26 May 2025 15:40:35 -0500 Subject: [PATCH] editor allow moving monsters in town --- rsrc/dialogs/edit-townperson.xml | 13 +++++++++---- src/scenedit/scen.townout.cpp | 15 ++++++++++++++- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/rsrc/dialogs/edit-townperson.xml b/rsrc/dialogs/edit-townperson.xml index d52b530b..330ee8aa 100644 --- a/rsrc/dialogs/edit-townperson.xml +++ b/rsrc/dialogs/edit-townperson.xml @@ -25,13 +25,9 @@ No Yes - - Creature number: - - Enter the information for this monster/townsperson. You only need to worry about the talking section if this is not a hostile monster. @@ -39,4 +35,13 @@ Talking to this creature: Leave at -1 for no pic. + + Location: + + + + + + + diff --git a/src/scenedit/scen.townout.cpp b/src/scenedit/scen.townout.cpp index fd4343c3..eb7ddb66 100644 --- a/src/scenedit/scen.townout.cpp +++ b/src/scenedit/scen.townout.cpp @@ -66,6 +66,7 @@ static void put_placed_monst_in_dlog(cDialog& me, cTownperson& monst, const shor else if((monst.facial_pic >= 1000)) dynamic_cast(me["pic"]).setPict(monst.facial_pic - 1000,PIC_CUSTOM_TALK); else dynamic_cast(me["pic"]).setPict(monst.facial_pic,PIC_TALK); + me["loc"].setText(boost::lexical_cast(monst.start_loc)); } static void get_placed_monst_in_dlog(cDialog& me, cTownperson& store_placed_monst) { @@ -73,6 +74,7 @@ static void get_placed_monst_in_dlog(cDialog& me, cTownperson& store_placed_mons store_placed_monst.mobility = dynamic_cast(me["mobility"]).getSelected()[3] - '1'; store_placed_monst.personality = me["talk"].getTextAsNum(); store_placed_monst.facial_pic = me["picnum"].getTextAsNum(); + store_placed_monst.start_loc = boost::lexical_cast(me["loc"].getText()); } static bool edit_placed_monst_event_filter(cDialog& me, std::string hit, cTownperson& monst, const short which) { @@ -106,6 +108,11 @@ static bool edit_placed_monst_event_filter(cDialog& me, std::string hit, cTownpe if(i >= 0) monst.personality = i; put_placed_monst_in_dlog(me, monst, which); + } else if(hit == "pick-loc") { + cArea* area = get_current_area(); + cLocationPicker picker(monst.start_loc, *area, "Move Creature", &me); + monst.start_loc = picker.run(); + put_placed_monst_in_dlog(me, monst, which); } else if(hit == "more") { //advanced store_m = edit_placed_monst_adv(monst, which, me); if(store_m.number != 0) @@ -117,13 +124,19 @@ static bool edit_placed_monst_event_filter(cDialog& me, std::string hit, cTownpe void edit_placed_monst(short which_m) { using namespace std::placeholders; cTownperson monst = town->creatures[which_m]; + location old_loc = monst.start_loc; cDialog edit(*ResMgr::dialogs.get("edit-townperson")); - edit.attachClickHandlers(std::bind(edit_placed_monst_event_filter, _1, _2, std::ref(monst), which_m), {"type-edit", "pict-edit", "talk-edit", "okay", "cancel", "more", "del"}); + edit.attachClickHandlers(std::bind(edit_placed_monst_event_filter, _1, _2, std::ref(monst), which_m), {"type-edit", "pict-edit", "talk-edit", "pick-loc", "okay", "cancel", "more", "del"}); put_placed_monst_in_dlog(edit, monst, which_m); edit.run(); + if(monst.start_loc != old_loc){ + // Move editor view to keep showing monster + cen_x = monst.start_loc.x; + cen_y = monst.start_loc.y; + } } static void put_placed_monst_adv_in_dlog(cDialog& me, cTownperson& monst, const short which) {