diff --git a/src/scenedit/scen.actions.cpp b/src/scenedit/scen.actions.cpp index 45f45611..aa5df3a1 100644 --- a/src/scenedit/scen.actions.cpp +++ b/src/scenedit/scen.actions.cpp @@ -92,7 +92,7 @@ ePalBtn town_buttons[6][10] = { {PAL_SPEC, PAL_COPY_SPEC, PAL_ERASE_SPEC, PAL_EDIT_SPEC, PAL_SPEC_SPOT, PAL_BOAT, PAL_HORSE, PAL_COPY_TER, PAL_CHANGE, PAL_TERRAIN}, {PAL_ROAD, PAL_WEB, PAL_CRATE, PAL_BARREL, PAL_BLOCK, PAL_EDIT_STORAGE, PAL_EDIT_ITEM, PAL_COPY_ITEM, PAL_ERASE_ITEM, PAL_ITEM}, {PAL_FIRE_BARR, PAL_FORCE_BARR, PAL_QUICKFIRE, PAL_FORCECAGE, PAL_BLANK, PAL_PASTE, PAL_EDIT_MONST, PAL_COPY_MONST, PAL_ERASE_MONST, PAL_MONST}, - {PAL_SFX_SB, PAL_SFX_MB, PAL_SFX_LB, PAL_SFX_SS, PAL_SFX_LS, PAL_SFX_ASH, PAL_SFX_BONE, PAL_SFX_ROCK, PAL_ERASE_FIELD, PAL_BLANK}, + {PAL_SFX_SB, PAL_SFX_MB, PAL_SFX_LB, PAL_SFX_SS, PAL_SFX_LS, PAL_SFX_ASH, PAL_SFX_BONE, PAL_SFX_ROCK, PAL_ERASE_FIELD, PAL_FIND_MONST}, }; rectangle working_rect; @@ -1792,11 +1792,16 @@ static bool handle_toolpal_action(location cur_point2) { mode_count = 2; set_string("Create saved item rect","Select upper left corner"); break; - case PAL_WANDER: - overall_mode = MODE_SET_WANDER_POINTS; - mode_count = 4; - set_string("Place first wandering monster arrival point",""); - break; + case PAL_FIND_MONST:{ + short which = choose_townperson(-1, nullptr); + if(which >= 0){ + cTownperson& pers = town->creatures[which]; + + cen_x = pers.start_loc.x; + cen_y = pers.start_loc.y; + redraw_screen(); + } + }break; case PAL_CHANGE: // replace terrain swap_terrain(); draw_main_screen(); diff --git a/src/scenedit/scen.global.hpp b/src/scenedit/scen.global.hpp index 400a38ba..548bddc0 100644 --- a/src/scenedit/scen.global.hpp +++ b/src/scenedit/scen.global.hpp @@ -105,9 +105,10 @@ enum eStrMode { }; enum ePalBtn { + // The organization here is terrible... the numbers are badly out of order PAL_BLANK = -1, PAL_PENCIL = 0, PAL_BRUSH_LG = 1, PAL_BRUSH_SM = 2, PAL_SPRAY_LG = 3, PAL_SPRAY_SM = 4, PAL_DROPPER = 5, PAL_RECT_HOLLOW = 6, PAL_RECT_FILLED = 7, PAL_BUCKET = 8, - PAL_ZOOM = 10, PAL_ERASER = 11, PAL_EDIT_SIGN = 12, PAL_TEXT_AREA = 13, PAL_WANDER = 14, PAL_CHANGE = 15, PAL_TOWN_BORDER = 16, PAL_EDIT_TOWN = 17, PAL_EDIT_STORAGE = 18, + PAL_ZOOM = 10, PAL_ERASER = 11, PAL_EDIT_SIGN = 12, PAL_TEXT_AREA = 13, PAL_FIND_MONST = 14, PAL_CHANGE = 15, PAL_TOWN_BORDER = 16, PAL_EDIT_TOWN = 17, PAL_EDIT_STORAGE = 18, PAL_EDIT_ITEM = 20, PAL_COPY_ITEM = 21, PAL_ERASE_ITEM = 22, PAL_SPEC = 23, PAL_COPY_SPEC = 24, PAL_PASTE = 25, PAL_ERASE_SPEC = 26, PAL_EDIT_SPEC = 27, PAL_START = 28, PAL_EDIT_MONST = 30, PAL_COPY_MONST = 31, PAL_ERASE_MONST = 32, PAL_ERASE_FIELD = 33, PAL_ENTER_N = 34, PAL_ENTER_W = 35, PAL_ENTER_S = 36, PAL_ENTER_E = 37, PAL_COPY_TER = 38, PAL_WEB = 40, PAL_CRATE = 41, PAL_BARREL = 42, PAL_FIRE_BARR = 43, PAL_FORCE_BARR = 44, PAL_QUICKFIRE = 45, PAL_SPEC_SPOT = 46, PAL_BLOCK = 47, PAL_FORCECAGE = 48, diff --git a/src/scenedit/scen.keydlgs.cpp b/src/scenedit/scen.keydlgs.cpp index d803ed7f..f07d4d60 100644 --- a/src/scenedit/scen.keydlgs.cpp +++ b/src/scenedit/scen.keydlgs.cpp @@ -1253,6 +1253,37 @@ static std::string get_control_for_field(eSpecField field) { return "num"; } +short choose_townperson(short cur_sel, cDialog* parent) { + if(cur_sel < 0) cur_sel = 0; + + std::vector pics; + std::vector labels; + for(size_t i = 0; i < town->creatures.size(); ++i){ + const cTownperson& person = town->creatures[i]; + if(person.number <= 0) { + pics.push_back(-1); + labels.push_back(""); + }else{ + const cMonster& monst = scenario.scen_monsters[person.number]; + pics.push_back(monst.picture_num); + std::string name = monst.m_name; + if(person.personality >= 0){ + int pers_town_num = person.personality / 10; + name = scenario.towns[pers_town_num]->talking.people[person.personality % 10].title; + } + // TODO use loc_str + labels.push_back(fmt::format("{} at {}", name, boost::lexical_cast(person.start_loc))); + } + } + cPictChoice choice(pics, labels, PIC_MONST, parent); + choice->getControl("prompt").setText("Select a creature:"); + if(choice.show(cur_sel)){ + return choice.getSelected(); + }else{ + return -1; + } +} + static bool edit_spec_enc_value(cDialog& me, std::string item_hit, node_stack_t& edit_stack) { std::string field = item_hit.substr(0, item_hit.find_first_of('-')); bool alt_button = item_hit.substr(item_hit.find_first_of('-') + 1) == "edit2"; @@ -1581,28 +1612,8 @@ static bool edit_spec_enc_value(cDialog& me, std::string item_hit, node_stack_t& break; } if(alt_button){ - std::vector pics; - std::vector labels; - for(size_t i = 0; i < town->creatures.size(); ++i){ - const cTownperson& person = town->creatures[i]; - if(person.number <= 0) { - pics.push_back(-1); - labels.push_back(""); - }else{ - const cMonster& monst = scenario.scen_monsters[person.number]; - pics.push_back(monst.picture_num); - std::string name = monst.m_name; - if(person.personality >= 0){ - int pers_town_num = person.personality / 10; - name = scenario.towns[pers_town_num]->talking.people[person.personality % 10].title; - } - labels.push_back(fmt::format("{} at {}", name, boost::lexical_cast(person.start_loc))); - } - } size_t sel = val < 0 ? town->creatures.size() + val : val; - cPictChoice choice(pics, labels, PIC_MONST, &me); - choice.show(sel); - size_t new_sel = choice.getSelected(); + size_t new_sel = choose_townperson(sel, &me); if(val < 0){ store = -(town->creatures.size() - new_sel); }else{ diff --git a/src/scenedit/scen.keydlgs.hpp b/src/scenedit/scen.keydlgs.hpp index 588dceb0..49a9d9a0 100644 --- a/src/scenedit/scen.keydlgs.hpp +++ b/src/scenedit/scen.keydlgs.hpp @@ -24,6 +24,8 @@ void edit_scen_intro(); bool edit_area_rect_str(info_rect_t& r); size_t num_strs(eStrMode str_mode); +short choose_townperson(short cur_sel = 0, cDialog* parent = nullptr); + pic_num_t choose_damage_type(short cur, cDialog* parent, bool allow_spec); short choose_field_type(short cur, cDialog* parent, bool includeSpec); snd_num_t choose_sound(short cur, cDialog* parent, std::string title = "Which sound?");