make switching outdoor sections DRY
This commit is contained in:
@@ -236,10 +236,7 @@ static bool handle_lb_action(location the_point) {
|
|||||||
file_to_load = nav_get_scenario();
|
file_to_load = nav_get_scenario();
|
||||||
if(!file_to_load.empty() && load_scenario(file_to_load, scenario)) {
|
if(!file_to_load.empty() && load_scenario(file_to_load, scenario)) {
|
||||||
set_current_town(scenario.last_town_edited);
|
set_current_town(scenario.last_town_edited);
|
||||||
cur_out = scenario.last_out_edited;
|
set_current_out(scenario.last_out_edited);
|
||||||
current_terrain = scenario.outdoors[cur_out.x][cur_out.y];
|
|
||||||
overall_mode = MODE_MAIN_SCREEN;
|
|
||||||
set_up_main_screen();
|
|
||||||
} else if(!file_to_load.empty())
|
} else if(!file_to_load.empty())
|
||||||
// If we tried to load but failed, the scenario record is messed up, so boot to start screen.
|
// If we tried to load but failed, the scenario record is messed up, so boot to start screen.
|
||||||
set_up_start_screen();
|
set_up_start_screen();
|
||||||
@@ -277,9 +274,7 @@ static bool handle_lb_action(location the_point) {
|
|||||||
case LB_LOAD_OUT:
|
case LB_LOAD_OUT:
|
||||||
spot_hit = pick_out(cur_out, scenario);
|
spot_hit = pick_out(cur_out, scenario);
|
||||||
if(spot_hit != cur_out) {
|
if(spot_hit != cur_out) {
|
||||||
cur_out = spot_hit;
|
set_current_out(spot_hit);
|
||||||
current_terrain = scenario.outdoors[cur_out.x][cur_out.y];
|
|
||||||
set_up_main_screen();
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case LB_EDIT_OUT:
|
case LB_EDIT_OUT:
|
||||||
|
@@ -52,11 +52,9 @@ void set_up_apple_events() {
|
|||||||
|
|
||||||
if(load_scenario(fileName, scenario)) {
|
if(load_scenario(fileName, scenario)) {
|
||||||
set_current_town(scenario.last_town_edited);
|
set_current_town(scenario.last_town_edited);
|
||||||
cur_out = scenario.last_out_edited;
|
|
||||||
current_terrain = scenario.outdoors[cur_out.x][cur_out.y];
|
|
||||||
change_made = false;
|
change_made = false;
|
||||||
ae_loading = true;
|
ae_loading = true;
|
||||||
set_up_main_screen();
|
set_current_out(scenario.last_out_edited);
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@@ -304,11 +304,9 @@ static void process_args(int argc, char* argv[]) {
|
|||||||
if(!file.empty()) {
|
if(!file.empty()) {
|
||||||
if(load_scenario(file, scenario)) {
|
if(load_scenario(file, scenario)) {
|
||||||
set_current_town(scenario.last_town_edited);
|
set_current_town(scenario.last_town_edited);
|
||||||
cur_out = scenario.last_out_edited;
|
|
||||||
current_terrain = scenario.outdoors[cur_out.x][cur_out.y];
|
|
||||||
change_made = false;
|
change_made = false;
|
||||||
ae_loading = true;
|
ae_loading = true;
|
||||||
set_up_main_screen();
|
set_current_out(scenario.last_out_edited);
|
||||||
} else {
|
} else {
|
||||||
std::cout << "Failed to load scenario: " << file << std::endl;
|
std::cout << "Failed to load scenario: " << file << std::endl;
|
||||||
}
|
}
|
||||||
@@ -449,11 +447,8 @@ void handle_menu_choice(eMenu item_hit) {
|
|||||||
if(!file_to_load.empty() && load_scenario(file_to_load, scenario)) {
|
if(!file_to_load.empty() && load_scenario(file_to_load, scenario)) {
|
||||||
cur_town = scenario.last_town_edited;
|
cur_town = scenario.last_town_edited;
|
||||||
town = scenario.towns[cur_town];
|
town = scenario.towns[cur_town];
|
||||||
cur_out = scenario.last_out_edited;
|
|
||||||
current_terrain = scenario.outdoors[cur_out.x][cur_out.y];
|
|
||||||
overall_mode = MODE_MAIN_SCREEN;
|
|
||||||
change_made = false;
|
change_made = false;
|
||||||
set_up_main_screen();
|
set_current_out(scenario.last_out_edited);
|
||||||
} else if(!file_to_load.empty())
|
} else if(!file_to_load.empty())
|
||||||
set_up_start_screen(); // Failed to load file, dump to start
|
set_up_start_screen(); // Failed to load file, dump to start
|
||||||
undo_list.clear();
|
undo_list.clear();
|
||||||
|
@@ -1296,6 +1296,13 @@ void set_current_town(int to) {
|
|||||||
scenario.last_town_edited = cur_town;
|
scenario.last_town_edited = cur_town;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void set_current_out(location out_sec) {
|
||||||
|
cur_out = out_sec;
|
||||||
|
scenario.last_out_edited = cur_out;
|
||||||
|
current_terrain = scenario.outdoors[cur_out.x][cur_out.y];
|
||||||
|
set_up_main_screen();
|
||||||
|
}
|
||||||
|
|
||||||
aNewTown::aNewTown(cTown* t)
|
aNewTown::aNewTown(cTown* t)
|
||||||
: cAction("add town")
|
: cAction("add town")
|
||||||
, theTown(t)
|
, theTown(t)
|
||||||
|
@@ -23,3 +23,4 @@ void edit_placed_item(short which_i);
|
|||||||
void delete_last_town();
|
void delete_last_town();
|
||||||
void edit_town_wand();
|
void edit_town_wand();
|
||||||
void set_current_town(int to);
|
void set_current_town(int to);
|
||||||
|
void set_current_out(location out_sec);
|
||||||
|
Reference in New Issue
Block a user