From 1f506afe3f1c1a4f61144059a049c5be975f6e29 Mon Sep 17 00:00:00 2001 From: Anairkoen Schno Date: Tue, 2 Apr 2019 22:25:39 -0500 Subject: [PATCH] Added ConfigProviderFeature Bumped version --- IPA.Injector/Properties/AssemblyInfo.cs | 4 +- IPA.Loader/Config/SelfConfig.cs | 2 +- IPA.Loader/IPA.Loader.csproj | 1 + .../Loader/Features/ConfigProviderFeature.cs | 65 +++++++++++++++++++ IPA.Loader/Loader/manifest.json | 7 +- IPA/Properties/AssemblyInfo.cs | 4 +- appveyor.yml | 2 +- 7 files changed, 76 insertions(+), 9 deletions(-) create mode 100644 IPA.Loader/Loader/Features/ConfigProviderFeature.cs diff --git a/IPA.Injector/Properties/AssemblyInfo.cs b/IPA.Injector/Properties/AssemblyInfo.cs index ed9ca143..5f18531f 100644 --- a/IPA.Injector/Properties/AssemblyInfo.cs +++ b/IPA.Injector/Properties/AssemblyInfo.cs @@ -33,5 +33,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("3.12.3")] -[assembly: AssemblyFileVersion("3.12.3")] \ No newline at end of file +[assembly: AssemblyVersion(IPA.Config.SelfConfig.IPAVersion)] +[assembly: AssemblyFileVersion(IPA.Config.SelfConfig.IPAVersion)] \ No newline at end of file diff --git a/IPA.Loader/Config/SelfConfig.cs b/IPA.Loader/Config/SelfConfig.cs index 82268461..f34e99b8 100644 --- a/IPA.Loader/Config/SelfConfig.cs +++ b/IPA.Loader/Config/SelfConfig.cs @@ -33,7 +33,7 @@ namespace IPA.Config } internal const string IPAName = "Beat Saber IPA"; - internal const string IPAVersion = "3.12.3"; + internal const string IPAVersion = "3.12.4"; // this should be completely outdated soon-ish public bool Regenerate = true; diff --git a/IPA.Loader/IPA.Loader.csproj b/IPA.Loader/IPA.Loader.csproj index 15272b25..a76f772d 100644 --- a/IPA.Loader/IPA.Loader.csproj +++ b/IPA.Loader/IPA.Loader.csproj @@ -63,6 +63,7 @@ + diff --git a/IPA.Loader/Loader/Features/ConfigProviderFeature.cs b/IPA.Loader/Loader/Features/ConfigProviderFeature.cs new file mode 100644 index 00000000..41037db2 --- /dev/null +++ b/IPA.Loader/Loader/Features/ConfigProviderFeature.cs @@ -0,0 +1,65 @@ +using System; +using System.IO; + +namespace IPA.Loader.Features +{ + internal class ConfigProviderFeature : Feature + { + public override bool Initialize(PluginLoader.PluginMetadata meta, string[] parameters) + {// parameters should be (fully qualified name of provider type) + if (parameters.Length != 1) + { + InvalidMessage = "Incorrect number of parameters"; + return false; + } + + RequireLoaded(meta); + + Type getType; + try + { + getType = meta.Assembly.GetType(parameters[0]); + } + catch (ArgumentException) + { + InvalidMessage = $"Invalid type name {parameters[0]}"; + return false; + } + catch (Exception e) when (e is FileNotFoundException || e is FileLoadException || e is BadImageFormatException) + { + string filename; + + switch (e) + { + case FileNotFoundException fn: + filename = fn.FileName; + goto hasFilename; + case FileLoadException fl: + filename = fl.FileName; + goto hasFilename; + case BadImageFormatException bi: + filename = bi.FileName; + hasFilename: + InvalidMessage = $"Could not find {filename} while loading type"; + break; + default: + InvalidMessage = $"Error while loading type: {e}"; + break; + } + + return false; + } + + try + { + Config.Config.Register(getType); + return true; + } + catch (Exception e) + { + InvalidMessage = $"Error generated while creating delegate: {e}"; + return false; + } + } + } +} diff --git a/IPA.Loader/Loader/manifest.json b/IPA.Loader/Loader/manifest.json index d754a56c..c2a1f9e1 100644 --- a/IPA.Loader/Loader/manifest.json +++ b/IPA.Loader/Loader/manifest.json @@ -2,16 +2,17 @@ "$schema": "https://raw.githubusercontent.com/nike4613/ModSaber-MetadataFileSchema/master/Schema.json", "author": "DaNike", "description": "A mod loader specifically for Beat Saber.", - "gameVersion": "0.12.2", + "gameVersion": "0.13.1", "id": "beatsaber-ipa-reloaded", "name": "BSIPA", - "version": "3.12.3", + "version": "3.12.4", "features": [ "define-feature(print, IPA.Loader.Features.PrintFeature)", "define-feature(debug, IPA.Loader.Features.DebugFeature)", "define-feature(warn, IPA.Loader.Features.WarnFeature)", "define-feature(no-update, IPA.Loader.Features.NoUpdateFeature)", "define-feature(add-in, IPA.Loader.Features.AddInFeature)", - "define-feature(init-injector, IPA.Loader.Features.InitInjectorFeature)" + "define-feature(init-injector, IPA.Loader.Features.InitInjectorFeature)", + "define-feature(config-provider, IPA.Loader.Features.ConfigProviderFeature)" ] } \ No newline at end of file diff --git a/IPA/Properties/AssemblyInfo.cs b/IPA/Properties/AssemblyInfo.cs index 14b18992..4be00a3a 100644 --- a/IPA/Properties/AssemblyInfo.cs +++ b/IPA/Properties/AssemblyInfo.cs @@ -31,5 +31,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("3.12.3")] -[assembly: AssemblyFileVersion("3.12.3")] \ No newline at end of file +[assembly: AssemblyVersion("3.12.4")] +[assembly: AssemblyFileVersion("3.12.4")] \ No newline at end of file diff --git a/appveyor.yml b/appveyor.yml index f6ee46eb..d671e710 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,6 +1,6 @@ version: 'BSIPA-{branch}-{build}' environment: - bsipa_version: '3.12.3' + bsipa_version: '3.12.4' pull_requests: do_not_increment_build_number: true install: