Skip to content

Commit 26da75e

Browse files
authored
Merge pull request #35704 from minetoblend/feature/quickplay-random-panel-design-pass
2 parents 713b645 + 9f8554c commit 26da75e

File tree

12 files changed

+198
-132
lines changed

12 files changed

+198
-132
lines changed

osu.Game.Tests/Visual/Matchmaking/TestSceneBeatmapSelectGrid.cs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
using osu.Framework.Allocation;
99
using osu.Framework.Graphics;
1010
using osu.Framework.Testing;
11-
using osu.Framework.Utils;
1211
using osu.Game.Beatmaps;
1312
using osu.Game.Graphics;
1413
using osu.Game.Graphics.Sprites;
@@ -130,7 +129,7 @@ public void TestCompleteRollAnimation()
130129
{
131130
var (candidateItems, finalItem) = pickRandomItems(5);
132131

133-
grid.RollAndDisplayFinalBeatmap(candidateItems, finalItem);
132+
grid.RollAndDisplayFinalBeatmap(candidateItems, finalItem, finalItem);
134133
});
135134
}
136135

@@ -159,7 +158,7 @@ public void TestPresentRolledBeatmap()
159158
grid.ArrangeItemsForRollAnimation(duration: 0, stagger: 0);
160159
grid.PlayRollAnimation(finalItem, duration: 0);
161160

162-
Scheduler.AddDelayed(() => grid.PresentRolledBeatmap(finalItem), 500);
161+
Scheduler.AddDelayed(() => grid.PresentRolledBeatmap(finalItem, finalItem), 500);
163162
});
164163
}
165164

@@ -174,7 +173,25 @@ public void TestPresentUnanimouslyChosenBeatmap()
174173
grid.ArrangeItemsForRollAnimation(duration: 0, stagger: 0);
175174
grid.PlayRollAnimation(finalItem, duration: 0);
176175

177-
Scheduler.AddDelayed(() => grid.PresentUnanimouslyChosenBeatmap(finalItem), 500);
176+
Scheduler.AddDelayed(() => grid.PresentUnanimouslyChosenBeatmap(finalItem, finalItem), 500);
177+
});
178+
}
179+
180+
[Test]
181+
public void TestPresentRandomItem()
182+
{
183+
AddStep("present random item panel", () =>
184+
{
185+
var (candidateItems, finalItem) = pickRandomItems(4);
186+
187+
grid.TransferCandidatePanelsToRollContainer(candidateItems.Append(-1).ToArray(), duration: 0);
188+
grid.ArrangeItemsForRollAnimation(duration: 0, stagger: 0);
189+
grid.PlayRollAnimation(-1, duration: 0);
190+
191+
Scheduler.AddDelayed(() =>
192+
{
193+
grid.PresentRolledBeatmap(-1, finalItem);
194+
}, 500);
178195
});
179196
}
180197

@@ -218,23 +235,6 @@ public void TestPanelArrangement(int count)
218235
});
219236
}
220237

221-
[Test]
222-
public void TestPresentRandomItem()
223-
{
224-
AddStep("present random item panel", () =>
225-
{
226-
grid.TransferCandidatePanelsToRollContainer(pickRandomItems(4).candidateItems.Append(-1).ToArray(), duration: 0);
227-
grid.ArrangeItemsForRollAnimation(duration: 0, stagger: 0);
228-
grid.PlayRollAnimation(-1, duration: 0);
229-
230-
Scheduler.AddDelayed(() => grid.PresentUnanimouslyChosenBeatmap(-1), 500);
231-
});
232-
233-
AddWaitStep("wait for animation", 5);
234-
235-
AddStep("reveal beatmap", () => grid.RevealRandomItem(items[RNG.Next(items.Length)].PlaylistItem));
236-
}
237-
238238
private (long[] candidateItems, long finalItem) pickRandomItems(int count)
239239
{
240240
long[] candidateItems = items.Select(it => it.ID).ToArray();

osu.Game.Tests/Visual/Matchmaking/TestSceneBeatmapSelectPanel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public void TestRandomPanel()
9898

9999
AddToggleStep("allow selection", value => panel!.AllowSelection = value);
100100

101-
AddStep("reveal beatmap", () => panel!.RevealBeatmap(CreateAPIBeatmap(), []));
101+
AddStep("reveal beatmap", () => panel!.PresentAsChosenBeatmap(new MatchmakingPlaylistItem(new MultiplayerPlaylistItem(), CreateAPIBeatmap(), [])));
102102
}
103103

