From 9fc4c865a9423d2fd05986b0c1ffbfed484747cc Mon Sep 17 00:00:00 2001 From: Halsafar <421822+halsafar@users.noreply.github.com> Date: Wed, 10 Mar 2021 09:17:04 -0600 Subject: [PATCH] V1.13.4 fixes (#144) Fixes for BeatSaber v1.13.4 --- BeatModsReleaseTemplate.txt | 4 +- .../UI/Browser/BeatSaberUIController.cs | 7 +- SongBrowserPlugin/UI/ProgressBar.cs | 119 ++++++++++++------ SongBrowserPlugin/manifest.json | 10 +- 4 files changed, 90 insertions(+), 50 deletions(-) diff --git a/BeatModsReleaseTemplate.txt b/BeatModsReleaseTemplate.txt index 04b70e4..d2465da 100644 --- a/BeatModsReleaseTemplate.txt +++ b/BeatModsReleaseTemplate.txt @@ -1,8 +1,8 @@ SongBrowser -6.1.4 +6.1.5 -SongCore@3.0.0,SongDataCore@1.3.5 +SongCore@3.2.0,SongDataCore@1.3.7 Adds various sorting and filtering methods to the UI. Search, favorites, ranked, and unranked filters. Sort by BeatSaver and ScoreSaber statistics. Adds PP and other extra stats to the stat panel. diff --git a/SongBrowserPlugin/UI/Browser/BeatSaberUIController.cs b/SongBrowserPlugin/UI/Browser/BeatSaberUIController.cs index 413c642..3386f73 100644 --- a/SongBrowserPlugin/UI/Browser/BeatSaberUIController.cs +++ b/SongBrowserPlugin/UI/Browser/BeatSaberUIController.cs @@ -93,8 +93,9 @@ public BeatSaberUIController(LevelSelectionFlowCoordinator flowCoordinator) Logger.Debug("Acquired AnnotatedBeatmapLevelCollectionsViewController from LevelFilteringNavigationController [{0}]", AnnotatedBeatmapLevelCollectionsViewController.GetInstanceID()); TableView tableView = LevelCollectionTableView.GetField("_tableView"); - TableViewPageUpButton = tableView.GetField("_pageUpButton"); - TableViewPageDownButton = tableView.GetField("_pageDownButton"); + ScrollView scrollView = tableView.GetField("_scrollView"); + TableViewPageUpButton = scrollView.GetField("_pageUpButton"); + TableViewPageDownButton = scrollView.GetField("_pageDownButton"); Logger.Debug("Acquired Page Up and Down buttons..."); ActionButtons = StandardLevelDetailView.GetComponentsInChildren().First(x => x.name == "ActionButtons"); @@ -362,7 +363,7 @@ public void ScrollToLevelByRow(int selectedIndex) { LevelCollectionTableView.HandleDidSelectRowEvent(tableView, selectedIndex); } - tableView.ScrollToCellWithIdx(selectedIndex, TableViewScroller.ScrollPositionType.Beginning, true); + tableView.ScrollToCellWithIdx(selectedIndex, TableView.ScrollPositionType.Beginning, true); tableView.SelectCellWithIdx(selectedIndex); } diff --git a/SongBrowserPlugin/UI/ProgressBar.cs b/SongBrowserPlugin/UI/ProgressBar.cs index 8725294..3df3f52 100644 --- a/SongBrowserPlugin/UI/ProgressBar.cs +++ b/SongBrowserPlugin/UI/ProgressBar.cs @@ -1,11 +1,11 @@ -using System.Collections; +using SongCore.Utilities; +using System.Collections; using System.Collections.Concurrent; -using HMUI; -using SongBrowser.Internals; using TMPro; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UI; +using SongCore; namespace SongBrowser.UI { @@ -19,8 +19,9 @@ public class ProgressBar : MonoBehaviour private TMP_Text _pluginNameText; private TMP_Text _headerText; internal Image _loadingBackg; + internal Image _loadingBar; - private static readonly Vector3 Position = new Vector3(0, 0.0f, 2.6f); + private static readonly Vector3 Position = new Vector3(0, 0, 2.5f); private static readonly Vector3 Rotation = Vector3.zero; private static readonly Vector3 Scale = new Vector3(0.01f, 0.01f, 0.01f); @@ -30,7 +31,7 @@ public class ProgressBar : MonoBehaviour private const float AuthorNameFontSize = 7f; private static readonly Vector2 AuthorNamePosition = new Vector2(10, 31); - private string PluginNameText => $"Song Browser - v{Plugin.VersionNumber}"; + private string PluginNameText = $"Song Browser - v{Plugin.VersionNumber}"; private const float PluginNameFontSize = 9f; private static readonly Vector2 PluginNamePosition = new Vector2(10, 23); @@ -54,8 +55,9 @@ public void ShowMessage(string message, float time) StopAllCoroutines(); _showingMessage = true; _headerText.text = message; + _loadingBar.enabled = false; _loadingBackg.enabled = false; - gameObject.SetActive(true); + _canvas.enabled = true; StartCoroutine(DisableCanvasRoutine(time)); } @@ -64,8 +66,9 @@ public void ShowMessage(string message) StopAllCoroutines(); _showingMessage = true; _headerText.text = message; + _loadingBar.enabled = false; _loadingBackg.enabled = false; - gameObject.SetActive(true); + _canvas.enabled = true; } private void OnEnable() @@ -77,7 +80,7 @@ private void OnEnable() private void OnDisable() { SceneManager.activeSceneChanged -= SceneManagerOnActiveSceneChanged; - SongBrowserModel.didFinishProcessingSongs -= SongBrowserFinishedProcessingSongs; + SongBrowserModel.didFinishProcessingSongs -= SongBrowserFinishedProcessingSongs; } private void SceneManagerOnActiveSceneChanged(Scene oldScene, Scene newScene) @@ -86,68 +89,104 @@ private void SceneManagerOnActiveSceneChanged(Scene oldScene, Scene newScene) { if (_showingMessage) { - gameObject.SetActive(true); + _canvas.enabled = true; } } else { - gameObject.SetActive(false); + _canvas.enabled = false; } } - private void SongBrowserFinishedProcessingSongs(ConcurrentDictionary arg2) + private void SongLoaderOnLoadingStartedEvent(Loader obj) { StopAllCoroutines(); _showingMessage = false; - _headerText.text = arg2.Count + " songs processed"; + _headerText.text = HeaderText; + _loadingBar.enabled = true; + _loadingBackg.enabled = true; + _canvas.enabled = true; + } + + private void SongBrowserFinishedProcessingSongs(ConcurrentDictionary customLevels) + { + _showingMessage = false; + _headerText.text = customLevels.Count + " songs processed."; + _loadingBar.enabled = false; _loadingBackg.enabled = false; - StartCoroutine(DisableCanvasRoutine(20f)); + StartCoroutine(DisableCanvasRoutine(7f)); } private IEnumerator DisableCanvasRoutine(float time) { yield return new WaitForSecondsRealtime(time); + _canvas.enabled = false; _showingMessage = false; - gameObject.SetActive(false); } private void Awake() { + gameObject.transform.position = Position; + gameObject.transform.eulerAngles = Rotation; + gameObject.transform.localScale = Scale; + _canvas = gameObject.AddComponent(); _canvas.renderMode = RenderMode.WorldSpace; - - gameObject.AddComponent().SetRadius(0f); - - var ct = _canvas.transform; - ct.position = Position; - ct.localScale = Scale; - - if (ct is RectTransform crt) - { - crt.sizeDelta = CanvasSize; - - _authorNameText = BeatSaberUI.CreateText(crt, AuthorNameText, AuthorNameFontSize, AuthorNamePosition, HeaderSize); - - _pluginNameText = BeatSaberUI.CreateText(crt, PluginNameText, PluginNameFontSize, PluginNamePosition, HeaderSize); - - _headerText = BeatSaberUI.CreateText(crt, HeaderText, HeaderFontSize, HeaderPosition, HeaderSize); - } - - _loadingBackg = new GameObject("Background").AddComponent(); - if (_loadingBackg.transform is RectTransform lbrt) - { - lbrt.SetParent(_canvas.transform, false); - lbrt.sizeDelta = LoadingBarSize; - } - + _canvas.enabled = false; + var rectTransform = _canvas.transform as RectTransform; + rectTransform.sizeDelta = CanvasSize; + + _authorNameText = BeatSaberMarkupLanguage.BeatSaberUI.CreateText(_canvas.transform as RectTransform, AuthorNameText, AuthorNamePosition); + rectTransform = _authorNameText.transform as RectTransform; + rectTransform.SetParent(_canvas.transform, false); + rectTransform.anchoredPosition = AuthorNamePosition; + rectTransform.sizeDelta = HeaderSize; + _authorNameText.text = AuthorNameText; + _authorNameText.fontSize = AuthorNameFontSize; + + _pluginNameText = BeatSaberMarkupLanguage.BeatSaberUI.CreateText(_canvas.transform as RectTransform, PluginNameText, PluginNamePosition); + rectTransform = _pluginNameText.transform as RectTransform; + rectTransform.SetParent(_canvas.transform, false); + rectTransform.sizeDelta = HeaderSize; + rectTransform.anchoredPosition = PluginNamePosition; + _pluginNameText.text = PluginNameText; + _pluginNameText.fontSize = PluginNameFontSize; + + _headerText = BeatSaberMarkupLanguage.BeatSaberUI.CreateText(_canvas.transform as RectTransform, HeaderText, HeaderPosition); + rectTransform = _headerText.transform as RectTransform; + rectTransform.SetParent(_canvas.transform, false); + rectTransform.anchoredPosition = HeaderPosition; + rectTransform.sizeDelta = HeaderSize; + _headerText.text = HeaderText; + _headerText.fontSize = HeaderFontSize; + + _loadingBackg = new GameObject("Background").AddComponent(); + rectTransform = _loadingBackg.transform as RectTransform; + rectTransform.SetParent(_canvas.transform, false); + rectTransform.sizeDelta = LoadingBarSize; _loadingBackg.color = BackgroundColor; - gameObject.SetActive(false); + _loadingBar = new GameObject("Loading Bar").AddComponent(); + rectTransform = _loadingBar.transform as RectTransform; + rectTransform.SetParent(_canvas.transform, false); + rectTransform.sizeDelta = LoadingBarSize; + var tex = Texture2D.whiteTexture; + var sprite = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), Vector2.one * 0.5f, 100, 1); + _loadingBar.sprite = sprite; + _loadingBar.type = Image.Type.Filled; + _loadingBar.fillMethod = Image.FillMethod.Horizontal; + _loadingBar.color = new Color(1, 1, 1, 0.5f); + + DontDestroyOnLoad(gameObject); } private void Update() { if (!_canvas.enabled) return; + _loadingBar.fillAmount = Loader.LoadingProgress; + + _loadingBar.color = HSBColor.ToColor(new HSBColor(Mathf.PingPong(Time.time * 0.35f, 1), 1, 1)); + _headerText.color = HSBColor.ToColor(new HSBColor(Mathf.PingPong(Time.time * 0.35f, 1), 1, 1)); } } } diff --git a/SongBrowserPlugin/manifest.json b/SongBrowserPlugin/manifest.json index 1377dff..58bac68 100644 --- a/SongBrowserPlugin/manifest.json +++ b/SongBrowserPlugin/manifest.json @@ -2,15 +2,15 @@ "$schema": "https://raw.githubusercontent.com/bsmg/BSIPA-MetadataFileSchema/master/Schema.json", "author": "Halsafar", "description": "Adds sort and filter features to the level selection UI.", - "gameVersion": "1.13.2", + "gameVersion": "1.13.4", "id": "SongBrowser", "name": "Song Browser", - "version": "6.1.4", + "version": "6.1.5", "dependsOn": { - "SongCore": "^3.0.0", - "SongDataCore": "^1.3.5", + "SongCore": "^3.2.0", + "SongDataCore": "^1.3.7", "BSIPA": "^4.1.3", - "BeatSaberMarkupLanguage": "^1.4.5" + "BeatSaberMarkupLanguage": "^1.5.1" }, "misc": { "plugin-hint": "SongBrowser.Plugin"