Convert several more dialogs, mostly related to outdoors stuff

This commit is contained in:
2014-12-18 18:55:21 -05:00
parent a672ec050d
commit 72200a57f3
13 changed files with 416 additions and 336 deletions

View File

@@ -1184,6 +1184,10 @@ bool cDialog::toast(bool triggerFocus){
return true;
}
void cDialog::untoast() {
dialogNotToast = true;
}
bool cDialog::setFocus(cTextField* newFocus, bool force) {
// TODO: Should check that there IS a currently focused field (which might not be the case if there are no fields at all).
if(!force) {

View File

@@ -134,9 +134,15 @@ public:
/// Close the dialog.
/// @param triggerFocus true to allow the focus handler of the currently focused text field to prevent the dialog from closing
/// @return true unless the currently focused field prevented the dialog from closing
/// @note The dialog is not actually closed immediately;
/// instead, a flag is set that triggers the event loop to end and the dialog to close.
///
/// Generally, you would pass true in a handler for an OK button and false in a handler for a Cancel button.
bool toast(bool triggerFocus);
/// Reopen the dialog after closing it.
/// This is meant to be called from within an event handler to reverse a previous call to toast();
/// if you're already out of the dialog's event loop, you should instead call run() to reopen it.
void untoast();
/// Get a reference to a control.
/// @param id The unique key of the control.
/// @throw std::invalid_argument if the control does not exist.

View File

@@ -238,12 +238,11 @@ bool handle_action(location the_point,sf::Event /*event*/) {
if(!save_check("save-section-confirm.xml"))
break;
}
x = pick_out(cur_out);
if(x >= 0) {
spot_hit.x = x / 100;
spot_hit.y = x % 100;
spot_hit = pick_out(cur_out);
if(spot_hit != cur_out) {
if(load_outdoors(spot_hit,current_terrain)){
augment_terrain(spot_hit);
cur_out = spot_hit;
set_up_main_screen();
}
}
@@ -258,7 +257,7 @@ bool handle_action(location the_point,sf::Event /*event*/) {
if(!save_check("save-section-confirm.xml"))
break;
}
x = pick_town_num(855,cur_town);
x = pick_town_num("select-town-edit.xml",cur_town);
if(x >= 0 && load_town(x,town)){
cur_town = x;
set_up_main_screen();
@@ -1295,8 +1294,7 @@ void swap_terrain() {
short a,b,c,i,j;
ter_num_t ter;
change_ter(&a,&b,&c);
if(a < 0) return;
if(!change_ter(a,b,c)) return;
for(i = 0; i < ((editing_town) ? town->max_dim() : 48); i++)
for(j = 0; j < ((editing_town) ? town->max_dim() : 48); j++) {
@@ -3007,13 +3005,13 @@ void town_entry(location spot_hit) {
y = -2;
for(x = 0; x < 8; x++)
if((current_terrain.exit_locs[x].x == spot_hit.x) && (current_terrain.exit_locs[x].y == spot_hit.y)) {
y = pick_town_num(856,current_terrain.exit_dests[x]);
y = pick_town_num("select-town-enter.xml",current_terrain.exit_dests[x]);
if(y >= 0) current_terrain.exit_dests[x] = y;
}
if(y == -2) {
for(x = 0; x < 8; x++)
if(current_terrain.exit_locs[x].x == 100) {
y = pick_town_num(856,0);
y = pick_town_num("select-town-enter.xml",0);
if(y >= 0) {
current_terrain.exit_dests[x] = y;
current_terrain.exit_locs[x] = spot_hit;

View File

@@ -214,7 +214,7 @@ static bool save_ter_info(cDialog& me, cTerrain& store_ter) {
}
// TODO: It would probably be good to use these for other dialogs, instead of the monolithic event filters
static bool check_range_msg(cDialog& me,std::string id,bool losing,long min_val,long max_val,std::string fld_name,std::string xtra){
bool check_range_msg(cDialog& me,std::string id,bool losing,long min_val,long max_val,std::string fld_name,std::string xtra){
if(!losing) return true;
cTextField& fld_ctrl = dynamic_cast<cTextField&>(me[id]);
long n = fld_ctrl.getTextAsNum();
@@ -228,12 +228,12 @@ static bool check_range_msg(cDialog& me,std::string id,bool losing,long min_val,
return true;
}
static bool check_range(cDialog& me,std::string id,bool losing,long min_val,long max_val,std::string fld_name) {
bool check_range(cDialog& me,std::string id,bool losing,long min_val,long max_val,std::string fld_name) {
return check_range_msg(me, id, losing, min_val, max_val, fld_name, "");
}
// TODO: I have two functions that do this. (The other one is choose_graphic.)
static bool pick_picture(ePicType type, cDialog& parent, std::string result_fld, std::string pic_fld, pic_num_t modifier){
bool pick_picture(ePicType type, cDialog& parent, std::string result_fld, std::string pic_fld, pic_num_t modifier){
pic_num_t cur_sel = 0;
if(result_fld != ""){
cControl& fld_ctrl = parent[result_fld];
@@ -258,7 +258,7 @@ static bool pick_picture(ePicType type, cDialog& parent, std::string result_fld,
return true;
}
static bool pick_string(std::string from_file, cDialog& parent, std::string result_fld, std::string str_fld){
bool pick_string(std::string from_file, cDialog& parent, std::string result_fld, std::string str_fld){
size_t cur_sel = 0;
if(result_fld != ""){
cTextField& fld_ctrl = dynamic_cast<cTextField&>(parent[result_fld]);

View File

@@ -1,4 +1,6 @@
class cDialog;
__declspec(deprecated) void init_scenario();
short edit_ter_type(ter_num_t which_ter);
short edit_monst_type(short which_monst);
@@ -18,3 +20,6 @@ bool build_scenario();
void set_starting_loc();
void edit_boats();
bool check_range_msg(cDialog& me,std::string id,bool losing,long min_val,long max_val,std::string fld_name,std::string xtra);
bool check_range(cDialog& me,std::string id,bool losing,long min_val,long max_val,std::string fld_name);
bool pick_string(std::string from_file, cDialog& parent, std::string result_fld, std::string str_fld);

View File

@@ -8,9 +8,11 @@
#include "scen.townout.h"
#include "scen.keydlgs.h"
#include "scen.fileio.h"
#include "scen.core.h"
#include "mathutil.h"
#include "button.h"
#include "dlogutil.h"
#include "winutil.h"
extern short cen_x, cen_y, overall_mode;//,user_given_password;
extern bool mouse_button_held,editing_town;
@@ -31,9 +33,6 @@ extern location cur_out;
cCreature store_placed_monst,store_placed_monst2;
short store_which_placed_monst;
short a,b,c;
short store_which_out_wand,store_out_wand_mode;
cOutdoors::cWandering store_out_wand;
const char *day_str_1[] = {"Unused","Day creature appears","Day creature disappears","",
"Unused","Unused","Unused","Unused","Unused"};
@@ -432,287 +431,209 @@ void edit_roomdescs(bool town) {
room_dlg.run();
}
short store_which_town_dlg;
void pick_town_num_event_filter (short item_hit) {
#if 0
switch(item_hit) {
case 3:
dialog_answer = CDGN(store_which_town_dlg,2);
if((dialog_answer < 0) || (dialog_answer >= scenario.num_towns)) {
give_error("This number is out of the correct range. (0 to the number of towns minus 1)","",store_which_town_dlg);
break;
}
toast_dialog();
break;
case 4:
dialog_answer = -1;
toast_dialog();
break;
}
#endif
}
short pick_town_num(short which_dlog,short def) {
#if 0
// ignore parent in Mac version
short town_strs_hit;
char temp_str[256],str2[256];
store_which_town_dlg = which_dlog;
cd_create_dialog_parent_num(store_which_town_dlg,0);
CDSN(store_which_town_dlg,2,def);
cd_get_item_text(store_which_town_dlg,7,(char *) temp_str);
sprintf((char *) str2,"%s (0 - %d)",(char *) temp_str,scenario.num_towns - 1);
csit(store_which_town_dlg,7,(char *) str2);
town_strs_hit = cd_run_dialog();
cd_kill_dialog(store_which_town_dlg);
#endif
return 0;//dialog_answer;
}
void change_ter_event_filter (short item_hit) {
short i;
#if 0
switch(item_hit) {
case 5:
a = CDGN(857,2);
b = CDGN(857,3);
c = CDGN(857,4);
if(cre(a,0,255,"Both terrain types must be from 0 to 255.","",857)) break;
if(cre(b,0,255,"Both terrain types must be from 0 to 255.","",857)) break;
if(cre(c,0,100,"The Chance must be from 0 to 100.","",857)) break;
toast_dialog();
break;
case 6:
a = -1;
b = -1;
c = -1;
toast_dialog();
break;
case 10: case 11:
i = CDGN(857,item_hit - 8);
i = choose_text_res(-4,0,255,i,857,"Which Terrain?");
if(i >= 0)
CDSN(857,item_hit - 8,i);
break;
}
#endif
}
void change_ter(short *change_from,short *change_to,short *chance) {
// ignore parent in Mac version
short town_strs_hit;
#if 0
cd_create_dialog_parent_num(857,0);
CDSN(857,2,0);
CDSN(857,3,0);
CDSN(857,4,100);
town_strs_hit = cd_run_dialog();
*change_from = a;
*change_to = b;
*chance = c;
cd_kill_dialog(857);
#endif
}
void outdoor_details_event_filter (short item_hit) {
#if 0
char str[256];
switch(item_hit) {
case 3:
CDGT(851,2,(char *) str);
str[29] = 0;
sprintf(current_terrain.out_strs(0),"%s",(char *) str);
toast_dialog();
break;
}
#endif
}
void outdoor_details() {
#if 0
// ignore parent in Mac version
short town_strs_hit;
char temp_str[256];
cd_create_dialog_parent_num(851,0);
CDST(851,2,current_terrain.out_strs(0));
sprintf((char *) temp_str,"X = %d, Y = %d",cur_out.x,cur_out.y);
csit(851,8,(char *) temp_str);
town_strs_hit = cd_run_dialog();
cd_kill_dialog(851);
#endif
}
void put_out_wand_in_dlog() {
#if 0
char str[256];
short i;
cdsin(852,45,store_which_out_wand);
for(i = 0; i < 7; i++)
if(store_out_wand.monst[i] == 0)
csit(852, i + 7, "Empty");
else {
strcpy((char*)str,(char*)scenario.scen_monsters[store_out_wand.monst[i]].m_name.c_str());
csit(852,i + 7,(char *) str);
}
for(i = 0; i < 3; i++)
if(store_out_wand.friendly[i] == 0)
csit(852, i + 7 + 7, "Empty");
else {
strcpy((char*)str,(char*)scenario.scen_monsters[store_out_wand.friendly[i]].m_name.c_str());
csit(852,i + 7 + 7,(char *) str);
}
if(store_out_wand.cant_flee % 10 == 1)
cd_set_led(852,51,1);
else cd_set_led(852,51,0);
if(store_out_wand.cant_flee >= 10)
cd_set_led(852,53,1);
else cd_set_led(852,53,0);
CDSN(852,2,store_out_wand.spec_on_meet);
CDSN(852,3,store_out_wand.spec_on_win);
CDSN(852,4,store_out_wand.spec_on_flee);
CDSN(852,5,store_out_wand.end_spec1);
CDSN(852,6,store_out_wand.end_spec2);
#endif
}
bool get_out_wand_in_dlog() {
#if 0
store_out_wand.spec_on_meet = CDGN(852,2);
store_out_wand.spec_on_win = CDGN(852,3);
store_out_wand.spec_on_flee = CDGN(852,4);
store_out_wand.end_spec1 = CDGN(852,5);
store_out_wand.end_spec2 = CDGN(852,6);
if(cre(store_out_wand.end_spec1,
-1,299,"First part of Stuff Done flag must be from 0 to 299 (or -1 if it's not used).","",852)) return false;
if(cre(store_out_wand.end_spec2,
-1,9,"Second part of Stuff Done flag must be from 0 to 9 (or -1 if it's not used).","",852)) return false;
if(cre(store_out_wand.spec_on_meet,
-1,59,"Outdoor Special Nodes run from 0 to 59 (or -1 if not used).","",852)) return false;
if(cre(store_out_wand.spec_on_win,
-1,59,"Outdoor Special Nodes run from 0 to 59 (or -1 if not used).","",852)) return false;
if(cre(store_out_wand.spec_on_flee,
-1,59,"Outdoor Special Nodes run from 0 to 59 (or -1 if not used).","",852)) return false;
store_out_wand.cant_flee = 0;
if(cd_get_led(852,53) > 0)
store_out_wand.cant_flee += 10;
if(cd_get_led(852,51) > 0)
store_out_wand.cant_flee += 1;
if(store_out_wand_mode == 0)
current_terrain.wandering[store_which_out_wand] = store_out_wand;
else current_terrain.special_enc[store_which_out_wand] = store_out_wand;
#endif
static bool save_town_num(cDialog& me, std::string, eKeyMod) {
if(me.toast(true)) me.setResult<short>(me["town"].getTextAsNum());
return true;
}
void edit_out_wand_event_filter (short item_hit) {
short i,spec;
cCreature store_m;
#if 0
switch(item_hit) {
case 17:
if(!get_out_wand_in_dlog())
break;
toast_dialog();
short pick_town_num(std::string which_dlog,short def) {
using namespace std::placeholders;
cDialog town_dlg(which_dlog);
town_dlg["cancel"].attachClickHandler(std::bind(&cDialog::toast, &town_dlg, false));
town_dlg["okay"].attachClickHandler(save_town_num);
town_dlg["town"].attachFocusHandler(std::bind(check_range, _1, _2, _3, 0, scenario.num_towns - 1, "Town number"));
town_dlg["town"].setTextToNum(def);
std::string prompt = town_dlg["prompt"].getText();
prompt += " (0 - " + std::to_string(scenario.num_towns - 1) + ')';
town_dlg["prompt"].setText(prompt);
town_dlg.setResult<short>(-1);
town_dlg.run();
return town_dlg.getResult<short>();
}
static bool change_ter_event_filter(cDialog& me, std::string item_hit, eKeyMod) {
std::string fld = item_hit.substr(7);
short i = me[fld].getTextAsNum();
i = choose_text(STRT_TER, i, &me, "Which Terrain?");
if(i >= 0) me[fld].setTextToNum(i);
return true;
}
static bool save_ter_change(cDialog& me, std::string, eKeyMod) {
me.setResult(me.toast(true));
return true;
}
bool change_ter(short& change_from,short& change_to,short& chance) {
using namespace std::placeholders;
cDialog chg_dlg("change-terrain.xml");
chg_dlg["cancel"].attachClickHandler(std::bind(&cDialog::toast, &chg_dlg, false));
chg_dlg["okay"].attachClickHandler(save_ter_change);
chg_dlg["chance"].attachFocusHandler(std::bind(check_range, _1, _2, _3, 0, 100, "The chance"));
chg_dlg.attachClickHandlers(change_ter_event_filter, {"choose-from", "choose-to"});
chg_dlg.attachFocusHandlers(std::bind(check_range, _1, _2, _3, 0, 255, "Both terrain types"), {"from", "to"});
chg_dlg.setResult(false);
chg_dlg.run();
change_from = chg_dlg["from"].getTextAsNum();
change_to = chg_dlg["to"].getTextAsNum();
chance = chg_dlg["chance"].getTextAsNum();
return chg_dlg.getResult<bool>();
}
static bool outdoor_details_event_filter(cDialog& me, std::string, eKeyMod) {
if(!me.toast(true)) return true;
current_terrain.out_name = me["name"].getText();
return true;
}
void outdoor_details() {
char temp_str[256];
cDialog out_dlg("edit-outdoor-details.xml");
out_dlg["okay"].attachClickHandler(outdoor_details_event_filter);
snprintf(temp_str,256,"X = %d, Y = %d",cur_out.x,cur_out.y);
out_dlg["loc"].setText(temp_str);
out_dlg["name"].setText(current_terrain.out_name);
out_dlg.run();
}
void put_out_wand_in_dlog(cDialog& me, short which_out_wand, const cOutdoors::cWandering& store_out_wand) {
char str[256];
short i;
me["num"].setTextToNum(which_out_wand);
for(i = 0; i < 7; i++) {
std::string id = "foe" + std::to_string(i + 1);
if(store_out_wand.monst[i] == 0)
me[id].setText("Empty");
// TODO: Wait a second, if 0 is no monster, does that mean it's impossible to use monster 0? Should 1 be subtracted here?
else me[id].setText(scenario.scen_monsters[store_out_wand.monst[i]].m_name);
}
for(i = 0; i < 3; i++) {
std::string id = "ally" + std::to_string(i + 1);
if(store_out_wand.friendly[i] == 0)
me[id].setText("Empty");
// TODO: Wait a second, if 0 is no monster, does that mean it's impossible to use monster 0? Should 1 be subtracted here?
else me[id].setText(scenario.scen_monsters[store_out_wand.friendly[i]].m_name);
}
dynamic_cast<cLed&>(me["no-flee"]).setState(store_out_wand.cant_flee % 10 == 1 ? led_red : led_off);
dynamic_cast<cLed&>(me["forced"]).setState(store_out_wand.cant_flee >= 10 ? led_red : led_off);
me["onmeet"].setTextToNum(store_out_wand.spec_on_meet);
me["onwin"].setTextToNum(store_out_wand.spec_on_win);
me["onflee"].setTextToNum(store_out_wand.spec_on_flee);
me["endx"].setTextToNum(store_out_wand.end_spec1);
me["endy"].setTextToNum(store_out_wand.end_spec2);
}
void save_out_wand(cDialog& me, short store_which_out_wand, cOutdoors::cWandering& store_out_wand, short mode) {
store_out_wand.spec_on_meet = me["onmeet"].getTextAsNum();
store_out_wand.spec_on_win = me["onwin"].getTextAsNum();
store_out_wand.spec_on_flee = me["onflee"].getTextAsNum();
store_out_wand.end_spec1 = me["endx"].getTextAsNum();
store_out_wand.end_spec2 = me["endy"].getTextAsNum();
store_out_wand.cant_flee = 0;
if(dynamic_cast<cLed&>(me["forced"]).getState() != led_off)
store_out_wand.cant_flee += 10;
if(dynamic_cast<cLed&>(me["no-flee"]).getState() != led_off)
store_out_wand.cant_flee += 1;
switch(mode) {
case 0:
current_terrain.wandering[store_which_out_wand] = store_out_wand;
break;
case 18:
toast_dialog();
break;
case 19:
if(!get_out_wand_in_dlog()) break;
store_which_out_wand--;
if(store_which_out_wand < 0) store_which_out_wand = 3;
store_out_wand = (store_out_wand_mode == 0) ?
current_terrain.wandering[store_which_out_wand] : current_terrain.special_enc[store_which_out_wand];
put_out_wand_in_dlog();
break;
case 20:
if(!get_out_wand_in_dlog()) break;
store_which_out_wand++;
if(store_which_out_wand > 3) store_which_out_wand = 0;
store_out_wand = (store_out_wand_mode == 0) ?
current_terrain.wandering[store_which_out_wand] : current_terrain.special_enc[store_which_out_wand];
put_out_wand_in_dlog();
break;
case 31: case 32: case 33:
if(!get_out_wand_in_dlog())
break;
spec = CDGN(852,item_hit - 29);
if((spec < 0) || (spec >= 60)) {
spec = get_fresh_spec(1);
if(spec < 0) {
give_error("You can't create a new 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.",852);
break;
}
CDSN(852,item_hit - 29,spec);
}
edit_spec_enc(spec,1,852);
if((spec >= 0) && (spec < 60) && (current_terrain.specials[spec].pic < 0))
CDSN(852,item_hit - 29,-1);
if(!get_out_wand_in_dlog())
break;
break;
default:
if(!get_out_wand_in_dlog())
break;
cd_flip_led(852,51,item_hit);
cd_flip_led(852,53,item_hit);
if((item_hit >= 21) && (item_hit <= 27)) {
i = choose_text_res(-1,0,255,store_out_wand.monst[item_hit - 21],852,"Choose Which Monster:");
if(i >= 0) store_out_wand.monst[item_hit - 21] = i;
put_out_wand_in_dlog();
}
if((item_hit >= 28) && (item_hit <= 30)) {
i = choose_text_res(-1,0,255,store_out_wand.friendly[item_hit - 28],852,"Choose Which Monster:");
if(i >= 0) store_out_wand.friendly[item_hit - 28] = i;
put_out_wand_in_dlog();
}
case 1:
current_terrain.special_enc[store_which_out_wand] = store_out_wand;
break;
}
#endif
}
static bool edit_out_wand_event_filter(cDialog& me, std::string item_hit, short& store_which_out_wand, cOutdoors::cWandering& store_out_wand, short mode) {
if(!me.toast(true)) return true;
save_out_wand(me, store_which_out_wand, store_out_wand, mode);
short i,spec;
cCreature store_m;
if(item_hit == "left") {
me.untoast();
store_which_out_wand--;
if(store_which_out_wand < 0) store_which_out_wand = 3;
store_out_wand = (mode == 0) ? current_terrain.wandering[store_which_out_wand] : current_terrain.special_enc[store_which_out_wand];
put_out_wand_in_dlog(me, store_which_out_wand, store_out_wand);
} else if(item_hit == "right") {
me.untoast();
store_which_out_wand++;
if(store_which_out_wand > 3) store_which_out_wand = 0;
store_out_wand = (mode == 0) ? current_terrain.wandering[store_which_out_wand] : current_terrain.special_enc[store_which_out_wand];
put_out_wand_in_dlog(me, store_which_out_wand, store_out_wand);
}
return true;
}
static bool edit_out_wand_spec(cDialog& me, std::string item_hit, short which_out_wand, cOutdoors::cWandering store_out_wand) {
if(!me.toast(true)) return true;
me.untoast();
save_out_wand(me, which_out_wand, store_out_wand, 100);
std::string fld = "on" + item_hit.substr(5);
short spec = me[fld].getTextAsNum();
if(spec < 0 || spec >= 60) {
spec = get_fresh_spec(1);
if(spec < 0) {
giveError("You can't create a new 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,1,&me))
me[fld].setTextToNum(spec);
return true;
}
static bool edit_out_wand_monst(cDialog& me, std::string item_hit, short which_out_wand, cOutdoors::cWandering store_out_wand) {
if(!me.toast(true)) return true;
save_out_wand(me, which_out_wand, store_out_wand, 100);
std::string fld = item_hit.substr(7);
short i;
if(fld[0] == 'f') {
i = choose_text(STRT_MONST,store_out_wand.monst[fld[3] - '0'],&me,"Choose Which Monster:");
if(i >= 0) store_out_wand.monst[fld[3] - '0'] = i;
} else if(fld[0] == 'a') {
i = choose_text(STRT_MONST,store_out_wand.friendly[fld[4] - '0'],&me,"Choose Which Monster:");
if(i >= 0) store_out_wand.friendly[fld[4] - '0'] = i;
}
me[fld].setText(scenario.scen_monsters[i].m_name);
return true;
}
// mode 0 - wandering 1 - special
void edit_out_wand(short mode) {
#if 0
short item_hit;
using namespace std::placeholders;
store_which_out_wand = 0;
store_out_wand_mode = mode;
store_out_wand = (store_out_wand_mode == 0) ? current_terrain.wandering[0] : current_terrain.special_enc[0];
short which_out_wand = 0;
cOutdoors::cWandering store_out_wand = (mode == 0) ? current_terrain.wandering[0] : current_terrain.special_enc[0];
cd_create_dialog_parent_num(852,0);
cDialog wand_dlg("edit-outdoor-encounter.xml");
wand_dlg["cancel"].attachClickHandler(std::bind(&cDialog::toast, &wand_dlg, false));
wand_dlg["endx"].attachFocusHandler(std::bind(check_range_msg, _1, _2, _3, -1, 299, "First part of Stuff Done flag", "-1 if not used"));
wand_dlg["endy"].attachFocusHandler(std::bind(check_range_msg, _1, _2, _3, -1, 9, "Second part of Stuff Done flag", "-1 if not used"));
wand_dlg.attachClickHandlers(std::bind(edit_out_wand_event_filter, _1, _2, std::ref(which_out_wand), std::ref(store_out_wand), mode), {"okay", "left", "right"});
wand_dlg.attachClickHandlers(std::bind(edit_out_wand_spec, _1, _2, which_out_wand, std::ref(store_out_wand)), {"edit-meet", "edit-win", "edit-flee"});
wand_dlg.attachClickHandlers(std::bind(edit_out_wand_monst, _1, _2, which_out_wand, std::ref(store_out_wand)), {"choose-foe1", "choose-foe2", "choose-foe3", "choose-foe4", "choose-foe5", "choose-foe6", "choose-foe7", "choose-ally1", "choose-ally2", "choose-ally3"});
wand_dlg.attachFocusHandlers(std::bind(check_range_msg, _1, _2, _3, -1, 59, "Outdoor Special Node", "-1 if not used"), {"onmeet", "onwin", "onflee"});
if(mode == 1)
csit(852,47,"Outdoor Special Encounter:");
wand_dlg["title"].setText("Outdoor Special Encounter:");
put_out_wand_in_dlog();
put_out_wand_in_dlog(wand_dlg, which_out_wand, store_out_wand);
item_hit = cd_run_dialog();
cd_kill_dialog(852);
#endif
wand_dlg.run();
}
bool save_town_details() {
@@ -1317,63 +1238,55 @@ void edit_talk_node(short which_node,short parent_num) {
#endif
}
void pick_out_event_filter (short item_hit) {
char temp_str[256];
#if 0
switch(item_hit) {
case 2:
dialog_answer = store_cur_loc.x * 100 + store_cur_loc.y;
toast_dialog();
break;
case 3:
dialog_answer = -1;
toast_dialog();
break;
case 12:
if(store_cur_loc.x == 0) SysBeep(20);
else store_cur_loc.x--;
break;
case 13:
if(store_cur_loc.x >= scenario.out_width - 1) SysBeep(20);
else store_cur_loc.x++;
break;
case 14:
if(store_cur_loc.y == 0) SysBeep(20);
else store_cur_loc.y--;
break;
case 15:
if(store_cur_loc.y >= scenario.out_height - 1) SysBeep(20);
else store_cur_loc.y++;
break;
}
sprintf((char *) temp_str,"X = %d",store_cur_loc.x);
csit(854,8,(char *) temp_str);
sprintf((char *) temp_str,"Y = %d",store_cur_loc.y);
csit(854,11,(char *) temp_str);
#endif
static void put_out_loc_in_dlog(cDialog& me, location cur_loc) {
std::ostringstream str("X = ");
str << cur_loc.x;
me["x"].setText(str.str());
str.str("Y = ");
str << cur_loc.y;
me["y"].setText(str.str());
}
short pick_out(location default_loc) {
// ignore parent in Mac version
short basic_dlog_hit;
char temp_str[256];
#if 0
store_cur_loc = default_loc;
static bool pick_out_event_filter(cDialog& me, std::string item_hit, location& cur_loc) {
if(item_hit == "xminus") {
if(cur_loc.x == 0) beep();
else cur_loc.x--;
} else if(item_hit == "xplus") {
if(cur_loc.x >= scenario.out_width - 1) beep();
else cur_loc.x++;
} else if(item_hit == "yminus") {
if(cur_loc.y == 0) beep();
else cur_loc.y--;
} else if(item_hit == "yplus") {
if(cur_loc.y >= scenario.out_height - 1) beep();
else cur_loc.y++;
}
put_out_loc_in_dlog(me, cur_loc);
return true;
}
static bool finish_pick_out(cDialog& me, bool okay, location& cur_loc, location orig_loc) {
if(me.toast(okay)) {
if(!okay) cur_loc = orig_loc;
}
return true;
}
location pick_out(location default_loc) {
using namespace std::placeholders;
location prev_loc = default_loc;
cd_create_dialog_parent_num(854,0);
cDialog out_dlg("select-sector.xml");
out_dlg["okay"].attachClickHandler(std::bind(finish_pick_out, _1, true, std::ref(default_loc), prev_loc));
out_dlg["cancel"].attachClickHandler(std::bind(finish_pick_out, _1, false, std::ref(default_loc), prev_loc));
out_dlg.attachClickHandlers(std::bind(pick_out_event_filter, _1, _2, std::ref(default_loc)), {"xplus", "xminus", "yplus", "yminus"});
cdsin(854,7,scenario.out_width);
cdsin(854,10,scenario.out_height);
sprintf((char *) temp_str,"X = %d",store_cur_loc.x);
csit(854,8,(char *) temp_str);
sprintf((char *) temp_str,"Y = %d",store_cur_loc.y);
csit(854,11,(char *) temp_str);
out_dlg["width"].setTextToNum(scenario.out_width);
out_dlg["height"].setTextToNum(scenario.out_height);
put_out_loc_in_dlog(out_dlg, default_loc);
basic_dlog_hit = cd_run_dialog();
cd_kill_dialog(854);
#endif
return 0;//dialog_answer;
out_dlg.run();
return default_loc;
}
void new_town_event_filter (short item_hit) {

View File

@@ -4,8 +4,8 @@ void edit_placed_monst(short which_m);
cCreature edit_placed_monst_adv(cCreature monst_record, class cDialog& parent);
void edit_sign(short which_sign,short picture);
void edit_roomdescs(bool town);
short pick_town_num(short which_dlog,short def);
void change_ter(short *change_from,short *change_to,short *chance);
short pick_town_num(std::string which_dlog,short def);
bool change_ter(short& change_from,short& change_to,short& chance);
void edit_out_wand(short mode);
void outdoor_details();
void edit_town_details();
@@ -13,7 +13,7 @@ void edit_town_events();
void edit_advanced_town();
void edit_basic_dlog(short which_node);
void edit_talk_node(short which_node,short parent_num);
short pick_out(location default_loc);
location pick_out(location default_loc);
short pick_import_town(short def,fs::path& temp_file_to_load);
bool new_town(short which_town);
void edit_placed_item(short which_i);

View File

@@ -0,0 +1,22 @@
<?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='from' type='uint' top='99' left='205' width='64' height='17'>0</field>
<field name='to' type='uint' top='125' left='205' width='64' height='17'>0</field>
<field name='chance' type='uint' top='151' left='205' width='64' height='17'>100</field>
<button name='okay' type='regular' top='177' left='280'>OK</button>
<button name='cancel' type='regular' top='177' left='214' def-key='esc'>Cancel</button>
<pict type='dlog' num='16' top='8' left='8'/>
<text size='large' top='6' left='50' width='167' height='17'>Change Terrain Randomly</text>
<text top='25' left='50' width='286' height='67'>
Select a terrain type and another terrain type to turn it into.
Also give a percentage chance of changing it (0 - 100).
Automatic corrections (like adjusting cave walls) will not be made to these changes.
</text>
<button name='choose-from' type='regular' top='97' left='275'>Choose</button>
<button name='choose-to' type='regular' top='123' left='275'>Choose</button>
<text top='101' left='7' width='164' height='13'>Change this terrain type:</text>
<text top='127' left='7' width='164' height='13'>To this terrain type:</text>
<text top='153' left='7' width='193' height='13'>Chance of changing: (0 - 100)</text>
</dialog>

View File

@@ -0,0 +1,12 @@
<?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='name' top='51' left='162' width='151' height='16'/>
<button name='okay' type='regular' top='74' left='254'>OK</button>
<pict type='dlog' num='16' top='8' left='8'/>
<text size='large' top='6' left='50' width='256' height='17'>Outdoors Details</text>
<text top='53' left='50' width='101' height='14'>Section name:</text>
<text top='29' left='50' width='87' height='14'>Coordinates:</text>
<text name='loc' top='29' left='142' width='127' height='14'/>
</dialog>

View File

@@ -0,0 +1,75 @@
<?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='onmeet' top='216' left='361' width='46' height='16'/>
<field name='onwin' top='259' left='361' width='46' height='16'/>
<field name='onflee' top='302' left='361' width='46' height='16'/>
<field name='endx' top='336' left='460' width='39' height='16'/>
<field name='endy' top='336' left='508' width='39' height='16'/>
<text name='foe1' framed='true' top='135' left='129' width='145' height='14'/>
<text name='foe2' framed='true' top='159' left='129' width='145' height='14'/>
<text name='foe3' framed='true' top='183' left='129' width='145' height='14'/>
<text name='foe4' framed='true' top='207' left='129' width='145' height='14'/>
<text name='foe5' framed='true' top='231' left='129' width='145' height='14'/>
<text name='foe6' framed='true' top='255' left='129' width='145' height='14'/>
<text name='foe7' framed='true' top='279' left='129' width='145' height='14'/>
<text name='ally1' framed='true' top='303' left='129' width='145' height='14'/>
<text name='ally2' framed='true' top='327' left='129' width='145' height='14'/>
<text name='ally3' framed='true' top='351' left='129' width='145' height='14'/>
<button name='okay' type='regular' top='370' left='489'>OK</button>
<button name='cancel' type='regular' def-key='esc' top='370' left='423'>Cancel</button>
<button name='left' type='left' def-key='left' top='370' left='11'/>
<button name='right' type='right' def-key='right' top='370' left='74'/>
<button name='choose-foe1' type='regular' top='130' left='280'>Choose</button>
<button name='choose-foe2' type='regular' top='154' left='280'>Choose</button>
<button name='choose-foe3' type='regular' top='178' left='280'>Choose</button>
<button name='choose-foe4' type='regular' top='202' left='280'>Choose</button>
<button name='choose-foe5' type='regular' top='226' left='280'>Choose</button>
<button name='choose-foe6' type='regular' top='250' left='280'>Choose</button>
<button name='choose-foe7' type='regular' top='274' left='280'>Choose</button>
<button name='choose-ally1' type='regular' top='298' left='280'>Choose</button>
<button name='choose-ally2' type='regular' top='322' left='280'>Choose</button>
<button name='choose-ally3' type='regular' top='346' left='280'>Choose</button>
<button name='edit-meet' type='large' top='213' left='412'>Create/Edit</button>
<button name='edit-win' type='large' top='256' left='412'>Create/Edit</button>
<button name='edit-flee' type='large' top='298' left='412'>Create/Edit</button>
<text top='135' left='11' width='113' height='14'>Hostile (15-30)</text>
<text top='159' left='11' width='113' height='14'>Hostile (7-10)</text>
<text top='183' left='11' width='113' height='14'>Hostile (4-6)</text>
<text top='207' left='11' width='113' height='14'>Hostile (3-5)</text>
<text top='231' left='11' width='113' height='14'>Hostile (2-3)</text>
<text top='255' left='11' width='113' height='14'>Hostile (1-2)</text>
<text top='279' left='11' width='113' height='14'>Hostile (1)</text>
<text top='303' left='11' width='113' height='14'>Friendly (7-10)</text>
<text top='327' left='11' width='113' height='14'>Friendly (2-4)</text>
<text top='351' left='11' width='113' height='14'>Friendly (1)</text>
<text top='97' left='50' width='127' height='14'>Encounter number:</text>
<text name='num' top='97' left='180' width='35' height='14'/>
<pict type='dlog' num='16' top='8' left='8'/>
<text name='title' size='large' top='6' left='50' width='191' height='15'>Outdoor Wandering Encounter:</text>
<text top='22' left='50' width='502' height='17'>
Enter the characteristics for this outdoor encounter.
There are four different wandering and special encounter slots.
To edit the others, use the arrow buttons.
</text>
<text top='53' left='50' width='502' height='39'>
Each encounter contains 10 monster slots, 7 hostile to the party and 3 friendly.
To place monsters in an encounter, press the Choose button by one of the slots.
For more information on how this works, see the documentation.
</text>
<!--
TODO: Put these LED labels in the LED elements
-->
<text top='102' left='349' width='154' height='14'>Monsters can't flee party</text>
<led name='no-flee' top='102' left='522'/>
<text top='117' left='350' width='170' height='27'>Encounter is forced<br/>(Party fights it right away)</text>
<led name='forced' top='117' left='522'/>
<text size='large' top='114' left='11' width='191' height='17'>Monsters in encounter:</text>
<text size='large' top='152' left='350' width='191' height='17'>Advanced encounter traits:</text>
<text top='197' left='352' width='194' height='14'>Special called when enc. starts</text>
<text top='240' left='352' width='194' height='14'>Special called when party winds</text>
<text top='283' left='352' width='194' height='14'>Special called if party flees</text>
<text top='326' left='352' width='103' height='33'>Stuff done flag to eliminate encounter</text>
<text top='168' left='364' width='170' height='27'>Note: Ignore these if you arent sure what they do.</text>
</dialog>

View File

@@ -0,0 +1,19 @@
<?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 -->
<button name='okay' type='regular' top='111' left='189'>OK</button>
<button name='cancel' type='regular' def-key='esc' top='111' left='124'>Cancel</button>
<pict type='dlog' num='16' top='8' left='8'/>
<text size='large' top='6' left='50' width='158' height='16'>Edit Which Outdoor Section?</text>
<text top='25' left='68' width='111' height='14'>World width:</text>
<text name='width' top='25' left='186' width='37'/>
<text name='x' framed='true' top='63' left='142' width='75' height='16'/>
<text top='41' left='68' width='111' height='14'>World height:</text>
<text name='height' top='41' left='186' width='37'/>
<text name='y' framed='true' top='88' left='142' width='75' height='16'/>
<button name='xminus' type='small' top='59' left='77'>-</button>
<button name='xplus' type='small' top='59' left='106'>+</button>
<button name='yminus' type='small' top='84' left='77'>-</button>
<button name='yplus' type='small' top='84' left='106'>+</button>
</dialog>

View 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 type='uint' name='town' top='58' left='102' width='62' height='16'/>
<button name='okay' type='regular' top='82' left='177'>OK</button>
<button name='cancel' type='regular' top='82' left='111'>Cancel</button>
<pict type='dlog' num='16' top='8' left='8'/>
<text size='large' top='6' left='50' width='267' height='17'>Pick Town to Edit:</text>
<text name='prompt' top='25' left='50' width='185' height='28'>
Enter the number of the town you want to edit next:
</text>
</dialog>

View 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 type='uint' name='town' top='71' left='119' width='62' height='16'/>
<button name='okay' type='regular' top='95' left='206'>OK</button>
<button name='cancel' type='regular' top='95' left='140'>Cancel</button>
<pict type='dlog' num='16' top='8' left='8'/>
<text size='large' top='6' left='50' width='267' height='17'>Entrance to what town?</text>
<text name='prompt' top='25' left='50' width='213' height='42'>
What town do you want the party to end up in when they walk into this space?
</text>
</dialog>