104104
[Test]

osu.Game.Tests/Visual/Matchmaking/TestSceneMatchmakingScreen.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ public void TestGameplayFlow()
110110

111111
state.CandidateItems = beatmaps.Select(b => b.ID).ToArray();
112112
state.CandidateItem = beatmaps[0].ID;
113+
state.GameplayItem = beatmaps[0].ID;
113114
}, waitTime: 35);
114115

115116
changeStage(MatchmakingStage.WaitingForClientsBeatmapDownload);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public void TestScreen()
104104
long[] candidateItems = selectedItems.ToArray();
105105
long finalItem = candidateItems[Random.Shared.Next(candidateItems.Length)];
106106

107-
screen.RollFinalBeatmap(candidateItems, finalItem);
107+
screen.RollFinalBeatmap(candidateItems, finalItem, finalItem);
108108
});
109109
}
110110

osu.Game/Online/Multiplayer/MatchTypes/Matchmaking/MatchmakingRoomState.cs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,20 @@ public class MatchmakingRoomState : MatchRoomState
2828
public int CurrentRound { get; set; }
2929

3030
/// <summary>
31-
/// The playlist items that were picked as gameplay candidates.
31+
/// The playlist items that were picked as candidates by user.
3232
/// </summary>
33+
/// <remarks>
34+
/// May contain <c>-1</c> when any users picked the "random" playlist item.
35+
/// </remarks>
3336
[Key(2)]
3437
public long[] CandidateItems { get; set; } = [];
3538

3639
/// <summary>
37-
/// The final gameplay candidate.
40+
/// A playlist item from <see cref="CandidateItems"/> that was randomly picked by the server.
3841
/// </summary>
42+
/// <remarks>
43+
/// May be <c>-1</c> to indicate the "random" playlist item was chosen.
44+
/// </remarks>
3945
[Key(3)]
4046
public long CandidateItem { get; set; }
4147

@@ -45,6 +51,15 @@ public class MatchmakingRoomState : MatchRoomState
4551
[Key(4)]
4652
public MatchmakingUserList Users { get; set; } = new MatchmakingUserList();
4753

54+
/// <summary>
55+
/// A playlist item from the room's playlist that will be played in the current round.
56+
/// </summary>
57+
/// <remarks>
58+
/// The value of this property may not equal <see cref="CandidateItem"/> or exist in <see cref="CandidateItems"/>.
59+
/// </remarks>
60+
[Key(5)]
61+
public long GameplayItem { get; set; }
62+
4863
/// <summary>
4964
/// Advances to the next round.
5065
/// </summary>

osu.Game/Screens/OnlinePlay/Matchmaking/Match/BeatmapSelect/BeatmapSelectGrid.cs

Lines changed: 14 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ public partial class BeatmapSelectGrid : CompositeDrawable
4646

4747
private readonly Sample?[] spinSamples = new Sample?[5];
4848
private static readonly int[] spin_sample_sequence = [0, 1, 2, 3, 4, 2, 3, 4];
49-
private Sample? randomRevealSample;
50-
private Sample? resultSample;
5149
private Sample? swooshSample;
5250
private double? lastSamplePlayback;
5351

@@ -81,8 +79,6 @@ private void load(AudioManager audio)
8179
for (int i = 0; i < spinSamples.Length; i++)
8280
spinSamples[i] = audio.Samples.Get($@"Multiplayer/Matchmaking/Selection/roulette-{i}");
8381

84-
randomRevealSample = audio.Samples.Get(@"Multiplayer/Matchmaking/Selection/random-reveal");
85-
resultSample = audio.Samples.Get(@"Multiplayer/Matchmaking/Selection/roulette-result");
8682
swooshSample = audio.Samples.Get(@"SongSelect/options-pop-out");
8783
}
8884

@@ -144,21 +140,11 @@ public void SetUserSelection(APIUser user, long itemId, bool selected) => whenPa
144140
panel.RemoveUser(user);
145141
});
146142

