diff --git a/src/scenedit/scen.actions.cpp b/src/scenedit/scen.actions.cpp index a9c35acc..08c06d3f 100644 --- a/src/scenedit/scen.actions.cpp +++ b/src/scenedit/scen.actions.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include "scen.global.hpp" #include "scenario/scenario.hpp" @@ -245,9 +246,14 @@ static bool handle_lb_action(int i){ set_up_main_screen(); } break; + case LB_LOAD_LAST: + file_to_load = get_string_pref("LastScenario"); + // Skip first line of the fallthrough + if(false) case LB_LOAD_SCEN: file_to_load = nav_get_scenario(); if(!file_to_load.empty() && load_scenario(file_to_load, scenario)) { + set_pref("LastScenario", file_to_load.string()); restore_editor_state(true); } else if(!file_to_load.empty()) // If we tried to load but failed, the scenario record is messed up, so boot to start screen. @@ -2489,6 +2495,11 @@ void set_up_start_screen() { set_lb(1,LB_TITLE,LB_NO_ACTION,"Scenario Editor"); set_lb(3,LB_TEXT,LB_NEW_SCEN,"Make New Scenario"); set_lb(4,LB_TEXT,LB_LOAD_SCEN,"Load Scenario"); + fs::path last_scenario = get_string_pref("LastScenario"); + if(!last_scenario.empty() && fs::exists(last_scenario)){ + set_lb(5,LB_TEXT,LB_LOAD_LAST,"Load Last: " + last_scenario.filename().string()); + } + set_lb(4,LB_TEXT,LB_LOAD_SCEN,"Load Scenario"); set_lb(7,LB_TEXT,LB_NO_ACTION,"To find out how to use the"); set_lb(8,LB_TEXT,LB_NO_ACTION,"editor, select Getting Started "); set_lb(9,LB_TEXT,LB_NO_ACTION,"from the Help menu."); diff --git a/src/scenedit/scen.appleevents.mm b/src/scenedit/scen.appleevents.mm index e87dfe48..82a3516d 100644 --- a/src/scenedit/scen.appleevents.mm +++ b/src/scenedit/scen.appleevents.mm @@ -14,6 +14,7 @@ #include "fileio/fileio.hpp" #include "scen.actions.hpp" #include "scen.townout.hpp" +#include "tools/prefs.hpp" //extern bool ae_loading, startup_loaded, All_Done, party_in_memory, finished_init; extern cScenario scenario; @@ -51,6 +52,7 @@ void set_up_apple_events() { std::copy(msg.get(), msg.get() + len, std::inserter(fileName, fileName.begin())); if(load_scenario(fileName, scenario)) { + set_pref("LastScenario", fileName); restore_editor_state(true); change_made = false; ae_loading = true; diff --git a/src/scenedit/scen.btnmg.hpp b/src/scenedit/scen.btnmg.hpp index 53dd2e43..38640cd2 100644 --- a/src/scenedit/scen.btnmg.hpp +++ b/src/scenedit/scen.btnmg.hpp @@ -3,6 +3,7 @@ enum eLBAction { LB_NO_ACTION, LB_NEW_SCEN, LB_LOAD_SCEN, + LB_LOAD_LAST, LB_EDIT_TER, LB_EDIT_MONST, LB_EDIT_ITEM, diff --git a/src/scenedit/scen.fileio.cpp b/src/scenedit/scen.fileio.cpp index 50facc24..f6c207d0 100644 --- a/src/scenedit/scen.fileio.cpp +++ b/src/scenedit/scen.fileio.cpp @@ -1095,6 +1095,8 @@ void save_scenario(bool rename) { if(toFile.empty()) return; } + set_pref("LastScenario", toFile.string()); + extern cUndoList undo_list; undo_list.save(); diff --git a/src/scenedit/scen.main.cpp b/src/scenedit/scen.main.cpp index ca3b2d01..98200055 100644 --- a/src/scenedit/scen.main.cpp +++ b/src/scenedit/scen.main.cpp @@ -309,6 +309,7 @@ static void process_args(int argc, char* argv[]) { } if(!file.empty()) { if(load_scenario(file, scenario)) { + set_pref("LastScenario", file); restore_editor_state(true); change_made = false; ae_loading = true; @@ -456,6 +457,7 @@ void handle_menu_choice(eMenu item_hit) { break; file_to_load = item_hit == eMenu::FILE_OPEN ? nav_get_scenario() : scenario.scen_file; if(!file_to_load.empty() && load_scenario(file_to_load, scenario)) { + set_pref("LastScenario", file_to_load.string()); restore_editor_state(true); change_made = false; } else if(!file_to_load.empty())