diff --git a/osu.Game.Rulesets.Karaoke.Tests/Skinning/TestSceneNotePlayfield.cs b/osu.Game.Rulesets.Karaoke.Tests/Skinning/TestSceneNotePlayfield.cs index 887f06e6d..338034beb 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Skinning/TestSceneNotePlayfield.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Skinning/TestSceneNotePlayfield.cs @@ -9,7 +9,7 @@ namespace osu.Game.Rulesets.Karaoke.Tests.Skinning public class TestSceneNotePlayfield : KaraokeSkinnableColumnTestScene { [BackgroundDependencyLoader] - private void load(IRulesetConfigCache configCache) + private void load() { SetContents(_ => new KaraokeInputManager(new KaraokeRuleset().RulesetInfo) { diff --git a/osu.Game.Rulesets.Karaoke.Tests/UI/TestSceneControlLayer.cs b/osu.Game.Rulesets.Karaoke.Tests/UI/TestSceneControlLayer.cs index 8c344696f..500c486d2 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/UI/TestSceneControlLayer.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/UI/TestSceneControlLayer.cs @@ -16,10 +16,12 @@ public class TestSceneControlLayer : OsuTestScene { public SettingOverlayContainer SettingOverlayContainer { get; set; } + protected override Ruleset CreateRuleset() => new KaraokeRuleset(); + [BackgroundDependencyLoader] - private void load(IRulesetConfigCache configCache) + private void load() { - var config = (KaraokeRulesetConfigManager)configCache.GetConfigFor(Ruleset.Value.CreateInstance()); + var config = Dependencies.Get(); Dependencies.Cache(new KaraokeSessionStatics(config, null)); // Cannot work now because it need extra BDL in child diff --git a/osu.Game.Rulesets.Karaoke.Tests/UI/TestSceneNotePlayfield.cs b/osu.Game.Rulesets.Karaoke.Tests/UI/TestSceneNotePlayfield.cs index 147343a13..f8d16169e 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/UI/TestSceneNotePlayfield.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/UI/TestSceneNotePlayfield.cs @@ -37,10 +37,12 @@ public class TestSceneNotePlayfield : OsuTestScene private readonly List notePlayfields = new(); + protected override Ruleset CreateRuleset() => new KaraokeRuleset(); + [BackgroundDependencyLoader] - private void load(IRulesetConfigCache configCache) + private void load() { - var config = (KaraokeRulesetConfigManager)configCache.GetConfigFor(Ruleset.Value.CreateInstance()); + var config = Dependencies.Get(); Dependencies.Cache(new KaraokeSessionStatics(config, null)); Child = new GridContainer diff --git a/osu.Game.Rulesets.Karaoke/Mods/KaraokeModPractice.cs b/osu.Game.Rulesets.Karaoke/Mods/KaraokeModPractice.cs index 1854c253a..888433153 100644 --- a/osu.Game.Rulesets.Karaoke/Mods/KaraokeModPractice.cs +++ b/osu.Game.Rulesets.Karaoke/Mods/KaraokeModPractice.cs @@ -1,12 +1,10 @@ // Copyright (c) andy840119 . 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 KaraokeIcon.ModPractice; public override ModType Type => ModType.Fun; - private KaraokeBeatmap beatmap; - public override ModReplayData CreateReplayData(IBeatmap beatmap, IReadOnlyList mods) => new(new KaraokeAutoGenerator(beatmap, mods).Generate(), new ModCreatedUser { Username = "practice master" }); public void ApplyToDrawableRuleset(DrawableRuleset drawableRuleset) { - beatmap = drawableRuleset.Beatmap as KaraokeBeatmap; - if (drawableRuleset.Playfield is KaraokePlayfield karaokePlayfield) { karaokePlayfield.DisplayCursor = new BindableBool @@ -47,11 +41,8 @@ public void ApplyToDrawableRuleset(DrawableRuleset 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 diff --git a/osu.Game.Rulesets.Karaoke/Screens/Skin/Style/NoteStylePreview.cs b/osu.Game.Rulesets.Karaoke/Screens/Skin/Style/NoteStylePreview.cs index 1d293589a..3102c2ddd 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Skin/Style/NoteStylePreview.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Skin/Style/NoteStylePreview.cs @@ -29,8 +29,7 @@ public class NoteStylePreview : Container protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) { - var configCache = parent.Get(); - var config = (KaraokeRulesetConfigManager)configCache.GetConfigFor(new KaraokeRuleset()); + var config = Dependencies.Get(); var dependencies = new DependencyContainer(base.CreateChildDependencies(parent)); dependencies.Cache(new KaraokeSessionStatics(config, null)); diff --git a/osu.Game.Rulesets.Karaoke/UI/HUD/GeneralSettingOverlay.cs b/osu.Game.Rulesets.Karaoke/UI/HUD/GeneralSettingOverlay.cs index 752200d1b..7e6caa885 100644 --- a/osu.Game.Rulesets.Karaoke/UI/HUD/GeneralSettingOverlay.cs +++ b/osu.Game.Rulesets.Karaoke/UI/HUD/GeneralSettingOverlay.cs @@ -20,7 +20,7 @@ public class GeneralSettingOverlay : SettingOverlay, IKeyBindingHandler new() @@ -131,8 +119,20 @@ public virtual void OnReleased(KeyBindingReleaseEvent e) } [BackgroundDependencyLoader] - private void load(KaraokeSessionStatics session) + private void load(IBindable beatmap, KaraokeSessionStatics session) { + // Add translate group if this beatmap has translate + if (beatmap.Value.Beatmap.AnyTranslate()) + { + Add(new TranslateSettings + { + Expanded = + { + Value = false + } + }); + } + session.BindWith(KaraokeRulesetSession.Pitch, bindablePitch); session.BindWith(KaraokeRulesetSession.VocalPitch, bindableVocalPitch); session.BindWith(KaraokeRulesetSession.SaitenPitch, bindableSaitenPitch); diff --git a/osu.Game.Rulesets.Karaoke/UI/HUD/PracticeOverlay.cs b/osu.Game.Rulesets.Karaoke/UI/HUD/PracticeOverlay.cs index 770e7e83f..c750fb01e 100644 --- a/osu.Game.Rulesets.Karaoke/UI/HUD/PracticeOverlay.cs +++ b/osu.Game.Rulesets.Karaoke/UI/HUD/PracticeOverlay.cs @@ -1,16 +1,15 @@ // Copyright (c) andy840119 . 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 = { diff --git a/osu.Game.Rulesets.Karaoke/UI/HUD/SettingOverlayContainer.cs b/osu.Game.Rulesets.Karaoke/UI/HUD/SettingOverlayContainer.cs index c19a6ac26..ba62d0bd3 100644 --- a/osu.Game.Rulesets.Karaoke/UI/HUD/SettingOverlayContainer.cs +++ b/osu.Game.Rulesets.Karaoke/UI/HUD/SettingOverlayContainer.cs @@ -2,14 +2,16 @@ // See the LICENCE file in the repository root for full licence text. using System; +using System.Collections.Generic; using System.Linq; using osu.Framework.Allocation; +using osu.Framework.Bindables; using osu.Framework.Graphics.Containers; using osu.Framework.Input.Bindings; using osu.Framework.Input.Events; using osu.Game.Rulesets.Karaoke.Mods; +using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.UI; -using osu.Game.Screens.Play; using osu.Game.Screens.Play.PlayerSettings; namespace osu.Game.Rulesets.Karaoke.UI.HUD @@ -20,17 +22,15 @@ public class SettingOverlayContainer : CompositeDrawable, IKeyBindingHandler OnNewOverlayAdded; - [BackgroundDependencyLoader(true)] - private void load(Player player) + [BackgroundDependencyLoader] + private void load(IBindable> mods) { - var beatmap = player?.Beatmap?.Value.Beatmap; - AddExtraOverlay(generalSettingsOverlay = new GeneralSettingOverlay(beatmap)); + AddExtraOverlay(generalSettingsOverlay = new GeneralSettingOverlay()); - var mods = player?.GameplayState.Mods; if (mods == null) return; - foreach (var mod in mods.OfType()) + foreach (var mod in mods.Value.OfType()) mod.ApplyToOverlay(this); } diff --git a/osu.Game.Rulesets.Karaoke/UI/PlayerSettings/LyricsPreview.cs b/osu.Game.Rulesets.Karaoke/UI/PlayerSettings/LyricsPreview.cs index 54ee8a69b..c04454829 100644 --- a/osu.Game.Rulesets.Karaoke/UI/PlayerSettings/LyricsPreview.cs +++ b/osu.Game.Rulesets.Karaoke/UI/PlayerSettings/LyricsPreview.cs @@ -1,7 +1,6 @@ // Copyright (c) andy840119 . 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 beatmap { get; set; } - public LyricsPreview(IEnumerable lyrics) + public LyricsPreview() { InternalChild = new OsuScrollContainer { @@ -41,11 +40,6 @@ public LyricsPreview(IEnumerable 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 lyrics) if (newValue != null) lyricTable.Where(x => newValue.Contains(x.HitObject)).ForEach(x => { x.Selected = true; }); }); + + Schedule(() => + { + var lyrics = beatmap.Value.Beatmap.HitObjects.OfType().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); diff --git a/osu.Game.Rulesets.Karaoke/UI/PlayerSettings/PracticeSettings.cs b/osu.Game.Rulesets.Karaoke/UI/PlayerSettings/PracticeSettings.cs index 9ac90c53f..3f76ccaeb 100644 --- a/osu.Game.Rulesets.Karaoke/UI/PlayerSettings/PracticeSettings.cs +++ b/osu.Game.Rulesets.Karaoke/UI/PlayerSettings/PracticeSettings.cs @@ -1,15 +1,12 @@ // Copyright (c) andy840119 . 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 preemptTimeSliderBar; - public PracticeSettings(IBeatmap beatmap) + public PracticeSettings() : base("Practice") { - var lyrics = beatmap.HitObjects.OfType().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, diff --git a/osu.Game.Rulesets.Karaoke/UI/PlayerSettings/TranslateSettings.cs b/osu.Game.Rulesets.Karaoke/UI/PlayerSettings/TranslateSettings.cs index 1fb1e09e2..125309546 100644 --- a/osu.Game.Rulesets.Karaoke/UI/PlayerSettings/TranslateSettings.cs +++ b/osu.Game.Rulesets.Karaoke/UI/PlayerSettings/TranslateSettings.cs @@ -1,12 +1,14 @@ // Copyright (c) andy840119 . 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 translateDropDown; - public TranslateSettings(IEnumerable translates) + public TranslateSettings() : base("Translate") { Children = new Drawable[] @@ -34,14 +36,15 @@ public TranslateSettings(IEnumerable translates) translateDropDown = new OsuDropdown { RelativeSizeAxes = Axes.X, - Items = translates }, }; } [BackgroundDependencyLoader] - private void load(KaraokeSessionStatics session) + private void load(IBindable beatmap, KaraokeSessionStatics session) { + translateDropDown.Items = beatmap.Value.Beatmap.AvailableTranslates(); + // Translate translateCheckBox.Current = session.GetBindable(KaraokeRulesetSession.UseTranslate); translateDropDown.Current = session.GetBindable(KaraokeRulesetSession.PreferLanguage);