scenedit quick-open last scenario

This commit is contained in:
2025-05-26 10:21:39 -05:00
parent 3d231ce76b
commit 744471b8c0
5 changed files with 18 additions and 0 deletions

View File

@@ -7,6 +7,7 @@
#include <stack> #include <stack>
#include <vector> #include <vector>
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>
#include <boost/filesystem.hpp>
#include <boost/variant.hpp> #include <boost/variant.hpp>
#include "scen.global.hpp" #include "scen.global.hpp"
#include "scenario/scenario.hpp" #include "scenario/scenario.hpp"
@@ -245,9 +246,14 @@ static bool handle_lb_action(int i){
set_up_main_screen(); set_up_main_screen();
} }
break; break;
case LB_LOAD_LAST:
file_to_load = get_string_pref("LastScenario");
// Skip first line of the fallthrough
if(false)
case LB_LOAD_SCEN: case LB_LOAD_SCEN:
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_pref("LastScenario", file_to_load.string());
restore_editor_state(true); restore_editor_state(true);
} 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.
@@ -2489,6 +2495,11 @@ void set_up_start_screen() {
set_lb(1,LB_TITLE,LB_NO_ACTION,"Scenario Editor"); set_lb(1,LB_TITLE,LB_NO_ACTION,"Scenario Editor");
set_lb(3,LB_TEXT,LB_NEW_SCEN,"Make New Scenario"); set_lb(3,LB_TEXT,LB_NEW_SCEN,"Make New Scenario");
set_lb(4,LB_TEXT,LB_LOAD_SCEN,"Load 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(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(8,LB_TEXT,LB_NO_ACTION,"editor, select Getting Started ");
set_lb(9,LB_TEXT,LB_NO_ACTION,"from the Help menu."); set_lb(9,LB_TEXT,LB_NO_ACTION,"from the Help menu.");

View File

@@ -14,6 +14,7 @@
#include "fileio/fileio.hpp" #include "fileio/fileio.hpp"
#include "scen.actions.hpp" #include "scen.actions.hpp"
#include "scen.townout.hpp" #include "scen.townout.hpp"
#include "tools/prefs.hpp"
//extern bool ae_loading, startup_loaded, All_Done, party_in_memory, finished_init; //extern bool ae_loading, startup_loaded, All_Done, party_in_memory, finished_init;
extern cScenario scenario; extern cScenario scenario;
@@ -51,6 +52,7 @@ void set_up_apple_events() {
std::copy(msg.get(), msg.get() + len, std::inserter(fileName, fileName.begin())); std::copy(msg.get(), msg.get() + len, std::inserter(fileName, fileName.begin()));
if(load_scenario(fileName, scenario)) { if(load_scenario(fileName, scenario)) {
set_pref("LastScenario", fileName);
restore_editor_state(true); restore_editor_state(true);
change_made = false; change_made = false;
ae_loading = true; ae_loading = true;

View File

@@ -3,6 +3,7 @@ enum eLBAction {
LB_NO_ACTION, LB_NO_ACTION,
LB_NEW_SCEN, LB_NEW_SCEN,
LB_LOAD_SCEN, LB_LOAD_SCEN,
LB_LOAD_LAST,
LB_EDIT_TER, LB_EDIT_TER,
LB_EDIT_MONST, LB_EDIT_MONST,
LB_EDIT_ITEM, LB_EDIT_ITEM,

View File

@@ -1095,6 +1095,8 @@ void save_scenario(bool rename) {
if(toFile.empty()) return; if(toFile.empty()) return;
} }
set_pref("LastScenario", toFile.string());
extern cUndoList undo_list; extern cUndoList undo_list;
undo_list.save(); undo_list.save();

View File

@@ -309,6 +309,7 @@ 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_pref("LastScenario", file);
restore_editor_state(true); restore_editor_state(true);
change_made = false; change_made = false;
ae_loading = true; ae_loading = true;
@@ -456,6 +457,7 @@ void handle_menu_choice(eMenu item_hit) {
break; break;
file_to_load = item_hit == eMenu::FILE_OPEN ? nav_get_scenario() : scenario.scen_file; 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)) { if(!file_to_load.empty() && load_scenario(file_to_load, scenario)) {
set_pref("LastScenario", file_to_load.string());
restore_editor_state(true); restore_editor_state(true);
change_made = false; change_made = false;
} else if(!file_to_load.empty()) } else if(!file_to_load.empty())