Move Set Town Start to Town menu and make it work the same as Set Out Start
- Also fix problem with initial starting town in new scenarios (it was uninitialized)
This commit is contained in:
@@ -66,6 +66,7 @@ cScenario::cScenario() {
|
||||
format.prog_make_ver[0] = 2;
|
||||
init_spec = -1;
|
||||
default_ground = 2;
|
||||
which_town_start = 0;
|
||||
where_start.x = 24;
|
||||
where_start.y = 24;
|
||||
out_start = where_start = loc(24,24);
|
||||
|
||||
@@ -1140,9 +1140,7 @@ static bool handle_terrain_action(location the_point, bool ctrl_hit) {
|
||||
overall_mode = MODE_DRAWING;
|
||||
change_made = true;
|
||||
break;
|
||||
case MODE_SET_OUT_START: //edit out start loc
|
||||
if(cChoiceDlog("set-out-start-confirm", {"okay", "cancel"}).show() == "cancel")
|
||||
break;
|
||||
case MODE_SET_OUT_START:
|
||||
if((spot_hit.x != minmax(4,43,spot_hit.x)) || (spot_hit.y != minmax(4,43,spot_hit.y))) {
|
||||
showError("You can't put the starting location this close to the edge of an outdoor section. It has to be at least 4 spaces away.");
|
||||
break;
|
||||
@@ -1174,7 +1172,15 @@ static bool handle_terrain_action(location the_point, bool ctrl_hit) {
|
||||
town->preset_items.pop_back();
|
||||
overall_mode = MODE_DRAWING;
|
||||
break;
|
||||
case MODE_SET_TOWN_START: // TODO: Implement this
|
||||
case MODE_SET_TOWN_START:
|
||||
if(!town->in_town_rect.contains(spot_hit)) {
|
||||
showError("You can't put the starting location outside the town boundaries.");
|
||||
break;
|
||||
}
|
||||
scenario.which_town_start = cur_town;
|
||||
scenario.where_start = spot_hit;
|
||||
overall_mode = MODE_DRAWING;
|
||||
change_made = true;
|
||||
break;
|
||||
case MODE_INTRO_SCREEN:
|
||||
case MODE_EDIT_TYPES:
|
||||
|
||||
@@ -3113,42 +3113,6 @@ bool build_scenario() {
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool check_location_bounds(cDialog& me, std::string id, bool losing) {
|
||||
if(!losing) return true;
|
||||
short town_num = me["town-num"].getTextAsNum();
|
||||
short dim = me[id].getTextAsNum();
|
||||
if(dim < 0 || dim >= scenario.towns[town_num]->max_dim()) {
|
||||
showError("This coordinate is not inside the bounds of the town.");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool set_starting_loc_filter(cDialog& me, std::string, eKeyMod) {
|
||||
if(me.toast(true)) {
|
||||
scenario.which_town_start = me["town-num"].getTextAsNum();
|
||||
scenario.where_start.x = me["town-x"].getTextAsNum();
|
||||
scenario.where_start.y = me["town-y"].getTextAsNum();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void set_starting_loc() {
|
||||
using namespace std::placeholders;
|
||||
|
||||
cDialog loc_dlg("set-start-loc");
|
||||
loc_dlg["cancel"].attachClickHandler(std::bind(&cDialog::toast, &loc_dlg, false));
|
||||
loc_dlg["okay"].attachClickHandler(set_starting_loc_filter);
|
||||
loc_dlg["town-num"].attachFocusHandler(std::bind(check_range, _1, _2, _3, 0, scenario.towns.size() - 1, "The starting town"));
|
||||
loc_dlg.attachFocusHandlers(check_location_bounds, {"town-x", "town-y"});
|
||||
|
||||
loc_dlg["town-num"].setTextToNum(scenario.which_town_start);
|
||||
loc_dlg["town-x"].setTextToNum(scenario.where_start.x);
|
||||
loc_dlg["town-y"].setTextToNum(scenario.where_start.y);
|
||||
|
||||
loc_dlg.run();
|
||||
}
|
||||
|
||||
static bool save_scenario_events(cDialog& me, std::string, eKeyMod) {
|
||||
short i;
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ bool edit_make_scen_2(short& out_w, short& out_h, short& town_l, short& town_m,
|
||||
bool edit_make_scen_1(std::string& filename,std::string& title,bool& grass);
|
||||
void edit_scenario_events();
|
||||
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);
|
||||
|
||||
@@ -315,8 +315,8 @@ void handle_menu_choice(eMenu item_hit) {
|
||||
change_made = true;
|
||||
break;
|
||||
case eMenu::TOWN_START:
|
||||
set_starting_loc();
|
||||
change_made = true;
|
||||
overall_mode = MODE_SET_TOWN_START;
|
||||
set_string("Select party starting location.","");
|
||||
break;
|
||||
case eMenu::SCEN_SHEETS:
|
||||
edit_custom_sheets();
|
||||
|
||||
@@ -53,14 +53,15 @@ void init_menubar() {
|
||||
};
|
||||
static const eMenu scen_choices[] = {
|
||||
eMenu::TOWN_CREATE, eMenu::OUT_RESIZE, eMenu::NONE,
|
||||
eMenu::SCEN_DETAILS, eMenu::SCEN_INTRO, eMenu::TOWN_START, eMenu::SCEN_SHEETS, eMenu::SCEN_PICS, eMenu::SCEN_SNDS, eMenu::NONE, eMenu::NONE,
|
||||
eMenu::SCEN_DETAILS, eMenu::SCEN_INTRO, eMenu::SCEN_SHEETS, eMenu::SCEN_PICS, eMenu::SCEN_SNDS, eMenu::NONE, eMenu::NONE,
|
||||
eMenu::SCEN_SPECIALS, eMenu::SCEN_TEXT, eMenu::SCEN_JOURNALS, eMenu::TOWN_IMPORT, eMenu::OUT_IMPORT, eMenu::SCEN_SAVE_ITEM_RECTS,
|
||||
eMenu::SCEN_HORSES, eMenu::SCEN_BOATS, eMenu::TOWN_VARYING, eMenu::SCEN_TIMERS, eMenu::SCEN_ITEM_SHORTCUTS,
|
||||
eMenu::TOWN_DELETE, eMenu::SCEN_DATA_DUMP, eMenu::SCEN_TEXT_DUMP,
|
||||
};
|
||||
static const eMenu town_choices[] = {
|
||||
eMenu::TOWN_DETAILS, eMenu::TOWN_WANDERING, eMenu::TOWN_BOUNDARIES, eMenu::FRILL, eMenu::UNFRILL, eMenu::TOWN_AREAS,
|
||||
eMenu::NONE, eMenu::TOWN_ITEMS_RANDOM, eMenu::TOWN_ITEMS_NOT_PROPERTY, eMenu::TOWN_ITEMS_CLEAR, eMenu::NONE, eMenu::NONE,
|
||||
eMenu::NONE, eMenu::TOWN_START, eMenu::TOWN_ITEMS_RANDOM, eMenu::TOWN_ITEMS_NOT_PROPERTY, eMenu::TOWN_ITEMS_CLEAR,
|
||||
eMenu::NONE, eMenu::NONE,
|
||||
eMenu::TOWN_SPECIALS, eMenu::TOWN_TEXT, eMenu::TOWN_SIGNS, eMenu::TOWN_ADVANCED, eMenu::TOWN_TIMERS,
|
||||
};
|
||||
static const eMenu out_choices[] = {
|
||||
|
||||
@@ -81,14 +81,15 @@ void init_menubar() {
|
||||
};
|
||||
static const eMenu scen_choices[] = {
|
||||
eMenu::TOWN_CREATE, eMenu::OUT_RESIZE, eMenu::NONE,
|
||||
eMenu::SCEN_DETAILS, eMenu::SCEN_INTRO, eMenu::TOWN_START, eMenu::SCEN_SHEETS, eMenu::SCEN_PICS, eMenu::SCEN_SNDS, eMenu::NONE, eMenu::NONE,
|
||||
eMenu::SCEN_DETAILS, eMenu::SCEN_INTRO, eMenu::SCEN_SHEETS, eMenu::SCEN_PICS, eMenu::SCEN_SNDS, eMenu::NONE, eMenu::NONE,
|
||||
eMenu::SCEN_SPECIALS, eMenu::SCEN_TEXT, eMenu::SCEN_JOURNALS, eMenu::TOWN_IMPORT, eMenu::OUT_IMPORT, eMenu::SCEN_SAVE_ITEM_RECTS,
|
||||
eMenu::SCEN_HORSES, eMenu::SCEN_BOATS, eMenu::TOWN_VARYING, eMenu::SCEN_TIMERS, eMenu::SCEN_ITEM_SHORTCUTS,
|
||||
eMenu::TOWN_DELETE, eMenu::SCEN_DATA_DUMP, eMenu::SCEN_TEXT_DUMP,
|
||||
};
|
||||
static const eMenu town_choices[] = {
|
||||
eMenu::TOWN_DETAILS, eMenu::TOWN_WANDERING, eMenu::TOWN_BOUNDARIES, eMenu::FRILL, eMenu::UNFRILL, eMenu::TOWN_AREAS,
|
||||
eMenu::NONE, eMenu::TOWN_ITEMS_RANDOM, eMenu::TOWN_ITEMS_NOT_PROPERTY, eMenu::TOWN_ITEMS_CLEAR, eMenu::NONE, eMenu::NONE,
|
||||
eMenu::NONE, eMenu::TOWN_START, eMenu::TOWN_ITEMS_RANDOM, eMenu::TOWN_ITEMS_NOT_PROPERTY, eMenu::TOWN_ITEMS_CLEAR,
|
||||
eMenu::NONE, eMenu::NONE,
|
||||
eMenu::TOWN_SPECIALS, eMenu::TOWN_TEXT, eMenu::TOWN_SIGNS, eMenu::TOWN_ADVANCED, eMenu::TOWN_TIMERS,
|
||||
};
|
||||
static const eMenu out_choices[] = {
|
||||
|
||||
Reference in New Issue
Block a user