start remembering/restoring last open editor menu

This commit is contained in:
2025-06-12 09:58:13 -05:00
parent 7b674ffb5c
commit 6d7711dd22
4 changed files with 26 additions and 0 deletions

View File

@@ -1124,6 +1124,10 @@ void readEditorStateFromXml(ticpp::Document&& data, cScenario& scenario) {
}
}
editor_state.out_view_state[section] = {center, viewing_mode};
}else if(type == "overall-mode"){
elem->GetText(&editor_state.overall_mode);
}else if(type == "type-editing-mode"){
elem->GetText(&editor_state.type_editing_mode);
}
}
}

View File

@@ -69,6 +69,10 @@ struct editor_state_t {
// When simply shifting over by 1 section we won't want to
// use this stored state, we want seamless transition.
std::map<location, terrain_view_t, loc_compare> out_view_state;
// Non-drawing modes will be remembered and reopened when the editor launches.
int overall_mode = -1;
int type_editing_mode = -1;
};
class cScenario {

View File

@@ -2928,6 +2928,9 @@ void start_type_editing(eDrawMode mode) {
right_sbar->hide();
pal_sbar->show();
overall_mode = MODE_EDIT_TYPES;
// Remember non-drawing modes
scenario.editor_state.overall_mode = MODE_EDIT_TYPES;
scenario.editor_state.type_editing_mode = mode;
draw_mode = mode;
set_up_type_buttons(true);
place_location();
@@ -3209,6 +3212,16 @@ void restore_editor_state() {
start_town_edit();
else
start_out_edit();
}else{
switch(scenario.editor_state.overall_mode){
case MODE_EDIT_TYPES:
start_type_editing(static_cast<eDrawMode>(scenario.editor_state.type_editing_mode));
break;
case MODE_EDIT_SPECIAL_ITEMS:
start_special_item_editing();
break;
default: break;
}
}
}
@@ -3216,6 +3229,8 @@ void handle_close_terrain_view(eScenMode new_mode) {
// When closing a terrain view, store its view state
store_current_terrain_state();
scenario.editor_state.drawing = false;
// Remember non-drawing modes
scenario.editor_state.overall_mode = new_mode;
// set up the main screen if needed
if(new_mode == MODE_MAIN_SCREEN && overall_mode <= MODE_MAIN_SCREEN)

View File

@@ -151,6 +151,9 @@ void writeEditorStateToXml(ticpp::Printer&& data, cScenario& scenario) {
data.CloseElement("out-view-state");
}
data.PushElement("overall-mode", scenario.editor_state.overall_mode);
data.PushElement("type-editing-mode", scenario.editor_state.type_editing_mode);
data.CloseElement("editor");
}