From edf27269ab7f5b17a1b1c0ed62e39d0b43f5676d Mon Sep 17 00:00:00 2001 From: PercyDan54 <50285552+PercyDan54@users.noreply.github.com> Date: Mon, 23 Sep 2024 23:02:11 +0800 Subject: [PATCH] Bindable change --- .../CloudMusic/Sidebar/Graphic/LyricPiece.cs | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/osu.Game.Rulesets.IGPlayer/Feature/Player/Plugins/Bundle/CloudMusic/Sidebar/Graphic/LyricPiece.cs b/osu.Game.Rulesets.IGPlayer/Feature/Player/Plugins/Bundle/CloudMusic/Sidebar/Graphic/LyricPiece.cs index 1679c7c..31193fb 100644 --- a/osu.Game.Rulesets.IGPlayer/Feature/Player/Plugins/Bundle/CloudMusic/Sidebar/Graphic/LyricPiece.cs +++ b/osu.Game.Rulesets.IGPlayer/Feature/Player/Plugins/Bundle/CloudMusic/Sidebar/Graphic/LyricPiece.cs @@ -1,5 +1,6 @@ using System; using osu.Framework.Allocation; +using osu.Framework.Bindables; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -36,13 +37,14 @@ public partial class LyricPiece : DrawableLyric, IHasTooltip, IHasContextMenu new OsuMenuItem( CloudMusicStrings.AdjustOffsetToLyric.ToString(), MenuItemType.Standard, - () => plugin.Offset.Value = Value.Time - mvisScreen.CurrentTrack.CurrentTime) + () => plugin.Offset.Value = Value.Time - llinScreen.CurrentTrack.CurrentTime) }; private Box hoverBox = null!; private OsuSpriteText contentText = null!; private OsuSpriteText translateText = null!; private OsuSpriteText timeText = null!; + private readonly BindableDouble offset = new BindableDouble(); public LyricPiece(Lyric lrc) { @@ -58,7 +60,7 @@ public LyricPiece() } [Resolved] - private IImplementLLin mvisScreen { get; set; } = null!; + private IImplementLLin llinScreen { get; set; } = null!; [Resolved] private CustomColourProvider colourProvider { get; set; } = null!; @@ -164,24 +166,30 @@ private void load() { bgBox.Colour = colourProvider.Highlight1.Opacity(isCurrent ? 1 : 0); }, true); - plugin.Offset.BindValueChanged(_ => Schedule(() => UpdateValue(Value)), true); + offset.BindValueChanged(_ => Schedule(() => UpdateValue(Value)), true); } - private bool isCurrent_real; + private bool isCurrentReal; private bool isCurrent { - get => isCurrent_real; + get => isCurrentReal; set { bgBox.FadeColour(colourProvider.Highlight1.Opacity(value ? 1 : 0), 300, Easing.OutQuint); textFillFlow.FadeColour(value ? Color4.Black : Color4.White, 300, Easing.OutQuint); timeText.FadeColour(value ? Color4.Black : Color4.White, 300, Easing.OutQuint); - isCurrent_real = value; + isCurrentReal = value; } } + protected override void LoadComplete() + { + base.LoadComplete(); + offset.BindTo(plugin.Offset); + } + protected override void Update() { isCurrent = plugin.CurrentLine != null && plugin.CurrentLine.Equals(Value); @@ -216,7 +224,7 @@ protected override void UpdateValue(Lyric lyric) protected override bool OnClick(ClickEvent e) { - mvisScreen.SeekTo(Value.Time + 1 - plugin.Offset.Value); + llinScreen.SeekTo(Value.Time + 1 - plugin.Offset.Value); return base.OnClick(e); }