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

@ -561,6 +561,25 @@ namespace CodeImp.DoomBuilder
return null; 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 #endregion
#region ================== Startup #region ================== Startup
@ -1003,12 +1022,11 @@ namespace CodeImp.DoomBuilder
// Save action controls // Save action controls
actions.SaveSettings(); actions.SaveSettings();
// Save game configuration settings // Save game settings
if(configs != null) foreach(ConfigurationInfo ci in configs) ci.SaveSettings(); SaveGameSettings();
// Save settings configuration // Save program configuration
if(!General.NoSettings) SaveSettings();
settings.Save(Path.Combine(settingspath, SETTINGS_FILE));
// Clean up // Clean up
if(map != null) { map.Dispose(); map = null; } if(map != null) { map.Dispose(); map = null; }

View file

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

View file

@ -2661,6 +2661,9 @@ namespace CodeImp.DoomBuilder.Windows
General.Settings.WriteSetting("recentfiles.file" + i, recentitems[i].Tag.ToString()); General.Settings.WriteSetting("recentfiles.file" + i, recentitems[i].Tag.ToString());
} }
} }
// Save program configuration
General.SaveSettings();
} }
// This adds a recent file to the list // This adds a recent file to the list
@ -2703,6 +2706,8 @@ namespace CodeImp.DoomBuilder.Windows
// Hide the no recent item // Hide the no recent item
itemnorecent.Visible = false; itemnorecent.Visible = false;
SaveRecentFiles();
} }
//mxd //mxd
@ -2711,7 +2716,7 @@ namespace CodeImp.DoomBuilder.Windows
foreach(ToolStripMenuItem item in recentitems) foreach(ToolStripMenuItem item in recentitems)
menufile.DropDownItems.Remove(item); menufile.DropDownItems.Remove(item);
SaveRecentFiles(); //SaveRecentFiles();
CreateRecentFiles(); CreateRecentFiles();
} }
@ -3430,8 +3435,11 @@ namespace CodeImp.DoomBuilder.Windows
General.Editing.UpdateCurrentEditModes(); General.Editing.UpdateCurrentEditModes();
General.Plugins.ProgramReconfigure(); General.Plugins.ProgramReconfigure();
// Save program configuration
General.SaveSettings();
// Reload resources if a map is open // 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 // Redraw display
RedrawDisplay(); RedrawDisplay();
@ -3456,6 +3464,9 @@ namespace CodeImp.DoomBuilder.Windows
General.Colors.CreateCorrectionTable(); General.Colors.CreateCorrectionTable();
General.Plugins.ProgramReconfigure(); General.Plugins.ProgramReconfigure();
// Save program configuration
General.SaveSettings();
// Map opened? // Map opened?
if(General.Map != null) if(General.Map != null)
{ {