1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-24 04:22:54 +08:00

Initial support for freemod+freestyle

This commit is contained in:
Dan Balasescu 2025-02-06 13:29:16 +09:00
parent 7f8f528ae2
commit 84206e9ad8
No known key found for this signature in database
3 changed files with 86 additions and 107 deletions

View File

@ -4,7 +4,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics;
using System.Linq; using System.Linq;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Audio; using osu.Framework.Audio;
@ -441,7 +440,9 @@ namespace osu.Game.Screens.OnlinePlay.Match
var rulesetInstance = GetGameplayRuleset().CreateInstance(); var rulesetInstance = GetGameplayRuleset().CreateInstance();
// Remove any user mods that are no longer allowed. // Remove any user mods that are no longer allowed.
Mod[] allowedMods = item.AllowedMods.Select(m => m.ToMod(rulesetInstance)).ToArray(); Mod[] allowedMods = item.Freestyle
? rulesetInstance.CreateAllMods().Where(m => ModUtils.IsValidFreeModForMatchType(m, Room.Type)).ToArray()
: item.AllowedMods.Select(m => m.ToMod(rulesetInstance)).ToArray();
Mod[] newUserMods = UserMods.Value.Where(m => allowedMods.Any(a => m.GetType() == a.GetType())).ToArray(); Mod[] newUserMods = UserMods.Value.Where(m => allowedMods.Any(a => m.GetType() == a.GetType())).ToArray();
if (!newUserMods.SequenceEqual(UserMods.Value)) if (!newUserMods.SequenceEqual(UserMods.Value))
UserMods.Value = UserMods.Value.Where(m => allowedMods.Any(a => m.GetType() == a.GetType())).ToList(); UserMods.Value = UserMods.Value.Where(m => allowedMods.Any(a => m.GetType() == a.GetType())).ToList();
@ -455,12 +456,8 @@ namespace osu.Game.Screens.OnlinePlay.Match
Mods.Value = GetGameplayMods().Select(m => m.ToMod(rulesetInstance)).ToArray(); Mods.Value = GetGameplayMods().Select(m => m.ToMod(rulesetInstance)).ToArray();
Ruleset.Value = GetGameplayRuleset(); Ruleset.Value = GetGameplayRuleset();
bool freeMod = item.AllowedMods.Any();
bool freestyle = item.Freestyle; bool freestyle = item.Freestyle;
bool freeMod = freestyle || item.AllowedMods.Any();
// For now, the game can never be in a state where freemod and freestyle are on at the same time.
// This will change, but due to the current implementation if this was to occur drawables will overlap so let's assert.
Debug.Assert(!freeMod || !freestyle);
if (freeMod) if (freeMod)
{ {

View File

@ -98,7 +98,6 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
{ {
new Drawable?[] new Drawable?[]
{ {
// Participants column
new GridContainer new GridContainer
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
@ -118,9 +117,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
} }
} }
}, },
// Spacer
null, null,
// Beatmap column
new GridContainer new GridContainer
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
@ -147,67 +144,63 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
SelectedItem = SelectedItem SelectedItem = SelectedItem
} }
}, },
new Drawable[] new[]
{ {
new Container UserModsSection = new FillFlowContainer
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
Margin = new MarginPadding { Top = 10 }, Margin = new MarginPadding { Top = 10 },
Children = new[] Alpha = 0,
Children = new Drawable[]
{ {
UserModsSection = new FillFlowContainer new OverlinedHeader("Extra mods"),
new FillFlowContainer
{ {
RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Both,
AutoSizeAxes = Axes.Y, Direction = FillDirection.Horizontal,
Alpha = 0, Spacing = new Vector2(10, 0),
Children = new Drawable[] Children = new Drawable[]
{ {
new OverlinedHeader("Extra mods"), new UserModSelectButton
new FillFlowContainer
{ {
AutoSizeAxes = Axes.Both, Anchor = Anchor.CentreLeft,
Direction = FillDirection.Horizontal, Origin = Anchor.CentreLeft,
Spacing = new Vector2(10, 0), Width = 90,
Children = new Drawable[] Text = "Select",
{ Action = ShowUserModSelect,
new UserModSelectButton
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Width = 90,
Text = "Select",
Action = ShowUserModSelect,
},
new ModDisplay
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Current = UserMods,
Scale = new Vector2(0.8f),
},
}
}, },
} new ModDisplay
},
UserStyleSection = new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Alpha = 0,
Children = new Drawable[]
{
new OverlinedHeader("Difficulty"),
UserStyleDisplayContainer = new Container<DrawableRoomPlaylistItem>
{ {
RelativeSizeAxes = Axes.X, Anchor = Anchor.CentreLeft,
AutoSizeAxes = Axes.Y Origin = Anchor.CentreLeft,
} Current = UserMods,
Scale = new Vector2(0.8f),
},
} }
}, },
} }
} }
}, },
new[]
{
UserStyleSection = new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Margin = new MarginPadding { Top = 10 },
Alpha = 0,
Children = new Drawable[]
{
new OverlinedHeader("Difficulty"),
UserStyleDisplayContainer = new Container<DrawableRoomPlaylistItem>
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y
}
}
},
},
}, },
RowDimensions = new[] RowDimensions = new[]
{ {
@ -218,9 +211,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
new Dimension(GridSizeMode.AutoSize), new Dimension(GridSizeMode.AutoSize),
} }
}, },
// Spacer
null, null,
// Main right column
new GridContainer new GridContainer
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,

