Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions Assembly-CSharp/Assembly-CSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
<Dependencies Include="$(TargetDir)Newtonsoft.Json.dll" />
<Dependencies Include="$(TargetDir)MMHOOK_Assembly-CSharp.dll" />
<Dependencies Include="$(TargetDir)MMHOOK_PlayMaker.dll" />
<Dependencies Include="$(TargetDir)MMHOOK_TeamCherry.TK2D.dll" />
<Dependencies Include="$(TargetDir)MMHOOK_TeamCherry.Cinematics.dll" />
<Dependencies Include="$(TargetDir)MonoMod.Utils.dll" />
<Dependencies Include="$(TargetDir)Mono.Cecil.dll" />
<Dependencies Include="$(TargetDir)MonoMod.RuntimeDetour.dll" />
Expand All @@ -45,11 +47,16 @@
<Copy SkipUnchangedFiles="true" SourceFiles="$(TargetDir)Assembly-CSharp-patched.dll" DestinationFiles="$(TargetDir)Assembly-CSharp.dll" />

<Delete Condition="Exists('MONOMODDED_Assembly-CSharp.dll')" Files="MONOMODDED_Assembly-CSharp.dll" />
<Exec WorkingDirectory="@(BuildDir)" Command="$(Mono) MonoMod.exe Assembly-CSharp.dll" />
<Exec WorkingDirectory="@(BuildDir)" Command="$(Mono) &quot;$(TargetDir)MonoMod.exe&quot; Assembly-CSharp.dll" />

<!-- Generate Hooks !-->
<Exec Condition="!Exists('$(TargetDir)MMHOOK_Assembly-CSharp.dll')" WorkingDirectory="@(BuildDir)" Command="$(Mono) MonoMod.RuntimeDetour.HookGen.exe --private Assembly-CSharp.dll" />
<Exec Condition="!Exists('$(TargetDir)MMHOOK_Playmaker.dll')" WorkingDirectory="@(BuildDir)" Command="$(Mono) MonoMod.RuntimeDetour.HookGen.exe --private PlayMaker.dll" />
<Exec Condition="!Exists('$(TargetDir)MMHOOK_Assembly-CSharp.dll')" WorkingDirectory="@(BuildDir)" Command="$(Mono) &quot;$(TargetDir)MonoMod.RuntimeDetour.HookGen.exe&quot; --private Assembly-CSharp.dll" />
<Exec Condition="!Exists('$(TargetDir)MMHOOK_Playmaker.dll')" WorkingDirectory="@(BuildDir)" Command="$(Mono) &quot;$(TargetDir)MonoMod.RuntimeDetour.HookGen.exe&quot; --private PlayMaker.dll" />
<!-- Generate hooks for TeamCherry.* (types moved here in Unity 6) and forward into MMHOOK_Assembly-CSharp for backward compat -->
<Exec Condition="!Exists('$(TargetDir)MMHOOK_TeamCherry.TK2D.dll')" WorkingDirectory="@(BuildDir)" Command="$(Mono) &quot;$(TargetDir)MonoMod.RuntimeDetour.HookGen.exe&quot; --private TeamCherry.TK2D.dll" />
<Exec Condition="!Exists('$(TargetDir)MMHOOK_TeamCherry.Cinematics.dll')" WorkingDirectory="@(BuildDir)" Command="$(Mono) &quot;$(TargetDir)MonoMod.RuntimeDetour.HookGen.exe&quot; --private TeamCherry.Cinematics.dll" />
<Exec WorkingDirectory="@(BuildDir)" Command="$(Mono) &quot;$(MSBuildProjectDirectory)/../PrePatcher/Output/PrePatcher.exe&quot; --mmhook MMHOOK_Assembly-CSharp.dll MMHOOK_TeamCherry.TK2D.dll" />
<Exec WorkingDirectory="@(BuildDir)" Command="$(Mono) &quot;$(MSBuildProjectDirectory)/../PrePatcher/Output/PrePatcher.exe&quot; --mmhook MMHOOK_Assembly-CSharp.dll MMHOOK_TeamCherry.Cinematics.dll" />
</Target>

<Target Name="SetupExamples" AfterTargets="PostBuildEvent" Condition="'$(SetupExamples)' == 'true'">
Expand All @@ -72,10 +79,9 @@
<!-- Make the output directory -->
<MakeDir Directories="$(OutputDir)/" />

<!-- Copy the API, the documentation, the overridden mscorlib, and the README. -->
<!-- Copy the API, the documentation, and the README. -->
<!-- mscorlib.dll is NOT copied: Unity 6 provides its own mscorlib; the override is build-time reference only. -->
<Copy SourceFiles="../README.ModdingApi.md" DestinationFiles="$(OutputDir)/README.md" />
<Copy SourceFiles="../override/mscorlib.dll" DestinationFiles="$(OutputDir)/mscorlib.dll" />
<Copy SourceFiles="../override/mscorlib.xml" DestinationFiles="$(OutputDir)/mscorlib.xml" />
<Copy SourceFiles="$(TargetDir)MONOMODDED_Assembly-CSharp.dll" DestinationFiles="$(OutputDir)/Assembly-CSharp.dll" />
<Copy SourceFiles="$(TargetDir)Assembly-CSharp.mm.xml" DestinationFiles="$(OutputDir)/Assembly-CSharp.xml" />

