The select town/sector dialogs now offer a Choose button

This commit is contained in:
2014-12-27 16:18:05 -05:00
parent d00e44f650
commit ddbc143c84
5 changed files with 34 additions and 11 deletions

View File

@@ -183,7 +183,14 @@ short choose_text(eStrType list, unsigned short cur_choice, cDialog* parent, con
}
break;
case STRT_SECTOR:
// TODO: Generate a list of all outdoor sectors
for(size_t i = 0; i < scenario.outdoors.width(); i++) {
for(size_t j = 0; j < scenario.outdoors.height(); j++) {
std::ostringstream name;
name << '[' << i << ',' << j << ']';
name << ' ' << scenario.outdoors[i][j]->out_name;
strings.push_back(name.str());
}
}
break;
case STRT_MAGE:
for(int i = 0; i < 62; i++) {

View File

@@ -371,6 +371,12 @@ short pick_town_num(std::string which_dlog,short def) {
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["choose"].attachClickHandler([](cDialog& me, std::string, eKeyMod) -> bool {
int i = me["town"].getTextAsNum();
i = choose_text(STRT_TOWN, i, &me, "Which town?");
me["town"].setTextToNum(i);
return true;
});
town_dlg["town"].setTextToNum(def);
std::string prompt = town_dlg["prompt"].getText();
@@ -1118,12 +1124,13 @@ void edit_talk_node(short which_node,short parent_num) {
}
static void put_out_loc_in_dlog(cDialog& me, location cur_loc) {
std::ostringstream str("X = ");
str << cur_loc.x;
std::ostringstream str;
str << "X = " << cur_loc.x;
me["x"].setText(str.str());
str.str("Y = ");
str << cur_loc.y;
str.str("");
str << "Y = " << cur_loc.y;
me["y"].setText(str.str());
me["title"].setText(scenario.outdoors[cur_loc.x][cur_loc.y]->out_name);
}
static bool pick_out_event_filter(cDialog& me, std::string item_hit, location& cur_loc) {
@@ -1139,6 +1146,11 @@ static bool pick_out_event_filter(cDialog& me, std::string item_hit, location& c
} else if(item_hit == "yplus") {
if(cur_loc.y >= scenario.out_height - 1) beep();
else cur_loc.y++;
} else if(item_hit == "choose") {
int i = cur_loc.x * scenario.out_width + cur_loc.y;
i = choose_text(STRT_SECTOR, i, &me, "Which sector?");
cur_loc.x = i / scenario.out_width;
cur_loc.y = i % scenario.out_width;
}
put_out_loc_in_dlog(me, cur_loc);
return true;
@@ -1158,7 +1170,7 @@ location pick_out(location default_loc) {
cDialog out_dlg("select-sector");
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"});
out_dlg.attachClickHandlers(std::bind(pick_out_event_filter, _1, _2, std::ref(default_loc)), {"xplus", "xminus", "yplus", "yminus", "choose"});
out_dlg["width"].setTextToNum(scenario.out_width);
out_dlg["height"].setTextToNum(scenario.out_height);

View File

@@ -2,10 +2,10 @@
<?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>
<button name='okay' type='regular' top='136' left='229'>OK</button>
<button name='cancel' type='regular' def-key='esc' top='136' left='164'>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 size='large' top='6' left='50' width='188' 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'/>
@@ -16,4 +16,6 @@
<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>
<text name='title' framed='true' top='111' left='142' width='150' height='16'/>
<button name='choose' type='regular' top='111' left='66'>Choose</button>
</dialog>

View File

@@ -6,8 +6,9 @@
<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 size='large' top='6' left='50' width='167' 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>
<button name='choose' type='regular' top='56' left='169'>Choose</button>
</dialog>

View File

@@ -6,8 +6,9 @@
<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 size='large' top='6' left='50' width='207' 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>
<button name='choose' type='regular' top='69' left='186'>Choose</button>
</dialog>