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 14, 2021
2 parents 3852b2c + f7be875 commit 8b74be0
Show file tree
Hide file tree
Showing 13 changed files with 356 additions and 71 deletions.
9 changes: 8 additions & 1 deletion Mvis.Plugin.CloudMusicSupport/Config/LyricConfigManager.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Platform;
using osu.Game.Screens.Mvis.Plugins.Config;

Expand All @@ -24,6 +25,9 @@ protected override void InitialiseDefaults()
SetDefault(LyricSettings.NoExtraShadow, true);
SetDefault(LyricSettings.UseDrawablePool, false);
SetDefault(LyricSettings.AutoScrollToCurrent, false);
SetDefault(LyricSettings.LyricDirection, Anchor.BottomCentre);
SetDefault(LyricSettings.LyricPositionX, 0f, -1f, 1f);
SetDefault(LyricSettings.LyricPositionY, 0f, -1f, 1f);
base.InitialiseDefaults();
}

Expand All @@ -40,6 +44,9 @@ public enum LyricSettings
SaveLrcWhenFetchFinish,
NoExtraShadow,
UseDrawablePool,
AutoScrollToCurrent
AutoScrollToCurrent,
LyricDirection,
LyricPositionX,
LyricPositionY
}
}
9 changes: 4 additions & 5 deletions Mvis.Plugin.CloudMusicSupport/LyricPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ public override PluginSidebarSettingsSection CreateSidebarSettingsSection()
public override int Version => 5;

private WorkingBeatmap currentWorkingBeatmap;
private LyricLine lrcLine;
private LyricLineHandler lrcLine;

/// <summary>
/// 请参阅 <see cref="MvisPlugin.CreateContent()"/>
/// </summary>
protected override Drawable CreateContent() => lrcLine = new LyricLine();
protected override Drawable CreateContent() => lrcLine = new LyricLineHandler();

private readonly LyricProcessor processor = new LyricProcessor();

Expand Down Expand Up @@ -116,8 +116,7 @@ public LyricPlugin()
PluginFlags.CanUnload
});

RelativeSizeAxes = Axes.X;
Height = 300;
RelativeSizeAxes = Axes.Both;
Anchor = Origin = Anchor.BottomCentre;
}

Expand Down Expand Up @@ -223,7 +222,7 @@ protected override void Update()
{
base.Update();

Margin = new MarginPadding { Bottom = (MvisScreen?.BottombarHeight ?? 0) + 20 };
Padding = new MarginPadding { Bottom = (MvisScreen?.BottombarHeight ?? 0) + 20 };

if (ContentLoaded)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace Mvis.Plugin.CloudMusicSupport.UI
{
public class LyricLine : CompositeDrawable
public class LyricLineHandler : CompositeDrawable
{
private OsuSpriteText currentLine;
private OsuSpriteText currentLineTranslated;
Expand All @@ -26,6 +26,7 @@ public class LyricLine : CompositeDrawable
AutoSizeAxes = Axes.Both,
Anchor = Anchor.BottomCentre,
Origin = Anchor.BottomCentre,
Margin = new MarginPadding { Horizontal = 15, Top = 15 }
};

private Easing fadeOutEasing => Easing.OutQuint;
Expand All @@ -44,9 +45,10 @@ public string Text
Text = value,
Alpha = 0,
Y = -5,
Anchor = configDirection.Value,
Origin = configDirection.Value,
Font = OsuFont.GetFont(size: 30, weight: FontWeight.Black),
Anchor = Anchor.BottomCentre,
Origin = Anchor.BottomCentre,
Margin = getMargin(false)
});
currentLine.MoveToY(0, fadeInDuration.Value, fadeInEasing)
.FadeIn(fadeInDuration.Value, fadeInEasing);
Expand All @@ -70,9 +72,9 @@ public string TranslatedText
Alpha = 0,
Y = -5,
Font = OsuFont.GetFont(size: 30, weight: FontWeight.Black),
Anchor = Anchor.BottomCentre,
Origin = Anchor.BottomCentre,
Margin = new MarginPadding { Bottom = 40 }
Anchor = configDirection.Value,
Origin = configDirection.Value,
Margin = getMargin(true)
});
currentLineTranslated.MoveToY(0, fadeInDuration.Value, fadeInEasing)
.FadeIn(fadeInDuration.Value, fadeInEasing);
Expand All @@ -96,12 +98,10 @@ private void checkIfEmpty()
this.FadeIn(200, Easing.OutQuint);
}

