Skip to content

Commit

Permalink
Give it a better naming.
Browse files Browse the repository at this point in the history
  • Loading branch information
andy840119 committed Apr 23, 2022
1 parent 29cea4f commit 78f3f91
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public KaraokeSessionStatics(KaraokeRulesetConfigManager config, IBeatmap beatma
SetDefault(KaraokeRulesetSession.PlaybackSpeed, overridePlaybackSpeed ? playbackSpeedValue : 0, -10, 10);

// Practice
SetDefault<Lyric[]>(KaraokeRulesetSession.NowLyrics, null);
SetDefault<Lyric[]>(KaraokeRulesetSession.SingingLyrics, null);

// Saiten status
SetDefault(KaraokeRulesetSession.SaitenStatus, SaitenStatusMode.NotInitialized);
Expand Down Expand Up @@ -80,7 +80,7 @@ public enum KaraokeRulesetSession
PlaybackSpeed,

// Practice
NowLyrics,
SingingLyrics,

// Saiten status
SaitenStatus,
Expand Down
12 changes: 6 additions & 6 deletions osu.Game.Rulesets.Karaoke/UI/LyricPlayfield.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace osu.Game.Rulesets.Karaoke.UI
{
public class LyricPlayfield : Playfield
{
private readonly Bindable<Lyric[]> nowLyrics = new();
private readonly Bindable<Lyric[]> singingLyrics = new();

protected override void OnNewDrawableHitObject(DrawableHitObject drawableHitObject)
{
Expand All @@ -31,31 +31,31 @@ protected override void OnNewDrawableHitObject(DrawableHitObject drawableHitObje

private void onLyricStart(DrawableLyric drawableLyric)
{
var lyrics = nowLyrics.Value ?? Array.Empty<Lyric>();
var lyrics = singingLyrics.Value ?? Array.Empty<Lyric>();
var lyric = drawableLyric.HitObject;

if (lyrics.Contains(lyric))
return;

nowLyrics.Value = lyrics.Concat(new[] { lyric }).ToArray();
singingLyrics.Value = lyrics.Concat(new[] { lyric }).ToArray();
}

private void onLyricEnd(DrawableLyric drawableLyric)
{
var lyrics = nowLyrics.Value ?? Array.Empty<Lyric>();
var lyrics = singingLyrics.Value ?? Array.Empty<Lyric>();
var lyric = drawableLyric.HitObject;

if (!lyrics.Contains(lyric))
return;

nowLyrics.Value = lyrics.Where(x => x != lyric).ToArray();
singingLyrics.Value = lyrics.Where(x => x != lyric).ToArray();
}

[BackgroundDependencyLoader]
private void load(KaraokeSessionStatics session)
{
// Practice
session.BindWith(KaraokeRulesetSession.NowLyrics, nowLyrics);
session.BindWith(KaraokeRulesetSession.SingingLyrics, singingLyrics);

RegisterPool<Lyric, DrawableLyric>(50);
}
Expand Down
8 changes: 4 additions & 4 deletions osu.Game.Rulesets.Karaoke/UI/PlayerSettings/LyricsPreview.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace osu.Game.Rulesets.Karaoke.UI.PlayerSettings
public class LyricsPreview : CompositeDrawable
{
private readonly Bindable<double> bindablePreemptTime = new();
private readonly Bindable<Lyric[]> selectedLyrics = new();
private readonly Bindable<Lyric[]> singingLyrics = new();

private readonly FillFlowContainer<ClickableLyric> lyricTable;

Expand All @@ -49,7 +49,7 @@ public LyricsPreview(IEnumerable<Lyric> lyrics)
}
};

selectedLyrics.BindValueChanged(value =>
singingLyrics.BindValueChanged(value =>
{
var oldValue = value.OldValue;
if (oldValue != null)
Expand All @@ -70,7 +70,7 @@ private void triggerLyric(Lyric lyric)

// because playback might not clear singing lyrics, so we should re-assign the lyric here.
// todo: find a better place.
selectedLyrics.Value = new[] { lyric };
singingLyrics.Value = new[] { lyric };
}

public Vector2 Spacing
Expand All @@ -83,7 +83,7 @@ public Vector2 Spacing
private void load(KaraokeRulesetConfigManager config, KaraokeSessionStatics session)
{
config.BindWith(KaraokeRulesetSetting.PracticePreemptTime, bindablePreemptTime);
session.BindWith(KaraokeRulesetSession.NowLyrics, selectedLyrics);
session.BindWith(KaraokeRulesetSession.SingingLyrics, singingLyrics);
}

private class ClickableLyric : ClickableContainer
Expand Down

0 comments on commit 78f3f91

Please sign in to comment.