147-
public void RevealRandomItem(MultiplayerPlaylistItem item) => whenPanelsLoaded(() =>
148-
{
149-
playlistItems.TryGetValue(item.ID, out var playlistItem);
150-
151-
Debug.Assert(playlistItem != null);
152-
153-
randomRevealSample?.Play();
154-
randomPanel.RevealBeatmap(playlistItem.Beatmap, playlistItem.Mods);
155-
});
156-
157-
public void RollAndDisplayFinalBeatmap(long[] candidateItemIds, long finalItemId) => whenPanelsLoaded(() =>
143+
public void RollAndDisplayFinalBeatmap(long[] candidateItemIds, long candidateItemId, long gameplayItemId) => whenPanelsLoaded(() =>
158144
{
159145
Debug.Assert(candidateItemIds.Length >= 1);
160-
Debug.Assert(candidateItemIds.Contains(finalItemId));
161-
Debug.Assert(panelLookup.ContainsKey(finalItemId));
146+
Debug.Assert(candidateItemIds.Contains(candidateItemId));
147+
Debug.Assert(panelLookup.ContainsKey(candidateItemId));
162148
Debug.Assert(candidateItemIds.All(id => panelLookup.ContainsKey(id)));
163149

164150
allowSelection = false;
@@ -170,16 +156,16 @@ public void RollAndDisplayFinalBeatmap(long[] candidateItemIds, long finalItemId
170156
this.Delay(ARRANGE_DELAY)
171157
.Schedule(() => ArrangeItemsForRollAnimation())
172158
.Delay(arrange_duration + present_beatmap_delay)
173-
.Schedule(() => PresentUnanimouslyChosenBeatmap(finalItemId));
159+
.Schedule(() => PresentUnanimouslyChosenBeatmap(candidateItemId, gameplayItemId));
174160
}
175161
else
176162
{
177163
this.Delay(ARRANGE_DELAY)
178164
.Schedule(() => ArrangeItemsForRollAnimation())
179165
.Delay(arrange_duration)
180-
.Schedule(() => PlayRollAnimation(finalItemId, roll_duration))
166+
.Schedule(() => PlayRollAnimation(gameplayItemId, roll_duration))
181167
.Delay(roll_duration + present_beatmap_delay)
182-
.Schedule(() => PresentRolledBeatmap(finalItemId));
168+
.Schedule(() => PresentRolledBeatmap(candidateItemId, gameplayItemId));
183169
}
184170
});
185171

@@ -326,13 +312,14 @@ internal void PlayRollAnimation(long finalItem, double duration = roll_duration)
326312
}
327313
}
328314

329-
internal void PresentRolledBeatmap(long finalItem)
315+
internal void PresentRolledBeatmap(long candidateItem, long gameplayItem)
330316
{
331-
Debug.Assert(rollContainer.Children.Any(it => it.Item.ID == finalItem));
317+
Debug.Assert(rollContainer.Children.Any(it => it.Item.ID == candidateItem));
318+
Debug.Assert(playlistItems.ContainsKey(gameplayItem));
332319

333320
foreach (var panel in rollContainer.Children)
334321
{
335-
if (panel.Item.ID != finalItem)
322+
if (panel.Item.ID != candidateItem)
336323
{
337324
panel.FadeOut(200);
338325
panel.PopOutAndExpire(easing: Easing.InQuad);
@@ -344,20 +331,18 @@ internal void PresentRolledBeatmap(long finalItem)
344331
{
345332
rollContainer.ChangeChildDepth(panel, float.MinValue);
346333

347-
panel.ShowChosenBorder();
348-
panel.MoveTo(Vector2.Zero, 1000, Easing.OutExpo)
349-
.ScaleTo(1.5f, 1000, Easing.OutExpo);
334+
var item = playlistItems[gameplayItem];
350335

351-
resultSample?.Play();
336+
panel.PresentAsChosenBeatmap(item);
352337
});
353338
}
354339
}
355340

356-
internal void PresentUnanimouslyChosenBeatmap(long finalItem)
341+
internal void PresentUnanimouslyChosenBeatmap(long candidateItem, long gameplayItem)
357342
{
358343
// TODO: display special animation in this case
359344

360-
PresentRolledBeatmap(finalItem);
345+
PresentRolledBeatmap(candidateItem, gameplayItem);
361346
}
362347

363348
private readonly TaskCompletionSource panelsLoaded = new TaskCompletionSource();

