Convert monster abilities dialog

This commit is contained in:
2014-11-28 02:19:07 -05:00
parent 14150c8e3b
commit 07ff864f4b
3 changed files with 164 additions and 122 deletions

View File

@@ -476,6 +476,7 @@
919DDC0D19007517003E7FED /* freetype.framework in Copy Libraries and Frameworks */ = {isa = PBXBuildFile; fileRef = 919DDC091900750D003E7FED /* freetype.framework */; };
919DDC0E1900751C003E7FED /* freetype.framework in Copy Libraries and Frameworks */ = {isa = PBXBuildFile; fileRef = 919DDC091900750D003E7FED /* freetype.framework */; };
919DDC0F1900751F003E7FED /* freetype.framework in Copy Libraries and Frameworks */ = {isa = PBXBuildFile; fileRef = 919DDC091900750D003E7FED /* freetype.framework */; };
91A073581A285293002F7E72 /* edit-monster-abils.xml in Copy Dialog Definitions */ = {isa = PBXBuildFile; fileRef = 91A073561A2828C6002F7E72 /* edit-monster-abils.xml */; };
91A0B1601900FFE500EF438F /* mask.frag in Copy Shaders */ = {isa = PBXBuildFile; fileRef = 91A0B15A1900F73E00EF438F /* mask.frag */; };
91A32D160FDE049900C4E957 /* ticpp.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 910BBA270FB8C459001E34EA /* ticpp.cpp */; };
91A32D170FDE049900C4E957 /* tinystr.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 910BBA2E0FB8C459001E34EA /* tinystr.cpp */; };
@@ -1063,6 +1064,7 @@
914CA49D190C47D000B6ADD1 /* edit-special-assign.xml in Copy Dialog Definitions */,
914CA49E190C47D000B6ADD1 /* edit-intro.xml in Copy Dialog Definitions */,
91C9C97D19116446001E14EB /* edit-monster.xml in Copy Dialog Definitions */,
91A073581A285293002F7E72 /* edit-monster-abils.xml in Copy Dialog Definitions */,
);
name = "Copy Dialog Definitions";
runOnlyForDeploymentPostprocessing = 0;
@@ -1660,6 +1662,7 @@
919DDBFA19006CC9003E7FED /* libboost_filesystem.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libboost_filesystem.dylib; path = /usr/local/lib/libboost_filesystem.dylib; sourceTree = "<absolute>"; };
919DDBFB19006CC9003E7FED /* libboost_system.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libboost_system.dylib; path = /usr/local/lib/libboost_system.dylib; sourceTree = "<absolute>"; };
919DDC091900750D003E7FED /* freetype.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = freetype.framework; path = ../../../../../../Library/Frameworks/freetype.framework; sourceTree = "<group>"; };
91A073561A2828C6002F7E72 /* edit-monster-abils.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = "edit-monster-abils.xml"; sourceTree = "<group>"; };
91A0B15A1900F73E00EF438F /* mask.frag */ = {isa = PBXFileReference; explicitFileType = sourcecode.glsl; fileEncoding = 4; path = mask.frag; sourceTree = "<group>"; };
91A32BBA0FDB657800C4E957 /* dialog.results.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = dialog.results.h; sourceTree = "<group>"; };
91A32BD10FDB797B00C4E957 /* dlogutil.buttons.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = dlogutil.buttons.h; sourceTree = "<group>"; };
@@ -2192,6 +2195,7 @@
91364F1118F0914F0033B58E /* tip-of-day.xml */,
91364F1218F0914F0033B58E /* view-sign.xml */,
91364F1318F0914F0033B58E /* welcome.xml */,
91A073561A2828C6002F7E72 /* edit-monster-abils.xml */,
);
path = dialogs;
sourceTree = "<group>";

View File

