mirror of
https://github.com/ppy/osu.git
synced 2025-02-21 07:33:15 +08:00
Fix mod/beatmap selection not always working
This commit is contained in:
parent
2e767a5292
commit
56fd4b95cd
@ -10,7 +10,6 @@ using osu.Framework.Graphics.Containers;
|
|||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Online.API;
|
using osu.Game.Online.API;
|
||||||
using osu.Game.Online.Multiplayer;
|
using osu.Game.Online.Multiplayer;
|
||||||
using osu.Game.Rulesets.Mods;
|
|
||||||
using osu.Game.Screens.Multi.Match.Components;
|
using osu.Game.Screens.Multi.Match.Components;
|
||||||
using osu.Game.Screens.Multi.Play;
|
using osu.Game.Screens.Multi.Play;
|
||||||
using osu.Game.Screens.Play;
|
using osu.Game.Screens.Play;
|
||||||
@ -40,9 +39,6 @@ namespace osu.Game.Screens.Multi.Match
|
|||||||
private readonly Components.Header header;
|
private readonly Components.Header header;
|
||||||
private readonly Info info;
|
private readonly Info info;
|
||||||
|
|
||||||
[Cached]
|
|
||||||
private readonly Bindable<IEnumerable<Mod>> mods = new Bindable<IEnumerable<Mod>>(Enumerable.Empty<Mod>());
|
|
||||||
|
|
||||||
[Cached]
|
[Cached]
|
||||||
private readonly Room room;
|
private readonly Room room;
|
||||||
|
|
||||||
@ -96,7 +92,7 @@ namespace osu.Game.Screens.Multi.Match
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
header.OnRequestSelectBeatmap = () => Push(new MatchSongSelect());
|
header.OnRequestSelectBeatmap = () => Push(new MatchSongSelect { Selected = addPlaylistItem });
|
||||||
|
|
||||||
header.Tabs.Current.ValueChanged += t =>
|
header.Tabs.Current.ValueChanged += t =>
|
||||||
{
|
{
|
||||||
@ -110,38 +106,27 @@ namespace osu.Game.Screens.Multi.Match
|
|||||||
info.Status.BindTo(statusBind);
|
info.Status.BindTo(statusBind);
|
||||||
info.Availability.BindTo(availabilityBind);
|
info.Availability.BindTo(availabilityBind);
|
||||||
info.Type.BindTo(typeBind);
|
info.Type.BindTo(typeBind);
|
||||||
info.Mods.BindTo(mods);
|
|
||||||
|
|
||||||
participants.Users.BindTo(participantsBind);
|
participants.Users.BindTo(participantsBind);
|
||||||
participants.MaxParticipants.BindTo(maxParticipantsBind);
|
participants.MaxParticipants.BindTo(maxParticipantsBind);
|
||||||
|
|
||||||
playlistBind.ItemsAdded += _ => updatePlaylist();
|
playlistBind.ItemsAdded += _ => setFromPlaylist();
|
||||||
playlistBind.ItemsRemoved += _ => updatePlaylist();
|
playlistBind.ItemsRemoved += _ => setFromPlaylist();
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
Beatmap.BindValueChanged(b =>
|
|
||||||
{
|
|
||||||
playlistBind.Clear();
|
|
||||||
|
|
||||||
var newItem = new PlaylistItem
|
|
||||||
{
|
|
||||||
Beatmap = b.BeatmapInfo,
|
|
||||||
Ruleset = Ruleset.Value
|
|
||||||
};
|
|
||||||
|
|
||||||
newItem.RequiredMods.Clear();
|
|
||||||
newItem.RequiredMods.AddRange(b.Mods.Value);
|
|
||||||
|
|
||||||
playlistBind.Add(newItem);
|
|
||||||
});
|
|
||||||
|
|
||||||
playlistBind.BindTo(room.Playlist);
|
playlistBind.BindTo(room.Playlist);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updatePlaylist()
|
private void addPlaylistItem(PlaylistItem item)
|
||||||
|
{
|
||||||
|
playlistBind.Clear();
|
||||||
|
playlistBind.Add(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setFromPlaylist()
|
||||||
{
|
{
|
||||||
if (playlistBind.Count == 0)
|
if (playlistBind.Count == 0)
|
||||||
return;
|
return;
|
||||||
@ -151,12 +136,9 @@ namespace osu.Game.Screens.Multi.Match
|
|||||||
|
|
||||||
header.Beatmap.Value = item.Beatmap;
|
header.Beatmap.Value = item.Beatmap;
|
||||||
info.Beatmap.Value = item.Beatmap;
|
info.Beatmap.Value = item.Beatmap;
|
||||||
|
info.Mods.Value = item.RequiredMods;
|
||||||
|
|
||||||
if (Beatmap.Value?.BeatmapInfo != item.Beatmap)
|
|
||||||
{
|
|
||||||
Beatmap.Value = beatmapManager.GetWorkingBeatmap(item.Beatmap);
|
Beatmap.Value = beatmapManager.GetWorkingBeatmap(item.Beatmap);
|
||||||
Beatmap.Value.Mods.Value = item.RequiredMods.ToArray();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onStart()
|
private void onStart()
|
||||||
|
@ -1,17 +1,33 @@
|
|||||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using osu.Game.Online.Multiplayer;
|
||||||
using osu.Game.Screens.Multi;
|
using osu.Game.Screens.Multi;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Select
|
namespace osu.Game.Screens.Select
|
||||||
{
|
{
|
||||||
public class MatchSongSelect : SongSelect, IMultiplayerScreen
|
public class MatchSongSelect : SongSelect, IMultiplayerScreen
|
||||||
{
|
{
|
||||||
|
public Action<PlaylistItem> Selected;
|
||||||
|
|
||||||
public string ShortTitle => "song selection";
|
public string ShortTitle => "song selection";
|
||||||
|
|
||||||
protected override bool OnStart()
|
protected override bool OnStart()
|
||||||
{
|
{
|
||||||
if (IsCurrentScreen) Exit();
|
var item = new PlaylistItem
|
||||||
|
{
|
||||||
|
Beatmap = Beatmap.Value.BeatmapInfo,
|
||||||
|
Ruleset = Ruleset.Value,
|
||||||
|
};
|
||||||
|
|
||||||
|
item.RequiredMods.AddRange(SelectedMods.Value);
|
||||||
|
|
||||||
|
Selected?.Invoke(item);
|
||||||
|
|
||||||
|
if (IsCurrentScreen)
|
||||||
|
Exit();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user