diff --git a/BepInEx/BaseUnityPlugin.cs b/BepInEx/BaseUnityPlugin.cs index 227c653..604e65f 100644 --- a/BepInEx/BaseUnityPlugin.cs +++ b/BepInEx/BaseUnityPlugin.cs @@ -9,21 +9,10 @@ namespace BepInEx { public abstract class BaseUnityPlugin : MonoBehaviour { + public abstract string ID { get; } + public abstract string Name { get; } - protected virtual void OnEnable() - { - SceneManager.sceneLoaded += LevelFinishedLoading; - } - - protected virtual void OnDisable() - { - SceneManager.sceneLoaded -= LevelFinishedLoading; - } - - protected virtual void LevelFinishedLoading(Scene scene, LoadSceneMode mode) - { - - } + public abstract Version Version { get; } } } diff --git a/Plugins/ColorCorrector/ColorCorrector.cs b/Plugins/ColorCorrector/ColorCorrector.cs index 2a09646..882789f 100644 --- a/Plugins/ColorCorrector/ColorCorrector.cs +++ b/Plugins/ColorCorrector/ColorCorrector.cs @@ -1,8 +1,5 @@ using BepInEx; using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using UnityEngine; using UnityEngine.SceneManagement; using UnityStandardAssets.ImageEffects; @@ -11,8 +8,11 @@ namespace ColorCorrector { public class ColorCorrector : BaseUnityPlugin { + public override string ID => "colorcorrector"; public override string Name => "Color Filter Remover"; + public override Version Version => new Version("1.2"); + #region Config properties private bool SaturationEnabled { get => bool.Parse(BepInEx.Config.GetEntry("colorcorrector-saturationenabled", "True")); @@ -24,14 +24,12 @@ namespace ColorCorrector get => bool.Parse(BepInEx.Config.GetEntry("colorcorrector-bloomenabled", "True")); set => BepInEx.Config.SetEntry("colorcorrector-bloomenabled", value.ToString()); } + #endregion - private Rect UI = new Rect(20, 20, 200, 100); - private bool showingUI = false; - AmplifyColorEffect amplifyComponent; BloomAndFlares bloomComponent; - protected override void LevelFinishedLoading(Scene scene, LoadSceneMode mode) + protected void LevelFinishedLoading(Scene scene, LoadSceneMode mode) { if (Camera.main != null && Camera.main?.gameObject != null) { @@ -42,6 +40,39 @@ namespace ColorCorrector } } + void SetEffects(bool satEnabled, bool bloomEnabled) + { + if (amplifyComponent != null) + amplifyComponent.enabled = satEnabled; + + if (bloomComponent != null) + bloomComponent.enabled = bloomEnabled; + } + + #region MonoBehaviour + void OnEnable() + { + SceneManager.sceneLoaded += LevelFinishedLoading; + } + + void OnDisable() + { + SceneManager.sceneLoaded -= LevelFinishedLoading; + } + + void Update() + { + if (UnityEngine.Input.GetKeyDown(UnityEngine.KeyCode.F6)) + { + showingUI = !showingUI; + } + } + #endregion + + #region UI + private Rect UI = new Rect(20, 20, 200, 100); + private bool showingUI = false; + void OnGUI() { if (showingUI) @@ -63,22 +94,6 @@ namespace ColorCorrector GUI.DragWindow(); } - - void Update() - { - if (UnityEngine.Input.GetKeyDown(UnityEngine.KeyCode.F6)) - { - showingUI = !showingUI; - } - } - - void SetEffects(bool satEnabled, bool bloomEnabled) - { - if (amplifyComponent != null) - amplifyComponent.enabled = satEnabled; - - if (bloomComponent != null) - bloomComponent.enabled = bloomEnabled; - } + #endregion } } diff --git a/Plugins/DeveloperConsole/DeveloperConsole.cs b/Plugins/DeveloperConsole/DeveloperConsole.cs index 8e538c7..8d2b8ec 100644 --- a/Plugins/DeveloperConsole/DeveloperConsole.cs +++ b/Plugins/DeveloperConsole/DeveloperConsole.cs @@ -1,15 +1,14 @@ using BepInEx; using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using UnityEngine; namespace DeveloperConsole { public class DeveloperConsole : BaseUnityPlugin { + public override string ID => "developerconsole"; public override string Name => "Developer Console"; + public override Version Version => new Version("1.0.1"); private Rect UI = new Rect(20, 20, 400, 200); bool showingUI = false; diff --git a/Plugins/DeveloperConsole/SceneDumper.cs b/Plugins/DeveloperConsole/SceneDumper.cs index 6d8b635..330d81d 100644 --- a/Plugins/DeveloperConsole/SceneDumper.cs +++ b/Plugins/DeveloperConsole/SceneDumper.cs @@ -1,8 +1,6 @@ using System; -using System.Collections.Generic; using System.Diagnostics; using System.IO; -using System.Linq; using System.Text; using UnityEngine; using UnityEngine.SceneManagement; diff --git a/Plugins/DynamicTranslationLoader/DynamicTranslator.cs b/Plugins/DynamicTranslationLoader/DynamicTranslator.cs index bf3b7d0..c2fb1f7 100644 --- a/Plugins/DynamicTranslationLoader/DynamicTranslator.cs +++ b/Plugins/DynamicTranslationLoader/DynamicTranslator.cs @@ -1,12 +1,9 @@ using BepInEx; using BepInEx.Common; -using Harmony; using System; using System.Collections.Generic; using System.IO; using System.Linq; -using System.Reflection; -using System.Text; using System.Text.RegularExpressions; using TMPro; using UnityEngine; @@ -16,11 +13,13 @@ namespace DynamicTranslationLoader { public class DynamicTranslator : BaseUnityPlugin { + public override string ID => "dynamictranslator"; + public override string Name => "Dynamic Translator"; + public override Version Version => new Version("1.2"); + private static Dictionary translations = new Dictionary(); private static List untranslated = new List(); - public override string Name => "Dynamic Translator"; - public DynamicTranslator() { string[] translation = File.ReadAllLines(Utility.CombinePaths(Utility.PluginsDirectory, "translation", "translation.txt")); @@ -35,36 +34,25 @@ namespace DynamicTranslationLoader translations[split[0]] = split[1]; } - - var harmony = HarmonyInstance.Create("com.bepis.bepinex.dynamictranslationloader"); - - MethodInfo original = AccessTools.Property(typeof(TMP_Text), "text").GetSetMethod(); - - HarmonyMethod prefix = new HarmonyMethod(typeof(Hooks).GetMethod("LabelTextHook")); - - harmony.Patch(original, prefix, null); - - - original = AccessTools.Method(typeof(TMP_Text), "SetText", new[] { typeof(string) }); - - prefix = new HarmonyMethod(typeof(Hooks).GetMethod("SetTextHook")); - - harmony.Patch(original, prefix, null); + Hooks.InstallHooks(); } - protected override void LevelFinishedLoading(Scene scene, LoadSceneMode mode) + + void LevelFinishedLoading(Scene scene, LoadSceneMode mode) { TranslateAll(); } - void Update() + public static string Translate(string input) { - if (UnityEngine.Input.GetKeyDown(UnityEngine.KeyCode.F10)) - { - Dump(); - Chainloader.Log($"Text dumped to \"{Path.GetFullPath("dumped-tl.txt")}\"", true); - } + if (translations.ContainsKey(input)) + return translations[input]; + + if (!untranslated.Contains(input)) + untranslated.Add(input); + + return input; } void TranslateAll() @@ -99,15 +87,25 @@ namespace DynamicTranslationLoader File.WriteAllText("dumped-tl.txt", output); } - public static string Translate(string input) + #region MonoBehaviour + void OnEnable() { - if (translations.ContainsKey(input)) - return translations[input]; - - if (!untranslated.Contains(input)) - untranslated.Add(input); - - return input; + SceneManager.sceneLoaded += LevelFinishedLoading; } + + void OnDisable() + { + SceneManager.sceneLoaded -= LevelFinishedLoading; + } + + void Update() + { + if (UnityEngine.Input.GetKeyDown(UnityEngine.KeyCode.F10)) + { + Dump(); + Chainloader.Log($"Text dumped to \"{Path.GetFullPath("dumped-tl.txt")}\"", true); + } + } + #endregion } } diff --git a/Plugins/DynamicTranslationLoader/Hooks.cs b/Plugins/DynamicTranslationLoader/Hooks.cs index 3d3e876..fd980f0 100644 --- a/Plugins/DynamicTranslationLoader/Hooks.cs +++ b/Plugins/DynamicTranslationLoader/Hooks.cs @@ -1,12 +1,30 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using Harmony; +using System.Reflection; +using TMPro; namespace DynamicTranslationLoader { public static class Hooks { + public static void InstallHooks() + { + var harmony = HarmonyInstance.Create("com.bepis.bepinex.dynamictranslationloader"); + + + MethodInfo original = AccessTools.Property(typeof(TMP_Text), "text").GetSetMethod(); + + HarmonyMethod prefix = new HarmonyMethod(typeof(Hooks).GetMethod("LabelTextHook")); + + harmony.Patch(original, prefix, null); + + + original = AccessTools.Method(typeof(TMP_Text), "SetText", new[] { typeof(string) }); + + prefix = new HarmonyMethod(typeof(Hooks).GetMethod("SetTextHook")); + + harmony.Patch(original, prefix, null); + } + public static void LabelTextHook(ref string value) { value = DynamicTranslator.Translate(value); diff --git a/Plugins/InputUnlocker/InputUnlocker.cs b/Plugins/InputUnlocker/InputUnlocker.cs index bd58fed..06c2c1d 100644 --- a/Plugins/InputUnlocker/InputUnlocker.cs +++ b/Plugins/InputUnlocker/InputUnlocker.cs @@ -1,8 +1,5 @@ using BepInEx; using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using UnityEngine; using UnityEngine.SceneManagement; @@ -10,14 +7,28 @@ namespace InputUnlocker { class InputUnlocker : BaseUnityPlugin { + public override string ID => "inputunlocker"; public override string Name => "Input Length Unlocker"; + public override Version Version => new Version("1.0"); - protected override void LevelFinishedLoading(Scene scene, LoadSceneMode mode) + void LevelFinishedLoading(Scene scene, LoadSceneMode mode) { foreach (UnityEngine.UI.InputField gameObject in GameObject.FindObjectsOfType()) { gameObject.characterLimit = 99; } } + + #region MonoBehaviour + void OnEnable() + { + SceneManager.sceneLoaded += LevelFinishedLoading; + } + + void OnDisable() + { + SceneManager.sceneLoaded -= LevelFinishedLoading; + } + #endregion } } diff --git a/Plugins/ResourceRedirector/ResourceRedirector.cs b/Plugins/ResourceRedirector/ResourceRedirector.cs index 9b338d8..10e3a82 100644 --- a/Plugins/ResourceRedirector/ResourceRedirector.cs +++ b/Plugins/ResourceRedirector/ResourceRedirector.cs @@ -1,20 +1,17 @@ using BepInEx; using BepInEx.Common; -using Harmony; -using Illusion.Game; using System; -using System.Collections; using System.Collections.Generic; using System.IO; -using System.Reflection; using UnityEngine; -using UnityEngine.SceneManagement; namespace ResourceRedirector { public class ResourceRedirector : BaseUnityPlugin { + public override string ID => "resourceredirector"; public override string Name => "Asset Emulator"; + public override Version Version => new Version("1.3"); public static string EmulatedDir => Path.Combine(Utility.ExecutingDirectory, "abdata-emulated"); diff --git a/Plugins/SliderUnlocker/Hooks.cs b/Plugins/SliderUnlocker/Hooks.cs index e66eb0f..e742a9d 100644 --- a/Plugins/SliderUnlocker/Hooks.cs +++ b/Plugins/SliderUnlocker/Hooks.cs @@ -1,14 +1,63 @@ -using System; +using ChaCustom; +using Harmony; +using System; using System.Collections.Generic; using System.Linq; using System.Reflection; -using System.Text; using UnityEngine; namespace SliderUnlocker { public static class Hooks { + public static void InstallHooks() + { + var harmony = HarmonyInstance.Create("com.bepis.bepinex.sliderunlocker"); + + MethodInfo original = AccessTools.Method(typeof(CustomBase), "ConvertTextFromRate"); + + HarmonyMethod postfix = new HarmonyMethod(typeof(Hooks).GetMethod("ConvertTextFromRateHook")); + + harmony.Patch(original, null, postfix); + + + + original = AccessTools.Method(typeof(CustomBase), "ConvertRateFromText"); + + postfix = new HarmonyMethod(typeof(Hooks).GetMethod("ConvertRateFromTextHook")); + + harmony.Patch(original, null, postfix); + + + + original = AccessTools.Method(typeof(Mathf), "Clamp", new Type[] { typeof(float), typeof(float), typeof(float) }); + + postfix = new HarmonyMethod(typeof(Hooks).GetMethod("MathfClampHook")); + + harmony.Patch(original, null, postfix); + + + + + original = typeof(AnimationKeyInfo).GetMethods().Where(x => x.Name.Contains("GetInfo")).ToArray()[0]; + + var prefix = new HarmonyMethod(typeof(Hooks).GetMethod("GetInfoSingularPreHook")); + + postfix = new HarmonyMethod(typeof(Hooks).GetMethod("GetInfoSingularPostHook")); + + harmony.Patch(original, prefix, postfix); + + + + original = typeof(AnimationKeyInfo).GetMethods().Where(x => x.Name.Contains("GetInfo")).ToArray()[1]; + + prefix = new HarmonyMethod(typeof(Hooks).GetMethod("GetInfoPreHook")); + + postfix = new HarmonyMethod(typeof(Hooks).GetMethod("GetInfoPostHook")); + + harmony.Patch(original, prefix, postfix); + } + private static FieldInfo akf_dictInfo = (typeof(AnimationKeyInfo).GetField("dictInfo", BindingFlags.NonPublic | BindingFlags.Instance)); public static void ConvertTextFromRateHook(ref string __result, int min, int max, float value) diff --git a/Plugins/SliderUnlocker/SliderMath.cs b/Plugins/SliderUnlocker/SliderMath.cs index a91a216..987e71e 100644 --- a/Plugins/SliderUnlocker/SliderMath.cs +++ b/Plugins/SliderUnlocker/SliderMath.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using System.Collections.Generic; using UnityEngine; using static AnimationKeyInfo; diff --git a/Plugins/SliderUnlocker/SliderUnlocker.cs b/Plugins/SliderUnlocker/SliderUnlocker.cs index e900f2c..74d585e 100644 --- a/Plugins/SliderUnlocker/SliderUnlocker.cs +++ b/Plugins/SliderUnlocker/SliderUnlocker.cs @@ -1,12 +1,9 @@ using BepInEx; using ChaCustom; -using Harmony; -using Illusion.Component.UI.ColorPicker; using System; using System.Collections.Generic; using System.Linq; using System.Reflection; -using System.Text; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UI; @@ -15,69 +12,24 @@ namespace SliderUnlocker { public class SliderUnlocker : BaseUnityPlugin { + public override string ID => "sliderunlocker"; public override string Name => "Slider Unlocker"; + public override Version Version => new Version("1.5"); public static float Minimum = -1.0f; public static float Maximum = 2.0f; public SliderUnlocker() { - PatchMethods(); + Hooks.InstallHooks(); } - private void PatchMethods() - { - var harmony = HarmonyInstance.Create("com.bepis.bepinex.sliderunlocker"); - - MethodInfo original = AccessTools.Method(typeof(CustomBase), "ConvertTextFromRate"); - - HarmonyMethod postfix = new HarmonyMethod(typeof(Hooks).GetMethod("ConvertTextFromRateHook")); - - harmony.Patch(original, null, postfix); - - - - original = AccessTools.Method(typeof(CustomBase), "ConvertRateFromText"); - - postfix = new HarmonyMethod(typeof(Hooks).GetMethod("ConvertRateFromTextHook")); - - harmony.Patch(original, null, postfix); - - - - original = AccessTools.Method(typeof(Mathf), "Clamp", new Type[] { typeof(float), typeof(float), typeof(float) }); - - postfix = new HarmonyMethod(typeof(Hooks).GetMethod("MathfClampHook")); - - harmony.Patch(original, null, postfix); - - - - - original = typeof(AnimationKeyInfo).GetMethods().Where(x => x.Name.Contains("GetInfo")).ToArray()[0]; - - var prefix = new HarmonyMethod(typeof(Hooks).GetMethod("GetInfoSingularPreHook")); - - postfix = new HarmonyMethod(typeof(Hooks).GetMethod("GetInfoSingularPostHook")); - - harmony.Patch(original, prefix, postfix); - - - - original = typeof(AnimationKeyInfo).GetMethods().Where(x => x.Name.Contains("GetInfo")).ToArray()[1]; - - prefix = new HarmonyMethod(typeof(Hooks).GetMethod("GetInfoPreHook")); - - postfix = new HarmonyMethod(typeof(Hooks).GetMethod("GetInfoPostHook")); - - harmony.Patch(original, prefix, postfix); - } - - protected override void LevelFinishedLoading(Scene scene, LoadSceneMode mode) + void LevelFinishedLoading(Scene scene, LoadSceneMode mode) { SetAllSliders(scene, Minimum, Maximum); } + public void SetAllSliders(Scene scene, float minimum, float maximum) { List cvsInstances = new List(); @@ -118,5 +70,17 @@ namespace SliderUnlocker } } } + + #region MonoBehaviour + void OnEnable() + { + SceneManager.sceneLoaded += LevelFinishedLoading; + } + + void OnDisable() + { + SceneManager.sceneLoaded -= LevelFinishedLoading; + } + #endregion } } \ No newline at end of file