mirror of
https://github.com/ppy/osu
synced 2025-03-21 10:28:06 +00:00
Add null room support to RoomInspector.
This commit is contained in:
parent
4b2b2086df
commit
ad878003f7
@ -21,7 +21,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
var room = new Room
|
Room room = new Room
|
||||||
{
|
{
|
||||||
Name = { Value = @"My Awesome Room" },
|
Name = { Value = @"My Awesome Room" },
|
||||||
Host = { Value = new User { Username = @"flyte", Id = 3103765, Country = new Country { FlagName = @"JP" } } },
|
Host = { Value = new User { Username = @"flyte", Id = 3103765, Country = new Country { FlagName = @"JP" } } },
|
||||||
@ -71,9 +71,11 @@ namespace osu.Game.Tests.Visual
|
|||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
Room = room,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
AddStep(@"set room", () => inspector.Room = room);
|
||||||
|
AddStep(@"null room", () => inspector.Room = null);
|
||||||
|
AddStep(@"set room", () => inspector.Room = room);
|
||||||
AddStep(@"change title", () => room.Name.Value = @"A Better Room Than The Above");
|
AddStep(@"change title", () => room.Name.Value = @"A Better Room Than The Above");
|
||||||
AddStep(@"change host", () => room.Host.Value = new User { Username = @"DrabWeb", Id = 6946022, Country = new Country { FlagName = @"CA" } });
|
AddStep(@"change host", () => room.Host.Value = new User { Username = @"DrabWeb", Id = 6946022, Country = new Country { FlagName = @"CA" } });
|
||||||
AddStep(@"change status", () => room.Status.Value = new RoomStatusPlaying());
|
AddStep(@"change status", () => room.Status.Value = new RoomStatusPlaying());
|
||||||
@ -88,7 +90,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
|
|
||||||
AddStep(@"change room", () =>
|
AddStep(@"change room", () =>
|
||||||
{
|
{
|
||||||
var newRoom = new Room
|
Room newRoom = new Room
|
||||||
{
|
{
|
||||||
Name = { Value = @"My New, Better Than Ever Room" },
|
Name = { Value = @"My New, Better Than Ever Room" },
|
||||||
Host = { Value = new User { Username = @"Angelsim", Id = 1777162, Country = new Country { FlagName = @"KR" } } },
|
Host = { Value = new User { Username = @"Angelsim", Id = 1777162, Country = new Country { FlagName = @"KR" } } },
|
||||||
|
@ -5,6 +5,7 @@ using System.Linq;
|
|||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Configuration;
|
using osu.Framework.Configuration;
|
||||||
using osu.Framework.Extensions.Color4Extensions;
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Colour;
|
using osu.Framework.Graphics.Colour;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
@ -25,9 +26,9 @@ namespace osu.Game.Screens.Multi.Components
|
|||||||
{
|
{
|
||||||
public class RoomInspector : Container
|
public class RoomInspector : Container
|
||||||
{
|
{
|
||||||
private readonly MarginPadding contentPadding = new MarginPadding { Horizontal = 20, Vertical = 10 };
|
|
||||||
private const float transition_duration = 100;
|
private const float transition_duration = 100;
|
||||||
|
|
||||||
|
private readonly MarginPadding contentPadding = new MarginPadding { Horizontal = 20, Vertical = 10 };
|
||||||
private readonly Bindable<string> nameBind = new Bindable<string>();
|
private readonly Bindable<string> nameBind = new Bindable<string>();
|
||||||
private readonly Bindable<User> hostBind = new Bindable<User>();
|
private readonly Bindable<User> hostBind = new Bindable<User>();
|
||||||
private readonly Bindable<RoomStatus> statusBind = new Bindable<RoomStatus>();
|
private readonly Bindable<RoomStatus> statusBind = new Bindable<RoomStatus>();
|
||||||
@ -36,8 +37,13 @@ namespace osu.Game.Screens.Multi.Components
|
|||||||
private readonly Bindable<int?> maxParticipantsBind = new Bindable<int?>();
|
private readonly Bindable<int?> maxParticipantsBind = new Bindable<int?>();
|
||||||
private readonly Bindable<User[]> participantsBind = new Bindable<User[]>();
|
private readonly Bindable<User[]> participantsBind = new Bindable<User[]>();
|
||||||
|
|
||||||
private FillFlowContainer topFlow;
|
private OsuColour colours;
|
||||||
|
private Box statusStrip;
|
||||||
|
private Container coverContainer;
|
||||||
|
private FillFlowContainer topFlow, participantsFlow, participantNumbersFlow, infoPanelFlow;
|
||||||
|
private OsuSpriteText name, status;
|
||||||
private ScrollContainer participantsScroll;
|
private ScrollContainer participantsScroll;
|
||||||
|
private ParticipantInfo participantInfo;
|
||||||
|
|
||||||
private Room room;
|
private Room room;
|
||||||
public Room Room
|
public Room Room
|
||||||
@ -48,13 +54,26 @@ namespace osu.Game.Screens.Multi.Components
|
|||||||
if (value == room) return;
|
if (value == room) return;
|
||||||
room = value;
|
room = value;
|
||||||
|
|
||||||
nameBind.BindTo(Room.Name);
|
nameBind.UnbindBindings();
|
||||||
hostBind.BindTo(Room.Host);
|
hostBind.UnbindBindings();
|
||||||
statusBind.BindTo(Room.Status);
|
statusBind.UnbindBindings();
|
||||||
typeBind.BindTo(Room.Type);
|
typeBind.UnbindBindings();
|
||||||
beatmapBind.BindTo(Room.Beatmap);
|
beatmapBind.UnbindBindings();
|
||||||
maxParticipantsBind.BindTo(Room.MaxParticipants);
|
maxParticipantsBind.UnbindBindings();
|
||||||
participantsBind.BindTo(Room.Participants);
|
participantsBind.UnbindBindings();
|
||||||
|
|
||||||
|
if (Room != null)
|
||||||
|
{
|
||||||
|
nameBind.BindTo(Room.Name);
|
||||||
|
hostBind.BindTo(Room.Host);
|
||||||
|
statusBind.BindTo(Room.Status);
|
||||||
|
typeBind.BindTo(Room.Type);
|
||||||
|
beatmapBind.BindTo(Room.Beatmap);
|
||||||
|
maxParticipantsBind.BindTo(Room.MaxParticipants);
|
||||||
|
participantsBind.BindTo(Room.Participants);
|
||||||
|
}
|
||||||
|
|
||||||
|
updateState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,12 +86,10 @@ namespace osu.Game.Screens.Multi.Components
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours, LocalisationEngine localisation)
|
private void load(OsuColour colours, LocalisationEngine localisation)
|
||||||
{
|
{
|
||||||
Box statusStrip;
|
this.colours = colours;
|
||||||
Container coverContainer;
|
|
||||||
FillFlowContainer participantsFlow;
|
|
||||||
ModeTypeInfo modeTypeInfo;
|
ModeTypeInfo modeTypeInfo;
|
||||||
OsuSpriteText participants, participantsSlash, maxParticipants, name, status, beatmapTitle, beatmapDash, beatmapArtist, beatmapAuthor;
|
OsuSpriteText participants, participantsSlash, maxParticipants, beatmapTitle, beatmapDash, beatmapArtist, beatmapAuthor;
|
||||||
ParticipantInfo participantInfo;
|
|
||||||
|
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
@ -122,7 +139,7 @@ namespace osu.Game.Screens.Multi.Components
|
|||||||
Padding = new MarginPadding(20),
|
Padding = new MarginPadding(20),
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new FillFlowContainer
|
participantNumbersFlow = new FillFlowContainer
|
||||||
{
|
{
|
||||||
Anchor = Anchor.TopRight,
|
Anchor = Anchor.TopRight,
|
||||||
Origin = Anchor.TopRight,
|
Origin = Anchor.TopRight,
|
||||||
@ -180,6 +197,7 @@ namespace osu.Game.Screens.Multi.Components
|
|||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
AutoSizeAxes = Axes.Y,
|
AutoSizeAxes = Axes.Y,
|
||||||
Direction = FillDirection.Vertical,
|
Direction = FillDirection.Vertical,
|
||||||
|
LayoutDuration = transition_duration,
|
||||||
Padding = contentPadding,
|
Padding = contentPadding,
|
||||||
Spacing = new Vector2(0f, 5f),
|
Spacing = new Vector2(0f, 5f),
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
@ -189,7 +207,7 @@ namespace osu.Game.Screens.Multi.Components
|
|||||||
TextSize = 14,
|
TextSize = 14,
|
||||||
Font = @"Exo2.0-Bold",
|
Font = @"Exo2.0-Bold",
|
||||||
},
|
},
|
||||||
new FillFlowContainer
|
infoPanelFlow = new FillFlowContainer
|
||||||
{
|
{
|
||||||
AutoSizeAxes = Axes.X,
|
AutoSizeAxes = Axes.X,
|
||||||
Height = 30,
|
Height = 30,
|
||||||
@ -275,14 +293,7 @@ namespace osu.Game.Screens.Multi.Components
|
|||||||
nameBind.ValueChanged += n => name.Text = n;
|
nameBind.ValueChanged += n => name.Text = n;
|
||||||
hostBind.ValueChanged += h => participantInfo.Host = h;
|
hostBind.ValueChanged += h => participantInfo.Host = h;
|
||||||
typeBind.ValueChanged += t => modeTypeInfo.Type = t;
|
typeBind.ValueChanged += t => modeTypeInfo.Type = t;
|
||||||
|
statusBind.ValueChanged += displayStatus;
|
||||||
statusBind.ValueChanged += s =>
|
|
||||||
{
|
|
||||||
status.Text = s.Message;
|
|
||||||
|
|
||||||
foreach (Drawable d in new Drawable[] { statusStrip, status })
|
|
||||||
d.FadeColour(s.GetAppropriateColour(colours), transition_duration);
|
|
||||||
};
|
|
||||||
|
|
||||||
beatmapBind.ValueChanged += b =>
|
beatmapBind.ValueChanged += b =>
|
||||||
{
|
{
|
||||||
@ -293,14 +304,13 @@ namespace osu.Game.Screens.Multi.Components
|
|||||||
coverContainer.FadeIn(transition_duration);
|
coverContainer.FadeIn(transition_duration);
|
||||||
|
|
||||||
LoadComponentAsync(new BeatmapSetCover(b.BeatmapSet)
|
LoadComponentAsync(new BeatmapSetCover(b.BeatmapSet)
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
FillMode = FillMode.Fill,
|
FillMode = FillMode.Fill,
|
||||||
OnLoadComplete = d => d.FadeInFromZero(400, Easing.Out),
|
OnLoadComplete = d => d.FadeInFromZero(400, Easing.Out),
|
||||||
},
|
}, coverContainer.Add);
|
||||||
coverContainer.Add);
|
|
||||||
|
|
||||||
beatmapTitle.Current = localisation.GetUnicodePreference(b.Metadata.TitleUnicode, b.Metadata.Title);
|
beatmapTitle.Current = localisation.GetUnicodePreference(b.Metadata.TitleUnicode, b.Metadata.Title);
|
||||||
beatmapDash.Text = @" - ";
|
beatmapDash.Text = @" - ";
|
||||||
@ -341,14 +351,7 @@ namespace osu.Game.Screens.Multi.Components
|
|||||||
participantsFlow.ChildrenEnumerable = p.Select(u => new UserTile(u));
|
participantsFlow.ChildrenEnumerable = p.Select(u => new UserTile(u));
|
||||||
};
|
};
|
||||||
|
|
||||||
// trigger incase a room was set before we were loaded
|
updateState();
|
||||||
nameBind.TriggerChange();
|
|
||||||
hostBind.TriggerChange();
|
|
||||||
statusBind.TriggerChange();
|
|
||||||
typeBind.TriggerChange();
|
|
||||||
beatmapBind.TriggerChange();
|
|
||||||
maxParticipantsBind.TriggerChange();
|
|
||||||
participantsBind.TriggerChange();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void UpdateAfterChildren()
|
protected override void UpdateAfterChildren()
|
||||||
@ -358,6 +361,33 @@ namespace osu.Game.Screens.Multi.Components
|
|||||||
participantsScroll.Height = DrawHeight - topFlow.DrawHeight;
|
participantsScroll.Height = DrawHeight - topFlow.DrawHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void displayStatus(RoomStatus s)
|
||||||
|
{
|
||||||
|
status.Text = s.Message;
|
||||||
|
|
||||||
|
foreach (Drawable d in new Drawable[] { statusStrip, status })
|
||||||
|
d.FadeColour(s.GetAppropriateColour(colours), transition_duration);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateState()
|
||||||
|
{
|
||||||
|
if (Room == null)
|
||||||
|
{
|
||||||
|
foreach (Drawable d in new Drawable[] { coverContainer, participantsFlow, participantNumbersFlow, infoPanelFlow, name, participantInfo })
|
||||||
|
d.FadeOut(transition_duration);
|
||||||
|
|
||||||
|
displayStatus(new RoomStatusNoneSelected());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
foreach (Drawable d in new Drawable[] { participantsFlow, participantNumbersFlow, infoPanelFlow, name, participantInfo })
|
||||||
|
d.FadeIn(transition_duration);
|
||||||
|
|
||||||
|
statusBind.TriggerChange();
|
||||||
|
beatmapBind.TriggerChange();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private class UserTile : Container, IHasTooltip
|
private class UserTile : Container, IHasTooltip
|
||||||
{
|
{
|
||||||
private readonly User user;
|
private readonly User user;
|
||||||
@ -386,5 +416,11 @@ namespace osu.Game.Screens.Multi.Components
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class RoomStatusNoneSelected : RoomStatus
|
||||||
|
{
|
||||||
|
public override string Message => @"No Room Selected";
|
||||||
|
public override Color4 GetAppropriateColour(OsuColour colours) => colours.Gray8;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user