(ISettingsManager): new public interface.

This commit is contained in:
morkt
2018-01-11 18:38:33 +04:00
parent c1a6c69145
commit 21f2529e97
5 changed files with 61 additions and 6 deletions

View File

@@ -49,6 +49,8 @@ namespace GameRes
private IEnumerable<AudioFormat> m_audio_formats;
[ImportMany(typeof(ScriptFormat))]
private IEnumerable<ScriptFormat> m_script_formats;
[ImportMany(typeof(ISettingsManager))]
private IEnumerable<ISettingsManager> m_settings_managers;
#pragma warning restore 649
private MultiValueDictionary<string, IResource> m_extension_map = new MultiValueDictionary<string, IResource>();
@@ -107,11 +109,6 @@ namespace GameRes
}
}
public void SaveSettings ()
{
Properties.Settings.Default.Save();
}
private void AddResourceImpl (IEnumerable<IResource> formats, CompositionContainer container)
{
foreach (var impl in formats)
@@ -137,6 +134,29 @@ namespace GameRes
}
}
public void UpgradeSettings ()
{
if (Properties.Settings.Default.UpgradeRequired)
{
Properties.Settings.Default.Upgrade();
Properties.Settings.Default.UpgradeRequired = false;
Properties.Settings.Default.Save();
}
foreach (var mgr in m_settings_managers)
{
mgr.UpgradeSettings();
}
}
public void SaveSettings ()
{
Properties.Settings.Default.Save();
foreach (var mgr in m_settings_managers)
{
mgr.SaveSettings();
}
}
/// <summary>
/// Look up filename in format registry by filename extension and return corresponding interfaces.
/// if no formats available, return empty range.
@@ -320,7 +340,7 @@ namespace GameRes
}
/// <summary>
/// Read text file <paramref name="filename"/> from data directory, performing <paramref name="process_line"/> action on each line.
/// Read text file <paramref name="filename"/> from data directory, performing <paramref name="process_line"/> action on each non-empty line.
/// </summary>
public void ReadFileList (string filename, Action<string> process_line)
{