Game configurations are now saved as soon as the configuration dialog is closed

Program preferences are now saved as soon as the configuration dialog is closed
Recent files are now saved as soon as an existing map is loaded
This commit is contained in:
biwa 2021-04-02 12:13:22 +02:00
parent 95f5c719b7
commit fe71e53edc
3 changed files with 41 additions and 10 deletions

View file

@ -560,6 +560,25 @@ namespace CodeImp.DoomBuilder
// Cannot find that nodebuilder
return null;
}
/// <summary>
/// Saves the program's configuration
/// </summary>
internal static void SaveSettings()
{
// Save settings configuration
if (!General.NoSettings)
General.Settings.Save(Path.Combine(settingspath, SETTINGS_FILE));
}
/// <summary>
/// Saves the game configuration settings, like engine, resources etc.
/// </summary>
internal static void SaveGameSettings()
{
// Save game configuration settings
if (configs != null) foreach (ConfigurationInfo ci in configs) ci.SaveSettings();
}
#endregion
@ -1002,13 +1021,12 @@ namespace CodeImp.DoomBuilder
// Save action controls
actions.SaveSettings();
// Save game configuration settings
if(configs != null) foreach(ConfigurationInfo ci in configs) ci.SaveSettings();
// Save settings configuration
if(!General.NoSettings)
settings.Save(Path.Combine(settingspath, SETTINGS_FILE));
// Save game settings
SaveGameSettings();
// Save program configuration
SaveSettings();
// Clean up
if(map != null) { map.Dispose(); map = null; }

View file

@ -415,6 +415,8 @@ namespace CodeImp.DoomBuilder.Windows
General.Configs[i].Enabled = ci.Enabled;
if(ci.Changed) General.Configs[i].Apply(ci);
}
General.SaveGameSettings();
// Close
this.DialogResult = DialogResult.OK;

View file

@ -2661,6 +2661,9 @@ namespace CodeImp.DoomBuilder.Windows
General.Settings.WriteSetting("recentfiles.file" + i, recentitems[i].Tag.ToString());
}
}
// Save program configuration
General.SaveSettings();
}
// This adds a recent file to the list
@ -2703,6 +2706,8 @@ namespace CodeImp.DoomBuilder.Windows
// Hide the no recent item
itemnorecent.Visible = false;
SaveRecentFiles();
}
//mxd
@ -2711,7 +2716,7 @@ namespace CodeImp.DoomBuilder.Windows
foreach(ToolStripMenuItem item in recentitems)
menufile.DropDownItems.Remove(item);
SaveRecentFiles();
//SaveRecentFiles();
CreateRecentFiles();
}
@ -3429,9 +3434,12 @@ namespace CodeImp.DoomBuilder.Windows
UpdateInterface();
General.Editing.UpdateCurrentEditModes();
General.Plugins.ProgramReconfigure();
// Save program configuration
General.SaveSettings();
// Reload resources if a map is open
if((General.Map != null) && cfgform.ReloadResources) General.Actions.InvokeAction("builder_reloadresources");
if ((General.Map != null) && cfgform.ReloadResources) General.Actions.InvokeAction("builder_reloadresources");
// Redraw display
RedrawDisplay();
@ -3455,6 +3463,9 @@ namespace CodeImp.DoomBuilder.Windows
ApplyShortcutKeys();
General.Colors.CreateCorrectionTable();
General.Plugins.ProgramReconfigure();
// Save program configuration
General.SaveSettings();
// Map opened?
if(General.Map != null)