Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
29d06b1
Add basic drag movement to cards
minetoblend Mar 27, 2026
d45a927
Ensure player cards are always drawn on top of opponent cards
minetoblend Mar 27, 2026
be9809b
Add drag information to card state
minetoblend Mar 27, 2026
b7dce0f
Ensure dragged card is treated as hovered even when mouse temporarily…
minetoblend Mar 27, 2026
e0a46fe
Refactor card hand layout to be stateless
minetoblend Mar 27, 2026
3400540
Update card order when card is dragged
minetoblend Mar 27, 2026
9483696
Ensure cards are drawn in the correct order
minetoblend Mar 27, 2026
1a039f4
Make sure sorting algorithm for card draw order is stable
minetoblend Mar 30, 2026
4ed73e6
Persist card order between rounds
minetoblend Mar 30, 2026
62bf8de
ensure player card hand gets drawn on top of discard button
minetoblend Mar 30, 2026
6c4a1d5
Fix using Count() on IReadOnlyList
minetoblend Mar 30, 2026
64e28f9
Adjust card replay parameters to fit more frequent events being emitted
minetoblend Mar 30, 2026
289c7c9
Make card sway while being dragged
minetoblend Mar 30, 2026
82b7a22
Fix reading from different array than the one being iterated over
minetoblend Mar 30, 2026
6477b78
Fix silly mistake from past me
minetoblend Mar 30, 2026
6a5e510
Rename order to drawOrder
minetoblend Mar 30, 2026
9a94604
Fix card upwards direction calculated with rotation of 0
minetoblend Mar 30, 2026
01f3ba0
Ignore key events while card is being dragged
minetoblend Mar 30, 2026
891c4a1
Fix song preview border being visible when card first loads
minetoblend Mar 31, 2026
d65ab0e
Use springs for card movement
minetoblend Mar 30, 2026
40155fe
code aweioqqqfi
peppy Mar 31, 2026
3563a2b
Remove unnecessary log statement
minetoblend Mar 31, 2026
3cb87dd
Add xmldocs and comments
minetoblend Mar 31, 2026
39016b1
Don't use when syntax
minetoblend Mar 31, 2026
32fe4f3
Get rid of MovementSpeed variable
minetoblend Mar 31, 2026
1cb0275
Cleanup code for card movement on screen enter
minetoblend Mar 31, 2026
cc02c6c
Use Interpolation.DampContinuously instead of manual exponential lerp.
minetoblend Mar 31, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions osu.Game.Tests/Visual/RankedPlay/TestSceneHandReplay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,14 @@ public override void SetUpSteps()
}

private double flushInterval = 1000;
private double recordInterval = 25;
private double recordInterval = 50;
private double fixedLatency;
private double maxLatency;

