Browse Source

Fixedconfig reloading

piracy-check
Anairkoen Schno 6 years ago
parent
commit
8fa20b4c53
2 changed files with 11 additions and 7 deletions
  1. +8
    -4
      IPA.Loader/Loader/PluginComponent.cs
  2. +3
    -3
      IPA.Loader/Loader/PluginManager.cs

+ 8
- 4
IPA.Loader/Loader/PluginComponent.cs View File

@ -44,7 +44,7 @@ namespace IPA.Loader
SceneManager.sceneUnloaded += OnSceneUnloaded; SceneManager.sceneUnloaded += OnSceneUnloaded;
foreach (var provider in PluginManager.configProviders) foreach (var provider in PluginManager.configProviders)
if (provider.Item1.HasChanged) provider.Item1.Save();
if (provider.Key.HasChanged) provider.Key.Save();
} }
void Update() void Update()
@ -60,8 +60,12 @@ namespace IPA.Loader
foreach (var provider in PluginManager.configProviders) foreach (var provider in PluginManager.configProviders)
{ {
if (provider.Item1.HasChanged) provider.Item1.Save();
else if (provider.Item1.LastModified > provider.Item2) provider.Item1.Load(); // auto reload if it changes
if (provider.Key.HasChanged) provider.Key.Save();
else if (provider.Key.LastModified > provider.Value.Value)
{
provider.Key.Load(); // auto reload if it changes
provider.Value.Value = provider.Key.LastModified;
}
} }
} }
@ -89,7 +93,7 @@ namespace IPA.Loader
ipaPlugins.OnApplicationQuit(); ipaPlugins.OnApplicationQuit();
foreach (var provider in PluginManager.configProviders) foreach (var provider in PluginManager.configProviders)
if (provider.Item1.HasChanged) provider.Item1.Save();
if (provider.Key.HasChanged) provider.Key.Save();
quitting = true; quitting = true;
} }


+ 3
- 3
IPA.Loader/Loader/PluginManager.cs View File

@ -79,7 +79,7 @@ namespace IPA.Loader
internal static IConfigProvider SelfConfigProvider { get; set; } = null; internal static IConfigProvider SelfConfigProvider { get; set; } = null;
internal static List<Tuple<IConfigProvider,DateTime>> configProviders = new List<Tuple<IConfigProvider, DateTime>>();
internal static List<KeyValuePair<IConfigProvider,Ref<DateTime>>> configProviders = new List<KeyValuePair<IConfigProvider, Ref<DateTime>>>();
private static void LoadPlugins() private static void LoadPlugins()
{ {
@ -164,7 +164,7 @@ namespace IPA.Loader
_bsPlugins.Add(selfPlugin); _bsPlugins.Add(selfPlugin);
configProviders.Add(new Tuple<IConfigProvider, DateTime>(SelfConfigProvider = new JsonConfigProvider() { Filename = Path.Combine("UserData", SelfPlugin.IPA_Name) }, SelfConfigProvider.LastModified));
configProviders.Add(new KeyValuePair<IConfigProvider, Ref<DateTime>>(SelfConfigProvider = new JsonConfigProvider() { Filename = Path.Combine("UserData", SelfPlugin.IPA_Name) }, new Ref<DateTime>(SelfConfigProvider.LastModified)));
SelfConfigProvider.Load(); SelfConfigProvider.Load();
//Load copied plugins //Load copied plugins
@ -268,7 +268,7 @@ namespace IPA.Loader
if (cfgProvider == null) if (cfgProvider == null)
{ {
cfgProvider = new JsonConfigProvider() { Filename = Path.Combine("UserData", $"{bsPlugin.Name}") }; cfgProvider = new JsonConfigProvider() { Filename = Path.Combine("UserData", $"{bsPlugin.Name}") };
configProviders.Add(new Tuple<IConfigProvider, DateTime>(cfgProvider, cfgProvider.LastModified));
configProviders.Add(new KeyValuePair<IConfigProvider, Ref<DateTime>>(cfgProvider, new Ref<DateTime>(cfgProvider.LastModified)));
cfgProvider.Load(); cfgProvider.Load();
} }
initArgs.Add(cfgProvider); initArgs.Add(cfgProvider);


Loading…
Cancel
Save