mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 08:49:59 +09:00
Fix free mod selection not showing allowed mods
This commit is contained in:
@ -14,11 +14,14 @@ using osu.Game.Online.API;
|
|||||||
using osu.Game.Online.API.Requests.Responses;
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
using osu.Game.Online.Multiplayer;
|
using osu.Game.Online.Multiplayer;
|
||||||
using osu.Game.Online.Rooms;
|
using osu.Game.Online.Rooms;
|
||||||
|
using osu.Game.Overlays.Mods;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Rulesets.Osu;
|
using osu.Game.Rulesets.Osu;
|
||||||
|
using osu.Game.Rulesets.Osu.Mods;
|
||||||
using osu.Game.Rulesets.Taiko;
|
using osu.Game.Rulesets.Taiko;
|
||||||
using osu.Game.Rulesets.Taiko.Mods;
|
using osu.Game.Rulesets.Taiko.Mods;
|
||||||
using osu.Game.Rulesets.UI;
|
using osu.Game.Rulesets.UI;
|
||||||
|
using osu.Game.Screens.OnlinePlay.Match;
|
||||||
using osu.Game.Screens.OnlinePlay.Multiplayer;
|
using osu.Game.Screens.OnlinePlay.Multiplayer;
|
||||||
using osu.Game.Screens.OnlinePlay.Multiplayer.Match;
|
using osu.Game.Screens.OnlinePlay.Multiplayer.Match;
|
||||||
using osu.Game.Screens.OnlinePlay.Multiplayer.Participants;
|
using osu.Game.Screens.OnlinePlay.Multiplayer.Participants;
|
||||||
@ -150,5 +153,27 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
|
|
||||||
AddUntilStep("match started", () => Client.Room?.State == MultiplayerRoomState.WaitingForLoad);
|
AddUntilStep("match started", () => Client.Room?.State == MultiplayerRoomState.WaitingForLoad);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestFreeModSelectionHasAllowedMods()
|
||||||
|
{
|
||||||
|
AddStep("add playlist item with allowed mod", () =>
|
||||||
|
{
|
||||||
|
SelectedRoom.Value.Playlist.Add(new PlaylistItem
|
||||||
|
{
|
||||||
|
Beatmap = { Value = new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo },
|
||||||
|
RulesetID = new OsuRuleset().RulesetInfo.OnlineID,
|
||||||
|
AllowedMods = new[] { new APIMod(new OsuModDoubleTime()) }
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
ClickButtonWhenEnabled<MultiplayerMatchSettingsOverlay.CreateOrUpdateButton>();
|
||||||
|
|
||||||
|
AddUntilStep("wait for join", () => RoomJoined);
|
||||||
|
|
||||||
|
ClickButtonWhenEnabled<RoomSubScreen.UserModSelectButton>();
|
||||||
|
|
||||||
|
AddAssert("mod select contains only double time mod", () => this.ChildrenOfType<UserModSelectOverlay>().Single().ChildrenOfType<ModButton>().Single().Mod is OsuModDoubleTime);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
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;
|
||||||
@ -350,10 +351,12 @@ namespace osu.Game.Screens.OnlinePlay.Match
|
|||||||
if (selected == null)
|
if (selected == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
var rulesetInstance = rulesets.GetRuleset(SelectedItem.Value.RulesetID)?.CreateInstance();
|
||||||
|
Debug.Assert(rulesetInstance != null);
|
||||||
|
var allowedMods = SelectedItem.Value.AllowedMods.Select(m => m.ToMod(rulesetInstance));
|
||||||
|
|
||||||
// Remove any user mods that are no longer allowed.
|
// Remove any user mods that are no longer allowed.
|
||||||
UserMods.Value = UserMods.Value
|
UserMods.Value = UserMods.Value.Where(m => allowedMods.Any(a => m.GetType() == a.GetType())).ToList();
|
||||||
.Where(m => selected.AllowedMods.Any(a => m.GetType() == a.GetType()))
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
UpdateMods();
|
UpdateMods();
|
||||||
updateRuleset();
|
updateRuleset();
|
||||||
@ -367,7 +370,7 @@ namespace osu.Game.Screens.OnlinePlay.Match
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
UserModsSection?.Show();
|
UserModsSection?.Show();
|
||||||
userModsSelectOverlay.IsValidMod = m => selected.AllowedMods.Any(a => a.GetType() == m.GetType());
|
userModsSelectOverlay.IsValidMod = m => allowedMods.Any(a => a.GetType() == m.GetType());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user