[Test]
public void TestCardHandReplay()
{
AddSliderStep("record interval", 0.0, 1000.0, 25.0, value =>
AddSliderStep("record interval", 0.0, 1000.0, 50.0, value =>
{
recordInterval = value;
recreateRecorder();
Expand Down
43 changes: 39 additions & 4 deletions osu.Game.Tests/Visual/RankedPlay/TestScenePlayerCardHand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Testing;
using osu.Game.Online.Multiplayer.MatchTypes.RankedPlay;
using osu.Game.Overlays;
using osu.Game.Screens.OnlinePlay.Matchmaking.RankedPlay;
Expand Down Expand Up @@ -33,12 +34,23 @@ private void load()
};
}

[SetUpSteps]
public void SetupSteps()
{
AddStep("reset card hand", () => Child = handOfCards = new PlayerHandOfCards
{
Anchor = Anchor.BottomCentre,
Origin = Anchor.BottomCentre,
RelativeSizeAxes = Axes.Both,
Height = 0.5f,
});
}

[Test]
public void TestSingleSelectionMode()
{
AddStep("add cards", () =>
{
handOfCards.Clear();
for (int i = 0; i < 5; i++)
handOfCards.AddCard(new RankedPlayCardWithPlaylistItem(new RankedPlayCardItem()));
});
Expand All @@ -59,7 +71,6 @@ public void TestMultiSelectionMode()
{
AddStep("add cards", () =>
{
handOfCards.Clear();
for (int i = 0; i < 5; i++)
handOfCards.AddCard(new RankedPlayCardWithPlaylistItem(new RankedPlayCardItem()));
});
Expand All @@ -84,7 +95,13 @@ public void TestCardCount()

AddStep($"{i} {"cards".Pluralize(i == 1)}", () =>
{
handOfCards.Clear();
Child = handOfCards = new PlayerHandOfCards
{
Anchor = Anchor.BottomCentre,
Origin = Anchor.BottomCentre,
RelativeSizeAxes = Axes.Both,
Height = 0.5f,
};

for (int j = 0; j < numCards; j++)
handOfCards.AddCard(new RankedPlayCardWithPlaylistItem(new RankedPlayCardItem()));
Expand Down Expand Up @@ -138,7 +155,6 @@ public void TestKeyboardSelectionMultiSelection()
{
AddStep("add cards", () =>
{
handOfCards.Clear();
for (int i = 0; i < 5; i++)
handOfCards.AddCard(new RankedPlayCardWithPlaylistItem(new RankedPlayCardItem()));
});
Expand All @@ -157,5 +173,24 @@ public void TestKeyboardSelectionMultiSelection()
AddAssert("card selected", () => handOfCards.Selection.Contains(handOfCards.Cards.ElementAt(i1).Card.Item));
}
}

[Test]
public void TestContract()
{
AddStep("add cards", () =>
{
for (int i = 0; i < 5; i++)
handOfCards.AddCard(new RankedPlayCardWithPlaylistItem(new RankedPlayCardItem()));
});
AddWaitStep("wait", 5);
AddStep("contract", () => handOfCards.Contract());
AddWaitStep("wait", 5);
AddAssert(
"all cards outside bounds", () =>
handOfCards
.ChildrenOfType<HandOfCards.HandCard>()
.All(card => !card.ScreenSpaceDrawQuad.AABBFloat.IntersectsWith(handOfCards.ScreenSpaceDrawQuad.AABBFloat))
);
}
}
}
24 changes: 24 additions & 0 deletions osu.Game/Online/RankedPlay/RankedPlayCardState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System;
using MessagePack;
using osuTK;

namespace osu.Game.Online.RankedPlay
{
Expand All @@ -18,5 +19,28 @@ public readonly record struct RankedPlayCardState

[Key(2)]
public required bool Selected { get; init; }

[Key(3)]
public required bool Dragged { get; init; }

[Key(4)]
public required int Order { get; init; }

[Key(5)]
public float DragX { get; init; }

[Key(6)]
public float DragY { get; init; }

[IgnoreMember]
public Vector2 DragPosition
{
get => new Vector2(DragX, DragY);
init
{
DragX = value.X;
DragY = value.Y;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ protected override void LoadComplete()
this.FadeOut(200);
}
}, true);
FinishTransforms();
}

protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, ChannelAmplitudes amplitudes)
Expand Down
35 changes: 18 additions & 17 deletions osu.Game/Screens/OnlinePlay/Matchmaking/RankedPlay/DiscardScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ private void load(AudioManager audio)
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
},
];

CenterColumn.Children =
[
discardButton = new ShearedButton
{
Name = "Discard Button",
Expand All @@ -89,11 +93,7 @@ private void load(AudioManager audio)
Width = 150,
Action = onDiscardButtonClicked,
Enabled = { Value = true },
}
];

CenterColumn.Children =
[
},
playerHand = new PlayerHandOfCards
{
Anchor = Anchor.BottomCentre,
Expand Down Expand Up @@ -179,23 +179,23 @@ public override void OnEntering(RankedPlaySubScreen? previous)
{
base.OnEntering(previous);

var screenBottomCenter = new Vector2(DrawWidth / 2, DrawHeight);
int cardCount = 0;
double delay = 0;
const double stagger = 50;

foreach (var card in matchInfo.PlayerCards)
{
double currentDelay = delay;

playerHand.AddCard(card, c =>
{
c.Position = ToSpaceOfOtherDrawable(screenBottomCenter, playerHand);
c.Position = playerHand.BottomCardInsertPosition;
c.DelayMovementOnEntering(currentDelay);
});
Scheduler.AddDelayed(() =>
{
SamplePlaybackHelper.PlayWithRandomPitch(cardAddSample);
}, 50 * cardCount);
cardCount++;
}

playerHand.UpdateLayout(stagger: 50);
Scheduler.AddDelayed(() => SamplePlaybackHelper.PlayWithRandomPitch(cardAddSample), delay);

delay += stagger;
}
}

private void onCountdownStarted(MultiplayerCountdown countdown) => Scheduler.Add(() =>
Expand Down Expand Up @@ -297,8 +297,9 @@ private void cardAdded(RankedPlayCardWithPlaylistItem card)
{
playerHand.AddCard(card, d =>
{
d.Position = ToSpaceOfOtherDrawable(new Vector2(DrawWidth, DrawHeight * 0.5f), playerHand);
d.Rotation = -30;
// card should enter from centre-right of screen
var cardEnterPosition = ToSpaceOfOtherDrawable(new Vector2(DrawWidth, DrawHeight * 0.5f), playerHand);
d.SetupMovementForDrawnCard(cardEnterPosition);
});

SamplePlaybackHelper.PlayWithRandomPitch(cardAddSample);
Expand Down
Loading
Loading