Skip to content

Commit

Permalink
Update for Beat Saber 1.34.5
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoco007 committed Feb 13, 2024
1 parent 0762d40 commit 16306f9
Show file tree
Hide file tree
Showing 35 changed files with 248 additions and 110 deletions.
91 changes: 49 additions & 42 deletions BeatSaberMarkupLanguage/BeatSaberMarkupLanguage.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,98 +13,105 @@
</PropertyGroup>

<ItemGroup>
<Reference Include="UnityEngine">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.dll</HintPath>
<Reference Include="0Harmony">
<HintPath>$(BeatSaberDir)\Libs\0Harmony.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
<Reference Include="BGLib.AppFlow">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\BGLib.AppFlow.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.ImageConversionModule">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.ImageConversionModule.dll</HintPath>
<Reference Include="BGLib.Polyglot">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\BGLib.Polyglot.dll</HintPath>
<Private>False</Private>
<Publicize>True</Publicize>
</Reference>
<Reference Include="UnityEngine.InputLegacyModule">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.InputLegacyModule.dll</HintPath>
<Reference Include="GameplayCore">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\GameplayCore.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.PhysicsModule">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.PhysicsModule.dll</HintPath>
<Reference Include="HMLib">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\HMLib.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.TextCoreFontEngineModule">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.TextCoreFontEngineModule.dll</HintPath>
<Reference Include="HMUI">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\HMUI.dll</HintPath>
<Private>False</Private>
<Publicize>True</Publicize>
</Reference>
<Reference Include="UnityEngine.TextRenderingModule">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.TextRenderingModule.dll</HintPath>
<Reference Include="IPA.Loader">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\IPA.Loader.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.UI">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.UI.dll</HintPath>
<Reference Include="Main">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\Main.dll</HintPath>
<Private>False</Private>
<Publicize>True</Publicize>
</Reference>
<Reference Include="UnityEngine.UIModule">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.UIModule.dll</HintPath>
<Reference Include="Menu.ColorSettings">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\Menu.ColorSettings.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.UnityWebRequestModule">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.UnityWebRequestModule.dll</HintPath>
<Reference Include="Menu.CommonLib">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\Menu.CommonLib.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>$(BeatSaberDir)\Libs\Newtonsoft.Json.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Unity.TextMeshPro">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\Unity.TextMeshPro.dll</HintPath>
<Private>False</Private>
<Publicize>True</Publicize>
</Reference>
<Reference Include="Main">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\Main.dll</HintPath>
<Reference Include="UnityEngine">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.dll</HintPath>
<Private>False</Private>
<Publicize>True</Publicize>
</Reference>
<Reference Include="GameplayCore">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\GameplayCore.dll</HintPath>
<Reference Include="UnityEngine.CoreModule">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="HMLib">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\HMLib.dll</HintPath>
<Reference Include="UnityEngine.ImageConversionModule">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.ImageConversionModule.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="HMUI">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\HMUI.dll</HintPath>
<Reference Include="UnityEngine.InputLegacyModule">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.InputLegacyModule.dll</HintPath>
<Private>False</Private>
<Publicize>True</Publicize>
</Reference>
<Reference Include="Menu.ColorSettings">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\Menu.ColorSettings.dll</HintPath>
<Reference Include="UnityEngine.PhysicsModule">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.PhysicsModule.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Menu.CommonLib">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\Menu.CommonLib.dll</HintPath>
<Reference Include="UnityEngine.TextCoreFontEngineModule">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.TextCoreFontEngineModule.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Polyglot">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\Polyglot.dll</HintPath>
<Reference Include="UnityEngine.TextRenderingModule">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.TextRenderingModule.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="VRUI">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\VRUI.dll</HintPath>
<Reference Include="UnityEngine.UI">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.UI.dll</HintPath>
<Private>False</Private>
<Publicize>True</Publicize>
</Reference>
<Reference Include="IPA.Loader">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\IPA.Loader.dll</HintPath>
<Reference Include="UnityEngine.UIModule">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.UIModule.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="0Harmony">
<HintPath>$(BeatSaberDir)\Libs\0Harmony.dll</HintPath>
<Reference Include="UnityEngine.UnityWebRequestModule">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.UnityWebRequestModule.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>$(BeatSaberDir)\Libs\Newtonsoft.Json.dll</HintPath>
<Reference Include="VRUI">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\VRUI.dll</HintPath>
<Private>False</Private>
<Publicize>True</Publicize>
</Reference>
<Reference Include="Zenject">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\Zenject.dll</HintPath>
Expand Down
3 changes: 2 additions & 1 deletion BeatSaberMarkupLanguage/BeatSaberUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Linq;
using System.Threading.Tasks;
using BeatSaberMarkupLanguage.Animations;
using BGLib.Polyglot;
using HMUI;
using IPA.Utilities.Async;
using TMPro;
Expand Down Expand Up @@ -275,7 +276,7 @@ public static T CreateText<T>(RectTransform parent, string text, Vector2 anchore

public static void SetButtonText(this Button button, string text)
{
Polyglot.LocalizedTextMeshProUGUI localizer = button.GetComponentInChildren<Polyglot.LocalizedTextMeshProUGUI>(true);
LocalizedTextMeshProUGUI localizer = button.GetComponentInChildren<LocalizedTextMeshProUGUI>(true);
if (localizer != null)
{
Object.Destroy(localizer);
Expand Down
7 changes: 7 additions & 0 deletions BeatSaberMarkupLanguage/Components/CustomListTableData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,13 @@ public int NumberOfCells()
return data.Count();
}

private void OnDestroy()
{
Destroy(songListTableCellInstance);
Destroy(levelPackTableCellInstance);
Destroy(simpleTextTableCellInstance);
}

public class CustomCellInfo
{
public string text;
Expand Down
14 changes: 0 additions & 14 deletions BeatSaberMarkupLanguage/Components/LocalizableText.cs

This file was deleted.

3 changes: 2 additions & 1 deletion BeatSaberMarkupLanguage/Components/ModalKeyboard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using BeatSaberMarkupLanguage.Parser;
using BGLib.Polyglot;
using HMUI;
using TMPro;
using UnityEngine;
Expand Down Expand Up @@ -569,7 +570,7 @@ public KEY(KEYBOARD kb, Vector2 position, string text, float width, float height
highlightedColors[i] = new Color(0.1f, 1, 0.1f, graphicColor.a);
}

Polyglot.LocalizedTextMeshProUGUI localizer = mybutton.GetComponentInChildren<Polyglot.LocalizedTextMeshProUGUI>(true);
LocalizedTextMeshProUGUI localizer = mybutton.GetComponentInChildren<LocalizedTextMeshProUGUI>(true);
if (localizer != null)
{
Object.Destroy(localizer);
Expand Down
2 changes: 1 addition & 1 deletion BeatSaberMarkupLanguage/Components/Settings/BoolSetting.cs
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
{
Expand Down
2 changes: 1 addition & 1 deletion BeatSaberMarkupLanguage/Components/TabSelector.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System.Collections.Generic;
using System.Linq;
using BeatSaberMarkupLanguage.Parser;
using BGLib.Polyglot;
using HMUI;
using Polyglot;
using UnityEngine;
using UnityEngine.UI;

Expand Down
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 BeatSaberMarkupLanguage/Harmony Patches/LocalizationLoader.cs
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));
}
}
}
}
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;
}
}
}
}
}
3 changes: 2 additions & 1 deletion BeatSaberMarkupLanguage/Harmony Patches/MainMenuInstaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using BeatSaberMarkupLanguage.Animations;
using BeatSaberMarkupLanguage.MenuButtons;
using BeatSaberMarkupLanguage.Settings;
using BeatSaberMarkupLanguage.Util;
using HarmonyLib;
using Zenject;

Expand Down Expand Up @@ -44,7 +45,7 @@ private static void Prefix(MainSettingsMenuViewControllersInstaller __instance)
container.Bind(typeof(IInitializable), typeof(IDisposable)).To<MenuInitAwaiter>().AsSingle();

#if DEBUG
container.Bind(typeof(IInitializable)).To<Util.TestPresenter>().AsSingle();
container.Bind(typeof(IInitializable)).To<TestPresenter>().AsSingle();
#endif
}
}
Expand Down
28 changes: 28 additions & 0 deletions BeatSaberMarkupLanguage/Harmony Patches/MainSystemInitAwaiter.cs
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();
}
}
}
Loading

0 comments on commit 16306f9

Please sign in to comment.