1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 17:47:29 +08:00

Initial cleanup

This commit is contained in:
DrabWeb 2017-05-22 00:07:15 -03:00
parent c4e6870c12
commit e5ee7096f8
7 changed files with 307 additions and 341 deletions

View File

@ -0,0 +1,60 @@
// 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.Game.Graphics.UserInterface;
using osu.Game.Screens.Select;
using osu.Game.Screens.Multiplayer;
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.Sprites;
using osu.Framework.Testing;
using osu.Game.Online.Multiplayer;
using osu.Game.Users;
using osu.Game.Database;
namespace osu.Desktop.VisualTests.Tests
{
class TestCaseDrawableMultiplayerRoom : TestCase
{
public override string Description => @"Select your favourite room";
public override void Reset()
{
base.Reset();
DrawableMultiplayerRoom p;
Add(new FillFlowContainer
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
AutoSizeAxes = Axes.Y,
Width = 500f,
Direction = FillDirection.Vertical,
Children = new Drawable[]
{
p = new DrawableMultiplayerRoom(new MultiplayerRoom
{
Name = @"Great Room Right Here",
Host = new User { Username = @"Naeferith", Country = new Country { FlagName = @"FR" }},
Status = MultiplayerRoomStatus.Open,
CurrentBeatmap = new BeatmapMetadata { Title = @"Seiryu", Artist = @"Critical Crystal" },
}),
new DrawableMultiplayerRoom(new MultiplayerRoom
{
Name = @"Relax It's The Weekend",
Host = new User{ Username = @"Someone", Country = new Country { FlagName = @"CA" }},
Status = MultiplayerRoomStatus.Playing,
CurrentBeatmap = new BeatmapMetadata { Title = @"ZAQ", Artist = @"Serendipity" },
}),
}
});
AddStep(@"change state", () => { p.Room.Status = MultiplayerRoomStatus.Playing; });
}
}
}

View File

@ -1,70 +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.Game.Graphics.UserInterface;
using osu.Game.Screens.Select;
using osu.Game.Screens.Multiplayer;
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.Sprites;
using osu.Framework.Testing;
namespace osu.Desktop.VisualTests.Tests
{
class TestCaseMultiRoomPanel : TestCase
{
private MultiRoomPanel test;
private FillFlowContainer panelContainer;
public override string Description => @"Select your favourite room";
private void action(int action)
{
switch (action)
{
case 0:
test.State = test.State == MultiRoomPanel.PanelState.Free ? MultiRoomPanel.PanelState.Busy : MultiRoomPanel.PanelState.Free;
break;
}
}
public override void Reset()
{
base.Reset();
AddStep(@"ChangeState", () => action(0));
Add(panelContainer = new FillFlowContainer //Positionning container
{
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Direction = FillDirection.Vertical,
Size = new Vector2(0.4f, 0.5f),
Children = new Drawable[]
{
test = new MultiRoomPanel("Great Room Right Here", "Naeferith", 0),
new MultiRoomPanel("Relax it's the weekend", "Someone", 1),
}
});
}
protected override bool OnMouseUp(InputState state, MouseUpEventArgs args)
{
foreach (MultiRoomPanel panel in panelContainer.Children)
{
panel.BorderThickness = 0;
if (panel.Clicked == true)
{
panel.BorderThickness = 3;
panel.Clicked = false;
}
}
return base.OnMouseUp(state, args);
}
}
}

View File

@ -220,7 +220,7 @@
<Compile Include="Tests\TestCaseLeaderboard.cs" />
<Compile Include="Beatmaps\TestWorkingBeatmap.cs" />
<Compile Include="Tests\TestCaseBeatmapDetailArea.cs" />
<Compile Include="Tests\TestCaseMultiRoomPanel.cs" />
<Compile Include="Tests\TestCaseDrawableMultiplayerRoom.cs" />
</ItemGroup>
<ItemGroup />
<ItemGroup />

View 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 System.ComponentModel;
using osu.Game.Database;
using osu.Game.Users;
namespace osu.Game.Online.Multiplayer
{
public class MultiplayerRoom
{
public string Name { get; set; }
public User Host { get; set; }
public MultiplayerRoomStatus Status { get; set; }
public BeatmapMetadata CurrentBeatmap { get; set; }
}
public enum MultiplayerRoomStatus
{
[Description(@"Welcoming Players")]
Open,
[Description(@"Now Playing")]
Playing,
}
}

View 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);
}
}
}

View File

@ -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
}
}
}

View File

@ -428,7 +428,8 @@
<Compile Include="Overlays\Music\PlaylistOverlay.cs" />
<Compile Include="Rulesets\Replays\IAutoGenerator.cs" />
<Compile Include="Rulesets\Replays\AutoGenerator.cs" />
<Compile Include="Screens\Multiplayer\MultiRoomPanel.cs" />
<Compile Include="Screens\Multiplayer\DrawableMultiplayerRoom.cs" />
<Compile Include="Online\Multiplayer\MultiplayerRoom.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\osu-framework\osu.Framework\osu.Framework.csproj">
@ -451,6 +452,9 @@
<ItemGroup />
<ItemGroup />
<ItemGroup />
<ItemGroup>
<Folder Include="Online\Multiplayer\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.