Dialog XML definitions are now loaded thru the resource manager

This commit is contained in:
2023-01-07 11:59:42 -05:00
parent c3dd886783
commit e3d6a4748e
25 changed files with 222 additions and 108 deletions

View File

@@ -26,6 +26,7 @@
#include "dialogxml/dialogs/strchoice.hpp"
#include "fileio/fileio.hpp"
#include "dialogxml/widgets/field.hpp"
#include "fileio/resmgr/res_dialog.hpp"
#include "fileio/resmgr/res_strings.hpp"
#include "fileio/resmgr/res_image.hpp"
#include "fileio/resmgr/res_sound.hpp"
@@ -460,7 +461,7 @@ static bool finish_editing_ter(cDialog& me, std::string id, ter_num_t& which) {
static bool edit_ter_obj(cDialog& me, ter_num_t which_ter) {
cTerrain& ter = scenario.ter_types[which_ter];
const pic_num_t pic = ter.picture;
cDialog obj_dlg("edit-ter-obj", &me);
cDialog obj_dlg(*ResMgr::dialogs.get("edit-ter-obj"), &me);
obj_dlg.attachFocusHandlers([&pic](cDialog& me, std::string fld, bool losing) -> bool {
if(!losing) return true;
int id = me["id"].getTextAsNum();
@@ -558,7 +559,7 @@ static bool play_ter_step_sound(cDialog& me, std::string id, bool losing) {
bool edit_ter_type(ter_num_t which) {
using namespace std::placeholders;
ter_num_t first = which;
cDialog ter_dlg("edit-terrain");
cDialog ter_dlg(*ResMgr::dialogs.get("edit-terrain"));
// Attach handlers
ter_dlg["pict"].attachFocusHandler(std::bind(check_range,_1,_2,_3,0,2999,"terrain graphic"));
ter_dlg["pickpict"].attachClickHandler(std::bind(pick_picture,PIC_TER,_1,"pict","graphic"));
@@ -822,7 +823,7 @@ static bool edit_monst_type_event_filter(cDialog& me,std::string hit,cMonster& m
put_monst_info_in_dlog(me,monst,which);
}
} else if(hit == "preview") {
cDialog monstInfo("monster-info", &me);
cDialog monstInfo(*ResMgr::dialogs.get("monster-info"), &me);
monstInfo["left"].hide();
monstInfo["right"].hide();
monstInfo.attachClickHandlers([](cDialog&,std::string,eKeyMod){return false;}, {"guard","mindless","invuln"});
@@ -851,7 +852,7 @@ bool edit_monst_type(short which) {
mon_num_t first = which;
cMonster monst = scenario.scen_monsters[which];
cDialog monst_dlg("edit-monster");
cDialog monst_dlg(*ResMgr::dialogs.get("edit-monster"));
monst_dlg["pickicon"].attachClickHandler(std::bind(pick_monst_picture,_1));
monst_dlg["picktalk"].attachClickHandler(std::bind(pick_picture,PIC_TALK,_1,"talk","talkpic"));
monst_dlg["cancel"].attachClickHandler(std::bind(&cDialog::toast, &monst_dlg, false));
@@ -997,7 +998,7 @@ static bool edit_monst_abil_event_filter(cDialog& me,std::string hit,cMonster& m
}
static short get_monst_abil_num(std::string prompt, int min, int max, cDialog& parent, int cur = -1) {
cDialog numPanel("get-mabil-num", &parent);
cDialog numPanel(*ResMgr::dialogs.get("get-mabil-num"), &parent);
numPanel["okay"].attachClickHandler(std::bind(&cDialog::toast, &numPanel, false));
numPanel["prompt"].setText(prompt + " (" + std::to_string(min) + "-" + std::to_string(max) + ") ");
numPanel["number"].setTextToNum(minmax(min,max,cur));
@@ -1238,7 +1239,7 @@ static bool edit_monst_abil_detail(cDialog& me, std::string hit, cMonster& monst
case eMonstAbilCat::SPECIAL: break;
}
using namespace std::placeholders;
cDialog abil_dlg("edit-mabil-" + which_dlg, &me);
cDialog abil_dlg(*ResMgr::dialogs.get("edit-mabil-" + which_dlg), &me);
abil_dlg["okay"].attachClickHandler(std::bind(&cDialog::toast, _1, true));
abil_dlg["cancel"].attachClickHandler(std::bind(&cDialog::toast, _1, false));
abil_dlg["delete"].attachClickHandler([&monst,&iter](cDialog& me,std::string,eKeyMod){
@@ -1381,7 +1382,7 @@ static bool edit_monst_abil_detail(cDialog& me, std::string hit, cMonster& monst
cMonster edit_monst_abil(cMonster initial,short which,cDialog& parent) {
using namespace std::placeholders;
cDialog monst_dlg("edit-monster-abils",&parent);
cDialog monst_dlg(*ResMgr::dialogs.get("edit-monster-abils"),&parent);
monst_dlg["loot-item"].attachFocusHandler(std::bind(check_range_msg, _1, _2, _3, -1, 399, "Item To Drop", "-1 for no item"));
monst_dlg["loot-chance"].attachFocusHandler(std::bind(check_range_msg, _1, _2, _3, -1, 100, "Dropping Chance", "-1 for no item"));
monst_dlg.attachClickHandlers(std::bind(edit_monst_abil_detail, _1, _2, std::ref(initial)), {"abil-edit1", "abil-edit2", "abil-edit3", "abil-edit4"});
@@ -1653,7 +1654,7 @@ static bool edit_item_type_event_filter(cDialog& me, std::string hit, cItem& ite
if(i < 0) return true;
item.missile = i;
} else if(hit == "desc") {
cDialog desc_dlg("edit-text", &me);
cDialog desc_dlg(*ResMgr::dialogs.get("edit-text"), &me);
desc_dlg["left"].hide();
desc_dlg["right"].hide();
desc_dlg["okay"].attachClickHandler(std::bind(&cDialog::toast, &desc_dlg, true));
@@ -1680,7 +1681,7 @@ static bool edit_item_type_event_filter(cDialog& me, std::string hit, cItem& ite
} else if(hit == "preview") {
cItem temp_item = item;
temp_item.ident = true;
cDialog itemInfo("item-info", &me);
cDialog itemInfo(*ResMgr::dialogs.get("item-info"), &me);
itemInfo["left"].hide();
itemInfo["right"].hide();
itemInfo["done"].attachClickHandler(std::bind(&cDialog::toast, &itemInfo, false));
@@ -1734,7 +1735,7 @@ bool edit_item_type(short which) {
scenario.scen_items.resize(which + 1);
cItem item = scenario.scen_items[which];
cDialog item_dlg("edit-item");
cDialog item_dlg(*ResMgr::dialogs.get("edit-item"));
item_dlg["level"].attachFocusHandler(std::bind(check_range, _1, _2, _3, 0, 50, "Item Level"));
item_dlg["awkward"].attachFocusHandler(std::bind(check_range, _1, _2, _3, 0, 20, "Awkward"));
item_dlg["bonus"].attachFocusHandler(std::bind(check_range, _1, _2, _3, 0, 60, "Bonus"));
@@ -1970,7 +1971,7 @@ static bool edit_item_abil_event_filter(cDialog& me, std::string hit, cItem& ite
cItem edit_item_abil(cItem initial,short which_item,cDialog& parent) {
using namespace std::placeholders;
cDialog item_dlg("edit-item-abils",&parent);
cDialog item_dlg(*ResMgr::dialogs.get("edit-item-abils"),&parent);
item_dlg.attachClickHandlers(std::bind(edit_item_abil_event_filter, _1, _2, std::ref(initial), which_item), {
"okay", "cancel",
"clear", "weapon", "general", "usable", "reagent",
@@ -2041,7 +2042,7 @@ bool edit_spec_item(short which_item) {
using namespace std::placeholders;
cSpecItem item = scenario.special_items[which_item];
cDialog item_dlg("edit-special-item");
cDialog item_dlg(*ResMgr::dialogs.get("edit-special-item"));
item_dlg["spec"].attachFocusHandler(std::bind(check_range_msg, _1, _2, _3, -1, scenario.scen_specials.size(), "Scenario special node called", "-1 for no special"));
item_dlg.attachClickHandlers(std::bind(edit_spec_item_event_filter, _1, _2, std::ref(item), std::ref(which_item)), {"okay", "cancel", "clear", "edit-spec"});
@@ -2133,7 +2134,7 @@ bool edit_quest(size_t which_quest) {
}
cQuest quest = scenario.quests[which_quest];
cDialog quest_dlg("edit-quest");
cDialog quest_dlg(*ResMgr::dialogs.get("edit-quest"));
quest_dlg["cancel"].attachClickHandler(std::bind(&cDialog::toast, _1, false));
quest_dlg["okay"].attachClickHandler(std::bind(save_quest_from_dlog, _1, std::ref(quest), std::ref(which_quest), true));
quest_dlg["inbank"].attachFocusHandler([](cDialog& me, std::string, bool losing) -> bool {
@@ -2281,7 +2282,7 @@ static bool change_shop_dlog_items_page(cDialog& me, std::string dir, const cSho
static void edit_shop_item(cDialog& parent, size_t& item, size_t& quantity, bool optional) {
using namespace std::placeholders;
int was_item = item;
cDialog item_dlg("edit-shop-item", &parent);
cDialog item_dlg(*ResMgr::dialogs.get("edit-shop-item"), &parent);
item_dlg["cancel"].attachClickHandler(std::bind(&cDialog::toast, _1, false));
item_dlg["okay"].attachClickHandler(std::bind(&cDialog::toast, _1, true));
@@ -2313,7 +2314,7 @@ static void edit_shop_item(cDialog& parent, size_t& item, size_t& quantity, bool
static void edit_shop_special(cDialog& parent, cItem& item, size_t& quantity) {
using namespace std::placeholders;
cDialog spec_dlg("edit-shop-special", &parent);
cDialog spec_dlg(*ResMgr::dialogs.get("edit-shop-special"), &parent);
spec_dlg["cancel"].attachClickHandler(std::bind(&cDialog::toast, _1, false));
spec_dlg["okay"].attachClickHandler(std::bind(&cDialog::toast, _1, true));
spec_dlg["cost"].attachFocusHandler(std::bind(check_range, _1, _2, _3, 0, 10000, "cost"));
@@ -2479,7 +2480,7 @@ bool edit_shop(size_t which_shop, cDialog* parent) {
scenario.shops.emplace_back("New Shop");
cShop shop = scenario.shops[which_shop];
cDialog shop_dlg("edit-shop", parent);
cDialog shop_dlg(*ResMgr::dialogs.get("edit-shop"), parent);
shop_dlg["cancel"].attachClickHandler(std::bind(&cDialog::toast, _1, false));
shop_dlg["okay"].attachClickHandler(std::bind(save_shop_from_dlog, _1, std::ref(shop), std::ref(which_shop), true));
shop_dlg["pickface"].attachClickHandler(std::bind(pick_picture, PIC_TALK, _1, "", "face"));
@@ -2558,7 +2559,7 @@ static bool edit_save_rects_event_filter(cDialog& me, std::string item_hit) {
void edit_save_rects() {
using namespace std::placeholders;
cDialog save_dlg("edit-save-rects");
cDialog save_dlg(*ResMgr::dialogs.get("edit-save-rects"));
save_dlg.attachClickHandlers(std::bind(edit_save_rects_event_filter, _1, _2), {"okay"});
put_save_rects_in_dlog(save_dlg);
@@ -2578,7 +2579,7 @@ static void put_vehicle_area(cDialog& me, const cVehicle& what) {
bool edit_vehicle(cVehicle& what, int num, bool is_boat) {
using namespace std::placeholders;
cDialog dlg("edit-vehicle");
cDialog dlg(*ResMgr::dialogs.get("edit-vehicle"));
dlg["okay"].attachClickHandler(std::bind(&cDialog::toast, &dlg, true));
dlg["cancel"].attachClickHandler(std::bind(&cDialog::toast, &dlg, false));
dlg["del"].attachClickHandler([](cDialog& me, std::string, eKeyMod) {
@@ -2642,7 +2643,7 @@ static bool edit_add_town_event_filter(cDialog& me, std::string hit) {
void edit_add_town() {
using namespace std::placeholders;
cDialog vary_dlg("edit-town-varying");
cDialog vary_dlg(*ResMgr::dialogs.get("edit-town-varying"));
vary_dlg.attachClickHandlers(std::bind(edit_add_town_event_filter, _1, _2), {"okay"});
put_add_town_in_dlog(vary_dlg);
@@ -2726,7 +2727,7 @@ void edit_item_placement() {
cScenario::cItemStorage storage = scenario.storage_shortcuts[0];
short cur_shortcut = 0;
cDialog shortcut_dlg("edit-item-shortcut");
cDialog shortcut_dlg(*ResMgr::dialogs.get("edit-item-shortcut"));
shortcut_dlg.attachClickHandlers(std::bind(edit_item_placement_event_filter, _1, _2, std::ref(storage), std::ref(cur_shortcut)), {"okay", "cancel", "left", "right", "choose-ter"});
for(int i = 0; i < 10; i++) {
std::string id = "choose-item" + std::to_string(i + 1);
@@ -2818,7 +2819,7 @@ static bool edit_scen_default_bgs(cDialog& me, std::string which, eKeyMod) {
}
void edit_scen_details() {
cDialog info_dlg("edit-scenario-details");
cDialog info_dlg(*ResMgr::dialogs.get("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);
@@ -2829,7 +2830,7 @@ void edit_scen_details() {
}
bool edit_make_scen_1(std::string& author,std::string& title,bool& grass) {
cDialog new_dlog("make-scenario1");
cDialog new_dlog(*ResMgr::dialogs.get("make-scenario1"));
new_dlog["okay"].attachClickHandler(std::bind(&cDialog::toast, &new_dlog, true));
new_dlog["cancel"].attachClickHandler(std::bind(&cDialog::toast, &new_dlog, false));
@@ -2872,7 +2873,7 @@ static bool make_scen_check_towns(cDialog& me, std::string which, bool losing) {
}
bool edit_make_scen_2(short& out_w, short& out_h, short& town_l, short& town_m, short& town_s, bool& def_town) {
cDialog new_dlog("make-scenario2");
cDialog new_dlog(*ResMgr::dialogs.get("make-scenario2"));
new_dlog["okay"].attachClickHandler(std::bind(&cDialog::toast, &new_dlog, true));
new_dlog["cancel"].attachClickHandler(std::bind(&cDialog::toast, &new_dlog, false));
new_dlog.attachFocusHandlers(make_scen_check_towns, {"town-s", "town-m", "town-l"});
@@ -3137,7 +3138,7 @@ static bool edit_scenario_events_event_filter(cDialog& me, std::string item_hit,
void edit_scenario_events() {
using namespace std::placeholders;
cDialog evt_dlg("edit-scenario-events");
cDialog evt_dlg(*ResMgr::dialogs.get("edit-scenario-events"));
evt_dlg["okay"].attachClickHandler(save_scenario_events);
// TODO: There are 20 events, not 10; allow editing the rest?
for(int i = 0; i < scenario.scenario_timers.size() && i < 10; i++) {
@@ -3291,7 +3292,7 @@ void edit_custom_pics_types() {
std::vector<ePicType> pics = scenario.custom_graphics;
pic_num_t first_pic = 0;
cDialog pic_dlg("graphic-types");
cDialog pic_dlg(*ResMgr::dialogs.get("graphic-types"));
for(int i = 0; i < 10; i++) {
std::string id = std::to_string(i + 1);
pic_dlg["type" + id].attachFocusHandler(std::bind(set_custom_pic_type, _1, _2, std::ref(pics), std::ref(first_pic)));
@@ -3372,7 +3373,7 @@ void edit_custom_sheets() {
using namespace std::placeholders;
cDialog pic_dlg("graphic-sheets");
cDialog pic_dlg(*ResMgr::dialogs.get("graphic-sheets"));
pic_dlg["cancel"].attachClickHandler(std::bind(&cDialog::toast, _1, false));
pic_dlg["okay"].attachClickHandler(std::bind(&cDialog::toast, _1, true));
pic_dlg["copy"].attachClickHandler([&sheets,&cur,&all_pics,&pic_dir](cDialog&, std::string, eKeyMod) -> bool {
@@ -3623,7 +3624,7 @@ static void get_sound_names_from_dlg(cDialog& me, std::vector<std::string>& snd_
}
void edit_custom_sounds() {
cDialog snd_dlg("edit-sounds");
cDialog snd_dlg(*ResMgr::dialogs.get("edit-sounds"));
snd_dlg["cancel"].attachClickHandler(std::bind(&cDialog::toast, &snd_dlg, false));
snd_dlg["okay"].attachClickHandler(std::bind(&cDialog::toast, &snd_dlg, true));

View File

@@ -18,6 +18,7 @@
#include "dialogxml/dialogs/3choice.hpp"
#include "dialogxml/dialogs/strchoice.hpp"
#include "dialogxml/dialogs/pictchoice.hpp"
#include "fileio/resmgr/res_dialog.hpp"
#include "fileio/resmgr/res_strings.hpp"
#include "spell.hpp"
#include "gfx/render_shapes.hpp" // for colour constants
@@ -121,7 +122,7 @@ bool cre(short val,short min,short max,std::string text1,std::string text2,cDial
}
short choose_background(short cur_choice, cDialog* parent) {
cDialog bg_dlg("choose-bg",parent);
cDialog bg_dlg(*ResMgr::dialogs.get("choose-bg"),parent);
auto get_selected = [&]() -> short {
std::string sel = dynamic_cast<cLedGroup&>(bg_dlg["group"]).getSelected();
if(sel.empty()) return -1;
@@ -467,7 +468,7 @@ bool edit_text_str(short which_str,eStrMode mode) {
using namespace std::placeholders;
short first = which_str;
cDialog dlog("edit-text");
cDialog dlog(*ResMgr::dialogs.get("edit-text"));
dlog.attachClickHandlers(std::bind(edit_text_event_filter, _1, _2, std::ref(which_str), mode), {"okay", "left", "right"});
dlog["cancel"].attachClickHandler(std::bind(&cDialog::toast, _1, false));
@@ -495,7 +496,7 @@ static bool edit_area_rect_event_filter(cDialog& me, std::string item_hit, info_
bool edit_area_rect_str(info_rect_t& r) {
using namespace std::placeholders;
cDialog dlog("set-area-desc");
cDialog dlog(*ResMgr::dialogs.get("set-area-desc"));
dlog.attachClickHandlers(std::bind(edit_area_rect_event_filter, _1, _2, std::ref(r)), {"okay", "cancel"});
dlog["area"].setText(r.descr);
@@ -966,7 +967,7 @@ bool edit_spec_enc(short which_node,short mode,cDialog* parent) {
the_node = town->specials[which_node];
}
cDialog special("edit-special-node",parent);
cDialog special(*ResMgr::dialogs.get("edit-special-node"),parent);
special.attachClickHandlers(std::bind(commit_spec_enc, _1, _2, std::ref(edit_stack)), {"okay", "back"});
special.attachClickHandlers(std::bind(edit_spec_enc_type, _1, _2, std::ref(edit_stack)), {
"general", "oneshot", "affectpc", "ifthen", "town", "out", "rect"
@@ -1061,7 +1062,8 @@ static bool edit_spec_text_event_filter(cDialog& me, std::string item_hit, eStrM
void edit_spec_text(eStrMode mode,short *str1,short *str2,cDialog* parent) {
using namespace std::placeholders;
cDialog edit(str2 ? "edit-special-text" : "edit-special-text-sm", parent);
std::string dlog_id = str2 ? "edit-special-text" : "edit-special-text-sm";
cDialog edit(*ResMgr::dialogs.get(dlog_id), parent);
edit.attachClickHandlers(std::bind(edit_spec_text_event_filter, _1, _2, mode, str1, str2), {"okay", "cancel"});
if(*str1 >= num_strs(mode))
@@ -1126,7 +1128,7 @@ void edit_dialog_text(eStrMode mode,short *str1,cDialog* parent) {
}
using namespace std::placeholders;
cDialog edit("edit-dialog-text",parent);
cDialog edit(*ResMgr::dialogs.get("edit-dialog-text"),parent);
edit.attachClickHandlers(std::bind(edit_dialog_text_event_filter, _1, _2, mode, str1), {"okay", "cancel"});
if(*str1 >= 0) {
@@ -1165,7 +1167,7 @@ static bool edit_special_num_event_filter(cDialog& me, std::string item_hit, sho
short edit_special_num(short mode,short what_start) {
using namespace std::placeholders;
cDialog edit("edit-special-assign");
cDialog edit(*ResMgr::dialogs.get("edit-special-assign"));
edit.attachClickHandlers(std::bind(edit_special_num_event_filter, _1, _2, mode), {"okay", "cancel"});
edit["num"].setTextToNum(what_start);
@@ -1201,7 +1203,7 @@ static bool edit_scen_intro_event_filter(cDialog& me, std::string item_hit, eKey
}
void edit_scen_intro() {
cDialog edit("edit-intro");
cDialog edit(*ResMgr::dialogs.get("edit-intro"));
edit.attachClickHandlers(edit_scen_intro_event_filter, {"okay", "cancel", "choose"});
edit["picnum"].setTextToNum(scenario.intro_pic);

View File

@@ -23,6 +23,7 @@
#include "dialogxml/widgets/stack.hpp"
#include "dialogxml/widgets/scrollpane.hpp"
#include "fileio/fileio.hpp"
#include "fileio/resmgr/res_dialog.hpp"
extern short cen_x, cen_y, overall_mode;
extern bool mouse_button_held,editing_town,change_made;
@@ -107,7 +108,7 @@ void edit_placed_monst(short which_m) {
using namespace std::placeholders;
cTownperson monst = town->creatures[which_m];
cDialog edit("edit-townperson");
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"});
put_placed_monst_in_dlog(edit, monst, which_m);
@@ -213,7 +214,7 @@ static bool edit_placed_monst_adv_hail(cDialog& me) {
cTownperson edit_placed_monst_adv(cTownperson initial, short which, cDialog& parent) {
using namespace std::placeholders;
cDialog edit("edit-townperson-advanced", &parent);
cDialog edit(*ResMgr::dialogs.get("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));
@@ -333,7 +334,7 @@ void edit_placed_item(short which_i) {
cTown::cItem item = town->preset_items[which_i];
cDialog item_dlg("edit-placed-item");
cDialog item_dlg(*ResMgr::dialogs.get("edit-placed-item"));
item_dlg["cancel"].attachClickHandler(std::bind(&cDialog::toast, &item_dlg, false));
item_dlg["okay"].attachClickHandler(std::bind(get_placed_item_in_dlog, _1, std::ref(item), which_i));
item_dlg["choose"].attachClickHandler(std::bind(edit_placed_item_type, _1, std::ref(item), which_i));
@@ -365,7 +366,7 @@ void edit_sign(sign_loc_t& which_sign,short num,short picture) {
using namespace std::placeholders;
location view_loc;
cDialog sign_dlg("edit-sign");
cDialog sign_dlg(*ResMgr::dialogs.get("edit-sign"));
sign_dlg["cancel"].attachClickHandler(std::bind(&cDialog::toast, &sign_dlg, false));
sign_dlg["okay"].attachClickHandler(std::bind(edit_sign_event_filter, _1, std::ref(which_sign)));
cPict& icon = dynamic_cast<cPict&>(sign_dlg["pic"]);
@@ -389,7 +390,7 @@ static bool save_town_num(cDialog& me, std::string, eKeyMod) {
short pick_town_num(std::string which_dlog,short def,cScenario& scenario) {
using namespace std::placeholders;
cDialog town_dlg(which_dlog);
cDialog town_dlg(*ResMgr::dialogs.get(which_dlog));
town_dlg["cancel"].attachClickHandler(std::bind(&cDialog::toast, &town_dlg, false));
town_dlg["okay"].attachClickHandler(save_town_num);
town_dlg["town"].attachFocusHandler(std::bind(check_range, _1, _2, _3, 0, scenario.towns.size() - 1, "Town number"));
@@ -430,7 +431,7 @@ static bool save_ter_change(cDialog& me, std::string, eKeyMod) {
bool change_ter(short& change_from,short& change_to,short& chance) {
using namespace std::placeholders;
cDialog chg_dlg("change-terrain");
cDialog chg_dlg(*ResMgr::dialogs.get("change-terrain"));
chg_dlg["cancel"].attachClickHandler(std::bind(&cDialog::toast, &chg_dlg, false));
chg_dlg["okay"].attachClickHandler(save_ter_change);
chg_dlg["chance"].attachFocusHandler(std::bind(check_range, _1, _2, _3, 0, 100, "The chance"));
@@ -458,7 +459,7 @@ static bool outdoor_details_event_filter(cDialog& me, std::string, eKeyMod) {
}
void outdoor_details() {
cDialog out_dlg("edit-outdoor-details");
cDialog out_dlg(*ResMgr::dialogs.get("edit-outdoor-details"));
out_dlg["okay"].attachClickHandler(outdoor_details_event_filter);
std::ostringstream str_out;
str_out << "X = " << cur_out.x << ", Y = " << cur_out.y;
@@ -606,7 +607,7 @@ void edit_out_wand(short mode) {
short which = 0;
cOutdoors::cWandering wand = (mode == 0) ? current_terrain->wandering[0] : current_terrain->special_enc[0];
cDialog wand_dlg("edit-outdoor-encounter");
cDialog wand_dlg(*ResMgr::dialogs.get("edit-outdoor-encounter"));
wand_dlg["cancel"].attachClickHandler(std::bind(&cDialog::toast, &wand_dlg, false));
wand_dlg["endx"].attachFocusHandler(std::bind(check_range_msg, _1, _2, _3, -1, 299, "First part of Stuff Done flag", "-1 if not used"));
@@ -666,7 +667,7 @@ static void put_town_details_in_dlog(cDialog& me) {
void edit_town_details() {
using namespace std::placeholders;
cDialog town_dlg("edit-town-details");
cDialog town_dlg(*ResMgr::dialogs.get("edit-town-details"));
town_dlg["okay"].attachClickHandler(save_town_details);
town_dlg["chop"].attachFocusHandler(std::bind(check_range_msg, _1, _2, _3, -1, 10000, "The day the town becomes abandoned", "-1 if it doesn't"));
town_dlg["key"].attachFocusHandler(std::bind(check_range_msg, _1, _2, _3, -1, 10, "The event which prevents the town from becoming abandoned", "-1 or 0 for none"));
@@ -714,7 +715,7 @@ static bool edit_town_events_event_filter(cDialog& me, std::string item_hit, eKe
void edit_town_events() {
using namespace std::placeholders;
cDialog evt_dlg("edit-town-events");
cDialog evt_dlg(*ResMgr::dialogs.get("edit-town-events"));
evt_dlg["okay"].attachClickHandler(save_town_events);
evt_dlg.attachClickHandlers(edit_town_events_event_filter, {"edit1", "edit2", "edit3", "edit4", "edit5", "edit6", "edit7", "edit8"});
evt_dlg.attachFocusHandlers(std::bind(check_range_msg, _1, _2, _3, -1, town->specials.size(), "The town special node", "-1 for no special"), {"spec1", "spec2", "spec3", "spec4", "spec5", "spec6", "spec7", "spec8"});
@@ -778,7 +779,7 @@ static bool edit_advanced_town_special(cDialog& me, std::string hit, eKeyMod) {
void edit_advanced_town() {
using namespace std::placeholders;
cDialog town_dlg("edit-town-advanced");
cDialog town_dlg(*ResMgr::dialogs.get("edit-town-advanced"));
town_dlg["okay"].attachClickHandler(save_advanced_town);
town_dlg["cancel"].attachClickHandler(std::bind(&cDialog::toast, &town_dlg, false));
auto loc_check = std::bind(check_range_msg, _1, _2, _3, -1, 47, "The town exit coordinates", "-1 if you want them ignored");
@@ -849,7 +850,7 @@ static bool edit_town_wand_event_filter(cDialog& me, std::string item_hit, eKeyM
void edit_town_wand() {
using namespace std::placeholders;
cDialog wand_dlg("edit-town-wandering");
cDialog wand_dlg(*ResMgr::dialogs.get("edit-town-wandering"));
wand_dlg["okay"].attachClickHandler(save_town_wand);
auto check_monst = std::bind(check_range_msg, _1, _2, _3, 0, 255, "Wandering monsters", "0 means no monster");
// Just go through and attach the same focus handler to ALL text fields.
@@ -904,7 +905,7 @@ static bool edit_basic_dlog_event_filter(cDialog& me, std::string hit, short& wh
void edit_basic_dlog(short personality) {
using namespace std::placeholders;
cDialog person_dlg("edit-personality");
cDialog person_dlg(*ResMgr::dialogs.get("edit-personality"));
person_dlg["cancel"].attachClickHandler(std::bind(&cDialog::toast, &person_dlg, false));
person_dlg.attachClickHandlers(std::bind(edit_basic_dlog_event_filter, _1, _2, std::ref(personality)), {"left", "right", "okay"});
@@ -1204,7 +1205,7 @@ short edit_talk_node(short which_node) {
std::stack<node_ref_t> talk_edit_stack;
talk_edit_stack.push({which_node, town->talking.talk_nodes[which_node]});
cDialog talk_dlg("edit-talk-node");
cDialog talk_dlg(*ResMgr::dialogs.get("edit-talk-node"));
talk_dlg["okay"].attachClickHandler(std::bind(save_talk_node, _1, std::ref(talk_edit_stack), true, true));
talk_dlg["cancel"].attachClickHandler(std::bind(&cDialog::toast, &talk_dlg, false));
talk_dlg["back"].attachClickHandler(std::bind(talk_node_back, _1, std::ref(talk_edit_stack)));
@@ -1273,7 +1274,7 @@ location pick_out(location default_loc,cScenario& scenario) {
if(default_loc.y < 0)
default_loc.y = 0;
cDialog out_dlg("select-sector");
cDialog out_dlg(*ResMgr::dialogs.get("select-sector"));
out_dlg["okay"].attachClickHandler(std::bind(finish_pick_out, _1, true, std::ref(default_loc), prev_loc));
out_dlg["cancel"].attachClickHandler(std::bind(finish_pick_out, _1, false, std::ref(default_loc), prev_loc));
out_dlg.attachClickHandlers(std::bind(pick_out_event_filter, _1, _2, std::ref(default_loc), std::ref(scenario)), {"xplus", "xminus", "yplus", "yminus", "choose"});
@@ -1453,7 +1454,7 @@ bool resize_outdoors() {
using namespace std::placeholders;
loc_set del;
rectangle mod;
cDialog size_dlg("resize-outdoors");
cDialog size_dlg(*ResMgr::dialogs.get("resize-outdoors"));
size_dlg["w-old"].setTextToNum(scenario.outdoors.width());
size_dlg["h-old"].setTextToNum(scenario.outdoors.height());
fill_resize_outdoors(size_dlg, mod.top, mod.left, mod.right, mod.bottom, del);