-
-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
35 changed files
with
248 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
using System; | ||
using Polyglot; | ||
using BGLib.Polyglot; | ||
|
||
namespace BeatSaberMarkupLanguage.Components.Settings | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
BeatSaberMarkupLanguage/Harmony Patches/FontAssetDefaultValueSetters.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System.Linq; | ||
using HarmonyLib; | ||
using TMPro; | ||
using UnityEngine; | ||
|
||
namespace BeatSaberMarkupLanguage.Harmony_Patches | ||
{ | ||
[HarmonyPatch(typeof(ShaderUtilities), nameof(ShaderUtilities.ShaderRef_MobileSDF), MethodType.Getter)] | ||
internal static class ShaderUtilities_ShaderRef_MobileSDF | ||
{ | ||
public static bool Prefix(ref Shader __result) | ||
{ | ||
if (ShaderUtilities.k_ShaderRef_MobileSDF == null) | ||
{ | ||
ShaderUtilities.k_ShaderRef_MobileSDF = Resources.FindObjectsOfTypeAll<Shader>().First(s => s.name == "TextMeshPro/Mobile/Distance Field"); | ||
} | ||
|
||
__result = ShaderUtilities.k_ShaderRef_MobileSDF; | ||
|
||
return false; | ||
} | ||
} | ||
|
||
[HarmonyPatch(typeof(TMP_Settings), nameof(TMP_Settings.instance), MethodType.Getter)] | ||
internal static class TMP_Settings_GetFontAsset | ||
{ | ||
public static void Postfix() | ||
{ | ||
if (TMP_Settings.s_Instance.m_defaultFontAsset == null) | ||
{ | ||
TMP_Settings.s_Instance.m_defaultFontAsset = Resources.FindObjectsOfTypeAll<TMP_FontAsset>().First(f => f.name == "Teko-Medium SDF"); | ||
} | ||
} | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
BeatSaberMarkupLanguage/Harmony Patches/LocalizationLoader.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Reflection; | ||
using BGLib.Polyglot; | ||
using HarmonyLib; | ||
using UnityEngine; | ||
|
||
namespace BeatSaberMarkupLanguage.Harmony_Patches | ||
{ | ||
[HarmonyPatch(typeof(LocalizationAsyncInstaller), "LoadResourcesBeforeInstall")] | ||
internal class LocalizationLoader | ||
{ | ||
public static void Prefix(IList<TextAsset> assets) | ||
{ | ||
using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("BeatSaberMarkupLanguage.Resources.beat-saber-markup-language.csv")) | ||
using (StreamReader reader = new(stream)) | ||
{ | ||
string content = reader.ReadToEnd(); | ||
assets.Add(new TextAsset(content)); | ||
} | ||
} | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
BeatSaberMarkupLanguage/Harmony Patches/LocalizationModelSilencer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Reflection; | ||
using System.Reflection.Emit; | ||
using BGLib.Polyglot; | ||
using HarmonyLib; | ||
using UnityEngine; | ||
|
||
namespace BeatSaberMarkupLanguage.Harmony_Patches | ||
{ | ||
[HarmonyPatch(typeof(LocalizationModel))] | ||
internal static class LocalizationModelSilencer | ||
{ | ||
private static readonly MethodInfo UnityDebugLogWarning = AccessTools.DeclaredMethod(typeof(Debug), nameof(Debug.LogWarning), new Type[] { typeof(object) }); | ||
|
||
[HarmonyPatch(nameof(LocalizationModel.Get))] | ||
[HarmonyPatch(nameof(LocalizationModel.TryGet))] | ||
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) | ||
{ | ||
foreach (CodeInstruction instruction in instructions) | ||
{ | ||
if (instruction.Calls(UnityDebugLogWarning)) | ||
{ | ||
yield return new CodeInstruction(OpCodes.Pop); | ||
} | ||
else | ||
{ | ||
yield return instruction; | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
BeatSaberMarkupLanguage/Harmony Patches/MainSystemInitAwaiter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System.Threading.Tasks; | ||
using BeatSaberMarkupLanguage.Util; | ||
using HarmonyLib; | ||
|
||
namespace BeatSaberMarkupLanguage.Harmony_Patches | ||
{ | ||
[HarmonyPatch] | ||
internal static class MainSystemInitAwaiter | ||
{ | ||
private static TaskCompletionSource<VoidResult> taskCompletionSource = new(); | ||
|
||
public static Task WaitForMainSystemInitAsync() => taskCompletionSource.Task; | ||
|
||
[HarmonyPatch(typeof(MainSystemInit), nameof(MainSystemInit.Init))] | ||
[HarmonyPostfix] | ||
private static void OnInit() | ||
{ | ||
taskCompletionSource.SetResult(default); | ||
} | ||
|
||
[HarmonyPatch(typeof(AppInit), "OnDestroy")] | ||
[HarmonyPostfix] | ||
private static void OnDestroy() | ||
{ | ||
taskCompletionSource = new(); | ||
} | ||
} | ||
} |
Oops, something went wrong.