Expand Down Expand Up @@ -148,7 +154,7 @@
<Reference Include="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<HintPath>..\override\mscorlib.dll</HintPath>
</Reference>
<Reference Include="netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51">
<Reference Include="netstandard, Version=2.1.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51">
<HintPath>../Vanilla/netstandard.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=null">
Expand Down Expand Up @@ -200,5 +206,11 @@
<Reference Include="UnityEngine.UIModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>../Vanilla/UnityEngine.UIModule.dll</HintPath>
</Reference>
<Reference Include="TeamCherry.Localization">
<HintPath>../Vanilla/TeamCherry.Localization.dll</HintPath>
</Reference>
<Reference Include="TeamCherry.TK2D">
<HintPath>../Vanilla/TeamCherry.TK2D.dll</HintPath>
</Reference>
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion Assembly-CSharp/Menu/MenuUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using UnityEngine;
using UnityEngine.UI;
using Patch = Modding.Patches;
using Lang = Language.Language;
using Lang = TeamCherry.Localization.Language;

Check failure on line 11 in Assembly-CSharp/Menu/MenuUtils.cs

View workflow job for this annotation

GitHub Actions / pr-build / build (windows, main)

The type or namespace name 'Localization' does not exist in the namespace 'TeamCherry' (are you missing an assembly reference?)

Check failure on line 11 in Assembly-CSharp/Menu/MenuUtils.cs

View workflow job for this annotation

GitHub Actions / pr-build / build (windows, main)

The type or namespace name 'Localization' does not exist in the namespace 'TeamCherry' (are you missing an assembly reference?)


namespace Modding.Menu
Expand Down
2 changes: 1 addition & 1 deletion Assembly-CSharp/Mod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public virtual void Initialize() { }
/// change the text of the button to jump to this mod's menu.
/// </summary>
/// <returns></returns>
public virtual string GetMenuButtonText() => $"{GetName()} {Language.Language.Get("MAIN_OPTIONS", "MainMenu")}";
public virtual string GetMenuButtonText() => $"{GetName()} {TeamCherry.Localization.Language.Get("MAIN_OPTIONS", "MainMenu")}";

private void HookSaveMethods()
{
Expand Down
27 changes: 22 additions & 5 deletions Assembly-CSharp/ModHooks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using JetBrains.Annotations;
using Modding.Patches;
using MonoMod;
using MonoMod.RuntimeDetour;
using Newtonsoft.Json;
using UnityEngine;
using System.Linq;
Expand Down Expand Up @@ -219,20 +220,36 @@ internal static void LogConsole(string message, LogLevel level)
/// <remarks>N/A</remarks>
public static event LanguageGetProxy LanguageGetHook;

private static Hook _languageGetHook;

internal static void InitLanguageHook()
{
var method = typeof(TeamCherry.Localization.Language).GetMethod(
"Get",
System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static,
null,
new[] { typeof(string), typeof(string) },
null
);
if (method == null) return;
_languageGetHook = new Hook(method,
new Func<Func<string, string, string>, string, string, string>(
(orig, key, sheet) => LanguageGet(key, sheet, orig)
));
}

/// <summary>
/// Called whenever localization specific strings are requested
/// </summary>
/// <remarks>N/A</remarks>
internal static string LanguageGet(string key, string sheet)
internal static string LanguageGet(string key, string sheet, Func<string, string, string> orig)
{
string res = Patches.Language.GetInternal(key, sheet);
string res = orig(key, sheet);

if (LanguageGetHook == null)
return res;

Delegate[] invocationList = LanguageGetHook.GetInvocationList();

foreach (LanguageGetProxy toInvoke in invocationList)
foreach (LanguageGetProxy toInvoke in LanguageGetHook.GetInvocationList())
{
try
{
Expand Down
2 changes: 1 addition & 1 deletion Assembly-CSharp/ModListMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using UnityEngine.UI;
using static Modding.ModLoader;
using Patch = Modding.Patches;
using Lang = Language.Language;
using Lang = TeamCherry.Localization.Language;

Check failure on line 9 in Assembly-CSharp/ModListMenu.cs

View workflow job for this annotation

GitHub Actions / pr-build / build (windows, main)

The type or namespace name 'Localization' does not exist in the namespace 'TeamCherry' (are you missing an assembly reference?)

Check failure on line 9 in Assembly-CSharp/ModListMenu.cs

View workflow job for this annotation

GitHub Actions / pr-build / build (windows, main)

The type or namespace name 'Localization' does not exist in the namespace 'TeamCherry' (are you missing an assembly reference?)

namespace Modding
{
Expand Down
1 change: 1 addition & 0 deletions Assembly-CSharp/ModLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public static IEnumerator LoadModsInit(GameObject coroutineHolder)
}

Logger.APILogger.Log("Starting mod loading");
ModHooks.InitLanguageHook();

string managed_path = SystemInfo.operatingSystemFamily switch
{
Expand Down
Loading
Loading