From 514ddbfd96107981438d53532c9d65e4601ab4dd Mon Sep 17 00:00:00 2001 From: LA <1245661240@qq.com> Date: Thu, 5 Mar 2026 21:15:17 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=B4=E6=8A=A4=E4=BB=A3=E7=A0=81=E3=80=81?= =?UTF-8?q?=E6=9C=AC=E5=9C=B0=E5=8C=96=EF=BC=9B=E5=90=88=E5=B9=B6=E6=97=B6?= =?UTF-8?q?=E7=9A=84=E9=81=97=E7=95=99=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BatchAddToCollectionHandler.cs | 2 +- .../Localization/EzSongSelectStrings.cs | 8 + .../LAsEzExtensions/Screens/EzToCollection.cs | 276 ------------------ .../UserInterface/EzKeyModeSelector.cs | 5 +- osu.Game/Screens/Select/BeatmapCarousel.cs | 2 + 5 files changed, 14 insertions(+), 279 deletions(-) delete mode 100644 osu.Game/LAsEzExtensions/Screens/EzToCollection.cs diff --git a/osu.Game/Collections/BatchAddToCollectionHandler.cs b/osu.Game/Collections/BatchAddToCollectionHandler.cs index 63c7ac8a9e..031ccc319c 100644 --- a/osu.Game/Collections/BatchAddToCollectionHandler.cs +++ b/osu.Game/Collections/BatchAddToCollectionHandler.cs @@ -124,7 +124,7 @@ namespace osu.Game.Collections }, new PopupDialogDangerousButton { - Text = EzSongSelectStrings.REMOVE_FROM_COLLECTION, + Text = EzSongSelectStrings.REMOVE_INTERSECTION, Action = onRemoveIntersection, }, new PopupDialogCancelButton diff --git a/osu.Game/LAsEzExtensions/Localization/EzSongSelectStrings.cs b/osu.Game/LAsEzExtensions/Localization/EzSongSelectStrings.cs index 136fe7445c..1ec3cf71f3 100644 --- a/osu.Game/LAsEzExtensions/Localization/EzSongSelectStrings.cs +++ b/osu.Game/LAsEzExtensions/Localization/EzSongSelectStrings.cs @@ -43,5 +43,13 @@ namespace osu.Game.LAsEzExtensions.Localization "按键音预览:\n0 关闭; \n1 蓝灯开启 (全量音效预览); \n2 黄灯开启 (全量音效预览, 游戏中自动播放 note 音效, 按键不再触发样本播放) ", "Key sound preview: \n0 Off; \n1 BlueLight (keypress triggers samples); " + "\n2 GoldLight (preserve preview in song select; in gameplay auto-play note samples, keypresses no longer trigger sample playback)"); + + public static readonly LocalisableString CLEAR_SELECTION = new EzLocalizationManager.EzLocalisableString( + "点此处可清除过滤选择。\n(CS: cs ±0.5)", + "Click here to clear the filter selection.\n(CS: cs ±0.5)"); + + public static readonly LocalisableString MULTI_SELECT_BUTTON_TOOLTIP = new EzLocalizationManager.EzLocalisableString( + "多选模式", + "Multi-select mode"); } } diff --git a/osu.Game/LAsEzExtensions/Screens/EzToCollection.cs b/osu.Game/LAsEzExtensions/Screens/EzToCollection.cs deleted file mode 100644 index 1c09fcfcba..0000000000 --- a/osu.Game/LAsEzExtensions/Screens/EzToCollection.cs +++ /dev/null @@ -1,276 +0,0 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. -// See the LICENCE file in the repository root for full licence text. - -using System; -using System.Diagnostics; -using System.Linq; -using osu.Framework.Allocation; -using osu.Framework.Bindables; -using osu.Framework.Extensions.ObjectExtensions; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Sprites; -using osu.Framework.Graphics.UserInterface; -using osu.Framework.Input.Events; -using osu.Framework.Localisation; -using osu.Game.Beatmaps; -using osu.Game.Collections; -using osu.Game.Database; -using osu.Game.Graphics.Containers; -using osu.Game.Graphics.UserInterface; -using osuTK; -using Realms; - -namespace osu.Game.LAsEzExtensions.Screens -{ - public partial class EzToCollection : OsuDropdown - { - protected virtual bool ShowManageCollectionsItem => true; - - public Action? RequestFilter { private get; set; } - - private readonly BindableList filters = new BindableList(); - - [Resolved] - private ManageCollectionsDialog? manageCollectionsDialog { get; set; } - - [Resolved] - private RealmAccess realm { get; set; } = null!; - - private IDisposable? realmSubscription; - - private readonly CollectionFilterMenuItem allBeatmapsItem = new AllBeatmapsCollectionFilterMenuItem(); - - public EzToCollection() - { - ItemSource = filters; - - Current.Value = allBeatmapsItem; - AlwaysShowSearchBar = true; - } - - protected override void LoadComplete() - { - base.LoadComplete(); - - realmSubscription = realm.RegisterForNotifications(r => r.All().OrderBy(c => c.Name), collectionsChanged); - - Current.BindValueChanged(selectionChanged); - } - - private void collectionsChanged(IRealmCollection collections, ChangeSet? changes) - { - if (changes == null) - { - filters.Clear(); - filters.Add(allBeatmapsItem); - filters.AddRange(collections.Select(c => new CollectionFilterMenuItem(c.ToLive(realm)))); - if (ShowManageCollectionsItem) - filters.Add(new ManageCollectionsFilterMenuItem()); - } - else - { - foreach (int i in changes.DeletedIndices.OrderDescending()) - filters.RemoveAt(i + 1); - - foreach (int i in changes.InsertedIndices) - filters.Insert(i + 1, new CollectionFilterMenuItem(collections[i].ToLive(realm))); - - var selectedItem = SelectedItem?.Value; - - foreach (int i in changes.NewModifiedIndices) - { - var updatedItem = collections[i]; - - // This is responsible for updating the state of the +/- button and the collection's name. - // TODO: we can probably make the menu items update with changes to avoid this. - filters.RemoveAt(i + 1); - filters.Insert(i + 1, new CollectionFilterMenuItem(updatedItem.ToLive(realm))); - - if (updatedItem.ID == selectedItem?.Collection?.ID) - { - // This current update and schedule is required to work around dropdown headers not updating text even when the selected item - // changes. It's not great but honestly the whole dropdown menu structure isn't great. This needs to be fixed, but I'll issue - // a warning that it's going to be a frustrating journey. - Current.Value = allBeatmapsItem; - Schedule(() => - { - // current may have changed before the scheduled call is run. - if (Current.Value != allBeatmapsItem) - return; - - Current.Value = filters.SingleOrDefault(f => f.Collection?.ID == selectedItem.Collection?.ID) ?? filters[0]; - }); - - // Trigger an external re-filter if the current item was in the change set. - RequestFilter?.Invoke(); - break; - } - } - } - } - - private Live? lastFiltered; - - private void selectionChanged(ValueChangedEvent filter) - { - // May be null during .Clear(). - if (filter.NewValue.IsNull()) - return; - - // Never select the manage collection filter - rollback to the previous filter. - // This is done after the above since it is important that bindable is unbound from OldValue, which is lost after forcing it back to the old value. - if (filter.NewValue is ManageCollectionsFilterMenuItem) - { - Current.Value = filter.OldValue; - manageCollectionsDialog?.Show(); - return; - } - - var newCollection = filter.NewValue.Collection; - - // This dropdown be weird. - // We only care about filtering if the actual collection has changed. - if (newCollection != lastFiltered) - { - RequestFilter?.Invoke(); - lastFiltered = newCollection; - } - } - - protected override void Dispose(bool isDisposing) - { - base.Dispose(isDisposing); - realmSubscription?.Dispose(); - } - - protected override LocalisableString GenerateItemText(CollectionFilterMenuItem item) => item.CollectionName; - - protected sealed override DropdownHeader CreateHeader() => CreateCollectionHeader(); - - protected sealed override DropdownMenu CreateMenu() => CreateCollectionMenu(); - - protected virtual CollectionDropdownHeader CreateCollectionHeader() => new CollectionDropdownHeader(); - - protected virtual CollectionDropdownMenu CreateCollectionMenu() => new CollectionDropdownMenu(); - - public partial class CollectionDropdownHeader : OsuDropdownHeader - { - public CollectionDropdownHeader() - { - Height = 25; - Chevron.Size = new Vector2(12); - Foreground.Padding = new MarginPadding { Top = 4, Bottom = 4, Left = 8, Right = 8 }; - } - } - - protected partial class CollectionDropdownMenu : OsuDropdownMenu - { - public CollectionDropdownMenu() - { - MaxHeight = 200; - } - - protected override DrawableDropdownMenuItem CreateDrawableDropdownMenuItem(MenuItem item) => new CollectionDropdownDrawableMenuItem(item) - { - BackgroundColourHover = HoverColour, - BackgroundColourSelected = SelectionColour - }; - } - - protected partial class CollectionDropdownDrawableMenuItem : OsuDropdownMenu.DrawableOsuDropdownMenuItem - { - private IconButton addOrRemoveButton = null!; - - private bool beatmapInCollection; - - private readonly Live? collection; - - [Resolved] - private IBindable beatmap { get; set; } = null!; - - public CollectionDropdownDrawableMenuItem(MenuItem item) - : base(item) - { - collection = ((DropdownMenuItem)item).Value.Collection; - } - - [BackgroundDependencyLoader] - private void load() - { - AddInternal(addOrRemoveButton = new NoFocusChangeIconButton - { - Anchor = Anchor.CentreRight, - Origin = Anchor.CentreRight, - X = -OsuScrollContainer.SCROLL_BAR_WIDTH, - Scale = new Vector2(0.65f), - Action = addOrRemove, - }); - } - - protected override void LoadComplete() - { - base.LoadComplete(); - - if (collection != null) - { - beatmap.BindValueChanged(_ => - { - beatmapInCollection = collection.PerformRead(c => c.BeatmapMD5Hashes.Contains(beatmap.Value.BeatmapInfo.MD5Hash)); - - addOrRemoveButton.Enabled.Value = !beatmap.IsDefault; - addOrRemoveButton.Icon = beatmapInCollection ? FontAwesome.Solid.MinusSquare : FontAwesome.Solid.PlusSquare; - addOrRemoveButton.TooltipText = beatmapInCollection ? "Remove selected beatmap" : "Add selected beatmap"; - - updateButtonVisibility(); - }, true); - } - - updateButtonVisibility(); - } - - protected override bool OnHover(HoverEvent e) - { - updateButtonVisibility(); - return base.OnHover(e); - } - - protected override void OnHoverLost(HoverLostEvent e) - { - updateButtonVisibility(); - base.OnHoverLost(e); - } - - protected override void OnSelectChange() - { - base.OnSelectChange(); - updateButtonVisibility(); - } - - private void updateButtonVisibility() - { - if (collection == null) - addOrRemoveButton.Alpha = 0; - else - addOrRemoveButton.Alpha = IsHovered || IsPreSelected || beatmapInCollection ? 1 : 0; - } - - private void addOrRemove() - { - Debug.Assert(collection != null); - - collection.PerformWrite(c => - { - if (!c.BeatmapMD5Hashes.Remove(beatmap.Value.BeatmapInfo.MD5Hash)) - c.BeatmapMD5Hashes.Add(beatmap.Value.BeatmapInfo.MD5Hash); - }); - } - - protected override Drawable CreateContent() => (Content)base.CreateContent(); - - private partial class NoFocusChangeIconButton : IconButton - { - public override bool ChangeFocusOnClick => false; - } - } - } -} diff --git a/osu.Game/LAsEzExtensions/UserInterface/EzKeyModeSelector.cs b/osu.Game/LAsEzExtensions/UserInterface/EzKeyModeSelector.cs index 8956b75189..abe14f186f 100644 --- a/osu.Game/LAsEzExtensions/UserInterface/EzKeyModeSelector.cs +++ b/osu.Game/LAsEzExtensions/UserInterface/EzKeyModeSelector.cs @@ -15,6 +15,7 @@ using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; using osu.Game.LAsEzExtensions.Configuration; +using osu.Game.LAsEzExtensions.Localization; using osu.Game.Overlays; using osu.Game.Rulesets; using osuTK; @@ -84,7 +85,7 @@ namespace osu.Game.LAsEzExtensions.UserInterface Anchor = Anchor.Centre, Origin = Anchor.Centre, Shear = new Vector2(0), - TooltipText = "Clear selection", + TooltipText = EzSongSelectStrings.CLEAR_SELECTION, }, tabControl = new ShearedCsModeTabControl { @@ -98,7 +99,7 @@ namespace osu.Game.LAsEzExtensions.UserInterface Shear = new Vector2(0), Text = "K +", Height = 30f, - TooltipText = "Enable multi-select", + TooltipText = EzSongSelectStrings.MULTI_SELECT_BUTTON_TOOLTIP, } } } diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index 2055cd0a4b..34e7c3a9fa 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -821,6 +821,8 @@ namespace osu.Game.Screens.Select public int LastFilterPanels { get; private set; } + public int FilterRuns => filterRuns; + public void Filter(FilterCriteria criteria, bool showLoadingImmediately = false) { bool resetDisplay = grouping.BeatmapSetsGroupedTogether != BeatmapCarouselFilterGrouping.ShouldGroupBeatmapsTogether(criteria);