Skip to content

Commit

Permalink
Fixed BSML Parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
Loloppe committed Sep 14, 2024
1 parent b9bcb07 commit 59e8eb6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
8 changes: 5 additions & 3 deletions Source/7_Utils/BSMLUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using UnityEngine;
using BeatSaberMarkupLanguage.Attributes;
using System.Reflection;
using System.Threading.Tasks;

namespace BeatLeader.Utils {
public static class BSMLUtility {
Expand All @@ -14,10 +15,11 @@ public static Sprite LoadSprite(string location) {
if (location.Length > 1 && location.StartsWith("#")) {
string text = location.Substring(1);
sprite = FindSpriteCached(text);
} else Utilities.GetData(location, (byte[] data) => {
sprite = Utilities.LoadSpriteRaw(data);
} else {
var task = Task.Run(async () => await Utilities.LoadSpriteFromAssemblyAsync(location));
sprite = task.GetAwaiter().GetResult();
sprite.texture.wrapMode = TextureWrapMode.Clamp;
});
}

if (sprite == null) {
throw new Exception($"Can not find sprite located at [{location}]!");
Expand Down
3 changes: 2 additions & 1 deletion Source/8_UI/ReeUIComponentV2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,9 @@ private void DisposeIfNeeded() {
_state = State.Uninitialized;
}

private void ParseSelfIfNeeded() {
private async void ParseSelfIfNeeded() {
if (_state != State.Uninitialized) return;
await MainMenuAwaiter.WaitForMainMenuAsync();
_state = State.Parsing;
BSMLParser.Instance.Parse(GetBsmlForType(GetType()), gameObject, ParseHost);
Content = Transform.GetChild(0);
Expand Down
9 changes: 6 additions & 3 deletions Source/Plugin.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
using BeatLeader.DataManager;
using BeatLeader.UI.BSML_Addons;
using BeatLeader.Utils;
using BeatSaberMarkupLanguage.Util;
using Hive.Versioning;
using IPA;
using IPA.Config;
using IPA.Config.Stores;
using IPA.Loader;
using JetBrains.Annotations;
using UnityEngine;
using IPALogger = IPA.Logging.Logger;

namespace BeatLeader {
Expand Down Expand Up @@ -53,11 +53,14 @@ private static void InitializeConfig(Config config) {
[UsedImplicitly]
public void OnApplicationStart() {
ObserveEnabled();
SettingsPanelUI.AddTab();
BSMLAddonsLoader.LoadAddons();
MainMenuAwaiter.MainMenuInitializing += MainMenuInit;
InteropLoader.Init();
}

public static void MainMenuInit() {
SettingsPanelUI.AddTab();
BSMLAddonsLoader.LoadAddons();
}
private static void ObserveEnabled() {
PluginConfig.OnEnabledChangedEvent += OnEnabledChanged;
OnEnabledChanged(PluginConfig.Enabled);
Expand Down

0 comments on commit 59e8eb6

Please sign in to comment.