From ec837907348eeeef243d660d99d8293953411f94 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Tue, 4 Dec 2018 18:58:45 +0900 Subject: [PATCH] Add timeshift game type --- osu.Game.Tests/Visual/TestCaseMatch.cs | 9 +++++ osu.Game.Tests/Visual/TestCaseRoomSettings.cs | 8 +++++ osu.Game/Online/Multiplayer/GameType.cs | 33 +++++++++++++++++++ osu.Game/Online/Multiplayer/Room.cs | 2 +- .../Multi/Components/GameTypePicker.cs | 15 ++++++++- 5 files changed, 65 insertions(+), 2 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseMatch.cs b/osu.Game.Tests/Visual/TestCaseMatch.cs index bb22358425..ae19b9720e 100644 --- a/osu.Game.Tests/Visual/TestCaseMatch.cs +++ b/osu.Game.Tests/Visual/TestCaseMatch.cs @@ -1,11 +1,14 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; +using System.Collections.Generic; using NUnit.Framework; using osu.Framework.Allocation; using osu.Game.Beatmaps; using osu.Game.Online.Multiplayer; using osu.Game.Rulesets; +using osu.Game.Screens.Multi.Components; using osu.Game.Screens.Multi.Screens.Match; using osu.Game.Users; @@ -14,6 +17,12 @@ namespace osu.Game.Tests.Visual [TestFixture] public class TestCaseMatch : OsuTestCase { + public override IReadOnlyList RequiredTypes => new[] + { + typeof(TestCaseMatch), + typeof(GameTypePicker) + }; + [BackgroundDependencyLoader] private void load(RulesetStore rulesets) { diff --git a/osu.Game.Tests/Visual/TestCaseRoomSettings.cs b/osu.Game.Tests/Visual/TestCaseRoomSettings.cs index e62afec6b4..af41563e30 100644 --- a/osu.Game.Tests/Visual/TestCaseRoomSettings.cs +++ b/osu.Game.Tests/Visual/TestCaseRoomSettings.cs @@ -1,6 +1,8 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; +using System.Collections.Generic; using NUnit.Framework; using osu.Framework.Graphics; using osu.Framework.Testing.Input; @@ -13,6 +15,12 @@ namespace osu.Game.Tests.Visual [TestFixture] public class TestCaseRoomSettings : ManualInputManagerTestCase { + public override IReadOnlyList RequiredTypes => new[] + { + typeof(RoomSettingsOverlay), + typeof(GameTypePicker) + }; + private readonly Room room; private readonly TestRoomSettingsOverlay overlay; diff --git a/osu.Game/Online/Multiplayer/GameType.cs b/osu.Game/Online/Multiplayer/GameType.cs index 8d39e8f59d..ced6d7d318 100644 --- a/osu.Game/Online/Multiplayer/GameType.cs +++ b/osu.Game/Online/Multiplayer/GameType.cs @@ -13,6 +13,9 @@ namespace osu.Game.Online.Multiplayer public abstract class GameType { public abstract string Name { get; } + + public abstract bool IsAvailable { get; } + public abstract Drawable GetIcon(OsuColour colours, float size); public override int GetHashCode() => GetType().GetHashCode(); @@ -22,6 +25,9 @@ namespace osu.Game.Online.Multiplayer public class GameTypeTag : GameType { public override string Name => "Tag"; + + public override bool IsAvailable => false; + public override Drawable GetIcon(OsuColour colours, float size) { return new SpriteIcon @@ -39,6 +45,9 @@ namespace osu.Game.Online.Multiplayer public class GameTypeVersus : GameType { public override string Name => "Versus"; + + public override bool IsAvailable => false; + public override Drawable GetIcon(OsuColour colours, float size) { return new VersusRow(colours.Blue, colours.Blue, size * 0.6f) @@ -52,6 +61,9 @@ namespace osu.Game.Online.Multiplayer public class GameTypeTagTeam : GameType { public override string Name => "Tag Team"; + + public override bool IsAvailable => false; + public override Drawable GetIcon(OsuColour colours, float size) { return new FillFlowContainer @@ -85,6 +97,9 @@ namespace osu.Game.Online.Multiplayer public class GameTypeTeamVersus : GameType { public override string Name => "Team Versus"; + + public override bool IsAvailable => false; + public override Drawable GetIcon(OsuColour colours, float size) { return new FillFlowContainer @@ -146,4 +161,22 @@ namespace osu.Game.Online.Multiplayer }; } } + + public class GameTypeTimeshift : GameType + { + public override string Name => "Timeshift"; + + public override bool IsAvailable => true; + + public override Drawable GetIcon(OsuColour colours, float size) => new SpriteIcon + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Icon = FontAwesome.fa_osu_charts, + X = -2, // The icon is off-centre + Size = new Vector2(size), + Colour = colours.Blue, + Shadow = false + }; + } } diff --git a/osu.Game/Online/Multiplayer/Room.cs b/osu.Game/Online/Multiplayer/Room.cs index f4885b6a4a..8395b7e638 100644 --- a/osu.Game/Online/Multiplayer/Room.cs +++ b/osu.Game/Online/Multiplayer/Room.cs @@ -15,7 +15,7 @@ namespace osu.Game.Online.Multiplayer public Bindable Host = new Bindable(); public Bindable Status = new Bindable(new RoomStatusOpen()); public Bindable Availability = new Bindable(); - public Bindable Type = new Bindable(new GameTypeVersus()); + public Bindable Type = new Bindable(new GameTypeTimeshift()); public Bindable Beatmap = new Bindable(); public Bindable MaxParticipants = new Bindable(); public Bindable> Participants = new Bindable>(Enumerable.Empty()); diff --git a/osu.Game/Screens/Multi/Components/GameTypePicker.cs b/osu.Game/Screens/Multi/Components/GameTypePicker.cs index 9058185e28..9cd1a7dc14 100644 --- a/osu.Game/Screens/Multi/Components/GameTypePicker.cs +++ b/osu.Game/Screens/Multi/Components/GameTypePicker.cs @@ -19,6 +19,7 @@ namespace osu.Game.Screens.Multi.Components private const float selection_width = 3; protected override TabItem CreateTabItem(GameType value) => new GameTypePickerItem(value); + protected override Dropdown CreateDropdown() => null; public GameTypePicker() @@ -30,6 +31,7 @@ namespace osu.Game.Screens.Multi.Components AddItem(new GameTypeVersus()); AddItem(new GameTypeTagTeam()); AddItem(new GameTypeTeamVersus()); + AddItem(new GameTypeTimeshift()); } private class GameTypePickerItem : TabItem @@ -38,7 +40,8 @@ namespace osu.Game.Screens.Multi.Components private readonly CircularContainer hover, selection; - public GameTypePickerItem(GameType value) : base(value) + public GameTypePickerItem(GameType value) + : base(value) { AutoSizeAxes = Axes.Both; @@ -81,6 +84,9 @@ namespace osu.Game.Screens.Multi.Components private void load(OsuColour colours) { selection.Colour = colours.Yellow; + + if (!Value.IsAvailable) + Colour = colours.Gray5; } protected override bool OnHover(HoverEvent e) @@ -95,6 +101,13 @@ namespace osu.Game.Screens.Multi.Components base.OnHoverLost(e); } + protected override bool OnClick(ClickEvent e) + { + if (!Value.IsAvailable) + return true; + return base.OnClick(e); + } + protected override void OnActivated() { selection.FadeIn(transition_duration, Easing.OutQuint);