Browse Source

Finalized ConfigProvider

Incremented version
pull/46/head
Anairkoen Schno 6 years ago
parent
commit
e8f6ce5730
7 changed files with 29 additions and 8 deletions
  1. +2
    -2
      IPA.Injector/Properties/AssemblyInfo.cs
  2. +6
    -0
      IPA.Loader/Config/ConfigProviders/JsonConfigProvider.cs
  3. +9
    -0
      IPA.Loader/Loader/PluginComponent.cs
  4. +8
    -3
      IPA.Loader/Loader/PluginManager.cs
  5. +1
    -0
      IPA.Loader/Logging/StandardLogger.cs
  6. +1
    -1
      IPA.Loader/Updating/SelfPlugin.cs
  7. +2
    -2
      IPA/Properties/AssemblyInfo.cs

+ 2
- 2
IPA.Injector/Properties/AssemblyInfo.cs View File

@ -33,5 +33,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("3.9.1")]
[assembly: AssemblyFileVersion("3.9.1")]
[assembly: AssemblyVersion("3.9.2")]
[assembly: AssemblyFileVersion("3.9.2")]

+ 6
- 0
IPA.Loader/Config/ConfigProviders/JsonConfigProvider.cs View File

@ -32,6 +32,8 @@ namespace IPA.Config.ConfigProviders
public void Load() public void Load()
{ {
Logger.config.Debug($"Loading file {Filename}.json");
var finfo = new FileInfo(Filename + ".json"); var finfo = new FileInfo(Filename + ".json");
if (finfo.Exists) if (finfo.Exists)
{ {
@ -85,9 +87,13 @@ namespace IPA.Config.ConfigProviders
public void Save() public void Save()
{ {
Logger.config.Debug($"Saving file {Filename}.json");
var finfo = new FileInfo(Filename + ".json"); var finfo = new FileInfo(Filename + ".json");
File.WriteAllText(finfo.FullName, JsonConvert.SerializeObject(jsonObj)); File.WriteAllText(finfo.FullName, JsonConvert.SerializeObject(jsonObj));
HasChanged = false;
} }
public void Store<T>(T obj) public void Store<T>(T obj)


+ 9
- 0
IPA.Loader/Loader/PluginComponent.cs View File

@ -42,6 +42,9 @@ namespace IPA.Loader
SceneManager.activeSceneChanged += OnActiveSceneChanged; SceneManager.activeSceneChanged += OnActiveSceneChanged;
SceneManager.sceneLoaded += OnSceneLoaded; SceneManager.sceneLoaded += OnSceneLoaded;
SceneManager.sceneUnloaded += OnSceneUnloaded; SceneManager.sceneUnloaded += OnSceneUnloaded;
foreach (var provider in PluginManager.configProviders)
if (provider.HasChanged) provider.Save();
} }
void Update() void Update()
@ -54,6 +57,9 @@ namespace IPA.Loader
{ {
bsPlugins.OnLateUpdate(); bsPlugins.OnLateUpdate();
ipaPlugins.OnLateUpdate(); ipaPlugins.OnLateUpdate();
foreach (var provider in PluginManager.configProviders)
if (provider.HasChanged) provider.Save();
} }
void FixedUpdate() void FixedUpdate()
@ -79,6 +85,9 @@ namespace IPA.Loader
bsPlugins.OnApplicationQuit(); bsPlugins.OnApplicationQuit();
ipaPlugins.OnApplicationQuit(); ipaPlugins.OnApplicationQuit();
foreach (var provider in PluginManager.configProviders)
if (provider.HasChanged) provider.Save();
quitting = true; quitting = true;
} }


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

@ -247,6 +247,7 @@ namespace IPA.Loader
Logger modLogger = null; Logger modLogger = null;
IModPrefs modPrefs = null; IModPrefs modPrefs = null;
IConfigProvider cfgProvider = null;
foreach (var param in initParams) foreach (var param in initParams)
{ {
@ -262,9 +263,13 @@ namespace IPA.Loader
} }
else if (ptype.IsAssignableFrom(typeof(IConfigProvider))) else if (ptype.IsAssignableFrom(typeof(IConfigProvider)))
{ {
var configProvider = new JsonConfigProvider() { Filename = Path.Combine("UserData", $"{bsPlugin.Name}.{param.Name}") };
configProviders.Add(configProvider);
initArgs.Add(configProvider);
if (cfgProvider == null)
{
cfgProvider = new JsonConfigProvider() { Filename = Path.Combine("UserData", $"{bsPlugin.Name}") };
configProviders.Add(cfgProvider);
cfgProvider.Load();
}
initArgs.Add(cfgProvider);
} }
else else
initArgs.Add(ptype.GetDefault()); initArgs.Add(ptype.GetDefault());


+ 1
- 0
IPA.Loader/Logging/StandardLogger.cs View File

@ -9,6 +9,7 @@ using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using IPA; using IPA;
using IPA.Logging.Printers; using IPA.Logging.Printers;
using IPA.Config;
namespace IPA.Logging namespace IPA.Logging
{ {


+ 1
- 1
IPA.Loader/Updating/SelfPlugin.cs View File

@ -11,7 +11,7 @@ namespace IPA.Updating
internal class SelfPlugin : IBeatSaberPlugin internal class SelfPlugin : IBeatSaberPlugin
{ {
internal const string IPA_Name = "Beat Saber IPA"; internal const string IPA_Name = "Beat Saber IPA";
internal const string IPA_Version = "3.9.1";
internal const string IPA_Version = "3.9.2";
public string Name => IPA_Name; public string Name => IPA_Name;


+ 2
- 2
IPA/Properties/AssemblyInfo.cs View File

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("3.9.1")]
[assembly: AssemblyFileVersion("3.9.1")]
[assembly: AssemblyVersion("3.9.2")]
[assembly: AssemblyFileVersion("3.9.2")]

Loading…
Cancel
Save