diff --git a/IPA.Loader/Config/ConfigProviders/JsonConfigProvider.cs b/IPA.Loader/Config/ConfigProviders/JsonConfigProvider.cs
index 58819c47..4226aee9 100644
--- a/IPA.Loader/Config/ConfigProviders/JsonConfigProvider.cs
+++ b/IPA.Loader/Config/ConfigProviders/JsonConfigProvider.cs
@@ -18,6 +18,8 @@ namespace IPA.Config.ConfigProviders
public bool HasChanged { get; private set; } = false;
+ public DateTime LastModified => File.GetLastWriteTime(Filename + ".json");
+
private string _filename = null;
public string Filename
{
diff --git a/IPA.Loader/Config/IConfigProvider.cs b/IPA.Loader/Config/IConfigProvider.cs
index 5bd773d3..0390f667 100644
--- a/IPA.Loader/Config/IConfigProvider.cs
+++ b/IPA.Loader/Config/IConfigProvider.cs
@@ -39,6 +39,10 @@ namespace IPA.Config
///
string Filename { set; }
///
+ /// Gets the last time the config was modified.
+ ///
+ DateTime LastModified { get; }
+ ///
/// Saves configuration to file. Should error if not a root object.
///
void Save();
diff --git a/IPA.Loader/Loader/PluginComponent.cs b/IPA.Loader/Loader/PluginComponent.cs
index b7529821..0e46febd 100644
--- a/IPA.Loader/Loader/PluginComponent.cs
+++ b/IPA.Loader/Loader/PluginComponent.cs
@@ -44,7 +44,7 @@ namespace IPA.Loader
SceneManager.sceneUnloaded += OnSceneUnloaded;
foreach (var provider in PluginManager.configProviders)
- if (provider.HasChanged) provider.Save();
+ if (provider.Item1.HasChanged) provider.Item1.Save();
}
void Update()
@@ -59,7 +59,10 @@ namespace IPA.Loader
ipaPlugins.OnLateUpdate();
foreach (var provider in PluginManager.configProviders)
- if (provider.HasChanged) provider.Save();
+ {
+ if (provider.Item1.HasChanged) provider.Item1.Save();
+ else if (provider.Item1.LastModified > provider.Item2) provider.Item1.Load(); // auto reload if it changes
+ }
}
void FixedUpdate()
@@ -86,7 +89,7 @@ namespace IPA.Loader
ipaPlugins.OnApplicationQuit();
foreach (var provider in PluginManager.configProviders)
- if (provider.HasChanged) provider.Save();
+ if (provider.Item1.HasChanged) provider.Item1.Save();
quitting = true;
}
diff --git a/IPA.Loader/Loader/PluginManager.cs b/IPA.Loader/Loader/PluginManager.cs
index 3bb6ae69..c5ebc84f 100644
--- a/IPA.Loader/Loader/PluginManager.cs
+++ b/IPA.Loader/Loader/PluginManager.cs
@@ -79,7 +79,7 @@ namespace IPA.Loader
internal static IConfigProvider SelfConfigProvider { get; set; } = null;
- internal static List configProviders = new List();
+ internal static List> configProviders = new List>();
private static void LoadPlugins()
{
@@ -164,7 +164,7 @@ namespace IPA.Loader
_bsPlugins.Add(selfPlugin);
- configProviders.Add(SelfConfigProvider = new JsonConfigProvider() { Filename = Path.Combine("UserData", SelfPlugin.IPA_Name) });
+ configProviders.Add(new Tuple(SelfConfigProvider = new JsonConfigProvider() { Filename = Path.Combine("UserData", SelfPlugin.IPA_Name) }, SelfConfigProvider.LastModified));
SelfConfigProvider.Load();
//Load copied plugins
@@ -268,7 +268,7 @@ namespace IPA.Loader
if (cfgProvider == null)
{
cfgProvider = new JsonConfigProvider() { Filename = Path.Combine("UserData", $"{bsPlugin.Name}") };
- configProviders.Add(cfgProvider);
+ configProviders.Add(new Tuple(cfgProvider, cfgProvider.LastModified));
cfgProvider.Load();
}
initArgs.Add(cfgProvider);
diff --git a/IPA/IPA.csproj b/IPA/IPA.csproj
index 61f5536f..9cbd7948 100644
--- a/IPA/IPA.csproj
+++ b/IPA/IPA.csproj
@@ -57,6 +57,9 @@
IPA.Program
+
+ false
+
@@ -118,7 +121,8 @@
-
+
+