Get the edit monster dialog completely working and updated for new stuff

(Just the main dialog, not the abilities dialog)
This commit is contained in:
2015-01-17 16:54:02 -05:00
parent 3d7fcbd60e
commit cdeb02c214
4 changed files with 47 additions and 52 deletions

View File

@@ -14,35 +14,36 @@
<field name='speed' top='178' left='206' width='52' height='16'/>
<field name='mage' top='202' left='206' width='51' height='16'/>
<field name='priest' top='226' left='206' width='51' height='16'/>
<field name='dice1' top='101' left='501' width='52' height='16'/>
<field name='sides1' top='125' left='501' width='52' height='16'/>
<field name='dice2' top='149' left='501' width='52' height='16'/>
<field name='sides2' top='173' left='501' width='52' height='16'/>
<field name='dice3' top='197' left='501' width='52' height='16'/>
<field name='sides3' top='221' left='501' width='52' height='16'/>
<field name='talk' top='327' left='168' width='77' height='16'/>
<field name='dice1' top='149' left='350' width='52' height='16'/>
<field name='sides1' top='149' left='410' width='52' height='16'/>
<field name='dice2' top='173' left='350' width='52' height='16'/>
<field name='sides2' top='173' left='410' width='52' height='16'/>
<field name='dice3' top='197' left='350' width='52' height='16'/>
<field name='sides3' top='197' left='410' width='52' height='16'/>
<field name='talk' top='276' left='168' width='77' height='16'/>
<field name='treas' top='273' left='513' width='55' height='16'/>
<button name='okay' type='regular' top='418' left='512'>OK</button>
<button name='cancel' type='regular' def-key='esc' top='418' left='439'>Cancel</button>
<button name='left' type='left' def-key='left' top='388' left='335'/>
<button name='right' type='right' def-key='right' top='388' left='398'/>
<button name='abils' type='large' top='388' left='473'>Abilities</button>
<button name='okay' type='regular' top='367' left='600'>OK</button>
<button name='cancel' type='regular' def-key='esc' top='367' left='527'>Cancel</button>
<button name='left' type='left' def-key='left' top='367' left='335'/>
<button name='right' type='right' def-key='right' top='367' left='398'/>
<button name='abils' type='large' top='337' left='561'>Abilities</button>
<button name='pickicon' type='large' top='53' left='201'>Select Icon</button>
<button name='picktype' type='regular' top='250' left='264'>Choose</button>
<button name='picktype1' type='regular' top='275' left='264'>Choose</button>
<button name='picktype2' type='regular' top='300' left='264'>Choose</button>
<button name='picktalk' type='regular' top='326' left='264'>Choose</button>
<button name='picktype1' type='regular' top='146' left='600'>Choose</button>
<button name='picktype2' type='regular' top='170' left='600'>Choose</button>
<button name='picktype3' type='regular' top='194' left='600'>Choose</button>
<button name='picktalk' type='regular' top='275' left='264'>Choose</button>
<group name='attitude'>
<led name='docile' top='355' left='358' width='100'>Friendly, Docile</led>
<led name='A' top='370' left='358' width='100'>Hostile, Type A</led>
<led name='friendly' top='355' left='490' width='100'>Friendly, Will Fight</led>
<led name='B' top='370' left='490' width='100'>Hostile, Type B</led>
<led name='docile' top='304' left='358' width='100'>Friendly, Docile</led>
<led name='A' top='319' left='358' width='100'>Hostile, Type A</led>
<led name='friendly' top='304' left='490' width='100'>Friendly, Will Fight</led>
<led name='B' top='319' left='490' width='100'>Hostile, Type B</led>
</group>
<text name='num' top='8' left='334' width='37' height='14'/>
<pict name='icon' type='monst' num='0' top='8' left='8'/>
<text size='large' top='6' left='44' width='158' height='16'>Edit Monster Statistics</text>
<text top='8' left='216' width='111' height='16'>Monster number:</text>
<text top='390' left='4' width='294' height='54'>
<text top='339' left='4' width='294' height='54'>
Enter properties for this monster type.
For a detailed description of the fields, see the documentation.
To edit monsters special abilities, press the Edit Abilities button.
@@ -52,14 +53,13 @@
<text name='w' top='59' left='334' width='86' height='14'>Width = </text>
<text name='h' top='59' left='426' width='86' height='14'>Height = </text>
<text name='type' top='253' left='134' width='120' height='14'/>
<text name='type1' top='278' left='134' width='120' height='14'/>
<text name='type2' top='303' left='134' width='120' height='14'/>
<text name='type1' top='150' left='470' width='120' height='14'/>
<text name='type2' top='174' left='470' width='120' height='14'/>
<text name='type3' top='198' left='470' width='120' height='14'/>
<text top='253' left='8' width='120' height='14'>Monster type:</text>
<text top='278' left='8' width='120' height='14'>Attack 1 type:</text>
<text top='303' left='8' width='120' height='14'>Attack #2,3 type:</text>
<text top='329' left='8' width='152' height='14'>Default talking picture:</text>
<text top='278' left='8' width='152' height='14'>Default talking picture:</text>
<!-- Note: This originally had width=202 -->
<text top='352' left='8' width='302' height='14'>Default attitude:
<text top='301' left='8' width='302' height='14'>Default attitude:
(attitude creature has when you place it)
</text>
<text size='large' top='250' left='343' width='158' height='16'>Treasure:</text>
@@ -72,10 +72,10 @@
<text top='203' left='8' width='179' height='14'>Monster magic spells: (0 - 7)</text>
<text top='227' left='8' width='179' height='14'>Monster priest spells: (0 - 7)</text>
<text size='large' top='82' left='273' width='158' height='16'>Hand to hand combat:</text>
<text top='102' left='283' width='214' height='14'>Attack 1 number of dice: (0 - 20)</text>
<text top='126' left='283' width='214' height='14'>Attack 1 number of sides: (1-50)</text>
<text top='150' left='283' width='214' height='14'>Attack 2 number of dice: (0 - 20)</text>
<text top='174' left='283' width='214' height='14'>Attack 2 number of sides: (1-50)</text>
<text top='198' left='283' width='214' height='14'>Attack 3 number of dice (0 - 20)</text>
<text top='222' left='283' width='214' height='14'>Attack 3 number of sides: (1-50)</text>
<text top='102' left='350' width='56' height='40'>Number of dice:<br/>(0 - 20)</text>
<text top='102' left='410' width='56' height='40'>Number of sides:<br/>(1-50)</text>
<text top='128' left='470' width='56' height='14'>Type</text>
<text top='150' left='283' width='50' height='14'>Attack 1:</text>
<text top='174' left='283' width='50' height='14'>Attack 2:</text>
<text top='198' left='283' width='50' height='14'>Attack 3:</text>
</dialog>

