mirror of
https://github.com/BepInEx/BepInEx.git
synced 2026-10-20 01:46:13 +00:00
Update contract and general clean up
This commit is contained in:
1 parent
9f9b97c540
commit
f684c1004e
11 files changed
+185
-150
No files matched your search
@@ -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; }
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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<string, string> translations = new Dictionary<string, string>();
|
||||
private static List<string> untranslated = new List<string>();
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
@@ -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<UnityEngine.UI.InputField>())
|
||||
{
|
||||
gameObject.characterLimit = 99;
|
||||
}
|
||||
}
|
||||
|
||||
#region MonoBehaviour
|
||||
void OnEnable()
|
||||
{
|
||||
SceneManager.sceneLoaded += LevelFinishedLoading;
|
||||
}
|
||||
|
||||
void OnDisable()
|
||||
{
|
||||
SceneManager.sceneLoaded -= LevelFinishedLoading;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -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");
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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<object> cvsInstances = new List<object>();
|
||||
@@ -118,5 +70,17 @@ namespace SliderUnlocker
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region MonoBehaviour
|
||||
void OnEnable()
|
||||
{
|
||||
SceneManager.sceneLoaded += LevelFinishedLoading;
|
||||
}
|
||||
|
||||
void OnDisable()
|
||||
{
|
||||
SceneManager.sceneLoaded -= LevelFinishedLoading;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user