1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 06:47:24 +08:00

Add timeshift game type

This commit is contained in:
smoogipoo 2018-12-04 18:58:45 +09:00
parent c469d12d63
commit ec83790734
5 changed files with 65 additions and 2 deletions

View File

@ -1,11 +1,14 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Collections.Generic;
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Online.Multiplayer; using osu.Game.Online.Multiplayer;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using osu.Game.Screens.Multi.Components;
using osu.Game.Screens.Multi.Screens.Match; using osu.Game.Screens.Multi.Screens.Match;
using osu.Game.Users; using osu.Game.Users;
@ -14,6 +17,12 @@ namespace osu.Game.Tests.Visual
[TestFixture] [TestFixture]
public class TestCaseMatch : OsuTestCase public class TestCaseMatch : OsuTestCase
{ {
public override IReadOnlyList<Type> RequiredTypes => new[]
{
typeof(TestCaseMatch),
typeof(GameTypePicker)
};
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(RulesetStore rulesets) private void load(RulesetStore rulesets)
{ {

View File

@ -1,6 +1,8 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Collections.Generic;
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Testing.Input; using osu.Framework.Testing.Input;
@ -13,6 +15,12 @@ namespace osu.Game.Tests.Visual
[TestFixture] [TestFixture]
public class TestCaseRoomSettings : ManualInputManagerTestCase public class TestCaseRoomSettings : ManualInputManagerTestCase
{ {
public override IReadOnlyList<Type> RequiredTypes => new[]
{
typeof(RoomSettingsOverlay),
typeof(GameTypePicker)
};
private readonly Room room; private readonly Room room;
private readonly TestRoomSettingsOverlay overlay; private readonly TestRoomSettingsOverlay overlay;

View File

@ -13,6 +13,9 @@ namespace osu.Game.Online.Multiplayer
public abstract class GameType public abstract class GameType
{ {
public abstract string Name { get; } public abstract string Name { get; }
public abstract bool IsAvailable { get; }
public abstract Drawable GetIcon(OsuColour colours, float size); public abstract Drawable GetIcon(OsuColour colours, float size);
public override int GetHashCode() => GetType().GetHashCode(); public override int GetHashCode() => GetType().GetHashCode();
@ -22,6 +25,9 @@ namespace osu.Game.Online.Multiplayer
public class GameTypeTag : GameType public class GameTypeTag : GameType
{ {
public override string Name => "Tag"; public override string Name => "Tag";
public override bool IsAvailable => false;
public override Drawable GetIcon(OsuColour colours, float size) public override Drawable GetIcon(OsuColour colours, float size)
{ {
return new SpriteIcon return new SpriteIcon
@ -39,6 +45,9 @@ namespace osu.Game.Online.Multiplayer
public class GameTypeVersus : GameType public class GameTypeVersus : GameType
{ {
public override string Name => "Versus"; public override string Name => "Versus";
public override bool IsAvailable => false;
public override Drawable GetIcon(OsuColour colours, float size) public override Drawable GetIcon(OsuColour colours, float size)
{ {
return new VersusRow(colours.Blue, colours.Blue, size * 0.6f) return new VersusRow(colours.Blue, colours.Blue, size * 0.6f)
@ -52,6 +61,9 @@ namespace osu.Game.Online.Multiplayer
public class GameTypeTagTeam : GameType public class GameTypeTagTeam : GameType
{ {
public override string Name => "Tag Team"; public override string Name => "Tag Team";
public override bool IsAvailable => false;
public override Drawable GetIcon(OsuColour colours, float size) public override Drawable GetIcon(OsuColour colours, float size)
{ {
return new FillFlowContainer return new FillFlowContainer
@ -85,6 +97,9 @@ namespace osu.Game.Online.Multiplayer
public class GameTypeTeamVersus : GameType public class GameTypeTeamVersus : GameType
{ {
public override string Name => "Team Versus"; public override string Name => "Team Versus";
public override bool IsAvailable => false;
public override Drawable GetIcon(OsuColour colours, float size) public override Drawable GetIcon(OsuColour colours, float size)
{ {
return new FillFlowContainer 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
};
}
} }

View File

@ -15,7 +15,7 @@ namespace osu.Game.Online.Multiplayer
public Bindable<User> Host = new Bindable<User>(); public Bindable<User> Host = new Bindable<User>();
public Bindable<RoomStatus> Status = new Bindable<RoomStatus>(new RoomStatusOpen()); public Bindable<RoomStatus> Status = new Bindable<RoomStatus>(new RoomStatusOpen());
public Bindable<RoomAvailability> Availability = new Bindable<RoomAvailability>(); public Bindable<RoomAvailability> Availability = new Bindable<RoomAvailability>();
public Bindable<GameType> Type = new Bindable<GameType>(new GameTypeVersus()); public Bindable<GameType> Type = new Bindable<GameType>(new GameTypeTimeshift());
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<IEnumerable<User>> Participants = new Bindable<IEnumerable<User>>(Enumerable.Empty<User>()); public Bindable<IEnumerable<User>> Participants = new Bindable<IEnumerable<User>>(Enumerable.Empty<User>());

View File

@ -19,6 +19,7 @@ namespace osu.Game.Screens.Multi.Components
private const float selection_width = 3; private const float selection_width = 3;
protected override TabItem<GameType> CreateTabItem(GameType value) => new GameTypePickerItem(value); protected override TabItem<GameType> CreateTabItem(GameType value) => new GameTypePickerItem(value);
protected override Dropdown<GameType> CreateDropdown() => null; protected override Dropdown<GameType> CreateDropdown() => null;
public GameTypePicker() public GameTypePicker()
@ -30,6 +31,7 @@ namespace osu.Game.Screens.Multi.Components
AddItem(new GameTypeVersus()); AddItem(new GameTypeVersus());
AddItem(new GameTypeTagTeam()); AddItem(new GameTypeTagTeam());
AddItem(new GameTypeTeamVersus()); AddItem(new GameTypeTeamVersus());
AddItem(new GameTypeTimeshift());
} }
private class GameTypePickerItem : TabItem<GameType> private class GameTypePickerItem : TabItem<GameType>
@ -38,7 +40,8 @@ namespace osu.Game.Screens.Multi.Components
private readonly CircularContainer hover, selection; private readonly CircularContainer hover, selection;
public GameTypePickerItem(GameType value) : base(value) public GameTypePickerItem(GameType value)
: base(value)
{ {
AutoSizeAxes = Axes.Both; AutoSizeAxes = Axes.Both;
@ -81,6 +84,9 @@ namespace osu.Game.Screens.Multi.Components
private void load(OsuColour colours) private void load(OsuColour colours)
{ {
selection.Colour = colours.Yellow; selection.Colour = colours.Yellow;
if (!Value.IsAvailable)
Colour = colours.Gray5;
} }
protected override bool OnHover(HoverEvent e) protected override bool OnHover(HoverEvent e)
@ -95,6 +101,13 @@ namespace osu.Game.Screens.Multi.Components
base.OnHoverLost(e); base.OnHoverLost(e);
} }
protected override bool OnClick(ClickEvent e)
{
if (!Value.IsAvailable)
return true;
return base.OnClick(e);
}
protected override void OnActivated() protected override void OnActivated()
{ {
selection.FadeIn(transition_duration, Easing.OutQuint); selection.FadeIn(transition_duration, Easing.OutQuint);