1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-24 12:42: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,19 +144,13 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
SelectedItem = SelectedItem SelectedItem = SelectedItem
} }
}, },
new Drawable[] new[]
{
new Container
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Margin = new MarginPadding { Top = 10 },
Children = new[]
{ {
UserModsSection = new FillFlowContainer UserModsSection = new FillFlowContainer
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
Margin = new MarginPadding { Top = 10 },
Alpha = 0, Alpha = 0,
Children = new Drawable[] Children = new Drawable[]
{ {
@ -189,11 +180,15 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
} }
}, },
} }
}
}, },
new[]
{
UserStyleSection = new FillFlowContainer UserStyleSection = new FillFlowContainer
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
Margin = new MarginPadding { Top = 10 },
Alpha = 0, Alpha = 0,
Children = new Drawable[] Children = new Drawable[]
{ {
@ -205,8 +200,6 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
} }
} }
}, },
}
}
}, },
}, },
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,29 +175,20 @@ 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
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Margin = new MarginPadding { Bottom = 10 },
Children = new[]
{ {
UserModsSection = new FillFlowContainer UserModsSection = new FillFlowContainer
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
Alpha = 0,
Margin = new MarginPadding { Bottom = 10 }, Margin = new MarginPadding { Bottom = 10 },
Alpha = 0,
Children = new Drawable[] Children = new Drawable[]
{ {
new OverlinedHeader("Extra mods"), new OverlinedHeader("Extra mods"),
@ -228,10 +218,14 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
} }
} }
}, },
},
new[]
{
UserStyleSection = new FillFlowContainer UserStyleSection = new FillFlowContainer
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
Margin = new MarginPadding { Bottom = 10 },
Alpha = 0, Alpha = 0,
Children = new Drawable[] Children = new Drawable[]
{ {
@ -243,8 +237,6 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
} }
} }
}, },
}
},
}, },
new Drawable[] new Drawable[]
{ {
@ -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,