mirror of
https://github.com/ppy/osu.git
synced 2025-01-07 21:32:57 +08:00
Merge pull request #2588 from DrabWeb/room-inspector-improvements
RoomInspector improvements
This commit is contained in:
commit
29261e5a6c
@ -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,13 @@ namespace osu.Game.Tests.Visual
|
|||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
Room = room,
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Width = 0.5f,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
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 +92,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" } } },
|
||||||
|
@ -25,17 +25,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 Box statusStrip;
|
private readonly MarginPadding contentPadding = new MarginPadding { Horizontal = 20, Vertical = 10 };
|
||||||
private readonly Container coverContainer;
|
|
||||||
private readonly FillFlowContainer topFlow, participantsFlow;
|
|
||||||
private readonly ModeTypeInfo modeTypeInfo;
|
|
||||||
private readonly OsuSpriteText participants, participantsSlash, maxParticipants, name, status, beatmapTitle, beatmapDash, beatmapArtist, beatmapAuthor;
|
|
||||||
private readonly ParticipantInfo participantInfo;
|
|
||||||
private readonly ScrollContainer participantsScroll;
|
|
||||||
|
|
||||||
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>();
|
||||||
@ -45,10 +37,14 @@ namespace osu.Game.Screens.Multi.Components
|
|||||||
private readonly Bindable<User[]> participantsBind = new Bindable<User[]>();
|
private readonly Bindable<User[]> participantsBind = new Bindable<User[]>();
|
||||||
|
|
||||||
private OsuColour colours;
|
private OsuColour colours;
|
||||||
private LocalisationEngine localisation;
|
private Box statusStrip;
|
||||||
|
private Container coverContainer;
|
||||||
|
private FillFlowContainer topFlow, participantsFlow, participantNumbersFlow, infoPanelFlow;
|
||||||
|
private OsuSpriteText name, status;
|
||||||
|
private ScrollContainer participantsScroll;
|
||||||
|
private ParticipantInfo participantInfo;
|
||||||
|
|
||||||
private Room room;
|
private Room room;
|
||||||
|
|
||||||
public Room Room
|
public Room Room
|
||||||
{
|
{
|
||||||
get { return room; }
|
get { return room; }
|
||||||
@ -57,20 +53,36 @@ 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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public RoomInspector()
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OsuColour colours, LocalisationEngine localisation)
|
||||||
{
|
{
|
||||||
Width = 520;
|
this.colours = colours;
|
||||||
RelativeSizeAxes = Axes.Y;
|
|
||||||
|
ModeTypeInfo modeTypeInfo;
|
||||||
|
OsuSpriteText participants, participantsSlash, maxParticipants, beatmapTitle, beatmapDash, beatmapArtist, beatmapAuthor;
|
||||||
|
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
@ -120,7 +132,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,
|
||||||
@ -178,6 +190,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[]
|
||||||
@ -187,7 +200,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,
|
||||||
@ -229,6 +242,7 @@ namespace osu.Game.Screens.Multi.Components
|
|||||||
Anchor = Anchor.BottomLeft,
|
Anchor = Anchor.BottomLeft,
|
||||||
Origin = Anchor.BottomLeft,
|
Origin = Anchor.BottomLeft,
|
||||||
TextSize = 14,
|
TextSize = 14,
|
||||||
|
Colour = colours.Gray9,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -269,27 +283,68 @@ namespace osu.Game.Screens.Multi.Components
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
nameBind.ValueChanged += displayName;
|
nameBind.ValueChanged += n => name.Text = n;
|
||||||
hostBind.ValueChanged += displayUser;
|
hostBind.ValueChanged += h => participantInfo.Host = h;
|
||||||
typeBind.ValueChanged += displayGameType;
|
typeBind.ValueChanged += t => modeTypeInfo.Type = t;
|
||||||
maxParticipantsBind.ValueChanged += displayMaxParticipants;
|
|
||||||
participantsBind.ValueChanged += displayParticipants;
|
|
||||||
}
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
|
||||||
private void load(OsuColour colours, LocalisationEngine localisation)
|
|
||||||
{
|
|
||||||
this.localisation = localisation;
|
|
||||||
this.colours = colours;
|
|
||||||
|
|
||||||
beatmapAuthor.Colour = colours.Gray9;
|
|
||||||
|
|
||||||
//binded here instead of ctor because dependencies are needed
|
|
||||||
statusBind.ValueChanged += displayStatus;
|
statusBind.ValueChanged += displayStatus;
|
||||||
beatmapBind.ValueChanged += displayBeatmap;
|
|
||||||
|
|
||||||
statusBind.TriggerChange();
|
beatmapBind.ValueChanged += b =>
|
||||||
beatmapBind.TriggerChange();
|
{
|
||||||
|
modeTypeInfo.Beatmap = b;
|
||||||
|
|
||||||
|
if (b != null)
|
||||||
|
{
|
||||||
|
coverContainer.FadeIn(transition_duration);
|
||||||
|
|
||||||
|
LoadComponentAsync(new BeatmapSetCover(b.BeatmapSet)
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
FillMode = FillMode.Fill,
|
||||||
|
OnLoadComplete = d => d.FadeInFromZero(400, Easing.Out),
|
||||||
|
}, coverContainer.Add);
|
||||||
|
|
||||||
|
beatmapTitle.Current = localisation.GetUnicodePreference(b.Metadata.TitleUnicode, b.Metadata.Title);
|
||||||
|
beatmapDash.Text = @" - ";
|
||||||
|
beatmapArtist.Current = localisation.GetUnicodePreference(b.Metadata.ArtistUnicode, b.Metadata.Artist);
|
||||||
|
beatmapAuthor.Text = $"mapped by {b.Metadata.Author}";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
coverContainer.FadeOut(transition_duration);
|
||||||
|
|
||||||
|
beatmapTitle.Current = null;
|
||||||
|
beatmapArtist.Current = null;
|
||||||
|
|
||||||
|
beatmapTitle.Text = "Changing map";
|
||||||
|
beatmapDash.Text = beatmapArtist.Text = beatmapAuthor.Text = string.Empty;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
maxParticipantsBind.ValueChanged += m =>
|
||||||
|
{
|
||||||
|
if (m == null)
|
||||||
|
{
|
||||||
|
participantsSlash.FadeOut(transition_duration);
|
||||||
|
maxParticipants.FadeOut(transition_duration);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
participantsSlash.FadeIn(transition_duration);
|
||||||
|
maxParticipants.FadeIn(transition_duration);
|
||||||
|
maxParticipants.Text = m.ToString();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
participantsBind.ValueChanged += p =>
|
||||||
|
{
|
||||||
|
participants.Text = p.Length.ToString();
|
||||||
|
participantInfo.Participants = p;
|
||||||
|
participantsFlow.ChildrenEnumerable = p.Select(u => new UserTile(u));
|
||||||
|
};
|
||||||
|
|
||||||
|
updateState();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void UpdateAfterChildren()
|
protected override void UpdateAfterChildren()
|
||||||
@ -299,84 +354,39 @@ namespace osu.Game.Screens.Multi.Components
|
|||||||
participantsScroll.Height = DrawHeight - topFlow.DrawHeight;
|
participantsScroll.Height = DrawHeight - topFlow.DrawHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void displayName(string value)
|
private void displayStatus(RoomStatus s)
|
||||||
{
|
{
|
||||||
name.Text = value;
|
status.Text = s.Message;
|
||||||
|
|
||||||
|
Color4 c = s.GetAppropriateColour(colours);
|
||||||
|
statusStrip.FadeColour(c, transition_duration);
|
||||||
|
status.FadeColour(c, transition_duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void displayUser(User value)
|
private void updateState()
|
||||||
{
|
{
|
||||||
participantInfo.Host = value;
|
if (Room == null)
|
||||||
}
|
|
||||||
|
|
||||||
private void displayStatus(RoomStatus value)
|
|
||||||
{
|
|
||||||
status.Text = value.Message;
|
|
||||||
|
|
||||||
foreach (Drawable d in new Drawable[] { statusStrip, status })
|
|
||||||
d.FadeColour(value.GetAppropriateColour(colours), transition_duration);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void displayGameType(GameType value)
|
|
||||||
{
|
|
||||||
modeTypeInfo.Type = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void displayBeatmap(BeatmapInfo value)
|
|
||||||
{
|
|
||||||
modeTypeInfo.Beatmap = value;
|
|
||||||
|
|
||||||
if (value != null)
|
|
||||||
{
|
|
||||||
coverContainer.FadeIn(transition_duration);
|
|
||||||
|
|
||||||
LoadComponentAsync(new BeatmapSetCover(value.BeatmapSet)
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Anchor = Anchor.Centre,
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
FillMode = FillMode.Fill,
|
|
||||||
OnLoadComplete = d => d.FadeInFromZero(400, Easing.Out),
|
|
||||||
},
|
|
||||||
coverContainer.Add);
|
|
||||||
|
|
||||||
beatmapTitle.Current = localisation.GetUnicodePreference(value.Metadata.TitleUnicode, value.Metadata.Title);
|
|
||||||
beatmapDash.Text = @" - ";
|
|
||||||
beatmapArtist.Current = localisation.GetUnicodePreference(value.Metadata.ArtistUnicode, value.Metadata.Artist);
|
|
||||||
beatmapAuthor.Text = $"mapped by {value.Metadata.Author}";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
coverContainer.FadeOut(transition_duration);
|
coverContainer.FadeOut(transition_duration);
|
||||||
|
participantsFlow.FadeOut(transition_duration);
|
||||||
|
participantNumbersFlow.FadeOut(transition_duration);
|
||||||
|
infoPanelFlow.FadeOut(transition_duration);
|
||||||
|
name.FadeOut(transition_duration);
|
||||||
|
participantInfo.FadeOut(transition_duration);
|
||||||
|
|
||||||
beatmapTitle.Current = null;
|
displayStatus(new RoomStatusNoneSelected());
|
||||||
beatmapArtist.Current = null;
|
|
||||||
|
|
||||||
beatmapTitle.Text = "Changing map";
|
|
||||||
beatmapDash.Text = beatmapArtist.Text = beatmapAuthor.Text = string.Empty;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void displayMaxParticipants(int? value)
|
|
||||||
{
|
|
||||||
if (value == null)
|
|
||||||
{
|
|
||||||
participantsSlash.FadeOut(transition_duration);
|
|
||||||
maxParticipants.FadeOut(transition_duration);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
participantsSlash.FadeIn(transition_duration);
|
participantsFlow.FadeIn(transition_duration);
|
||||||
maxParticipants.FadeIn(transition_duration);
|
participantNumbersFlow.FadeIn(transition_duration);
|
||||||
maxParticipants.Text = value.ToString();
|
infoPanelFlow.FadeIn(transition_duration);
|
||||||
}
|
name.FadeIn(transition_duration);
|
||||||
}
|
participantInfo.FadeIn(transition_duration);
|
||||||
|
|
||||||
private void displayParticipants(User[] value)
|
statusBind.TriggerChange();
|
||||||
{
|
beatmapBind.TriggerChange();
|
||||||
participants.Text = value.Length.ToString();
|
}
|
||||||
participantInfo.Participants = value;
|
|
||||||
participantsFlow.ChildrenEnumerable = value.Select(u => new UserTile(u));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class UserTile : Container, IHasTooltip
|
private class UserTile : Container, IHasTooltip
|
||||||
@ -407,5 +417,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