-
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 #1283 from andy840119/do-not-pass-beatmap-in-pract…
…ice-overlay Do not pass beatmap in practice overlay.
- Loading branch information
Showing
11 changed files
with
54 additions
and
59 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
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,12 +1,10 @@ | ||
// Copyright (c) andy840119 <[email protected]>. Licensed under the GPL Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using osu.Framework.Bindables; | ||
using osu.Framework.Graphics.Sprites; | ||
using osu.Game.Beatmaps; | ||
using osu.Game.Rulesets.Karaoke.Beatmaps; | ||
using osu.Game.Rulesets.Karaoke.Graphics.Sprites; | ||
using osu.Game.Rulesets.Karaoke.Objects; | ||
using osu.Game.Rulesets.Karaoke.Replays; | ||
|
@@ -26,15 +24,11 @@ public class KaraokeModPractice : ModAutoplay, IApplicableToDrawableRuleset<Kara | |
public override IconUsage? Icon => KaraokeIcon.ModPractice; | ||
public override ModType Type => ModType.Fun; | ||
|
||
private KaraokeBeatmap beatmap; | ||
|
||
public override ModReplayData CreateReplayData(IBeatmap beatmap, IReadOnlyList<Mod> mods) | ||
=> new(new KaraokeAutoGenerator(beatmap, mods).Generate(), new ModCreatedUser { Username = "practice master" }); | ||
|
||
public void ApplyToDrawableRuleset(DrawableRuleset<KaraokeHitObject> drawableRuleset) | ||
{ | ||
beatmap = drawableRuleset.Beatmap as KaraokeBeatmap; | ||
|
||
if (drawableRuleset.Playfield is KaraokePlayfield karaokePlayfield) | ||
{ | ||
karaokePlayfield.DisplayCursor = new BindableBool | ||
|
@@ -47,11 +41,8 @@ public void ApplyToDrawableRuleset(DrawableRuleset<KaraokeHitObject> drawableRul | |
|
||
public void ApplyToOverlay(ISettingHUDOverlay overlay) | ||
{ | ||
if (beatmap == null) | ||
throw new ArgumentNullException(nameof(beatmap)); | ||
|
||
// Add practice overlay | ||
overlay.AddExtraOverlay(new PracticeOverlay(beatmap)); | ||
overlay.AddExtraOverlay(new PracticeOverlay()); | ||
|
||
// Add playback group into main overlay | ||
overlay.AddSettingsGroup(new PlaybackSettings | ||
|
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
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,16 +1,15 @@ | ||
// Copyright (c) andy840119 <[email protected]>. Licensed under the GPL Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using osu.Game.Beatmaps; | ||
using osu.Game.Rulesets.Karaoke.UI.PlayerSettings; | ||
|
||
namespace osu.Game.Rulesets.Karaoke.UI.HUD | ||
{ | ||
public class PracticeOverlay : SettingOverlay | ||
{ | ||
public PracticeOverlay(IBeatmap beatmap) | ||
public PracticeOverlay() | ||
{ | ||
Add(new PracticeSettings(beatmap) | ||
Add(new PracticeSettings | ||
{ | ||
Expanded = | ||
{ | ||
|
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,7 +1,6 @@ | ||
// Copyright (c) andy840119 <[email protected]>. Licensed under the GPL Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using System.Collections.Generic; | ||
using System.Linq; | ||
using osu.Framework.Allocation; | ||
using osu.Framework.Bindables; | ||
|
@@ -31,7 +30,7 @@ public class LyricsPreview : CompositeDrawable | |
[Resolved] | ||
private IBindable<WorkingBeatmap> beatmap { get; set; } | ||
|
||
public LyricsPreview(IEnumerable<Lyric> lyrics) | ||
public LyricsPreview() | ||
{ | ||
InternalChild = new OsuScrollContainer | ||
{ | ||
|
@@ -41,11 +40,6 @@ public LyricsPreview(IEnumerable<Lyric> lyrics) | |
AutoSizeAxes = Axes.Y, | ||
RelativeSizeAxes = Axes.X, | ||
Direction = FillDirection.Vertical, | ||
Children = lyrics.Select(x => createLyricContainer(x).With(c => | ||
{ | ||
c.Selected = false; | ||
c.Action = () => triggerLyric(x); | ||
})).ToList() | ||
} | ||
}; | ||
|
||
|
@@ -59,6 +53,16 @@ public LyricsPreview(IEnumerable<Lyric> lyrics) | |
if (newValue != null) | ||
lyricTable.Where(x => newValue.Contains(x.HitObject)).ForEach(x => { x.Selected = true; }); | ||
}); | ||
|
||
Schedule(() => | ||
{ | ||
var lyrics = beatmap.Value.Beatmap.HitObjects.OfType<Lyric>().ToList(); | ||
lyricTable.Children = lyrics.Select(x => createLyricContainer(x).With(c => | ||
{ | ||
c.Selected = false; | ||
c.Action = () => triggerLyric(x); | ||
})).ToList(); | ||
}); | ||
} | ||
|
||
private ClickableLyric createLyricContainer(Lyric lyric) => new(lyric); | ||
|
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,12 @@ | ||
// Copyright (c) andy840119 <[email protected]>. Licensed under the GPL Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using System.Linq; | ||
using osu.Framework.Allocation; | ||
using osu.Framework.Graphics; | ||
using osu.Framework.Input.Bindings; | ||
using osu.Framework.Input.Events; | ||
using osu.Game.Beatmaps; | ||
using osu.Game.Graphics.Sprites; | ||
using osu.Game.Rulesets.Karaoke.Configuration; | ||
using osu.Game.Rulesets.Karaoke.Objects; | ||
using osu.Game.Screens.Play.PlayerSettings; | ||
using osuTK; | ||
|
||
|
@@ -19,11 +16,9 @@ public class PracticeSettings : PlayerSettingsGroup, IKeyBindingHandler<KaraokeA | |
{ | ||
private readonly PlayerSliderBar<double> preemptTimeSliderBar; | ||
|
||
public PracticeSettings(IBeatmap beatmap) | ||
public PracticeSettings() | ||
: base("Practice") | ||
{ | ||
var lyrics = beatmap.HitObjects.OfType<Lyric>().ToList(); | ||
|
||
Children = new Drawable[] | ||
{ | ||
new OsuSpriteText | ||
|
@@ -35,7 +30,7 @@ public PracticeSettings(IBeatmap beatmap) | |
{ | ||
Text = "Lyric:" | ||
}, | ||
new LyricsPreview(lyrics) | ||
new LyricsPreview | ||
{ | ||
Height = 580, | ||
RelativeSizeAxes = Axes.X, | ||
|
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,12 +1,14 @@ | ||
// Copyright (c) andy840119 <[email protected]>. Licensed under the GPL Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using System.Collections.Generic; | ||
using System.Globalization; | ||
using osu.Framework.Allocation; | ||
using osu.Framework.Bindables; | ||
using osu.Framework.Graphics; | ||
using osu.Game.Beatmaps; | ||
using osu.Game.Graphics.Sprites; | ||
using osu.Game.Graphics.UserInterface; | ||
using osu.Game.Rulesets.Karaoke.Beatmaps; | ||
using osu.Game.Rulesets.Karaoke.Configuration; | ||
using osu.Game.Screens.Play.PlayerSettings; | ||
|
||
|
@@ -18,7 +20,7 @@ public class TranslateSettings : PlayerSettingsGroup | |
private readonly OsuSpriteText translateText; | ||
private readonly OsuDropdown<CultureInfo> translateDropDown; | ||
|
||
public TranslateSettings(IEnumerable<CultureInfo> translates) | ||
public TranslateSettings() | ||
: base("Translate") | ||
{ | ||
Children = new Drawable[] | ||
|
@@ -34,14 +36,15 @@ public TranslateSettings(IEnumerable<CultureInfo> translates) | |
translateDropDown = new OsuDropdown<CultureInfo> | ||
{ | ||
RelativeSizeAxes = Axes.X, | ||
Items = translates | ||
}, | ||
}; | ||
} | ||
|
||
[BackgroundDependencyLoader] | ||
private void load(KaraokeSessionStatics session) | ||
private void load(IBindable<WorkingBeatmap> beatmap, KaraokeSessionStatics session) | ||
{ | ||
translateDropDown.Items = beatmap.Value.Beatmap.AvailableTranslates(); | ||
|
||
// Translate | ||
translateCheckBox.Current = session.GetBindable<bool>(KaraokeRulesetSession.UseTranslate); | ||
translateDropDown.Current = session.GetBindable<CultureInfo>(KaraokeRulesetSession.PreferLanguage); | ||
|