View File

@ -146,7 +146,6 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
{ {
new Drawable?[] new Drawable?[]
{ {
// Playlist items column
new GridContainer new GridContainer
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
@ -176,73 +175,66 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
new Dimension(), new Dimension(),
} }
}, },
// Spacer
null, null,
// Middle column (mods and leaderboard)
new GridContainer new GridContainer
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Content = new[] Content = new[]
{ {
new Drawable[] new[]
{ {
new Container UserModsSection = new FillFlowContainer
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
Margin = new MarginPadding { Bottom = 10 }, Margin = new MarginPadding { Bottom = 10 },
Children = new[] Alpha = 0,
Children = new Drawable[]
{ {
UserModsSection = new FillFlowContainer new OverlinedHeader("Extra mods"),
new FillFlowContainer
{ {
RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Both,
AutoSizeAxes = Axes.Y, Direction = FillDirection.Horizontal,
Alpha = 0, Spacing = new Vector2(10, 0),
Margin = new MarginPadding { Bottom = 10 },
Children = new Drawable[] Children = new Drawable[]
{ {
new OverlinedHeader("Extra mods"), new UserModSelectButton
new FillFlowContainer
{ {
AutoSizeAxes = Axes.Both, Anchor = Anchor.CentreLeft,
Direction = FillDirection.Horizontal, Origin = Anchor.CentreLeft,
Spacing = new Vector2(10, 0), Width = 90,
Children = new Drawable[] Text = "Select",
{ Action = ShowUserModSelect,
new UserModSelectButton },
{ new ModDisplay
Anchor = Anchor.CentreLeft, {
Origin = Anchor.CentreLeft, Anchor = Anchor.CentreLeft,
Width = 90, Origin = Anchor.CentreLeft,
Text = "Select", Current = UserMods,
Action = ShowUserModSelect, Scale = new Vector2(0.8f),
}, },
new ModDisplay
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Current = UserMods,
Scale = new Vector2(0.8f),
},
}
}
} }
}, }
UserStyleSection = new FillFlowContainer }
},
},
new[]
{
UserStyleSection = new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Margin = new MarginPadding { Bottom = 10 },
Alpha = 0,
Children = new Drawable[]
{
new OverlinedHeader("Difficulty"),
UserStyleDisplayContainer = new Container<DrawableRoomPlaylistItem>
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y
Alpha = 0, }
Children = new Drawable[]
{
new OverlinedHeader("Difficulty"),
UserStyleDisplayContainer = new Container<DrawableRoomPlaylistItem>
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y
}
}
},
} }
}, },
}, },
@ -273,12 +265,11 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
new Dimension(GridSizeMode.AutoSize), new Dimension(GridSizeMode.AutoSize),
new Dimension(GridSizeMode.AutoSize), new Dimension(GridSizeMode.AutoSize),
new Dimension(GridSizeMode.AutoSize), new Dimension(GridSizeMode.AutoSize),
new Dimension(GridSizeMode.AutoSize),
new Dimension(), new Dimension(),
} }
}, },
// Spacer
null, null,
// Main right column
new GridContainer new GridContainer
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,