Convert five more dialogs and fix the string choice dialog

(The latter was always returning 0)
This commit is contained in:
2014-12-02 03:05:08 -05:00
parent d64770b1e0
commit d61c0a5c1e
8 changed files with 450 additions and 272 deletions

View File

@@ -11,6 +11,7 @@
#include <algorithm> #include <algorithm>
#include <functional> #include <functional>
#include <boost/lexical_cast.hpp>
#include "dialog.h" #include "dialog.h"
#include "dlogutil.h" #include "dlogutil.h"
#include "mathutil.h" #include "mathutil.h"
@@ -131,11 +132,7 @@ cStringChoice::cStringChoice(
std::string title, std::string title,
cDialog* parent cDialog* parent
) : dlg("choose-string.xml",parent) { ) : dlg("choose-string.xml",parent) {
using namespace std::placeholders; attachHandlers();
dlg["left"].attachClickHandler(std::bind(&cStringChoice::onLeft,this,_1,_2));
dlg["right"].attachClickHandler(std::bind(&cStringChoice::onRight,this,_1,_2));
dlg["done"].attachClickHandler(std::bind(&cStringChoice::onOkay,this,_1,_2));
dlg["cancel"].attachClickHandler(std::bind(&cStringChoice::onCancel,this,_1,_2));
if(!title.empty()) dlg["title"].setText(title); if(!title.empty()) dlg["title"].setText(title);
strings = strs; strings = strs;
} }
@@ -146,13 +143,19 @@ cStringChoice::cStringChoice(
std::string title, std::string title,
cDialog* parent cDialog* parent
) : dlg("choose-string.xml",parent) { ) : dlg("choose-string.xml",parent) {
attachHandlers();
if(!title.empty()) dlg["title"].setText(title);
copy(begin,end,std::inserter(strings, strings.begin()));
}
void cStringChoice::attachHandlers() {
using namespace std::placeholders; using namespace std::placeholders;
dlg["left"].attachClickHandler(std::bind(&cStringChoice::onLeft,this,_1,_2)); dlg["left"].attachClickHandler(std::bind(&cStringChoice::onLeft,this,_1,_2));
dlg["right"].attachClickHandler(std::bind(&cStringChoice::onRight,this,_1,_2)); dlg["right"].attachClickHandler(std::bind(&cStringChoice::onRight,this,_1,_2));
dlg["done"].attachClickHandler(std::bind(&cStringChoice::onOkay,this,_1,_2)); dlg["done"].attachClickHandler(std::bind(&cStringChoice::onOkay,this,_1,_2));
dlg["cancel"].attachClickHandler(std::bind(&cStringChoice::onCancel,this,_1,_2)); dlg["cancel"].attachClickHandler(std::bind(&cStringChoice::onCancel,this,_1,_2));
if(!title.empty()) dlg["title"].setText(title); leds = &dynamic_cast<cLedGroup&>(dlg["strings"]);
copy(begin,end,std::inserter(strings, strings.begin())); leds->attachFocusHandler(std::bind(&cStringChoice::onSelect,this,_1,_3));
} }
size_t cStringChoice::show(std::string select){ size_t cStringChoice::show(std::string select){
@@ -215,6 +218,13 @@ bool cStringChoice::onOkay(cDialog& me, std::string id __attribute__((unused))){
return true; return true;
} }
bool cStringChoice::onSelect(cDialog& me, bool losing) {
if(losing) return true;
int i = boost::lexical_cast<int>(leds->getSelected().substr(3));
cur = page * 40 + i - 1;
return true;
}
cChoiceDlog::cChoiceDlog(std::string file, std::vector<std::string> buttons, cDialog* p) : dlg(file, p) { cChoiceDlog::cChoiceDlog(std::string file, std::vector<std::string> buttons, cDialog* p) : dlg(file, p) {
using namespace std::placeholders; using namespace std::placeholders;
std::vector<std::string>::iterator iter = buttons.begin(); std::vector<std::string>::iterator iter = buttons.begin();

View File

@@ -86,9 +86,12 @@ class cStringChoice {
bool onRight(cDialog& me, std::string id); bool onRight(cDialog& me, std::string id);
bool onCancel(cDialog& me, std::string id); bool onCancel(cDialog& me, std::string id);
bool onOkay(cDialog& me, std::string id); bool onOkay(cDialog& me, std::string id);
bool onSelect(cDialog& me, bool losing);
void attachHandlers();
void fillPage(); void fillPage();
std::vector<std::string> strings; std::vector<std::string> strings;
size_t page, cur; size_t page, cur;
cLedGroup* leds;
public: public:
explicit cStringChoice(std::vector<std::string>& strs, std::string title, cDialog* parent = NULL); explicit cStringChoice(std::vector<std::string>& strs, std::string title, cDialog* parent = NULL);
cStringChoice(std::vector<std::string>::iterator begin, std::vector<std::string>::iterator end, std::string title, cDialog* parent = NULL); cStringChoice(std::vector<std::string>::iterator begin, std::vector<std::string>::iterator end, std::string title, cDialog* parent = NULL);

View File

@@ -34,8 +34,6 @@ extern cSpeech null_talk_node;
extern location cur_out; extern location cur_out;
extern short start_volume, start_dir; extern short start_volume, start_dir;
short cur_shortcut;
void init_scenario() { void init_scenario() {
short i; short i;
rectangle dummy_rect; rectangle dummy_rect;
@@ -1252,33 +1250,32 @@ void edit_spec_item(short which_item) {
item_dlg.run(); item_dlg.run();
} }
void put_save_rects_in_dlog() { void put_save_rects_in_dlog(cDialog& me) {
#if 0
short i; short i;
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
CDSN(807,3 + 5 * i,scenario.store_item_rects[i].top); std::string id = std::to_string(i + 1);
CDSN(807,4 + 5 * i,scenario.store_item_rects[i].left); me["top" + id].setTextToNum(scenario.store_item_rects[i].top);
CDSN(807,5 + 5 * i,scenario.store_item_rects[i].bottom); me["left" + id].setTextToNum(scenario.store_item_rects[i].left);
CDSN(807,6 + 5 * i,scenario.store_item_rects[i].right); me["bottom" + id].setTextToNum(scenario.store_item_rects[i].bottom);
CDSN(807,2 + 5 * i,scenario.store_item_towns[i]); me["right" + id].setTextToNum(scenario.store_item_rects[i].right);
me["town" + id].setTextToNum(scenario.store_item_towns[i]);
} }
#endif
} }
bool save_save_rects() { bool save_save_rects(cDialog& me) {
#if 0
short i; short i;
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
scenario.store_item_rects[i].top = CDGN(807,3 + 5 * i); std::string id = std::to_string(i + 1);
scenario.store_item_rects[i].left = CDGN(807,4 + 5 * i); scenario.store_item_rects[i].top = me["top" + id].getTextAsNum();
scenario.store_item_rects[i].bottom = CDGN(807,5 + 5 * i); scenario.store_item_rects[i].left = me["left" + id].getTextAsNum();
scenario.store_item_rects[i].right = CDGN(807,6 + 5 * i); scenario.store_item_rects[i].bottom = me["bottom" + id].getTextAsNum();
scenario.store_item_towns[i] = CDGN(807,2 + 5 * i); scenario.store_item_rects[i].right = me["right" + id].getTextAsNum();
scenario.store_item_towns[i] = me["town" + id].getTextAsNum();
if ((scenario.store_item_towns[i] < -1) || (scenario.store_item_towns[i] >= 200)) { if ((scenario.store_item_towns[i] < -1) || (scenario.store_item_towns[i] >= 200)) {
give_error("Towns must be in 0 to 200 range (or -1 for no save items rectangle).","",807); giveError("Towns must be in 0 to 200 range (or -1 for no save items rectangle).","",&me);
return false; return false;
} }
} }
@@ -1291,353 +1288,249 @@ bool save_save_rects() {
((scenario.store_item_towns[2] == scenario.store_item_towns[0]) && ((scenario.store_item_towns[2] == scenario.store_item_towns[0]) &&
(scenario.store_item_towns[2] >= 0) && (scenario.store_item_towns[0] >= 0)) (scenario.store_item_towns[2] >= 0) && (scenario.store_item_towns[0] >= 0))
) { ) {
give_error("The three towns towns with saved item rectangles must be different.","",807); giveError("The three towns towns with saved item rectangles must be different.","",&me);
return false; return false;
} }
#endif
return true; return true;
} }
void edit_save_rects_event_filter (short save_rects_hit) { bool edit_save_rects_event_filter(cDialog& me, std::string item_hit) {
#if 0 if(item_hit == "cancel") {
switch (save_rects_hit) { me.toast();
case 18: } else if(item_hit == "okay") {
toast_dialog(); if(save_save_rects(me))
break; me.toast();
case 17:
if (save_save_rects() == true)
toast_dialog();
break;
} }
#endif return true;
} }
void edit_save_rects() { void edit_save_rects() {
#if 0 using namespace std::placeholders;
// ignore parent in Mac version
short save_rects_hit;
cd_create_dialog_parent_num(807,0); cDialog save_dlg("edit-save-rects.xml");
save_dlg.attachClickHandlers(std::bind(edit_save_rects_event_filter, _1, _2), {"okay"});
put_save_rects_in_dlog(); put_save_rects_in_dlog(save_dlg);
save_rects_hit = cd_run_dialog(); save_dlg.run();
cd_kill_dialog(807);
#endif
} }
bool save_horses() { bool save_vehicles(cDialog& me, cVehicle* vehicles, const short page) {
#if 0
short i; short i;
for (i = 0; i < 6; i++) { for (i = 0; i < 6; i++) {
scenario.horses[6 * store_horse_page + i].which_town = CDGN(808,2 + i); std::string id = std::to_string(i + 1);
if (cre(scenario.horses[6 * store_horse_page + i].which_town, vehicles[6 * page + i].which_town = me["town" + id].getTextAsNum();
-1,199,"Town number must be from 0 to 199 (or -1 for horse to not exist).","",808) == true) return false; if(cre(vehicles[6 * page + i].which_town,
scenario.horses[6 * store_horse_page + i].loc.x = CDGN(808,8 + i); -1,199,"Town number must be from 0 to 199 (or -1 for it to not exist).","",&me)) return false;
if (cre(scenario.horses[6 * store_horse_page + i].loc.x, vehicles[6 * page + i].loc.x = me["x" + id].getTextAsNum();
0,63,"Horse location coordinates must be from 0 to 63.","",808) == true) return false; if(cre(vehicles[6 * page + i].loc.x,
scenario.horses[6 * store_horse_page + i].loc.y = CDGN(808,14 + i); 0,63,"coordinates must be from 0 to 63.","",&me)) return false;
if (cre(scenario.horses[6 * store_horse_page + i].loc.y, vehicles[6 * page + i].loc.y = me["y" + id].getTextAsNum();
0,63,"Horse location coordinates must be from 0 to 63.","",808) == true) return false; if(cre(vehicles[6 * page + i].loc.y,
scenario.horses[6 * store_horse_page + i].property = cd_get_led(808,43 + i); 0,63,"coordinates must be from 0 to 63.","",&me)) return false;
vehicles[6 * page + i].property = dynamic_cast<cLed&>(me["owned" + id]).getState() != led_off;
} }
#endif
return true; return true;
} }
void put_horses_in_dlog() { void put_vehicles_in_dlog(cDialog& me, cVehicle* vehicles, const short page) {
#if 0
short i; short i;
for (i = 0; i < 6; i++) { for (i = 0; i < 6; i++) {
cdsin(808,23 + i,6 * store_horse_page + i); std::string id = std::to_string(i + 1);
CDSN(808,2 + i,scenario.horses[6 * store_horse_page + i].which_town); me["num" + id].setTextToNum(6 * page + i);
CDSN(808,8 + i,scenario.horses[6 * store_horse_page + i].loc.x); me["town" + id].setTextToNum(vehicles[6 * page + i].which_town);
CDSN(808,14 + i,scenario.horses[6 * store_horse_page + i].loc.y); me["x" + id].setTextToNum(vehicles[6 * page + i].loc.x);
cd_set_led(808,43 + i,scenario.horses[6 * store_horse_page + i].property); me["y" + id].setTextToNum(vehicles[6 * page + i].loc.y);
dynamic_cast<cLed&>(me["owned" + id]).setState(vehicles[6 * page + i].property ? led_red : led_off);
} }
#endif
} }
void edit_horses_event_filter (short item_hit) { bool edit_vehicles_event_filter(cDialog& me, std::string item_hit, cVehicle* vehicles, size_t nVehicles, short& page) {
#if 0
short i; short i;
switch (item_hit) { if(item_hit == "okay") {
case 20: if(save_vehicles(me, vehicles, page))
if (save_horses() == true) me.toast();
toast_dialog(); } else if(item_hit == "left") {
break; if(!save_vehicles(me, vehicles, page)) return true;
case 21: page--;
if (save_horses() == false) break; if(page < 0) page = (nVehicles - 1) / 6;
store_horse_page--; put_vehicles_in_dlog(me, vehicles, page);
if (store_horse_page < 0) store_horse_page = 4; } else if(item_hit == "right") {
put_horses_in_dlog(); if(!save_vehicles(me, vehicles, page)) return true;
break; page++;
case 22: if(page > (nVehicles - 1) / 6) page = 0;
if (save_horses() == false) break; put_vehicles_in_dlog(me, vehicles, page);
store_horse_page++;
if (store_horse_page > 4) store_horse_page = 0;
put_horses_in_dlog();
break;
default:
for (i = 0; i < 6; i++)
cd_flip_led(808,43 + i,item_hit);
break;
} }
#endif return true;
} }
void edit_horses() { void edit_horses() {
#if 0 using namespace std::placeholders;
// ignore parent in Mac version short page = 0;
short horses_hit;
store_horse_page = 0; cDialog horse_dlg("edit-horses.xml");
horse_dlg.attachClickHandlers(std::bind(edit_vehicles_event_filter, _1, _2, scenario.horses, 30, std::ref(page)), {"okay", "left", "right"});
cd_create_dialog_parent_num(808,0); put_vehicles_in_dlog(horse_dlg, scenario.horses, page);
put_horses_in_dlog(); horse_dlg.run();
horses_hit = cd_run_dialog();
cd_kill_dialog(808);
#endif
}
bool save_boats() {
#if 0
short i;
for (i = 0; i < 6; i++) {
scenario.boats[6 * store_boat_page + i].which_town = CDGN(809,2 + i);
if (cre(scenario.boats[6 * store_boat_page + i].which_town,
-1,199,"Town number must be from 0 to 199 (or -1 for boat to not exist).","",809) == true) return false;
scenario.boats[6 * store_boat_page + i].loc.x = CDGN(809,8 + i);
if (cre(scenario.boats[6 * store_boat_page + i].loc.x,
0,63,"boat location coordinates must be from 0 to 63.","",809) == true) return false;
scenario.boats[6 * store_boat_page + i].loc.y = CDGN(809,14 + i);
if (cre(scenario.boats[6 * store_boat_page + i].loc.y,
0,63,"boat location coordinates must be from 0 to 63.","",809) == true) return false;
scenario.boats[6 * store_boat_page + i].property = cd_get_led(809,43 + i);
}
#endif
return true;
}
void put_boats_in_dlog() {
#if 0
short i;
for (i = 0; i < 6; i++) {
cdsin(809,24 + i,6 * store_boat_page + i);
CDSN(809,2 + i,scenario.boats[6 * store_boat_page + i].which_town);
CDSN(809,8 + i,scenario.boats[6 * store_boat_page + i].loc.x);
CDSN(809,14 + i,scenario.boats[6 * store_boat_page + i].loc.y);
cd_set_led(809,43 + i,scenario.boats[6 * store_boat_page + i].property);
}
#endif
}
void edit_boats_event_filter (short item_hit) {
#if 0
short i;
switch (item_hit) {
case 20:
if (save_boats() == true)
toast_dialog();
break;
case 22:
if (save_boats() == false) break;
store_boat_page--;
if (store_boat_page < 0) store_boat_page = 4;
put_boats_in_dlog();
break;
case 23:
if (save_boats() == false) break;
store_boat_page++;
if (store_boat_page > 4) store_boat_page = 0;
put_boats_in_dlog();
break;
default:
for (i = 0; i < 6; i++)
cd_flip_led(809,43 + i,item_hit);
break;
}
#endif
} }
void edit_boats() { void edit_boats() {
#if 0 using namespace std::placeholders;
// ignore parent in Mac version short page = 0;
short boats_hit;
store_boat_page = 0; cDialog boat_dlg("edit-boats.xml");
boat_dlg.attachClickHandlers(std::bind(edit_vehicles_event_filter, _1, _2, scenario.boats, 30, std::ref(page)), {"okay", "left", "right"});
cd_create_dialog_parent_num(809,0); put_vehicles_in_dlog(boat_dlg, scenario.boats, page);
put_boats_in_dlog(); boat_dlg.run();
boats_hit = cd_run_dialog();
cd_kill_dialog(809);
#endif
} }
bool save_add_town() { bool save_add_town(cDialog& me) {
#if 0
short i; short i;
for (i = 0; i < 10; i++) { for (i = 0; i < 10; i++) {
scenario.town_to_add_to[i] = CDGN(810,2 + i); std::string id = std::to_string(i + 1);
scenario.town_to_add_to[i] = me["town" + id].getTextAsNum();
if (cre(scenario.town_to_add_to[i], if (cre(scenario.town_to_add_to[i],
-1,199,"Town number must be from 0 to 199 (or -1 for no effect).","",810) == true) return false; -1,199,"Town number must be from 0 to 199 (or -1 for no effect).","",&me)) return false;
scenario.flag_to_add_to_town[i][0] = CDGN(810,12 + i); scenario.flag_to_add_to_town[i][0] = me["flag" + id + "-x"].getTextAsNum();
if (cre(scenario.flag_to_add_to_town[i][0], if (cre(scenario.flag_to_add_to_town[i][0],
0,299,"First part of flag must be from 0 to 299.","",810) == true) return false; 0,299,"First part of flag must be from 0 to 299.","",&me)) return false;
scenario.flag_to_add_to_town[i][1] = CDGN(810,22 + i); scenario.flag_to_add_to_town[i][1] = me["flag" + id + "-y"].getTextAsNum();
if (cre(scenario.flag_to_add_to_town[i][1], if (cre(scenario.flag_to_add_to_town[i][1],
0,9,"Second part of flag must be from 0 to 9.","",810) == true) return false; 0,9,"Second part of flag must be from 0 to 9.","",&me)) return false;
} }
#endif
return true; return true;
} }
void put_add_town_in_dlog() { void put_add_town_in_dlog(cDialog& me) {
#if 0
short i; short i;
for (i = 0; i < 10; i++) { for (i = 0; i < 10; i++) {
CDSN(810,2 + i,scenario.town_to_add_to[i]); std::string id = std::to_string(i + 1);
CDSN(810,12 + i,scenario.flag_to_add_to_town[i][0]); me["town" + id].setTextToNum(scenario.town_to_add_to[i]);
CDSN(810,22 + i,scenario.flag_to_add_to_town[i][1]); me["flag" + id + "-x"].setTextToNum(scenario.flag_to_add_to_town[i][0]);
me["flag" + id + "-y"].setTextToNum(scenario.flag_to_add_to_town[i][1]);
} }
#endif
} }
void edit_add_town_event_filter (short item_hit) { bool edit_add_town_event_filter(cDialog& me, std::string item_hit) {
#if 0 if(item_hit == "okay") {
switch (item_hit) { if(save_add_town(me))
case 32: me.toast();
if (save_add_town() == true)
toast_dialog();
break;
} }
#endif return true;
} }
void edit_add_town() { void edit_add_town() {
#if 0 using namespace std::placeholders;
// ignore parent in Mac version
short add_town_hit;
cd_create_dialog_parent_num(810,0); cDialog vary_dlg("edit-town-varying.xml");
vary_dlg.attachClickHandlers(std::bind(edit_add_town_event_filter, _1, _2), {"okay"});
put_add_town_in_dlog(); put_add_town_in_dlog(vary_dlg);
add_town_hit = cd_run_dialog(); vary_dlg.run();
cd_kill_dialog(810);
#endif
} }
bool save_item_placement() { bool save_item_placement(cDialog& me, cScenario::cItemStorage& store_storage, short cur_shortcut) {
#if 0
short i; short i;
store_storage.property = cd_get_led(812,38); store_storage.property = dynamic_cast<cLed&>(me["owned"]).getState() != led_off;
store_storage.ter_type = CDGN(812,22); store_storage.ter_type = me["ter"].getTextAsNum();
if (cre(store_storage.ter_type, if (cre(store_storage.ter_type,
-1,255,"Terrain Type must be from 0 to 255 (or -1 for No Shortcut).","",812) == true) return false; -1,255,"Terrain Type must be from 0 to 255 (or -1 for No Shortcut).","",&me)) return false;
for (i = 0; i < 10; i++) { for (i = 0; i < 10; i++) {
store_storage.item_num[i] = CDGN(812,2 + i); std::string id = std::to_string(i + 1);
if (cre(store_storage.item_num[i], store_storage.item_num[i] = me["item" + id].getTextAsNum();
-1,399,"All item numbers must be from 0 to 399 (or -1 for No Item).","",812) == true) return false; if(cre(store_storage.item_num[i],
store_storage.item_odds[i] = CDGN(812,12 + i); -1,399,"All item numbers must be from 0 to 399 (or -1 for No Item).","",&me) == true) return false;
if (cre(store_storage.item_odds[i], store_storage.item_odds[i] = me["odds" + id].getTextAsNum();
0,100,"All item chances must bve from 0 to 100.","",812) == true) return false; if(cre(store_storage.item_odds[i],
0,100,"All item chances must bve from 0 to 100.","",&me) == true) return false;
} }
scenario.storage_shortcuts[cur_shortcut] = store_storage; scenario.storage_shortcuts[cur_shortcut] = store_storage;
#endif
return true; return true;
} }
void put_item_placement_in_dlog() { void put_item_placement_in_dlog(cDialog& me, const cScenario::cItemStorage& store_storage, short cur_shortcut) {
#if 0
short i; short i;
cdsin(812,27,cur_shortcut); me["num"].setTextToNum(cur_shortcut);
cd_set_led(812,38,store_storage.property); dynamic_cast<cLed&>(me["owned"]).setState(store_storage.property ? led_red : led_off);
CDSN(812,22,store_storage.ter_type); me["ter"].setTextToNum(store_storage.ter_type);
for (i = 0; i < 10; i++) { for (i = 0; i < 10; i++) {
CDSN(812,2 + i,store_storage.item_num[i]); std::string id = std::to_string(i + 1);
CDSN(812,12 + i,store_storage.item_odds[i]); me["item" + id].setTextToNum(store_storage.item_num[i]);
me["odds" + id].setTextToNum(store_storage.item_odds[i]);
} }
#endif
} }
void edit_item_placement_event_filter (short item_hit) { bool edit_item_placement_event_filter(cDialog& me, std::string item_hit, cScenario::cItemStorage& store_storage, short& cur_shortcut) {
#if 0
short i; short i;
switch (item_hit) { if(item_hit == "okay") {
case 23: if(save_item_placement(me, store_storage, cur_shortcut))
if (save_item_placement() == true) me.toast();
toast_dialog(); } else if(item_hit == "cancel") {
break; me.toast();
case 24: } else if(item_hit == "left") {
toast_dialog(); if(!save_item_placement(me, store_storage, cur_shortcut)) return true;
break;
case 26:
if (save_item_placement() == false) break;
cur_shortcut--; cur_shortcut--;
if (cur_shortcut < 0) cur_shortcut = 9; if (cur_shortcut < 0) cur_shortcut = 9;
store_storage = scenario.storage_shortcuts[cur_shortcut]; store_storage = scenario.storage_shortcuts[cur_shortcut];
put_item_placement_in_dlog(); put_item_placement_in_dlog(me, store_storage, cur_shortcut);
break; } else if(item_hit == "right") {
case 25: if(!save_item_placement(me, store_storage, cur_shortcut)) return true;
if (save_item_placement() == false) break;
cur_shortcut++; cur_shortcut++;
if (cur_shortcut > 9) cur_shortcut = 0; if (cur_shortcut > 9) cur_shortcut = 0;
store_storage = scenario.storage_shortcuts[cur_shortcut]; store_storage = scenario.storage_shortcuts[cur_shortcut];
put_item_placement_in_dlog(); put_item_placement_in_dlog(me, store_storage, cur_shortcut);
break; } else if(item_hit == "choose-ter") {
case 41: i = me["ter"].getTextAsNum();
store_storage.ter_type = CDGN(812,22); store_storage.ter_type = i;
i = choose_text_res(-4,0,255,store_storage.ter_type,812,"Which Terrain?"); i = choose_text(STRT_TER,i,&me,"Which Terrain?");
if(i >= 0){
me["ter"].setTextToNum(i);
store_storage.ter_type = i; store_storage.ter_type = i;
CDSN(812,22,i); }
break;
default:
if ((item_hit >= 42) && (item_hit <= 51)) {
i = CDGN(812,2 + item_hit - 42);
i = choose_text_res(-2,0,399,i,812,"Place which item?");
if (i >= 0)
CDSN(812,2 + item_hit - 42,i);
break;
}
cd_flip_led(812,38,item_hit);
break;
} }
#endif return true;
}
bool edit_item_placement_select_item(cDialog& me, cScenario::cItemStorage& store_storage, short item_hit) {
std::string id = "item" + std::to_string(item_hit);
short i = me[id].getTextAsNum();
store_storage.item_num[item_hit - 1] = i;
i = choose_text(STRT_ITEM,i,&me,"Place which item?");
if(i >= 0) {
me[id].setTextToNum(i);
store_storage.item_num[item_hit - 1] = i;
}
return true;
} }
void edit_item_placement() { void edit_item_placement() {
#if 0 using namespace std::placeholders;
// ignore parent in Mac version cScenario::cItemStorage store_storage = scenario.storage_shortcuts[0];
short item_placement_hit; short cur_shortcut = 0;
store_storage = scenario.storage_shortcuts[0]; cDialog shortcut_dlg("edit-item-shortcut.xml");
cur_shortcut = 0; shortcut_dlg.attachClickHandlers(std::bind(edit_item_placement_event_filter, _1, _2, std::ref(store_storage), std::ref(cur_shortcut)), {"okay", "cancel", "left", "right", "choose-ter"});
for(int i = 0; i < 10; i++) {
std::string id = "choose-item" + std::to_string(i + 1);
shortcut_dlg[id].attachClickHandler(std::bind(edit_item_placement_select_item, _1, std::ref(store_storage), i + 1));
}
cd_create_dialog_parent_num(812,0); put_item_placement_in_dlog(shortcut_dlg, store_storage, cur_shortcut);
put_item_placement_in_dlog(); shortcut_dlg.run();
item_placement_hit = cd_run_dialog();
cd_kill_dialog(812);
#endif
} }
bool save_scen_details() { bool save_scen_details() {

View File

@@ -0,0 +1,56 @@
<?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='town1' top='100' left='214' width='67' height='16'/>
<field name='town2' top='128' left='214' width='67' height='16'/>
<field name='town3' top='156' left='214' width='67' height='16'/>
<field name='town4' top='184' left='214' width='67' height='16'/>
<field name='town5' top='212' left='214' width='67' height='16'/>
<field name='town6' top='240' left='214' width='67' height='16'/>
<field name='x1' top='100' left='329' width='39' height='16'/>
<field name='x2' top='128' left='329' width='39' height='16'/>
<field name='x3' top='156' left='329' width='39' height='16'/>
<field name='x4' top='184' left='329' width='39' height='16'/>
<field name='x5' top='212' left='329' width='39' height='16'/>
<field name='x6' top='240' left='329' width='39' height='16'/>
<field name='y1' top='100' left='410' width='39' height='16'/>
<field name='y2' top='128' left='410' width='39' height='16'/>
<field name='y3' top='156' left='410' width='39' height='16'/>
<field name='y4' top='184' left='410' width='39' height='16'/>
<field name='y5' top='212' left='410' width='39' height='16'/>
<field name='y6' top='240' left='410' width='39' height='16'/>
<button name='okay' type='regular' top='268' left='468'>OK</button>
<text top='268' left='381' width='75' height='16'/>
<button name='left' type='left' top='268' left='51'/>
<button name='right' type='right' top='268' left='114'/>
<text name='num1' top='100' left='152' width='46' height='14'/>
<text name='num2' top='128' left='152' width='46' height='14'/>
<text name='num3' top='156' left='153' width='46' height='14'/>
<text name='num4' top='184' left='153' width='46' height='14'/>
<text name='num5' top='211' left='153' width='46' height='14'/>
<text name='num6' top='239' left='153' width='46' height='14'/>
<pict type='dlog' num='16' top='8' left='8'/>
<text size='large' top='6' left='50' width='256' height='17'>Edit Boats</text>
<text top='25' left='50' width='439' height='39'>
There can be up to 24 boats in your scenario,
each of which must start in some town.
The boats can start as the parties property, if you want.
If the town is left at -1, the boat wont exist.
</text>
<text top='70' left='199' width='106' height='14'>Town to start in</text>
<text top='64' left='310' width='76' height='25'>X Location in town</text>
<text top='64' left='392' width='81' height='26'>Y Location in town</text>
<text top='100' left='50' width='97' height='14'>Horse number</text>
<text top='128' left='50' width='97' height='14'>Horse number</text>
<text top='156' left='51' width='97' height='14'>Horse number</text>
<text top='184' left='51' width='97' height='14'>Horse number</text>
<text top='211' left='51' width='97' height='14'>Horse number</text>
<text top='239' left='51' width='97' height='14'>Horse number</text>
<text top='64' left='477' width='70' height='26'>Not Party Property</text>
<led name='owned1' state='off' top='100' left='487'/>
<led name='owned2' state='off' top='128' left='487'/>
<led name='owned3' state='off' top='156' left='488'/>
<led name='owned4' state='off' top='184' left='488'/>
<led name='owned5' state='off' top='211' left='488'/>
<led name='owned6' state='off' top='239' left='488'/>
</dialog>

View File

@@ -0,0 +1,60 @@
<?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='town1' top='143' left='214' width='67' height='16'/>
<field name='town2' top='171' left='214' width='67' height='16'/>
<field name='town3' top='199' left='214' width='67' height='16'/>
<field name='town4' top='227' left='214' width='67' height='16'/>
<field name='town5' top='255' left='214' width='67' height='16'/>
<field name='town6' top='283' left='214' width='67' height='16'/>
<field name='x1' top='143' left='329' width='39' height='16'/>
<field name='x2' top='171' left='329' width='39' height='16'/>
<field name='x3' top='199' left='329' width='39' height='16'/>
<field name='x4' top='227' left='329' width='39' height='16'/>
<field name='x5' top='255' left='329' width='39' height='16'/>
<field name='x6' top='283' left='329' width='39' height='16'/>
<field name='y1' top='143' left='410' width='39' height='16'/>
<field name='y2' top='171' left='410' width='39' height='16'/>
<field name='y3' top='199' left='410' width='39' height='16'/>
<field name='y4' top='227' left='410' width='39' height='16'/>
<field name='y5' top='255' left='410' width='39' height='16'/>
<field name='y6' top='283' left='410' width='39' height='16'/>
<button name='okay' type='regular' top='309' left='463'>OK</button>
<button name='left' type='left' top='309' left='52'/>
<button name='right' type='right' top='309' left='115'/>
<text name='num1' top='143' left='152' width='46' height='14'/>
<text name='num2' top='171' left='152' width='46' height='14'/>
<text name='num3' top='199' left='153' width='46' height='14'/>
<text name='num4' top='227' left='153' width='46' height='14'/>
<text name='num5' top='254' left='153' width='46' height='14'/>
<text name='num6' top='282' left='153' width='46' height='14'/>
<pict type='dlog' num='16' top='8' left='8'/>
<text size='large' top='6' left='50' width='256' height='17'>Edit Horses</text>
<text top='25' left='50' width='439' height='39'>
There can be up to 24 horses in your scenario,
each of which must start in some town.
The horses can start as the parties property, if you want.
Leave the town at -1 to make the horse not exist.
</text>
<text top='65' left='50' width='439' height='41'>
Note that horses cant walk over certain terrain types (like floors).
Be careful not to place horses where theyre stuck and cant get out.
This makes them sad.
</text>
<text top='113' left='199' width='106' height='14'>Town to start in</text>
<text top='107' left='310' width='76' height='25'>X Location in town</text>
<text top='107' left='392' width='81' height='26'>Y Location in town</text>
<text top='143' left='50' width='97' height='14'>Horse number</text>
<text top='171' left='50' width='97' height='14'>Horse number</text>
<text top='199' left='51' width='97' height='14'>Horse number</text>
<text top='227' left='51' width='97' height='14'>Horse number</text>
<text top='254' left='51' width='97' height='14'>Horse number</text>
<text top='282' left='51' width='97' height='14'>Horse number</text>
<text top='107' left='477' width='70' height='26'>Not Party Property</text>
<led name='owned1' state='off' top='143' left='488'/>
<led name='owned2' state='off' top='171' left='488'/>
<led name='owned3' state='off' top='199' left='488'/>
<led name='owned4' state='off' top='227' left='488'/>
<led name='owned5' state='off' top='254' left='488'/>
<led name='owned6' state='off' top='282' left='488'/>
</dialog>

View File

@@ -0,0 +1,63 @@
<?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='item1' top='188' left='73' width='39' height='16'/>
<field name='item2' top='216' left='73' width='39' height='16'/>
<field name='item3' top='244' left='73' width='39' height='16'/>
<field name='item4' top='272' left='73' width='39' height='16'/>
<field name='item5' top='300' left='73' width='39' height='16'/>
<field name='item6' top='188' left='309' width='39' height='16'/>
<field name='item7' top='216' left='309' width='39' height='16'/>
<field name='item8' top='244' left='309' width='39' height='16'/>
<field name='item9' top='272' left='309' width='39' height='16'/>
<field name='item10' top='300' left='309' width='39' height='16'/>
<field name='odds1' top='188' left='192' width='39' height='16'/>
<field name='odds2' top='216' left='192' width='39' height='16'/>
<field name='odds3' top='244' left='192' width='39' height='16'/>
<field name='odds4' top='272' left='192' width='39' height='16'/>
<field name='odds5' top='300' left='192' width='39' height='16'/>
<field name='odds6' top='188' left='428' width='39' height='16'/>
<field name='odds7' top='216' left='428' width='39' height='16'/>
<field name='odds8' top='244' left='428' width='39' height='16'/>
<field name='odds9' top='272' left='428' width='39' height='16'/>
<field name='odds10' top='300' left='428' width='39' height='16'/>
<field name='ter' top='113' left='410' width='42' height='17'/>
<button name='okay' type='regular' top='334' left='462'>OK</button>
<button name='cancel' type='regular' top='334' left='396' def-key='esc'>Cancel</button>
<button name='right' type='right' top='334' left='73' def-key='right'/>
<button name='left' type='left' top='334' left='10' def-key='left'/>
<text name='num' top='115' left='211' width=' 46' height='14'/>
<pict type='dlog' num='16' top='8' left='8'/>
<text size='large' top='6' left='50' width='256' height='20'>Item Placement Shortcuts</text>
<text top='25' left='50' width='439' height='40'>
You can design shortcuts for automatic placement of items in towns.
When editing towns, if you select the Place Automatic Items menu item,
the edit will randomly place items you specify in terrain types you specify.
</text>
<text top='66' left='50' width='439' height='41'>
Enter the terrain type to get the items,
the numbers of the items to place,
and the percentage chance (0-100) that the item is places there.
For more details, see the documentation.
</text>
<text top='115' left='50' width='155' height='14'>Item shortcut number:</text>
<text top='115' left='269' width='136' height='14'>Terrain type number:</text>
<text top='154' left='50' width='98' height='26'>Number of item to place:</text>
<text top='154' left='159' width='119' height='26'>Chance of placing: (0-100%)</text>
<text top='154' left='286' width='99' height='36'>Number of item to place:</text>
<text top='154' left='395' width='119' height='26'>Chance of placing: (0-100%)</text>
<led name='owned' state='off' top='138' left='215'/>
<text top='134' left=' 50' width='155' height='14'>Items are always property:</text>
<text top='134' left='277' width='297' height='14'>(Leave this at -1 for no shortcut.)</text>
<button name='choose-ter' type='regular' top='110' left='458'>Choose</button>
<button name='choose-item1' type='regular' top='185' left='118'>Choose</button>
<button name='choose-item2' type='regular' top='213' left='118'>Choose</button>
<button name='choose-item3' type='regular' top='241' left='118'>Choose</button>
<button name='choose-item4' type='regular' top='270' left='118'>Choose</button>
<button name='choose-item5' type='regular' top='298' left='118'>Choose</button>
<button name='choose-item6' type='regular' top='185' left='354'>Choose</button>
<button name='choose-item7' type='regular' top='213' left='354'>Choose</button>
<button name='choose-item8' type='regular' top='241' left='354'>Choose</button>
<button name='choose-item9' type='regular' top='270' left='354'>Choose</button>
<button name='choose-item10' type='regular' top='298' left='354'>Choose</button>
</dialog>

View File

@@ -0,0 +1,42 @@
<?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='town1' top='161' left='214' width='67' height='16'/>
<field name='top1' top='161' left='293' width='39' height='16'/>
<field name='left1' top='161' left='343' width='39' height='16'/>
<field name='bottom1' top='161' left='393' width='39' height='16'/>
<field name='right1' top='161' left='443' width='39' height='16'/>
<field name='town2' top='189' left='214' width='67' height='16'/>
<field name='top2' top='189' left='293' width='39' height='16'/>
<field name='left2' top='189' left='343' width='39' height='16'/>
<field name='bottom2' top='189' left='393' width='39' height='16'/>
<field name='right2' top='189' left='443' width='39' height='16'/>
<field name='town3' top='217' left='214' width='67' height='16'/>
<field name='top3' top='217' left='293' width='39' height='16'/>
<field name='left3' top='217' left='343' width='39' height='16'/>
<field name='bottom3' top='217' left='393' width='39' height='16'/>
<field name='right3' top='217' left='443' width='39' height='16'/>
<button name='okay' type='regular' top='248' left='413'>OK</button>
<pict type='dlog' num='16' top='8' left='8'/>
<text size='large' top='6' left='50' width='256' height='44'>Save Items Rectangles</text>
<text top='25' left='50' width='438' height='53'>
There can be areas in towns where items left there are remembered,
even after the party leaves town.
Enter the numbers of the towns where items are saved (-1 means no area),
and the rectangles where the items left are remembered.
</text>
<text top='79' left='50' width='438' height='54'>
if the party leaves the given town with an item on the ground inside the given rectangle,
the item will still be there when they get back.
If the item is not inside the rectangle, it is lost.
Note that the three towns must be different.
</text>
<text top='164' left='50' width='153' height='14'>Items save rectangle 1</text>
<text top='192' left='50' width='153' height='14'>Items save rectangle 2</text>
<text top='220' left='50' width='153' height='14'>Items save rectangle 3</text>
<text top='139' left='211' width='70' height='14'>Town num.</text>
<text top='139' left='290' width='38' height='14'>Top</text>
<text top='139' left='344' width='38' height='14'>Left</text>
<text top='139' left='389' width='47' height='14'>Bottom</text>
<text top='139' left='441' width='40' height='14'>Right</text>
</dialog>

View File

@@ -0,0 +1,51 @@
<?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='town1' top='130' left='146' width='67' height='16'/>
<field name='town2' top='158' left='146' width='67' height='16'/>
<field name='town3' top='186' left='146' width='67' height='16'/>
<field name='town4' top='214' left='146' width='67' height='16'/>
<field name='town5' top='242' left='146' width='67' height='16'/>
<field name='town6' top='270' left='146' width='67' height='16'/>
<field name='town7' top='298' left='146' width='67' height='16'/>
<field name='town8' top='326' left='146' width='67' height='16'/>
<field name='town9' top='354' left='146' width='67' height='16'/>
<field name='town10' top='382' left='146' width='67' height='16'/>
<field name='flag1-x' top='130' left='258' width='40' height='16'/>
<field name='flag2-x' top='158' left='258' width='40' height='16'/>
<field name='flag3-x' top='186' left='258' width='40' height='16'/>
<field name='flag4-x' top='214' left='258' width='40' height='16'/>
<field name='flag5-x' top='242' left='258' width='40' height='16'/>
<field name='flag6-x' top='270' left='258' width='40' height='16'/>
<field name='flag7-x' top='298' left='258' width='40' height='16'/>
<field name='flag8-x' top='326' left='258' width='40' height='16'/>
<field name='flag9-x' top='354' left='258' width='40' height='16'/>
<field name='flag10-x' top='382' left='258' width='40' height='16'/>
<field name='flag1-y' top='130' left='344' width='40' height='16'/>
<field name='flag2-y' top='158' left='344' width='40' height='16'/>
<field name='flag3-y' top='186' left='344' width='40' height='16'/>
<field name='flag4-y' top='214' left='344' width='40' height='16'/>
<field name='flag5-y' top='242' left='344' width='40' height='16'/>
<field name='flag6-y' top='270' left='344' width='40' height='16'/>
<field name='flag7-y' top='298' left='344' width='40' height='16'/>
<field name='flag8-y' top='326' left='344' width='40' height='16'/>
<field name='flag9-y' top='354' left='344' width='40' height='16'/>
<field name='flag10-y' top='382' left='344' width='40' height='16'/>
<button name='okay' type='regular' top='379' left='419'>OK</button>
<pict type='dlog' num='16' top='8' left='8'/>
<text size='large' top='6' left='50' width='256' height='44'>Variable Town Entry</text>
<text top='25' left='50' width='439' height='40'>
When the party enters a town,
you can have the exact town entered vary,
depending on circumstances.
To do this, specify a town number below,
and the Stuff Done flag to add to the town number when that town is entered.
</text>
<text top='68' left='50' width='439' height='27'>
Leave the town at -1 for this to have no effect.
For more information on how this works, see the documentation.
</text>
<text top='102' left='131' width='100' height='14'>Town entered</text>
<text top='96' left='235' width='96' height='25'>Stuff Done Flag to add X</text>
<text top='96' left='329' width='96' height='25'>Stuff Done Flag to add Y</text>
</dialog>