Fix/update the edit placed monster dialogs

- Also, edit monster dialog now shows default facial pic
This commit is contained in:
2015-01-23 13:37:47 -05:00
parent 72dfea868f
commit cf85ea7f5a
12 changed files with 93 additions and 78 deletions

View File

@@ -466,6 +466,7 @@ static void put_monst_info_in_dlog(cDialog& me, cMonster& store_monst, mon_num_t
}
dynamic_cast<cPict&>(me["icon"]).setPict(store_monst.picture_num,type_g);
}
dynamic_cast<cPict&>(me["talkpic"]).setPict(store_monst.default_facial_pic, PIC_TALK);
me["num"].setTextToNum(which_monst);
me["name"].setText(store_monst.m_name);
me["pic"].setTextToNum(store_monst.picture_num);
@@ -487,7 +488,7 @@ static void put_monst_info_in_dlog(cDialog& me, cMonster& store_monst, mon_num_t
me["sides2"].setTextToNum(store_monst.a[1].sides);
me["dice3"].setTextToNum(store_monst.a[2].dice);
me["sides3"].setTextToNum(store_monst.a[2].sides);
me["talk"].setTextToNum(store_monst.default_facial_pic);
me["talk"].setTextToNum(short(store_monst.default_facial_pic));
me["treas"].setTextToNum(store_monst.treasure);
cLedGroup& attitude = dynamic_cast<cLedGroup&>(me["attitude"]);
@@ -668,7 +669,7 @@ short edit_monst_type(short which_monst) {
cDialog monst_dlg("edit-monster");
monst_dlg["pickicon"].attachClickHandler(std::bind(pick_monst_picture,_1));
monst_dlg["picktalk"].attachClickHandler(std::bind(pick_picture,PIC_TALK,_1,"talk",""));
monst_dlg["picktalk"].attachClickHandler(std::bind(pick_picture,PIC_TALK,_1,"talk","talkpic"));
monst_dlg["cancel"].attachClickHandler(std::bind(&cDialog::toast, &monst_dlg, false));
monst_dlg["pic"].attachFocusHandler(std::bind(check_monst_pic, _1, _2, _3, std::ref(store_monst)));
monst_dlg["level"].attachFocusHandler(std::bind(check_range, _1, _2, _3, 0, 40, "level"));

View File

@@ -268,6 +268,13 @@ short choose_text(eStrType list, unsigned short cur_choice, cDialog* parent, con
case STRT_SUMMON:
strings = {"0 - no summon (weak)", "1 - weak summoning", "2 - summoning", "3 - major summoning", "4 - no summon (unique/powerful"};
break;
case STRT_TALK:
for(cTown* town : scenario.towns) {
for(cPersonality who : town->talking.people) {
strings.push_back(who.title + " (in " + town->town_name + ")");
}
}
break;
}
if(cur_choice < 0 || cur_choice >= strings.size())
cur_choice = -1;

View File

@@ -10,7 +10,7 @@ enum eStrType {
STRT_PICT, STRT_SND, STRT_CMP, STRT_ACCUM, STRT_TRAP,
STRT_ATTITUDE, STRT_STAIR, STRT_LIGHT, STRT_CONTEXT,
STRT_SHOP, STRT_COST_ADJ, STRT_STAIR_MODE, STRT_TALK_NODE,
STRT_STATUS, STRT_SPELL_PAT, STRT_SUMMON,
STRT_STATUS, STRT_SPELL_PAT, STRT_SUMMON, STRT_TALK,
};
bool cre(short val,short min,short max,std::string text1,std::string text2,cDialog* parent) ;

View File

@@ -33,11 +33,11 @@ extern location cur_out;
cTownperson store_placed_monst,store_placed_monst2;
short store_which_placed_monst;
const char *day_str_1[] = {"Unused","Day creature appears","Day creature disappears","",
"Unused","Unused","Unused","Unused","Unused"};
const char *day_str_2[] = {"Unused","Event code (0 - no event)","Event code (0 - no event)","",
const char *day_str_1[] = {"Unused","Day creature appears","Day creature disappears",
"Unused","Unused","Unused","Unused","Unused","Unused"};
const char *day_str_2[] = {"Unused","Event code (0 - no event)","Event code (0 - no event)",
"Unused","Unused","Unused",
"Event code (0 - no event)","Event code (0 - no event)"};
"Event code (0 - no event)","Event code (0 - no event)","Unused"};
static void put_placed_monst_in_dlog(cDialog& me) {
me["num"].setTextToNum(store_which_placed_monst);
@@ -48,21 +48,18 @@ static void put_placed_monst_in_dlog(cDialog& me) {
me["talk"].setTextToNum(store_placed_monst.personality);
me["picnum"].setTextToNum(store_placed_monst.facial_pic);
// TODO: Use -1 instead of 0 for "no pic", since 0 is a valid talking picture
if((store_placed_monst.facial_pic < 1))
dynamic_cast<cPict&>(me["pic"]).setPict(-1);
if(short(store_placed_monst.facial_pic) < 0)
dynamic_cast<cPict&>(me["pic"]).setPict(scenario.scen_monsters[store_placed_monst.number].picture_num, PIC_MONST);
else if((store_placed_monst.facial_pic >= 1000))
dynamic_cast<cPict&>(me["pic"]).setPict(store_placed_monst.facial_pic - 1000,PIC_CUSTOM_TALK);
else dynamic_cast<cPict&>(me["pic"]).setPict(store_placed_monst.facial_pic,PIC_TALK);
}
static bool get_placed_monst_in_dlog(cDialog& me) {
static void get_placed_monst_in_dlog(cDialog& me) {
store_placed_monst.start_attitude = dynamic_cast<cLedGroup&>(me["attitude"]).getSelected()[3] - '1';
store_placed_monst.mobility = dynamic_cast<cLedGroup&>(me["mobility"]).getSelected()[3] - '1';
store_placed_monst.personality = me["talk"].getTextAsNum();
store_placed_monst.facial_pic = me["picnum"].getTextAsNum();
// later
town->creatures[store_which_placed_monst] = store_placed_monst;
return true;
}
static bool edit_placed_monst_event_filter(cDialog& me, std::string item_hit, eKeyMod) {
@@ -70,25 +67,31 @@ static bool edit_placed_monst_event_filter(cDialog& me, std::string item_hit, eK
cTownperson store_m;
if(item_hit == "okay") {
if(!get_placed_monst_in_dlog(me)) return true;
me.toast(true);
if(!me.toast(true)) return true;
get_placed_monst_in_dlog(me);
town->creatures[store_which_placed_monst] = store_placed_monst;
} else if(item_hit == "cancel") {
me.toast(false);
} else if(item_hit == "del") {
me.toast(false);
town->creatures[store_which_placed_monst].number = 0;
} else if(item_hit == "type-edit") {
if(!get_placed_monst_in_dlog(me)) return true;
get_placed_monst_in_dlog(me);
i = choose_text(STRT_MONST,store_placed_monst.number,&me,"Choose Which Monster:");
if(i >= 0) {
store_placed_monst.number = i;
put_placed_monst_in_dlog(me);
}
} else if(item_hit == "pict-edit") {
if(!get_placed_monst_in_dlog(me)) return true;
get_placed_monst_in_dlog(me);
i = choose_graphic(store_placed_monst.facial_pic,PIC_TALK,&me);
if(i >= 0) {
// TODO: Use -1 instead of 0 for "no pic"
store_placed_monst.facial_pic = i + 1;
}
else return true;
store_placed_monst.facial_pic = i;
put_placed_monst_in_dlog(me);
} else if(item_hit == "talk-edit") {
get_placed_monst_in_dlog(me);
i = choose_text(STRT_TALK, store_placed_monst.personality, &me, "Which personality?");
if(i >= 0)
store_placed_monst.personality = i;
put_placed_monst_in_dlog(me);
} else if(item_hit == "more") { //advanced
store_m = edit_placed_monst_adv(store_placed_monst, me);
@@ -103,7 +106,7 @@ void edit_placed_monst(short which_m) {
store_which_placed_monst = which_m;
cDialog edit("edit-townperson");
edit.attachClickHandlers(edit_placed_monst_event_filter, {"type-edit", "pict-edit", "okay", "cancel", "more"});
edit.attachClickHandlers(edit_placed_monst_event_filter, {"type-edit", "pict-edit", "talk-edit", "okay", "cancel", "more", "del"});
put_placed_monst_in_dlog(edit);
@@ -111,7 +114,6 @@ void edit_placed_monst(short which_m) {
}
static void put_placed_monst_adv_in_dlog(cDialog& me) {
me["num"].setTextToNum(store_which_placed_monst);
me["type"].setText(scenario.scen_monsters[store_placed_monst2.number].m_name);
int iTime = 0;
@@ -131,8 +133,7 @@ static void put_placed_monst_adv_in_dlog(cDialog& me) {
me["extra2-lbl"].setText(day_str_2[iTime]);
me["extra1"].setTextToNum(store_placed_monst2.monster_time);
me["extra2"].setTextToNum(store_placed_monst2.time_code);
// TODO: Why on earth is this an LED group? Just use a text field!
dynamic_cast<cLedGroup&>(me["group"]).setSelected("group" + std::to_string(store_placed_monst2.spec_enc_code));
me["group"].setTextToNum(store_placed_monst2.spec_enc_code);
me["death"].setTextToNum(store_placed_monst2.special_on_kill);
me["sdfx"].setTextToNum(store_placed_monst2.spec1);
me["sdfy"].setTextToNum(store_placed_monst2.spec2);
@@ -161,9 +162,7 @@ static bool get_placed_monst_adv_in_dlog(cDialog& me) {
store_placed_monst2.spec2 = me["sdfy"].getTextAsNum();
if(cre(store_placed_monst2.spec2,-1,9,"Second part of special flag must be -1 (if this is to be ignored) or from 0 to 9.","",&me)) return false;
std::string group = dynamic_cast<cLedGroup&>(me["group"]).getSelected();
if(group == "group10") store_placed_monst2.spec_enc_code = 10;
else store_placed_monst2.spec_enc_code = group[5] - '0';
store_placed_monst2.spec_enc_code = me["group"].getTextAsNum();
return true;
}
@@ -178,14 +177,28 @@ static bool edit_placed_monst_adv_event_filter(cDialog& me, std::string item_hit
return true;
}
static bool edit_placed_monst_adv_time_flag(cDialog& me, std::string id, bool losingFocus) {
static bool edit_placed_monst_adv_time_flag(cDialog& me, std::string, bool losingFocus) {
if(losingFocus) return true;
if(id.substr(0,4) == "time") {
int item_hit = id[4] - '1';
me["extra1-lbl"].setText(day_str_1[item_hit]);
me["extra2-lbl"].setText(day_str_2[item_hit]);
cLedGroup& time = dynamic_cast<cLedGroup&>(me["time"]);
int item_hit = time.getSelected()[4] - '1';
me["extra1-lbl"].setText(day_str_1[item_hit]);
me["extra2-lbl"].setText(day_str_2[item_hit]);
return true;
}
static bool edit_placed_monst_adv_death(cDialog& me, std::string, eKeyMod) {
short spec = store_placed_monst2.special_on_kill;
if(spec < 0) {
spec = get_fresh_spec(2);
if(spec < 0) {
giveError("You can't create a new town special encounter because there are no more free special nodes.",
"To free a special node, set its type to No Special and set its Jump To special to -1.", &me);
return true;
}
}
if(edit_spec_enc(spec,2,&me))
me["death"].setTextToNum(spec);
return true;
}
@@ -195,6 +208,7 @@ cTownperson edit_placed_monst_adv(cTownperson monst_record, cDialog& parent) {
cDialog edit("edit-townperson-advanced", &parent);
edit["okay"].attachClickHandler(edit_placed_monst_adv_event_filter);
edit["cancel"].attachClickHandler(edit_placed_monst_adv_event_filter);
edit["editdeath"].attachClickHandler(edit_placed_monst_adv_death);
edit["time"].attachFocusHandler(edit_placed_monst_adv_time_flag);
put_placed_monst_adv_in_dlog(edit);