osu.Game/Screens/OnlinePlay/Matchmaking/Match/BeatmapSelect/MatchmakingSelectPanel.CardContentRandom.cs

Lines changed: 54 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33

44
using osu.Framework.Allocation;
55
using osu.Framework.Graphics;
6-
using osu.Framework.Graphics.Containers;
76
using osu.Framework.Graphics.Shapes;
87
using osu.Framework.Graphics.Sprites;
8+
using osu.Framework.Utils;
9+
using osu.Game.Graphics.Backgrounds;
910
using osu.Game.Graphics.Sprites;
1011
using osu.Game.Overlays;
1112
using osuTK;
@@ -22,6 +23,8 @@ public partial class CardContentRandom : CardContent
2223
private OverlayColourProvider colourProvider { get; set; } = null!;
2324

2425
private AvatarOverlay selectionOverlay = null!;
26+
public SpriteIcon Dice { get; private set; } = null!;
27+
public OsuSpriteText Label { get; private set; } = null!;
2528

2629
[BackgroundDependencyLoader]
2730
private void load()
@@ -31,50 +34,62 @@ private void load()
3134
new Box
3235
{
3336
RelativeSizeAxes = Axes.Both,
34-
Colour = colourProvider.Background2,
37+
Colour = colourProvider.Dark5,
3538
},
36-
new Container
39+
new TrianglesV2
3740
{
3841
RelativeSizeAxes = Axes.Both,
39-
Padding = new MarginPadding
40-
{
41-
Horizontal = 10,
42-
Vertical = 4
43-
},
44-
Children = new Drawable[]
45-
{
46-
new FillFlowContainer
47-
{
48-
Anchor = Anchor.Centre,
49-
Origin = Anchor.Centre,
50-
AutoSizeAxes = Axes.Both,
51-
Direction = FillDirection.Vertical,
52-
Children =
53-
[
54-
new SpriteIcon
55-
{
56-
Anchor = Anchor.TopCentre,
57-
Origin = Anchor.TopCentre,
58-
Size = new Vector2(32),
59-
Icon = FontAwesome.Solid.Random,
60-
},
61-
new OsuSpriteText
62-
{
63-
Anchor = Anchor.TopCentre,
64-
Origin = Anchor.TopCentre,
65-
Text = "Random",
66-
}
67-
]
68-
},
69-
selectionOverlay = new AvatarOverlay
70-
{
71-
Anchor = Anchor.TopRight,
72-
Origin = Anchor.TopRight,
73-
}
74-
}
42+
Alpha = 0.1f,
43+
},
44+
Label = new OsuSpriteText
45+
{
46+
Y = 20,
47+
Anchor = Anchor.Centre,
48+
Origin = Anchor.Centre,
49+
Text = "Random"
50+
},
51+
Dice = new SpriteIcon
52+
{
53+
Y = -10,
54+
Size = new Vector2(28),
55+
Anchor = Anchor.Centre,
56+
Origin = Anchor.Centre,
57+
Icon = randomDiceIcon(),
58+
},
59+
selectionOverlay = new AvatarOverlay
60+
{
61+
Anchor = Anchor.TopRight,
62+
Origin = Anchor.TopRight,
7563
}
7664
};
65+
66+
Dice.Spin(10_000, RotationDirection.Clockwise);
7767
}
68+
69+
public void RollDice()
70+
{
71+
var icon = randomDiceIcon();
72+
73+
while (icon.Equals(Dice.Icon))
74+
icon = randomDiceIcon();
75+
76+
Dice.ScaleTo(0.65f, 60, Easing.Out)
77+
.Then()
78+
.Schedule(() => Dice.Icon = icon)
79+
.ScaleTo(1f, 400, Easing.OutElasticHalf);
80+
}
81+
82+
private static IconUsage[] diceIcons => new[]
83+
{
84+
FontAwesome.Solid.DiceOne,
85+
FontAwesome.Solid.DiceTwo,
86+
FontAwesome.Solid.DiceThree,
87+
FontAwesome.Solid.DiceFour,
88+
FontAwesome.Solid.DiceFive,
89+
FontAwesome.Solid.DiceSix,
90+
};
91+
92+
private static IconUsage randomDiceIcon() => diceIcons[RNG.Next(diceIcons.Length)];
7893
}
7994
}
8095
}

0 commit comments

Comments
 (0)