Implemented an advanced plugin loader

This commit is contained in:
Bepis committed 2018-02-14 07:50:03 +11:00
1 parent 849e722c1a
commit 53bc809afa
29 files changed
+522 -354

No files matched your search

+14
View File
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
<HasSharedItems>true</HasSharedItems>
<SharedGUID>d8deeef7-28f5-4f13-a004-c581ce051cdc</SharedGUID>
</PropertyGroup>
<PropertyGroup Label="Configuration">
<Import_RootNamespace>BepInEx.Common</Import_RootNamespace>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)Utility.cs" />
</ItemGroup>
</Project>
+13
View File
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Globals">
<ProjectGuid>d8deeef7-28f5-4f13-a004-c581ce051cdc</ProjectGuid>
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.props" />
<PropertyGroup />
<Import Project="BepInEx.Common.projitems" Label="Shared" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.CSharp.targets" />
</Project>
@@ -5,7 +5,7 @@ using System.Linq;
using System.Reflection;
using System.Text;
namespace BepInEx
namespace BepInEx.Common
{
public static class Utility
{
+4 -4
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
</configuration>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2"/></startup>
</configuration>
+5 -6
View File
@@ -11,16 +11,18 @@
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>M:\koikatu\KoikatuTrial_Data\Managed\</OutputPath>
<OutputPath>D:\koikatu\KoikatuTrial_Data\Managed\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -30,6 +32,7 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="Mono.Cecil, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
@@ -48,15 +51,10 @@
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Internal\TitleScenePlugin.cs" />
<Compile Include="Internal\ExitScenePlugin.cs" />
<Compile Include="Internal\SliderPlugin.cs" />
<Compile Include="IPatchPlugin.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
@@ -65,5 +63,6 @@
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="..\BepInEx.Common\BepInEx.Common.projitems" Label="Shared" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
-1
View File
@@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Mono.Cecil;
namespace BepInEx.Patcher
@@ -1,23 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Mono.Cecil;
using Mono.Cecil.Cil;
namespace BepInEx.Patcher.Internal
{
public class ExitScenePlugin : IPatchPlugin
{
public void Patch(AssemblyDefinition assembly)
{
TypeDefinition exitScene = assembly.MainModule.Types.First(x => x.Name == "ExitScene");
var startExit = exitScene.Methods.First(x => x.Name == "Start");
var IL = startExit.Body.GetILProcessor();
IL.Replace(startExit.Body.Instructions[26], IL.Create(OpCodes.Ldstr, "Do you want to exit the character maker?"));
}
}
}
-32
View File
@@ -1,32 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Mono.Cecil;
using Mono.Cecil.Cil;
namespace BepInEx.Patcher.Internal
{
public class SliderPlugin : IPatchPlugin
{
public void Patch(AssemblyDefinition assembly)
{
TypeDefinition customBase = assembly.MainModule.Types.First(x => x.Name == "CustomBase");
var methods = customBase.Methods;
var convertTextFromRate = methods.First(x => x.Name == "ConvertTextFromRate");
var IL = convertTextFromRate.Body.GetILProcessor();
IL.Replace(convertTextFromRate.Body.Instructions[0], IL.Create(OpCodes.Ldc_I4, -0));
IL.Replace(convertTextFromRate.Body.Instructions[2], IL.Create(OpCodes.Ldc_I4, 200));
var convertRateFromText = methods.First(x => x.Name == "ConvertRateFromText");
IL = convertRateFromText.Body.GetILProcessor();
IL.Replace(convertRateFromText.Body.Instructions[11], IL.Create(OpCodes.Ldc_I4, -0));
IL.Replace(convertRateFromText.Body.Instructions[13], IL.Create(OpCodes.Ldc_I4, 200));
}
}
}
@@ -1,40 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Mono.Cecil;
using Mono.Cecil.Cil;
namespace BepInEx.Patcher.Internal
{
public class TitleScenePlugin : IPatchPlugin
{
public void Patch(AssemblyDefinition assembly)
{
TypeDefinition CustomTrialTitle = assembly.MainModule.Types.First(x => x.Name == "CustomTrialTitle");
var enter = CustomTrialTitle.Methods.First(x => x.Name == "Enter");
var IL = enter.Body.GetILProcessor();
//IL.Replace(enter.Body.Instructions[32], IL.Create(OpCodes.Ldstr, "Title"));
IL.Replace(enter.Body.Instructions[15], IL.Create(OpCodes.Ldstr, "Title"));
var lambda = (MethodDefinition)enter.Body.Instructions[45].Operand;
var onCustom = CustomTrialTitle.Methods.First(x => x.Name == "OnCustom");
onCustom.Body.Instructions[1].Operand = "Title";
IL = lambda.Body.GetILProcessor();
var method = (GenericInstanceMethod)lambda.Body.Instructions[2].Operand;
method.GenericArguments[0] = assembly.MainModule.Types.First(x => x.Name == "TitleScene");
//IL.Remove(lambda.Body.Instructions[1]);
//IL.Remove(lambda.Body.Instructions[0]);
//IL.InsertBefore(lambda.Body.Instructions[0], IL.Create(OpCodes.Ldstr, "Title"));
}
}
}
+6 -7
View File
@@ -1,12 +1,12 @@
using BepInEx.Patcher.Internal;
using BepInEx.Common;
using Mono.Cecil;
using Mono.Cecil.Cil;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace BepInEx.Patcher
{
@@ -39,6 +39,8 @@ namespace BepInEx.Patcher
if (!File.Exists(unityOriginalDLL))
File.Copy(unityOutputDLL, unityOriginalDLL);
Assembly.LoadFile(unityOriginalDLL);
string tmOutputDLL = Path.GetFullPath("TextMeshPro-1.0.55.56.0b12.dll");
if (!File.Exists(tmOutputDLL))
@@ -47,6 +49,7 @@ namespace BepInEx.Patcher
string tmOriginalDLL = Path.GetFullPath("TextMeshPro-1.0.55.56.0b12.dll.bak");
if (!File.Exists(tmOriginalDLL))
File.Copy(tmOutputDLL, tmOriginalDLL);
string injectedDLL = Path.GetFullPath("BepInEx.dll");
@@ -77,11 +80,7 @@ namespace BepInEx.Patcher
InjectAssembly(assembly, unity, tm, injected);
IPatchPlugin exitScene = new ExitScenePlugin();
exitScene.Patch(assembly);
assembly.Write(assemblyDLL);
unity.Write(unityOutputDLL);
+33 -1
View File
@@ -1,13 +1,28 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27130.2027
VisualStudioVersion = 15.0.26228.9
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BepInEx", "BepInEx\BepInEx.csproj", "{4FFBA620-F5ED-47F9-B90C-DAD1316FD9B9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BepInEx.Patcher", "BepInEx.Patcher\BepInEx.Patcher.csproj", "{DC89F18B-235B-4C01-AB31-AF40DCE5C4C7}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Plugins", "Plugins", "{FF8CE2C8-C185-4EA9-8D63-E2542F0C2FCF}"
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "BepInEx.Common", "BepInEx.Common\BepInEx.Common.shproj", "{D8DEEEF7-28F5-4F13-A004-C581CE051CDC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DynamicTranslationLoader", "Plugins\DynamicTranslationLoader\DynamicTranslationLoader.csproj", "{6FE9DE86-F466-49FD-BCCA-ADD512C8DCE8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InputUnlocker", "Plugins\InputUnlocker\InputUnlocker.csproj", "{379BA41B-9944-4B5A-8732-EEBAA7F05B04}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SceneDumper", "Plugins\SceneDumper\SceneDumper.csproj", "{C42BD13E-B5E4-4B73-B21B-E34B9DFA9108}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
BepInEx.Common\BepInEx.Common.projitems*{4ffba620-f5ed-47f9-b90c-dad1316fd9b9}*SharedItemsImports = 4
BepInEx.Common\BepInEx.Common.projitems*{d8deeef7-28f5-4f13-a004-c581ce051cdc}*SharedItemsImports = 13
BepInEx.Common\BepInEx.Common.projitems*{dc89f18b-235b-4c01-ab31-af40dce5c4c7}*SharedItemsImports = 4
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
@@ -21,10 +36,27 @@ Global
{DC89F18B-235B-4C01-AB31-AF40DCE5C4C7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DC89F18B-235B-4C01-AB31-AF40DCE5C4C7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DC89F18B-235B-4C01-AB31-AF40DCE5C4C7}.Release|Any CPU.Build.0 = Release|Any CPU
{6FE9DE86-F466-49FD-BCCA-ADD512C8DCE8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6FE9DE86-F466-49FD-BCCA-ADD512C8DCE8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6FE9DE86-F466-49FD-BCCA-ADD512C8DCE8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6FE9DE86-F466-49FD-BCCA-ADD512C8DCE8}.Release|Any CPU.Build.0 = Release|Any CPU
{379BA41B-9944-4B5A-8732-EEBAA7F05B04}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{379BA41B-9944-4B5A-8732-EEBAA7F05B04}.Debug|Any CPU.Build.0 = Debug|Any CPU
{379BA41B-9944-4B5A-8732-EEBAA7F05B04}.Release|Any CPU.ActiveCfg = Release|Any CPU
{379BA41B-9944-4B5A-8732-EEBAA7F05B04}.Release|Any CPU.Build.0 = Release|Any CPU
{C42BD13E-B5E4-4B73-B21B-E34B9DFA9108}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C42BD13E-B5E4-4B73-B21B-E34B9DFA9108}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C42BD13E-B5E4-4B73-B21B-E34B9DFA9108}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C42BD13E-B5E4-4B73-B21B-E34B9DFA9108}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{6FE9DE86-F466-49FD-BCCA-ADD512C8DCE8} = {FF8CE2C8-C185-4EA9-8D63-E2542F0C2FCF}
{379BA41B-9944-4B5A-8732-EEBAA7F05B04} = {FF8CE2C8-C185-4EA9-8D63-E2542F0C2FCF}
{C42BD13E-B5E4-4B73-B21B-E34B9DFA9108} = {FF8CE2C8-C185-4EA9-8D63-E2542F0C2FCF}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {55AC11EF-F568-4C79-A356-7ED9510145B1}
EndGlobalSection
+29
View File
@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
using UnityEngine.SceneManagement;
namespace BepInEx
{
public abstract class BaseUnityPlugin : MonoBehaviour
{
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)
{
}
}
}
+12 -42
View File
@@ -13,61 +13,31 @@ namespace BepInEx
//Adapted from https://github.com/Eusth/IPA/blob/0df8b1ecb87fdfc9e169365cb4a8fd5a909a2ad6/IllusionInjector/PluginComponent.cs
public class BepInComponent : MonoBehaviour
{
IEnumerable<IUnityPlugin> Plugins;
List<BaseUnityPlugin> Plugins;
private bool quitting = false;
public static BepInComponent Create()
public static GameObject Create()
{
return new GameObject("BepInEx_Manager").AddComponent<BepInComponent>();
var obj = new GameObject("BepInEx_Manager");
var manager = obj.AddComponent<BepInComponent>();
manager.Plugins = new List<BaseUnityPlugin>();
foreach (Type t in Chainloader.Plugins)
manager.Plugins.Add((BaseUnityPlugin)obj.AddComponent(t));
return obj;
}
void Awake()
{
DontDestroyOnLoad(gameObject);
Plugins = Chainloader.Plugins;
}
void Start()
{
Console.WriteLine("Component ready");
foreach (IUnityPlugin plugin in Plugins)
plugin.OnStart();
}
void OnEnable()
{
SceneManager.sceneLoaded += LevelFinishedLoading;
}
void OnDisable()
{
SceneManager.sceneLoaded -= LevelFinishedLoading;
}
void Update()
{
foreach (IUnityPlugin plugin in Plugins)
plugin.OnUpdate();
}
void LateUpdate()
{
foreach (IUnityPlugin plugin in Plugins)
plugin.OnLateUpdate();
}
void FixedUpdate()
{
foreach (IUnityPlugin plugin in Plugins)
plugin.OnFixedUpdate();
}
void LevelFinishedLoading(Scene scene, LoadSceneMode mode)
{
foreach (IUnityPlugin plugin in Plugins)
plugin.OnLevelFinishedLoading(scene, mode);
}
void OnDestroy()
+8 -9
View File
@@ -18,7 +18,7 @@
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>M:\koikatu\KoikatuTrial_Data\Managed\</OutputPath>
<OutputPath>D:\koikatu\KoikatuTrial_Data\Managed\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
@@ -27,7 +27,7 @@
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<OutputPath>D:\koikatu\KoikatuTrial_Data\Managed\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
@@ -39,6 +39,7 @@
<Reference Include="Assembly-CSharp-original, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>D:\koikatu\KoikatuTrial_Data\Managed\Assembly-CSharp-original.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Windows.Forms" />
@@ -47,14 +48,17 @@
<Reference Include="TextMeshPro-1.0.55.56.0b12, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>D:\koikatu\KoikatuTrial_Data\Managed\TextMeshPro-1.0.55.56.0b12.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine-original, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>D:\koikatu\KoikatuTrial_Data\Managed\UnityEngine-original.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.UI, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>D:\koikatu\KoikatuTrial_Data\Managed\UnityEngine.UI.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
@@ -67,18 +71,13 @@
<Compile Include="ConsoleUtil\Extensions.cs" />
<Compile Include="ConsoleUtil\SafeConsole.cs" />
<Compile Include="Chainloader.cs" />
<Compile Include="Internal\DumpScenePlugin.cs" />
<Compile Include="Internal\TranslationPlugin.cs" />
<Compile Include="Internal\UnlockedInputPlugin.cs" />
<Compile Include="ITranslationPlugin.cs" />
<Compile Include="IUnityPlugin.cs" />
<Compile Include="PluginLoader.cs" />
<Compile Include="BaseUnityPlugin.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Utility.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="..\BepInEx.Common\BepInEx.Common.projitems" Label="Shared" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
+47 -23
View File
@@ -1,17 +1,20 @@
using BepInEx.Internal;
using BepInEx.Common;
using ChaCustom;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using UnityEngine;
namespace BepInEx
{
public class Chainloader
{
static bool loaded = false;
public static IEnumerable<IUnityPlugin> Plugins;
public static IEnumerable<ITranslationPlugin> TLPlugins;
public static IEnumerable<Type> Plugins;
public static GameObject managerObject;
public static void Initialize()
{
@@ -21,37 +24,58 @@ namespace BepInEx
UnityInjector.ConsoleUtil.ConsoleWindow.Attach();
Console.WriteLine("Chainloader started");
TranslationPlugin translationPlugin = new TranslationPlugin();
Plugins = new List<IUnityPlugin>
{
new DumpScenePlugin(),
new UnlockedInputPlugin(),
translationPlugin
};
TLPlugins = new List<ITranslationPlugin>
{
translationPlugin
};
UnityInjector.ConsoleUtil.ConsoleWindow.Attach();
UnityInjector.ConsoleUtil.ConsoleEncoding.ConsoleCodePage = 932;
Plugins = LoadTypes<BaseUnityPlugin>(Utility.PluginsDirectory);
//UnityInjector.ConsoleUtil.ConsoleEncoding.ConsoleCodePage = 932;
Console.WriteLine($"{Plugins.Count()} plugins loaded");
BepInComponent.Create();
managerObject = BepInComponent.Create();
loaded = true;
}
public static string TextLoadedHook(string text)
{
foreach (var plugin in TLPlugins)
if (plugin.TryTranslate(text, out string output))
return output;
//foreach (var plugin in TLPlugins)
// if (plugin.TryTranslate(text, out string output))
// return output;
return text;
}
public static ICollection<Type> LoadTypes<T>(string directory)
{
List<Type> types = new List<Type>();
Type pluginType = typeof(T);
foreach (string dll in Directory.GetFiles(Path.GetFullPath(directory), "*.dll"))
{
try
{
AssemblyName an = AssemblyName.GetAssemblyName(dll);
Assembly assembly = Assembly.Load(an);
foreach (Type type in assembly.GetTypes())
{
if (type.IsInterface || type.IsAbstract)
{
continue;
}
else
{
if (type.BaseType == pluginType)
types.Add(type);
}
}
}
catch (BadImageFormatException)
{
}
}
return types;
}
}
}
-22
View File
@@ -1,22 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine.SceneManagement;
namespace BepInEx
{
public interface IUnityPlugin
{
void OnStart();
void OnLevelFinishedLoading(Scene scene, LoadSceneMode mode);
void OnUpdate();
void OnLateUpdate();
void OnFixedUpdate();
}
}
-40
View File
@@ -1,40 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
using UnityEngine.SceneManagement;
namespace BepInEx.Internal
{
class UnlockedInputPlugin : IUnityPlugin
{
public void OnStart()
{
}
public void OnLevelFinishedLoading(Scene scene, LoadSceneMode mode)
{
foreach (UnityEngine.UI.InputField gameObject in GameObject.FindObjectsOfType<UnityEngine.UI.InputField>())
{
gameObject.characterLimit = 99;
}
}
public void OnFixedUpdate()
{
}
public void OnLateUpdate()
{
}
public void OnUpdate()
{
}
}
}
-48
View File
@@ -1,48 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
namespace BepInEx
{
public static class PluginLoader
{
public static ICollection<T> LoadPlugins<T>(string directory)
{
List<T> plugins = new List<T>();
Type pluginType = typeof(T);
foreach (string dll in Directory.GetFiles(Path.GetFullPath(directory), "*.dll"))
{
try
{
AssemblyName an = AssemblyName.GetAssemblyName(dll);
Assembly assembly = Assembly.Load(an);
foreach (Type type in assembly.GetTypes())
{
if (type.IsInterface || type.IsAbstract)
{
continue;
}
else
{
if (type.GetInterface(pluginType.FullName) != null)
{
plugins.Add((T)Activator.CreateInstance(type));
}
}
}
}
catch (BadImageFormatException ex)
{
}
}
return plugins;
}
}
}
+2 -2
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
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyFileVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
-4
View File
@@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net20" requireReinstallation="true" />
</packages>
@@ -0,0 +1,71 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{6FE9DE86-F466-49FD-BCCA-ADD512C8DCE8}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>DynamicTranslationLoader</RootNamespace>
<AssemblyName>DynamicTranslationLoader</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>D:\koikatu\KoikatuTrial_Data\Managed\BepInEx\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Assembly-CSharp, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>D:\koikatu\KoikatuTrial_Data\Managed\Assembly-CSharp.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="TextMeshPro-1.0.55.56.0b12, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>D:\koikatu\KoikatuTrial_Data\Managed\TextMeshPro-1.0.55.56.0b12.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>D:\koikatu\KoikatuTrial_Data\Managed\UnityEngine.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.UI">
<HintPath>D:\koikatu\KoikatuTrial_Data\Managed\UnityEngine.UI.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="DynamicTranslator.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\BepInEx\BepInEx.csproj">
<Project>{4ffba620-f5ed-47f9-b90c-dad1316fd9b9}</Project>
<Name>BepInEx</Name>
<Private>False</Private>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
@@ -1,4 +1,6 @@
using System;
using BepInEx;
using BepInEx.Common;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@@ -8,14 +10,16 @@ using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;
namespace BepInEx.Internal
namespace DynamicTranslationLoader
{
public class TranslationPlugin : ITranslationPlugin, IUnityPlugin
public class DynamicTranslator : BaseUnityPlugin
{
Dictionary<string, string> translations = new Dictionary<string, string>();
List<string> untranslated = new List<string>();
public TranslationPlugin()
public override string Name => "Dynamic Translator";
public DynamicTranslator()
{
string[] translation = File.ReadAllLines(Utility.CombinePaths(Utility.ExecutingDirectory, "translation", "translation.txt"));
@@ -31,27 +35,12 @@ namespace BepInEx.Internal
}
}
public void OnStart()
{
}
public void OnLevelFinishedLoading(Scene scene, LoadSceneMode mode)
protected override void LevelFinishedLoading(Scene scene, LoadSceneMode mode)
{
Translate();
}
public void OnFixedUpdate()
{
}
public void OnLateUpdate()
{
}
public void OnUpdate()
void OnUpdate()
{
if (UnityEngine.Event.current.Equals(Event.KeyboardEvent("f9")))
{
@@ -74,7 +63,7 @@ namespace BepInEx.Internal
gameObject.text = translations[gameObject.text];
else
if (!untranslated.Contains(gameObject.text))
untranslated.Add(gameObject.text);
untranslated.Add(gameObject.text);
}
}
@@ -90,7 +79,7 @@ namespace BepInEx.Internal
&& !text.Contains("Reset")
&& !Regex.Replace(text, @"[\d-]", string.Empty).IsNullOrWhiteSpace()
&& !translations.ContainsValue(text.Trim()))
output += $"{text.Trim()}=\r\n";
output += $"{text.Trim()}=\r\n";
File.WriteAllText("dumped-tl.txt", output);
}
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("BaseTranslationLoader")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BaseTranslationLoader")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("6fe9de86-f466-49fd-bcca-add512c8dce8")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// 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("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
+23
View File
@@ -0,0 +1,23 @@
using BepInEx;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
using UnityEngine.SceneManagement;
namespace InputUnlocker
{
class InputUnlocker : BaseUnityPlugin
{
public override string Name => "Input Length Unlocker";
protected override void LevelFinishedLoading(Scene scene, LoadSceneMode mode)
{
foreach (UnityEngine.UI.InputField gameObject in GameObject.FindObjectsOfType<UnityEngine.UI.InputField>())
{
gameObject.characterLimit = 99;
}
}
}
}
@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{379BA41B-9944-4B5A-8732-EEBAA7F05B04}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>InputUnlocker</RootNamespace>
<AssemblyName>InputUnlocker</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>D:\koikatu\KoikatuTrial_Data\Managed\BepInEx\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="UnityEngine">
<HintPath>D:\koikatu\KoikatuTrial_Data\Managed\UnityEngine.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.UI">
<HintPath>D:\koikatu\KoikatuTrial_Data\Managed\UnityEngine.UI.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="InputUnlocker.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\BepInEx\BepInEx.csproj">
<Project>{4ffba620-f5ed-47f9-b90c-dad1316fd9b9}</Project>
<Name>BepInEx</Name>
<Private>False</Private>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("InputUnlocker")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("InputUnlocker")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("379ba41b-9944-4b5a-8732-eebaa7f05b04")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// 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("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("SceneDumper")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SceneDumper")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("c42bd13e-b5e4-4b73-b21b-e34b9dfa9108")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// 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("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
@@ -1,4 +1,5 @@
using System;
using BepInEx;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@@ -8,40 +9,23 @@ using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;
namespace BepInEx.Internal
namespace SceneDumper
{
class DumpScenePlugin : IUnityPlugin
class SceneDumper : BaseUnityPlugin
{
public void OnStart()
{
public override string Name => "Scene Dumper";
}
public void OnLevelFinishedLoading(Scene scene, LoadSceneMode mode)
{
}
public void OnFixedUpdate()
{
}
public void OnLateUpdate()
{
}
public void OnUpdate()
void OnUpdate()
{
if (UnityEngine.Event.current.Equals(Event.KeyboardEvent("f8")))
{
//DumpScene();
DumpScene();
}
}
static List<string> lines;
public static void DumpScene()
{
lines = new List<string>();
@@ -88,9 +72,9 @@ namespace BepInEx.Internal
{
string text = ((TextMeshProUGUI)component).text;
if (!text.IsNullOrWhiteSpace()
if (text.Trim() != ""
&& !text.Contains("Reset")
&& !Regex.Replace(text, @"[\d-]", string.Empty).IsNullOrWhiteSpace())
&& Regex.Replace(text, @"[\d-]", string.Empty).Trim() != "")
{
if (!lines.Contains(text))
lines.Add(text);
+64
View File
@@ -0,0 +1,64 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{C42BD13E-B5E4-4B73-B21B-E34B9DFA9108}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SceneDumper</RootNamespace>
<AssemblyName>SceneDumper</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>D:\koikatu\KoikatuTrial_Data\Managed\BepInEx\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="TextMeshPro-1.0.55.56.0b12">
<HintPath>D:\koikatu\KoikatuTrial_Data\Managed\TextMeshPro-1.0.55.56.0b12.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine">
<HintPath>D:\koikatu\KoikatuTrial_Data\Managed\UnityEngine.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.UI">
<HintPath>D:\koikatu\KoikatuTrial_Data\Managed\UnityEngine.UI.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="SceneDumper.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\BepInEx\BepInEx.csproj">
<Project>{4ffba620-f5ed-47f9-b90c-dad1316fd9b9}</Project>
<Name>BepInEx</Name>
<Private>False</Private>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>