Skip to content
This repository has been archived by the owner on Jun 11, 2023. It is now read-only.

Commit

Permalink
Merge branch 'daily' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
MATRIX-feather committed Aug 15, 2021
2 parents 8b74be0 + 823e856 commit 1e2658b
Show file tree
Hide file tree
Showing 62 changed files with 1,645 additions and 748 deletions.
6 changes: 6 additions & 0 deletions M.Resources/Localisation/Mvis/Plugins/CloudMusicStrings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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"), @"试验性功能!");
Expand Down
9 changes: 9 additions & 0 deletions Mvis.Plugin.BottomBar/BottomBarProvider.cs
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();
}
}
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
{
Expand All @@ -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,
Expand All @@ -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]
Expand All @@ -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 },
Expand All @@ -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
Expand Down Expand Up @@ -197,7 +200,7 @@ protected override void OnMouseUp(MouseUpEvent e)
protected override bool OnClick(ClickEvent e)
{
OnClickAnimation();
Action?.Invoke();
Provider.Active();

return true;
}
Expand Down
76 changes: 76 additions & 0 deletions Mvis.Plugin.BottomBar/Buttons/BottomBarSwitchButton.cs
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()
{
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Audio;
using osu.Game.Skinning;
using osu.Game.Screens.Mvis;
using osu.Game.Screens.Mvis.Plugins.Types;

namespace osu.Game.Screens.Mvis.BottomBar.Buttons
namespace Mvis.Plugin.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;

Expand All @@ -22,9 +19,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(IToggleableFunctionProvider provider)
: base(provider)
{
TooltipText = "切换暂停";
AutoSizeAxes = Axes.X;
}

Expand All @@ -35,7 +32,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}";
}
}
}
Loading

0 comments on commit 1e2658b

Please sign in to comment.