mirror of
https://github.com/osukey/osukey.git
synced 2025-08-05 15:44:04 +09:00
Initial cleanup
This commit is contained in:
215
osu.Game/Screens/Multiplayer/DrawableMultiplayerRoom.cs
Normal file
215
osu.Game/Screens/Multiplayer/DrawableMultiplayerRoom.cs
Normal file
@ -0,0 +1,215 @@
|
||||
// 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;
|
||||
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;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Backgrounds;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Online.Multiplayer;
|
||||
using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Screens.Multiplayer
|
||||
{
|
||||
public class DrawableMultiplayerRoom : ClickableContainer
|
||||
{
|
||||
private const float content_padding = 5;
|
||||
private const float height = 90;
|
||||
|
||||
private readonly Box sideStrip;
|
||||
private readonly OsuSpriteText status;
|
||||
private readonly OsuSpriteText host;
|
||||
private readonly OsuSpriteText rankBounds;
|
||||
private readonly FillFlowContainer<OsuSpriteText> beatmapInfoFlow;
|
||||
private readonly OsuSpriteText beatmapTitle;
|
||||
private readonly OsuSpriteText beatmapArtist;
|
||||
|
||||
private Color4 openColour;
|
||||
private Color4 playingColour;
|
||||
|
||||
public readonly MultiplayerRoom Room;
|
||||
|
||||
public DrawableMultiplayerRoom(MultiplayerRoom room)
|
||||
{
|
||||
Room = room;
|
||||
|
||||
RelativeSizeAxes = Axes.X;
|
||||
Height = height;
|
||||
CornerRadius = 5;
|
||||
Masking = true;
|
||||
EdgeEffect = new EdgeEffect
|
||||
{
|
||||
Type = EdgeEffectType.Shadow,
|
||||
Colour = Color4.Black.Opacity(40),
|
||||
Radius = 5,
|
||||
};
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = OsuColour.Gray(34),
|
||||
},
|
||||
new Background(@"Backgrounds/bg4")
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
sideStrip = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Width = 5,
|
||||
},
|
||||
new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Padding = new MarginPadding { Top = content_padding, Bottom = content_padding * 2, Left = Height + content_padding * 2, Right = content_padding },
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new FillFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Direction = FillDirection.Vertical,
|
||||
Spacing = new Vector2(5f),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new OsuSpriteText
|
||||
{
|
||||
Text = Room.Name,
|
||||
TextSize = 18,
|
||||
},
|
||||
new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = 20f,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new FillFlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.X,
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Spacing = new Vector2(5f, 0f),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new DrawableFlag(Room.Host?.Country?.FlagName ?? "__")
|
||||
{
|
||||
Width = 30f,
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
},
|
||||
new Container
|
||||
{
|
||||
Width = 40f,
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
Text = "hosted by",
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
TextSize = 14,
|
||||
},
|
||||
host = new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Text = Room.Host?.Username ?? @"",
|
||||
TextSize = 14,
|
||||
Font = @"Exo2.0-BoldItalic",
|
||||
},
|
||||
},
|
||||
},
|
||||
rankBounds = new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.CentreRight,
|
||||
Origin = Anchor.CentreRight,
|
||||
Text = "#6895 - #50024",
|
||||
TextSize = 14,
|
||||
Margin = new MarginPadding { Right = 10 },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
new FillFlowContainer
|
||||
{
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Direction = FillDirection.Vertical,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
status = new OsuSpriteText
|
||||
{
|
||||
TextSize = 14,
|
||||
Font = @"Exo2.0-Bold",
|
||||
},
|
||||
beatmapInfoFlow = new FillFlowContainer<OsuSpriteText>
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Children = new[]
|
||||
{
|
||||
beatmapTitle = new OsuSpriteText
|
||||
{
|
||||
TextSize = 14,
|
||||
Font = @"Exo2.0-BoldItalic",
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
Text = @" - ",
|
||||
TextSize = 14,
|
||||
Font = @"Exo2.0-RegularItalic",
|
||||
},
|
||||
beatmapArtist = new OsuSpriteText
|
||||
{
|
||||
TextSize = 14,
|
||||
Font = @"Exo2.0-RegularItalic",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours, LocalisationEngine localisation)
|
||||
{
|
||||
openColour = colours.GreenLight;
|
||||
playingColour = colours.Purple;
|
||||
beatmapInfoFlow.Colour = rankBounds.Colour = colours.Gray9;
|
||||
host.Colour = colours.Blue;
|
||||
|
||||
if (Room.CurrentBeatmap != null)
|
||||
{
|
||||
beatmapTitle.Current = localisation.GetUnicodePreference(Room.CurrentBeatmap.TitleUnicode, Room.CurrentBeatmap.Title);
|
||||
beatmapArtist.Current = localisation.GetUnicodePreference(Room.CurrentBeatmap.ArtistUnicode, Room.CurrentBeatmap.Artist);
|
||||
}
|
||||
|
||||
updateStatus();
|
||||
}
|
||||
|
||||
private void updateStatus()
|
||||
{
|
||||
if (Room == null) return;
|
||||
|
||||
status.Text = Room.Status.GetDescription();
|
||||
|
||||
foreach (Drawable d in new Drawable[] { sideStrip, status })
|
||||
d.FadeColour(Room.Status == MultiplayerRoomStatus.Playing? playingColour : openColour);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,269 +0,0 @@
|
||||
// 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;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Primitives;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Input;
|
||||
using osu.Game.Graphics.Backgrounds;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
|
||||
namespace osu.Game.Screens.Multiplayer
|
||||
{
|
||||
public class MultiRoomPanel : ClickableContainer, IStateful<MultiRoomPanel.PanelState>
|
||||
{
|
||||
private PanelState state;
|
||||
public PanelState State
|
||||
{
|
||||
get { return state; }
|
||||
set
|
||||
{
|
||||
if (state == value)
|
||||
return;
|
||||
|
||||
state = value;
|
||||
switch (state)
|
||||
{
|
||||
case PanelState.Free:
|
||||
statusColour = ColourFree;
|
||||
statusString = "Welcoming Players";
|
||||
UpdatePanel(this);
|
||||
break;
|
||||
|
||||
case PanelState.Busy:
|
||||
statusColour = ColourBusy;
|
||||
statusString = "Now Playing";
|
||||
UpdatePanel(this);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool didClick;
|
||||
private string roomName;
|
||||
private string hostName;
|
||||
|
||||
private int roomStatus;
|
||||
private Color4 statusColour;
|
||||
private string statusString;
|
||||
|
||||
private Box sideSprite;
|
||||
private OsuSpriteText hostSprite;
|
||||
private OsuSpriteText statusSprite;
|
||||
private OsuSpriteText roomSprite;
|
||||
|
||||
public const int PANEL_HEIGHT = 90;
|
||||
public const int CONTENT_PADDING = 5;
|
||||
|
||||
public Color4 ColourFree = new Color4(166, 204, 0, 255);
|
||||
public Color4 ColourBusy = new Color4(135, 102, 237, 255);
|
||||
|
||||
public bool Clicked
|
||||
{
|
||||
get { return didClick; }
|
||||
set
|
||||
{
|
||||
didClick = value;
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdatePanel(MultiRoomPanel panel)
|
||||
{
|
||||
panel.BorderColour = statusColour;
|
||||
panel.sideSprite.Colour = statusColour;
|
||||
|
||||
statusSprite.Colour = statusColour;
|
||||
statusSprite.Text = statusString;
|
||||
}
|
||||
|
||||
public MultiRoomPanel(string matchName = "Room Name", string host = "Undefined", int status = 0)
|
||||
{
|
||||
roomName = matchName;
|
||||
hostName = host;
|
||||
roomStatus = status;
|
||||
|
||||
if (status == 0)
|
||||
{
|
||||
statusColour = ColourFree;
|
||||
statusString = "Welcoming Players";
|
||||
}
|
||||
else
|
||||
{
|
||||
statusColour = ColourBusy;
|
||||
statusString = "Now Playing";
|
||||
}
|
||||
|
||||
RelativeSizeAxes = Axes.X;
|
||||
Height = PANEL_HEIGHT;
|
||||
Masking = true;
|
||||
CornerRadius = 5;
|
||||
BorderThickness = 0;
|
||||
BorderColour = statusColour;
|
||||
EdgeEffect = new EdgeEffect
|
||||
{
|
||||
Type = EdgeEffectType.Shadow,
|
||||
Colour = Color4.Black.Opacity(40),
|
||||
Radius = 5,
|
||||
};
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = new Color4(34,34,34, 255),
|
||||
},
|
||||
sideSprite = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Width = 5,
|
||||
Colour = statusColour,
|
||||
},
|
||||
/*new Box //Beatmap img
|
||||
{
|
||||
|
||||
},*/
|
||||
new Background(@"Backgrounds/bg4")
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
}
|
||||
,
|
||||
new FillFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
Direction = FillDirection.Vertical,
|
||||
Size = new Vector2(0.75f,1),
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
roomSprite = new OsuSpriteText
|
||||
{
|
||||
Text = roomName,
|
||||
TextSize = 18,
|
||||
Margin = new MarginPadding { Top = CONTENT_PADDING },
|
||||
},
|
||||
new FillFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = 20,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Spacing = new Vector2(5,0),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
|
||||
|
||||
new Container
|
||||
{
|
||||
Masking = true,
|
||||
CornerRadius = 5,
|
||||
Width = 30,
|
||||
Height = 20,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.Gray,
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
new Container
|
||||
{
|
||||
Masking = true,
|
||||
CornerRadius = 5,
|
||||
Width = 40,
|
||||
Height = 20,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = new Color4(173,56,126,255),
|
||||
}
|
||||
}
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
Text = "hosted by",
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
TextSize = 14,
|
||||
},
|
||||
hostSprite = new OsuSpriteText
|
||||
{
|
||||
Text = hostName,
|
||||
Font = @"Exo2.0-Bold",
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Shear = new Vector2(0.1f,0),
|
||||
Colour = new Color4(69,179,222,255),
|
||||
TextSize = 14,
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
Text = "#6895 - #50024",
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
TextSize = 14,
|
||||
Margin = new MarginPadding { Left = 80 },
|
||||
Colour = new Color4(153,153,153,255),
|
||||
}
|
||||
}
|
||||
},
|
||||
statusSprite = new OsuSpriteText
|
||||
{
|
||||
Text = statusString,
|
||||
TextSize = 14,
|
||||
Font = @"Exo2.0-Bold",
|
||||
Colour = statusColour,
|
||||
Margin = new MarginPadding { Top = 10 }
|
||||
},
|
||||
new FillFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new OsuSpriteText
|
||||
{
|
||||
Text = "Platina",
|
||||
Font = @"Exo2.0-Bold",
|
||||
TextSize = 14,
|
||||
Shear = new Vector2(0.1f,0),
|
||||
Colour = new Color4(153,153,153,255),
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
Text = " - " + "Maaya Sakamoto",
|
||||
TextSize = 14,
|
||||
Shear = new Vector2(0.1f,0),
|
||||
Colour = new Color4(153,153,153,255),
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
protected override bool OnMouseUp(InputState state, MouseUpEventArgs args)
|
||||
{
|
||||
BorderThickness = 3;
|
||||
didClick = true;
|
||||
return base.OnMouseUp(state, args);
|
||||
}
|
||||
|
||||
public enum PanelState
|
||||
{
|
||||
Free,
|
||||
Busy
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user