2024-02-23 13:42:58 +00:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
2024-02-18 01:13:57 +00:00
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
2024-02-20 10:57:28 +00:00
|
|
|
using System.Collections.Generic;
|
2024-02-18 01:13:57 +00:00
|
|
|
using System.Linq;
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Game.Online.Rooms;
|
2024-02-23 13:42:58 +00:00
|
|
|
using osu.Game.Overlays;
|
|
|
|
using osu.Game.Overlays.Mods;
|
|
|
|
using osu.Game.Rulesets;
|
2024-02-18 01:13:57 +00:00
|
|
|
using osu.Game.Rulesets.Mods;
|
|
|
|
|
2024-02-23 13:42:58 +00:00
|
|
|
namespace osu.Game.Screens.OnlinePlay.Match
|
2024-02-18 01:13:57 +00:00
|
|
|
{
|
2024-02-23 13:42:58 +00:00
|
|
|
public partial class RoomModSelectOverlay : UserModSelectOverlay
|
2024-02-18 01:13:57 +00:00
|
|
|
{
|
2024-02-23 13:42:58 +00:00
|
|
|
public RoomModSelectOverlay(OverlayColourScheme colourScheme = OverlayColourScheme.Plum)
|
2024-02-18 01:13:57 +00:00
|
|
|
: base(colourScheme)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
[Resolved(CanBeNull = true)]
|
2024-02-23 13:42:58 +00:00
|
|
|
private IBindable<PlaylistItem>? selectedItem { get; set; }
|
2024-02-18 01:13:57 +00:00
|
|
|
|
|
|
|
[Resolved]
|
|
|
|
private OsuGameBase game { get; set; } = null!;
|
|
|
|
|
2024-02-23 13:42:58 +00:00
|
|
|
protected override BeatmapAttributesDisplay GetBeatmapAttributesDisplay => new RoomBeatmapAttributesDisplay
|
2024-02-18 01:13:57 +00:00
|
|
|
{
|
|
|
|
Anchor = Anchor.BottomRight,
|
|
|
|
Origin = Anchor.BottomRight,
|
2024-02-18 01:15:53 +00:00
|
|
|
BeatmapInfo = { Value = Beatmap?.BeatmapInfo }
|
2024-02-18 01:13:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
2024-02-23 13:42:58 +00:00
|
|
|
selectedItem?.BindValueChanged(_ => SelectedMods.TriggerChange());
|
2024-02-18 01:13:57 +00:00
|
|
|
}
|
|
|
|
|
2024-02-20 10:57:28 +00:00
|
|
|
protected override IEnumerable<Mod> AllSelectedMods
|
2024-02-18 01:13:57 +00:00
|
|
|
{
|
2024-02-20 10:57:28 +00:00
|
|
|
get
|
2024-02-18 01:13:57 +00:00
|
|
|
{
|
2024-02-20 10:57:28 +00:00
|
|
|
IEnumerable<Mod> allMods = SelectedMods.Value;
|
2024-02-18 01:13:57 +00:00
|
|
|
|
2024-02-23 13:42:58 +00:00
|
|
|
if (selectedItem?.Value != null)
|
2024-02-20 10:57:28 +00:00
|
|
|
{
|
|
|
|
Ruleset ruleset = game.Ruleset.Value.CreateInstance();
|
2024-02-23 13:42:58 +00:00
|
|
|
var multiplayerRoomMods = selectedItem.Value.RequiredMods.Select(m => m.ToMod(ruleset));
|
2024-02-20 10:57:28 +00:00
|
|
|
allMods = allMods.Concat(multiplayerRoomMods);
|
|
|
|
}
|
2024-02-18 01:13:57 +00:00
|
|
|
|
2024-02-20 10:57:28 +00:00
|
|
|
return allMods;
|
2024-02-18 01:13:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-23 13:42:58 +00:00
|
|
|
public partial class RoomBeatmapAttributesDisplay : BeatmapAttributesDisplay
|
2024-02-18 01:13:57 +00:00
|
|
|
{
|
|
|
|
[Resolved(CanBeNull = true)]
|
|
|
|
private IBindable<PlaylistItem>? multiplayerRoomItem { get; set; }
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
|
|
|
multiplayerRoomItem?.BindValueChanged(_ => Mods.TriggerChange());
|
|
|
|
}
|
|
|
|
|
2024-02-20 10:57:28 +00:00
|
|
|
protected override IEnumerable<Mod> SelectedMods
|
2024-02-18 01:13:57 +00:00
|
|
|
{
|
2024-02-20 10:57:28 +00:00
|
|
|
get
|
2024-02-18 01:13:57 +00:00
|
|
|
{
|
2024-02-20 10:57:28 +00:00
|
|
|
IEnumerable<Mod> selectedMods = Mods.Value;
|
2024-02-18 01:13:57 +00:00
|
|
|
|
2024-02-20 10:57:28 +00:00
|
|
|
if (multiplayerRoomItem?.Value != null)
|
|
|
|
{
|
|
|
|
Ruleset ruleset = GameRuleset.Value.CreateInstance();
|
|
|
|
var multiplayerRoomMods = multiplayerRoomItem.Value.RequiredMods.Select(m => m.ToMod(ruleset));
|
|
|
|
selectedMods = selectedMods.Concat(multiplayerRoomMods);
|
|
|
|
}
|
2024-02-18 01:28:24 +00:00
|
|
|
|
2024-02-20 10:57:28 +00:00
|
|
|
return selectedMods;
|
2024-02-18 01:13:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|