when replaying, don't open file browsers
This commit is contained in:
@@ -21,6 +21,9 @@ class cUniverse;
|
||||
fs::path locate_scenario(std::string scen_name);
|
||||
bool load_scenario(fs::path file_to_load, cScenario& scenario, bool only_header = false);
|
||||
|
||||
fs::path nav_get_or_decode_party();
|
||||
fs::path nav_put_or_temp_party(fs::path def = "");
|
||||
|
||||
bool load_party(fs::path file_to_load, cUniverse& univ);
|
||||
bool save_party(fs::path dest_file, const cUniverse& univ);
|
||||
|
||||
|
@@ -30,6 +30,28 @@ extern cCustomGraphics spec_scen_g;
|
||||
static bool load_party_v1(fs::path file_to_load, cUniverse& univ, bool town_restore, bool in_scen, bool maps_there, bool must_port);
|
||||
static bool load_party_v2(fs::path file_to_load, cUniverse& univ);
|
||||
|
||||
fs::path nav_get_party();
|
||||
|
||||
fs::path nav_get_or_decode_party() {
|
||||
if(replaying){
|
||||
Element* next_action = pop_next_action("load_party");
|
||||
decode_file(next_action->GetText(), tempDir / "temp.exg");
|
||||
return tempDir / "temp.exg";
|
||||
}else{
|
||||
return nav_get_party();
|
||||
}
|
||||
}
|
||||
|
||||
fs::path nav_put_party(fs::path def);
|
||||
|
||||
fs::path nav_put_or_temp_party(fs::path def) {
|
||||
if(replaying){
|
||||
return tempDir / "temp.exg";
|
||||
}else{
|
||||
return nav_put_party(def);
|
||||
}
|
||||
}
|
||||
|
||||
bool load_party(fs::path file_to_load, cUniverse& univ){
|
||||
bool town_restore = false;
|
||||
bool maps_there = false;
|
||||
|
@@ -1010,7 +1010,7 @@ static void handle_victory() {
|
||||
univ.party.scen_name = ""; // should be harmless...
|
||||
if(cChoiceDlog("congrats-save",{"cancel","save"}).show() == "save"){
|
||||
// TODO: Wait, this shouldn't be a "save as" action, should it? It should save without asking for a location.
|
||||
fs::path file = nav_put_party();
|
||||
fs::path file = nav_put_or_temp_party();
|
||||
if(!file.empty()) save_party(file, univ);
|
||||
}
|
||||
}
|
||||
@@ -2153,7 +2153,7 @@ bool handle_scroll(const sf::Event& event) {
|
||||
}
|
||||
|
||||
void do_load() {
|
||||
fs::path file_to_load = nav_get_party();
|
||||
fs::path file_to_load = nav_get_or_decode_party();
|
||||
if(file_to_load.empty()) return;
|
||||
if(!load_party(file_to_load, univ))
|
||||
return;
|
||||
@@ -2203,7 +2203,7 @@ void do_save(short mode) {
|
||||
if(univ.party.is_in_scenario()) save_outdoor_maps();
|
||||
fs::path file = univ.file;
|
||||
if(mode == 1 || file.empty())
|
||||
file = nav_put_party(file);
|
||||
file = nav_put_or_temp_party(file);
|
||||
bool saved = false;
|
||||
if(!file.empty()) {
|
||||
univ.file = file;
|
||||
@@ -2595,7 +2595,7 @@ void handle_death() {
|
||||
return;
|
||||
}
|
||||
else if(choice == "load") {
|
||||
fs::path file_to_load = nav_get_party();
|
||||
fs::path file_to_load = nav_get_or_decode_party();
|
||||
if(!file_to_load.empty()) load_party(file_to_load, univ);
|
||||
if(univ.party.is_alive()) {
|
||||
if(overall_mode != MODE_STARTUP)
|
||||
@@ -2658,7 +2658,7 @@ void start_new_game(bool force) {
|
||||
}
|
||||
party_in_memory = true;
|
||||
if(force) return;
|
||||
fs::path file = nav_put_party();
|
||||
fs::path file = nav_put_or_temp_party();
|
||||
if(!file.empty()) save_party(file, univ);
|
||||
univ.file = file;
|
||||
}
|
||||
|
@@ -457,7 +457,7 @@ void handle_one_event(const sf::Event& event) {
|
||||
std::string choice = cChoiceDlog("quit-confirm-save", {"save","quit","cancel"}).show();
|
||||
if(choice == "cancel") break;
|
||||
if(choice == "save") {
|
||||
fs::path file = nav_put_party();
|
||||
fs::path file = nav_put_or_temp_party();
|
||||
if(!file.empty()) break;
|
||||
save_party(file, univ);
|
||||
}
|
||||
@@ -609,7 +609,7 @@ void handle_menu_choice(eMenu item_hit) {
|
||||
std::string choice = cChoiceDlog("quit-confirm-save", {"save","quit","cancel"}).show();
|
||||
if(choice == "cancel") break;
|
||||
if(choice == "save") {
|
||||
fs::path file = nav_put_party();
|
||||
fs::path file = nav_put_or_temp_party();
|
||||
if(!file.empty()) break;
|
||||
save_party(file, univ);
|
||||
}
|
||||
@@ -623,7 +623,7 @@ void handle_menu_choice(eMenu item_hit) {
|
||||
break;
|
||||
if(choice == "save") {
|
||||
if(univ.file.empty()) {
|
||||
univ.file = nav_put_party();
|
||||
univ.file = nav_put_or_temp_party();
|
||||
if(univ.file.empty()) break;
|
||||
}
|
||||
save_party(univ.file, univ);
|
||||
|
Reference in New Issue
Block a user