Skip to content

Commit

Permalink
V1.13.4 fixes (#144)
Browse files Browse the repository at this point in the history
Fixes for BeatSaber v1.13.4
  • Loading branch information
halsafar authored Mar 10, 2021
1 parent 0bf8a2f commit 9fc4c86
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 50 deletions.
4 changes: 2 additions & 2 deletions BeatModsReleaseTemplate.txt
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
7 changes: 4 additions & 3 deletions SongBrowserPlugin/UI/Browser/BeatSaberUIController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,9 @@ public BeatSaberUIController(LevelSelectionFlowCoordinator flowCoordinator)
Logger.Debug("Acquired AnnotatedBeatmapLevelCollectionsViewController from LevelFilteringNavigationController [{0}]", AnnotatedBeatmapLevelCollectionsViewController.GetInstanceID());

TableView tableView = LevelCollectionTableView.GetField<TableView, LevelCollectionTableView>("_tableView");
TableViewPageUpButton = tableView.GetField<Button, TableView>("_pageUpButton");
TableViewPageDownButton = tableView.GetField<Button, TableView>("_pageDownButton");
ScrollView scrollView = tableView.GetField<ScrollView, TableView>("_scrollView");
TableViewPageUpButton = scrollView.GetField<Button, ScrollView>("_pageUpButton");
TableViewPageDownButton = scrollView.GetField<Button, ScrollView>("_pageDownButton");
Logger.Debug("Acquired Page Up and Down buttons...");

ActionButtons = StandardLevelDetailView.GetComponentsInChildren<RectTransform>().First(x => x.name == "ActionButtons");
Expand Down Expand Up @@ -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);
}

Expand Down
119 changes: 79 additions & 40 deletions SongBrowserPlugin/UI/ProgressBar.cs
Original file line number Diff line number Diff line change
@@ -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
{
Expand All @@ -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);

Expand All @@ -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<size=100%>{Plugin.VersionNumber}</size>";
private string PluginNameText = $"Song Browser - v<size=100%>{Plugin.VersionNumber}</size>";
private const float PluginNameFontSize = 9f;
private static readonly Vector2 PluginNamePosition = new Vector2(10, 23);

Expand All @@ -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));
}

Expand All @@ -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()
Expand All @@ -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)
Expand All @@ -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<string, CustomPreviewBeatmapLevel> 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<string, CustomPreviewBeatmapLevel> 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>();
_canvas.renderMode = RenderMode.WorldSpace;

gameObject.AddComponent<CurvedCanvasSettings>().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<ImageView>();
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<Image>();
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<Image>();
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));
}
}
}
10 changes: 5 additions & 5 deletions SongBrowserPlugin/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 9fc4c86

Please sign in to comment.