Merge branch 'timeshift-api-integration'

This commit is contained in:
smoogipoo 2018-12-13 18:38:22 +09:00
commit 91f6b08479
8 changed files with 86 additions and 46 deletions

View File

@ -11,7 +11,7 @@ namespace osu.Game.Beatmaps.Drawables
{
public class UpdateableBeatmapBackgroundSprite : ModelBackedDrawable<BeatmapInfo>
{
public readonly IBindable<BeatmapInfo> Beatmap = new Bindable<BeatmapInfo>();
public readonly Bindable<BeatmapInfo> Beatmap = new Bindable<BeatmapInfo>();
[Resolved]
private BeatmapManager beatmaps { get; set; }

View File

@ -18,9 +18,6 @@ namespace osu.Game.Online.Multiplayer
[JsonProperty("id")]
public Bindable<int?> RoomID { get; } = new Bindable<int?>();
[JsonIgnore]
public readonly Bindable<BeatmapInfo> Beatmap = new Bindable<BeatmapInfo>();
[JsonProperty("name")]
public readonly Bindable<string> Name = new Bindable<string>("My awesome room!");
@ -52,15 +49,6 @@ namespace osu.Game.Online.Multiplayer
public Bindable<int?> MaxParticipants = new Bindable<int?>();
public Bindable<IEnumerable<User>> Participants = new Bindable<IEnumerable<User>>(Enumerable.Empty<User>());
public Room()
{
Beatmap.BindValueChanged(b =>
{
Playlist.Clear();
Playlist.Add(new PlaylistItem { Beatmap = b });
});
}
public void CopyFrom(Room other)
{
RoomID.Value = other.RoomID;

View File

@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using osu.Framework;
using osu.Framework.Allocation;
using osu.Framework.Configuration;
@ -39,14 +40,18 @@ namespace osu.Game.Screens.Multi.Lounge.Components
private readonly Box selectionBox;
private readonly Bindable<string> nameBind = new Bindable<string>();
private readonly Bindable<BeatmapInfo> beatmapBind = new Bindable<BeatmapInfo>();
private readonly Bindable<User> hostBind = new Bindable<User>();
private readonly Bindable<RoomStatus> statusBind = new Bindable<RoomStatus>();
private readonly Bindable<GameType> typeBind = new Bindable<GameType>();
private readonly Bindable<IEnumerable<User>> participantsBind = new Bindable<IEnumerable<User>>();
private readonly IBindableCollection<PlaylistItem> playlistBind = new BindableCollection<PlaylistItem>();
private readonly Bindable<WorkingBeatmap> beatmap = new Bindable<WorkingBeatmap>();
private UpdateableBeatmapBackgroundSprite background;
private BeatmapTitle beatmapTitle;
private ModeTypeInfo modeTypeInfo;
[Resolved]
private BeatmapManager beatmaps { get; set; }
@ -104,11 +109,9 @@ namespace osu.Game.Screens.Multi.Lounge.Components
private void load(OsuColour colours)
{
Box sideStrip;
UpdateableBeatmapBackgroundSprite background;
OsuSpriteText status;
ParticipantInfo participantInfo;
BeatmapTitle beatmapTitle;
ModeTypeInfo modeTypeInfo;
OsuSpriteText name;
Children = new Drawable[]
@ -213,24 +216,24 @@ namespace osu.Game.Screens.Multi.Lounge.Components
d.FadeColour(s.GetAppropriateColour(colours), transition_duration);
};
beatmapBind.BindValueChanged(b => beatmap.Value = beatmaps.GetWorkingBeatmap(b));
nameBind.BindValueChanged(n => name.Text = n);
nameBind.BindTo(Room.Name);
hostBind.BindTo(Room.Host);
statusBind.BindTo(Room.Status);
typeBind.BindTo(Room.Type);
beatmapBind.BindTo(Room.Beatmap);
playlistBind.BindTo(Room.Playlist);
participantsBind.BindTo(Room.Participants);
background.Beatmap.BindTo(beatmapBind);
modeTypeInfo.Beatmap.BindTo(beatmapBind);
modeTypeInfo.Type.BindTo(typeBind);
participantInfo.Host.BindTo(hostBind);
participantInfo.Participants.BindTo(participantsBind);
beatmapTitle.Beatmap.BindTo(beatmapBind);
playlistBind.ItemsAdded += _ => updatePlaylist();
playlistBind.ItemsRemoved += _ => updatePlaylist();
updatePlaylist();
}
protected override void LoadComplete()
@ -238,5 +241,16 @@ namespace osu.Game.Screens.Multi.Lounge.Components
base.LoadComplete();
this.FadeInFromZero(transition_duration);
}
private void updatePlaylist()
{
// For now, only the first playlist item is supported
var item = playlistBind.First();
beatmap.Value = beatmaps.GetWorkingBeatmap(item.Beatmap);
background.Beatmap.Value = item.Beatmap;
modeTypeInfo.Beatmap.Value = item.Beatmap;
beatmapTitle.Beatmap.Value = item.Beatmap;
}
}
}

