Convert the edit special item dialog

This commit is contained in:
2014-11-29 12:12:01 -05:00
parent 7aa3ba3794
commit 13d00cd27a
3 changed files with 89 additions and 99 deletions

View File

@@ -464,6 +464,7 @@
9192C14B18F32E8D0088A580 /* spell-times.txt in Copy Strings */ = {isa = PBXBuildFile; fileRef = 9192C13218F327230088A580 /* spell-times.txt */; };
9192C14C18F32E8D0088A580 /* magic-names.txt in Copy Strings */ = {isa = PBXBuildFile; fileRef = 9192C13318F327230088A580 /* magic-names.txt */; };
9192C15118F32E8D0088A580 /* traits.txt in Copy Strings */ = {isa = PBXBuildFile; fileRef = 9192C13818F327230088A580 /* traits.txt */; };
919C6D8D1A2A32CE00FD761F /* edit-special-item.xml in Copy Dialog Definitions */ = {isa = PBXBuildFile; fileRef = 919C6D8B1A2A22FC00FD761F /* edit-special-item.xml */; };
919DDBFC19006CF2003E7FED /* libboost_filesystem.dylib in Copy Libraries and Frameworks */ = {isa = PBXBuildFile; fileRef = 919DDBFA19006CC9003E7FED /* libboost_filesystem.dylib */; };
919DDBFD19006CF2003E7FED /* libboost_system.dylib in Copy Libraries and Frameworks */ = {isa = PBXBuildFile; fileRef = 919DDBFB19006CC9003E7FED /* libboost_system.dylib */; };
919DDBFE19006CF6003E7FED /* libboost_filesystem.dylib in Copy Libraries and Frameworks */ = {isa = PBXBuildFile; fileRef = 919DDBFA19006CC9003E7FED /* libboost_filesystem.dylib */; };
@@ -1070,6 +1071,7 @@
91A073581A285293002F7E72 /* edit-monster-abils.xml in Copy Dialog Definitions */,
91A0735D1A297C4D002F7E72 /* edit-item.xml in Copy Dialog Definitions */,
91A0735E1A297C4D002F7E72 /* edit-item-abils.xml in Copy Dialog Definitions */,
919C6D8D1A2A32CE00FD761F /* edit-special-item.xml in Copy Dialog Definitions */,
);
name = "Copy Dialog Definitions";
runOnlyForDeploymentPostprocessing = 0;
@@ -1665,6 +1667,7 @@
9192C13218F327230088A580 /* spell-times.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = "spell-times.txt"; path = "strings/spell-times.txt"; sourceTree = "<group>"; };
9192C13318F327230088A580 /* magic-names.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = "magic-names.txt"; path = "strings/magic-names.txt"; sourceTree = "<group>"; };
9192C13818F327230088A580 /* traits.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = traits.txt; path = strings/traits.txt; sourceTree = "<group>"; };
919C6D8B1A2A22FC00FD761F /* edit-special-item.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = "edit-special-item.xml"; sourceTree = "<group>"; };
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>"; };
@@ -2208,6 +2211,7 @@
91A073561A2828C6002F7E72 /* edit-monster-abils.xml */,
91A073591A29202E002F7E72 /* edit-item.xml */,
91A0735A1A2928B4002F7E72 /* edit-item-abils.xml */,
919C6D8B1A2A22FC00FD761F /* edit-special-item.xml */,
);
path = dialogs;
sourceTree = "<group>";

View File

