mirror of
https://github.com/ppy/osu.git
synced 2025-03-23 02:57:25 +08:00
Move RoomStatus to a class instead of enum
This commit is contained in:
parent
cf0e7887b5
commit
9798117d53
@ -37,17 +37,17 @@ namespace osu.Desktop.VisualTests.Tests
|
||||
|
||||
first.Room.Name.Value = @"Great Room Right Here";
|
||||
first.Room.Host.Value = new User { Username = @"Naeferith", Id = 9492835, Country = new Country { FlagName = @"FR" }};
|
||||
first.Room.Status.Value = RoomStatus.Open;
|
||||
first.Room.Status.Value = new RoomStatusOpen();
|
||||
first.Room.Beatmap.Value = new BeatmapMetadata { Title = @"Seiryu", Artist = @"Critical Crystal" };
|
||||
|
||||
second.Room.Name.Value = @"Relax It's The Weekend";
|
||||
second.Room.Host.Value = new User { Username = @"peppy", Id = 2, Country = new Country { FlagName = @"AU" }};
|
||||
second.Room.Status.Value = RoomStatus.Playing;
|
||||
second.Room.Status.Value = new RoomStatusPlaying();
|
||||
second.Room.Beatmap.Value = new BeatmapMetadata { Title = @"ZAQ", Artist = @"Serendipity" };
|
||||
|
||||
AddStep(@"change state", () =>
|
||||
{
|
||||
first.Room.Status.Value = RoomStatus.Playing;
|
||||
first.Room.Status.Value = new RoomStatusPlaying();
|
||||
});
|
||||
|
||||
AddStep(@"change name", () =>
|
||||
@ -67,7 +67,7 @@ namespace osu.Desktop.VisualTests.Tests
|
||||
|
||||
AddStep(@"change state", () =>
|
||||
{
|
||||
first.Room.Status.Value = RoomStatus.Open;
|
||||
first.Room.Status.Value = new RoomStatusOpen();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System.ComponentModel;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Users;
|
||||
@ -15,13 +14,4 @@ namespace osu.Game.Online.Multiplayer
|
||||
public Bindable<RoomStatus> Status = new Bindable<RoomStatus>();
|
||||
public Bindable<BeatmapMetadata> Beatmap = new Bindable<BeatmapMetadata>();
|
||||
}
|
||||
|
||||
public enum RoomStatus
|
||||
{
|
||||
[Description(@"Welcoming Players")]
|
||||
Open,
|
||||
|
||||
[Description(@"Now Playing")]
|
||||
Playing,
|
||||
}
|
||||
}
|
||||
|
26
osu.Game/Online/Multiplayer/RoomStatus.cs
Normal file
26
osu.Game/Online/Multiplayer/RoomStatus.cs
Normal file
@ -0,0 +1,26 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using OpenTK.Graphics;
|
||||
using osu.Game.Graphics;
|
||||
|
||||
namespace osu.Game.Online.Multiplayer
|
||||
{
|
||||
public abstract class RoomStatus
|
||||
{
|
||||
public abstract string Message { get; }
|
||||
public abstract Color4 GetAppropriateColour(OsuColour colours);
|
||||
}
|
||||
|
||||
public class RoomStatusOpen : RoomStatus
|
||||
{
|
||||
public override string Message => @"Welcoming Players";
|
||||
public override Color4 GetAppropriateColour(OsuColour colours) => colours.GreenLight;
|
||||
}
|
||||
|
||||
public class RoomStatusPlaying : RoomStatus
|
||||
{
|
||||
public override string Message => @"Now Playing";
|
||||
public override Color4 GetAppropriateColour(OsuColour colours) => colours.Purple;
|
||||
}
|
||||
}
|
@ -4,7 +4,6 @@
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
@ -35,8 +34,7 @@ namespace osu.Game.Screens.Multiplayer
|
||||
private readonly OsuSpriteText beatmapDash;
|
||||
private readonly OsuSpriteText beatmapArtist;
|
||||
|
||||
private Color4 openColour;
|
||||
private Color4 playingColour;
|
||||
private OsuColour colours;
|
||||
private LocalisationEngine localisation;
|
||||
|
||||
public readonly Room Room;
|
||||
@ -200,9 +198,8 @@ namespace osu.Game.Screens.Multiplayer
|
||||
private void load(OsuColour colours, LocalisationEngine localisation)
|
||||
{
|
||||
this.localisation = localisation;
|
||||
this.colours = colours;
|
||||
|
||||
openColour = colours.GreenLight;
|
||||
playingColour = colours.Purple;
|
||||
beatmapInfoFlow.Colour = rankBounds.Colour = colours.Gray9;
|
||||
host.Colour = colours.Blue;
|
||||
|
||||
@ -223,10 +220,11 @@ namespace osu.Game.Screens.Multiplayer
|
||||
|
||||
private void displayStatus(RoomStatus value)
|
||||
{
|
||||
status.Text = value.GetDescription() ?? value.ToString();
|
||||
if (value == null) return;
|
||||
status.Text = value.Message;
|
||||
|
||||
foreach (Drawable d in new Drawable[] { sideStrip, status })
|
||||
d.FadeColour(value == RoomStatus.Playing ? playingColour : openColour, 100);
|
||||
d.FadeColour(value.GetAppropriateColour(colours), 100);
|
||||
}
|
||||
|
||||
private void displayBeatmap(BeatmapMetadata value)
|
||||
|
@ -427,6 +427,7 @@
|
||||
<Compile Include="Rulesets\Replays\AutoGenerator.cs" />
|
||||
<Compile Include="Screens\Multiplayer\DrawableRoom.cs" />
|
||||
<Compile Include="Online\Multiplayer\Room.cs" />
|
||||
<Compile Include="Online\Multiplayer\RoomStatus.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\osu-framework\osu.Framework\osu.Framework.csproj">
|
||||
|
Loading…
x
Reference in New Issue
Block a user