public LyricLine()
public LyricLineHandler()
{
Anchor = Anchor.BottomCentre;
Origin = Anchor.BottomCentre;
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
RelativeSizeAxes = Axes.Both;
RelativePositionAxes = Axes.Both;
Alpha = 0;

InternalChild = outlineEffectContainer = new Container
Expand All @@ -121,6 +121,14 @@ public LyricLine()
private readonly Bindable<float> fadeInDuration = new Bindable<float>();
private readonly Bindable<float> fadeOutDuration = new Bindable<float>();
private readonly Bindable<bool> disableOutline = new Bindable<bool>();
private readonly Bindable<float> positionX = new Bindable<float>();
private readonly Bindable<float> positionY = new Bindable<float>();

private readonly Bindable<Anchor> configDirection = new Bindable<Anchor>
{
Default = Anchor.BottomCentre,
Value = Anchor.BottomCentre,
};

[BackgroundDependencyLoader]
private void load(LyricConfigManager config)
Expand All @@ -130,6 +138,10 @@ private void load(LyricConfigManager config)
config.BindWith(LyricSettings.LyricFadeInDuration, fadeInDuration);
config.BindWith(LyricSettings.LyricFadeOutDuration, fadeOutDuration);
config.BindWith(LyricSettings.NoExtraShadow, disableOutline);

config.BindWith(LyricSettings.LyricDirection, configDirection);
config.BindWith(LyricSettings.LyricPositionX, positionX);
config.BindWith(LyricSettings.LyricPositionY, positionY);
}

protected override void LoadComplete()
Expand All @@ -154,7 +166,47 @@ protected override void LoadComplete()
}
}, true);

configDirection.BindValueChanged(v =>
{
if (currentLineTranslated != null)
{
currentLineTranslated.Anchor = v.NewValue;
currentLineTranslated.Origin = v.NewValue;
currentLineTranslated.Margin = getMargin(true);
}

if (currentLine != null)
{
currentLine.Anchor = v.NewValue;
currentLine.Origin = v.NewValue;
currentLine.Margin = getMargin(false);
}

lyricContainer.Anchor = lyricContainer.Origin = v.NewValue;
outlineEffectContainer.Anchor = outlineEffectContainer.Origin = v.NewValue;
}, true);

positionX.BindValueChanged(v => this.MoveToX(v.NewValue, 300, Easing.OutQuint));
positionY.BindValueChanged(v => this.MoveToY(v.NewValue, 300, Easing.OutQuint));

base.LoadComplete();
}

private MarginPadding getMargin(bool isTranslateText)
{
bool revert = configDirection.Value == Anchor.TopCentre
|| configDirection.Value == Anchor.TopLeft
|| configDirection.Value == Anchor.TopRight;

const int amount = 40;

//在顶上:原始歌词Margin.Top=0,翻译Margin.Top=40
//在底下:原始歌词Margin.Top=40,翻译Margin.Top=0

if (isTranslateText)
return new MarginPadding { Bottom = revert ? 0 : amount, Top = revert ? amount : 0 };

return new MarginPadding { Bottom = revert ? amount : 0, Top = revert ? 0 : amount };
}
}
}
18 changes: 18 additions & 0 deletions Mvis.Plugin.CloudMusicSupport/UI/LyricSidebarSection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,24 @@ private void load()
Description = CloudMusicStrings.LyricAutoScrollMain,
TooltipText = CloudMusicStrings.LyricAutoScrollSub,
Bindable = config.GetBindable<bool>(LyricSettings.AutoScrollToCurrent)
},
new SettingsAnchorPiece
{
Description = "Direction",
Icon = FontAwesome.Solid.Anchor,
Bindable = config.GetBindable<Anchor>(LyricSettings.LyricDirection)
},
new SettingsSliderPiece<float>
{
Description = "横向位移",
Bindable = config.GetBindable<float>(LyricSettings.LyricPositionX),
DisplayAsPercentage = true
},
new SettingsSliderPiece<float>
{
Description = "纵向位移",
Bindable = config.GetBindable<float>(LyricSettings.LyricPositionY),
DisplayAsPercentage = true
}
});
}
Expand Down
30 changes: 30 additions & 0 deletions Mvis.Plugin.CloudMusicSupport/UI/SettingsAnchorPiece.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System.Linq;
using osu.Framework.Extensions;
using osu.Framework.Graphics;
using osu.Game.Screens.Mvis.SideBar.Settings.Items;

