This repository has been archived by the owner on Jun 11, 2023. It is now read-only.
forked from ppy/osu
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
62 changed files
with
1,645 additions
and
748 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using osu.Game.Screens.Mvis.Plugins; | ||
|
||
namespace Mvis.Plugin.BottomBar | ||
{ | ||
public class BottomBarProvider : MvisPluginProvider | ||
{ | ||
public override MvisPlugin CreatePlugin => new LegacyBottomBar(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,25 @@ | ||
// Copyright (c) ppy Pty Ltd <[email protected]>. 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; | ||
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; | ||
using osu.Game.Screens.Mvis.Plugins.Types; | ||
using osuTK; | ||
using osuTK.Graphics; | ||
|
||
namespace osu.Game.Screens.Mvis.BottomBar.Buttons | ||
namespace Mvis.Plugin.BottomBar.Buttons | ||
{ | ||
public class BottomBarButton : CompositeDrawable, IHasTooltip | ||
{ | ||
|
@@ -31,34 +28,26 @@ 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 LocalisableString TooltipText { get; set; } | ||
|
||
protected readonly OsuSpriteText SpriteText = new OsuSpriteText | ||
{ | ||
Anchor = Anchor.Centre, | ||
|
@@ -79,9 +68,24 @@ public LocalisableString Text | |
set => base.AutoSizeAxes = value; | ||
} | ||
|
||
public BottomBarButton() | ||
public readonly IFunctionProvider Provider; | ||
|
||
public BottomBarButton(IFunctionProvider provider = null) | ||
{ | ||
Size = new Vector2(30); | ||
|
||
Anchor = Anchor.Centre; | ||
Origin = Anchor.Centre; | ||
|
||
if (provider != null) | ||
{ | ||
Icon = provider.Icon; | ||
SpriteText.Text = provider.Title; | ||
SpriteIcon.Icon = provider.Icon; | ||
TooltipText = provider.Description; | ||
Size = provider.Size; | ||
Provider = provider; | ||
} | ||
} | ||
|
||
[BackgroundDependencyLoader] | ||
|
@@ -103,14 +107,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 +135,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 | ||
|
@@ -197,7 +200,7 @@ protected override void OnMouseUp(MouseUpEvent e) | |
protected override bool OnClick(ClickEvent e) | ||
{ | ||
OnClickAnimation(); | ||
Action?.Invoke(); | ||
Provider.Active(); | ||
|
||
return true; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
using osu.Framework.Bindables; | ||
using osu.Framework.Graphics; | ||
using osu.Framework.Input.Events; | ||
using osu.Game.Screens.Mvis.Plugins.Types; | ||
using osuTK.Graphics; | ||
|
||
namespace Mvis.Plugin.BottomBar.Buttons | ||
{ | ||
public class BottomBarSwitchButton : BottomBarButton | ||
{ | ||
public BindableBool Value = new BindableBool(); | ||
|
||
public bool Default { get; set; } | ||
|
||
protected Color4 ActivateColor => ColourProvider.Highlight1; | ||
protected Color4 InActivateColor => ColourProvider.Background3; | ||
|
||
public BottomBarSwitchButton(IToggleableFunctionProvider provider) | ||
: base(provider) | ||
{ | ||
Value.Value = Default; | ||
|
||
Value.BindTo(provider.Bindable); | ||
} | ||
|
||
protected override void LoadComplete() | ||
{ | ||
Value.BindValueChanged(_ => updateVisuals(true), true); | ||
Value.BindDisabledChanged(onDisabledChanged, true); | ||
|
||
ColourProvider.HueColour.BindValueChanged(_ => updateVisuals()); | ||
|
||
base.LoadComplete(); | ||
} | ||
|
||
private void onDisabledChanged(bool disabled) | ||
{ | ||
this.FadeColour(disabled ? Color4.Gray : Color4.White, 300, Easing.OutQuint); | ||
} | ||
|
||
protected override bool OnClick(ClickEvent e) | ||
{ | ||
if (Value.Disabled) | ||
{ | ||
this.FlashColour(Color4.Red, 1000, Easing.OutQuint); | ||
return false; | ||
} | ||
|
||
return base.OnClick(e); | ||
} | ||
|
||
private void updateVisuals(bool animate = false) | ||
{ | ||
var duration = animate ? 500 : 0; | ||
|
||
switch (Value.Value) | ||
{ | ||
case true: | ||
BgBox.FadeColour(ActivateColor, duration, Easing.OutQuint); | ||
ContentFillFlow.FadeColour(Colour4.Black, duration, Easing.OutQuint); | ||
if (animate) | ||
OnToggledOnAnimation(); | ||
break; | ||
|
||
case false: | ||
BgBox.FadeColour(InActivateColor, duration, Easing.OutQuint); | ||
ContentFillFlow.FadeColour(Colour4.White, duration, Easing.OutQuint); | ||
break; | ||
} | ||
} | ||
|
||
protected virtual void OnToggledOnAnimation() | ||
{ | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.