@@ -34,7 +34,6 @@ extern cSpeech null_talk_node;
extern location cur_out;
extern short start_volume, start_dir;
short spec_item_spec,store_horse_page,store_boat_page ;
short cur_shortcut;
void init_scenario() {
@@ -1175,117 +1174,80 @@ cItemRec edit_item_abil(cItemRec starting_record,short which_item) {
return store_item;
}
void put_spec_item_in_dlog() {
#if 0
cdsin(806,19,store_which_spec_item);
CDST(806,2,scenario.scen_strs(60 + store_which_spec_item * 2));
CDST(806,3,scenario.scen_strs(60 + store_which_spec_item * 2 + 1));
CDSN(806,4,scenario.special_item_special[store_which_spec_item]);
if (scenario.special_items[store_which_spec_item] >= 10)
cd_set_led(806,15,1);
else cd_set_led(806,15,0);
if (scenario.special_items[store_which_spec_item] % 10 > 0)
cd_set_led(806,17,1);
else cd_set_led(806,17,0);
#endif
void put_spec_item_in_dlog(cDialog& me, cSpecItem& store_item, short which_item) {
me["num"].setTextToNum(which_item);
me["name"].setText(store_item.name);
me["descr"].setText(store_item.descr);
me["spec"].setTextToNum(store_item.special);
dynamic_cast<cLed&>(me["start-with"]).setState(store_item.flags >= 10 ? led_red : led_off);
dynamic_cast<cLed&>(me["usable"]).setState(store_item.flags % 10 > 0 ? led_red : led_off);
}
bool save_spec_item() {
#if 0
char str[256];
CDGT(806,2,(char *) str);
str[25] = 0;
sprintf(scenario.scen_strs(60 + store_which_spec_item * 2 + 0),"%s",str);
CDGT(806,3,scenario.scen_strs(60 + store_which_spec_item * 2 + 1));
spec_item_spec = CDGN(806,4);
if (cre(scenario.special_item_special[store_which_spec_item],
-1,255,"Scenario special node called must be from 0 to 255 (or -1 for no special).","",806) > 0) return false;
scenario.special_item_special[store_which_spec_item] = spec_item_spec;
scenario.special_items[store_which_spec_item] = 0;
if (cd_get_led(806,15) == 1)
scenario.special_items[store_which_spec_item] += 10;
if (cd_get_led(806,17) == 1)
scenario.special_items[store_which_spec_item] += 1;
#endif
bool save_spec_item(cDialog& me, cSpecItem& store_item, short which_item) {
strncpy(store_item.name, me["name"].getText().c_str(),25);
store_item.name[25] = 0;
strncpy(store_item.descr, me["descr"].getText().c_str(),255);
store_item.descr[255] = 0;
store_item.special = me["spec"].getTextAsNum();
store_item.flags = 0;
if(dynamic_cast<cLed&>(me["start-with"]).getState() != led_off)
store_item.flags += 10;
if(dynamic_cast<cLed&>(me["usable"]).getState() != led_off)
store_item.flags += 1;
scenario.special_items[which_item] = store_item;
return true;
}
void edit_spec_item_event_filter (short spec_item_hit) {
#if 0
short spec;
switch (spec_item_hit) {
case 11:
toast_dialog();
break;
case 5:
if (save_spec_item() == true)
toast_dialog();
break;
case 20:
if (save_spec_item() == false) break;
store_which_spec_item--;
if (store_which_spec_item < 0) store_which_spec_item = 49;
spec_item_spec = scenario.special_item_special[store_which_spec_item];
put_spec_item_in_dlog();
break;
case 21:
if (save_spec_item() == false) break;
store_which_spec_item++;
if (store_which_spec_item > 49) store_which_spec_item = 0;
spec_item_spec = scenario.special_item_special[store_which_spec_item];
put_spec_item_in_dlog();
break;
case 13: //choose edit
if (save_spec_item() == false)
break;
spec = CDGN(806,4);
if ((spec < 0) || (spec >= 256)) {
spec = get_fresh_spec(0);
if (spec < 0) {
give_error("You can't create a new special encounter because there are no more free scenario special nodes.",
"To free a special node, set its type to No Special and set its Jump To special to -1.",806);
break;
}
CDSN(806,4,spec);
}
edit_spec_enc(spec,0,806);
if ((spec >= 0) && (spec < 256) && (scenario.scen_specials[spec].pic < 0))
CDSN(806,4,-1);
if (save_spec_item() == false)
break;
break;
default:
cd_flip_led(806,15,spec_item_hit);
cd_flip_led(806,17,spec_item_hit);
break;
bool edit_spec_item_event_filter(cDialog& me, std::string item_hit, cSpecItem& store_item, short which_item) {
if(item_hit == "cancel") {
me.toast();
} else if(item_hit == "okay") {
if(save_spec_item(me, store_item, which_item)) me.toast();
} else if(item_hit == "left") {
if(!save_spec_item(me, store_item, which_item)) return true;
which_item--;
if(which_item < 0) which_item = 49;
store_item = scenario.special_items[which_item];
put_spec_item_in_dlog(me, store_item, which_item);
} else if(item_hit == "right") {
if(!save_spec_item(me, store_item, which_item)) return true;
which_item++;
if(which_item > 49) which_item = 0;
store_item = scenario.special_items[which_item];
put_spec_item_in_dlog(me, store_item, which_item);
} else if(item_hit == "edit-spec") {
if(!save_spec_item(me, store_item, which_item)) return true;
short spec = me["spec"].getTextAsNum();
if((spec < 0) || (spec >= 256)) {
spec = get_fresh_spec(0);
if(spec < 0) {
giveError("You can't create a new special encounter because there are no more free scenario special nodes.",
"To free a special node, set its type to No Special and set its Jump To special to -1.",&me);
return true;
}
me["spec"].setTextToNum(spec);
}
edit_spec_enc(spec,0,&me);
if(spec >= 0 && spec < 256 && scenario.scen_specials[spec].pic < 0)
me["spec"].setTextToNum(-1);
save_spec_item(me, store_item, which_item);
}
#endif
return true;
}
void edit_spec_item(short which_item) {
#if 0
// ignore parent in Mac version
short spec_item_hit;
using namespace std::placeholders;
cSpecItem store_item = scenario.special_items[which_item];
//store_which_spec_item = which_spec_item;
store_which_spec_item = which_item;
spec_item_spec = scenario.special_item_special[store_which_spec_item];
cDialog item_dlg("edit-special-item.xml");
item_dlg["spec"].attachFocusHandler(std::bind(check_range_msg, _1, _2, _3, -1, 255, "Scenario special node called", "-1 for no special"));
item_dlg.attachClickHandlers(std::bind(edit_spec_item_event_filter, _1, _2, std::ref(store_item), which_item), {"okay", "cancel", "clear", "edit-spec", "left", "right"});
cd_create_dialog_parent_num(806,0);
put_spec_item_in_dlog(item_dlg, store_item, which_item);
item_dlg["clear"].hide();
put_spec_item_in_dlog();
cd_attach_key(806,20,0);
cd_attach_key(806,21,0);
cd_activate_item(806,12,0);
spec_item_hit = cd_run_dialog();
cd_kill_dialog(806);
#endif
item_dlg.run();
}
void put_save_rects_in_dlog() {

View File

@@ -0,0 +1,24 @@
<?xml version='1.0' encoding='UTF-8' standalone='no'?>
<?xml-stylesheet href="dialog.xsl" type="text/xsl"?>
<dialog skin='light' defbtn='okay' debug='true'>
<field name='name' top='57' left='195' width='252' height='16'/>
<field name='descr' top='84' left='195' width='252' height='104'/>
<field name='spec' top='249' left='268' width='87' height='16'/>
<button name='okay' type='regular' top='288' left='397'>OK</button>
<pict type='dlog' num='16' top='8' left='8'/>
<text size='large' top='6' left='50' width='256' height='17'>Edit Special Items</text>
<text top='58' left='50' width='132' height='14'>Name of Special Item:</text>
<text top='85' left='50' width='118' height='27'>Special Item Description:</text>
<text top='243' left='51' width='208' height='28'>Scenario special node to be called when item is used:</text>
<button name='cancel' type='regular' top='288' left='332' def-key='esc'>Cancel</button>
<button name='clear' type='large' top='15' left='329'>Clear Special</button>
<button name='edit-spec' type='large' top='246' left='363'>Create/Edit</button>
<text top='199' left='50' width='179' height='14'>Party starts scen. with item</text>
<led name='start-with' state='off' top='198' left='233'/>
<text top='219' left='50' width='179' height='14'>Special item can be used</text>
<led name='usable' state='off' top='218' left='233'/>
<text top='29' left='50' width='136' height='14'>Editing special item:</text>
<text name='num' top='29' left='190' width='39' height='14'/>
<button name='left' type='left' top='288' left='9'/>
<button name='right' type='right' top='288' left='72'/>
</dialog>