Skip to content

Commit

Permalink
Bindable change
Browse files Browse the repository at this point in the history
  • Loading branch information
PercyDan54 committed Sep 23, 2024
1 parent 8796969 commit edf2726
Showing 1 changed file with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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)
{
Expand All @@ -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!;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit edf2726

Please sign in to comment.