From d361b0cb6af458387b27705d55f22b3bdfbf7293 Mon Sep 17 00:00:00 2001 From: NSGolova Date: Sat, 28 Sep 2024 21:06:16 +0100 Subject: [PATCH] Fixed song filter characteristic and diff overlap and "Select" button remaining --- Source/2_Core/Installers/OnMenuInstaller.cs | 6 +++- Source/8_UI/BSML Addons/BSMLAddonsLoader.cs | 4 +-- .../LayoutElementExtensionHandler.cs | 22 -------------- .../BeatLeaderMenuButtonManager.cs | 4 +++ .../FiltersMenu/BeatmapCharacteristicPanel.cs | 10 +++---- .../FiltersMenu/BeatmapDifficultyPanel.cs | 13 ++++----- .../BeatmapSelectorViewController.cs | 29 ++++++++++++------- Source/8_UI/Results/ResultsScreenUI.cs | 2 +- 8 files changed, 40 insertions(+), 50 deletions(-) delete mode 100644 Source/8_UI/BSML Addons/TypeHandlers/Extensions/LayoutElementExtensionHandler.cs diff --git a/Source/2_Core/Installers/OnMenuInstaller.cs b/Source/2_Core/Installers/OnMenuInstaller.cs index f95999c6..ccc516a4 100644 --- a/Source/2_Core/Installers/OnMenuInstaller.cs +++ b/Source/2_Core/Installers/OnMenuInstaller.cs @@ -1,9 +1,10 @@ -using BeatLeader.DataManager; +using BeatLeader.DataManager; using BeatLeader.Interop; using BeatLeader.ViewControllers; using BeatLeader.Replayer; using JetBrains.Annotations; using Zenject; +using BeatLeader.Components; namespace BeatLeader.Installers { [UsedImplicitly] @@ -36,6 +37,9 @@ private void BindLeaderboard() { Container.Bind().FromNewComponentOnNewGameObject().AsSingle().NonLazy(); Container.Bind().FromNewComponentOnNewGameObject().AsSingle().NonLazy(); Container.Bind().FromNewComponentAsViewController().AsSingle(); + + _ = BeatmapDifficultyPanel.BeatmapDifficultySegmentedControl; + _ = BeatmapCharacteristicPanel.BeatmapCharacteristicSegmentedControl; } } } \ No newline at end of file diff --git a/Source/8_UI/BSML Addons/BSMLAddonsLoader.cs b/Source/8_UI/BSML Addons/BSMLAddonsLoader.cs index bc8c0276..3baa4b5d 100644 --- a/Source/8_UI/BSML Addons/BSMLAddonsLoader.cs +++ b/Source/8_UI/BSML Addons/BSMLAddonsLoader.cs @@ -45,17 +45,17 @@ internal static class BSMLAddonsLoader { new GenericSettingExtensionHandler(), new GraphicExtensionHandler(), new ImageViewExtensionHandler(), - new LayoutElementExtensionHandler(), new ModalViewExtensionHandler() }; private static bool _ready; public static void LoadAddons() { - if (_ready) return; + if (!_ready) { foreach (var sprite in spritesToCache) BSMLUtility .AddSpriteToBSMLCache("bl-" + sprite.Key, sprite.Value); + } foreach (var tag in addonTags) BSMLParser.Instance.RegisterTag(tag); foreach (var handler in addonHandlers) BSMLParser.Instance.RegisterTypeHandler(handler); _ready = true; diff --git a/Source/8_UI/BSML Addons/TypeHandlers/Extensions/LayoutElementExtensionHandler.cs b/Source/8_UI/BSML Addons/TypeHandlers/Extensions/LayoutElementExtensionHandler.cs deleted file mode 100644 index 76baf725..00000000 --- a/Source/8_UI/BSML Addons/TypeHandlers/Extensions/LayoutElementExtensionHandler.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using System.Collections.Generic; -using BeatSaberMarkupLanguage.TypeHandlers; -using UnityEngine.UI; - -namespace BeatLeader.UI.BSML_Addons.Extensions -{ - [ComponentHandler(typeof(LayoutElement))] - internal class LayoutElementExtensionHandler : TypeHandler - { - public override Dictionary Props => new Dictionary() - { - { "flexibleHeight", new string[] { "flexible-height" } }, - { "flexibleWidth", new string[] { "flexible-width" } }, - }; - public override Dictionary> Setters => new Dictionary> - { - { "flexibleHeight", delegate(LayoutElement el, string str) { el.flexibleHeight = float.Parse(str.Replace('.', ',')); } }, - { "flexibleWidth", delegate(LayoutElement el, string str) { el.flexibleWidth = float.Parse(str.Replace('.', ',')); } }, - }; - } -} diff --git a/Source/8_UI/FlowCoordinator/BeatLeaderMenuButtonManager.cs b/Source/8_UI/FlowCoordinator/BeatLeaderMenuButtonManager.cs index 27c51dcd..f2f66e8f 100644 --- a/Source/8_UI/FlowCoordinator/BeatLeaderMenuButtonManager.cs +++ b/Source/8_UI/FlowCoordinator/BeatLeaderMenuButtonManager.cs @@ -32,6 +32,10 @@ private void Start() { MenuButtonClickedEvent += HandleMenuButtonClicked; } + private void OnDestroy() { + MenuButtonClickedEvent -= HandleMenuButtonClicked; + } + #endregion #region Callbacks diff --git a/Source/8_UI/FlowCoordinator/Components/ReplayLaunchView/SearchFiltersPanel/FiltersMenu/BeatmapCharacteristicPanel.cs b/Source/8_UI/FlowCoordinator/Components/ReplayLaunchView/SearchFiltersPanel/FiltersMenu/BeatmapCharacteristicPanel.cs index fb12a0e3..db472bb5 100644 --- a/Source/8_UI/FlowCoordinator/Components/ReplayLaunchView/SearchFiltersPanel/FiltersMenu/BeatmapCharacteristicPanel.cs +++ b/Source/8_UI/FlowCoordinator/Components/ReplayLaunchView/SearchFiltersPanel/FiltersMenu/BeatmapCharacteristicPanel.cs @@ -12,9 +12,9 @@ namespace BeatLeader.Components { internal class BeatmapCharacteristicPanel : ReeUIComponentV2 { #region Prefab - private static Transform BeatmapCharacteristicSegmentedControl => _beatmapCharacteristicSegmentedControl ? - _beatmapCharacteristicSegmentedControl! : _beatmapCharacteristicSegmentedControl = Resources - .FindObjectsOfTypeAll().First().transform.parent; + public static Transform BeatmapCharacteristicSegmentedControl => _beatmapCharacteristicSegmentedControl ? + _beatmapCharacteristicSegmentedControl! : _beatmapCharacteristicSegmentedControl = Instantiate(Resources + .FindObjectsOfTypeAll().First().transform.parent); private static Transform? _beatmapCharacteristicSegmentedControl; @@ -88,8 +88,8 @@ public void SetData(IEnumerable? beatmapCharacteristics private List? _beatmapCharacteristics; protected override void OnInitialize() { - var characteristicPanel = Instantiate( - BeatmapCharacteristicSegmentedControl, _container, true); + var characteristicPanel = BeatmapCharacteristicSegmentedControl; + characteristicPanel.SetParent(_container, true); characteristicPanel.localScale = Vector3.one; characteristicPanel.localPosition = Vector3.zero; characteristicPanel diff --git a/Source/8_UI/FlowCoordinator/Components/ReplayLaunchView/SearchFiltersPanel/FiltersMenu/BeatmapDifficultyPanel.cs b/Source/8_UI/FlowCoordinator/Components/ReplayLaunchView/SearchFiltersPanel/FiltersMenu/BeatmapDifficultyPanel.cs index 6f884629..3f4f6d35 100644 --- a/Source/8_UI/FlowCoordinator/Components/ReplayLaunchView/SearchFiltersPanel/FiltersMenu/BeatmapDifficultyPanel.cs +++ b/Source/8_UI/FlowCoordinator/Components/ReplayLaunchView/SearchFiltersPanel/FiltersMenu/BeatmapDifficultyPanel.cs @@ -12,9 +12,9 @@ namespace BeatLeader.Components { internal class BeatmapDifficultyPanel : ReeUIComponentV2 { #region Prefab - private static Transform BeatmapDifficultySegmentedControl => _beatmapDifficultySegmentedControl ? - _beatmapDifficultySegmentedControl! : _beatmapDifficultySegmentedControl = Resources - .FindObjectsOfTypeAll().First().transform.parent; + public static Transform BeatmapDifficultySegmentedControl => _beatmapDifficultySegmentedControl ? + _beatmapDifficultySegmentedControl! : _beatmapDifficultySegmentedControl = Instantiate(Resources + .FindObjectsOfTypeAll().First().transform.parent); private static Transform? _beatmapDifficultySegmentedControl; @@ -88,11 +88,8 @@ public void SetData(IReadOnlyList? difficulties) { #region Init protected override void OnInitialize() { - var characteristicPanel = Instantiate( - BeatmapDifficultySegmentedControl, - _container, - true - ); + var characteristicPanel = BeatmapDifficultySegmentedControl; + characteristicPanel.SetParent(_container, true); characteristicPanel.localScale = Vector3.one; characteristicPanel.localPosition = Vector3.zero; characteristicPanel diff --git a/Source/8_UI/FlowCoordinator/Components/ReplayLaunchView/SearchFiltersPanel/FiltersMenu/BeatmapSelector/BeatmapSelectorViewController.cs b/Source/8_UI/FlowCoordinator/Components/ReplayLaunchView/SearchFiltersPanel/FiltersMenu/BeatmapSelector/BeatmapSelectorViewController.cs index ebaee55b..dca3a6df 100644 --- a/Source/8_UI/FlowCoordinator/Components/ReplayLaunchView/SearchFiltersPanel/FiltersMenu/BeatmapSelector/BeatmapSelectorViewController.cs +++ b/Source/8_UI/FlowCoordinator/Components/ReplayLaunchView/SearchFiltersPanel/FiltersMenu/BeatmapSelector/BeatmapSelectorViewController.cs @@ -1,4 +1,5 @@ using System; +using BGLib.Polyglot; using HMUI; using IPA.Utilities; using UnityEngine; @@ -33,6 +34,7 @@ internal class BeatmapSelectorViewController : DummyViewController { private SelectLevelCategoryViewController.LevelCategory _lastSelectedLevelCategory = SelectLevelCategoryViewController.LevelCategory.All; private BeatmapLevel? _originalPreviewBeatmapLevel; private bool _isInitialized; + private string _defaultPlayButtonText = Localization.Get("BUTTON_PLAY"); public void Init( LevelSelectionNavigationController levelSelectionNavigationController, @@ -66,23 +68,27 @@ public override void OnDestroy() { public override void DidActivate(bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling) { if (!_isInitialized) throw new UninitializedComponentException(); if (firstActivation) { - _levelSelectionNavigationController.Setup( - SongPackMask.all, - BeatmapDifficultyMask.All, - Array.Empty(), - false, - false, - "SELECT", - null, - SelectLevelCategoryViewController.LevelCategory.None, - null, - true); + if (_levelSelectionNavigationController._actionButtonText == null) { + _levelSelectionNavigationController.Setup( + SongPackMask.all, + BeatmapDifficultyMask.All, + Array.Empty(), + false, + false, + "SELECT", + null, + SelectLevelCategoryViewController.LevelCategory.None, + null, + true); + } _levelDetailWrapper = ReeUIComponentV2.Instantiate(_levelDetail.parent); _levelDetailWrapper.SelectButtonPressedEvent += HandleSelectButtonPressed; _closeButton = ReeUIComponentV2.Instantiate(_levelFilteringNavigationController.transform); _closeButton.ManualInit(_closeButton.transform); _closeButton.ButtonPressedEvent += HandleCloseButtonPressed; } + _levelSelectionNavigationController._actionButtonText = "SELECT"; + _originalLevelCategory = _levelSelectionNavigationController.selectedLevelCategory; _originalPreviewBeatmapLevel = _levelCollectionNavigationController.beatmapLevel; SetLevelDetailWrapperEnabled(true); @@ -93,6 +99,7 @@ public override void DidActivate(bool firstActivation, bool addedToHierarchy, bo } public override void DidDeactivate(bool removedFromHierarchy, bool screenSystemDisabling) { + _levelSelectionNavigationController._actionButtonText = _defaultPlayButtonText; SetLevelDetailWrapperEnabled(false); SetCloseButtonEnabled(false); _lastSelectedLevelCategory = _levelSelectionNavigationController.selectedLevelCategory; diff --git a/Source/8_UI/Results/ResultsScreenUI.cs b/Source/8_UI/Results/ResultsScreenUI.cs index 2cce6b4b..206f31a4 100644 --- a/Source/8_UI/Results/ResultsScreenUI.cs +++ b/Source/8_UI/Results/ResultsScreenUI.cs @@ -22,7 +22,7 @@ private void Awake() { LeaderboardEvents.VotingWasPressedEvent += PresentVotingModal; } - protected override void OnDispose() { + protected override void OnDestroy() { _replayButton.ReplayButtonClickedEvent -= HandleReplayButtonClicked; LeaderboardEvents.VotingWasPressedEvent -= PresentVotingModal; }