namespace Mvis.Plugin.CloudMusicSupport.UI
{
public class SettingsAnchorPiece : SettingsListPiece<Anchor>
{
public SettingsAnchorPiece()
{
var anchorArray = new[]
{
Anchor.TopLeft,
Anchor.TopCentre,
Anchor.TopRight,
Anchor.CentreLeft,
Anchor.Centre,
Anchor.CentreRight,
Anchor.BottomLeft,
Anchor.BottomCentre,
Anchor.BottomRight,
};

Values = anchorArray.ToList();
}

protected override string GetValueText(Anchor newValue) => newValue.GetDescription();
}
}
11 changes: 10 additions & 1 deletion osu.Game.Rulesets.Osu/Configuration/OsuRulesetConfigManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ protected override void InitialiseDefaults()
SetDefault(OsuRulesetSetting.StreamRestrict, false);
SetDefault(OsuRulesetSetting.RestrictInvert, true);
SetDefault(OsuRulesetSetting.SkipStackAngles, false);

//Bezier mover settings
SetDefault(OsuRulesetSetting.BezierAggressiveness, 60f, 1f, 180f);
SetDefault(OsuRulesetSetting.BezierSliderAggressiveness, 3f, 1f, 20f);
}
}

Expand All @@ -55,7 +59,10 @@ public enum OsuDanceMover
HalfCircle,
Flower,
Momentum,
Pippi
Pippi,
AxisAligned,
Aggresive,
Bezier
}

public enum OsuRulesetSetting
Expand Down Expand Up @@ -84,5 +91,7 @@ public enum OsuRulesetSetting
StreamRestrict,
DurationTrigger,
DurationMult,
BezierAggressiveness,
BezierSliderAggressiveness,
}
}
42 changes: 42 additions & 0 deletions osu.Game.Rulesets.Osu/Replays/Movers/AggressiveMover.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// 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 osu.Game.Rulesets.Osu.Objects;
using osuTK;
using static osu.Game.Rulesets.Osu.Replays.Movers.MoverUtilExtensions;

namespace osu.Game.Rulesets.Osu.Replays.Movers
{
public class AggressiveMover : DanceMover
{
private BezierCurve curve;
private float lastAngle;

public override void OnObjChange()
{
var scaledDistance = (float)(EndTime - StartTime);
var newAngle = lastAngle + MathF.PI;

if (Start is Slider start)
newAngle = start.GetEndAngle();

var p1 = V2FromRad(newAngle, scaledDistance) + StartPos;
var p2 = Vector2.Zero;

if (scaledDistance > 1)
lastAngle = p1.AngleRV(EndPos);

if (End is Slider end)
{
p2 = V2FromRad(end.GetStartAngle(), scaledDistance) + EndPos;
}

curve = new BezierCurve(StartPos, p1);
if (p2 != Vector2.Zero) curve.Points.Add(p2);
curve.Points.Add(EndPos);
}

public override Vector2 Update(double time) => curve.CalculatePoint(T(time));
}
}
31 changes: 31 additions & 0 deletions osu.Game.Rulesets.Osu/Replays/Movers/AxisAlignedMover.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// 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 osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Types;
using osuTK;

namespace osu.Game.Rulesets.Osu.Replays.Movers
{
public class AxisAlignedMover : DanceMover
{
private SliderPath path;

public override void OnObjChange()
{
var midP = MathF.Abs((EndPos - StartPos).X) < MathF.Abs((EndPos - EndPos).X)
? new Vector2(StartX, EndY)
: new Vector2(EndX, StartY);

path = new SliderPath(new[]
{
new PathControlPoint(StartPos, PathType.Linear),
new PathControlPoint(midP),
new PathControlPoint(EndPos)
});
}

public override Vector2 Update(double time) => path.PositionAt(T(time));
}
}
Loading

0 comments on commit 8b74be0

Please sign in to comment.