View File

@ -32,12 +32,12 @@ namespace osu.Game.Screens.Multi.Lounge.Components
private readonly MarginPadding contentPadding = new MarginPadding { Horizontal = 20, Vertical = 10 };
private readonly Bindable<string> nameBind = new Bindable<string>();
private readonly Bindable<BeatmapInfo> beatmapBind = new Bindable<BeatmapInfo>();
private readonly Bindable<User> hostBind = new Bindable<User>();
private readonly Bindable<RoomStatus> statusBind = new Bindable<RoomStatus>();
private readonly Bindable<GameType> typeBind = new Bindable<GameType>();
private readonly Bindable<int?> maxParticipantsBind = new Bindable<int?>();
private readonly Bindable<IEnumerable<User>> participantsBind = new Bindable<IEnumerable<User>>();
private readonly IBindableCollection<PlaylistItem> playlistBind = new BindableCollection<PlaylistItem>();
private readonly Bindable<WorkingBeatmap> beatmap = new Bindable<WorkingBeatmap>();
@ -174,14 +174,14 @@ namespace osu.Game.Screens.Multi.Lounge.Components
},
};
playlistBind.ItemsAdded += _ => updatePlaylist();
playlistBind.ItemsRemoved += _ => updatePlaylist();
statusBind.BindValueChanged(displayStatus);
beatmapBind.BindValueChanged(b => beatmap.Value = beatmaps.GetWorkingBeatmap(b));
participantsBind.BindValueChanged(p => participantsFlow.ChildrenEnumerable = p.Select(u => new UserTile(u)));
nameBind.BindValueChanged(n => name.Text = n);
background.Beatmap.BindTo(beatmapBind);
participantInfo.Host.BindTo(hostBind);
participantInfo.Participants.BindTo(participantsBind);
@ -189,7 +189,6 @@ namespace osu.Game.Screens.Multi.Lounge.Components
participantCount.MaxParticipants.BindTo(maxParticipantsBind);
beatmapTypeInfo.Type.BindTo(typeBind);
beatmapTypeInfo.Beatmap.BindTo(beatmapBind);
Room.BindValueChanged(updateRoom, true);
}
@ -204,7 +203,7 @@ namespace osu.Game.Screens.Multi.Lounge.Components
hostBind.UnbindFrom(lastRoom.Host);
statusBind.UnbindFrom(lastRoom.Status);
typeBind.UnbindFrom(lastRoom.Type);
beatmapBind.UnbindFrom(lastRoom.Beatmap);
playlistBind.UnbindFrom(lastRoom.Playlist);
maxParticipantsBind.UnbindFrom(lastRoom.MaxParticipants);
participantsBind.UnbindFrom(lastRoom.Participants);
}
@ -215,7 +214,7 @@ namespace osu.Game.Screens.Multi.Lounge.Components
hostBind.BindTo(newRoom.Host);
statusBind.BindTo(newRoom.Status);
typeBind.BindTo(newRoom.Type);
beatmapBind.BindTo(newRoom.Beatmap);
playlistBind.BindTo(newRoom.Playlist);
maxParticipantsBind.BindTo(newRoom.MaxParticipants);
participantsBind.BindTo(newRoom.Participants);
@ -239,6 +238,16 @@ namespace osu.Game.Screens.Multi.Lounge.Components
lastRoom = newRoom;
}
private void updatePlaylist()
{
// For now, only the first playlist item is supported
var item = playlistBind.First();
beatmap.Value = beatmaps.GetWorkingBeatmap(item.Beatmap);
background.Beatmap.Value = item.Beatmap;
beatmapTypeInfo.Beatmap.Value = item.Beatmap;
}
protected override void UpdateAfterChildren()
{
base.UpdateAfterChildren();

View File

@ -23,7 +23,7 @@ namespace osu.Game.Screens.Multi.Match.Components
{
public const float HEIGHT = 200;
public readonly IBindable<BeatmapInfo> Beatmap = new Bindable<BeatmapInfo>();
public readonly Bindable<BeatmapInfo> Beatmap = new Bindable<BeatmapInfo>();
private readonly Box tabStrip;

View File

@ -6,7 +6,6 @@ using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
@ -23,10 +22,10 @@ namespace osu.Game.Screens.Multi.Match.Components
private const float field_padding = 45;
private readonly Bindable<string> nameBind = new Bindable<string>();
private readonly Bindable<BeatmapInfo> beatmapBind = new Bindable<BeatmapInfo>();
private readonly Bindable<RoomAvailability> availabilityBind = new Bindable<RoomAvailability>();
private readonly Bindable<GameType> typeBind = new Bindable<GameType>();
private readonly Bindable<int?> maxParticipantsBind = new Bindable<int?>();
private readonly IBindableCollection<PlaylistItem> playlistBind = new BindableCollection<PlaylistItem>();
private readonly Container content;
@ -160,7 +159,7 @@ namespace osu.Game.Screens.Multi.Match.Components
typeLabel.Colour = colours.Yellow;
nameBind.BindTo(room.Name);
beatmapBind.BindTo(room.Beatmap);
playlistBind.BindTo(room.Playlist);
availabilityBind.BindTo(room.Availability);
typeBind.BindTo(room.Type);
maxParticipantsBind.BindTo(room.MaxParticipants);
@ -179,7 +178,7 @@ namespace osu.Game.Screens.Multi.Match.Components
ApplyButton.Enabled.Value = hasValidSettings;
}
private bool hasValidSettings => NameField.Text.Length > 0 && beatmapBind.Value != null;
private bool hasValidSettings => NameField.Text.Length > 0 && playlistBind.Count > 0;
protected override void PopIn()
{

View File

@ -24,12 +24,12 @@ namespace osu.Game.Screens.Multi.Match
private readonly Participants participants;
private readonly Bindable<string> nameBind = new Bindable<string>();
private readonly Bindable<BeatmapInfo> beatmapBind = new Bindable<BeatmapInfo>();
private readonly Bindable<RoomStatus> statusBind = new Bindable<RoomStatus>();
private readonly Bindable<RoomAvailability> availabilityBind = new Bindable<RoomAvailability>();
private readonly Bindable<GameType> typeBind = new Bindable<GameType>();
private readonly Bindable<int?> maxParticipantsBind = new Bindable<int?>();
private readonly Bindable<IEnumerable<User>> participantsBind = new Bindable<IEnumerable<User>>();
private readonly BindableCollection<PlaylistItem> playlistBind = new BindableCollection<PlaylistItem>();
protected override Drawable TransitionContent => participants;
@ -37,6 +37,9 @@ namespace osu.Game.Screens.Multi.Match
public override string ShortTitle => "room";
private readonly Components.Header header;
private readonly Info info;
[Cached]
private readonly Bindable<IEnumerable<Mod>> mods = new Bindable<IEnumerable<Mod>>(Enumerable.Empty<Mod>());
@ -57,16 +60,13 @@ namespace osu.Game.Screens.Multi.Match
this.room = room;
nameBind.BindTo(room.Name);
beatmapBind.BindTo(room.Beatmap);
statusBind.BindTo(room.Status);
availabilityBind.BindTo(room.Availability);
typeBind.BindTo(room.Type);
participantsBind.BindTo(room.Participants);
maxParticipantsBind.BindTo(room.MaxParticipants);
Components.Header header;
RoomSettingsOverlay settings;
Info info;
Children = new Drawable[]
{
@ -97,7 +97,6 @@ namespace osu.Game.Screens.Multi.Match
};
header.OnRequestSelectBeatmap = () => Push(new MatchSongSelect());
header.Beatmap.BindTo(beatmapBind);
header.Tabs.Current.ValueChanged += t =>
{
@ -107,7 +106,6 @@ namespace osu.Game.Screens.Multi.Match
settings.Hide();
};
info.Beatmap.BindTo(beatmapBind);
info.Name.BindTo(nameBind);
info.Status.BindTo(statusBind);
info.Availability.BindTo(availabilityBind);
@ -116,14 +114,49 @@ namespace osu.Game.Screens.Multi.Match
participants.Users.BindTo(participantsBind);
participants.MaxParticipants.BindTo(maxParticipantsBind);
playlistBind.ItemsAdded += _ => updatePlaylist();
playlistBind.ItemsRemoved += _ => updatePlaylist();
}
[BackgroundDependencyLoader]
private void load()
{
beatmapBind.BindTo(room.Beatmap);
beatmapBind.BindValueChanged(b => Beatmap.Value = beatmapManager.GetWorkingBeatmap(room.Beatmap.Value), true);
Beatmap.BindValueChanged(b => beatmapBind.Value = b.BeatmapInfo);
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);
}
private void updatePlaylist()
{
if (playlistBind.Count == 0)
return;
// For now, only the first playlist item is supported
var item = playlistBind.First();
header.Beatmap.Value = item.Beatmap;
info.Beatmap.Value = item.Beatmap;
if (Beatmap.Value?.BeatmapInfo != item.Beatmap)
{
Beatmap.Value = beatmapManager.GetWorkingBeatmap(item.Beatmap);
Beatmap.Value.Mods.Value = item.RequiredMods.ToArray();
}
}
private void onStart()

View File

@ -69,9 +69,6 @@ namespace osu.Game.Screens.Multi
pi.SetRulesets(rulesets);
}
// Temporarily
r.Beatmap.Value = r.Playlist.FirstOrDefault()?.Beatmap;
var existing = rooms.FirstOrDefault(e => e.RoomID.Value == r.RoomID.Value);
if (existing == null)
rooms.Add(r);