@@ -591,7 +591,7 @@ static bool edit_monst_type_event_filter(cDialog& me,std::string item_hit,cMonst
}
} else if(item_hit == "abils") {
if(!save_monst_info(me,store_monst)) return false;
temp_monst = edit_monst_abil(store_monst,814);
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);
@@ -670,148 +670,123 @@ short edit_monst_type(short which_monst) {
return 0;
}
void put_monst_abils_in_dlog() {
#if 0
char str[256];
short i;
static const std::string resist_field_names[8] = {
"magic-res", "fire-res", "cold-res", "poison-res",
"magic-imm", "fire-imm", "cold-imm", "poison-imm",
};
void put_monst_abils_in_dlog(cDialog& me, cMonster& store_monst, short which_monst) {
me["num"].setTextToNum(which_monst);
cdsin(815,24,store_which_monst);
me["poison"].setTextToNum(store_monst.poison);
me["breath-str"].setTextToNum(store_monst.breath);
me["abil-name"].setText(get_str("monster-abilities", store_monst.spec_skill + 1));
me["radiate-name"].setText(get_str("monster-abilities", store_monst.radiate_1 + 50));
me["radiate-param"].setText(get_str("monster-abilities", store_monst.radiate_1 + 80));
me["abil-xtra"].setTextToNum(store_monst.radiate_2);
me["loot-item"].setTextToNum(store_monst.corpse_item);
me["loot-chance"].setTextToNum(store_monst.corpse_item_chance);
CDSN(815,2,store_monst2.poison);
CDSN(815,3,store_monst2.breath);
cLedGroup& breathType = dynamic_cast<cLedGroup&>(me["breath-type"]);
switch(store_monst.breath_type) {
case 0:
breathType.setSelected("fire");
break;
case 1:
breathType.setSelected("cold");
break;
case 2:
breathType.setSelected("shock");
break;
case 3:
breathType.setSelected("dark");
break;
}
get_str(str,20,store_monst2.spec_skill + 1);
csit(815,30,(char *) str);
get_str(str,20,store_monst2.radiate_1 + 50);
csit(815,33,(char *) str);
get_str(str,20,store_monst2.radiate_1 + 80);
csit(815,36,(char *) str);
CDSN(815,4,store_monst2.radiate_2);
CDSN(815,5,store_monst2.corpse_item);
CDSN(815,6,store_monst2.corpse_item_chance);
cd_set_led_range(815,9,12,store_monst2.breath_type);
cd_set_led_range(815,41,44,store_monst2.summon_type);
for (i = 0; i < 8; i++)
cd_set_led(815,13 + i,0);
if (store_monst2.immunities & 1 ) cd_set_led(815,13,1);
if (store_monst2.immunities & 2 ) cd_set_led(815,14,1);
if (store_monst2.immunities & 4 ) cd_set_led(815,15,1);
if (store_monst2.immunities & 8 ) cd_set_led(815,16,1);
if (store_monst2.immunities & 16 ) cd_set_led(815,17,1);
if (store_monst2.immunities & 32 ) cd_set_led(815,18,1);
if (store_monst2.immunities & 64 ) cd_set_led(815,19,1);
if (store_monst2.immunities & 128 ) cd_set_led(815,20,1);
#endif
dynamic_cast<cLedGroup&>(me["summon"]).setSelected("s" + boost::lexical_cast<std::string,short>(store_monst.summon_type));
for(short i = 0; i < 8; i++) {
cLed& resistLed = dynamic_cast<cLed&>(me[resist_field_names[i]]);
if(store_monst.immunities & (1 << i))
resistLed.setState(led_red);
else resistLed.setState(led_off);
}
}
bool save_monst_abils() {
#if 0
store_monst2.poison = CDGN(815,2);
if (cre(store_monst2.poison,0,8,"Poison must be from 0 to 8.","",815) > 0) return false;
store_monst2.breath = CDGN(815,3);
if (cre(store_monst2.poison,0,40,"Breath Damage must be from 0 to 4.","",815) > 0) return false;
store_monst2.breath_type = cd_get_led_range(815,9,12);
store_monst2.summon_type = cd_get_led_range(815,41,44);
store_monst2.radiate_2 = CDGN(815,4);
if ((store_monst2.radiate_1 >= 1) && (store_monst2.radiate_1 <= 6))
if (cre(store_monst2.radiate_2,0,100,"Radiation Chance must be from 0 to 100.","",815) > 0) return false;
if ((store_monst2.radiate_1 >= 10) && (store_monst2.radiate_1 <= 12))
if (cre(store_monst2.radiate_2,0,255,"Summoned Monster must be from 0 to 255.","",815) > 0) return false;
bool save_monst_abils(cDialog& me, cMonster& store_monst) {
store_monst.poison = me["poison"].getTextAsNum();
store_monst.breath = me["breath-str"].getTextAsNum();
std::string breathType = dynamic_cast<cLedGroup&>(me["breath-type"]).getSelected();
if(breathType == "fire")
store_monst.breath_type = 0;
else if(breathType == "cold")
store_monst.breath_type = 1;
else if(breathType == "shock")
store_monst.breath_type = 2;
else if(breathType == "dark")
store_monst.breath_type = 3;
store_monst.summon_type = boost::lexical_cast<short>(dynamic_cast<cLedGroup&>(me["summon"]).getSelected().substr(1));
store_monst.radiate_2 = me["abil-xtra"].getTextAsNum();
store_monst2.corpse_item = CDGN(815,5);
if (cre(store_monst2.corpse_item,-1,399,"Item To Drop must be from 0 to 399 (or -1 for no item).","",815) > 0) return false;
store_monst2.corpse_item_chance = CDGN(815,6);
if (cre(store_monst2.corpse_item_chance,-1,100,"Dropping Chance must be from 0 to 100 (or -1 for no item).","",815) > 0) return false;
store_monst2.immunities = 0;
if (cd_get_led(815,13) == 1) store_monst2.immunities = store_monst2.immunities | 1;
if (cd_get_led(815,14) == 1) store_monst2.immunities = store_monst2.immunities | 2;
if (cd_get_led(815,15) == 1) store_monst2.immunities = store_monst2.immunities | 4;
if (cd_get_led(815,16) == 1) store_monst2.immunities = store_monst2.immunities | 8;
if (cd_get_led(815,17) == 1) store_monst2.immunities = store_monst2.immunities | 16;
if (cd_get_led(815,18) == 1) store_monst2.immunities = store_monst2.immunities | 32;
if (cd_get_led(815,19) == 1) store_monst2.immunities = store_monst2.immunities | 64;
if (cd_get_led(815,20) == 1) store_monst2.immunities = store_monst2.immunities | 128;
#endif
store_monst.corpse_item = me["loot-item"].getTextAsNum();
store_monst.corpse_item_chance = me["loot-chance"].getTextAsNum();
store_monst.immunities = 0;
for(short i = 0; i < 8; i++) {
if(dynamic_cast<cLed&>(me[resist_field_names[i]]).getState() != led_off)
store_monst.immunities |= 1 << i;
}
return true;
}
void edit_monst_abil_event_filter (short item_hit) {
#if 0
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;
switch (item_hit) {
case 8:
store_monst2.level = 255;
toast_dialog();
break;
case 7:
if (save_monst_abils() == true)
toast_dialog();
break;
case 31: // abils
if (save_monst_abils() == false) break;
i = choose_text_res(20,1,38,store_monst2.spec_skill + 1,815,"Choose Monster Ability:");
if(item_hit == "cancel") {
store_monst.level = 255;
me.toast();
} else if(item_hit == "okay") {
if(save_monst_abils(me, store_monst))
me.toast();
} else if(item_hit == "abils") {
if(!save_monst_abils(me, store_monst)) return true;
i = choose_text_res("monster-abilities", 1, 38, store_monst.spec_skill + 1, &me, "Choose Monster Ability:");
if (i >= 0) {
store_monst2.spec_skill = i - 1;
put_monst_abils_in_dlog();
store_monst.spec_skill = i - 1;
put_monst_abils_in_dlog(me, store_monst, which_monst);
}
break;
case 34: // radiate
if (save_monst_abils() == false) break;
i = choose_text_res(20,50,65,store_monst2.radiate_1 + 50,815,"Choose Radiation Ability:");
} else if(item_hit == "radiate") {
if(!save_monst_abils(me, store_monst)) return true;
i = choose_text_res("monster-abilities", 50, 65, store_monst.radiate_1 + 50, &me, "Choose Radiation Ability:");
if (i >= 0) {
store_monst2.radiate_1 = i - 50;
put_monst_abils_in_dlog();
}
break;
default:
cd_hit_led_range(815,9,12,item_hit);
cd_hit_led_range(815,41,44,item_hit);
for (i = 13; i < 21; i++)
cd_flip_led(815,i,item_hit);
break;
store_monst.radiate_1 = i - 50;
put_monst_abils_in_dlog(me, store_monst, which_monst);
}
if(i >= 1 && i <= 6)
me["abil-xtra"].attachFocusHandler(std::bind(check_range, _1, _2, _3, 0, 100, "Radiation Chance"));
else if(i >= 10 && i <= 12)
me["abil-xtra"].attachFocusHandler(std::bind(check_range, _1, _2, _3, 0, 255, "Summoned Monster"));
else me["abil-xtra"].attachFocusHandler(nullptr);
}
#endif
return true;
}
cMonster edit_monst_abil(cMonster starting_record,short parent_num) {
cMonster store_monst2 = starting_record;
#if 0
// ignore parent in Mac version
short item_hit;
cMonster edit_monst_abil(cMonster starting_record,short which_monst) {
using namespace std::placeholders;
cMonster store_monst = starting_record;
//store_which_monst = which_monst;
store_monst2 = starting_record;
//make_cursor_sword();
cDialog monst_dlg("edit-monster-abils.xml");
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"});
cd_create_dialog_parent_num(815,parent_num);
put_monst_abils_in_dlog(monst_dlg, store_monst, which_monst);
put_monst_abils_in_dlog();
cd_add_label(815,9,"Fire",35);
cd_add_label(815,10,"Cold",35);
cd_add_label(815,11,"Electricity",35);
cd_add_label(815,12,"Darkness",35);
cd_add_label(815,41,"No Summon",35);
cd_add_label(815,42,"Type 1",35);
cd_add_label(815,43,"Type 2",35);
cd_add_label(815,44,"Type 3",35);
cd_add_label(815,13,"Resist Magic",55);
cd_add_label(815,15,"Resist Fire",55);
cd_add_label(815,17,"Resist Cold",55);
cd_add_label(815,19,"Resist Poison",55);
cd_add_label(815,14,"Immune To Magic",55);
cd_add_label(815,16,"Immune To Fire",55);
cd_add_label(815,18,"Immune To Cold",55);
cd_add_label(815,20,"Immune To Poison",55);
item_hit = cd_run_dialog();
cd_kill_dialog(815);
#endif
return store_monst2;
monst_dlg.run();
return store_monst;
}
void put_item_info_in_dlog() {

View File

@@ -0,0 +1,63 @@
<?xml version='1.0' encoding='UTF-8' standalone='no'?>
<?xml-stylesheet href="dialog.xsl" type="text/xsl"?>
<!--<!DOCTYPE dialog SYSTEM "dialog.dtd">-->
<dialog skin='light' defbtn='okay' debug='true'>
<field name='poison' top='53' left='206' width='52' height='16'/>
<field name='breath-str' top='77' left='206' width='52' height='16'/>
<field name='abil-xtra' top='204' left='382' width='53' height='17'/>
<field name='loot-item' top='246' left='194' width='64' height='16'/>
<field name='loot-chance' top='247' left='464' width='64' height='16'/>
<button name='okay' type='regular' top='325' left='572'>OK</button>
<button name='cancel' type='regular' top='325' left='506'>Cancel</button>
<!--
TODO: Originally these LED labels would've been bold, I think
Note: These LEDs were shifted left 100 pixels to account for the labels swapping sides
-->
<group name='breath-type'>
<led name='fire' state='off' top='82' left='394' width='100'>Fire</led>
<led name='cold' state='off' top='97' left='394' width='100'>Cold</led>
<led name='shock' state='off' top='112' left='394' width='100'>Electricity</led>
<led name='dark' state='off' top='127' left='394' width='100'>Darkness</led>
</group>
<led name='magic-res' state='off' top='283' left='167' width='100'>Resist Magic</led>
<led name='fire-res' state='off' top='298' left='167' width='100'>Resist Fire</led>
<led name='cold-res' state='off' top='313' left='167' width='100'>Resist Cold</led>
<led name='poison-res' state='off' top='328' left='167' width='100'>Resist Poison</led>
<led name='magic-imm' state='off' top='283' left='320' width='100'>Immune To Magic</led>
<led name='fire-imm' state='off' top='298' left='320' width='100'>Immune To Fire</led>
<led name='cold-imm' state='off' top='313' left='320' width='100'>Immune To Cold</led>
<led name='poison-imm' state='off' top='328' left='320' width='100'>Immune To Poison</led>
<pict type='dlog' num='16' top='8' left='8'/>
<text size='large' top='6' left='50' width='158' height='16'>Edit Monster Abilities</text>
<text framed='true' top='6' left='222' width='111' height='14'>Monster number:</text>
<text name='num' framed='true' top='8' left='340' width='37' height='14'/>
<text top='2' left='408' width='184' height='54'>
Enter properties for this monster type. For a detailed
description of the fields, see the documentation.
</text>
<text top='54' left='7' width='179' height='14'>Monster Poison: (0 - 8)</text>
<text top='77' left='7' width='190' height='68'>Monster Breath Weapon strength (0 - 40):</text>
<text top='78' left='268' width='131' height='14'>Breath weapon type:</text>
<text size='large' top='152' left='7' width='120' height='14'>Special ability:</text>
<text name='abil-name' framed='true' top='152' left='184' width='183' height='14'/>
<button name='abils' type='regular' top='149' left='374'>Choose</button>
<text size='large' top='178' left='7' width='166' height='15'>Create monsters/fields:</text>
<text name='radiate-name' framed='true' top='178' left='184' width='183' height='14'/>
<button name='radiate' type='regular' top='175' left='374'>Choose</button>
<text top='205' left='54' width='118' height='16'/>
<text name='radiate-param' framed='true' top='205' left='180' width='195' height='14'/>
<text size='large' top='228' left='7' width='158' height='16'>Special treasure:</text>
<text top='247' left='23' width='162' height='14'>Item to drop when killed:</text>
<text top='247' left='270' width='186' height='14'>Chance of dropping: (0-100)</text>
<text top='279' left='9' width='141' height='14'>Monster resistances:</text>
<!--
Note: These LEDs were shifted left 80 pixels to account for the labels swapping sides
-->
<group name='summon'>
<led name='s0' state='off' top='153' left='525' width='100'>No Summon</led>
<led name='s1' state='off' top='168' left='525' width='100'>Type 1</led>
<led name='s2' state='off' top='183' left='525' width='100'>Type 2</led>
<led name='s3' state='off' top='198' left='525' width='100'>Type 3</led>
</group>
<text top='149' left='440' width='94' height='14'>Summon type:</text>
</dialog>