Skip to content

Commit ee2f7a7

Browse files
authored
Adjust RankedPlayCard to always show card back (when loading content) (ppy#37129)
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. > Cards have a stale grey background when they are spawning in before they get changed into the cards they’re supposed to be. This can be changed to the backside of the card or maybe a bright white card. Makes it look less placeholdery. Keeping it simple for now. Can probably hide it when not in use in the future.
1 parent 940848e commit ee2f7a7

File tree

4 files changed

+76
-20
lines changed

4 files changed

+76
-20
lines changed

osu.Game.Tests/Visual/RankedPlay/TestSceneDiscardScreen.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 TestSceneDiscardScreen : MultiplayerTestScene
13+
public partial class TestSceneDiscardScreen : 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.CardDiscard).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.Tests/Visual/RankedPlay/TestSceneOpponentPickScreen.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 TestSceneOpponentPickScreen : MultiplayerTestScene
13+
public partial class TestSceneOpponentPickScreen : 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 = 2).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.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: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,11 @@ public RankedPlayCard(RankedPlayCardWithPlaylistItem item)
9797
Origin = Anchor.Centre,
9898
Children =
9999
[
100+
new RankedPlayCardBackSide(),
100101
cardContent = new Container
101102
{
102103
RelativeSizeAxes = Axes.Both,
103-
Child = new RankedPlayCardBackSide()
104+
Child = Empty(),
104105
},
105106
selectionOutline = new SelectionOutline
106107
{
@@ -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,22 @@ 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+
private bool hasContent;
176+
177+
public void SetContent(Drawable? newContent)
177178
{
178-
if (!flip)
179-
{
180-
cardContent.Child = newContent;
179+
if (newContent == null && !hasContent)
181180
return;
182-
}
183181

182+
hasContent = newContent != null;
184183
content.ScaleTo(new Vector2(0, 1), 100, Easing.In)
185184
.Then()
186-
.Schedule(() => cardContent.Child = newContent)
185+
.Schedule(() => cardContent.Child = newContent ?? Empty())
187186
.ScaleTo(new Vector2(1), 300, Easing.OutElasticQuarter);
188187

189188
SamplePlaybackHelper.PlayWithRandomPitch(cardFlipSample);

0 commit comments

Comments
 (0)