-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1560 from andy840119/display-reference-lyric-amount
Display reference lyric amount at the end of the lyric.
- Loading branch information
Showing
4 changed files
with
79 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,23 @@ | ||
// Copyright (c) andy840119 <[email protected]>. Licensed under the GPL Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using System.Diagnostics.CodeAnalysis; | ||
using System.Linq; | ||
using osu.Framework.Allocation; | ||
using osu.Framework.Bindables; | ||
using osu.Framework.Extensions; | ||
using osu.Framework.Graphics; | ||
using osu.Framework.Graphics.Cursor; | ||
using osu.Framework.Graphics.UserInterface; | ||
using osu.Framework.Input.Events; | ||
using osu.Game.Graphics; | ||
using osu.Game.Graphics.Containers; | ||
using osu.Game.Graphics.UserInterface; | ||
using osu.Game.Graphics.UserInterfaceV2; | ||
using osu.Game.Rulesets.Karaoke.Edit.Components.UserInterfaceV2; | ||
using osu.Game.Rulesets.Karaoke.Edit.Utils; | ||
using osu.Game.Rulesets.Karaoke.Objects; | ||
using osu.Game.Screens.Edit; | ||
|
||
namespace osu.Game.Rulesets.Karaoke.Edit.Lyrics.Extends.Reference | ||
{ | ||
|
@@ -52,13 +60,13 @@ public Popover GetPopover() | |
=> new LyricSelectorPopover(Current); | ||
} | ||
|
||
public class LyricSelectorPopover : OsuPopover | ||
private class LyricSelectorPopover : OsuPopover | ||
{ | ||
private readonly LyricSelector lyricSelector; | ||
private readonly ReferenceLyricSelector lyricSelector; | ||
|
||
public LyricSelectorPopover(Bindable<Lyric?> bindable) | ||
{ | ||
Child = lyricSelector = new LyricSelector | ||
Child = lyricSelector = new ReferenceLyricSelector | ||
{ | ||
Width = 400, | ||
Height = 600, | ||
|
@@ -73,5 +81,64 @@ protected override void LoadComplete() | |
GetContainingInputManager().ChangeFocus(lyricSelector); | ||
} | ||
} | ||
|
||
protected class ReferenceLyricSelector : LyricSelector | ||
{ | ||
protected override RearrangeableLyricListContainer CreateRearrangeableLyricListContainer() | ||
=> new RearrangeableReferenceLyricListContainer(); | ||
|
||
protected class RearrangeableReferenceLyricListContainer : RearrangeableLyricListContainer | ||
{ | ||
protected override DrawableTextListItem CreateDrawable(Lyric? item) | ||
=> new DrawableReferenceLyricListItem(item); | ||
|
||
protected class DrawableReferenceLyricListItem : DrawableLyricListItem | ||
{ | ||
[Resolved, AllowNull] | ||
private OsuColour colours { get; set; } | ||
|
||
[Resolved, AllowNull] | ||
private EditorBeatmap editorBeatmap { get; set; } | ||
|
||
public DrawableReferenceLyricListItem(Lyric? item) | ||
: base(item) | ||
{ | ||
} | ||
|
||
protected override bool OnClick(ClickEvent e) | ||
{ | ||
// cannot select those lyric that already contains reference lyric. | ||
if (!selectable(Model)) | ||
return false; | ||
|
||
return base.OnClick(e); | ||
} | ||
|
||
protected override void CreateDisplayContent(OsuTextFlowContainer textFlowContainer, Lyric? model) | ||
{ | ||
base.CreateDisplayContent(textFlowContainer, model); | ||
|
||
// should have disable style if lyric is not selectable. | ||
textFlowContainer.Alpha = selectable(model) ? 1 : 0.5f; | ||
|
||
if (model == null) | ||
return; | ||
|
||
Schedule(() => | ||
{ | ||
// add reference text at the end of the text. | ||
int referenceLyricsAmount = EditorBeatmapUtils.GetAllReferenceLyrics(editorBeatmap, model).Count(); | ||
|
||
if (referenceLyricsAmount > 0) | ||
{ | ||
textFlowContainer.AddText($"({referenceLyricsAmount} reference)", x => x.Colour = colours.Red); | ||
} | ||
}); | ||
} | ||
|
||
private static bool selectable(Lyric? lyric) => lyric?.ReferenceLyric == null; | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters