From d999180fdd90eb0d6b6caf4454cd00596f090213 Mon Sep 17 00:00:00 2001 From: MATRIX-feather Date: Wed, 11 Aug 2021 17:54:17 +0800 Subject: [PATCH 1/8] =?UTF-8?q?=E5=88=9D=E6=AD=A5=E5=88=86=E7=A6=BB?= =?UTF-8?q?=E5=BA=95=E6=A0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sidebar/LyricBottombarButton.cs | 16 - .../Sidebar/LyricFunctionProvider.cs | 31 ++ .../Sidebar/LyricSidebarPage.cs | 5 +- .../Sidebar/CollectionFunctionProvider.cs | 29 ++ .../Sidebar/CollectionPluginPage.cs | 3 +- .../Sidebar/CollectionSupportEntryButton.cs | 16 - .../Mvis/TestSceneMvisBottomBarButton.cs | 1 + .../Rankings/RankingsOverlayHeader.cs | 1 - .../Sections/Debug/GeneralSettings.cs | 2 - osu.Game/Screens/Edit/EditorTable.cs | 1 - osu.Game/Screens/Mvis/BottomBar/BottomBar.cs | 88 ---- .../BottomBarOverlayLockSwitchButton.cs | 34 -- .../Mvis/BottomBar/Buttons/NextPrevButton.cs | 7 - .../BottomBar/Buttons/ToggleLoopButton.cs | 21 - osu.Game/Screens/Mvis/MvisScreen.cs | 383 ++++++++---------- .../BottomBar/Buttons/BottomBarButton.cs | 69 ++-- .../Buttons/BottomBarSwitchButton.cs | 60 ++- .../BottomBar/Buttons/SongProgressButton.cs | 14 +- .../Internal/BottomBar/LegacyBottomBar.cs | 179 ++++++++ .../Internal}/BottomBar/SongProgressBar.cs | 0 osu.Game/Screens/Mvis/Plugins/MvisPlugin.cs | 3 +- .../Mvis/Plugins/PluginBottomBarButton.cs | 14 - .../Screens/Mvis/Plugins/PluginSidebarPage.cs | 3 +- .../Screens/Mvis/Plugins/Types/FakeButton.cs | 22 + .../Plugins/Types/IFunctionBarProvider.cs | 68 ++++ .../Mvis/Plugins/Types/IFunctionProvider.cs | 43 ++ .../Plugins/Types/ToggleableFakeButton.cs | 37 ++ osu.Game/Screens/Mvis/SideBar/Sidebar.cs | 7 +- osu.Game/osu.Game.csproj | 3 + 29 files changed, 667 insertions(+), 493 deletions(-) delete mode 100644 Mvis.Plugin.CloudMusicSupport/Sidebar/LyricBottombarButton.cs create mode 100644 Mvis.Plugin.CloudMusicSupport/Sidebar/LyricFunctionProvider.cs create mode 100644 Mvis.Plugin.CollectionSupport/Sidebar/CollectionFunctionProvider.cs delete mode 100644 Mvis.Plugin.CollectionSupport/Sidebar/CollectionSupportEntryButton.cs delete mode 100644 osu.Game/Screens/Mvis/BottomBar/BottomBar.cs delete mode 100644 osu.Game/Screens/Mvis/BottomBar/Buttons/BottomBarOverlayLockSwitchButton.cs delete mode 100644 osu.Game/Screens/Mvis/BottomBar/Buttons/NextPrevButton.cs delete mode 100644 osu.Game/Screens/Mvis/BottomBar/Buttons/ToggleLoopButton.cs rename osu.Game/Screens/Mvis/{ => Plugins/Internal}/BottomBar/Buttons/BottomBarButton.cs (89%) rename osu.Game/Screens/Mvis/{ => Plugins/Internal}/BottomBar/Buttons/BottomBarSwitchButton.cs (52%) rename osu.Game/Screens/Mvis/{ => Plugins/Internal}/BottomBar/Buttons/SongProgressButton.cs (66%) create mode 100644 osu.Game/Screens/Mvis/Plugins/Internal/BottomBar/LegacyBottomBar.cs rename osu.Game/Screens/Mvis/{ => Plugins/Internal}/BottomBar/SongProgressBar.cs (100%) delete mode 100644 osu.Game/Screens/Mvis/Plugins/PluginBottomBarButton.cs create mode 100644 osu.Game/Screens/Mvis/Plugins/Types/FakeButton.cs create mode 100644 osu.Game/Screens/Mvis/Plugins/Types/IFunctionBarProvider.cs create mode 100644 osu.Game/Screens/Mvis/Plugins/Types/IFunctionProvider.cs create mode 100644 osu.Game/Screens/Mvis/Plugins/Types/ToggleableFakeButton.cs diff --git a/Mvis.Plugin.CloudMusicSupport/Sidebar/LyricBottombarButton.cs b/Mvis.Plugin.CloudMusicSupport/Sidebar/LyricBottombarButton.cs deleted file mode 100644 index c1d00ebd7a34..000000000000 --- a/Mvis.Plugin.CloudMusicSupport/Sidebar/LyricBottombarButton.cs +++ /dev/null @@ -1,16 +0,0 @@ -using M.Resources.Localisation.Mvis.Plugins; -using osu.Framework.Graphics.Sprites; -using osu.Game.Screens.Mvis.Plugins; - -namespace Mvis.Plugin.CloudMusicSupport.Sidebar -{ - public class LyricBottombarButton : PluginBottomBarButton - { - public LyricBottombarButton(PluginSidebarPage page) - : base(page) - { - ButtonIcon = FontAwesome.Solid.Music; - TooltipText = CloudMusicStrings.EntryTooltip; - } - } -} diff --git a/Mvis.Plugin.CloudMusicSupport/Sidebar/LyricFunctionProvider.cs b/Mvis.Plugin.CloudMusicSupport/Sidebar/LyricFunctionProvider.cs new file mode 100644 index 000000000000..7503e6e924b8 --- /dev/null +++ b/Mvis.Plugin.CloudMusicSupport/Sidebar/LyricFunctionProvider.cs @@ -0,0 +1,31 @@ +// 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 M.Resources.Localisation.Mvis.Plugins; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Localisation; +using osu.Game.Screens.Mvis.Plugins; +using osu.Game.Screens.Mvis.Plugins.Types; +using osuTK; + +namespace Mvis.Plugin.CloudMusicSupport.Sidebar +{ + public class LyricFunctionProvider : IPluginFunctionProvider + { + public Vector2 Size { get; set; } = new Vector2(30); + public Action Action { get; set; } + public IconUsage Icon { get; set; } = FontAwesome.Solid.Music; + public LocalisableString Title { get; set; } + public LocalisableString Description { get; set; } = CloudMusicStrings.EntryTooltip; + public void Active() => Action?.Invoke(); + public FunctionType Type { get; set; } = FunctionType.Plugin; + + public PluginSidebarPage SourcePage { get; set; } + + public LyricFunctionProvider(PluginSidebarPage page) + { + SourcePage = page; + } + } +} diff --git a/Mvis.Plugin.CloudMusicSupport/Sidebar/LyricSidebarPage.cs b/Mvis.Plugin.CloudMusicSupport/Sidebar/LyricSidebarPage.cs index 37945ad1bab0..374efd3f6bc1 100644 --- a/Mvis.Plugin.CloudMusicSupport/Sidebar/LyricSidebarPage.cs +++ b/Mvis.Plugin.CloudMusicSupport/Sidebar/LyricSidebarPage.cs @@ -13,6 +13,7 @@ using osu.Game.Overlays; using osu.Game.Screens.Mvis; using osu.Game.Screens.Mvis.Plugins; +using osu.Game.Screens.Mvis.Plugins.Types; namespace Mvis.Plugin.CloudMusicSupport.Sidebar { @@ -26,8 +27,8 @@ public LyricSidebarSectionContainer(MvisPlugin plugin) Icon = FontAwesome.Solid.Music; } - public override PluginBottomBarButton CreateBottomBarButton() - => new LyricBottombarButton(this); + public override IPluginFunctionProvider GetFunctionEntry() + => new LyricFunctionProvider(this); [Resolved] private MvisScreen mvisScreen { get; set; } diff --git a/Mvis.Plugin.CollectionSupport/Sidebar/CollectionFunctionProvider.cs b/Mvis.Plugin.CollectionSupport/Sidebar/CollectionFunctionProvider.cs new file mode 100644 index 000000000000..3f98a1efbf5d --- /dev/null +++ b/Mvis.Plugin.CollectionSupport/Sidebar/CollectionFunctionProvider.cs @@ -0,0 +1,29 @@ +using System; +using M.Resources.Localisation.Mvis.Plugins; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Localisation; +using osu.Game.Screens.Mvis.Plugins; +using osu.Game.Screens.Mvis.Plugins.Types; +using osuTK; + +namespace Mvis.Plugin.CollectionSupport.Sidebar +{ + public class CollectionFunctionProvider : IPluginFunctionProvider + { + public Vector2 Size { get; set; } = new Vector2(30); + public Action Action { get; set; } + public IconUsage Icon { get; set; } = FontAwesome.Solid.Check; + public LocalisableString Title { get; set; } + public LocalisableString Description { get; set; } = CollectionStrings.EntryTooltip; + public FunctionType Type { get; set; } = FunctionType.Plugin; + + public void Active() => Action?.Invoke(); + + public PluginSidebarPage SourcePage { get; set; } + + public CollectionFunctionProvider(PluginSidebarPage page) + { + SourcePage = page; + } + } +} diff --git a/Mvis.Plugin.CollectionSupport/Sidebar/CollectionPluginPage.cs b/Mvis.Plugin.CollectionSupport/Sidebar/CollectionPluginPage.cs index 8f6d68d6aa38..21f5529362b4 100644 --- a/Mvis.Plugin.CollectionSupport/Sidebar/CollectionPluginPage.cs +++ b/Mvis.Plugin.CollectionSupport/Sidebar/CollectionPluginPage.cs @@ -10,6 +10,7 @@ using osu.Game.Graphics.Containers; using osu.Game.Screens.Mvis; using osu.Game.Screens.Mvis.Plugins; +using osu.Game.Screens.Mvis.Plugins.Types; using osu.Game.Screens.Mvis.Skinning; using osu.Game.Skinning; using osuTK; @@ -49,7 +50,7 @@ public CollectionPluginPage(MvisPlugin plugin) protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) => dependencies = new DependencyContainer(base.CreateChildDependencies(parent)); - public override PluginBottomBarButton CreateBottomBarButton() => new CollectionSupportEntryButton(this); + public override IPluginFunctionProvider GetFunctionEntry() => new CollectionFunctionProvider(this); public override Key ShortcutKey => Key.Period; [BackgroundDependencyLoader] diff --git a/Mvis.Plugin.CollectionSupport/Sidebar/CollectionSupportEntryButton.cs b/Mvis.Plugin.CollectionSupport/Sidebar/CollectionSupportEntryButton.cs deleted file mode 100644 index 7b74b37b832e..000000000000 --- a/Mvis.Plugin.CollectionSupport/Sidebar/CollectionSupportEntryButton.cs +++ /dev/null @@ -1,16 +0,0 @@ -using M.Resources.Localisation.Mvis.Plugins; -using osu.Framework.Graphics.Sprites; -using osu.Game.Screens.Mvis.Plugins; - -namespace Mvis.Plugin.CollectionSupport.Sidebar -{ - public class CollectionSupportEntryButton : PluginBottomBarButton - { - public CollectionSupportEntryButton(PluginSidebarPage page) - : base(page) - { - ButtonIcon = FontAwesome.Solid.Check; - TooltipText = CollectionStrings.EntryTooltip; - } - } -} diff --git a/osu.Game.Tests/Visual/Mvis/TestSceneMvisBottomBarButton.cs b/osu.Game.Tests/Visual/Mvis/TestSceneMvisBottomBarButton.cs index 95498e8c3fdb..45de3f723f30 100644 --- a/osu.Game.Tests/Visual/Mvis/TestSceneMvisBottomBarButton.cs +++ b/osu.Game.Tests/Visual/Mvis/TestSceneMvisBottomBarButton.cs @@ -6,6 +6,7 @@ using osu.Framework.Graphics.Sprites; using osu.Game.Screens.Mvis; using osu.Game.Screens.Mvis.BottomBar.Buttons; +using osu.Game.Screens.Mvis.Plugins.Internal.BottomBar.Buttons; using osuTK; namespace osu.Game.Tests.Visual.Mvis diff --git a/osu.Game/Overlays/Rankings/RankingsOverlayHeader.cs b/osu.Game/Overlays/Rankings/RankingsOverlayHeader.cs index e2145bfb673c..72a67483743d 100644 --- a/osu.Game/Overlays/Rankings/RankingsOverlayHeader.cs +++ b/osu.Game/Overlays/Rankings/RankingsOverlayHeader.cs @@ -7,7 +7,6 @@ using osu.Framework.Graphics; using osu.Game.Rulesets; using osu.Game.Users; -using System.ComponentModel; namespace osu.Game.Overlays.Rankings { diff --git a/osu.Game/Overlays/Settings/Sections/Debug/GeneralSettings.cs b/osu.Game/Overlays/Settings/Sections/Debug/GeneralSettings.cs index bdfdeb86b464..605beb5e7565 100755 --- a/osu.Game/Overlays/Settings/Sections/Debug/GeneralSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Debug/GeneralSettings.cs @@ -5,8 +5,6 @@ using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Localisation; -using osu.Framework.Screens; -using osu.Game.Screens.Import; namespace osu.Game.Overlays.Settings.Sections.Debug { diff --git a/osu.Game/Screens/Edit/EditorTable.cs b/osu.Game/Screens/Edit/EditorTable.cs index 5342c19014f1..b364db9a2d84 100644 --- a/osu.Game/Screens/Edit/EditorTable.cs +++ b/osu.Game/Screens/Edit/EditorTable.cs @@ -2,7 +2,6 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; -using osu.Framework.Extensions.LocalisationExtensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; diff --git a/osu.Game/Screens/Mvis/BottomBar/BottomBar.cs b/osu.Game/Screens/Mvis/BottomBar/BottomBar.cs deleted file mode 100644 index 74db596cbd76..000000000000 --- a/osu.Game/Screens/Mvis/BottomBar/BottomBar.cs +++ /dev/null @@ -1,88 +0,0 @@ -using System; -using osu.Framework.Allocation; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Game.Screens.Mvis.BottomBar.Buttons; -using osuTK; - -namespace osu.Game.Screens.Mvis.BottomBar -{ - internal class BottomBarContainer : Container - { - public Drawable[] LeftContent; - public Drawable[] CentreContent; - public Drawable[] RightContent; - public FillFlowContainer PluginEntriesFillFlow; - - public BottomBarContainer() - { - Anchor = Anchor.BottomCentre; - Origin = Anchor.BottomCentre; - RelativeSizeAxes = Axes.X; - AutoSizeAxes = Axes.Y; - AutoSizeDuration = 300; - AutoSizeEasing = Easing.OutQuint; - Margin = new MarginPadding { Bottom = 10 }; - } - - [BackgroundDependencyLoader] - private void load(MvisScreen mvisScreen) - { - InternalChildren = new Drawable[] - { - new FillFlowContainer - { - Name = "Left Container", - Anchor = Anchor.BottomLeft, - Origin = Anchor.BottomLeft, - AutoSizeAxes = Axes.Both, - Spacing = new Vector2(5), - Margin = new MarginPadding { Left = 5 }, - Children = LeftContent - }, - new FillFlowContainer - { - Name = "Centre Container", - Anchor = Anchor.BottomCentre, - Origin = Anchor.BottomCentre, - AutoSizeAxes = Axes.Both, - Spacing = new Vector2(5), - Children = CentreContent - }, - new FillFlowContainer - { - Name = "Right Container", - Anchor = Anchor.BottomRight, - Origin = Anchor.BottomRight, - AutoSizeAxes = Axes.Both, - Spacing = new Vector2(5), - Margin = new MarginPadding { Right = 5 }, - Children = RightContent - }, - PluginEntriesFillFlow = new FillFlowContainer - { - Name = "Plugin Entries Container", - Anchor = Anchor.BottomCentre, - Origin = Anchor.BottomCentre, - AutoSizeAxes = Axes.Both, - AutoSizeDuration = 300, - AutoSizeEasing = Easing.OutQuint, - Spacing = new Vector2(5), - Margin = new MarginPadding { Bottom = 35 } - } - }; - - mvisScreen.OnIdle += Hide; - mvisScreen.OnResumeFromIdle += Show; - } - - public override void Show() => - this.MoveToY(0, 300, Easing.OutQuint).FadeIn(300, Easing.OutQuint); - - public override void Hide() => - this.MoveToY(40, 300, Easing.OutQuint); - - public void CentreBotton(BottomBarButton btn) => - PluginEntriesFillFlow.SetLayoutPosition(btn, (float)Math.Floor(PluginEntriesFillFlow.Count / 2f)); - } -} diff --git a/osu.Game/Screens/Mvis/BottomBar/Buttons/BottomBarOverlayLockSwitchButton.cs b/osu.Game/Screens/Mvis/BottomBar/Buttons/BottomBarOverlayLockSwitchButton.cs deleted file mode 100644 index a1e1759283d2..000000000000 --- a/osu.Game/Screens/Mvis/BottomBar/Buttons/BottomBarOverlayLockSwitchButton.cs +++ /dev/null @@ -1,34 +0,0 @@ -using osu.Framework.Allocation; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Sprites; -using osuTK.Graphics; - -namespace osu.Game.Screens.Mvis.BottomBar.Buttons -{ - public class BottomBarOverlayLockSwitchButton : BottomBarSwitchButton - { - private const float animate_duration = 100; - - public bool Disabled - { - set => this.FadeColour(value ? Color4.Gray : Color4.White, 300, Easing.OutQuint); - } - - public BottomBarOverlayLockSwitchButton() - { - ButtonIcon = FontAwesome.Solid.Lock; - } - - [Resolved] - private MvisScreen mvisScreen { get; set; } - - protected override void OnToggledOnAnimation() - { - base.OnToggledOnAnimation(); - - SpriteIcon.RotateTo(15, animate_duration).Then() - .RotateTo(-15, animate_duration).Loop(0, 2).Then() - .RotateTo(0, animate_duration); - } - } -} diff --git a/osu.Game/Screens/Mvis/BottomBar/Buttons/NextPrevButton.cs b/osu.Game/Screens/Mvis/BottomBar/Buttons/NextPrevButton.cs deleted file mode 100644 index f7fc1cd4688b..000000000000 --- a/osu.Game/Screens/Mvis/BottomBar/Buttons/NextPrevButton.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace osu.Game.Screens.Mvis.BottomBar.Buttons -{ - public class NextPrevButton : BottomBarButton - { - protected override string BackgroundTextureName => "MButtonWide-background.png"; - } -} diff --git a/osu.Game/Screens/Mvis/BottomBar/Buttons/ToggleLoopButton.cs b/osu.Game/Screens/Mvis/BottomBar/Buttons/ToggleLoopButton.cs deleted file mode 100644 index 1edc88c03348..000000000000 --- a/osu.Game/Screens/Mvis/BottomBar/Buttons/ToggleLoopButton.cs +++ /dev/null @@ -1,21 +0,0 @@ -using osu.Framework.Graphics; -using osu.Framework.Graphics.Sprites; - -namespace osu.Game.Screens.Mvis.BottomBar.Buttons -{ - public class ToggleLoopButton : BottomBarSwitchButton - { - public ToggleLoopButton() - { - ButtonIcon = FontAwesome.Solid.Undo; - TooltipText = "单曲循环"; - } - - protected override void OnToggledOnAnimation() - { - base.OnToggledOnAnimation(); - - SpriteIcon.RotateTo(0).RotateTo(-360, 1000, Easing.OutQuint); - } - } -} diff --git a/osu.Game/Screens/Mvis/MvisScreen.cs b/osu.Game/Screens/Mvis/MvisScreen.cs index 6d7ff23ebfb4..c2fa6dadf2b9 100644 --- a/osu.Game/Screens/Mvis/MvisScreen.cs +++ b/osu.Game/Screens/Mvis/MvisScreen.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Collections.Specialized; using System.Linq; +using JetBrains.Annotations; using M.Resources.Localisation.Mvis; using osu.Framework; using osu.Framework.Allocation; @@ -27,24 +28,20 @@ using osu.Game.Overlays.Dialog; using osu.Game.Overlays.Settings; using osu.Game.Rulesets.Mods; -using osu.Game.Screens.Mvis.BottomBar; -using osu.Game.Screens.Mvis.BottomBar.Buttons; using osu.Game.Screens.Mvis.Misc; using osu.Game.Screens.Mvis.Plugins; +using osu.Game.Screens.Mvis.Plugins.Internal.BottomBar; using osu.Game.Screens.Mvis.Plugins.Types; using osu.Game.Screens.Mvis.SideBar; using osu.Game.Screens.Mvis.SideBar.Settings; using osu.Game.Screens.Mvis.SideBar.Tabs; -using osu.Game.Screens.Mvis.Skinning; using osu.Game.Screens.Play; using osu.Game.Screens.Select; -using osu.Game.Skinning; using osu.Game.Users; using osuTK; using osuTK.Graphics; using osuTK.Input; using Sidebar = osu.Game.Screens.Mvis.SideBar.Sidebar; -using SongProgressBar = osu.Game.Screens.Mvis.BottomBar.SongProgressBar; namespace osu.Game.Screens.Mvis { @@ -63,9 +60,9 @@ public class MvisScreen : ScreenWithBeatmapBackground, IKeyBindingHandler IsHovered && isIdle.Value - && !(bottomBar?.IsHovered ?? false) - && !(lockButton?.Value.Value ?? false) - && !lockChanges.Value + && !currentFunctionBarProvider.OkForHide() + && !(lockButton?.Bindable.Value ?? false) + && !(lockButton?.Bindable.Disabled ?? false) && inputManager?.DraggedDrawable == null && inputManager?.FocusedDrawable == null; @@ -178,19 +175,32 @@ protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnl #region 底栏 - private BottomBarContainer bottomBar; - private SongProgressBar progressBar; + [CanBeNull] + private IFunctionBarProvider realFunctionBarProvider; + + [NotNull] + private IFunctionBarProvider currentFunctionBarProvider + { + get => realFunctionBarProvider ?? legacyBottomBarContainer; + set => realFunctionBarProvider = value; + } + + private readonly LegacyBottomBar legacyBottomBarContainer = new LegacyBottomBar(); + + private readonly List functionBarProviders = new List(); + private readonly List functionProviders = new List(); //留着这些能让播放器在触发GlobalAction时会有更好的界面体验 - private BottomBarButton soloButton; - private BottomBarButton prevButton; - private BottomBarButton nextButton; - private BottomBarButton sidebarToggleButton; - private BottomBarButton pluginButton; + private FakeButton soloButton; + private FakeButton prevButton; + private FakeButton nextButton; + private FakeButton pluginButton; + private FakeButton disableChangesButton; + private FakeButton sidebarToggleButton; - private BottomBarSwitchButton loopToggleButton; - private BottomBarOverlayLockSwitchButton lockButton; - private BottomBarSwitchButton songProgressButton; + private ToggleableFakeButton loopToggleButton; + private ToggleableFakeButton lockButton; + private ToggleableFakeButton songProgressButton; #endregion @@ -201,10 +211,10 @@ protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnl private Container background; private BgTrianglesContainer bgTriangles; - private FullScreenSkinnableComponent skinnableBbBackground; private Container foreground; - private FullScreenSkinnableComponent skinnableForeground; + + private Container overlay; #endregion @@ -280,7 +290,6 @@ public bool RemoveDrawableFromProxy(Drawable d) private readonly Dictionary keyBindings = new Dictionary(); public bool OverlaysHidden { get; private set; } - private readonly BindableBool lockChanges = new BindableBool(); private readonly IBindable isIdle = new BindableBool(); private readonly Bindable activity = new Bindable(); @@ -297,7 +306,7 @@ public bool RemoveDrawableFromProxy(Drawable d) private SettingsButton songSelectButton; private PlayerSettings settingsScroll; - public float BottombarHeight => (bottomBar?.Height - bottomBar?.Y ?? 0) + 10 + 5; + public float BottombarHeight => currentFunctionBarProvider.GetSafeAreaPadding(); #endregion @@ -327,6 +336,7 @@ private void load(MConfigManager config, IdleTracker idleTracker) settingsScroll = new PlayerSettings(), pluginsPage = new SidebarPluginsPage() }); + songSelectButton = new SettingsButton { Text = "歌曲选择", @@ -366,16 +376,7 @@ private void load(MConfigManager config, IdleTracker idleTracker) Anchor = Anchor.Centre, Origin = Anchor.Centre }, - skinnableForeground = new FullScreenSkinnableComponent("MPlayer-foreground", confineMode: ConfineMode.ScaleToFill, defaultImplementation: _ => new PlaceHolder()) - { - Name = "前景图", - RelativeSizeAxes = Axes.Both, - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, - Alpha = 0, - OverrideChildAnchor = true - }, - new Container + overlay = new Container { Name = "Overlay Layer", RelativeSizeAxes = Axes.Both, @@ -383,22 +384,6 @@ private void load(MConfigManager config, IdleTracker idleTracker) Padding = new MarginPadding { Horizontal = HORIZONTAL_OVERFLOW_PADDING }, Children = new Drawable[] { - skinnableBbBackground = new FullScreenSkinnableComponent("MBottomBar-background", - confineMode: ConfineMode.ScaleToFill, - masking: false, - defaultImplementation: _ => new PlaceHolder()) - { - Name = "底栏背景图", - Anchor = Anchor.BottomCentre, - Origin = Anchor.BottomCentre, - RelativeSizeAxes = Axes.X, - Height = 100, - ChildAnchor = Anchor.BottomCentre, - ChildOrigin = Anchor.BottomCentre, - Alpha = 0, - CentreComponent = false, - OverrideChildAnchor = true - }, sidebar, tabHeader, loadingSpinner = new LoadingSpinner(true, true) @@ -406,116 +391,108 @@ private void load(MConfigManager config, IdleTracker idleTracker) Anchor = Anchor.BottomCentre, Origin = Anchor.BottomCentre, Margin = new MarginPadding(115) - }, - bottomBar = new BottomBarContainer - { - LeftContent = new Drawable[] - { - new BottomBarButton - { - ButtonIcon = FontAwesome.Solid.ArrowLeft, - Action = this.Exit, - TooltipText = MvisBaseStrings.Exit - }, - new BottomBarButton - { - ButtonIcon = FontAwesome.Regular.QuestionCircle, - Action = () => game?.OpenUrlExternally("https://matrix-feather.github.io/mfosu/mfosu_mp_manual/"), - TooltipText = MvisBaseStrings.Manual - } - }, - CentreContent = new Drawable[] - { - prevButton = new NextPrevButton - { - Size = new Vector2(50, 30), - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - ButtonIcon = FontAwesome.Solid.StepBackward, - Action = prevTrack, - TooltipText = MvisBaseStrings.PrevOrRestart - }, - songProgressButton = new SongProgressButton - { - TooltipText = MvisBaseStrings.TogglePause, - Action = togglePause, - Anchor = Anchor.Centre, - Origin = Anchor.Centre - }, - nextButton = new NextPrevButton - { - Size = new Vector2(50, 30), - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - ButtonIcon = FontAwesome.Solid.StepForward, - Action = nextTrack, - TooltipText = MvisBaseStrings.Next - }, - }, - RightContent = new Drawable[] - { - pluginButton = new BottomBarButton - { - ButtonIcon = FontAwesome.Solid.Plug, - TooltipText = MvisBaseStrings.ViewPlugins, - Action = () => updateSidebarState(pluginsPage) - }, - new BottomBarButton - { - ButtonIcon = FontAwesome.Solid.Desktop, - Action = () => - { - //隐藏界面,锁定更改并隐藏锁定按钮 - lockChanges.Value = false; - hideOverlays(true); - - updateSidebarState(null); - - //防止手机端无法恢复界面 - lockChanges.Value = RuntimeInfo.IsDesktop; - lockButton.Value.Value = !RuntimeInfo.IsDesktop; - }, - TooltipText = MvisBaseStrings.HideAndLockInterface - }, - loopToggleButton = new ToggleLoopButton - { - ButtonIcon = FontAwesome.Solid.Undo, - Action = () => CurrentTrack.Looping = loopToggleButton.Value.Value, - TooltipText = MvisBaseStrings.ToggleLoop - }, - soloButton = new BottomBarButton - { - ButtonIcon = FontAwesome.Solid.User, - Action = presentBeatmap, - TooltipText = MvisBaseStrings.ViewInSongSelect, - }, - sidebarToggleButton = new BottomBarSwitchButton - { - ButtonIcon = FontAwesome.Solid.List, - Action = () => updateSidebarState(settingsScroll), - TooltipText = MvisBaseStrings.OpenSidebar, - Value = { BindTarget = sidebar.IsVisible }, - IsCoupled = false - } - } - }, - progressBar = new SongProgressBar - { - OnSeek = SeekTo } } } }; - //后期设置 - bottomBar.PluginEntriesFillFlow.Add(lockButton = new BottomBarOverlayLockSwitchButton - { - TooltipText = MvisBaseStrings.LockInterface, - Action = showPluginEntriesTemporary - }); - //todo: 找出为啥audioControlProvider会在被赋值前访问 audioControlProvider = MusicControllerWrapper; + + functionProviders.AddRange(new IFunctionProvider[] + { + new FakeButton + { + Icon = FontAwesome.Solid.ArrowLeft, + Action = this.Exit, + Description = MvisBaseStrings.Exit, + Type = FunctionType.Base + }, + new FakeButton + { + Icon = FontAwesome.Regular.QuestionCircle, + Action = () => game?.OpenUrlExternally("https://matrix-feather.github.io/mfosu/mfosu_mp_manual/"), + Description = MvisBaseStrings.Manual, + Type = FunctionType.Base + }, + prevButton = new FakeButton + { + Size = new Vector2(50, 30), + Icon = FontAwesome.Solid.StepBackward, + Action = prevTrack, + Description = MvisBaseStrings.PrevOrRestart, + Type = FunctionType.Audio + }, + songProgressButton = new ToggleableFakeButton + { + Description = MvisBaseStrings.TogglePause, + Action = togglePause, + Type = FunctionType.ProgressDisplay + }, + nextButton = new FakeButton + { + Size = new Vector2(50, 30), + Icon = FontAwesome.Solid.StepForward, + Action = nextTrack, + Description = MvisBaseStrings.Next, + Type = FunctionType.Audio, + }, + pluginButton = new FakeButton + { + Icon = FontAwesome.Solid.Plug, + Description = MvisBaseStrings.ViewPlugins, + Action = () => updateSidebarState(pluginsPage), + Type = FunctionType.Misc + }, + disableChangesButton = new FakeButton + { + Icon = FontAwesome.Solid.Desktop, + Action = () => + { + bool disabledBefore = lockButton.Bindable.Disabled; + lockButton.Bindable.Disabled = false; + + //隐藏界面,锁定更改并隐藏锁定按钮 + hideOverlays(true); + + updateSidebarState(null); + + //防止手机端无法恢复界面 + lockButton.Bindable.Value = RuntimeInfo.IsDesktop; + lockButton.Bindable.Disabled = RuntimeInfo.IsDesktop && !disabledBefore; + }, + Description = MvisBaseStrings.HideAndLockInterface, + Type = FunctionType.Misc + }, + loopToggleButton = new ToggleableFakeButton + { + Icon = FontAwesome.Solid.Undo, + Action = () => CurrentTrack.Looping = loopToggleButton.Bindable.Value, + Description = MvisBaseStrings.ToggleLoop, + Type = FunctionType.Misc + }, + soloButton = new FakeButton + { + Icon = FontAwesome.Solid.User, + Action = presentBeatmap, + Description = MvisBaseStrings.ViewInSongSelect, + Type = FunctionType.Misc + }, + sidebarToggleButton = new FakeButton + { + Icon = FontAwesome.Solid.List, + Action = () => updateSidebarState(settingsScroll), + Description = MvisBaseStrings.OpenSidebar, + Type = FunctionType.Misc + }, + lockButton = new ToggleableFakeButton + { + Description = MvisBaseStrings.LockInterface, + Action = showPluginEntriesTemporary, + Type = FunctionType.Plugin, + Icon = FontAwesome.Solid.Lock + } + }); } protected override void LoadComplete() @@ -526,11 +503,6 @@ protected override void LoadComplete() bgBlur.BindValueChanged(v => updateBackground(Beatmap.Value)); idleBgDim.BindValueChanged(_ => updateIdleVisuals()); - lockChanges.BindValueChanged(v => - { - lockButton.Disabled = v.NewValue; - }); - musicSpeed.BindValueChanged(_ => applyTrackAdjustments()); adjustFreq.BindValueChanged(_ => applyTrackAdjustments()); nightcoreBeat.BindValueChanged(v => @@ -548,7 +520,7 @@ protected override void LoadComplete() inputManager = GetContainingInputManager(); - songProgressButton.Value.BindTo(trackRunning); + songProgressButton.Bindable.BindTo(trackRunning); allowProxy.BindValueChanged(v => { @@ -602,6 +574,11 @@ protected override void LoadComplete() case MvisPlugin.TargetLayer.Foreground: foreground.Add(pl); break; + + case MvisPlugin.TargetLayer.FunctionBar: + if (pl.GetType().IsSubclassOf(typeof(IFunctionBarProvider))) + functionBarProviders.Add(pl as IFunctionBarProvider); + break; } var pluginSidebarPage = pl.CreateSidebarPage(); @@ -610,15 +587,15 @@ protected override void LoadComplete() if (pluginSidebarPage != null) { sidebar.Add(pluginSidebarPage); - var btn = pluginSidebarPage.CreateBottomBarButton(); + var btn = pluginSidebarPage.GetFunctionEntry(); //如果插件的侧边栏页面有入口按钮 if (btn != null) { btn.Action = () => updateSidebarState(pluginSidebarPage); - btn.TooltipText += $" ({pluginSidebarPage.ShortcutKey})"; + btn.Description += $" ({pluginSidebarPage.ShortcutKey})"; - bottomBar.PluginEntriesFillFlow.Add(btn); + functionProviders.Add(btn); } //如果插件的侧边栏页面有调用快捷键 @@ -626,7 +603,7 @@ protected override void LoadComplete() { RegisterKeybind(pl, new PluginKeybind(pluginSidebarPage.ShortcutKey, () => { - if (!pl.Disabled.Value) btn?.TriggerClick(); + if (!pl.Disabled.Value) btn?.Active(); })); } } @@ -643,9 +620,6 @@ protected override void LoadComplete() Action = () => this.Push(new MvisSongSelect()) }); - //把lockButton放在中间 - bottomBar.CentreBotton(lockButton); - //更新当前音乐控制插件 currentAudioControlProviderSetting.BindValueChanged(v => { @@ -654,9 +628,10 @@ protected override void LoadComplete() changeAudioControlProvider(pl); }, true); - bottomBar.MoveToY(bottomBar.Height + 10).FadeOut(); - progressBar.MoveToY(5); + //todo: 实现切换功能 + changeFunctionBarProvider(null); + currentFunctionBarProvider.Hide(); base.LoadComplete(); } @@ -675,20 +650,33 @@ private void changeAudioControlProvider(IProvideAudioControlPlugin pacp) songSelectButton.Enabled.Value = audioControlProvider == MusicControllerWrapper; } + private void changeFunctionBarProvider(IFunctionBarProvider target) + { + var targetDrawable = overlay.FirstOrDefault(d => d.GetType().IsSubclassOf(typeof(IFunctionBarProvider))); + + if (targetDrawable != null) + overlay.Remove(targetDrawable); + + currentFunctionBarProvider = target ?? legacyBottomBarContainer; + currentFunctionBarProvider.AddFunctionControls(functionProviders); + + overlay.Add((Drawable)currentFunctionBarProvider); + } + private void setupKeyBindings() { - keyBindings[GlobalAction.MvisMusicPrev] = () => prevButton.TriggerClick(); - keyBindings[GlobalAction.MvisMusicNext] = () => nextButton.TriggerClick(); - keyBindings[GlobalAction.MvisOpenInSongSelect] = () => soloButton.TriggerClick(); - keyBindings[GlobalAction.MvisToggleOverlayLock] = () => lockButton.TriggerClick(); - keyBindings[GlobalAction.MvisTogglePluginPage] = () => pluginButton.TriggerClick(); - keyBindings[GlobalAction.MvisTogglePause] = () => songProgressButton.TriggerClick(); - keyBindings[GlobalAction.MvisToggleTrackLoop] = () => loopToggleButton.TriggerClick(); - keyBindings[GlobalAction.MvisTogglePlayList] = () => sidebarToggleButton.TriggerClick(); - keyBindings[GlobalAction.MvisForceLockOverlayChanges] = () => lockChanges.Toggle(); + keyBindings[GlobalAction.MvisMusicPrev] = () => prevButton.Active(); + keyBindings[GlobalAction.MvisMusicNext] = () => nextButton.Active(); + keyBindings[GlobalAction.MvisOpenInSongSelect] = () => soloButton.Active(); + keyBindings[GlobalAction.MvisToggleOverlayLock] = () => lockButton.Active(); + keyBindings[GlobalAction.MvisTogglePluginPage] = () => pluginButton.Active(); + keyBindings[GlobalAction.MvisTogglePause] = () => songProgressButton.Active(); + keyBindings[GlobalAction.MvisToggleTrackLoop] = () => loopToggleButton.Active(); + keyBindings[GlobalAction.MvisTogglePlayList] = () => sidebarToggleButton.Active(); + keyBindings[GlobalAction.MvisForceLockOverlayChanges] = () => disableChangesButton.Active(); keyBindings[GlobalAction.Back] = () => { - if (sidebar.IsPresent && sidebar.IsVisible.Value) + if (sidebar.IsPresent && sidebar.State.Value == Visibility.Visible) { sidebar.Hide(); return; @@ -696,8 +684,8 @@ private void setupKeyBindings() if (OverlaysHidden) { - lockChanges.Value = false; - lockButton.Value.Value = false; + lockButton.Bindable.Disabled = false; + lockButton.Bindable.Value = false; showOverlays(true); } else @@ -718,16 +706,13 @@ private void onPluginUnLoad(MvisPlugin pl) sidebar.Remove(plsp); //移除这个页面 //查找与plsp对应的底栏入口 - foreach (var d in bottomBar.PluginEntriesFillFlow) + foreach (var d in currentFunctionBarProvider.GetAllPluginFunctionButton()) { //同上 - if (d is PluginBottomBarButton btn && btn.Page == plsp) + if (d is IPluginFunctionProvider btn && btn.SourcePage == plsp) { - btn.FadeTo(0.01f, 300, Easing.OutQuint).Then().Schedule(() => - { - btn.Expire(); - bottomBar.CentreBotton(lockButton); - }); + functionProviders.Remove(d); + currentFunctionBarProvider.OnRemove(d); } } } @@ -802,8 +787,6 @@ protected override void Update() base.Update(); trackRunning.Value = CurrentTrack.IsRunning; - progressBar.CurrentTime = CurrentTrack.CurrentTime; - progressBar.EndTime = CurrentTrack.Length; } public override void OnEntering(IScreen last) @@ -821,7 +804,6 @@ public override void OnEntering(IScreen last) //非背景层的动画 foreground.ScaleTo(0f).Then().ScaleTo(1f, duration, Easing.OutQuint); - skinnableForeground.FadeIn(duration, Easing.OutQuint); //触发一次onBeatmapChanged和onTrackRunningToggle Beatmap.BindValueChanged(onBeatmapChanged, true); @@ -840,12 +822,11 @@ public override bool OnExiting(IScreen next) Mods.Value = originalMods; //锁定变更 - lockChanges.Value = true; + lockButton.Bindable.Disabled = true; //非背景层的动画 foreground.ScaleTo(0, duration, Easing.OutQuint); - bottomBar.MoveToY(bottomBar.Height + 10, duration, Easing.OutQuint).FadeOut(duration, Easing.OutExpo); - progressBar.MoveToY(3.5f, duration, Easing.OutQuint).FadeTo(0.1f, duration, Easing.OutExpo); + currentFunctionBarProvider.Hide(); this.FadeOut(500, Easing.OutQuint); @@ -929,8 +910,8 @@ protected override bool OnKeyDown(KeyDownEvent e) //当有弹窗或游戏失去焦点时要进行的动作 protected override void OnHoverLost(HoverLostEvent e) { - if (lockButton.Value.Value && OverlaysHidden) - lockButton.Toggle(); + if (lockButton.Bindable.Value && OverlaysHidden && !lockButton.Bindable.Disabled) + lockButton.Bindable.Toggle(); showOverlays(false); base.OnHoverLost(e); @@ -942,18 +923,13 @@ private void presentBeatmap() => game?.PresentBeatmap(Beatmap.Value.BeatmapSetInfo); private void showPluginEntriesTemporary() => - bottomBar.PluginEntriesFillFlow.FadeIn(500, Easing.OutQuint).Then().Delay(2000).FadeOut(500, Easing.OutQuint); + currentFunctionBarProvider.ShowFunctionControlTemporary(); private void hideOverlays(bool force) { if (!force && !okForHide) return; - skinnableBbBackground.MoveToY(bottomBar.Height, duration, Easing.OutQuint) - .FadeOut(duration, Easing.OutQuint); - - progressBar.MoveToY(4f, duration, Easing.OutQuint); - OverlaysHidden = true; updateIdleVisuals(); OnIdle?.Invoke(); @@ -962,7 +938,7 @@ private void hideOverlays(bool force) private void showOverlays(bool force) { //在有锁并且悬浮界面已隐藏或悬浮界面可见的情况下显示悬浮锁 - if (!force && ((lockButton.Value.Value && OverlaysHidden) || !OverlaysHidden || lockChanges.Value)) + if (!force && ((lockButton.Bindable.Value && OverlaysHidden) || !OverlaysHidden || lockButton.Bindable.Disabled)) { showPluginEntriesTemporary(); return; @@ -970,10 +946,7 @@ private void showOverlays(bool force) foreground.FadeTo(1, duration, Easing.OutQuint); - skinnableBbBackground.MoveToY(0, duration, Easing.OutQuint) - .FadeIn(duration, Easing.OutQuint); - - progressBar.MoveToY(0, duration, Easing.OutQuint); + currentFunctionBarProvider.Show(); OverlaysHidden = false; @@ -1013,7 +986,7 @@ private void updateIdleVisuals() private void applyTrackAdjustments() { CurrentTrack.ResetSpeedAdjustments(); - CurrentTrack.Looping = loopToggleButton.Value.Value; + CurrentTrack.Looping = loopToggleButton.Bindable.Value; CurrentTrack.RestartPoint = 0; CurrentTrack.AddAdjustment(adjustFreq.Value ? AdjustableProperty.Frequency : AdjustableProperty.Tempo, musicSpeed); diff --git a/osu.Game/Screens/Mvis/BottomBar/Buttons/BottomBarButton.cs b/osu.Game/Screens/Mvis/Plugins/Internal/BottomBar/Buttons/BottomBarButton.cs similarity index 89% rename from osu.Game/Screens/Mvis/BottomBar/Buttons/BottomBarButton.cs rename to osu.Game/Screens/Mvis/Plugins/Internal/BottomBar/Buttons/BottomBarButton.cs index 008888bbf7c7..f07270963f15 100644 --- a/osu.Game/Screens/Mvis/BottomBar/Buttons/BottomBarButton.cs +++ b/osu.Game/Screens/Mvis/Plugins/Internal/BottomBar/Buttons/BottomBarButton.cs @@ -4,25 +4,25 @@ using System; using JetBrains.Annotations; using osu.Framework.Allocation; +using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; -using osu.Framework.Graphics.Shapes; -using osu.Framework.Graphics.Sprites; -using osuTK; using osu.Framework.Graphics.Containers; -using osuTK.Graphics; -using osu.Game.Graphics.Sprites; -using osu.Game.Configuration; -using osu.Framework.Graphics.Effects; -using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics.Cursor; +using osu.Framework.Graphics.Effects; +using osu.Framework.Graphics.Shapes; +using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Textures; using osu.Framework.Input.Events; using osu.Framework.Localisation; +using osu.Game.Configuration; using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; -using osu.Game.Skinning; +using osu.Game.Screens.Mvis.Plugins.Types; +using osuTK; +using osuTK.Graphics; -namespace osu.Game.Screens.Mvis.BottomBar.Buttons +namespace osu.Game.Screens.Mvis.Plugins.Internal.BottomBar.Buttons { public class BottomBarButton : CompositeDrawable, IHasTooltip { @@ -31,34 +31,27 @@ public class BottomBarButton : CompositeDrawable, IHasTooltip protected CustomColourProvider ColourProvider => colourProvider; protected FillFlowContainer ContentFillFlow; - protected virtual string BackgroundTextureName => "MButtonSquare-background"; - protected virtual Drawable CreateBackgroundDrawable => new SkinnableSprite(BackgroundTextureName, confineMode: ConfineMode.ScaleToFit) - { - RelativeSizeAxes = Axes.Both, - CentreComponent = false - }; - - protected Box BgBox; - private Box flashBox; - private Container content; - private IconUsage emptyIcon => new IconUsage(); - - public Action Action; - public LocalisableString TooltipText { get; set; } - - public IconUsage ButtonIcon + public IconUsage Icon { get => SpriteIcon.Icon; set => SpriteIcon.Icon = value; } - public LocalisableString Text + public LocalisableString Title { get => SpriteText.Text; set => SpriteText.Text = value; } + protected Box BgBox; + private Box flashBox; + private Container content; + private IconUsage emptyIcon => new IconUsage(); + + public Action Action { get; set; } + public LocalisableString TooltipText { get; set; } + protected readonly OsuSpriteText SpriteText = new OsuSpriteText { Anchor = Anchor.Centre, @@ -79,9 +72,22 @@ public LocalisableString Text set => base.AutoSizeAxes = value; } - public BottomBarButton() + public BottomBarButton(IFunctionProvider provider = null) { Size = new Vector2(30); + + Anchor = Anchor.Centre; + Origin = Anchor.Centre; + + if (provider != null) + { + Action = provider.Action; + Icon = provider.Icon; + SpriteText.Text = provider.Title; + SpriteIcon.Icon = provider.Icon; + TooltipText = provider.Description; + Size = provider.Size; + } } [BackgroundDependencyLoader] @@ -103,14 +109,13 @@ private void load(MConfigManager config) Colour = Color4.Black.Opacity(0.6f), Offset = new Vector2(0, 1.5f) }, - Children = new[] + Children = new Drawable[] { BgBox = new Box { RelativeSizeAxes = Axes.Both, Colour = ColourProvider.Background3 }, - CreateBackgroundDrawable, ContentFillFlow = new FillFlowContainer { Margin = new MarginPadding { Left = 15, Right = 15 }, @@ -132,10 +137,10 @@ private void load(MConfigManager config) new HoverClickSounds() }; - if (!ButtonIcon.Equals(emptyIcon)) + if (!Icon.Equals(emptyIcon)) ContentFillFlow.Add(SpriteIcon); - if (string.IsNullOrEmpty(Text.ToString())) + if (string.IsNullOrEmpty(Title.ToString())) ContentFillFlow.Add(SpriteText); // From OsuAnimatedButton diff --git a/osu.Game/Screens/Mvis/BottomBar/Buttons/BottomBarSwitchButton.cs b/osu.Game/Screens/Mvis/Plugins/Internal/BottomBar/Buttons/BottomBarSwitchButton.cs similarity index 52% rename from osu.Game/Screens/Mvis/BottomBar/Buttons/BottomBarSwitchButton.cs rename to osu.Game/Screens/Mvis/Plugins/Internal/BottomBar/Buttons/BottomBarSwitchButton.cs index 47da93ac2298..fbdb26557808 100644 --- a/osu.Game/Screens/Mvis/BottomBar/Buttons/BottomBarSwitchButton.cs +++ b/osu.Game/Screens/Mvis/Plugins/Internal/BottomBar/Buttons/BottomBarSwitchButton.cs @@ -3,61 +3,51 @@ using osu.Framework.Bindables; using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Game.Skinning; +using osu.Framework.Input.Events; +using osu.Game.Screens.Mvis.Plugins.Types; using osuTK.Graphics; -namespace osu.Game.Screens.Mvis.BottomBar.Buttons +namespace osu.Game.Screens.Mvis.Plugins.Internal.BottomBar.Buttons { public class BottomBarSwitchButton : BottomBarButton { public BindableBool Value = new BindableBool(); - public bool IsCoupled = true; - private SkinnableSprite off; - private SkinnableSprite on; public bool Default { get; set; } - protected override string BackgroundTextureName => "MButtonSwitchOff-background"; - protected virtual string SwitchOnBgTextureName => "MButtonSwitchOn-background"; - protected virtual ConfineMode TextureConfineMode => ConfineMode.ScaleToFit; - protected Color4 ActivateColor => ColourProvider.Highlight1; protected Color4 InActivateColor => ColourProvider.Background3; - protected override Drawable CreateBackgroundDrawable => new Container + public BottomBarSwitchButton(IFunctionProvider provider = null) + : base(provider) { - RelativeSizeAxes = Axes.Both, - Children = new Drawable[] + Value.Value = Default; + + if (provider is IToggleableFunctionProvider toggleableProvider) { - off = new SkinnableSprite(BackgroundTextureName, confineMode: TextureConfineMode) - { - CentreComponent = false, - RelativeSizeAxes = Axes.Both, - Alpha = 0 - }, - on = new SkinnableSprite(SwitchOnBgTextureName, confineMode: TextureConfineMode) - { - CentreComponent = false, - RelativeSizeAxes = Axes.Both, - Alpha = 0 - }, + Value.BindTo(toggleableProvider.Bindable); } - }; + } protected override void LoadComplete() { - Value.Value = Default; - Value.BindValueChanged(_ => updateVisuals(true)); - - updateVisuals(); + Value.BindValueChanged(_ => updateVisuals(true), true); + Value.BindDisabledChanged(onDisabledChanged, true); ColourProvider.HueColour.BindValueChanged(_ => updateVisuals()); base.LoadComplete(); } - protected override bool OnClick(Framework.Input.Events.ClickEvent e) + private void onDisabledChanged(bool disabled) + { + if (disabled) + this.ScaleTo(0.8f, 300, Easing.OutQuint).FadeColour(Color4.Gray, 300, Easing.OutQuint); + else + this.ScaleTo(1, 300, Easing.OutQuint).FadeColour(Color4.White, 300, Easing.OutQuint); + } + + protected override bool OnClick(ClickEvent e) { Toggle(); return base.OnClick(e); @@ -65,7 +55,9 @@ protected override bool OnClick(Framework.Input.Events.ClickEvent e) public void Toggle() { - if (IsCoupled) + if (Value.Disabled) + this.FlashColour(Color4.Red, 1000, Easing.OutQuint); + else Value.Toggle(); } @@ -78,15 +70,11 @@ private void updateVisuals(bool animate = false) case true: BgBox.FadeColour(ActivateColor, duration, Easing.OutQuint); ContentFillFlow.FadeColour(Colour4.Black, duration, Easing.OutQuint); - off?.FadeOut(duration, Easing.OutQuint); - on?.FadeIn(duration, Easing.OutQuint); if (animate) OnToggledOnAnimation(); break; case false: - off?.FadeIn(duration, Easing.OutQuint); - on?.FadeOut(duration, Easing.OutQuint); BgBox.FadeColour(InActivateColor, duration, Easing.OutQuint); ContentFillFlow.FadeColour(Colour4.White, duration, Easing.OutQuint); break; diff --git a/osu.Game/Screens/Mvis/BottomBar/Buttons/SongProgressButton.cs b/osu.Game/Screens/Mvis/Plugins/Internal/BottomBar/Buttons/SongProgressButton.cs similarity index 66% rename from osu.Game/Screens/Mvis/BottomBar/Buttons/SongProgressButton.cs rename to osu.Game/Screens/Mvis/Plugins/Internal/BottomBar/Buttons/SongProgressButton.cs index 97054b7b2d0f..eaff310b3ba3 100644 --- a/osu.Game/Screens/Mvis/BottomBar/Buttons/SongProgressButton.cs +++ b/osu.Game/Screens/Mvis/Plugins/Internal/BottomBar/Buttons/SongProgressButton.cs @@ -2,16 +2,12 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Audio; -using osu.Game.Skinning; +using osu.Game.Screens.Mvis.Plugins.Types; -namespace osu.Game.Screens.Mvis.BottomBar.Buttons +namespace osu.Game.Screens.Mvis.Plugins.Internal.BottomBar.Buttons { public class SongProgressButton : BottomBarSwitchButton { - protected override string BackgroundTextureName => "MButtonProgressOff-background"; - protected override string SwitchOnBgTextureName => "MButtonProgressOn-background"; - protected override ConfineMode TextureConfineMode => ConfineMode.NoScaling; - private string timeCurrent; private string timeTotal; @@ -22,9 +18,9 @@ public class SongProgressButton : BottomBarSwitchButton private string formatTime(TimeSpan timeSpan) => $"{(timeSpan < TimeSpan.Zero ? "-" : "")}{Math.Floor(timeSpan.Duration().TotalMinutes)}:{timeSpan.Duration().Seconds:D2}"; - public SongProgressButton() + public SongProgressButton(IFunctionProvider provider) + : base(provider) { - TooltipText = "切换暂停"; AutoSizeAxes = Axes.X; } @@ -35,7 +31,7 @@ protected override void Update() int currentSecond = (int)Math.Floor(track.CurrentTime / 1000.0); timeCurrent = formatTime(TimeSpan.FromSeconds(currentSecond)); timeTotal = formatTime(TimeSpan.FromMilliseconds(track.Length)); - Text = $"{timeCurrent} / {timeTotal}"; + Title = $"{timeCurrent} / {timeTotal}"; } } } diff --git a/osu.Game/Screens/Mvis/Plugins/Internal/BottomBar/LegacyBottomBar.cs b/osu.Game/Screens/Mvis/Plugins/Internal/BottomBar/LegacyBottomBar.cs new file mode 100644 index 000000000000..997ef19b7ef5 --- /dev/null +++ b/osu.Game/Screens/Mvis/Plugins/Internal/BottomBar/LegacyBottomBar.cs @@ -0,0 +1,179 @@ +using System; +using System.Collections.Generic; +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Game.Screens.Mvis.Plugins.Internal.BottomBar.Buttons; +using osu.Game.Screens.Mvis.Plugins.Types; +using osuTK; + +namespace osu.Game.Screens.Mvis.Plugins.Internal.BottomBar +{ + internal class LegacyBottomBar : MvisPlugin, IFunctionBarProvider + { + protected override Drawable CreateContent() + { + throw new NotImplementedException(); + } + + protected override bool OnContentLoaded(Drawable content) => true; + + protected override bool PostInit() => true; + + public override int Version => 0; + + private readonly FillFlowContainer leftContent; + private readonly FillFlowContainer centreContent; + private readonly FillFlowContainer rightContent; + private readonly FillFlowContainer pluginEntriesFillFlow; + + public LegacyBottomBar() + { + Anchor = Anchor.BottomCentre; + Origin = Anchor.BottomCentre; + RelativeSizeAxes = Axes.X; + AutoSizeAxes = Axes.Y; + AutoSizeDuration = 300; + AutoSizeEasing = Easing.OutQuint; + Margin = new MarginPadding { Bottom = 10 }; + + InternalChildren = new Drawable[] + { + leftContent = new FillFlowContainer + { + Name = "Left Container", + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + AutoSizeAxes = Axes.Both, + Spacing = new Vector2(5), + Margin = new MarginPadding { Left = 5 } + }, + centreContent = new FillFlowContainer + { + Name = "Centre Container", + Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomCentre, + AutoSizeAxes = Axes.Both, + Spacing = new Vector2(5) + }, + rightContent = new FillFlowContainer + { + Name = "Right Container", + Anchor = Anchor.BottomRight, + Origin = Anchor.BottomRight, + AutoSizeAxes = Axes.Both, + Spacing = new Vector2(5), + Margin = new MarginPadding { Right = 5 } + }, + pluginEntriesFillFlow = new FillFlowContainer + { + Name = "Plugin Entries Container", + Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomCentre, + AutoSizeAxes = Axes.Both, + AutoSizeDuration = 300, + AutoSizeEasing = Easing.OutQuint, + Spacing = new Vector2(5), + Margin = new MarginPadding { Bottom = 35 } + } + }; + } + + [BackgroundDependencyLoader] + private void load(MvisScreen mvisScreen) + { + mvisScreen.OnIdle += Hide; + mvisScreen.OnResumeFromIdle += Show; + } + + public float GetSafeAreaPadding() => Height - Y + 10 + 5; + + public override void Show() => + this.MoveToY(0, 300, Easing.OutQuint).FadeIn(300, Easing.OutQuint); + + public override void Hide() => + this.MoveToY(40, 300, Easing.OutQuint); + + public bool OkForHide() => IsHovered; + + private void checkForPluginControls(IFunctionProvider provider) + { + if (provider is IPluginFunctionProvider pluginFunctionProvider) + pluginButtons.Add(pluginFunctionProvider); + } + + public bool AddFunctionControl(IFunctionProvider provider) + { + checkForPluginControls(provider); + + var button = provider is IToggleableFunctionProvider + ? new BottomBarSwitchButton((IToggleableFunctionProvider)provider) + : new BottomBarButton(provider); + + switch (provider.Type) + { + case FunctionType.Audio: + centreContent.Add(button); + break; + + case FunctionType.Base: + leftContent.Add(button); + break; + + case FunctionType.Misc: + rightContent.Add(button); + break; + + case FunctionType.Plugin: + pluginEntriesFillFlow.Add(button); + break; + + case FunctionType.ProgressDisplay: + button.Dispose(); + centreContent.Add(new SongProgressButton(provider)); + break; + + default: + throw new InvalidOperationException("???"); + } + + return true; + } + + public bool AddFunctionControls(List providers) + { + foreach (var provider in providers) + { + AddFunctionControl(provider); + } + + return true; + } + + public bool SetFunctionControls(List providers) + { + leftContent.Clear(); + centreContent.Clear(); + rightContent.Clear(); + pluginEntriesFillFlow.Clear(); + + return AddFunctionControls(providers); + } + + private readonly List pluginButtons = new List(); + + public void OnRemove(IFunctionBarProvider provider) + { + throw new NotImplementedException(); + } + + public void OnRemove(IPluginFunctionProvider provider) + { + pluginButtons.Remove(provider); + } + + public void ShowFunctionControlTemporary() => pluginEntriesFillFlow.FadeIn(500, Easing.OutQuint).Then().Delay(2000).FadeOut(500, Easing.OutQuint); + + public List GetAllPluginFunctionButton() => pluginButtons; + } +} diff --git a/osu.Game/Screens/Mvis/BottomBar/SongProgressBar.cs b/osu.Game/Screens/Mvis/Plugins/Internal/BottomBar/SongProgressBar.cs similarity index 100% rename from osu.Game/Screens/Mvis/BottomBar/SongProgressBar.cs rename to osu.Game/Screens/Mvis/Plugins/Internal/BottomBar/SongProgressBar.cs diff --git a/osu.Game/Screens/Mvis/Plugins/MvisPlugin.cs b/osu.Game/Screens/Mvis/Plugins/MvisPlugin.cs index 47d6c5d20886..3683903ab9b3 100644 --- a/osu.Game/Screens/Mvis/Plugins/MvisPlugin.cs +++ b/osu.Game/Screens/Mvis/Plugins/MvisPlugin.cs @@ -238,7 +238,8 @@ public enum PluginFlags public enum TargetLayer { Background, - Foreground + Foreground, + FunctionBar } protected override void Dispose(bool isDisposing) diff --git a/osu.Game/Screens/Mvis/Plugins/PluginBottomBarButton.cs b/osu.Game/Screens/Mvis/Plugins/PluginBottomBarButton.cs deleted file mode 100644 index 07e252c7eec8..000000000000 --- a/osu.Game/Screens/Mvis/Plugins/PluginBottomBarButton.cs +++ /dev/null @@ -1,14 +0,0 @@ -using osu.Game.Screens.Mvis.BottomBar.Buttons; - -namespace osu.Game.Screens.Mvis.Plugins -{ - public class PluginBottomBarButton : BottomBarButton - { - public readonly PluginSidebarPage Page; - - public PluginBottomBarButton(PluginSidebarPage page) - { - Page = page; - } - } -} diff --git a/osu.Game/Screens/Mvis/Plugins/PluginSidebarPage.cs b/osu.Game/Screens/Mvis/Plugins/PluginSidebarPage.cs index aefaa63d036e..0789d1f4ab5e 100644 --- a/osu.Game/Screens/Mvis/Plugins/PluginSidebarPage.cs +++ b/osu.Game/Screens/Mvis/Plugins/PluginSidebarPage.cs @@ -5,6 +5,7 @@ using osu.Framework.Logging; using osu.Game.Online.Placeholders; using osu.Game.Screens.Mvis.Plugins.Config; +using osu.Game.Screens.Mvis.Plugins.Types; using osu.Game.Screens.Mvis.SideBar; using osuTK; using osuTK.Input; @@ -22,7 +23,7 @@ protected virtual void InitContent(MvisPlugin plugin) { } - public virtual PluginBottomBarButton CreateBottomBarButton() => null; + public virtual IPluginFunctionProvider GetFunctionEntry() => null; public virtual Key ShortcutKey => Key.Unknown; private bool contentInit; diff --git a/osu.Game/Screens/Mvis/Plugins/Types/FakeButton.cs b/osu.Game/Screens/Mvis/Plugins/Types/FakeButton.cs new file mode 100644 index 000000000000..5f950b52efad --- /dev/null +++ b/osu.Game/Screens/Mvis/Plugins/Types/FakeButton.cs @@ -0,0 +1,22 @@ +using System; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Localisation; +using osuTK; + +namespace osu.Game.Screens.Mvis.Plugins.Types +{ + public class FakeButton : IFunctionProvider + { + public Vector2 Size { get; set; } = new Vector2(30); + public Action Action { get; set; } + public IconUsage Icon { get; set; } + public LocalisableString Title { get; set; } + public LocalisableString Description { get; set; } + public FunctionType Type { get; set; } + + public void Active() + { + Action?.Invoke(); + } + } +} diff --git a/osu.Game/Screens/Mvis/Plugins/Types/IFunctionBarProvider.cs b/osu.Game/Screens/Mvis/Plugins/Types/IFunctionBarProvider.cs new file mode 100644 index 000000000000..59f01bcb5fcd --- /dev/null +++ b/osu.Game/Screens/Mvis/Plugins/Types/IFunctionBarProvider.cs @@ -0,0 +1,68 @@ +using System.Collections.Generic; +using osu.Framework.Graphics; + +namespace osu.Game.Screens.Mvis.Plugins.Types +{ + public interface IFunctionBarProvider : IDrawable + { + /// + /// 用于确定附加层(Overlay)安全区的底部Padding + /// + /// 底部Padding + public float GetSafeAreaPadding(); + + /// + /// 是否允许播放器隐藏界面 + /// + /// + /// true: 可以隐藏 + /// false: 不能隐藏 + /// + public bool OkForHide(); + + /// + /// 设置功能控制 + /// + /// + /// + /// true: 没有问题 + /// false: 出现问题或按钮重复 + /// + public bool AddFunctionControl(IFunctionProvider provider); + + /// + /// 添加一些控制按钮 + /// + /// + /// + /// true: 没有问题 + /// false: 出现问题或按钮重复 + /// + public bool AddFunctionControls(List providers); + + /// + /// 设置一些控制按钮 + /// + /// + /// + /// true: 没有问题 + /// false: 出现问题或按钮重复 + /// + public bool SetFunctionControls(List providers); + + + public void OnRemove(IFunctionBarProvider provider); + public void OnRemove(IPluginFunctionProvider provider); + + /// + /// 临时显示功能控制按钮 + /// + public void ShowFunctionControlTemporary(); + + /// + /// 获取所有插件按钮 + /// + /// 插件按钮列表 + public List GetAllPluginFunctionButton(); + } +} diff --git a/osu.Game/Screens/Mvis/Plugins/Types/IFunctionProvider.cs b/osu.Game/Screens/Mvis/Plugins/Types/IFunctionProvider.cs new file mode 100644 index 000000000000..f755c84b03c3 --- /dev/null +++ b/osu.Game/Screens/Mvis/Plugins/Types/IFunctionProvider.cs @@ -0,0 +1,43 @@ +using System; +using osu.Framework.Bindables; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Localisation; +using osuTK; + +namespace osu.Game.Screens.Mvis.Plugins.Types +{ + public interface IFunctionProvider + { + public Vector2 Size { get; set; } + public Action Action { get; set; } + + public IconUsage Icon { get; set; } + + public LocalisableString Title { get; set; } + + public LocalisableString Description { get; set; } + + public FunctionType Type { get; set; } + + public void Active(); + } + + public interface IToggleableFunctionProvider : IFunctionProvider + { + public BindableBool Bindable { get; set; } + } + + public interface IPluginFunctionProvider : IFunctionProvider + { + public PluginSidebarPage SourcePage { get; set; } + } + + public enum FunctionType + { + Base, + Audio, + Plugin, + Misc, + ProgressDisplay + } +} diff --git a/osu.Game/Screens/Mvis/Plugins/Types/ToggleableFakeButton.cs b/osu.Game/Screens/Mvis/Plugins/Types/ToggleableFakeButton.cs new file mode 100644 index 000000000000..a05c5b8a7b42 --- /dev/null +++ b/osu.Game/Screens/Mvis/Plugins/Types/ToggleableFakeButton.cs @@ -0,0 +1,37 @@ +using System; +using osu.Framework.Bindables; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Localisation; +using osu.Framework.Logging; +using osuTK; + +namespace osu.Game.Screens.Mvis.Plugins.Types +{ + public class ToggleableFakeButton : IToggleableFunctionProvider + { + public Vector2 Size { get; set; } = new Vector2(30); + public Action Action { get; set; } + public IconUsage Icon { get; set; } + public LocalisableString Title { get; set; } + public LocalisableString Description { get; set; } + public FunctionType Type { get; set; } + + public void Active() + { + if (!Bindable.Disabled) + Bindable.Toggle(); + else + Logger.Log($"无法更改 \"{Title}\" 的值, 因为此Bindable已禁用", level: LogLevel.Important); + } + + public void Active(bool performAction) + { + if (performAction) + Action?.Invoke(); + else + Active(); + } + + public BindableBool Bindable { get; set; } = new BindableBool(); + } +} diff --git a/osu.Game/Screens/Mvis/SideBar/Sidebar.cs b/osu.Game/Screens/Mvis/SideBar/Sidebar.cs index 80c478f6b96b..b03d2ff948c6 100644 --- a/osu.Game/Screens/Mvis/SideBar/Sidebar.cs +++ b/osu.Game/Screens/Mvis/SideBar/Sidebar.cs @@ -28,7 +28,6 @@ internal class Sidebar : VisibilityContainer private const float duration = 400; private TabControlItem prevTab; - public BindableBool IsVisible = new BindableBool(); public Bindable CurrentDisplay = new Bindable(); private readonly Container contentContainer; @@ -123,7 +122,7 @@ public void ShowComponent(Drawable d, bool allowHide = false) if (CurrentDisplay.Value == d) { //如果要显示的是当前正在显示的内容,则中断 - if (IsVisible.Value) + if (State.Value == Visibility.Visible) { if (allowHide) Hide(); @@ -205,8 +204,6 @@ protected override void PopOut() .MoveToY(70, duration, Easing.OutQuint); prevTab?.MakeInActive(); - - IsVisible.Value = false; } protected override void PopIn() @@ -219,8 +216,6 @@ protected override void PopIn() contentContainer.FadeIn(duration, Easing.OutQuint) .MoveToY(0, duration, Easing.OutQuint); - - IsVisible.Value = true; } } } diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index cd34036311e7..7e2efbbcb774 100755 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -46,4 +46,7 @@ + + + From d3aab59aa74d7ac35a1a36269e75d8f2ddb08ce3 Mon Sep 17 00:00:00 2001 From: MATRIX-feather Date: Wed, 11 Aug 2021 18:58:54 +0800 Subject: [PATCH 2/8] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E9=81=97=E7=95=99?= =?UTF-8?q?bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- osu.Game/Screens/Mvis/MvisScreen.cs | 7 +- .../BottomBar/Buttons/BottomBarButton.cs | 3 + .../Buttons/BottomBarSwitchButton.cs | 5 +- .../Internal/BottomBar/LegacyBottomBar.cs | 170 ++++++++++++------ .../Plugins/Types/IFunctionBarProvider.cs | 4 +- .../Mvis/Plugins/Types/IFunctionProvider.cs | 2 + 6 files changed, 131 insertions(+), 60 deletions(-) diff --git a/osu.Game/Screens/Mvis/MvisScreen.cs b/osu.Game/Screens/Mvis/MvisScreen.cs index c2fa6dadf2b9..a2b60f073823 100644 --- a/osu.Game/Screens/Mvis/MvisScreen.cs +++ b/osu.Game/Screens/Mvis/MvisScreen.cs @@ -658,7 +658,7 @@ private void changeFunctionBarProvider(IFunctionBarProvider target) overlay.Remove(targetDrawable); currentFunctionBarProvider = target ?? legacyBottomBarContainer; - currentFunctionBarProvider.AddFunctionControls(functionProviders); + currentFunctionBarProvider.SetFunctionControls(functionProviders); overlay.Add((Drawable)currentFunctionBarProvider); } @@ -670,7 +670,7 @@ private void setupKeyBindings() keyBindings[GlobalAction.MvisOpenInSongSelect] = () => soloButton.Active(); keyBindings[GlobalAction.MvisToggleOverlayLock] = () => lockButton.Active(); keyBindings[GlobalAction.MvisTogglePluginPage] = () => pluginButton.Active(); - keyBindings[GlobalAction.MvisTogglePause] = () => songProgressButton.Active(); + keyBindings[GlobalAction.MvisTogglePause] = () => songProgressButton.Active(true); keyBindings[GlobalAction.MvisToggleTrackLoop] = () => loopToggleButton.Active(); keyBindings[GlobalAction.MvisTogglePlayList] = () => sidebarToggleButton.Active(); keyBindings[GlobalAction.MvisForceLockOverlayChanges] = () => disableChangesButton.Active(); @@ -712,7 +712,8 @@ private void onPluginUnLoad(MvisPlugin pl) if (d is IPluginFunctionProvider btn && btn.SourcePage == plsp) { functionProviders.Remove(d); - currentFunctionBarProvider.OnRemove(d); + currentFunctionBarProvider.Remove(d); + break; } } } diff --git a/osu.Game/Screens/Mvis/Plugins/Internal/BottomBar/Buttons/BottomBarButton.cs b/osu.Game/Screens/Mvis/Plugins/Internal/BottomBar/Buttons/BottomBarButton.cs index f07270963f15..1b8daf6f9e2a 100644 --- a/osu.Game/Screens/Mvis/Plugins/Internal/BottomBar/Buttons/BottomBarButton.cs +++ b/osu.Game/Screens/Mvis/Plugins/Internal/BottomBar/Buttons/BottomBarButton.cs @@ -72,6 +72,8 @@ public LocalisableString Title set => base.AutoSizeAxes = value; } + public readonly IFunctionProvider Provider; + public BottomBarButton(IFunctionProvider provider = null) { Size = new Vector2(30); @@ -87,6 +89,7 @@ public BottomBarButton(IFunctionProvider provider = null) SpriteIcon.Icon = provider.Icon; TooltipText = provider.Description; Size = provider.Size; + Provider = provider; } } diff --git a/osu.Game/Screens/Mvis/Plugins/Internal/BottomBar/Buttons/BottomBarSwitchButton.cs b/osu.Game/Screens/Mvis/Plugins/Internal/BottomBar/Buttons/BottomBarSwitchButton.cs index fbdb26557808..3b12be30586d 100644 --- a/osu.Game/Screens/Mvis/Plugins/Internal/BottomBar/Buttons/BottomBarSwitchButton.cs +++ b/osu.Game/Screens/Mvis/Plugins/Internal/BottomBar/Buttons/BottomBarSwitchButton.cs @@ -41,10 +41,7 @@ protected override void LoadComplete() private void onDisabledChanged(bool disabled) { - if (disabled) - this.ScaleTo(0.8f, 300, Easing.OutQuint).FadeColour(Color4.Gray, 300, Easing.OutQuint); - else - this.ScaleTo(1, 300, Easing.OutQuint).FadeColour(Color4.White, 300, Easing.OutQuint); + this.FadeColour(disabled ? Color4.Gray : Color4.White, 300, Easing.OutQuint); } protected override bool OnClick(ClickEvent e) diff --git a/osu.Game/Screens/Mvis/Plugins/Internal/BottomBar/LegacyBottomBar.cs b/osu.Game/Screens/Mvis/Plugins/Internal/BottomBar/LegacyBottomBar.cs index 997ef19b7ef5..df0e4044778c 100644 --- a/osu.Game/Screens/Mvis/Plugins/Internal/BottomBar/LegacyBottomBar.cs +++ b/osu.Game/Screens/Mvis/Plugins/Internal/BottomBar/LegacyBottomBar.cs @@ -1,8 +1,10 @@ using System; using System.Collections.Generic; +using System.Linq; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Game.Screens.Mvis.BottomBar; using osu.Game.Screens.Mvis.Plugins.Internal.BottomBar.Buttons; using osu.Game.Screens.Mvis.Plugins.Types; using osuTK; @@ -22,10 +24,16 @@ protected override Drawable CreateContent() public override int Version => 0; - private readonly FillFlowContainer leftContent; - private readonly FillFlowContainer centreContent; - private readonly FillFlowContainer rightContent; - private readonly FillFlowContainer pluginEntriesFillFlow; + private readonly FillFlowContainer leftContent; + private readonly FillFlowContainer centreContent; + private readonly FillFlowContainer rightContent; + private readonly FillFlowContainer pluginEntriesFillFlow; + + private readonly SongProgressBar progressBar; + private readonly Container contentContainer; + + [Resolved] + private MvisScreen mvisScreen { get; set; } public LegacyBottomBar() { @@ -33,49 +41,60 @@ public LegacyBottomBar() Origin = Anchor.BottomCentre; RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; - AutoSizeDuration = 300; - AutoSizeEasing = Easing.OutQuint; - Margin = new MarginPadding { Bottom = 10 }; InternalChildren = new Drawable[] { - leftContent = new FillFlowContainer - { - Name = "Left Container", - Anchor = Anchor.BottomLeft, - Origin = Anchor.BottomLeft, - AutoSizeAxes = Axes.Both, - Spacing = new Vector2(5), - Margin = new MarginPadding { Left = 5 } - }, - centreContent = new FillFlowContainer + contentContainer = new Container { - Name = "Centre Container", Anchor = Anchor.BottomCentre, Origin = Anchor.BottomCentre, - AutoSizeAxes = Axes.Both, - Spacing = new Vector2(5) - }, - rightContent = new FillFlowContainer - { - Name = "Right Container", - Anchor = Anchor.BottomRight, - Origin = Anchor.BottomRight, - AutoSizeAxes = Axes.Both, - Spacing = new Vector2(5), - Margin = new MarginPadding { Right = 5 } - }, - pluginEntriesFillFlow = new FillFlowContainer - { - Name = "Plugin Entries Container", - Anchor = Anchor.BottomCentre, - Origin = Anchor.BottomCentre, - AutoSizeAxes = Axes.Both, + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, AutoSizeDuration = 300, AutoSizeEasing = Easing.OutQuint, - Spacing = new Vector2(5), - Margin = new MarginPadding { Bottom = 35 } - } + Children = new Drawable[] + { + leftContent = new FillFlowContainer + { + Name = "Left Container", + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + AutoSizeAxes = Axes.Both, + Spacing = new Vector2(5), + Margin = new MarginPadding { Left = 5, Bottom = 10 } + }, + centreContent = new FillFlowContainer + { + Name = "Centre Container", + Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomCentre, + AutoSizeAxes = Axes.Both, + Spacing = new Vector2(5), + Margin = new MarginPadding { Bottom = 10 } + }, + rightContent = new FillFlowContainer + { + Name = "Right Container", + Anchor = Anchor.BottomRight, + Origin = Anchor.BottomRight, + AutoSizeAxes = Axes.Both, + Spacing = new Vector2(5), + Margin = new MarginPadding { Right = 5, Bottom = 10 } + }, + pluginEntriesFillFlow = new FillFlowContainer + { + Name = "Plugin Entries Container", + Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomCentre, + AutoSizeAxes = Axes.Both, + AutoSizeDuration = 300, + AutoSizeEasing = Easing.OutQuint, + Spacing = new Vector2(5), + Margin = new MarginPadding { Bottom = 35 + 10 } + }, + } + }, + progressBar = new SongProgressBar() }; } @@ -84,15 +103,30 @@ private void load(MvisScreen mvisScreen) { mvisScreen.OnIdle += Hide; mvisScreen.OnResumeFromIdle += Show; + + progressBar.OnSeek = mvisScreen.SeekTo; } - public float GetSafeAreaPadding() => Height - Y + 10 + 5; + protected override void Update() + { + progressBar.CurrentTime = mvisScreen.CurrentTrack.CurrentTime; + progressBar.EndTime = mvisScreen.CurrentTrack.Length; + base.Update(); + } + + public float GetSafeAreaPadding() => contentContainer.Height - contentContainer.Y; - public override void Show() => - this.MoveToY(0, 300, Easing.OutQuint).FadeIn(300, Easing.OutQuint); + public override void Show() + { + contentContainer.MoveToY(0, 300, Easing.OutQuint); + progressBar.MoveToY(0, 300, Easing.OutQuint); + } - public override void Hide() => - this.MoveToY(40, 300, Easing.OutQuint); + public override void Hide() + { + contentContainer.MoveToY(40, 300, Easing.OutQuint); + progressBar.MoveToY(4f, 300, Easing.OutQuint); + } public bool OkForHide() => IsHovered; @@ -162,18 +196,54 @@ public bool SetFunctionControls(List providers) private readonly List pluginButtons = new List(); - public void OnRemove(IFunctionBarProvider provider) + public void Remove(IFunctionProvider provider) { - throw new NotImplementedException(); - } + BottomBarButton target; - public void OnRemove(IPluginFunctionProvider provider) - { - pluginButtons.Remove(provider); + switch (provider.Type) + { + case FunctionType.ProgressDisplay: + case FunctionType.Audio: + target = centreContent.FirstOrDefault(b => b.Provider == provider); + break; + + case FunctionType.Base: + target = leftContent.FirstOrDefault(b => b.Provider == provider); + break; + + case FunctionType.Misc: + target = rightContent.FirstOrDefault(b => b.Provider == provider); + break; + + case FunctionType.Plugin: + target = pluginEntriesFillFlow.FirstOrDefault(b => b.Provider == provider); + break; + + default: + throw new InvalidOperationException("???"); + } + + if (target != null) + { + target.Expire(); + + if (provider is IPluginFunctionProvider pluginFunctionProvider) + pluginButtons.Remove(pluginFunctionProvider); + } + else + throw new ButtonNotFoundException(provider); } public void ShowFunctionControlTemporary() => pluginEntriesFillFlow.FadeIn(500, Easing.OutQuint).Then().Delay(2000).FadeOut(500, Easing.OutQuint); public List GetAllPluginFunctionButton() => pluginButtons; + + public class ButtonNotFoundException : Exception + { + public ButtonNotFoundException(IFunctionProvider provider) + : base($"无法找到与{provider.ToString()}对应的按钮") + { + } + } } } diff --git a/osu.Game/Screens/Mvis/Plugins/Types/IFunctionBarProvider.cs b/osu.Game/Screens/Mvis/Plugins/Types/IFunctionBarProvider.cs index 59f01bcb5fcd..bd09e60f7f4a 100644 --- a/osu.Game/Screens/Mvis/Plugins/Types/IFunctionBarProvider.cs +++ b/osu.Game/Screens/Mvis/Plugins/Types/IFunctionBarProvider.cs @@ -50,9 +50,7 @@ public interface IFunctionBarProvider : IDrawable /// public bool SetFunctionControls(List providers); - - public void OnRemove(IFunctionBarProvider provider); - public void OnRemove(IPluginFunctionProvider provider); + public void Remove(IFunctionProvider provider); /// /// 临时显示功能控制按钮 diff --git a/osu.Game/Screens/Mvis/Plugins/Types/IFunctionProvider.cs b/osu.Game/Screens/Mvis/Plugins/Types/IFunctionProvider.cs index f755c84b03c3..c88df8e3a635 100644 --- a/osu.Game/Screens/Mvis/Plugins/Types/IFunctionProvider.cs +++ b/osu.Game/Screens/Mvis/Plugins/Types/IFunctionProvider.cs @@ -20,6 +20,8 @@ public interface IFunctionProvider public FunctionType Type { get; set; } public void Active(); + + public string ToString() => $"{Title} - {Description}"; } public interface IToggleableFunctionProvider : IFunctionProvider From d6669a5804aa015cfb1161edf313c82668088a6d Mon Sep 17 00:00:00 2001 From: MATRIX-feather Date: Wed, 11 Aug 2021 20:00:13 +0800 Subject: [PATCH 3/8] wip, do not push --- Mvis.Plugin.BottomBar/BottomBarProvider.cs | 9 ++ .../Buttons/BottomBarButton.cs | 6 +- .../Buttons/BottomBarSwitchButton.cs | 5 +- .../Buttons/SongProgressButton.cs | 3 +- .../LegacyBottomBar.cs | 18 ++- .../Mvis.Plugin.BottomBar.csproj | 17 +++ .../SongProgressBar.cs | 5 +- osu.Android/osu.Android.csproj | 1 + osu.Desktop.slnf | 1 + osu.Desktop/osu.Desktop.csproj | 1 + osu.Game/Configuration/MConfigManager.cs | 4 +- osu.Game/Screens/Mvis/MvisScreen.cs | 9 +- .../FallbackFunctionBar/FunctionBar.cs | 113 ++++++++++++++++++ .../FallbackFunctionBar/SimpleBarButton.cs | 71 +++++++++++ .../ToggleableBarButton.cs | 66 ++++++++++ .../Screens/Mvis/Plugins/MvisPluginManager.cs | 7 +- osu.Game/osu.Game.csproj | 3 - osu.sln | 14 +++ 18 files changed, 327 insertions(+), 26 deletions(-) create mode 100644 Mvis.Plugin.BottomBar/BottomBarProvider.cs rename {osu.Game/Screens/Mvis/Plugins/Internal/BottomBar => Mvis.Plugin.BottomBar}/Buttons/BottomBarButton.cs (97%) rename {osu.Game/Screens/Mvis/Plugins/Internal/BottomBar => Mvis.Plugin.BottomBar}/Buttons/BottomBarSwitchButton.cs (91%) rename {osu.Game/Screens/Mvis/Plugins/Internal/BottomBar => Mvis.Plugin.BottomBar}/Buttons/SongProgressButton.cs (94%) rename {osu.Game/Screens/Mvis/Plugins/Internal/BottomBar => Mvis.Plugin.BottomBar}/LegacyBottomBar.cs (95%) create mode 100644 Mvis.Plugin.BottomBar/Mvis.Plugin.BottomBar.csproj rename {osu.Game/Screens/Mvis/Plugins/Internal/BottomBar => Mvis.Plugin.BottomBar}/SongProgressBar.cs (98%) create mode 100644 osu.Game/Screens/Mvis/Plugins/Internal/FallbackFunctionBar/FunctionBar.cs create mode 100644 osu.Game/Screens/Mvis/Plugins/Internal/FallbackFunctionBar/SimpleBarButton.cs create mode 100644 osu.Game/Screens/Mvis/Plugins/Internal/FallbackFunctionBar/ToggleableBarButton.cs diff --git a/Mvis.Plugin.BottomBar/BottomBarProvider.cs b/Mvis.Plugin.BottomBar/BottomBarProvider.cs new file mode 100644 index 000000000000..4ad6423b296e --- /dev/null +++ b/Mvis.Plugin.BottomBar/BottomBarProvider.cs @@ -0,0 +1,9 @@ +using osu.Game.Screens.Mvis.Plugins; + +namespace Mvis.Plugin.BottomBar +{ + public class BottomBarProvider : MvisPluginProvider + { + public override MvisPlugin CreatePlugin => new LegacyBottomBar(); + } +} diff --git a/osu.Game/Screens/Mvis/Plugins/Internal/BottomBar/Buttons/BottomBarButton.cs b/Mvis.Plugin.BottomBar/Buttons/BottomBarButton.cs similarity index 97% rename from osu.Game/Screens/Mvis/Plugins/Internal/BottomBar/Buttons/BottomBarButton.cs rename to Mvis.Plugin.BottomBar/Buttons/BottomBarButton.cs index 1b8daf6f9e2a..c30ee17b93ac 100644 --- a/osu.Game/Screens/Mvis/Plugins/Internal/BottomBar/Buttons/BottomBarButton.cs +++ b/Mvis.Plugin.BottomBar/Buttons/BottomBarButton.cs @@ -1,6 +1,3 @@ -// 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 JetBrains.Annotations; using osu.Framework.Allocation; @@ -18,11 +15,12 @@ using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; +using osu.Game.Screens.Mvis; using osu.Game.Screens.Mvis.Plugins.Types; using osuTK; using osuTK.Graphics; -namespace osu.Game.Screens.Mvis.Plugins.Internal.BottomBar.Buttons +namespace Mvis.Plugin.BottomBar.Buttons { public class BottomBarButton : CompositeDrawable, IHasTooltip { diff --git a/osu.Game/Screens/Mvis/Plugins/Internal/BottomBar/Buttons/BottomBarSwitchButton.cs b/Mvis.Plugin.BottomBar/Buttons/BottomBarSwitchButton.cs similarity index 91% rename from osu.Game/Screens/Mvis/Plugins/Internal/BottomBar/Buttons/BottomBarSwitchButton.cs rename to Mvis.Plugin.BottomBar/Buttons/BottomBarSwitchButton.cs index 3b12be30586d..dc6df7135e5c 100644 --- a/osu.Game/Screens/Mvis/Plugins/Internal/BottomBar/Buttons/BottomBarSwitchButton.cs +++ b/Mvis.Plugin.BottomBar/Buttons/BottomBarSwitchButton.cs @@ -1,13 +1,10 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. -// See the LICENCE file in the repository root for full licence text. - using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Input.Events; using osu.Game.Screens.Mvis.Plugins.Types; using osuTK.Graphics; -namespace osu.Game.Screens.Mvis.Plugins.Internal.BottomBar.Buttons +namespace Mvis.Plugin.BottomBar.Buttons { public class BottomBarSwitchButton : BottomBarButton { diff --git a/osu.Game/Screens/Mvis/Plugins/Internal/BottomBar/Buttons/SongProgressButton.cs b/Mvis.Plugin.BottomBar/Buttons/SongProgressButton.cs similarity index 94% rename from osu.Game/Screens/Mvis/Plugins/Internal/BottomBar/Buttons/SongProgressButton.cs rename to Mvis.Plugin.BottomBar/Buttons/SongProgressButton.cs index eaff310b3ba3..2ce77d9fe0f3 100644 --- a/osu.Game/Screens/Mvis/Plugins/Internal/BottomBar/Buttons/SongProgressButton.cs +++ b/Mvis.Plugin.BottomBar/Buttons/SongProgressButton.cs @@ -2,9 +2,10 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Audio; +using osu.Game.Screens.Mvis; using osu.Game.Screens.Mvis.Plugins.Types; -namespace osu.Game.Screens.Mvis.Plugins.Internal.BottomBar.Buttons +namespace Mvis.Plugin.BottomBar.Buttons { public class SongProgressButton : BottomBarSwitchButton { diff --git a/osu.Game/Screens/Mvis/Plugins/Internal/BottomBar/LegacyBottomBar.cs b/Mvis.Plugin.BottomBar/LegacyBottomBar.cs similarity index 95% rename from osu.Game/Screens/Mvis/Plugins/Internal/BottomBar/LegacyBottomBar.cs rename to Mvis.Plugin.BottomBar/LegacyBottomBar.cs index df0e4044778c..8b610f2a62db 100644 --- a/osu.Game/Screens/Mvis/Plugins/Internal/BottomBar/LegacyBottomBar.cs +++ b/Mvis.Plugin.BottomBar/LegacyBottomBar.cs @@ -1,15 +1,16 @@ using System; using System.Collections.Generic; using System.Linq; +using Mvis.Plugin.BottomBar.Buttons; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Game.Screens.Mvis.BottomBar; -using osu.Game.Screens.Mvis.Plugins.Internal.BottomBar.Buttons; +using osu.Game.Screens.Mvis; +using osu.Game.Screens.Mvis.Plugins; using osu.Game.Screens.Mvis.Plugins.Types; using osuTK; -namespace osu.Game.Screens.Mvis.Plugins.Internal.BottomBar +namespace Mvis.Plugin.BottomBar { internal class LegacyBottomBar : MvisPlugin, IFunctionBarProvider { @@ -22,8 +23,6 @@ protected override Drawable CreateContent() protected override bool PostInit() => true; - public override int Version => 0; - private readonly FillFlowContainer leftContent; private readonly FillFlowContainer centreContent; private readonly FillFlowContainer rightContent; @@ -35,8 +34,17 @@ protected override Drawable CreateContent() [Resolved] private MvisScreen mvisScreen { get; set; } + public override int Version => 6; + + public override TargetLayer Target => TargetLayer.FunctionBar; + public LegacyBottomBar() { + Name = "功能条"; + Description = "mf-osu默认功能条"; + Author = "MATRIX-夜翎"; + Depth = -1; + Anchor = Anchor.BottomCentre; Origin = Anchor.BottomCentre; RelativeSizeAxes = Axes.X; diff --git a/Mvis.Plugin.BottomBar/Mvis.Plugin.BottomBar.csproj b/Mvis.Plugin.BottomBar/Mvis.Plugin.BottomBar.csproj new file mode 100644 index 000000000000..e8741ef45e78 --- /dev/null +++ b/Mvis.Plugin.BottomBar/Mvis.Plugin.BottomBar.csproj @@ -0,0 +1,17 @@ + + + netstandard2.1 + Library + true + ExamplePlugin + + + + + + + + + + + diff --git a/osu.Game/Screens/Mvis/Plugins/Internal/BottomBar/SongProgressBar.cs b/Mvis.Plugin.BottomBar/SongProgressBar.cs similarity index 98% rename from osu.Game/Screens/Mvis/Plugins/Internal/BottomBar/SongProgressBar.cs rename to Mvis.Plugin.BottomBar/SongProgressBar.cs index ff9860ab54f1..425b213e3996 100644 --- a/osu.Game/Screens/Mvis/Plugins/Internal/BottomBar/SongProgressBar.cs +++ b/Mvis.Plugin.BottomBar/SongProgressBar.cs @@ -3,9 +3,10 @@ using osu.Framework.Graphics; using osu.Framework.Input.Events; using osu.Game.Graphics.UserInterface; +using osu.Game.Screens.Mvis; using osu.Game.Screens.Mvis.Misc; -namespace osu.Game.Screens.Mvis.BottomBar +namespace Mvis.Plugin.BottomBar { public class SongProgressBar : ProgressBar { @@ -89,9 +90,11 @@ protected override void UpdateValue(float value) fill.Width = value; if (mvisScreen.OverlaysHidden) + { songProgressIndicator.MoveToX( getFinalPosX(songProgressIndicator, (value * UsableWidth) - (songProgressIndicator.Width / 2)), 300, Easing.OutQuint); + } } private bool indicatorsOverlaps; diff --git a/osu.Android/osu.Android.csproj b/osu.Android/osu.Android.csproj index b2599535aea3..5984b209f179 100755 --- a/osu.Android/osu.Android.csproj +++ b/osu.Android/osu.Android.csproj @@ -54,6 +54,7 @@ {2a66dd92-adb1-4994-89e2-c94e04acda0d} osu.Game + diff --git a/osu.Desktop.slnf b/osu.Desktop.slnf index dd94d9860397..2e0ee0d4d4f8 100644 --- a/osu.Desktop.slnf +++ b/osu.Desktop.slnf @@ -23,6 +23,7 @@ "Mvis.Plugin.CloudMusicSupport\\Mvis.Plugin.CloudMusicSupport.csproj", "Mvis.Plugin.SandboxToPanel\\Mvis.Plugin.SandboxToPanel.csproj", "Mvis.Plugin.FakeEditor\\Mvis.Plugin.FakeEditor.csproj", + "Mvis.Plugin.BottomBar\\Mvis.Plugin.BottomBar.csproj", "..\\osu-framework\\osu.Framework\\osu.Framework.csproj", "..\\osu-framework\\osu.Framework.NativeLibs\\osu.Framework.NativeLibs.csproj", "Templates\\Rulesets\\ruleset-empty\\osu.Game.Rulesets.EmptyFreeform\\osu.Game.Rulesets.EmptyFreeform.csproj", diff --git a/osu.Desktop/osu.Desktop.csproj b/osu.Desktop/osu.Desktop.csproj index 6ed40dae8fd2..6b7dedc7c290 100755 --- a/osu.Desktop/osu.Desktop.csproj +++ b/osu.Desktop/osu.Desktop.csproj @@ -28,6 +28,7 @@ + diff --git a/osu.Game/Configuration/MConfigManager.cs b/osu.Game/Configuration/MConfigManager.cs index 4c778741a453..c5c5ba935078 100644 --- a/osu.Game/Configuration/MConfigManager.cs +++ b/osu.Game/Configuration/MConfigManager.cs @@ -55,6 +55,7 @@ protected override void InitialiseDefaults() SetDefault(MSetting.MvisInterfaceGreen, value: 119f, 0, 255f); SetDefault(MSetting.MvisInterfaceBlue, value: 255f, 0, 255f); SetDefault(MSetting.MvisCurrentAudioProvider, "osu.Game.Screens.Mvis.Plugins+OsuMusicControllerWrapper"); + SetDefault(MSetting.MvisCurrentFunctionBar, ""); SetDefault(MSetting.MvisTabControlPosition, TabControlPosition.Right); //实验性功能 @@ -119,7 +120,8 @@ public enum MSetting MvisCurrentAudioProvider, Gamemode, DoNotShowDisclaimer, - LoaderBackgroundColor + LoaderBackgroundColor, + MvisCurrentFunctionBar } public enum GamemodeActivateCondition diff --git a/osu.Game/Screens/Mvis/MvisScreen.cs b/osu.Game/Screens/Mvis/MvisScreen.cs index a2b60f073823..afc52dc3f789 100644 --- a/osu.Game/Screens/Mvis/MvisScreen.cs +++ b/osu.Game/Screens/Mvis/MvisScreen.cs @@ -30,7 +30,7 @@ using osu.Game.Rulesets.Mods; using osu.Game.Screens.Mvis.Misc; using osu.Game.Screens.Mvis.Plugins; -using osu.Game.Screens.Mvis.Plugins.Internal.BottomBar; +using osu.Game.Screens.Mvis.Plugins.Internal.FallbackFunctionBar; using osu.Game.Screens.Mvis.Plugins.Types; using osu.Game.Screens.Mvis.SideBar; using osu.Game.Screens.Mvis.SideBar.Settings; @@ -181,13 +181,12 @@ protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnl [NotNull] private IFunctionBarProvider currentFunctionBarProvider { - get => realFunctionBarProvider ?? legacyBottomBarContainer; + get => realFunctionBarProvider ?? fallbackFunctionBar; set => realFunctionBarProvider = value; } - private readonly LegacyBottomBar legacyBottomBarContainer = new LegacyBottomBar(); + private readonly FunctionBar fallbackFunctionBar = new FunctionBar(); - private readonly List functionBarProviders = new List(); private readonly List functionProviders = new List(); //留着这些能让播放器在触发GlobalAction时会有更好的界面体验 @@ -657,7 +656,7 @@ private void changeFunctionBarProvider(IFunctionBarProvider target) if (targetDrawable != null) overlay.Remove(targetDrawable); - currentFunctionBarProvider = target ?? legacyBottomBarContainer; + currentFunctionBarProvider = target ?? fallbackFunctionBar; currentFunctionBarProvider.SetFunctionControls(functionProviders); overlay.Add((Drawable)currentFunctionBarProvider); diff --git a/osu.Game/Screens/Mvis/Plugins/Internal/FallbackFunctionBar/FunctionBar.cs b/osu.Game/Screens/Mvis/Plugins/Internal/FallbackFunctionBar/FunctionBar.cs new file mode 100644 index 000000000000..9a37b7b941c7 --- /dev/null +++ b/osu.Game/Screens/Mvis/Plugins/Internal/FallbackFunctionBar/FunctionBar.cs @@ -0,0 +1,113 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Cursor; +using osu.Framework.Graphics.Shapes; +using osu.Framework.Localisation; +using osu.Game.Graphics.Containers; +using osu.Game.Screens.Mvis.Plugins.Types; +using osuTK; +using osuTK.Graphics; + +namespace osu.Game.Screens.Mvis.Plugins.Internal.FallbackFunctionBar +{ + public class FunctionBar : Container, IFunctionBarProvider, IHasTooltip + { + public float GetSafeAreaPadding() => Height; + + public bool OkForHide() => IsHovered; + + private readonly FillFlowContainer contentContainer; + + private readonly List pluginButtons = new List(); + + public FunctionBar() + { + Height = 40; + RelativeSizeAxes = Axes.X; + + Anchor = Origin = Anchor.BottomCentre; + + InternalChildren = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.Green + }, + new OsuScrollContainer(Direction.Horizontal) + { + RelativeSizeAxes = Axes.Both, + ScrollbarVisible = false, + Child = contentContainer = new FillFlowContainer + { + AutoSizeAxes = Axes.X, + RelativeSizeAxes = Axes.Y, + Spacing = new Vector2(5) + } + } + }; + } + + public bool AddFunctionControl(IFunctionProvider provider) + { + if (provider is IToggleableFunctionProvider toggleableFunctionProvider) + contentContainer.Add(new ToggleableBarButton(toggleableFunctionProvider)); + else + contentContainer.Add(new SimpleBarButton(provider)); + + return true; + } + + public bool AddFunctionControls(List providers) + { + foreach (var provider in providers) + { + AddFunctionControl(provider); + } + + return true; + } + + public bool SetFunctionControls(List providers) + { + contentContainer.Clear(); + + return AddFunctionControls(providers); + } + + public void Remove(IFunctionProvider provider) + { + var target = contentContainer.FirstOrDefault(b => b.Provider == provider); + + if (target != null) + { + target.Expire(); + + if (provider is IPluginFunctionProvider pluginFunctionProvider) + pluginButtons.Remove(pluginFunctionProvider); + } + else + throw new ButtonNotFoundException(provider); + } + + public void ShowFunctionControlTemporary() + { + this.FadeIn().Delay(300).FadeTo(0.8f); + } + + public List GetAllPluginFunctionButton() => pluginButtons; + + public class ButtonNotFoundException : Exception + { + public ButtonNotFoundException(IFunctionProvider provider) + : base($"无法找到与{provider.ToString()}对应的按钮") + { + } + } + + public LocalisableString TooltipText => "这是一个后备功能条,如果你没在开发功能条插件,那么这很可能是个错误。\n请检查你的插件配置"; + } +} diff --git a/osu.Game/Screens/Mvis/Plugins/Internal/FallbackFunctionBar/SimpleBarButton.cs b/osu.Game/Screens/Mvis/Plugins/Internal/FallbackFunctionBar/SimpleBarButton.cs new file mode 100644 index 000000000000..f768aebf59ed --- /dev/null +++ b/osu.Game/Screens/Mvis/Plugins/Internal/FallbackFunctionBar/SimpleBarButton.cs @@ -0,0 +1,71 @@ +using System; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Cursor; +using osu.Framework.Graphics.Shapes; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Input.Events; +using osu.Framework.Localisation; +using osu.Game.Graphics.Sprites; +using osu.Game.Screens.Mvis.Plugins.Types; +using osuTK; +using osuTK.Graphics; + +namespace osu.Game.Screens.Mvis.Plugins.Internal.FallbackFunctionBar +{ + public class SimpleBarButton : CompositeDrawable, IHasTooltip + { + public LocalisableString TooltipText { get; } + + public IFunctionProvider Provider { get; set; } + + private Action action { get; set; } + + public SimpleBarButton(IFunctionProvider provider) + { + TooltipText = provider.Description; + Size = provider.Size; + action = provider.Action; + + Height = 1; + RelativeSizeAxes = Axes.Y; + + InternalChildren = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.DarkGreen + }, + new FillFlowContainer + { + RelativeSizeAxes = Axes.Both, + Children = new Drawable[] + { + new SpriteIcon + { + Icon = provider.Icon, + Size = new Vector2(13), + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Colour = Color4.Black + }, + new OsuSpriteText + { + Text = provider.Title, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Colour = Color4.Black + } + } + } + }; + } + + protected override bool OnClick(ClickEvent e) + { + action?.Invoke(); + return base.OnClick(e); + } + } +} diff --git a/osu.Game/Screens/Mvis/Plugins/Internal/FallbackFunctionBar/ToggleableBarButton.cs b/osu.Game/Screens/Mvis/Plugins/Internal/FallbackFunctionBar/ToggleableBarButton.cs new file mode 100644 index 000000000000..8d0cd4594ec6 --- /dev/null +++ b/osu.Game/Screens/Mvis/Plugins/Internal/FallbackFunctionBar/ToggleableBarButton.cs @@ -0,0 +1,66 @@ +using osu.Framework.Allocation; +using osu.Framework.Bindables; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Shapes; +using osu.Framework.Input.Events; +using osu.Game.Screens.Mvis.Plugins.Types; +using osuTK; +using osuTK.Graphics; + +namespace osu.Game.Screens.Mvis.Plugins.Internal.FallbackFunctionBar +{ + public class ToggleableBarButton : SimpleBarButton + { + private Box indicator; + + public BindableBool Value = new BindableBool(); + + public ToggleableBarButton(IToggleableFunctionProvider provider) + : base(provider) + { + if (provider is IToggleableFunctionProvider toggleableFunctionProvider) + { + Value.BindTo(toggleableFunctionProvider.Bindable); + } + } + + [BackgroundDependencyLoader] + private void load() + { + AddInternal(indicator = new Box + { + Size = new Vector2(5) + }); + } + + protected override void LoadComplete() + { + Value.BindValueChanged(onValueChanged, true); + Value.BindDisabledChanged(onDisableChanged, true); + } + + private void onDisableChanged(bool value) + { + this.FadeColour(value ? Color4.Gray : Color4.White); + } + + private void onValueChanged(ValueChangedEvent v) + { + indicator.FadeColour(v.NewValue ? Color4.Green : Color4.Red); + } + + protected override bool OnClick(ClickEvent e) + { + Toggle(); + return base.OnClick(e); + } + + public void Toggle() + { + if (Value.Disabled) + this.FlashColour(Color4.Red, 1000, Easing.OutQuint); + else + Value.Toggle(); + } + } +} diff --git a/osu.Game/Screens/Mvis/Plugins/MvisPluginManager.cs b/osu.Game/Screens/Mvis/Plugins/MvisPluginManager.cs index 250e87fbcc68..f06d2b1304c3 100644 --- a/osu.Game/Screens/Mvis/Plugins/MvisPluginManager.cs +++ b/osu.Game/Screens/Mvis/Plugins/MvisPluginManager.cs @@ -12,6 +12,7 @@ using osu.Framework.Logging; using osu.Framework.Platform; using osu.Game.Screens.Mvis.Plugins.Config; +using osu.Game.Screens.Mvis.Plugins.Types; namespace osu.Game.Screens.Mvis.Plugins { @@ -33,8 +34,8 @@ public class MvisPluginManager : Component internal Action OnPluginAdd; internal Action OnPluginUnLoad; - public int PluginVersion => 5; - public int MinimumPluginVersion => 4; + public int PluginVersion => 6; + public int MinimumPluginVersion => 6; private const bool experimental = true; private string blockedPluginFilePath => storage.GetFullPath("custom/blocked_plugins.json"); @@ -203,5 +204,7 @@ internal void ExpireOldPlugins() avaliablePlugins.Clear(); } + + internal List FunctionBarProviders = new List(); } } diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 7e2efbbcb774..cd34036311e7 100755 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -46,7 +46,4 @@ - - - diff --git a/osu.sln b/osu.sln index 273cedbc270b..f777d4b6c08d 100755 --- a/osu.sln +++ b/osu.sln @@ -114,6 +114,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mvis.Plugin.CloudMusicSuppo EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mvis.Plugin.Yasp", "Mvis.Plugin.Yasp\Mvis.Plugin.Yasp.csproj", "{EE35BF67-5705-405E-B403-F63EBF206AA5}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mvis.Plugin.BottomBar", "Mvis.Plugin.BottomBar\Mvis.Plugin.BottomBar.csproj", "{7606289A-E139-48B0-9F76-9D4552AC50D8}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -652,6 +654,18 @@ Global {EE35BF67-5705-405E-B403-F63EBF206AA5}.Release|iPhone.Build.0 = Release|Any CPU {EE35BF67-5705-405E-B403-F63EBF206AA5}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU {EE35BF67-5705-405E-B403-F63EBF206AA5}.Release|iPhoneSimulator.Build.0 = Release|Any CPU + {7606289A-E139-48B0-9F76-9D4552AC50D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7606289A-E139-48B0-9F76-9D4552AC50D8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7606289A-E139-48B0-9F76-9D4552AC50D8}.Debug|iPhone.ActiveCfg = Debug|Any CPU + {7606289A-E139-48B0-9F76-9D4552AC50D8}.Debug|iPhone.Build.0 = Debug|Any CPU + {7606289A-E139-48B0-9F76-9D4552AC50D8}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {7606289A-E139-48B0-9F76-9D4552AC50D8}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU + {7606289A-E139-48B0-9F76-9D4552AC50D8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7606289A-E139-48B0-9F76-9D4552AC50D8}.Release|Any CPU.Build.0 = Release|Any CPU + {7606289A-E139-48B0-9F76-9D4552AC50D8}.Release|iPhone.ActiveCfg = Release|Any CPU + {7606289A-E139-48B0-9F76-9D4552AC50D8}.Release|iPhone.Build.0 = Release|Any CPU + {7606289A-E139-48B0-9F76-9D4552AC50D8}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU + {7606289A-E139-48B0-9F76-9D4552AC50D8}.Release|iPhoneSimulator.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From c92d1c9ffa0b03abc188a6566139e86695417c78 Mon Sep 17 00:00:00 2001 From: MATRIX-feather Date: Fri, 13 Aug 2021 20:51:33 +0800 Subject: [PATCH 4/8] =?UTF-8?q?new:=20=E5=AE=9E=E7=8E=B0=E5=BA=95=E6=A0=8F?= =?UTF-8?q?=E6=8F=92=E4=BB=B6=E9=80=89=E6=8B=A9=20enchance:=20=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E9=9F=B3=E9=A2=91=E6=8F=92=E4=BB=B6=E3=80=81=E5=BA=95?= =?UTF-8?q?=E6=A0=8F=E6=8F=92=E4=BB=B6=E9=80=89=E6=8B=A9=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=20remove:=20=E7=A7=BB=E9=99=A4=E7=9A=AE=E8=82=A4=E6=94=AF?= =?UTF-8?q?=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/.idea.osu.Desktop/.idea/discord.xml | 7 ++ Mvis.Plugin.BottomBar/LegacyBottomBar.cs | 19 +++- .../CollectionHepler.cs | 2 +- .../Sidebar/CollectionPluginPage.cs | 16 --- osu.Game/Configuration/MConfigManager.cs | 4 +- osu.Game/Graphics/TextEditIndicator.cs | 2 +- .../Settings/Sections/Mf/MvisAudioSettings.cs | 23 ++-- .../Settings/Sections/Mf/MvisUISettings.cs | 50 ++++++++- .../PluginResolvers/AudioPluginResolver.cs | 106 ++++++++++++++++++ osu.Game/Screens/Mvis/MvisScreen.cs | 64 +++++++---- .../FallbackFunctionBar/FunctionBar.cs | 92 ++++++++++++++- .../FallbackFunctionBar/SimpleBarButton.cs | 81 ++++++++++--- .../FallbackFunctionBar/SongProgressButton.cs | 36 ++++++ .../ToggleableBarButton.cs | 8 +- .../Screens/Mvis/Plugins/MvisPluginManager.cs | 28 ++++- .../Mvis/Plugins/OsuMusicControllerWrapper.cs | 2 +- .../Plugins/Types/IFunctionBarProvider.cs | 3 + .../Plugins/Types/ToggleableFakeButton.cs | 3 - .../Screens/Mvis/SideBar/Footer/Footer.cs | 20 ---- .../Settings/Items}/PlaceHolder.cs | 2 +- .../Settings/Items/SettingsPieceBasePanel.cs | 1 - .../SideBar/Settings/Sections/BaseSettings.cs | 61 +++++----- .../Skinning/FullScreenSkinnableComponent.cs | 26 ----- .../Mvis/Skinning/SkinnableComponent.cs | 50 --------- 24 files changed, 486 insertions(+), 220 deletions(-) create mode 100644 .idea/.idea.osu.Desktop/.idea/discord.xml create mode 100644 osu.Game/Screens/Mvis/Misc/PluginResolvers/AudioPluginResolver.cs create mode 100644 osu.Game/Screens/Mvis/Plugins/Internal/FallbackFunctionBar/SongProgressButton.cs rename osu.Game/Screens/Mvis/{Skinning => SideBar/Settings/Items}/PlaceHolder.cs (61%) delete mode 100644 osu.Game/Screens/Mvis/Skinning/FullScreenSkinnableComponent.cs delete mode 100644 osu.Game/Screens/Mvis/Skinning/SkinnableComponent.cs diff --git a/.idea/.idea.osu.Desktop/.idea/discord.xml b/.idea/.idea.osu.Desktop/.idea/discord.xml new file mode 100644 index 000000000000..30bab2abb1a9 --- /dev/null +++ b/.idea/.idea.osu.Desktop/.idea/discord.xml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/Mvis.Plugin.BottomBar/LegacyBottomBar.cs b/Mvis.Plugin.BottomBar/LegacyBottomBar.cs index 8b610f2a62db..79d0adabe975 100644 --- a/Mvis.Plugin.BottomBar/LegacyBottomBar.cs +++ b/Mvis.Plugin.BottomBar/LegacyBottomBar.cs @@ -8,16 +8,14 @@ using osu.Game.Screens.Mvis; using osu.Game.Screens.Mvis.Plugins; using osu.Game.Screens.Mvis.Plugins.Types; +using osu.Game.Screens.Mvis.SideBar.Settings.Items; using osuTK; namespace Mvis.Plugin.BottomBar { internal class LegacyBottomBar : MvisPlugin, IFunctionBarProvider { - protected override Drawable CreateContent() - { - throw new NotImplementedException(); - } + protected override Drawable CreateContent() => new PlaceHolder(); protected override bool OnContentLoaded(Drawable content) => true; @@ -45,6 +43,12 @@ public LegacyBottomBar() Author = "MATRIX-夜翎"; Depth = -1; + Flags.AddRange(new[] + { + PluginFlags.CanDisable, + PluginFlags.CanUnload + }); + Anchor = Anchor.BottomCentre; Origin = Anchor.BottomCentre; RelativeSizeAxes = Axes.X; @@ -245,6 +249,13 @@ public void Remove(IFunctionProvider provider) public void ShowFunctionControlTemporary() => pluginEntriesFillFlow.FadeIn(500, Easing.OutQuint).Then().Delay(2000).FadeOut(500, Easing.OutQuint); public List GetAllPluginFunctionButton() => pluginButtons; + public Action OnDisable { get; set; } + + public override bool Disable() + { + OnDisable?.Invoke(); + return base.Disable(); + } public class ButtonNotFoundException : Exception { diff --git a/Mvis.Plugin.CollectionSupport/CollectionHepler.cs b/Mvis.Plugin.CollectionSupport/CollectionHepler.cs index 5da486c8004c..823ce77aadb1 100644 --- a/Mvis.Plugin.CollectionSupport/CollectionHepler.cs +++ b/Mvis.Plugin.CollectionSupport/CollectionHepler.cs @@ -14,7 +14,7 @@ using osu.Game.Screens.Mvis.Plugins; using osu.Game.Screens.Mvis.Plugins.Config; using osu.Game.Screens.Mvis.Plugins.Types; -using osu.Game.Screens.Mvis.Skinning; +using osu.Game.Screens.Mvis.SideBar.Settings.Items; namespace Mvis.Plugin.CollectionSupport { diff --git a/Mvis.Plugin.CollectionSupport/Sidebar/CollectionPluginPage.cs b/Mvis.Plugin.CollectionSupport/Sidebar/CollectionPluginPage.cs index 21f5529362b4..9df0ede2aaca 100644 --- a/Mvis.Plugin.CollectionSupport/Sidebar/CollectionPluginPage.cs +++ b/Mvis.Plugin.CollectionSupport/Sidebar/CollectionPluginPage.cs @@ -11,8 +11,6 @@ using osu.Game.Screens.Mvis; using osu.Game.Screens.Mvis.Plugins; using osu.Game.Screens.Mvis.Plugins.Types; -using osu.Game.Screens.Mvis.Skinning; -using osu.Game.Skinning; using osuTK; using osuTK.Input; @@ -60,20 +58,6 @@ private void load() Children = new Drawable[] { - new SkinnableComponent( - "MSidebar-Collection-background", - confineMode: ConfineMode.ScaleToFill, - defaultImplementation: _ => new PlaceHolder()) - { - Name = "收藏夹背景", - Anchor = Anchor.BottomRight, - Origin = Anchor.BottomRight, - ChildAnchor = Anchor.BottomRight, - ChildOrigin = Anchor.BottomRight, - RelativeSizeAxes = Axes.Both, - CentreComponent = false, - OverrideChildAnchor = true, - }, new Container { Name = "收藏夹选择界面", diff --git a/osu.Game/Configuration/MConfigManager.cs b/osu.Game/Configuration/MConfigManager.cs index c5c5ba935078..f361e3d4c754 100644 --- a/osu.Game/Configuration/MConfigManager.cs +++ b/osu.Game/Configuration/MConfigManager.cs @@ -54,8 +54,8 @@ protected override void InitialiseDefaults() SetDefault(MSetting.MvisInterfaceRed, value: 0, 0, 255f); SetDefault(MSetting.MvisInterfaceGreen, value: 119f, 0, 255f); SetDefault(MSetting.MvisInterfaceBlue, value: 255f, 0, 255f); - SetDefault(MSetting.MvisCurrentAudioProvider, "osu.Game.Screens.Mvis.Plugins+OsuMusicControllerWrapper"); - SetDefault(MSetting.MvisCurrentFunctionBar, ""); + SetDefault(MSetting.MvisCurrentAudioProvider, "OsuMusicControllerWrapper@osu.Game.Screens.Mvis.Plugins"); + SetDefault(MSetting.MvisCurrentFunctionBar, "LegacyBottomBar@Mvis.Plugin.BottomBar"); SetDefault(MSetting.MvisTabControlPosition, TabControlPosition.Right); //实验性功能 diff --git a/osu.Game/Graphics/TextEditIndicator.cs b/osu.Game/Graphics/TextEditIndicator.cs index 3636f92edfb6..96f67bfd7f89 100644 --- a/osu.Game/Graphics/TextEditIndicator.cs +++ b/osu.Game/Graphics/TextEditIndicator.cs @@ -10,7 +10,7 @@ using osu.Game.Configuration; using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; -using osu.Game.Screens.Mvis.Skinning; +using osu.Game.Screens.Mvis.SideBar.Settings.Items; using osuTK; using osuTK.Graphics; diff --git a/osu.Game/Overlays/Settings/Sections/Mf/MvisAudioSettings.cs b/osu.Game/Overlays/Settings/Sections/Mf/MvisAudioSettings.cs index e7ae6254a260..effc454fcc89 100644 --- a/osu.Game/Overlays/Settings/Sections/Mf/MvisAudioSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Mf/MvisAudioSettings.cs @@ -1,7 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using System.Collections.Generic; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Localisation; @@ -48,23 +47,17 @@ private void load(MConfigManager config, MvisPluginManager pluginManager) } }; - var plugins = new List(); - var currentAudioControlPlugin = config.Get(MSetting.MvisCurrentAudioProvider); + var plugins = pluginManager.GetAllAudioControlPlugin(); - plugins.Add(new OsuMusicControllerWrapper()); + var currentAudioControlPlugin = config.Get(MSetting.MvisCurrentAudioProvider); - foreach (var pl in pluginManager.GetAllPlugins(false)) + foreach (var pl in plugins) { - if (pl is IProvideAudioControlPlugin pacp) - { - plugins.Add(pacp); - - var type = pl.GetType(); + var type = pl.GetType(); - if (currentAudioControlPlugin == $"{type.Namespace}+{type.Name}") - { - dropdown.Current.Value = pacp; - } + if (currentAudioControlPlugin == type.Name + "@" + type.Namespace) + { + dropdown.Current.Value = pl; } } @@ -80,7 +73,7 @@ private void load(MConfigManager config, MvisPluginManager pluginManager) var pl = (MvisPlugin)v.NewValue; var type = pl.GetType(); - config.SetValue(MSetting.MvisCurrentAudioProvider, $"{type.Namespace}+{type.Name}"); + config.SetValue(MSetting.MvisCurrentAudioProvider, type.Name + "@" + type.Namespace); }); } diff --git a/osu.Game/Overlays/Settings/Sections/Mf/MvisUISettings.cs b/osu.Game/Overlays/Settings/Sections/Mf/MvisUISettings.cs index 5255202842c9..f7348c706570 100644 --- a/osu.Game/Overlays/Settings/Sections/Mf/MvisUISettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Mf/MvisUISettings.cs @@ -6,6 +6,9 @@ using osu.Framework.Graphics; using osu.Framework.Localisation; using osu.Game.Configuration; +using osu.Game.Graphics.UserInterface; +using osu.Game.Screens.Mvis.Plugins; +using osu.Game.Screens.Mvis.Plugins.Types; using osu.Game.Screens.Mvis.SideBar.Tabs; namespace osu.Game.Overlays.Settings.Sections.Mf @@ -17,9 +20,10 @@ public class MvisUISettings : SettingsSubsection private readonly BindableFloat iG = new BindableFloat(); private readonly BindableFloat iB = new BindableFloat(); private ColourPreviewer preview; + private FunctionBarPluginDropDown dropdown; [BackgroundDependencyLoader] - private void load(MConfigManager config) + private void load(MConfigManager config, MvisPluginManager pluginManager) { config.BindWith(MSetting.MvisInterfaceRed, iR); config.BindWith(MSetting.MvisInterfaceGreen, iG); @@ -79,8 +83,38 @@ private void load(MConfigManager config) LabelText = "启用背景动画", Current = config.GetBindable(MSetting.MvisEnableBgTriangles), TooltipText = "如果条件允许,播放器将会在背景显示动画" + }, + dropdown = new FunctionBarPluginDropDown + { + LabelText = "底栏插件" } }; + + var plugins = pluginManager.GetAllFunctionBarProviders(); + var currentFunctionBar = config.Get(MSetting.MvisCurrentFunctionBar); + + foreach (var pl in plugins) + { + if (currentFunctionBar == pluginManager.ToPath(pl)) + { + dropdown.Current.Value = pl; + } + } + + dropdown.Items = plugins; + dropdown.Current.BindValueChanged(v => + { + if (v.NewValue == null) + { + config.SetValue(MSetting.MvisCurrentFunctionBar, string.Empty); + return; + } + + var pl = (MvisPlugin)v.NewValue; + var type = pl.GetType(); + + config.SetValue(MSetting.MvisCurrentFunctionBar, type.Name + "@" + type.Namespace); + }); } protected override void LoadComplete() @@ -91,5 +125,19 @@ protected override void LoadComplete() } private void updateColor() => preview.UpdateColor(iR.Value, iG.Value, iB.Value); + + private class FunctionBarPluginDropDown : SettingsDropdown + { + protected override OsuDropdown CreateDropdown() + => new PluginDropDownControl(); + + private class PluginDropDownControl : DropdownControl + { + protected override LocalisableString GenerateItemText(IFunctionBarProvider item) + { + return ((MvisPlugin)item).Name; + } + } + } } } diff --git a/osu.Game/Screens/Mvis/Misc/PluginResolvers/AudioPluginResolver.cs b/osu.Game/Screens/Mvis/Misc/PluginResolvers/AudioPluginResolver.cs new file mode 100644 index 000000000000..e0263d54529e --- /dev/null +++ b/osu.Game/Screens/Mvis/Misc/PluginResolvers/AudioPluginResolver.cs @@ -0,0 +1,106 @@ +using System.Collections.Concurrent; +using System.Collections.Generic; +using JetBrains.Annotations; +using osu.Game.Screens.Mvis.Plugins; +using osu.Game.Screens.Mvis.Plugins.Types; + +namespace osu.Game.Screens.Mvis.Misc.PluginResolvers +{ + public class MvisPluginResolver + { + private readonly MvisPluginManager pluginManager; + + public MvisPluginResolver(MvisPluginManager pluginManager) + { + this.pluginManager = pluginManager; + } + + public string ToPath(object target) + { + return target.GetType().Name + "@" + target.GetType().Namespace; + } + + internal void UpdatePluginDictionary(List newPluginList) + { + functionBarDictionary.Clear(); + audioPluginDictionary.Clear(); + + foreach (var plugin in newPluginList) + { + var pluginPath = + plugin.GetType().Name + + "@" + + plugin.GetType().Namespace; + + if (plugin is IFunctionBarProvider functionBarProvider) + functionBarDictionary[pluginPath] = functionBarProvider; + + if (plugin is IProvideAudioControlPlugin audioControlPlugin) + audioPluginDictionary[pluginPath] = audioControlPlugin; + } + + var defaultAudioControlPath = pluginManager.DefaultAudioController.GetType().Name + + "@" + + pluginManager.DefaultAudioController.GetType().Namespace; + + audioPluginDictionary[defaultAudioControlPath] = pluginManager.DefaultAudioController; + } + + private readonly ConcurrentDictionary audioPluginDictionary = new ConcurrentDictionary(); + private readonly ConcurrentDictionary functionBarDictionary = new ConcurrentDictionary(); + + [CanBeNull] + internal IProvideAudioControlPlugin GetAudioControlPluginByPath(string path) + { + IProvideAudioControlPlugin result; + if (audioPluginDictionary.TryGetValue(path, out result)) + return result; + + return null; + } + + [CanBeNull] + internal IFunctionBarProvider GetFunctionBarProviderByPath(string path) + { + IFunctionBarProvider result; + if (functionBarDictionary.TryGetValue(path, out result)) + return result; + + return null; + } + + private List cachedAudioControlPluginList; + + internal List GetAllAudioControlPlugin() + { + var list = new List(); + + foreach (var keyPair in audioPluginDictionary) + { + list.Add(keyPair.Value); + } + + if (cachedAudioControlPluginList == null || cachedAudioControlPluginList != list) + cachedAudioControlPluginList = list; + + return list; + } + + private List cachedFunctionBarPluginList; + + internal List GetAllFunctionBarProviders() + { + var list = new List(); + + foreach (var keyPair in functionBarDictionary) + { + list.Add(keyPair.Value); + } + + if (cachedFunctionBarPluginList == null || cachedFunctionBarPluginList != list) + cachedFunctionBarPluginList = list; + + return list; + } + } +} diff --git a/osu.Game/Screens/Mvis/MvisScreen.cs b/osu.Game/Screens/Mvis/MvisScreen.cs index afc52dc3f789..8cd2db3eeef1 100644 --- a/osu.Game/Screens/Mvis/MvisScreen.cs +++ b/osu.Game/Screens/Mvis/MvisScreen.cs @@ -237,6 +237,7 @@ private IFunctionBarProvider currentFunctionBarProvider private readonly BindableBool nightcoreBeat = new BindableBool(); private readonly BindableBool allowProxy = new BindableBool(); private Bindable currentAudioControlProviderSetting; + private Bindable currentFunctionbarSetting; #endregion @@ -301,7 +302,6 @@ public bool RemoveDrawableFromProxy(Drawable d) public Bindable HideScreenBackground = new Bindable(); private IProvideAudioControlPlugin audioControlProvider; - public readonly OsuMusicControllerWrapper MusicControllerWrapper = new OsuMusicControllerWrapper(); private SettingsButton songSelectButton; private PlayerSettings settingsScroll; @@ -351,11 +351,11 @@ private void load(MConfigManager config, IdleTracker idleTracker) config.BindWith(MSetting.MvisEnableNightcoreBeat, nightcoreBeat); config.BindWith(MSetting.MvisStoryboardProxy, allowProxy); currentAudioControlProviderSetting = config.GetBindable(MSetting.MvisCurrentAudioProvider); + currentFunctionbarSetting = config.GetBindable(MSetting.MvisCurrentFunctionBar); InternalChildren = new Drawable[] { colourProvider, - MusicControllerWrapper, nightcoreBeatContainer = new NightcoreBeatContainer { Alpha = 0 @@ -396,7 +396,7 @@ private void load(MConfigManager config, IdleTracker idleTracker) }; //todo: 找出为啥audioControlProvider会在被赋值前访问 - audioControlProvider = MusicControllerWrapper; + audioControlProvider = pluginManager.DefaultAudioController; functionProviders.AddRange(new IFunctionProvider[] { @@ -487,7 +487,11 @@ private void load(MConfigManager config, IdleTracker idleTracker) lockButton = new ToggleableFakeButton { Description = MvisBaseStrings.LockInterface, - Action = showPluginEntriesTemporary, + Action = () => + { + showPluginEntriesTemporary(); + lockButton.Active(); + }, Type = FunctionType.Plugin, Icon = FontAwesome.Solid.Lock } @@ -573,11 +577,6 @@ protected override void LoadComplete() case MvisPlugin.TargetLayer.Foreground: foreground.Add(pl); break; - - case MvisPlugin.TargetLayer.FunctionBar: - if (pl.GetType().IsSubclassOf(typeof(IFunctionBarProvider))) - functionBarProviders.Add(pl as IFunctionBarProvider); - break; } var pluginSidebarPage = pl.CreateSidebarPage(); @@ -623,12 +622,17 @@ protected override void LoadComplete() currentAudioControlProviderSetting.BindValueChanged(v => { //获取与新值匹配的控制插件 - var pl = (IProvideAudioControlPlugin)pluginManager.GetAllPlugins(false).FirstOrDefault(p => v.NewValue == $"{p.GetType().Namespace}+{p.GetType().Name}"); + var pl = pluginManager.GetAudioControlByPath(v.NewValue); changeAudioControlProvider(pl); }, true); - //todo: 实现切换功能 - changeFunctionBarProvider(null); + //更新当前功能条 + currentFunctionbarSetting.BindValueChanged(v => + { + //获取与新值匹配的控制插件 + var pl = pluginManager.GetFunctionBarProviderByPath(v.NewValue); + changeFunctionBarProvider(pl); + }, true); currentFunctionBarProvider.Hide(); base.LoadComplete(); @@ -637,29 +641,46 @@ protected override void LoadComplete() private void changeAudioControlProvider(IProvideAudioControlPlugin pacp) { //如果没找到(为null),则解锁Beatmap.Disabled - Beatmap.Disabled = pacp != null; + Beatmap.Disabled = (pacp != null) && (pacp != pluginManager.DefaultAudioController); //设置当前控制插件IsCurrent为false audioControlProvider.IsCurrent = false; //切换并设置当前控制插件IsCurrent为true - audioControlProvider = pacp ?? MusicControllerWrapper; + audioControlProvider = pacp ?? pluginManager.DefaultAudioController; audioControlProvider.IsCurrent = true; - songSelectButton.Enabled.Value = audioControlProvider == MusicControllerWrapper; + songSelectButton.Enabled.Value = audioControlProvider == pluginManager.DefaultAudioController; + //Logger.Log($"更改控制插件到{audioControlProvider}"); } + private void onFunctionBarPluginDisable() => changeFunctionBarProvider(null); + private void changeFunctionBarProvider(IFunctionBarProvider target) { - var targetDrawable = overlay.FirstOrDefault(d => d.GetType().IsSubclassOf(typeof(IFunctionBarProvider))); + //找到旧的Functionbar + var targetDrawable = overlay.FirstOrDefault(d => d is IFunctionBarProvider); + //移除 if (targetDrawable != null) overlay.Remove(targetDrawable); - currentFunctionBarProvider = target ?? fallbackFunctionBar; - currentFunctionBarProvider.SetFunctionControls(functionProviders); + //不要在此功能条禁用时再调用onFunctionBarPluginDisable + currentFunctionBarProvider.OnDisable -= onFunctionBarPluginDisable; + + //如果新的目标是null,则使用后备功能条 + var newProvider = target ?? fallbackFunctionBar; + //更新控制按钮 + newProvider.SetFunctionControls(functionProviders); + newProvider.OnDisable += onFunctionBarPluginDisable; + + //更新currentFunctionBarProvider + currentFunctionBarProvider = newProvider; + + //添加新的功能条 overlay.Add((Drawable)currentFunctionBarProvider); + //Logger.Log($"更改底栏到{currentFunctionBarProvider}"); } private void setupKeyBindings() @@ -667,7 +688,7 @@ private void setupKeyBindings() keyBindings[GlobalAction.MvisMusicPrev] = () => prevButton.Active(); keyBindings[GlobalAction.MvisMusicNext] = () => nextButton.Active(); keyBindings[GlobalAction.MvisOpenInSongSelect] = () => soloButton.Active(); - keyBindings[GlobalAction.MvisToggleOverlayLock] = () => lockButton.Active(); + keyBindings[GlobalAction.MvisToggleOverlayLock] = () => lockButton.Active(true); keyBindings[GlobalAction.MvisTogglePluginPage] = () => pluginButton.Active(); keyBindings[GlobalAction.MvisTogglePause] = () => songProgressButton.Active(true); keyBindings[GlobalAction.MvisToggleTrackLoop] = () => loopToggleButton.Active(); @@ -717,6 +738,9 @@ private void onPluginUnLoad(MvisPlugin pl) } } } + + if ((MvisPlugin)currentFunctionBarProvider == pl) + changeFunctionBarProvider(null); } internal bool RemovePluginFromLoadList(MvisPlugin pl) @@ -865,7 +889,7 @@ public override void OnResuming(IScreen last) Mods.Value = timeRateMod; - Beatmap.Disabled = audioControlProvider != null && audioControlProvider != MusicControllerWrapper; + Beatmap.Disabled = audioControlProvider != null && audioControlProvider != pluginManager.DefaultAudioController; this.FadeIn(duration * 0.6f) .ScaleTo(1, duration * 0.6f, Easing.OutQuint); diff --git a/osu.Game/Screens/Mvis/Plugins/Internal/FallbackFunctionBar/FunctionBar.cs b/osu.Game/Screens/Mvis/Plugins/Internal/FallbackFunctionBar/FunctionBar.cs index 9a37b7b941c7..2d149d616a17 100644 --- a/osu.Game/Screens/Mvis/Plugins/Internal/FallbackFunctionBar/FunctionBar.cs +++ b/osu.Game/Screens/Mvis/Plugins/Internal/FallbackFunctionBar/FunctionBar.cs @@ -1,6 +1,8 @@ using System; using System.Collections.Generic; using System.Linq; +using osu.Framework.Allocation; +using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Cursor; @@ -13,7 +15,7 @@ namespace osu.Game.Screens.Mvis.Plugins.Internal.FallbackFunctionBar { - public class FunctionBar : Container, IFunctionBarProvider, IHasTooltip + public class FunctionBar : MvisPlugin, IFunctionBarProvider, IHasTooltip { public float GetSafeAreaPadding() => Height; @@ -22,6 +24,8 @@ public class FunctionBar : Container, IFunctionBarProvider, IHasTooltip private readonly FillFlowContainer contentContainer; private readonly List pluginButtons = new List(); + private readonly Box idleIndicator; + private readonly Box hideIndicator; public FunctionBar() { @@ -35,7 +39,7 @@ public FunctionBar() new Box { RelativeSizeAxes = Axes.Both, - Colour = Color4.Green + Colour = Color4Extensions.FromHex("#2d353f") }, new OsuScrollContainer(Direction.Horizontal) { @@ -47,16 +51,86 @@ public FunctionBar() RelativeSizeAxes = Axes.Y, Spacing = new Vector2(5) } + }, + idleIndicator = new Box + { + Width = 5, + RelativeSizeAxes = Axes.Y, + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + Colour = Color4.Gold + }, + hideIndicator = new Box + { + Width = 5, + RelativeSizeAxes = Axes.Y, + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + Colour = Color4Extensions.FromHex("#365960"), + Margin = new MarginPadding { Right = 5 } } }; } + protected override Drawable CreateContent() + { + throw new NotImplementedException(); + } + + protected override bool OnContentLoaded(Drawable content) => true; + + protected override bool PostInit() => true; + + public override int Version => 0; + + [BackgroundDependencyLoader] + private void load() + { + MvisScreen.OnIdle += onIdle; + MvisScreen.OnResumeFromIdle += resumeFromIdle; + } + + private void resumeFromIdle() + { + hideIndicator.FadeOut(300, Easing.OutQuint); + } + + private void onIdle() + { + hideIndicator.FadeIn(300, Easing.OutQuint); + } + + protected override void Dispose(bool isDisposing) + { + if (MvisScreen != null) + { + MvisScreen.OnIdle -= onIdle; + MvisScreen.OnResumeFromIdle -= resumeFromIdle; + } + + base.Dispose(isDisposing); + } + public bool AddFunctionControl(IFunctionProvider provider) { + SimpleBarButton button; + if (provider is IToggleableFunctionProvider toggleableFunctionProvider) - contentContainer.Add(new ToggleableBarButton(toggleableFunctionProvider)); + button = new ToggleableBarButton(toggleableFunctionProvider); else - contentContainer.Add(new SimpleBarButton(provider)); + button = new SimpleBarButton(provider); + + switch (provider.Type) + { + case FunctionType.ProgressDisplay: + button.Dispose(); + contentContainer.Add(new SongProgressButton((IToggleableFunctionProvider)provider)); + break; + + default: + contentContainer.Add(button); + break; + } return true; } @@ -95,11 +169,19 @@ public void Remove(IFunctionProvider provider) public void ShowFunctionControlTemporary() { - this.FadeIn().Delay(300).FadeTo(0.8f); + idleIndicator.FlashColour(Color4.Green, 500); } public List GetAllPluginFunctionButton() => pluginButtons; + public Action OnDisable { get; set; } + + public override bool Disable() + { + OnDisable?.Invoke(); + return base.Disable(); + } + public class ButtonNotFoundException : Exception { public ButtonNotFoundException(IFunctionProvider provider) diff --git a/osu.Game/Screens/Mvis/Plugins/Internal/FallbackFunctionBar/SimpleBarButton.cs b/osu.Game/Screens/Mvis/Plugins/Internal/FallbackFunctionBar/SimpleBarButton.cs index f768aebf59ed..605a01726824 100644 --- a/osu.Game/Screens/Mvis/Plugins/Internal/FallbackFunctionBar/SimpleBarButton.cs +++ b/osu.Game/Screens/Mvis/Plugins/Internal/FallbackFunctionBar/SimpleBarButton.cs @@ -1,4 +1,5 @@ using System; +using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Cursor; @@ -15,19 +16,58 @@ namespace osu.Game.Screens.Mvis.Plugins.Internal.FallbackFunctionBar { public class SimpleBarButton : CompositeDrawable, IHasTooltip { + private readonly SpriteIcon spriteIcon = new SpriteIcon + { + Size = new Vector2(13), + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Colour = Color4.White + }; + + private readonly OsuSpriteText spriteText = new OsuSpriteText + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Colour = Color4.White + }; + + private readonly Box flashBox; + public LocalisableString TooltipText { get; } public IFunctionProvider Provider { get; set; } private Action action { get; set; } + protected LocalisableString Title + { + get => spriteText.Text; + set => spriteText.Text = value; + } + + private IconUsage emptyIcon => new IconUsage(); + + protected IconUsage Icon + { + get => spriteIcon.Icon; + set + { + if (!value.Equals(emptyIcon)) + spriteIcon.Icon = value; + else + spriteIcon.FadeOut(); + } + } + public SimpleBarButton(IFunctionProvider provider) { TooltipText = provider.Description; - Size = provider.Size; + Width = Math.Max(provider.Size.X, 40); action = provider.Action; - Height = 1; + Title = provider.Title; + Icon = provider.Icon; + RelativeSizeAxes = Axes.Y; InternalChildren = new Drawable[] @@ -35,33 +75,38 @@ public SimpleBarButton(IFunctionProvider provider) new Box { RelativeSizeAxes = Axes.Both, - Colour = Color4.DarkGreen + Colour = Color4Extensions.FromHex("#365960") }, new FillFlowContainer { RelativeSizeAxes = Axes.Both, Children = new Drawable[] { - new SpriteIcon - { - Icon = provider.Icon, - Size = new Vector2(13), - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Colour = Color4.Black - }, - new OsuSpriteText - { - Text = provider.Title, - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Colour = Color4.Black - } + spriteIcon, + spriteText, } + }, + flashBox = new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.White, + Alpha = 0, } }; } + protected override bool OnHover(HoverEvent e) + { + flashBox.FadeTo(0.1f, 300); + return base.OnHover(e); + } + + protected override void OnHoverLost(HoverLostEvent e) + { + base.OnHoverLost(e); + flashBox.FadeTo(0f, 300); + } + protected override bool OnClick(ClickEvent e) { action?.Invoke(); diff --git a/osu.Game/Screens/Mvis/Plugins/Internal/FallbackFunctionBar/SongProgressButton.cs b/osu.Game/Screens/Mvis/Plugins/Internal/FallbackFunctionBar/SongProgressButton.cs new file mode 100644 index 000000000000..df1d89128571 --- /dev/null +++ b/osu.Game/Screens/Mvis/Plugins/Internal/FallbackFunctionBar/SongProgressButton.cs @@ -0,0 +1,36 @@ +using System; +using osu.Framework.Allocation; +using osu.Framework.Graphics.Audio; +using osu.Game.Screens.Mvis.Plugins.Types; + +namespace osu.Game.Screens.Mvis.Plugins.Internal.FallbackFunctionBar +{ + public class SongProgressButton : ToggleableBarButton + { + public SongProgressButton(IToggleableFunctionProvider provider) + : base(provider) + { + Width = 120; + } + + private string timeCurrent; + private string timeTotal; + + [Resolved] + private MvisScreen mvisScreen { get; set; } + + private DrawableTrack track => mvisScreen.CurrentTrack; + + private string formatTime(TimeSpan timeSpan) => $"{(timeSpan < TimeSpan.Zero ? "-" : "")}{Math.Floor(timeSpan.Duration().TotalMinutes)}:{timeSpan.Duration().Seconds:D2}"; + + protected override void Update() + { + base.Update(); + + int currentSecond = (int)Math.Floor(track.CurrentTime / 1000.0); + timeCurrent = formatTime(TimeSpan.FromSeconds(currentSecond)); + timeTotal = formatTime(TimeSpan.FromMilliseconds(track.Length)); + Title = $"{timeCurrent} / {timeTotal}"; + } + } +} diff --git a/osu.Game/Screens/Mvis/Plugins/Internal/FallbackFunctionBar/ToggleableBarButton.cs b/osu.Game/Screens/Mvis/Plugins/Internal/FallbackFunctionBar/ToggleableBarButton.cs index 8d0cd4594ec6..7259d05e1000 100644 --- a/osu.Game/Screens/Mvis/Plugins/Internal/FallbackFunctionBar/ToggleableBarButton.cs +++ b/osu.Game/Screens/Mvis/Plugins/Internal/FallbackFunctionBar/ToggleableBarButton.cs @@ -4,7 +4,6 @@ using osu.Framework.Graphics.Shapes; using osu.Framework.Input.Events; using osu.Game.Screens.Mvis.Plugins.Types; -using osuTK; using osuTK.Graphics; namespace osu.Game.Screens.Mvis.Plugins.Internal.FallbackFunctionBar @@ -29,7 +28,8 @@ private void load() { AddInternal(indicator = new Box { - Size = new Vector2(5) + Height = 5, + RelativeSizeAxes = Axes.X }); } @@ -41,12 +41,12 @@ protected override void LoadComplete() private void onDisableChanged(bool value) { - this.FadeColour(value ? Color4.Gray : Color4.White); + this.FadeColour(value ? Color4.Gray : Color4.White, 300, Easing.OutQuint); } private void onValueChanged(ValueChangedEvent v) { - indicator.FadeColour(v.NewValue ? Color4.Green : Color4.Red); + indicator.FadeColour(v.NewValue ? Color4.Green : Color4.Gold, 300, Easing.OutQuint); } protected override bool OnClick(ClickEvent e) diff --git a/osu.Game/Screens/Mvis/Plugins/MvisPluginManager.cs b/osu.Game/Screens/Mvis/Plugins/MvisPluginManager.cs index f06d2b1304c3..5a5f35f6e006 100644 --- a/osu.Game/Screens/Mvis/Plugins/MvisPluginManager.cs +++ b/osu.Game/Screens/Mvis/Plugins/MvisPluginManager.cs @@ -3,20 +3,21 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using JetBrains.Annotations; using Newtonsoft.Json; using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Development; -using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Logging; using osu.Framework.Platform; +using osu.Game.Screens.Mvis.Misc.PluginResolvers; using osu.Game.Screens.Mvis.Plugins.Config; using osu.Game.Screens.Mvis.Plugins.Types; namespace osu.Game.Screens.Mvis.Plugins { - public class MvisPluginManager : Component + public class MvisPluginManager : CompositeDrawable { private readonly BindableList avaliablePlugins = new BindableList(); private readonly BindableList activePlugins = new BindableList(); @@ -38,8 +39,18 @@ public class MvisPluginManager : Component public int MinimumPluginVersion => 6; private const bool experimental = true; + public readonly IProvideAudioControlPlugin DefaultAudioController = new OsuMusicControllerWrapper(); + private readonly MvisPluginResolver resolver; + private string blockedPluginFilePath => storage.GetFullPath("custom/blocked_plugins.json"); + public MvisPluginManager() + { + resolver = new MvisPluginResolver(this); + + InternalChild = (OsuMusicControllerWrapper)DefaultAudioController; + } + [BackgroundDependencyLoader] private void load() { @@ -68,6 +79,8 @@ private void load() } } + resolver.UpdatePluginDictionary(GetAllPlugins(false)); + if (!DebugUtils.IsDebugBuild && experimental) { Logger.Log($"看上去该版本 ({PluginVersion}) 尚处于实现性阶段。 " @@ -189,6 +202,8 @@ public List GetAllPlugins(bool newInstance) { avaliablePlugins.Add(p.CreatePlugin); } + + resolver.UpdatePluginDictionary(avaliablePlugins.ToList()); } return avaliablePlugins.ToList(); @@ -205,6 +220,13 @@ internal void ExpireOldPlugins() avaliablePlugins.Clear(); } - internal List FunctionBarProviders = new List(); + internal List GetAllFunctionBarProviders() => resolver.GetAllFunctionBarProviders(); + + internal List GetAllAudioControlPlugin() => resolver.GetAllAudioControlPlugin(); + + internal IProvideAudioControlPlugin GetAudioControlByPath([NotNull] string path) => resolver.GetAudioControlPluginByPath(path); + internal IFunctionBarProvider GetFunctionBarProviderByPath([NotNull] string path) => resolver.GetFunctionBarProviderByPath(path); + + public string ToPath([NotNull] object target) => resolver.ToPath(target); } } diff --git a/osu.Game/Screens/Mvis/Plugins/OsuMusicControllerWrapper.cs b/osu.Game/Screens/Mvis/Plugins/OsuMusicControllerWrapper.cs index 2106324f5938..121f1e38379f 100644 --- a/osu.Game/Screens/Mvis/Plugins/OsuMusicControllerWrapper.cs +++ b/osu.Game/Screens/Mvis/Plugins/OsuMusicControllerWrapper.cs @@ -3,7 +3,7 @@ using osu.Framework.Graphics.Audio; using osu.Game.Overlays; using osu.Game.Screens.Mvis.Plugins.Types; -using osu.Game.Screens.Mvis.Skinning; +using osu.Game.Screens.Mvis.SideBar.Settings.Items; namespace osu.Game.Screens.Mvis.Plugins { diff --git a/osu.Game/Screens/Mvis/Plugins/Types/IFunctionBarProvider.cs b/osu.Game/Screens/Mvis/Plugins/Types/IFunctionBarProvider.cs index bd09e60f7f4a..65ccf03aad87 100644 --- a/osu.Game/Screens/Mvis/Plugins/Types/IFunctionBarProvider.cs +++ b/osu.Game/Screens/Mvis/Plugins/Types/IFunctionBarProvider.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using osu.Framework.Graphics; @@ -62,5 +63,7 @@ public interface IFunctionBarProvider : IDrawable /// /// 插件按钮列表 public List GetAllPluginFunctionButton(); + + public Action OnDisable { get; set; } } } diff --git a/osu.Game/Screens/Mvis/Plugins/Types/ToggleableFakeButton.cs b/osu.Game/Screens/Mvis/Plugins/Types/ToggleableFakeButton.cs index a05c5b8a7b42..95b0e12a7a3a 100644 --- a/osu.Game/Screens/Mvis/Plugins/Types/ToggleableFakeButton.cs +++ b/osu.Game/Screens/Mvis/Plugins/Types/ToggleableFakeButton.cs @@ -2,7 +2,6 @@ using osu.Framework.Bindables; using osu.Framework.Graphics.Sprites; using osu.Framework.Localisation; -using osu.Framework.Logging; using osuTK; namespace osu.Game.Screens.Mvis.Plugins.Types @@ -20,8 +19,6 @@ public void Active() { if (!Bindable.Disabled) Bindable.Toggle(); - else - Logger.Log($"无法更改 \"{Title}\" 的值, 因为此Bindable已禁用", level: LogLevel.Important); } public void Active(bool performAction) diff --git a/osu.Game/Screens/Mvis/SideBar/Footer/Footer.cs b/osu.Game/Screens/Mvis/SideBar/Footer/Footer.cs index 81ebbfa23655..56c67aabcc7c 100644 --- a/osu.Game/Screens/Mvis/SideBar/Footer/Footer.cs +++ b/osu.Game/Screens/Mvis/SideBar/Footer/Footer.cs @@ -4,8 +4,6 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; -using osu.Game.Screens.Mvis.Skinning; -using osu.Game.Skinning; namespace osu.Game.Screens.Mvis.SideBar.Footer { @@ -31,24 +29,6 @@ private void load() Anchor = Anchor.BottomCentre; Origin = Anchor.BottomCentre; Masking = true; - - InternalChildren = new Drawable[] - { - new SkinnableComponent( - "MSidebar-BottomBox", - confineMode: ConfineMode.ScaleToFill, - defaultImplementation: _ => createDefaultFooter()) - { - Name = "侧边栏底部横条", - Anchor = Anchor.BottomRight, - Origin = Anchor.BottomRight, - ChildAnchor = Anchor.BottomRight, - ChildOrigin = Anchor.BottomRight, - RelativeSizeAxes = Axes.Both, - CentreComponent = false, - OverrideChildAnchor = true, - } - }; } private Drawable createDefaultFooter() diff --git a/osu.Game/Screens/Mvis/Skinning/PlaceHolder.cs b/osu.Game/Screens/Mvis/SideBar/Settings/Items/PlaceHolder.cs similarity index 61% rename from osu.Game/Screens/Mvis/Skinning/PlaceHolder.cs rename to osu.Game/Screens/Mvis/SideBar/Settings/Items/PlaceHolder.cs index fe9651085c1d..d2bd71e2d1d6 100644 --- a/osu.Game/Screens/Mvis/Skinning/PlaceHolder.cs +++ b/osu.Game/Screens/Mvis/SideBar/Settings/Items/PlaceHolder.cs @@ -1,6 +1,6 @@ using osu.Framework.Graphics; -namespace osu.Game.Screens.Mvis.Skinning +namespace osu.Game.Screens.Mvis.SideBar.Settings.Items { public class PlaceHolder : Drawable { diff --git a/osu.Game/Screens/Mvis/SideBar/Settings/Items/SettingsPieceBasePanel.cs b/osu.Game/Screens/Mvis/SideBar/Settings/Items/SettingsPieceBasePanel.cs index ed81306ea77c..fe823f6e1c02 100644 --- a/osu.Game/Screens/Mvis/SideBar/Settings/Items/SettingsPieceBasePanel.cs +++ b/osu.Game/Screens/Mvis/SideBar/Settings/Items/SettingsPieceBasePanel.cs @@ -10,7 +10,6 @@ using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; -using osu.Game.Screens.Mvis.Skinning; using osuTK; using osuTK.Graphics; using osuTK.Input; diff --git a/osu.Game/Screens/Mvis/SideBar/Settings/Sections/BaseSettings.cs b/osu.Game/Screens/Mvis/SideBar/Settings/Sections/BaseSettings.cs index d879219e37e8..c1df2f528a96 100644 --- a/osu.Game/Screens/Mvis/SideBar/Settings/Sections/BaseSettings.cs +++ b/osu.Game/Screens/Mvis/SideBar/Settings/Sections/BaseSettings.cs @@ -1,4 +1,3 @@ -using System.Collections.Generic; using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; @@ -29,28 +28,17 @@ private void load(MConfigManager config, MvisPluginManager pluginManager, MvisSc config.BindWith(MSetting.MvisInterfaceGreen, iG); config.BindWith(MSetting.MvisInterfaceBlue, iB); - var plugins = new List(); + var audioControlProviders = pluginManager.GetAllAudioControlPlugin(); + var functionBarProviders = pluginManager.GetAllFunctionBarProviders(); + var currentAudioControlPlugin = config.Get(MSetting.MvisCurrentAudioProvider); - IProvideAudioControlPlugin currentprovider = mvisScreen.MusicControllerWrapper; + var currentFunctionbar = config.Get(MSetting.MvisCurrentFunctionBar); - foreach (var pl in pluginManager.GetAllPlugins(false)) - { - if (pl is IProvideAudioControlPlugin pacp) - { - plugins.Add(pacp); + audioControlProviders.Add(pluginManager.DefaultAudioController); - var type = pl.GetType(); + Bindable audioConfigBindable; + Bindable functionBarConfigBindable; - if (currentAudioControlPlugin == $"{type.Namespace}+{type.Name}") - { - currentprovider = pacp; - } - } - } - - plugins.Add(mvisScreen.MusicControllerWrapper); - - Bindable configBindable; AddRange(new Drawable[] { new SettingsSliderPiece @@ -72,12 +60,22 @@ private void load(MConfigManager config, MvisPluginManager pluginManager, MvisSc { Icon = FontAwesome.Solid.Bullseye, Description = "音乐控制插件", - Bindable = configBindable = new Bindable + Bindable = audioConfigBindable = new Bindable { - Value = currentprovider, - Default = mvisScreen.MusicControllerWrapper + Value = pluginManager.GetAudioControlByPath(currentAudioControlPlugin), + Default = pluginManager.DefaultAudioController }, - Values = plugins + Values = audioControlProviders + }, + new ProviderSettingsPiece + { + Icon = FontAwesome.Solid.Bullseye, + Description = "音乐控制插件", + Bindable = functionBarConfigBindable = new Bindable + { + Value = pluginManager.GetFunctionBarProviderByPath(currentFunctionbar) + }, + Values = functionBarProviders }, new SettingsEnumPiece { @@ -115,7 +113,7 @@ private void load(MConfigManager config, MvisPluginManager pluginManager, MvisSc }, }); - configBindable.BindValueChanged(v => + audioConfigBindable.BindValueChanged(v => { if (v.NewValue == null) { @@ -123,15 +121,22 @@ private void load(MConfigManager config, MvisPluginManager pluginManager, MvisSc return; } - var pl = (MvisPlugin)v.NewValue; - var type = pl.GetType(); + config.SetValue(MSetting.MvisCurrentAudioProvider, pluginManager.ToPath(v.NewValue)); + }); + + functionBarConfigBindable.BindValueChanged(v => + { + if (v.NewValue == null) + { + config.SetValue(MSetting.MvisCurrentFunctionBar, string.Empty); + return; + } - config.SetValue(MSetting.MvisCurrentAudioProvider, $"{type.Namespace}+{type.Name}"); + config.SetValue(MSetting.MvisCurrentFunctionBar, pluginManager.ToPath(v.NewValue)); }); } private class ProviderSettingsPiece : SettingsListPiece - where T : IProvideAudioControlPlugin { protected override string GetValueText(T newValue) { diff --git a/osu.Game/Screens/Mvis/Skinning/FullScreenSkinnableComponent.cs b/osu.Game/Screens/Mvis/Skinning/FullScreenSkinnableComponent.cs deleted file mode 100644 index cc68b68bdc09..000000000000 --- a/osu.Game/Screens/Mvis/Skinning/FullScreenSkinnableComponent.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; -using osu.Framework.Allocation; -using osu.Framework.Graphics; -using osu.Game.Skinning; -using osuTK; - -namespace osu.Game.Screens.Mvis.Skinning -{ - public class FullScreenSkinnableComponent : SkinnableComponent - { - protected override Vector2 DrawScale => new Vector2(Parent.DrawHeight / 768); - - public FullScreenSkinnableComponent(string textureName, Func defaultImplementation, Func allowFallback = null, ConfineMode confineMode = ConfineMode.NoScaling, bool masking = false) - : base(textureName, defaultImplementation, allowFallback, confineMode, masking) - { - Size = new Vector2(1366, 768); - } - - [BackgroundDependencyLoader] - private void load() - { - RelativeSizeAxes = Axes.None; - CentreComponent = false; - } - } -} diff --git a/osu.Game/Screens/Mvis/Skinning/SkinnableComponent.cs b/osu.Game/Screens/Mvis/Skinning/SkinnableComponent.cs deleted file mode 100644 index c851784baba2..000000000000 --- a/osu.Game/Screens/Mvis/Skinning/SkinnableComponent.cs +++ /dev/null @@ -1,50 +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 osu.Framework.Allocation; -using osu.Framework.Graphics; -using osu.Game.Skinning; - -namespace osu.Game.Screens.Mvis.Skinning -{ - public class SkinnableComponent : SkinnableDrawable - { - public new MarginPadding Padding - { - get => base.Padding; - set => base.Padding = value; - } - - public SkinnableComponent(string textureName, - Func defaultImplementation, - Func allowFallback = null, - ConfineMode confineMode = ConfineMode.NoScaling, - bool masking = false) - : base(new SkinComponent(textureName), defaultImplementation, confineMode) - { - CentreComponent = false; - OverrideChildAnchor = true; - Masking = masking; - - ChildAnchor = Anchor.Centre; - ChildOrigin = Anchor.Centre; - } - - [BackgroundDependencyLoader] - private void load() - { - CentreComponent = false; - } - - private class SkinComponent : ISkinComponent - { - public string LookupName { get; } - - public SkinComponent(string textureName) - { - LookupName = textureName; - } - } - } -} From 282012af9707108fb6869045d7f92eef6feebf6a Mon Sep 17 00:00:00 2001 From: MATRIX-feather Date: Sun, 15 Aug 2021 08:32:43 +0800 Subject: [PATCH 5/8] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E9=94=81=E5=AE=9A?= =?UTF-8?q?=E6=8C=89=E9=92=AE=E5=9C=A8=E5=9F=BA=E7=A1=80=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E6=9D=A1=E4=B8=8B=E4=B8=8D=E5=B7=A5=E4=BD=9C=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98=20misc:=20=E8=B0=83=E6=95=B4=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E5=80=BC=20misc:=20=E8=B0=83=E6=95=B4audioCo?= =?UTF-8?q?ntrolProvider=E5=9C=A8MvisScreen=E4=B8=AD=E7=AC=AC=E4=B8=80?= =?UTF-8?q?=E6=AC=A1=E8=B5=8B=E5=80=BC=E7=9A=84=E4=BD=8D=E7=BD=AE=20misc:?= =?UTF-8?q?=20=E8=B0=83=E6=95=B4=E5=85=B6=E4=BD=99=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=E7=9A=84=E6=8F=92=E4=BB=B6=E7=89=88=E6=9C=AC=20misc:=20?= =?UTF-8?q?=E8=B0=83=E6=95=B4BottomBar=E6=8F=92=E4=BB=B6=E7=9A=84=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=E5=90=8D=E7=A7=B0=20remove:=20=E7=A7=BB=E9=99=A4?= =?UTF-8?q?=E5=BA=95=E6=A0=8F=E6=8F=92=E4=BB=B6=E7=9A=84=E7=A6=81=E7=94=A8?= =?UTF-8?q?/=E5=90=AF=E7=94=A8=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Mvis.Plugin.BottomBar/LegacyBottomBar.cs | 3 +- Mvis.Plugin.CloudMusicSupport/LyricPlugin.cs | 2 +- .../CollectionHepler.cs | 2 +- Mvis.Plugin.FakeEditor/FakeEditor.cs | 2 +- Mvis.Plugin.SandboxToPanel/SandboxPanel.cs | 2 +- .../BackgroundStoryBoardLoader.cs | 2 +- Mvis.Plugin.Yasp/YaspPlugin.cs | 2 +- osu.Game/Configuration/MConfigManager.cs | 2 +- .../Settings/Sections/Mf/MvisAudioSettings.cs | 7 +- .../Settings/Sections/Mf/MvisUISettings.cs | 5 +- .../PluginResolvers/AudioPluginResolver.cs | 6 ++ osu.Game/Screens/Mvis/MvisScreen.cs | 18 ++--- .../Mvis/Plugins/Internal/DummyFunctionBar.cs | 74 +++++++++++++++++++ .../FallbackFunctionBar/FunctionBar.cs | 6 +- .../Screens/Mvis/Plugins/MvisPluginManager.cs | 12 +++ .../SideBar/Settings/Sections/BaseSettings.cs | 11 ++- 16 files changed, 120 insertions(+), 36 deletions(-) create mode 100644 osu.Game/Screens/Mvis/Plugins/Internal/DummyFunctionBar.cs diff --git a/Mvis.Plugin.BottomBar/LegacyBottomBar.cs b/Mvis.Plugin.BottomBar/LegacyBottomBar.cs index 79d0adabe975..3db1d87282d3 100644 --- a/Mvis.Plugin.BottomBar/LegacyBottomBar.cs +++ b/Mvis.Plugin.BottomBar/LegacyBottomBar.cs @@ -38,14 +38,13 @@ internal class LegacyBottomBar : MvisPlugin, IFunctionBarProvider public LegacyBottomBar() { - Name = "功能条"; + Name = "底栏"; Description = "mf-osu默认功能条"; Author = "MATRIX-夜翎"; Depth = -1; Flags.AddRange(new[] { - PluginFlags.CanDisable, PluginFlags.CanUnload }); diff --git a/Mvis.Plugin.CloudMusicSupport/LyricPlugin.cs b/Mvis.Plugin.CloudMusicSupport/LyricPlugin.cs index 4423f659cac6..50926273f3b6 100644 --- a/Mvis.Plugin.CloudMusicSupport/LyricPlugin.cs +++ b/Mvis.Plugin.CloudMusicSupport/LyricPlugin.cs @@ -41,7 +41,7 @@ public override PluginSidebarPage CreateSidebarPage() public override PluginSidebarSettingsSection CreateSidebarSettingsSection() => new LyricSidebarSection(this); - public override int Version => 5; + public override int Version => 6; private WorkingBeatmap currentWorkingBeatmap; private LyricLineHandler lrcLine; diff --git a/Mvis.Plugin.CollectionSupport/CollectionHepler.cs b/Mvis.Plugin.CollectionSupport/CollectionHepler.cs index 823ce77aadb1..a95b29f5de63 100644 --- a/Mvis.Plugin.CollectionSupport/CollectionHepler.cs +++ b/Mvis.Plugin.CollectionSupport/CollectionHepler.cs @@ -43,7 +43,7 @@ public class CollectionHelper : BindableControlledPlugin, IProvideAudioControlPl protected override bool PostInit() => true; - public override int Version => 5; + public override int Version => 6; public override PluginSidebarPage CreateSidebarPage() => new CollectionPluginPage(this); diff --git a/Mvis.Plugin.FakeEditor/FakeEditor.cs b/Mvis.Plugin.FakeEditor/FakeEditor.cs index 9754ef5eae34..97a21d117a1a 100644 --- a/Mvis.Plugin.FakeEditor/FakeEditor.cs +++ b/Mvis.Plugin.FakeEditor/FakeEditor.cs @@ -36,7 +36,7 @@ protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnl private WorkingBeatmap beatmap; - public override int Version => 5; + public override int Version => 6; public FakeEditor() { diff --git a/Mvis.Plugin.SandboxToPanel/SandboxPanel.cs b/Mvis.Plugin.SandboxToPanel/SandboxPanel.cs index bf127f8e78c0..0572a44cdf84 100644 --- a/Mvis.Plugin.SandboxToPanel/SandboxPanel.cs +++ b/Mvis.Plugin.SandboxToPanel/SandboxPanel.cs @@ -17,7 +17,7 @@ namespace Mvis.Plugin.Sandbox public class SandboxPanel : BindableControlledPlugin { public override TargetLayer Target => TargetLayer.Foreground; - public override int Version => 5; + public override int Version => 6; public Bindable CurrentBeatmap = new Bindable(); public SandboxPanel() diff --git a/Mvis.Plugin.StoryboardSupport/BackgroundStoryBoardLoader.cs b/Mvis.Plugin.StoryboardSupport/BackgroundStoryBoardLoader.cs index b7febbdd3378..bb5fd043102d 100644 --- a/Mvis.Plugin.StoryboardSupport/BackgroundStoryBoardLoader.cs +++ b/Mvis.Plugin.StoryboardSupport/BackgroundStoryBoardLoader.cs @@ -148,7 +148,7 @@ protected override bool PostInit() return true; } - public override int Version => 5; + public override int Version => 6; private Drawable prevProxy; diff --git a/Mvis.Plugin.Yasp/YaspPlugin.cs b/Mvis.Plugin.Yasp/YaspPlugin.cs index 8fc156d6fac3..07872f23b965 100644 --- a/Mvis.Plugin.Yasp/YaspPlugin.cs +++ b/Mvis.Plugin.Yasp/YaspPlugin.cs @@ -38,7 +38,7 @@ public override PluginSettingsSubSection CreateSettingsSubSection() public override PluginSidebarSettingsSection CreateSidebarSettingsSection() => new YaspSidebarSection(this); - public override int Version => 5; + public override int Version => 6; public YaspPlugin() { diff --git a/osu.Game/Configuration/MConfigManager.cs b/osu.Game/Configuration/MConfigManager.cs index f361e3d4c754..4c0fe4a2f77d 100644 --- a/osu.Game/Configuration/MConfigManager.cs +++ b/osu.Game/Configuration/MConfigManager.cs @@ -54,7 +54,7 @@ protected override void InitialiseDefaults() SetDefault(MSetting.MvisInterfaceRed, value: 0, 0, 255f); SetDefault(MSetting.MvisInterfaceGreen, value: 119f, 0, 255f); SetDefault(MSetting.MvisInterfaceBlue, value: 255f, 0, 255f); - SetDefault(MSetting.MvisCurrentAudioProvider, "OsuMusicControllerWrapper@osu.Game.Screens.Mvis.Plugins"); + SetDefault(MSetting.MvisCurrentAudioProvider, "a@b"); SetDefault(MSetting.MvisCurrentFunctionBar, "LegacyBottomBar@Mvis.Plugin.BottomBar"); SetDefault(MSetting.MvisTabControlPosition, TabControlPosition.Right); diff --git a/osu.Game/Overlays/Settings/Sections/Mf/MvisAudioSettings.cs b/osu.Game/Overlays/Settings/Sections/Mf/MvisAudioSettings.cs index effc454fcc89..e7ed7efd9bb2 100644 --- a/osu.Game/Overlays/Settings/Sections/Mf/MvisAudioSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Mf/MvisAudioSettings.cs @@ -53,9 +53,7 @@ private void load(MConfigManager config, MvisPluginManager pluginManager) foreach (var pl in plugins) { - var type = pl.GetType(); - - if (currentAudioControlPlugin == type.Name + "@" + type.Namespace) + if (currentAudioControlPlugin == pluginManager.ToPath(pl)) { dropdown.Current.Value = pl; } @@ -71,9 +69,8 @@ private void load(MConfigManager config, MvisPluginManager pluginManager) } var pl = (MvisPlugin)v.NewValue; - var type = pl.GetType(); - config.SetValue(MSetting.MvisCurrentAudioProvider, type.Name + "@" + type.Namespace); + config.SetValue(MSetting.MvisCurrentAudioProvider, pluginManager.ToPath(pl)); }); } diff --git a/osu.Game/Overlays/Settings/Sections/Mf/MvisUISettings.cs b/osu.Game/Overlays/Settings/Sections/Mf/MvisUISettings.cs index f7348c706570..3465bef80a27 100644 --- a/osu.Game/Overlays/Settings/Sections/Mf/MvisUISettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Mf/MvisUISettings.cs @@ -91,6 +91,8 @@ private void load(MConfigManager config, MvisPluginManager pluginManager) }; var plugins = pluginManager.GetAllFunctionBarProviders(); + plugins.Insert(0, pluginManager.DummyFunctionBar); + var currentFunctionBar = config.Get(MSetting.MvisCurrentFunctionBar); foreach (var pl in plugins) @@ -111,9 +113,8 @@ private void load(MConfigManager config, MvisPluginManager pluginManager) } var pl = (MvisPlugin)v.NewValue; - var type = pl.GetType(); - config.SetValue(MSetting.MvisCurrentFunctionBar, type.Name + "@" + type.Namespace); + config.SetValue(MSetting.MvisCurrentFunctionBar, pluginManager.ToPath(pl)); }); } diff --git a/osu.Game/Screens/Mvis/Misc/PluginResolvers/AudioPluginResolver.cs b/osu.Game/Screens/Mvis/Misc/PluginResolvers/AudioPluginResolver.cs index e0263d54529e..51e1b7a18a33 100644 --- a/osu.Game/Screens/Mvis/Misc/PluginResolvers/AudioPluginResolver.cs +++ b/osu.Game/Screens/Mvis/Misc/PluginResolvers/AudioPluginResolver.cs @@ -46,6 +46,12 @@ internal void UpdatePluginDictionary(List newPluginList) audioPluginDictionary[defaultAudioControlPath] = pluginManager.DefaultAudioController; } + internal bool RemoveFunctionBarProvider(IFunctionBarProvider functionBarProvider) + => functionBarDictionary.Remove(ToPath(functionBarProvider), out functionBarProvider); + + internal bool RemoveAudioControlProvider(IProvideAudioControlPlugin provideAudioControlPlugin) + => audioPluginDictionary.Remove(ToPath(provideAudioControlPlugin), out provideAudioControlPlugin); + private readonly ConcurrentDictionary audioPluginDictionary = new ConcurrentDictionary(); private readonly ConcurrentDictionary functionBarDictionary = new ConcurrentDictionary(); diff --git a/osu.Game/Screens/Mvis/MvisScreen.cs b/osu.Game/Screens/Mvis/MvisScreen.cs index 8cd2db3eeef1..784611537130 100644 --- a/osu.Game/Screens/Mvis/MvisScreen.cs +++ b/osu.Game/Screens/Mvis/MvisScreen.cs @@ -395,9 +395,6 @@ private void load(MConfigManager config, IdleTracker idleTracker) } }; - //todo: 找出为啥audioControlProvider会在被赋值前访问 - audioControlProvider = pluginManager.DefaultAudioController; - functionProviders.AddRange(new IFunctionProvider[] { new FakeButton @@ -487,11 +484,7 @@ private void load(MConfigManager config, IdleTracker idleTracker) lockButton = new ToggleableFakeButton { Description = MvisBaseStrings.LockInterface, - Action = () => - { - showPluginEntriesTemporary(); - lockButton.Active(); - }, + Action = showPluginEntriesTemporary, Type = FunctionType.Plugin, Icon = FontAwesome.Solid.Lock } @@ -500,6 +493,9 @@ private void load(MConfigManager config, IdleTracker idleTracker) protected override void LoadComplete() { + //todo: 找出为啥audioControlProvider会在被赋值前访问 + audioControlProvider = pluginManager.DefaultAudioController; + //各种BindValueChanged //这部分放load会导致当前屏幕为主界面时,播放器会在后台相应设置变动 loadList.BindCollectionChanged(onLoadListChanged); @@ -688,7 +684,11 @@ private void setupKeyBindings() keyBindings[GlobalAction.MvisMusicPrev] = () => prevButton.Active(); keyBindings[GlobalAction.MvisMusicNext] = () => nextButton.Active(); keyBindings[GlobalAction.MvisOpenInSongSelect] = () => soloButton.Active(); - keyBindings[GlobalAction.MvisToggleOverlayLock] = () => lockButton.Active(true); + keyBindings[GlobalAction.MvisToggleOverlayLock] = () => + { + lockButton.Active(true); + lockButton.Active(); + }; //todo: 修复会在Bottombar中重复调用的问题 keyBindings[GlobalAction.MvisTogglePluginPage] = () => pluginButton.Active(); keyBindings[GlobalAction.MvisTogglePause] = () => songProgressButton.Active(true); keyBindings[GlobalAction.MvisToggleTrackLoop] = () => loopToggleButton.Active(); diff --git a/osu.Game/Screens/Mvis/Plugins/Internal/DummyFunctionBar.cs b/osu.Game/Screens/Mvis/Plugins/Internal/DummyFunctionBar.cs new file mode 100644 index 000000000000..c02a8a89614a --- /dev/null +++ b/osu.Game/Screens/Mvis/Plugins/Internal/DummyFunctionBar.cs @@ -0,0 +1,74 @@ +using System; +using System.Collections.Generic; +using osu.Framework.Graphics; +using osu.Game.Screens.Mvis.Plugins.Types; + +namespace osu.Game.Screens.Mvis.Plugins.Internal +{ + public class DummyFunctionBar : MvisPlugin, IFunctionBarProvider + { + public DummyFunctionBar() + { + Name = "无"; + } + + protected override Drawable CreateContent() + { + throw new NotImplementedException(); + } + + protected override bool OnContentLoaded(Drawable content) + { + throw new NotImplementedException(); + } + + protected override bool PostInit() + { + throw new NotImplementedException(); + } + + public override int Version => 6; + + public float GetSafeAreaPadding() + { + throw new NotImplementedException(); + } + + public bool OkForHide() + { + throw new NotImplementedException(); + } + + public bool AddFunctionControl(IFunctionProvider provider) + { + throw new NotImplementedException(); + } + + public bool AddFunctionControls(List providers) + { + throw new NotImplementedException(); + } + + public bool SetFunctionControls(List providers) + { + throw new NotImplementedException(); + } + + public void Remove(IFunctionProvider provider) + { + throw new NotImplementedException(); + } + + public void ShowFunctionControlTemporary() + { + throw new NotImplementedException(); + } + + public List GetAllPluginFunctionButton() + { + throw new NotImplementedException(); + } + + public Action OnDisable { get; set; } + } +} diff --git a/osu.Game/Screens/Mvis/Plugins/Internal/FallbackFunctionBar/FunctionBar.cs b/osu.Game/Screens/Mvis/Plugins/Internal/FallbackFunctionBar/FunctionBar.cs index 2d149d616a17..eac8f7257299 100644 --- a/osu.Game/Screens/Mvis/Plugins/Internal/FallbackFunctionBar/FunctionBar.cs +++ b/osu.Game/Screens/Mvis/Plugins/Internal/FallbackFunctionBar/FunctionBar.cs @@ -5,9 +5,7 @@ using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Shapes; -using osu.Framework.Localisation; using osu.Game.Graphics.Containers; using osu.Game.Screens.Mvis.Plugins.Types; using osuTK; @@ -15,7 +13,7 @@ namespace osu.Game.Screens.Mvis.Plugins.Internal.FallbackFunctionBar { - public class FunctionBar : MvisPlugin, IFunctionBarProvider, IHasTooltip + public class FunctionBar : MvisPlugin, IFunctionBarProvider { public float GetSafeAreaPadding() => Height; @@ -189,7 +187,5 @@ public ButtonNotFoundException(IFunctionProvider provider) { } } - - public LocalisableString TooltipText => "这是一个后备功能条,如果你没在开发功能条插件,那么这很可能是个错误。\n请检查你的插件配置"; } } diff --git a/osu.Game/Screens/Mvis/Plugins/MvisPluginManager.cs b/osu.Game/Screens/Mvis/Plugins/MvisPluginManager.cs index 5a5f35f6e006..ca3c57fc3509 100644 --- a/osu.Game/Screens/Mvis/Plugins/MvisPluginManager.cs +++ b/osu.Game/Screens/Mvis/Plugins/MvisPluginManager.cs @@ -13,6 +13,7 @@ using osu.Framework.Platform; using osu.Game.Screens.Mvis.Misc.PluginResolvers; using osu.Game.Screens.Mvis.Plugins.Config; +using osu.Game.Screens.Mvis.Plugins.Internal; using osu.Game.Screens.Mvis.Plugins.Types; namespace osu.Game.Screens.Mvis.Plugins @@ -40,6 +41,8 @@ public class MvisPluginManager : CompositeDrawable private const bool experimental = true; public readonly IProvideAudioControlPlugin DefaultAudioController = new OsuMusicControllerWrapper(); + public readonly IFunctionBarProvider DummyFunctionBar = new DummyFunctionBar(); + private readonly MvisPluginResolver resolver; private string blockedPluginFilePath => storage.GetFullPath("custom/blocked_plugins.json"); @@ -119,6 +122,12 @@ internal bool UnLoadPlugin(MvisPlugin pl, bool blockFromFutureLoad = false) try { + if (pl is IFunctionBarProvider functionBarProvider) + resolver.RemoveFunctionBarProvider(functionBarProvider); + + if (pl is IProvideAudioControlPlugin provideAudioControlPlugin) + resolver.RemoveAudioControlProvider(provideAudioControlPlugin); + pl.UnLoad(); OnPluginUnLoad?.Invoke(pl); @@ -146,6 +155,9 @@ internal bool UnLoadPlugin(MvisPlugin pl, bool blockFromFutureLoad = false) container.Remove(pl); pl.Dispose(); } + + //刷新列表 + resolver.UpdatePluginDictionary(GetAllPlugins(false)); } return true; diff --git a/osu.Game/Screens/Mvis/SideBar/Settings/Sections/BaseSettings.cs b/osu.Game/Screens/Mvis/SideBar/Settings/Sections/BaseSettings.cs index c1df2f528a96..99de9ee712ae 100644 --- a/osu.Game/Screens/Mvis/SideBar/Settings/Sections/BaseSettings.cs +++ b/osu.Game/Screens/Mvis/SideBar/Settings/Sections/BaseSettings.cs @@ -28,14 +28,12 @@ private void load(MConfigManager config, MvisPluginManager pluginManager, MvisSc config.BindWith(MSetting.MvisInterfaceGreen, iG); config.BindWith(MSetting.MvisInterfaceBlue, iB); - var audioControlProviders = pluginManager.GetAllAudioControlPlugin(); var functionBarProviders = pluginManager.GetAllFunctionBarProviders(); + functionBarProviders.Insert(0, pluginManager.DummyFunctionBar); var currentAudioControlPlugin = config.Get(MSetting.MvisCurrentAudioProvider); var currentFunctionbar = config.Get(MSetting.MvisCurrentFunctionBar); - audioControlProviders.Add(pluginManager.DefaultAudioController); - Bindable audioConfigBindable; Bindable functionBarConfigBindable; @@ -65,15 +63,16 @@ private void load(MConfigManager config, MvisPluginManager pluginManager, MvisSc Value = pluginManager.GetAudioControlByPath(currentAudioControlPlugin), Default = pluginManager.DefaultAudioController }, - Values = audioControlProviders + Values = pluginManager.GetAllAudioControlPlugin() }, new ProviderSettingsPiece { Icon = FontAwesome.Solid.Bullseye, - Description = "音乐控制插件", + Description = "底栏插件", Bindable = functionBarConfigBindable = new Bindable { - Value = pluginManager.GetFunctionBarProviderByPath(currentFunctionbar) + Value = pluginManager.GetFunctionBarProviderByPath(currentFunctionbar), + Default = pluginManager.DummyFunctionBar }, Values = functionBarProviders }, From 5bb0dadfd6845ede88f9bd1e71e2af5d5426e481 Mon Sep 17 00:00:00 2001 From: MATRIX-feather Date: Sun, 15 Aug 2021 08:48:21 +0800 Subject: [PATCH 6/8] =?UTF-8?q?new:=20=E4=B8=BA=E6=96=B0=E7=9A=84=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E9=A1=B9=E6=B7=BB=E5=8A=A0=E5=A4=9A=E8=AF=AD=E8=A8=80?= =?UTF-8?q?=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- M.Resources/Localisation/Mvis/Plugins/CloudMusicStrings.cs | 6 ++++++ Mvis.Plugin.CloudMusicSupport/UI/LyricSidebarSection.cs | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/M.Resources/Localisation/Mvis/Plugins/CloudMusicStrings.cs b/M.Resources/Localisation/Mvis/Plugins/CloudMusicStrings.cs index 211f0275df8b..82e0d87dcd4c 100644 --- a/M.Resources/Localisation/Mvis/Plugins/CloudMusicStrings.cs +++ b/M.Resources/Localisation/Mvis/Plugins/CloudMusicStrings.cs @@ -7,6 +7,12 @@ public class CloudMusicStrings private const string prefix = @"M.Resources.Localisation.Mvis.Plugins.CloudMusicStrings"; //设置 + public static LocalisableString LocationDirection => new TranslatableString(getKey(@"location_direction"), @"位置方向"); + + public static LocalisableString PositionX => new TranslatableString(getKey(@"pos_x"), @"横向位移"); + + public static LocalisableString PositionY => new TranslatableString(getKey(@"pox_y"), @"纵向位移"); + public static LocalisableString UseDrawablePool => new TranslatableString(getKey(@"use_drawable_pool"), @"使用DrawablePool"); public static LocalisableString ExperimentalWarning => new TranslatableString(getKey(@"experimental_warning"), @"试验性功能!"); diff --git a/Mvis.Plugin.CloudMusicSupport/UI/LyricSidebarSection.cs b/Mvis.Plugin.CloudMusicSupport/UI/LyricSidebarSection.cs index 1d98c56875c3..eaee4f5ff788 100644 --- a/Mvis.Plugin.CloudMusicSupport/UI/LyricSidebarSection.cs +++ b/Mvis.Plugin.CloudMusicSupport/UI/LyricSidebarSection.cs @@ -68,19 +68,19 @@ private void load() }, new SettingsAnchorPiece { - Description = "Direction", + Description = CloudMusicStrings.LocationDirection, Icon = FontAwesome.Solid.Anchor, Bindable = config.GetBindable(LyricSettings.LyricDirection) }, new SettingsSliderPiece { - Description = "横向位移", + Description = CloudMusicStrings.PositionX, Bindable = config.GetBindable(LyricSettings.LyricPositionX), DisplayAsPercentage = true }, new SettingsSliderPiece { - Description = "纵向位移", + Description = CloudMusicStrings.PositionY, Bindable = config.GetBindable(LyricSettings.LyricPositionY), DisplayAsPercentage = true } From de229e3e7ff4c313906ff597b8b44a6e4a7029f9 Mon Sep 17 00:00:00 2001 From: MATRIX-feather Date: Sun, 15 Aug 2021 09:01:44 +0800 Subject: [PATCH 7/8] =?UTF-8?q?enchance:=20=E4=BC=98=E5=8C=96=E8=B0=83?= =?UTF-8?q?=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Buttons/BottomBarButton.cs | 5 +---- .../Buttons/BottomBarSwitchButton.cs | 20 ++++++----------- .../Buttons/SongProgressButton.cs | 2 +- Mvis.Plugin.BottomBar/LegacyBottomBar.cs | 2 +- osu.Game/Screens/Mvis/MvisScreen.cs | 22 ++++++++----------- .../FallbackFunctionBar/SimpleBarButton.cs | 8 +++---- .../ToggleableBarButton.cs | 18 +++++---------- .../Plugins/Types/ToggleableFakeButton.cs | 8 +------ 8 files changed, 29 insertions(+), 56 deletions(-) diff --git a/Mvis.Plugin.BottomBar/Buttons/BottomBarButton.cs b/Mvis.Plugin.BottomBar/Buttons/BottomBarButton.cs index c30ee17b93ac..90aa7eef8e60 100644 --- a/Mvis.Plugin.BottomBar/Buttons/BottomBarButton.cs +++ b/Mvis.Plugin.BottomBar/Buttons/BottomBarButton.cs @@ -1,4 +1,3 @@ -using System; using JetBrains.Annotations; using osu.Framework.Allocation; using osu.Framework.Extensions.Color4Extensions; @@ -47,7 +46,6 @@ public LocalisableString Title private Container content; private IconUsage emptyIcon => new IconUsage(); - public Action Action { get; set; } public LocalisableString TooltipText { get; set; } protected readonly OsuSpriteText SpriteText = new OsuSpriteText @@ -81,7 +79,6 @@ public BottomBarButton(IFunctionProvider provider = null) if (provider != null) { - Action = provider.Action; Icon = provider.Icon; SpriteText.Text = provider.Title; SpriteIcon.Icon = provider.Icon; @@ -203,7 +200,7 @@ protected override void OnMouseUp(MouseUpEvent e) protected override bool OnClick(ClickEvent e) { OnClickAnimation(); - Action?.Invoke(); + Provider.Active(); return true; } diff --git a/Mvis.Plugin.BottomBar/Buttons/BottomBarSwitchButton.cs b/Mvis.Plugin.BottomBar/Buttons/BottomBarSwitchButton.cs index dc6df7135e5c..b589a8ffd634 100644 --- a/Mvis.Plugin.BottomBar/Buttons/BottomBarSwitchButton.cs +++ b/Mvis.Plugin.BottomBar/Buttons/BottomBarSwitchButton.cs @@ -15,15 +15,12 @@ public class BottomBarSwitchButton : BottomBarButton protected Color4 ActivateColor => ColourProvider.Highlight1; protected Color4 InActivateColor => ColourProvider.Background3; - public BottomBarSwitchButton(IFunctionProvider provider = null) + public BottomBarSwitchButton(IToggleableFunctionProvider provider) : base(provider) { Value.Value = Default; - if (provider is IToggleableFunctionProvider toggleableProvider) - { - Value.BindTo(toggleableProvider.Bindable); - } + Value.BindTo(provider.Bindable); } protected override void LoadComplete() @@ -42,17 +39,14 @@ private void onDisabledChanged(bool disabled) } protected override bool OnClick(ClickEvent e) - { - Toggle(); - return base.OnClick(e); - } - - public void Toggle() { if (Value.Disabled) + { this.FlashColour(Color4.Red, 1000, Easing.OutQuint); - else - Value.Toggle(); + return false; + } + + return base.OnClick(e); } private void updateVisuals(bool animate = false) diff --git a/Mvis.Plugin.BottomBar/Buttons/SongProgressButton.cs b/Mvis.Plugin.BottomBar/Buttons/SongProgressButton.cs index 2ce77d9fe0f3..5ffa0b65c0b1 100644 --- a/Mvis.Plugin.BottomBar/Buttons/SongProgressButton.cs +++ b/Mvis.Plugin.BottomBar/Buttons/SongProgressButton.cs @@ -19,7 +19,7 @@ public class SongProgressButton : BottomBarSwitchButton private string formatTime(TimeSpan timeSpan) => $"{(timeSpan < TimeSpan.Zero ? "-" : "")}{Math.Floor(timeSpan.Duration().TotalMinutes)}:{timeSpan.Duration().Seconds:D2}"; - public SongProgressButton(IFunctionProvider provider) + public SongProgressButton(IToggleableFunctionProvider provider) : base(provider) { AutoSizeAxes = Axes.X; diff --git a/Mvis.Plugin.BottomBar/LegacyBottomBar.cs b/Mvis.Plugin.BottomBar/LegacyBottomBar.cs index 3db1d87282d3..aee7771f8aba 100644 --- a/Mvis.Plugin.BottomBar/LegacyBottomBar.cs +++ b/Mvis.Plugin.BottomBar/LegacyBottomBar.cs @@ -175,7 +175,7 @@ public bool AddFunctionControl(IFunctionProvider provider) case FunctionType.ProgressDisplay: button.Dispose(); - centreContent.Add(new SongProgressButton(provider)); + centreContent.Add(new SongProgressButton((IToggleableFunctionProvider)provider)); break; default: diff --git a/osu.Game/Screens/Mvis/MvisScreen.cs b/osu.Game/Screens/Mvis/MvisScreen.cs index 784611537130..78585ac065de 100644 --- a/osu.Game/Screens/Mvis/MvisScreen.cs +++ b/osu.Game/Screens/Mvis/MvisScreen.cs @@ -681,19 +681,15 @@ private void changeFunctionBarProvider(IFunctionBarProvider target) private void setupKeyBindings() { - keyBindings[GlobalAction.MvisMusicPrev] = () => prevButton.Active(); - keyBindings[GlobalAction.MvisMusicNext] = () => nextButton.Active(); - keyBindings[GlobalAction.MvisOpenInSongSelect] = () => soloButton.Active(); - keyBindings[GlobalAction.MvisToggleOverlayLock] = () => - { - lockButton.Active(true); - lockButton.Active(); - }; //todo: 修复会在Bottombar中重复调用的问题 - keyBindings[GlobalAction.MvisTogglePluginPage] = () => pluginButton.Active(); - keyBindings[GlobalAction.MvisTogglePause] = () => songProgressButton.Active(true); - keyBindings[GlobalAction.MvisToggleTrackLoop] = () => loopToggleButton.Active(); - keyBindings[GlobalAction.MvisTogglePlayList] = () => sidebarToggleButton.Active(); - keyBindings[GlobalAction.MvisForceLockOverlayChanges] = () => disableChangesButton.Active(); + keyBindings[GlobalAction.MvisMusicPrev] = prevButton.Active; + keyBindings[GlobalAction.MvisMusicNext] = nextButton.Active; + keyBindings[GlobalAction.MvisOpenInSongSelect] = soloButton.Active; + keyBindings[GlobalAction.MvisToggleOverlayLock] = lockButton.Active; + keyBindings[GlobalAction.MvisTogglePluginPage] = pluginButton.Active; + keyBindings[GlobalAction.MvisTogglePause] = songProgressButton.Active; + keyBindings[GlobalAction.MvisToggleTrackLoop] = loopToggleButton.Active; + keyBindings[GlobalAction.MvisTogglePlayList] = sidebarToggleButton.Active; + keyBindings[GlobalAction.MvisForceLockOverlayChanges] = disableChangesButton.Active; keyBindings[GlobalAction.Back] = () => { if (sidebar.IsPresent && sidebar.State.Value == Visibility.Visible) diff --git a/osu.Game/Screens/Mvis/Plugins/Internal/FallbackFunctionBar/SimpleBarButton.cs b/osu.Game/Screens/Mvis/Plugins/Internal/FallbackFunctionBar/SimpleBarButton.cs index 605a01726824..2a4ed0e7cc1f 100644 --- a/osu.Game/Screens/Mvis/Plugins/Internal/FallbackFunctionBar/SimpleBarButton.cs +++ b/osu.Game/Screens/Mvis/Plugins/Internal/FallbackFunctionBar/SimpleBarButton.cs @@ -35,9 +35,7 @@ public class SimpleBarButton : CompositeDrawable, IHasTooltip public LocalisableString TooltipText { get; } - public IFunctionProvider Provider { get; set; } - - private Action action { get; set; } + public readonly IFunctionProvider Provider; protected LocalisableString Title { @@ -63,7 +61,7 @@ public SimpleBarButton(IFunctionProvider provider) { TooltipText = provider.Description; Width = Math.Max(provider.Size.X, 40); - action = provider.Action; + Provider = provider; Title = provider.Title; Icon = provider.Icon; @@ -109,7 +107,7 @@ protected override void OnHoverLost(HoverLostEvent e) protected override bool OnClick(ClickEvent e) { - action?.Invoke(); + Provider.Active(); return base.OnClick(e); } } diff --git a/osu.Game/Screens/Mvis/Plugins/Internal/FallbackFunctionBar/ToggleableBarButton.cs b/osu.Game/Screens/Mvis/Plugins/Internal/FallbackFunctionBar/ToggleableBarButton.cs index 7259d05e1000..ee66dda8d900 100644 --- a/osu.Game/Screens/Mvis/Plugins/Internal/FallbackFunctionBar/ToggleableBarButton.cs +++ b/osu.Game/Screens/Mvis/Plugins/Internal/FallbackFunctionBar/ToggleableBarButton.cs @@ -17,10 +17,7 @@ public class ToggleableBarButton : SimpleBarButton public ToggleableBarButton(IToggleableFunctionProvider provider) : base(provider) { - if (provider is IToggleableFunctionProvider toggleableFunctionProvider) - { - Value.BindTo(toggleableFunctionProvider.Bindable); - } + Value.BindTo(provider.Bindable); } [BackgroundDependencyLoader] @@ -50,17 +47,14 @@ private void onValueChanged(ValueChangedEvent v) } protected override bool OnClick(ClickEvent e) - { - Toggle(); - return base.OnClick(e); - } - - public void Toggle() { if (Value.Disabled) + { this.FlashColour(Color4.Red, 1000, Easing.OutQuint); - else - Value.Toggle(); + return false; + } + + return base.OnClick(e); } } } diff --git a/osu.Game/Screens/Mvis/Plugins/Types/ToggleableFakeButton.cs b/osu.Game/Screens/Mvis/Plugins/Types/ToggleableFakeButton.cs index 95b0e12a7a3a..b8bf9e6002ca 100644 --- a/osu.Game/Screens/Mvis/Plugins/Types/ToggleableFakeButton.cs +++ b/osu.Game/Screens/Mvis/Plugins/Types/ToggleableFakeButton.cs @@ -19,14 +19,8 @@ public void Active() { if (!Bindable.Disabled) Bindable.Toggle(); - } - public void Active(bool performAction) - { - if (performAction) - Action?.Invoke(); - else - Active(); + Action?.Invoke(); } public BindableBool Bindable { get; set; } = new BindableBool(); From 823e85646a7c7aa4dfabead97fc03e55050d73d8 Mon Sep 17 00:00:00 2001 From: MATRIX-feather Date: Sun, 15 Aug 2021 09:37:49 +0800 Subject: [PATCH 8/8] =?UTF-8?q?new:=20=E5=83=8Fosu!=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=96=B0=E5=A2=9E=E7=9A=84=E6=AD=8C=E8=AF=8D?= =?UTF-8?q?=E6=8F=92=E4=BB=B6=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UI/LyricSettingsSubSection.cs | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/Mvis.Plugin.CloudMusicSupport/UI/LyricSettingsSubSection.cs b/Mvis.Plugin.CloudMusicSupport/UI/LyricSettingsSubSection.cs index 00dbcf17b73d..7d35d1d61412 100644 --- a/Mvis.Plugin.CloudMusicSupport/UI/LyricSettingsSubSection.cs +++ b/Mvis.Plugin.CloudMusicSupport/UI/LyricSettingsSubSection.cs @@ -67,6 +67,35 @@ private void load() LabelText = CloudMusicStrings.LyricAutoScrollMain, Current = config.GetBindable(LyricSettings.AutoScrollToCurrent) }, + new SettingsDropdown + { + LabelText = CloudMusicStrings.LocationDirection, + Current = config.GetBindable(LyricSettings.LyricDirection), + Items = new[] + { + Anchor.TopLeft, + Anchor.TopCentre, + Anchor.TopRight, + Anchor.CentreLeft, + Anchor.Centre, + Anchor.CentreRight, + Anchor.BottomLeft, + Anchor.BottomCentre, + Anchor.BottomRight, + } + }, + new SettingsSlider + { + LabelText = CloudMusicStrings.PositionX, + Current = config.GetBindable(LyricSettings.LyricPositionX), + DisplayAsPercentage = true + }, + new SettingsSlider + { + LabelText = CloudMusicStrings.PositionY, + Current = config.GetBindable(LyricSettings.LyricPositionY), + DisplayAsPercentage = true + } }; useDrawablePoolCheckBox.WarningText = CloudMusicStrings.ExperimentalWarning;