mirror of
https://github.com/ppy/osu
synced 2024-12-15 03:16:17 +00:00
Fix up room inspector status
This commit is contained in:
parent
1e0135af6f
commit
1c2450a95a
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Configuration;
|
||||||
using osu.Framework.Extensions.Color4Extensions;
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Colour;
|
using osu.Framework.Graphics.Colour;
|
||||||
@ -28,21 +29,19 @@ namespace osu.Game.Screens.Multi.Lounge.Components
|
|||||||
|
|
||||||
private readonly MarginPadding contentPadding = new MarginPadding { Horizontal = 20, Vertical = 10 };
|
private readonly MarginPadding contentPadding = new MarginPadding { Horizontal = 20, Vertical = 10 };
|
||||||
|
|
||||||
private OsuColour colours;
|
|
||||||
private Box statusStrip;
|
|
||||||
private ParticipantCountDisplay participantCount;
|
private ParticipantCountDisplay participantCount;
|
||||||
private OsuSpriteText name, status;
|
private OsuSpriteText name;
|
||||||
private BeatmapTypeInfo beatmapTypeInfo;
|
private BeatmapTypeInfo beatmapTypeInfo;
|
||||||
private ParticipantInfo participantInfo;
|
private ParticipantInfo participantInfo;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private BeatmapManager beatmaps { get; set; }
|
private BeatmapManager beatmaps { get; set; }
|
||||||
|
|
||||||
|
private readonly Bindable<RoomStatus> status = new Bindable<RoomStatus>(new RoomStatusNoneSelected());
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours)
|
private void load(OsuColour colours)
|
||||||
{
|
{
|
||||||
this.colours = colours;
|
|
||||||
|
|
||||||
InternalChildren = new Drawable[]
|
InternalChildren = new Drawable[]
|
||||||
{
|
{
|
||||||
new Box
|
new Box
|
||||||
@ -98,15 +97,17 @@ namespace osu.Game.Screens.Multi.Lounge.Components
|
|||||||
Anchor = Anchor.BottomLeft,
|
Anchor = Anchor.BottomLeft,
|
||||||
Origin = Anchor.BottomLeft,
|
Origin = Anchor.BottomLeft,
|
||||||
TextSize = 30,
|
TextSize = 30,
|
||||||
|
Current = Name
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
statusStrip = new Box
|
new StatusColouredContainer(transition_duration)
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
Height = 5,
|
Height = 5,
|
||||||
|
Child = new Box { RelativeSizeAxes = Axes.Both }
|
||||||
},
|
},
|
||||||
new Container
|
new Container
|
||||||
{
|
{
|
||||||
@ -129,10 +130,14 @@ namespace osu.Game.Screens.Multi.Lounge.Components
|
|||||||
Spacing = new Vector2(0f, 5f),
|
Spacing = new Vector2(0f, 5f),
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
status = new OsuSpriteText
|
new StatusColouredContainer(transition_duration)
|
||||||
{
|
{
|
||||||
TextSize = 14,
|
AutoSizeAxes = Axes.Both,
|
||||||
Font = @"Exo2.0-Bold",
|
Child = new StatusText
|
||||||
|
{
|
||||||
|
TextSize = 14,
|
||||||
|
Font = @"Exo2.0-Bold",
|
||||||
|
}
|
||||||
},
|
},
|
||||||
beatmapTypeInfo = new BeatmapTypeInfo(),
|
beatmapTypeInfo = new BeatmapTypeInfo(),
|
||||||
},
|
},
|
||||||
@ -163,38 +168,37 @@ namespace osu.Game.Screens.Multi.Lounge.Components
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Status.BindValueChanged(displayStatus, true);
|
Status.BindValueChanged(_ => updateStatus(), true);
|
||||||
Name.BindValueChanged(n => name.Text = n, true);
|
RoomID.BindValueChanged(_ => updateStatus(), true);
|
||||||
RoomID.BindValueChanged(updateRoom, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateRoom(int? roomId)
|
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
||||||
{
|
{
|
||||||
if (roomId != null)
|
var dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
||||||
|
dependencies.CacheAs(status, new CacheInfo(nameof(Online.Multiplayer.Room.Status), typeof(Room)));
|
||||||
|
return dependencies;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateStatus()
|
||||||
|
{
|
||||||
|
if (RoomID.Value == null)
|
||||||
{
|
{
|
||||||
|
status.Value = new RoomStatusNoneSelected();
|
||||||
|
|
||||||
|
participantCount.FadeOut(transition_duration);
|
||||||
|
beatmapTypeInfo.FadeOut(transition_duration);
|
||||||
|
name.FadeOut(transition_duration);
|
||||||
|
participantInfo.FadeOut(transition_duration);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
status.Value = Status;
|
||||||
|
|
||||||
participantCount.FadeIn(transition_duration);
|
participantCount.FadeIn(transition_duration);
|
||||||
beatmapTypeInfo.FadeIn(transition_duration);
|
beatmapTypeInfo.FadeIn(transition_duration);
|
||||||
name.FadeIn(transition_duration);
|
name.FadeIn(transition_duration);
|
||||||
participantInfo.FadeIn(transition_duration);
|
participantInfo.FadeIn(transition_duration);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
participantCount.FadeOut(transition_duration);
|
|
||||||
beatmapTypeInfo.FadeOut(transition_duration);
|
|
||||||
name.FadeOut(transition_duration);
|
|
||||||
participantInfo.FadeOut(transition_duration);
|
|
||||||
|
|
||||||
displayStatus(new RoomStatusNoneSelected());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void displayStatus(RoomStatus s)
|
|
||||||
{
|
|
||||||
status.Text = s.Message;
|
|
||||||
|
|
||||||
Color4 c = s.GetAppropriateColour(colours);
|
|
||||||
statusStrip.FadeColour(c, transition_duration);
|
|
||||||
status.FadeColour(c, transition_duration);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class RoomStatusNoneSelected : RoomStatus
|
private class RoomStatusNoneSelected : RoomStatus
|
||||||
@ -203,6 +207,18 @@ namespace osu.Game.Screens.Multi.Lounge.Components
|
|||||||
public override Color4 GetAppropriateColour(OsuColour colours) => colours.Gray8;
|
public override Color4 GetAppropriateColour(OsuColour colours) => colours.Gray8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class StatusText : OsuSpriteText
|
||||||
|
{
|
||||||
|
[Resolved(typeof(Room), nameof(Online.Multiplayer.Room.Status))]
|
||||||
|
private Bindable<RoomStatus> status { get; set; }
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
|
{
|
||||||
|
status.BindValueChanged(s => Text = s.Message, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private class MatchParticipants : MultiplayerComposite
|
private class MatchParticipants : MultiplayerComposite
|
||||||
{
|
{
|
||||||
private readonly FillFlowContainer fill;
|
private readonly FillFlowContainer fill;
|
||||||
|
Loading…
Reference in New Issue
Block a user