Skip to content

Commit 368377a

Browse files
committed
Adjust RankedPlayCard to always show card back (when loading content too)
This was mentioned in vivi's feedback. Basically now the card backside is always loaded and there, rather than faffing with switching the content around. Keeping it simple for now. Can probably hide it when not in use in the future.
1 parent c8f563d commit 368377a

File tree

2 files changed

+29
-17
lines changed

2 files changed

+29
-17
lines changed

osu.Game.Tests/Visual/RankedPlay/TestScenePickScreen.cs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
// See the LICENCE file in the repository root for full licence text.
33

44
using osu.Framework.Extensions;
5+
using osu.Game.Online.API;
56
using osu.Game.Online.Multiplayer;
67
using osu.Game.Online.Multiplayer.MatchTypes.RankedPlay;
78
using osu.Game.Online.Rooms;
89
using osu.Game.Screens.OnlinePlay.Matchmaking.RankedPlay;
9-
using osu.Game.Tests.Visual.Multiplayer;
1010

1111
namespace osu.Game.Tests.Visual.RankedPlay
1212
{
13-
public partial class TestScenePickScreen : MultiplayerTestScene
13+
public partial class TestScenePickScreen : RankedPlayTestScene
1414
{
1515
private RankedPlayScreen screen = null!;
1616

@@ -26,7 +26,26 @@ public override void SetUpSteps()
2626
AddStep("load screen", () => LoadScreen(screen = new RankedPlayScreen(MultiplayerClient.ClientRoom!)));
2727
AddUntilStep("screen loaded", () => screen.IsLoaded);
2828

29+
var requestHandler = new BeatmapRequestHandler();
30+
31+
AddStep("setup request handler", () => ((DummyAPIAccess)API).HandleRequest = requestHandler.HandleRequest);
32+
2933
AddStep("set pick state", () => MultiplayerClient.RankedPlayChangeStage(RankedPlayStage.CardPlay, state => state.ActiveUserId = API.LocalUser.Value.OnlineID).WaitSafely());
34+
35+
AddWaitStep("wait some", 5);
36+
37+
AddStep("reveal cards", () =>
38+
{
39+
for (int i = 0; i < 5; i++)
40+
{
41+
int i2 = i;
42+
MultiplayerClient.RankedPlayRevealCard(hand => hand[i2], new MultiplayerPlaylistItem
43+
{
44+
ID = i2,
45+
BeatmapID = requestHandler.Beatmaps[i2].OnlineID
46+
}).WaitSafely();
47+
}
48+
});
3049
}
3150
}
3251
}

osu.Game/Screens/OnlinePlay/Matchmaking/RankedPlay/Card/RankedPlayCard.cs

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ public RankedPlayCard(RankedPlayCardWithPlaylistItem item)
9797
Origin = Anchor.Centre,
9898
Children =
9999
[
100+
new RankedPlayCardBackSide(),
100101
cardContent = new Container
101102
{
102103
RelativeSizeAxes = Axes.Both,
@@ -123,9 +124,7 @@ protected override void LoadComplete()
123124
{
124125
base.LoadComplete();
125126

126-
playlistItem.BindValueChanged(e => onPlaylistItemChanged(e.NewValue));
127-
if (playlistItem.Value != null)
128-
loadCardContent(playlistItem.Value, false);
127+
playlistItem.BindValueChanged(e => onPlaylistItemChanged(e.NewValue), true);
129128
}
130129

131130
protected override void UpdateAfterChildren()
@@ -147,14 +146,14 @@ private void onPlaylistItemChanged(MultiplayerPlaylistItem? playlistItem)
147146
{
148147
if (playlistItem == null)
149148
{
150-
SetContent(new RankedPlayCardBackSide(), true);
149+
SetContent(null);
151150
return;
152151
}
153152

154-
loadCardContent(playlistItem, true);
153+
loadCardContentAsync(playlistItem);
155154
}
156155

157-
private void loadCardContent(MultiplayerPlaylistItem playlistItem, bool flip) => Task.Run(async () =>
156+
private void loadCardContentAsync(MultiplayerPlaylistItem playlistItem) => Task.Run(async () =>
158157
{
159158
var beatmap = await beatmapLookupCache.GetBeatmapAsync(playlistItem.BeatmapID).ConfigureAwait(false);
160159

@@ -168,22 +167,16 @@ private void loadCardContent(MultiplayerPlaylistItem playlistItem, bool flip) =>
168167

169168
Schedule(() =>
170169
{
171-
SetContent(new RankedPlayCardContent(beatmap), flip);
170+
SetContent(new RankedPlayCardContent(beatmap));
172171
songPreviewContainer.LoadPreview(beatmap);
173172
});
174173
});
175174

176-
public void SetContent(Drawable newContent, bool flip)
175+
public void SetContent(Drawable? newContent)
177176
{
178-
if (!flip)
179-
{
180-
cardContent.Child = newContent;
181-
return;
182-
}
183-
184177
content.ScaleTo(new Vector2(0, 1), 100, Easing.In)
185178
.Then()
186-
.Schedule(() => cardContent.Child = newContent)
179+
.Schedule(() => cardContent.Child = newContent ?? Empty())
187180
.ScaleTo(new Vector2(1), 300, Easing.OutElasticQuarter);
188181

189182
SamplePlaybackHelper.PlayWithRandomPitch(cardFlipSample);

0 commit comments

Comments
 (0)