Convert two more dialogs
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#include "scen.fileio.h"
|
||||
#include "mathutil.h"
|
||||
#include "button.h"
|
||||
#include "dlogutil.h"
|
||||
|
||||
extern short cen_x, cen_y, overall_mode;//,user_given_password;
|
||||
extern bool mouse_button_held,editing_town;
|
||||
@@ -29,8 +30,6 @@ extern location cur_out;
|
||||
|
||||
cCreature store_placed_monst,store_placed_monst2;
|
||||
short store_which_placed_monst;
|
||||
cTown::cItem store_placed_item;
|
||||
short store_which_placed_item,store_which_sign;
|
||||
short str_do_delete[16];
|
||||
short a,b,c;
|
||||
short store_which_out_wand,store_out_wand_mode;
|
||||
@@ -261,111 +260,78 @@ cCreature edit_placed_monst_adv(cCreature monst_record, cDialog& parent) {
|
||||
return store_placed_monst2;
|
||||
}
|
||||
|
||||
void put_placed_item_in_dlog() {
|
||||
static void put_placed_item_in_dlog(cDialog& me, const cTown::cItem& store_placed_item, const short store_which_placed_item) {
|
||||
char str[256];
|
||||
short i;
|
||||
#if 0
|
||||
cdsin(836,17,store_which_placed_item);
|
||||
sprintf((char *) str,"X = %d, Y = %d",store_placed_item.loc.x,store_placed_item.loc.y);
|
||||
csit(836,22,(char *) str);
|
||||
csit(836,15,scenario.scen_items[store_placed_item.code].full_name.c_str());
|
||||
CDSN(836,2,store_placed_item.ability);
|
||||
me["num"].setTextToNum(store_which_placed_item);
|
||||
sprintf(str,"X = %d, Y = %d",store_placed_item.loc.x,store_placed_item.loc.y);
|
||||
me["loc"].setText(str);
|
||||
me["name"].setText(scenario.scen_items[store_placed_item.code].full_name);
|
||||
me["charges"].setTextToNum(store_placed_item.ability);
|
||||
if(store_placed_item.always_there)
|
||||
cd_set_led(836,12,1);
|
||||
else cd_set_led(836,12,0);
|
||||
dynamic_cast<cLed&>(me["always"]).setState(led_red);
|
||||
if(store_placed_item.property)
|
||||
cd_set_led(836,13,1);
|
||||
else cd_set_led(836,13,0);
|
||||
dynamic_cast<cLed&>(me["owned"]).setState(led_red);
|
||||
if(store_placed_item.contained)
|
||||
cd_set_led(836,14,1);
|
||||
else cd_set_led(836,14,0);
|
||||
dynamic_cast<cLed&>(me["contained"]).setState(led_red);
|
||||
|
||||
i = scenario.scen_items[store_placed_item.code].graphic_num;
|
||||
if(i >= 1000) // was 1000, then was 150
|
||||
csp(836,4,i % 1000,PICT_CUSTOM + PICT_ITEM);
|
||||
else csp(836,4,/*1800 + */i,PICT_ITEM);
|
||||
#endif
|
||||
dynamic_cast<cPict&>(me["pic"]).setPict(scenario.scen_items[store_placed_item.code].graphic_num, PIC_ITEM);
|
||||
}
|
||||
|
||||
bool get_placed_item_in_dlog() {
|
||||
short i;
|
||||
#if 0
|
||||
store_placed_item.ability = CDGN(836,2);
|
||||
if((store_placed_item.ability < -1) || (store_placed_item.ability > 2500)) {
|
||||
give_error("Number of charges/amount of gold or food must be from 0 to 2500."
|
||||
,"If an item with charges (not gold or food) leave this at -1 for the item to have the default number of charges.",836);
|
||||
static bool get_placed_item_in_dlog(cDialog& me, cTown::cItem& store_placed_item, const short store_which_placed_item) {
|
||||
if(!me.toast(true)) return true;
|
||||
|
||||
store_placed_item.ability = me["charges"].getTextAsNum();
|
||||
if(store_placed_item.ability < -1 || store_placed_item.ability > 2500) {
|
||||
giveError("Number of charges/amount of gold or food must be from 0 to 2500.",
|
||||
"If an item with charges (not gold or food) leave this at -1 for the item to have the default number of charges.",&me);
|
||||
return true;
|
||||
}
|
||||
|
||||
eItemType type = scenario.scen_items[store_placed_item.code].variety;
|
||||
if(store_placed_item.ability == 0 && (type == eItemType::GOLD || type == eItemType::FOOD)) {
|
||||
giveError("You must assign gold or food an amount of at least 1.","",&me);
|
||||
return false;
|
||||
}
|
||||
i = scenario.scen_items[store_placed_item.code].variety;
|
||||
if((store_placed_item.ability == 0) && ((i == 3) || (i == 11))) {
|
||||
give_error("You must assign gold or food an amount of at least 1.","",836);
|
||||
return false;
|
||||
}
|
||||
store_placed_item.always_there = cd_get_led(836,12);
|
||||
store_placed_item.property = cd_get_led(836,13);
|
||||
store_placed_item.contained = cd_get_led(836,14);
|
||||
|
||||
store_placed_item.always_there = dynamic_cast<cLed&>(me["always"]).getState() != led_off;
|
||||
store_placed_item.property = dynamic_cast<cLed&>(me["owned"]).getState() != led_off;
|
||||
store_placed_item.contained = dynamic_cast<cLed&>(me["contained"]).getState() != led_off;
|
||||
|
||||
town->preset_items[store_which_placed_item] = store_placed_item;
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
void edit_placed_item_event_filter (short item_hit) {
|
||||
short i;
|
||||
cCreature store_m;
|
||||
#if 0
|
||||
switch(item_hit) {
|
||||
case 3:
|
||||
if(!get_placed_item_in_dlog())
|
||||
break;
|
||||
toast_dialog();
|
||||
break;
|
||||
case 20:
|
||||
toast_dialog();
|
||||
break;
|
||||
case 18:
|
||||
i = choose_text_res(-2,0,399,store_placed_item.code,836,"Place which item?");
|
||||
if(i >= 0) {
|
||||
store_placed_item.code = i;
|
||||
put_placed_item_in_dlog();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
for(i = 12; i <= 14; i++)
|
||||
cd_flip_led(836,i,item_hit);
|
||||
break;
|
||||
static bool edit_placed_item_event_filter(cDialog& me, cTown::cItem& store_placed_item, const short store_which_placed_item) {
|
||||
short i = choose_text(STRT_ITEM, store_placed_item.code, &me, "Place which item?");
|
||||
if(i >= 0) {
|
||||
store_placed_item.code = i;
|
||||
put_placed_item_in_dlog(me, store_placed_item, store_which_placed_item);
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
void edit_placed_item(short which_i) {
|
||||
#if 0
|
||||
using namespace std::placeholders;
|
||||
short item_hit;
|
||||
|
||||
store_placed_item = town->preset_items[which_i];
|
||||
store_which_placed_item = which_i;
|
||||
cTown::cItem placed_item = town->preset_items[which_i];
|
||||
|
||||
cd_create_dialog_parent_num(836,0);
|
||||
cDialog item_dlg("edit-placed-item.xml");
|
||||
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(placed_item), which_i));
|
||||
item_dlg["choose"].attachClickHandler(std::bind(edit_placed_item_event_filter, _1, std::ref(placed_item), which_i));
|
||||
|
||||
cd_activate_item(836,19,0);
|
||||
put_placed_item_in_dlog();
|
||||
put_placed_item_in_dlog(item_dlg, placed_item, which_i);
|
||||
|
||||
item_hit = cd_run_dialog();
|
||||
|
||||
cd_kill_dialog(836);
|
||||
#endif
|
||||
item_dlg.run();
|
||||
}
|
||||
|
||||
void edit_sign_event_filter (short item_hit) {
|
||||
#if 0
|
||||
switch(item_hit) {
|
||||
case 9: case 4:
|
||||
if(!editing_town)
|
||||
CDGT(831,2,current_terrain.out_strs(100 + store_which_sign));
|
||||
else CDGT(831,2,town->town_strs(120 + store_which_sign));
|
||||
if(item_hit == 9)
|
||||
toast_dialog();
|
||||
else {
|
||||
static bool edit_sign_event_filter(cDialog& me, short which_sign) {
|
||||
if(!me.toast(true)) return true;
|
||||
if(editing_town)
|
||||
town->sign_strs[which_sign] = me["text"].getText();
|
||||
else current_terrain.sign_strs[which_sign] = me["text"].getText();
|
||||
#if 0 // TODO: Apparently there used to be left/right buttons on this dialog.
|
||||
if(item_hit == 3)
|
||||
store_which_sign--;
|
||||
else store_which_sign++;
|
||||
@@ -373,45 +339,31 @@ void edit_sign_event_filter (short item_hit) {
|
||||
store_which_sign = (editing_town) ? 14 : 7;
|
||||
if(store_which_sign > (editing_town) ? 14 : 7)
|
||||
store_which_sign = 0;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
toast_dialog();
|
||||
break;
|
||||
}
|
||||
cdsin(831,5,store_which_sign);
|
||||
if(!editing_town)
|
||||
CDST(831,2,current_terrain.out_strs(100 + store_which_sign));
|
||||
else CDST(831,2,town->town_strs(120 + store_which_sign));
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
void edit_sign(short which_sign,short picture) {
|
||||
#if 0
|
||||
using namespace std::placeholders;
|
||||
short item_hit;
|
||||
location view_loc;
|
||||
|
||||
store_which_sign = which_sign;
|
||||
cDialog sign_dlg("edit-sign.xml");
|
||||
sign_dlg["cancel"].attachClickHandler(std::bind(&cDialog::toast, &sign_dlg, false));
|
||||
sign_dlg["okay"].attachClickHandler(std::bind(edit_sign_event_filter, _1, which_sign));
|
||||
cPict& icon = dynamic_cast<cPict&>(sign_dlg["pic"]);
|
||||
if(picture >= 400 && picture < 1000)
|
||||
icon.setPict(picture, PIC_TER_ANIM);
|
||||
else if(picture >= 2000)
|
||||
icon.setPict(picture - 2000, PIC_CUSTOM_TER_ANIM);
|
||||
else icon.setPict(picture, PIC_TER); // automatically adjusts for custom graphics
|
||||
|
||||
cd_create_dialog_parent_num(831,0);
|
||||
|
||||
if(picture >= 1000)
|
||||
csp(831,6,picture % 1000,PICT_CUSTOM + PICT_TER);
|
||||
else if(picture >= 400)
|
||||
csp(831,6,picture - 400,PICT_TER_ANIM);
|
||||
else csp(831,6,picture,PICT_TER);
|
||||
|
||||
cdsin(831,5,store_which_sign);
|
||||
sign_dlg["num"].setTextToNum(which_sign);
|
||||
if(!editing_town)
|
||||
CDST(831,2,current_terrain.out_strs(100 + store_which_sign));
|
||||
else CDST(831,2,town->town_strs(120 + store_which_sign));
|
||||
//cd_activate_item(831,3,0);
|
||||
//cd_activate_item(831,4,0);
|
||||
sign_dlg["text"].setText(current_terrain.sign_strs[which_sign]);
|
||||
else sign_dlg["text"].setText(town->sign_strs[which_sign]);
|
||||
|
||||
item_hit = cd_run_dialog();
|
||||
|
||||
cd_kill_dialog(831);
|
||||
#endif
|
||||
sign_dlg.run();
|
||||
}
|
||||
|
||||
bool save_out_strs() {
|
||||
|
@@ -56,6 +56,7 @@ public:
|
||||
};
|
||||
|
||||
typedef unsigned short pic_num_t;
|
||||
// TODO: Okay, is this really needed? Also this value also means "blank pic" in the dialog engine.
|
||||
static const pic_num_t NO_PIC = std::numeric_limits<pic_num_t>::max();
|
||||
using graf_pos = std::pair<sf::Texture*,rectangle>;
|
||||
using graf_pos_ref = std::pair<sf::Texture*&,rectangle&>;
|
||||
|
33
rsrc/dialogs/edit-placed-item.xml
Normal file
33
rsrc/dialogs/edit-placed-item.xml
Normal file
@@ -0,0 +1,33 @@
|
||||
<?xml version='1.0' encoding='UTF-8' standalone='no'?>
|
||||
<?xml-stylesheet href="dialog.xsl" type="text/xsl"?>
|
||||
<dialog skin='light' defbtn='okay' debug='true'>
|
||||
<!-- OK button -->
|
||||
<field name='charges' top='84' left='335' width='52' height='16'/>
|
||||
<button name='okay' type='regular' top='195' left='316'>OK</button>
|
||||
<pict name='pic' type='dlog' num='16' top='8' left='12'/>
|
||||
<text size='large' top='6' left='50' width='175' height='17'>Editing Preset Item</text>
|
||||
<text top='50' left='50' width='77' height='14'>Item name:</text>
|
||||
<text top='73' left='50' width='280' height='41'>
|
||||
Amount (if gold or food),
|
||||
or Charges (if item that can have charges,
|
||||
leave at -1 if you want the item to have its default number of charges)
|
||||
</text>
|
||||
<text top='120' left='50' width='116' height='14'>Special Flags:</text>
|
||||
<!--
|
||||
TODO: Put these LED labels inside the LED elements.
|
||||
-->
|
||||
<text top='138' left='84' width='164' height='14'>Always here</text>
|
||||
<text top='155' left='84' width='164' height='14'>Someone's property</text>
|
||||
<text top='172' left='84' width='164' height='14'>Contained in something</text>
|
||||
<led name='always' top='138' left='291'/>
|
||||
<led name='owned' top='155' left='291'/>
|
||||
<led name='contained' top='172' left='291'/>
|
||||
<text name='name' framed='true' top='50' left='136' width='143' height='14'/>
|
||||
<text top='28' left='50' width='97' height='14'>Item number:</text>
|
||||
<text name='num' top='28' left='151' width='137' height='14'/>
|
||||
<button name='choose' type='regular' top='46' left='290'>Choose</button>
|
||||
<!-- Deleted button -->
|
||||
<button name='cancel' type='regular' top='195' left='248'>Cancel</button>
|
||||
<text top='28' left='196' width='70' height='14'>Location:</text>
|
||||
<text name='loc' top='28' left='272' width='116' height='14'/>
|
||||
</dialog>
|
13
rsrc/dialogs/edit-sign.xml
Normal file
13
rsrc/dialogs/edit-sign.xml
Normal file
@@ -0,0 +1,13 @@
|
||||
<?xml version='1.0' encoding='UTF-8' standalone='no'?>
|
||||
<?xml-stylesheet href="dialog.xsl" type="text/xsl"?>
|
||||
<dialog skin='light' defbtn='okay' debug='true'>
|
||||
<!-- OK button -->
|
||||
<field name='text' top='34' left='55' width='293' height='98'/>
|
||||
<button name='cancel' type='regular' top='141' left='222' def-key='esc'>Cancel</button>
|
||||
<text top='142' left='7' width='198' height='15'>Use a ‘|’ to indicate a line break.</text>
|
||||
<text name='num' top='8' left='287' width='37' height='14'/>
|
||||
<pict name='pic' type='dlog' num='16' top='8' left='12'/>
|
||||
<text size='large' top='6' left='50' width='138' height='17'>Editing Sign</text>
|
||||
<text top='8' left='197' width='89' height='14'>Sign number:</text>
|
||||
<button name='okay' type='regular' top='141' left='288'>OK</button>
|
||||
</dialog>
|
Reference in New Issue
Block a user