View File

@@ -27,7 +27,7 @@ void cMonster::append(legacy::monster_record_type& old){
armor = old.armor;
skill = old.skill;
for(int i = 0; i < 3; i++) {
a[i].dice = old.a[i] / 100 + 1;
a[i].dice = old.a[i] / 100;
a[i].sides = old.a[i] % 100;
}
a[0].type = eMonstMelee(old.a1_type);

View File

@@ -348,9 +348,8 @@ short edit_ter_type(ter_num_t which_ter) {
return 0;
}
static void put_monst_info_in_dlog(cDialog& me, mon_num_t which_monst) {
static void put_monst_info_in_dlog(cDialog& me, cMonster& store_monst, mon_num_t which_monst) {
char str[256];
cMonster& store_monst = scenario.scen_monsters[which_monst];
if(store_monst.picture_num < 1000)
dynamic_cast<cPict&>(me["icon"]).setPict(store_monst.picture_num,PIC_MONST);
@@ -410,10 +409,9 @@ static void put_monst_info_in_dlog(cDialog& me, mon_num_t which_monst) {
}
me["type"].setText(get_str("traits",33 + int(store_monst.m_type) * 2));
me["type1"].setText(get_str("monster-abilities",131 + int(store_monst.a[0].type)));
me["type2"].setText(get_str("monster-abilities",131 + int(store_monst.a[1].type)));
// TODO: Attack 3 type
// me["type3"].setText(get_str("monster-abilities",130 + store_monst.a[2].type));
me["type1"].setText(get_str("monster-abilities",130 + int(store_monst.a[0].type)));
me["type2"].setText(get_str("monster-abilities",130 + int(store_monst.a[1].type)));
me["type3"].setText(get_str("monster-abilities",130 + int(store_monst.a[2].type)));
}
static bool check_monst_pic(cDialog& me, std::string id, bool losing, cMonster& store_monst) {
@@ -492,7 +490,7 @@ static bool edit_monst_type_event_filter(cDialog& me,std::string item_hit,cMonst
temp_monst = edit_monst_abil(store_monst,which_monst);
if(temp_monst.level < 255)
store_monst = temp_monst;
put_monst_info_in_dlog(me,which_monst);
put_monst_info_in_dlog(me,store_monst,which_monst);
} else if(item_hit == "left") {
if(!save_monst_info(me,store_monst)) return false;
scenario.scen_monsters[which_monst] = store_monst;
@@ -500,41 +498,41 @@ static bool edit_monst_type_event_filter(cDialog& me,std::string item_hit,cMonst
// TODO: Use size() once scen_monsters becomes a vector
if(which_monst < 1) which_monst = 255;
store_monst = scenario.scen_monsters[which_monst];
put_monst_info_in_dlog(me,which_monst);
put_monst_info_in_dlog(me,store_monst,which_monst);
} else if(item_hit == "right") {
if(!save_monst_info(me,store_monst)) return false;
scenario.scen_monsters[which_monst] = store_monst;
which_monst++;
if(which_monst > 255) which_monst = 1;
store_monst = scenario.scen_monsters[which_monst];
put_monst_info_in_dlog(me,which_monst);
put_monst_info_in_dlog(me,store_monst,which_monst);
} else if(item_hit == "picktype") {
if(!save_monst_info(me,store_monst)) return false;
i = choose_text(STRT_RACE,int(store_monst.m_type),&me,"Choose Monster Type:");
if(i >= 0) {
store_monst.m_type = (eRace) i;
put_monst_info_in_dlog(me,which_monst);
put_monst_info_in_dlog(me,store_monst,which_monst);
}
} else if(item_hit == "picktype1") {
if(!save_monst_info(me,store_monst)) return false;
i = choose_text_res("monster-abilities",130,139,int(store_monst.a[0].type),&me,"Choose Attack 1 Type:");
if(i >= 0) {
store_monst.a[0].type = eMonstMelee(i);
put_monst_info_in_dlog(me,which_monst);
put_monst_info_in_dlog(me,store_monst,which_monst);
}
} else if(item_hit == "picktype2") {
if(!save_monst_info(me,store_monst)) return false;
i = choose_text_res("monster-abilities",130,139,int(store_monst.a[1].type),&me,"Choose Attack 2 & 3 Type:");
if(i >= 0) {
store_monst.a[1].type = store_monst.a[2].type = eMonstMelee(i);
put_monst_info_in_dlog(me,which_monst);
put_monst_info_in_dlog(me,store_monst,which_monst);
}
} else if(item_hit == "picktype3") {
if(!save_monst_info(me,store_monst)) return false;
i = choose_text_res("monster-abilities",130,139,int(store_monst.a[2].type),&me,"Choose Attack 3 Type:");
if(i >= 0) {
store_monst.a[2].type = eMonstMelee(i);
put_monst_info_in_dlog(me,which_monst);
put_monst_info_in_dlog(me,store_monst,which_monst);
}
}
return true;
@@ -565,9 +563,9 @@ short edit_monst_type(short which_monst) {
monst_dlg["priest"].attachFocusHandler(std::bind(check_range, _1, _2, _3, 0, 7, "priest spells"));
monst_dlg["treas"].attachFocusHandler(std::bind(check_range, _1, _2, _3, 0, 4, "treasure"));
monst_dlg.attachFocusHandlers(check_monst_dice,{"dice1","dice2","dice3","sides1","sides2","sides3"});
monst_dlg.attachClickHandlers(std::bind(edit_monst_type_event_filter,_1,_2,std::ref(store_monst),std::ref(which_monst)),{"okay","abils","left","right","picktype","picktype1","picktype2"});
monst_dlg.attachClickHandlers(std::bind(edit_monst_type_event_filter,_1,_2,std::ref(store_monst),std::ref(which_monst)),{"okay","abils","left","right","picktype","picktype1","picktype2","picktype3"});
put_monst_info_in_dlog(monst_dlg, which_monst);
put_monst_info_in_dlog(monst_dlg, store_monst, which_monst);
monst_dlg.run();
return 0;
@@ -609,7 +607,6 @@ static bool save_monst_abils(cDialog& me, cMonster& store_monst) {
static bool edit_monst_abil_event_filter(cDialog& me,std::string item_hit,cMonster& store_monst,short which_monst) {
using namespace std::placeholders;
short i;
if(item_hit == "cancel") {
store_monst.level = 255;
@@ -626,8 +623,6 @@ cMonster edit_monst_abil(cMonster starting_record,short which_monst) {
cMonster store_monst = starting_record;
cDialog monst_dlg("edit-monster-abils");
monst_dlg["poison"].attachFocusHandler(std::bind(check_range, _1, _2, _3, 0, 8, "Poison"));
monst_dlg["breath-str"].attachFocusHandler(std::bind(check_range, _1, _2, _3, 0, 4, "Breath Damage"));
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_event_filter, _1, _2, std::ref(store_monst),which_monst), {"okay", "cancel", "abils", "radiate"});

View File

@@ -145,7 +145,7 @@ short choose_text_res(std::string res_list,short first_t,short last_t,unsigned s
cur_choice -= first_t;
StringRsrc strings = *ResMgr::get<StringRsrc>(res_list);
cStringChoice dlog(strings.begin() + first_t, strings.begin() + last_t + 1, title, parent);
cStringChoice dlog(strings.begin() + first_t - 1, strings.begin() + last_t, title, parent);
return dlog.show(cur_choice);
}