mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 22:34:09 +08:00
Add GameType and DrawableGameType
This commit is contained in:
parent
d331aa3b30
commit
9e01074852
@ -25,6 +25,7 @@ namespace osu.Desktop.VisualTests.Tests
|
|||||||
room.Name.Value = @"My Awesome Room";
|
room.Name.Value = @"My Awesome Room";
|
||||||
room.Host.Value = new User { Username = @"flyte", Id = 3103765, Country = new Country { FlagName = @"JP" }};
|
room.Host.Value = new User { Username = @"flyte", Id = 3103765, Country = new Country { FlagName = @"JP" }};
|
||||||
room.Status.Value = new RoomStatusOpen();
|
room.Status.Value = new RoomStatusOpen();
|
||||||
|
room.Type.Value = new GameTypeTeamVersus();
|
||||||
room.Beatmap.Value = new BeatmapInfo
|
room.Beatmap.Value = new BeatmapInfo
|
||||||
{
|
{
|
||||||
StarDifficulty = 3.7,
|
StarDifficulty = 3.7,
|
||||||
@ -59,6 +60,7 @@ namespace osu.Desktop.VisualTests.Tests
|
|||||||
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());
|
||||||
|
AddStep(@"change type", () => room.Type.Value = new GameTypeTag());
|
||||||
AddStep(@"change beatmap", () => room.Beatmap.Value = null);
|
AddStep(@"change beatmap", () => room.Beatmap.Value = null);
|
||||||
AddStep(@"change max participants", () => room.MaxParticipants.Value = null);
|
AddStep(@"change max participants", () => room.MaxParticipants.Value = null);
|
||||||
AddStep(@"change participants", () => room.Participants.Value = new[]
|
AddStep(@"change participants", () => room.Participants.Value = new[]
|
||||||
@ -73,6 +75,7 @@ namespace osu.Desktop.VisualTests.Tests
|
|||||||
newRoom.Name.Value = @"My New, Better Than Ever Room";
|
newRoom.Name.Value = @"My New, Better Than Ever Room";
|
||||||
newRoom.Host.Value = new User { Username = @"Angelsim", Id = 1777162, Country = new Country { FlagName = @"KR" }};
|
newRoom.Host.Value = new User { Username = @"Angelsim", Id = 1777162, Country = new Country { FlagName = @"KR" }};
|
||||||
newRoom.Status.Value = new RoomStatusOpen();
|
newRoom.Status.Value = new RoomStatusOpen();
|
||||||
|
newRoom.Type.Value = new GameTypeTagTeam();
|
||||||
newRoom.Beatmap.Value = new BeatmapInfo
|
newRoom.Beatmap.Value = new BeatmapInfo
|
||||||
{
|
{
|
||||||
StarDifficulty = 7.07,
|
StarDifficulty = 7.07,
|
||||||
|
127
osu.Game/Online/Multiplayer/GameType.cs
Normal file
127
osu.Game/Online/Multiplayer/GameType.cs
Normal file
@ -0,0 +1,127 @@
|
|||||||
|
// 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.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
|
||||||
|
namespace osu.Game.Online.Multiplayer
|
||||||
|
{
|
||||||
|
public abstract class GameType
|
||||||
|
{
|
||||||
|
public abstract string Name { get; }
|
||||||
|
public abstract Drawable GetIcon(OsuColour colours, float size);
|
||||||
|
}
|
||||||
|
|
||||||
|
public class GameTypeTag : GameType
|
||||||
|
{
|
||||||
|
public override string Name => "Tag";
|
||||||
|
public override Drawable GetIcon(OsuColour colours, float size)
|
||||||
|
{
|
||||||
|
return new TextAwesome
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Icon = FontAwesome.fa_refresh,
|
||||||
|
TextSize = size,
|
||||||
|
Colour = colours.Blue,
|
||||||
|
Shadow = false,
|
||||||
|
UseFullGlyphHeight = false,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class GameTypeVersus : GameType
|
||||||
|
{
|
||||||
|
public override string Name => "Versus";
|
||||||
|
public override Drawable GetIcon(OsuColour colours, float size)
|
||||||
|
{
|
||||||
|
return new VersusRow(colours.Blue, colours.Blue, size * 0.6f)
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class GameTypeTagTeam : GameType
|
||||||
|
{
|
||||||
|
public override string Name => "Tag Team";
|
||||||
|
public override Drawable GetIcon(OsuColour colours, float size)
|
||||||
|
{
|
||||||
|
return new VersusRow(colours.Blue, colours.Blue, size * 0.6f)
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class GameTypeTeamVersus : GameType
|
||||||
|
{
|
||||||
|
public override string Name => "Team Versus";
|
||||||
|
public override Drawable GetIcon(OsuColour colours, float size)
|
||||||
|
{
|
||||||
|
return new FillFlowContainer
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
AutoSizeAxes = Axes.Both,
|
||||||
|
Direction = FillDirection.Vertical,
|
||||||
|
Spacing = new Vector2(2f),
|
||||||
|
Children = new[]
|
||||||
|
{
|
||||||
|
new VersusRow(colours.Blue, colours.Pink, size * 0.5f),
|
||||||
|
new VersusRow(colours.Blue, colours.Pink, size * 0.5f),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class VersusRow : FillFlowContainer
|
||||||
|
{
|
||||||
|
public VersusRow(Color4 first, Color4 second, float size)
|
||||||
|
{
|
||||||
|
var triangle_size = new Vector2(size);
|
||||||
|
AutoSizeAxes = Axes.Both;
|
||||||
|
Spacing = new Vector2(2f, 0f);
|
||||||
|
|
||||||
|
Children = new[]
|
||||||
|
{
|
||||||
|
new Container
|
||||||
|
{
|
||||||
|
Size = triangle_size,
|
||||||
|
Colour = first,
|
||||||
|
Children = new[]
|
||||||
|
{
|
||||||
|
new EquilateralTriangle
|
||||||
|
{
|
||||||
|
Origin = Anchor.BottomLeft,
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Rotation = 90,
|
||||||
|
EdgeSmoothness = new Vector2(1f),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
new Container
|
||||||
|
{
|
||||||
|
Size = triangle_size,
|
||||||
|
Colour = second,
|
||||||
|
Children = new[]
|
||||||
|
{
|
||||||
|
new EquilateralTriangle
|
||||||
|
{
|
||||||
|
Anchor = Anchor.BottomLeft,
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Rotation = -90,
|
||||||
|
EdgeSmoothness = new Vector2(1f),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -12,6 +12,7 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
public Bindable<string> Name = new Bindable<string>();
|
public Bindable<string> Name = new Bindable<string>();
|
||||||
public Bindable<User> Host = new Bindable<User>();
|
public Bindable<User> Host = new Bindable<User>();
|
||||||
public Bindable<RoomStatus> Status = new Bindable<RoomStatus>();
|
public Bindable<RoomStatus> Status = new Bindable<RoomStatus>();
|
||||||
|
public Bindable<GameType> Type = new Bindable<GameType>();
|
||||||
public Bindable<BeatmapInfo> Beatmap = new Bindable<BeatmapInfo>();
|
public Bindable<BeatmapInfo> Beatmap = new Bindable<BeatmapInfo>();
|
||||||
public Bindable<int?> MaxParticipants = new Bindable<int?>();
|
public Bindable<int?> MaxParticipants = new Bindable<int?>();
|
||||||
public Bindable<User[]> Participants = new Bindable<User[]>();
|
public Bindable<User[]> Participants = new Bindable<User[]>();
|
||||||
|
43
osu.Game/Screens/Multiplayer/DrawableGameType.cs
Normal file
43
osu.Game/Screens/Multiplayer/DrawableGameType.cs
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
// 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.Color4Extensions;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Online.Multiplayer;
|
||||||
|
|
||||||
|
namespace osu.Game.Screens.Multiplayer
|
||||||
|
{
|
||||||
|
public class DrawableGameType : CircularContainer, IHasTooltip
|
||||||
|
{
|
||||||
|
private readonly GameType type;
|
||||||
|
|
||||||
|
public string TooltipText => type.Name;
|
||||||
|
|
||||||
|
public DrawableGameType(GameType type)
|
||||||
|
{
|
||||||
|
this.type = type;
|
||||||
|
Masking = true;
|
||||||
|
|
||||||
|
Children = new[]
|
||||||
|
{
|
||||||
|
new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Colour = OsuColour.FromHex(@"545454"),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OsuColour colours)
|
||||||
|
{
|
||||||
|
Add(type.GetIcon(colours, Height / 2));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -29,7 +29,7 @@ namespace osu.Game.Screens.Multiplayer
|
|||||||
private const float ruleset_height = 30;
|
private const float ruleset_height = 30;
|
||||||
|
|
||||||
private readonly Box statusStrip;
|
private readonly Box statusStrip;
|
||||||
private readonly Container coverContainer, rulesetContainer, flagContainer;
|
private readonly Container coverContainer, rulesetContainer, gameTypeContainer, flagContainer;
|
||||||
private readonly FillFlowContainer topFlow, levelRangeContainer, participantsFlow;
|
private readonly FillFlowContainer topFlow, levelRangeContainer, participantsFlow;
|
||||||
private readonly OsuSpriteText participants, participantsSlash, maxParticipants, name, status, beatmapTitle, beatmapDash, beatmapArtist, beatmapAuthor, host, levelRangeLower, levelRangeHigher;
|
private readonly OsuSpriteText participants, participantsSlash, maxParticipants, name, status, beatmapTitle, beatmapDash, beatmapArtist, beatmapAuthor, host, levelRangeLower, levelRangeHigher;
|
||||||
private readonly ScrollContainer participantsScroll;
|
private readonly ScrollContainer participantsScroll;
|
||||||
@ -37,6 +37,7 @@ namespace osu.Game.Screens.Multiplayer
|
|||||||
private Bindable<string> nameBind = new Bindable<string>();
|
private Bindable<string> nameBind = new Bindable<string>();
|
||||||
private Bindable<User> hostBind = new Bindable<User>();
|
private Bindable<User> hostBind = new Bindable<User>();
|
||||||
private Bindable<RoomStatus> statusBind = new Bindable<RoomStatus>();
|
private Bindable<RoomStatus> statusBind = new Bindable<RoomStatus>();
|
||||||
|
private Bindable<GameType> typeBind = new Bindable<GameType>();
|
||||||
private Bindable<BeatmapInfo> beatmapBind = new Bindable<BeatmapInfo>();
|
private Bindable<BeatmapInfo> beatmapBind = new Bindable<BeatmapInfo>();
|
||||||
private Bindable<int?> maxParticipantsBind = new Bindable<int?>();
|
private Bindable<int?> maxParticipantsBind = new Bindable<int?>();
|
||||||
private Bindable<User[]> participantsBind = new Bindable<User[]>();
|
private Bindable<User[]> participantsBind = new Bindable<User[]>();
|
||||||
@ -57,6 +58,7 @@ namespace osu.Game.Screens.Multiplayer
|
|||||||
nameBind.BindTo(Room.Name);
|
nameBind.BindTo(Room.Name);
|
||||||
hostBind.BindTo(Room.Host);
|
hostBind.BindTo(Room.Host);
|
||||||
statusBind.BindTo(Room.Status);
|
statusBind.BindTo(Room.Status);
|
||||||
|
typeBind.BindTo(Room.Type);
|
||||||
beatmapBind.BindTo(Room.Beatmap);
|
beatmapBind.BindTo(Room.Beatmap);
|
||||||
maxParticipantsBind.BindTo(Room.MaxParticipants);
|
maxParticipantsBind.BindTo(Room.MaxParticipants);
|
||||||
participantsBind.BindTo(Room.Participants);
|
participantsBind.BindTo(Room.Participants);
|
||||||
@ -196,19 +198,9 @@ namespace osu.Game.Screens.Multiplayer
|
|||||||
{
|
{
|
||||||
Size = new Vector2(ruleset_height),
|
Size = new Vector2(ruleset_height),
|
||||||
},
|
},
|
||||||
new Container //todo: game type icon
|
gameTypeContainer = new Container
|
||||||
{
|
{
|
||||||
Size = new Vector2(ruleset_height),
|
Size = new Vector2(ruleset_height),
|
||||||
CornerRadius = 15f,
|
|
||||||
Masking = true,
|
|
||||||
Children = new[]
|
|
||||||
{
|
|
||||||
new Box
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Colour = OsuColour.FromHex(@"545454"),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
new Container
|
new Container
|
||||||
{
|
{
|
||||||
@ -384,9 +376,11 @@ namespace osu.Game.Screens.Multiplayer
|
|||||||
|
|
||||||
//binded here instead of ctor because dependencies are needed
|
//binded here instead of ctor because dependencies are needed
|
||||||
statusBind.ValueChanged += displayStatus;
|
statusBind.ValueChanged += displayStatus;
|
||||||
|
typeBind.ValueChanged += displayGameType;
|
||||||
beatmapBind.ValueChanged += displayBeatmap;
|
beatmapBind.ValueChanged += displayBeatmap;
|
||||||
|
|
||||||
statusBind.TriggerChange();
|
statusBind.TriggerChange();
|
||||||
|
typeBind.TriggerChange();
|
||||||
beatmapBind.TriggerChange();
|
beatmapBind.TriggerChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -417,6 +411,17 @@ namespace osu.Game.Screens.Multiplayer
|
|||||||
d.FadeColour(value.GetAppropriateColour(colours), transition_duration);
|
d.FadeColour(value.GetAppropriateColour(colours), transition_duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void displayGameType(GameType value)
|
||||||
|
{
|
||||||
|
gameTypeContainer.Children = new[]
|
||||||
|
{
|
||||||
|
new DrawableGameType(value)
|
||||||
|
{
|
||||||
|
Size = new Vector2(ruleset_height),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
private void displayBeatmap(BeatmapInfo value)
|
private void displayBeatmap(BeatmapInfo value)
|
||||||
{
|
{
|
||||||
if (value != null)
|
if (value != null)
|
||||||
|
@ -453,6 +453,8 @@
|
|||||||
<Compile Include="Database\RankStatus.cs" />
|
<Compile Include="Database\RankStatus.cs" />
|
||||||
<Compile Include="Graphics\UserInterface\BreadcrumbControl.cs" />
|
<Compile Include="Graphics\UserInterface\BreadcrumbControl.cs" />
|
||||||
<Compile Include="Screens\Multiplayer\RoomInspector.cs" />
|
<Compile Include="Screens\Multiplayer\RoomInspector.cs" />
|
||||||
|
<Compile Include="Online\Multiplayer\GameType.cs" />
|
||||||
|
<Compile Include="Screens\Multiplayer\DrawableGameType.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\osu-framework\osu.Framework\osu.Framework.csproj">
|
<ProjectReference Include="..\osu-framework\osu.Framework\osu.Framework.csproj">
|
||||||
|
Loading…
Reference in New Issue
Block a user