Skip to content

Commit

Permalink
Merge pull request #2248 from andy840119/upgrade-package
Browse files Browse the repository at this point in the history
Upgrade package.
  • Loading branch information
andy840119 authored Jun 25, 2024
2 parents 6666cc9 + 59b2a55 commit 6afb172
Show file tree
Hide file tree
Showing 21 changed files with 78 additions and 80 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<ProjectReference Include="..\osu.Game.Rulesets.Karaoke.Tests\osu.Game.Rulesets.Karaoke.Tests.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="TngTech.ArchUnitNET" Version="0.10.6" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,10 @@ public MockEditorChangeHandler(EditorBeatmap editorBeatmap)
editorBeatmap.SaveStateTriggered += SaveState;
}

public void RestoreState(int direction)
{
}

protected override void UpdateState()
{
OnStateChange?.Invoke();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using osu.Framework.Extensions;
using osu.Framework.Graphics;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Karaoke.Objects.Drawables;
using osu.Game.Rulesets.Karaoke.UI;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Scoring;
Expand All @@ -19,7 +20,7 @@ public TestSceneDrawableJudgement()
foreach (var result in Enum.GetValues<HitResult>().Skip(1))
{
AddStep("Show " + result.GetDescription(), () => SetContents(_ =>
new DrawableNoteJudgement(new JudgementResult(new HitObject(), new Judgement()) { Type = result }, null)
new DrawableNoteJudgement(new JudgementResult(new HitObject(), new Judgement()) { Type = result }, new DrawableNote())
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Expand Down
30 changes: 22 additions & 8 deletions osu.Game.Rulesets.Karaoke/Beatmaps/KaraokeBeatmapProcessor.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) andy840119 <andy840119@gmail.com>. Licensed under the GPL Licence.
// See the LICENCE file in the repository root for full licence text.

using System;
using System.Linq;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Game.Beatmaps;
Expand All @@ -10,24 +11,37 @@
using osu.Game.Rulesets.Karaoke.Stages;
using osu.Game.Rulesets.Karaoke.Stages.Preview;
using osu.Game.Rulesets.Karaoke.Stages.Types;
using osu.Game.Screens.Edit;

namespace osu.Game.Rulesets.Karaoke.Beatmaps;

public class KaraokeBeatmapProcessor : BeatmapProcessor
{
public new KaraokeBeatmap Beatmap => (KaraokeBeatmap)base.Beatmap;

public KaraokeBeatmapProcessor(IBeatmap beatmap)
: base(beatmap)
{
}

public override void PreProcess()
{
applyStage(Beatmap);
var karaokeBeatmap = getKaraokeBeatmap(Beatmap);
applyStage(karaokeBeatmap);

base.PreProcess();
applyInvalidProperty(Beatmap);
applyInvalidProperty(karaokeBeatmap);

static KaraokeBeatmap getKaraokeBeatmap(IBeatmap beatmap)
{
// goes to there while parsing the beatmap.
if (beatmap is KaraokeBeatmap karaokeBeatmap)
return karaokeBeatmap;

// goes to there while editing the beatmap.
if (beatmap is EditorBeatmap editorBeatmap)
return getKaraokeBeatmap(editorBeatmap.PlayableBeatmap);

throw new InvalidCastException($"The beatmap is not a {nameof(KaraokeBeatmap)}");
}
}

private void applyStage(KaraokeBeatmap beatmap)
Expand All @@ -36,7 +50,7 @@ private void applyStage(KaraokeBeatmap beatmap)
// trying to load the first stage or create a default one.
if (beatmap.CurrentStageInfo == null)
{
beatmap.CurrentStageInfo = getWorkingStage() ?? createDefaultWorkingStage();
beatmap.CurrentStageInfo = getWorkingStage(beatmap) ?? createDefaultWorkingStage();

// should invalidate the working property here because the stage info is changed.
beatmap.HitObjects.OfType<Lyric>().ForEach(x =>
Expand All @@ -50,10 +64,10 @@ private void applyStage(KaraokeBeatmap beatmap)
if (beatmap.CurrentStageInfo is IHasCalculatedProperty calculatedProperty)
calculatedProperty.ValidateCalculatedProperty(beatmap);

StageInfo? getWorkingStage()
=> Beatmap.StageInfos.FirstOrDefault();
static StageInfo? getWorkingStage(KaraokeBeatmap beatmap)
=> beatmap.StageInfos.FirstOrDefault();

StageInfo createDefaultWorkingStage() => new PreviewStageInfo();
static StageInfo createDefaultWorkingStage() => new PreviewStageInfo();
}

private void applyInvalidProperty(KaraokeBeatmap beatmap)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// Copyright (c) andy840119 <andy840119@gmail.com>. Licensed under the GPL Licence.
// See the LICENCE file in the repository root for full licence text.

using System;
using osu.Framework.Graphics;
using osu.Game.Graphics.UserInterfaceV2;
using osu.Game.Overlays.Settings;
using System.Numerics;

namespace osu.Game.Rulesets.Karaoke.Graphics.UserInterfaceV2;

public partial class LabelledRealTimeSliderBar<TNumber> : LabelledSliderBar<TNumber>
where TNumber : struct, IEquatable<TNumber>, IComparable<TNumber>, IConvertible
where TNumber : struct, INumber<TNumber>, IMinMaxValue<TNumber>
{
protected override SettingsSlider<TNumber> CreateComponent()
=> base.CreateComponent().With(x => x.TransferValueOnCommit = false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ protected override void OnFocus(FocusEvent e)
{
base.OnFocus(e);

GetContainingInputManager().ChangeFocus(filter);
GetContainingFocusManager().ChangeFocus(filter);
}

private bool enableEmptyOption;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ protected override void LoadComplete()
{
base.LoadComplete();

GetContainingInputManager().ChangeFocus(languageSelector);
GetContainingFocusManager().ChangeFocus(languageSelector);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ protected override void OnFocus(FocusEvent e)
{
base.OnFocus(e);

GetContainingInputManager().ChangeFocus(filter);
GetContainingFocusManager().ChangeFocus(filter);
}

private partial class LyricSelectionSearchTextBox : SearchTextBox
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ protected override void OnSelectionChanged()
base.OnSelectionChanged();

// only select one ruby tag can let user drag to change start and end index.
SelectionBox.CanScaleX = SelectedItems.Count == 1;
ScaleHandler.CanScaleX.Value = SelectedItems.Count == 1;

// should clear delta size before change start/end index.
deltaScaleSize = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ void deleteRubyText()
protected override void LoadComplete()
{
base.LoadComplete();
ScheduleAfterChildren(() => GetContainingInputManager().ChangeFocus(labelledRubyTextBox));
ScheduleAfterChildren(() => GetContainingFocusManager().ChangeFocus(labelledRubyTextBox));
}

private partial class DeleteRubyButton : EditorSectionButton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ private void addRubyText()
if (string.IsNullOrEmpty(rubyText))
{
labelledRubyTextBox.Description = "Please enter the ruby text";
GetContainingInputManager().ChangeFocus(labelledRubyTextBox);
GetContainingFocusManager().ChangeFocus(labelledRubyTextBox);
return;
}

Expand All @@ -208,7 +208,7 @@ private void addRubyText()
protected override void LoadComplete()
{
base.LoadComplete();
ScheduleAfterChildren(() => GetContainingInputManager().ChangeFocus(labelledRubyTextBox));
ScheduleAfterChildren(() => GetContainingFocusManager().ChangeFocus(labelledRubyTextBox));
}

private partial class CreateRubyLabelledTextBox : LabelledTextBox
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public void FocusInputCaretTextBox()
Schedule(() =>
{
inputCaretTextBox.Text = string.Empty;
GetContainingInputManager().ChangeFocus(inputCaretTextBox);
GetContainingFocusManager().ChangeFocus(inputCaretTextBox);
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public NoteSection(Note note)

ScheduleAfterChildren(() =>
{
GetContainingInputManager().ChangeFocus(text);
GetContainingFocusManager().ChangeFocus(text);
});

text.OnCommit += (sender, newText) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,11 +304,8 @@ private void assignBottomEditor(BottomEditorType? bottomEditorType)
const double new_animation_time = 200;

bool hasOldButtonEditor = bottomEditorContainer.Children.Any();
var newButtonEditor = createBottomEditor(bottomEditorType).With(x =>
var newButtonEditor = createBottomEditor(bottomEditorType)?.With(x =>
{
if (x == null)
return;
x.RelativePositionAxes = Axes.Y;
x.Y = -1;
x.Alpha = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ protected override void Dispose(bool isDisposing)
base.Dispose(isDisposing);

// todo: not very sure
if (!editorBeatmap.IsNull())
if (editorBeatmap.IsNull())
return;

editorBeatmap.HitObjectAdded -= hitObjectAdded;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,15 @@ private void focus()
// Make sure that view is visible in the scroll container.
// Give the top spacing larger space to let use able to see the previous item or the description text.
var parentScrollContainer = this.FindClosestParent<OsuScrollContainer>();
if (parentScrollContainer == null)
throw new InvalidOperationException("Should have a parent scroll container.");
parentScrollContainer.ScrollIntoViewWithSpacing(this, new MarginPadding { Top = 150, Bottom = 50 });
if (IsFocused(focusedDrawable))
return;
GetContainingInputManager().ChangeFocus(Component);
GetContainingFocusManager().ChangeFocus(Component);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ protected override void LoadComplete()
{
base.LoadComplete();

GetContainingInputManager().ChangeFocus(lyricSelector);
GetContainingFocusManager().ChangeFocus(lyricSelector);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,8 @@ private void load(ISkinSource skin, IScrollingInfo scrollingInfo)
if (tmp is IFramedAnimation { FrameCount: > 0 } tmpAnimation)
frameLength = Math.Max(1000 / 60.0, 170.0 / tmpAnimation.FrameCount);

explosion = skin.GetAnimation(imageName, true, false, frameLength: frameLength).With(d =>
explosion = skin.GetAnimation(imageName, true, false, frameLength: frameLength)?.With(d =>
{
if (d == null)
return;
d.Origin = Anchor.Centre;
d.Blending = BlendingParameters.Additive;
d.Scale = new Vector2(explosionScale);
Expand Down
20 changes: 4 additions & 16 deletions osu.Game.Rulesets.Karaoke/Skinning/Legacy/LegacyNotePiece.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,20 +140,14 @@ private LayerContainer createLayer(string name, ISkin skin, LegacyKaraokeSkinNot
Name = name,
Children = new[]
{
getSpriteFromLookup(skin, LegacyKaraokeSkinConfigurationLookups.NoteHeadImage, layer).With(d =>
getSpriteFromLookup(skin, LegacyKaraokeSkinConfigurationLookups.NoteHeadImage, layer)?.With(d =>
{
if (d == null)
return;
d.Name = "Head";
d.Anchor = Anchor.CentreLeft;
d.Origin = Anchor.Centre;
}),
getSpriteFromLookup(skin, LegacyKaraokeSkinConfigurationLookups.NoteBodyImage, layer).With(d =>
getSpriteFromLookup(skin, LegacyKaraokeSkinConfigurationLookups.NoteBodyImage, layer)?.With(d =>
{
if (d == null)
return;
d.Name = "Body";
d.Anchor = Anchor.Centre;
d.Origin = Anchor.Centre;
Expand All @@ -164,11 +158,8 @@ private LayerContainer createLayer(string name, ISkin skin, LegacyKaraokeSkinNot
d.Height = d.Texture?.DisplayHeight ?? 0;
}),
getSpriteFromLookup(skin, LegacyKaraokeSkinConfigurationLookups.NoteTailImage, layer).With(d =>
getSpriteFromLookup(skin, LegacyKaraokeSkinConfigurationLookups.NoteTailImage, layer)?.With(d =>
{
if (d == null)
return;
d.Name = "Tail";
d.Anchor = Anchor.CentreRight;
d.Origin = Anchor.Centre;
Expand All @@ -195,13 +186,10 @@ private LayerContainer createLayer(string name, ISkin skin, LegacyKaraokeSkinNot
return null;
}

Sprite? getSpriteByName(string spriteName) => (Sprite?)skin.GetAnimation(spriteName, true, true).With(d =>
Sprite? getSpriteByName(string spriteName) => (Sprite?)skin.GetAnimation(spriteName, true, true)?.With(d =>
{
switch (d)
{
case null:
return;
case TextureAnimation animation:
animation.IsPlaying = false;
break;
Expand Down
54 changes: 24 additions & 30 deletions osu.Game.Rulesets.Karaoke/UI/DrawableNoteJudgement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,46 +5,18 @@
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Scoring;
using osuTK;

namespace osu.Game.Rulesets.Karaoke.UI;

public partial class DrawableNoteJudgement : DrawableJudgement
{
public DrawableNoteJudgement(JudgementResult result, DrawableHitObject? judgedObject)
public DrawableNoteJudgement(JudgementResult result, DrawableHitObject judgedObject)
: base(result, judgedObject)
{
}

protected override void ApplyMissAnimations()
public DrawableNoteJudgement()
{
if (JudgementBody.Drawable is not DefaultKaraokeJudgementPiece)
{
// this is temporary logic until mania's skin transformer returns IAnimatableJudgements
JudgementBody.ScaleTo(1.6f);
JudgementBody.ScaleTo(1, 100, Easing.In);

JudgementBody.MoveTo(Vector2.Zero);
JudgementBody.MoveToOffset(new Vector2(0, 100), 800, Easing.InQuint);

JudgementBody.RotateTo(0);
JudgementBody.RotateTo(40, 800, Easing.InQuint);
JudgementBody.FadeOutFromOne(800);

LifetimeEnd = JudgementBody.LatestTransformEndTime;
}

base.ApplyMissAnimations();
}

protected override void ApplyHitAnimations()
{
JudgementBody.ScaleTo(0.8f);
JudgementBody.ScaleTo(1, 250, Easing.OutElastic);

JudgementBody.Delay(50)
.ScaleTo(0.75f, 250)
.FadeOut(200);
}

protected override Drawable CreateDefaultJudgement(HitResult result) => new DefaultKaraokeJudgementPiece(result);
Expand All @@ -62,5 +34,27 @@ protected override void LoadComplete()

JudgementText.Font = JudgementText.Font.With(size: 25);
}

public override void PlayAnimation()
{
switch (Result)
{
case HitResult.None:
case HitResult.Miss:
base.PlayAnimation();
break;

default:
this.ScaleTo(0.8f);
this.ScaleTo(1, 250, Easing.OutElastic);

this.Delay(50)
.ScaleTo(0.75f, 250)
.FadeOut(200);

// karaoke uses a custom fade length, so the base call is intentionally omitted.
break;
}
}
}
}
Loading

0 comments on commit 6afb172

Please sign in to comment.