mirror of
https://github.com/osukey/osukey.git
synced 2025-06-05 12:57:39 +09:00
Merge pull request #11208 from smoogipoo/realtime-ready-button
Implement the realtime multiplayer ready button
This commit is contained in:
commit
c37840b37c
@ -0,0 +1,135 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System.Linq;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Audio;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Platform;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Online.Multiplayer;
|
||||||
|
using osu.Game.Online.RealtimeMultiplayer;
|
||||||
|
using osu.Game.Rulesets;
|
||||||
|
using osu.Game.Screens.Multi.RealtimeMultiplayer;
|
||||||
|
using osu.Game.Tests.Resources;
|
||||||
|
using osu.Game.Users;
|
||||||
|
using osuTK;
|
||||||
|
using osuTK.Input;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Visual.RealtimeMultiplayer
|
||||||
|
{
|
||||||
|
public class TestSceneRealtimeReadyButton : RealtimeMultiplayerTestScene
|
||||||
|
{
|
||||||
|
private RealtimeReadyButton button;
|
||||||
|
|
||||||
|
private BeatmapManager beatmaps;
|
||||||
|
private RulesetStore rulesets;
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(GameHost host, AudioManager audio)
|
||||||
|
{
|
||||||
|
Dependencies.Cache(rulesets = new RulesetStore(ContextFactory));
|
||||||
|
Dependencies.Cache(beatmaps = new BeatmapManager(LocalStorage, ContextFactory, rulesets, null, audio, host, Beatmap.Default));
|
||||||
|
beatmaps.Import(TestResources.GetTestBeatmapForImport(true)).Wait();
|
||||||
|
}
|
||||||
|
|
||||||
|
[SetUp]
|
||||||
|
public new void Setup() => Schedule(() =>
|
||||||
|
{
|
||||||
|
var beatmap = beatmaps.GetAllUsableBeatmapSetsEnumerable(IncludedDetails.All).First().Beatmaps.First();
|
||||||
|
|
||||||
|
Beatmap.Value = beatmaps.GetWorkingBeatmap(beatmap);
|
||||||
|
|
||||||
|
Child = button = new RealtimeReadyButton
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Size = new Vector2(200, 50),
|
||||||
|
SelectedItem =
|
||||||
|
{
|
||||||
|
Value = new PlaylistItem
|
||||||
|
{
|
||||||
|
Beatmap = { Value = beatmap },
|
||||||
|
Ruleset = { Value = beatmap.Ruleset }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Client.AddUser(API.LocalUser.Value);
|
||||||
|
});
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestToggleStateWhenNotHost()
|
||||||
|
{
|
||||||
|
AddStep("add second user as host", () =>
|
||||||
|
{
|
||||||
|
Client.AddUser(new User { Id = 2, Username = "Another user" });
|
||||||
|
Client.TransferHost(2);
|
||||||
|
});
|
||||||
|
|
||||||
|
addClickButtonStep();
|
||||||
|
AddAssert("user is ready", () => Client.Room?.Users[0].State == MultiplayerUserState.Ready);
|
||||||
|
|
||||||
|
addClickButtonStep();
|
||||||
|
AddAssert("user is idle", () => Client.Room?.Users[0].State == MultiplayerUserState.Idle);
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestCase(true)]
|
||||||
|
[TestCase(false)]
|
||||||
|
public void TestToggleStateWhenHost(bool allReady)
|
||||||
|
{
|
||||||
|
AddStep("setup", () =>
|
||||||
|
{
|
||||||
|
Client.TransferHost(Client.Room?.Users[0].UserID ?? 0);
|
||||||
|
|
||||||
|
if (!allReady)
|
||||||
|
Client.AddUser(new User { Id = 2, Username = "Another user" });
|
||||||
|
});
|
||||||
|
|
||||||
|
addClickButtonStep();
|
||||||
|
AddAssert("user is ready", () => Client.Room?.Users[0].State == MultiplayerUserState.Ready);
|
||||||
|
|
||||||
|
addClickButtonStep();
|
||||||
|
AddAssert("match started", () => Client.Room?.Users[0].State == MultiplayerUserState.WaitingForLoad);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestBecomeHostWhileReady()
|
||||||
|
{
|
||||||
|
AddStep("add host", () =>
|
||||||
|
{
|
||||||
|
Client.AddUser(new User { Id = 2, Username = "Another user" });
|
||||||
|
Client.TransferHost(2);
|
||||||
|
});
|
||||||
|
|
||||||
|
addClickButtonStep();
|
||||||
|
AddStep("make user host", () => Client.TransferHost(Client.Room?.Users[0].UserID ?? 0));
|
||||||
|
|
||||||
|
addClickButtonStep();
|
||||||
|
AddAssert("match started", () => Client.Room?.Users[0].State == MultiplayerUserState.WaitingForLoad);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestLoseHostWhileReady()
|
||||||
|
{
|
||||||
|
AddStep("setup", () =>
|
||||||
|
{
|
||||||
|
Client.TransferHost(Client.Room?.Users[0].UserID ?? 0);
|
||||||
|
Client.AddUser(new User { Id = 2, Username = "Another user" });
|
||||||
|
});
|
||||||
|
|
||||||
|
addClickButtonStep();
|
||||||
|
AddStep("transfer host", () => Client.TransferHost(Client.Room?.Users[1].UserID ?? 0));
|
||||||
|
|
||||||
|
addClickButtonStep();
|
||||||
|
AddAssert("match not started", () => Client.Room?.Users[0].State == MultiplayerUserState.Idle);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addClickButtonStep() => AddStep("click button", () =>
|
||||||
|
{
|
||||||
|
InputManager.MoveMouseTo(button);
|
||||||
|
InputManager.Click(MouseButton.Left);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -81,7 +81,9 @@ namespace osu.Game.Online.RealtimeMultiplayer
|
|||||||
/// <param name="room">The API <see cref="Room"/>.</param>
|
/// <param name="room">The API <see cref="Room"/>.</param>
|
||||||
public async Task JoinRoom(Room room)
|
public async Task JoinRoom(Room room)
|
||||||
{
|
{
|
||||||
Debug.Assert(Room == null);
|
if (Room != null)
|
||||||
|
throw new InvalidOperationException("Cannot join a multiplayer room while already in one.");
|
||||||
|
|
||||||
Debug.Assert(room.RoomID.Value != null);
|
Debug.Assert(room.RoomID.Value != null);
|
||||||
|
|
||||||
apiRoom = room;
|
apiRoom = room;
|
||||||
@ -164,6 +166,9 @@ namespace osu.Game.Online.RealtimeMultiplayer
|
|||||||
|
|
||||||
Task IMultiplayerClient.RoomStateChanged(MultiplayerRoomState state)
|
Task IMultiplayerClient.RoomStateChanged(MultiplayerRoomState state)
|
||||||
{
|
{
|
||||||
|
if (Room == null)
|
||||||
|
return Task.CompletedTask;
|
||||||
|
|
||||||
Schedule(() =>
|
Schedule(() =>
|
||||||
{
|
{
|
||||||
if (Room == null)
|
if (Room == null)
|
||||||
@ -196,6 +201,9 @@ namespace osu.Game.Online.RealtimeMultiplayer
|
|||||||
|
|
||||||
async Task IMultiplayerClient.UserJoined(MultiplayerRoomUser user)
|
async Task IMultiplayerClient.UserJoined(MultiplayerRoomUser user)
|
||||||
{
|
{
|
||||||
|
if (Room == null)
|
||||||
|
return;
|
||||||
|
|
||||||
await PopulateUser(user);
|
await PopulateUser(user);
|
||||||
|
|
||||||
Schedule(() =>
|
Schedule(() =>
|
||||||
@ -211,6 +219,9 @@ namespace osu.Game.Online.RealtimeMultiplayer
|
|||||||
|
|
||||||
Task IMultiplayerClient.UserLeft(MultiplayerRoomUser user)
|
Task IMultiplayerClient.UserLeft(MultiplayerRoomUser user)
|
||||||
{
|
{
|
||||||
|
if (Room == null)
|
||||||
|
return Task.CompletedTask;
|
||||||
|
|
||||||
Schedule(() =>
|
Schedule(() =>
|
||||||
{
|
{
|
||||||
if (Room == null)
|
if (Room == null)
|
||||||
@ -227,6 +238,9 @@ namespace osu.Game.Online.RealtimeMultiplayer
|
|||||||
|
|
||||||
Task IMultiplayerClient.HostChanged(int userId)
|
Task IMultiplayerClient.HostChanged(int userId)
|
||||||
{
|
{
|
||||||
|
if (Room == null)
|
||||||
|
return Task.CompletedTask;
|
||||||
|
|
||||||
Schedule(() =>
|
Schedule(() =>
|
||||||
{
|
{
|
||||||
if (Room == null)
|
if (Room == null)
|
||||||
@ -253,6 +267,9 @@ namespace osu.Game.Online.RealtimeMultiplayer
|
|||||||
|
|
||||||
Task IMultiplayerClient.UserStateChanged(int userId, MultiplayerUserState state)
|
Task IMultiplayerClient.UserStateChanged(int userId, MultiplayerUserState state)
|
||||||
{
|
{
|
||||||
|
if (Room == null)
|
||||||
|
return Task.CompletedTask;
|
||||||
|
|
||||||
Schedule(() =>
|
Schedule(() =>
|
||||||
{
|
{
|
||||||
if (Room == null)
|
if (Room == null)
|
||||||
@ -271,6 +288,9 @@ namespace osu.Game.Online.RealtimeMultiplayer
|
|||||||
|
|
||||||
Task IMultiplayerClient.LoadRequested()
|
Task IMultiplayerClient.LoadRequested()
|
||||||
{
|
{
|
||||||
|
if (Room == null)
|
||||||
|
return Task.CompletedTask;
|
||||||
|
|
||||||
Schedule(() =>
|
Schedule(() =>
|
||||||
{
|
{
|
||||||
if (Room == null)
|
if (Room == null)
|
||||||
@ -284,15 +304,15 @@ namespace osu.Game.Online.RealtimeMultiplayer
|
|||||||
|
|
||||||
Task IMultiplayerClient.MatchStarted()
|
Task IMultiplayerClient.MatchStarted()
|
||||||
{
|
{
|
||||||
Debug.Assert(Room != null);
|
if (Room == null)
|
||||||
var players = Room.Users.Where(u => u.State == MultiplayerUserState.Playing).Select(u => u.UserID).ToList();
|
return Task.CompletedTask;
|
||||||
|
|
||||||
Schedule(() =>
|
Schedule(() =>
|
||||||
{
|
{
|
||||||
if (Room == null)
|
if (Room == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
PlayingUsers.AddRange(players);
|
PlayingUsers.AddRange(Room.Users.Where(u => u.State == MultiplayerUserState.Playing).Select(u => u.UserID));
|
||||||
|
|
||||||
MatchStarted?.Invoke();
|
MatchStarted?.Invoke();
|
||||||
});
|
});
|
||||||
@ -302,6 +322,9 @@ namespace osu.Game.Online.RealtimeMultiplayer
|
|||||||
|
|
||||||
Task IMultiplayerClient.ResultsReady()
|
Task IMultiplayerClient.ResultsReady()
|
||||||
{
|
{
|
||||||
|
if (Room == null)
|
||||||
|
return Task.CompletedTask;
|
||||||
|
|
||||||
Schedule(() =>
|
Schedule(() =>
|
||||||
{
|
{
|
||||||
if (Room == null)
|
if (Room == null)
|
||||||
|
@ -11,28 +11,22 @@ using osu.Game.Graphics;
|
|||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Online.Multiplayer;
|
using osu.Game.Online.Multiplayer;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Multi.Match.Components
|
namespace osu.Game.Screens.Multi.Components
|
||||||
{
|
{
|
||||||
public class ReadyButton : TriangleButton
|
public abstract class ReadyButton : TriangleButton
|
||||||
{
|
{
|
||||||
public readonly Bindable<PlaylistItem> SelectedItem = new Bindable<PlaylistItem>();
|
public readonly Bindable<PlaylistItem> SelectedItem = new Bindable<PlaylistItem>();
|
||||||
|
|
||||||
[Resolved(typeof(Room), nameof(Room.EndDate))]
|
public new readonly BindableBool Enabled = new BindableBool();
|
||||||
private Bindable<DateTimeOffset> endDate { get; set; }
|
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private IBindable<WorkingBeatmap> gameBeatmap { get; set; }
|
protected IBindable<WorkingBeatmap> GameBeatmap { get; private set; }
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private BeatmapManager beatmaps { get; set; }
|
private BeatmapManager beatmaps { get; set; }
|
||||||
|
|
||||||
private bool hasBeatmap;
|
private bool hasBeatmap;
|
||||||
|
|
||||||
public ReadyButton()
|
|
||||||
{
|
|
||||||
Text = "Start";
|
|
||||||
}
|
|
||||||
|
|
||||||
private IBindable<WeakReference<BeatmapSetInfo>> managerUpdated;
|
private IBindable<WeakReference<BeatmapSetInfo>> managerUpdated;
|
||||||
private IBindable<WeakReference<BeatmapSetInfo>> managerRemoved;
|
private IBindable<WeakReference<BeatmapSetInfo>> managerRemoved;
|
||||||
|
|
||||||
@ -45,10 +39,6 @@ namespace osu.Game.Screens.Multi.Match.Components
|
|||||||
managerRemoved.BindValueChanged(beatmapRemoved);
|
managerRemoved.BindValueChanged(beatmapRemoved);
|
||||||
|
|
||||||
SelectedItem.BindValueChanged(item => updateSelectedItem(item.NewValue), true);
|
SelectedItem.BindValueChanged(item => updateSelectedItem(item.NewValue), true);
|
||||||
|
|
||||||
BackgroundColour = colours.Green;
|
|
||||||
Triangles.ColourDark = colours.Green;
|
|
||||||
Triangles.ColourLight = colours.GreenLight;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateSelectedItem(PlaylistItem item)
|
private void updateSelectedItem(PlaylistItem item)
|
||||||
@ -94,15 +84,13 @@ namespace osu.Game.Screens.Multi.Match.Components
|
|||||||
|
|
||||||
private void updateEnabledState()
|
private void updateEnabledState()
|
||||||
{
|
{
|
||||||
if (gameBeatmap.Value == null || SelectedItem.Value == null)
|
if (GameBeatmap.Value == null || SelectedItem.Value == null)
|
||||||
{
|
{
|
||||||
Enabled.Value = false;
|
base.Enabled.Value = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hasEnoughTime = DateTimeOffset.UtcNow.AddSeconds(30).AddMilliseconds(gameBeatmap.Value.Track.Length) < endDate.Value;
|
base.Enabled.Value = hasBeatmap && Enabled.Value;
|
||||||
|
|
||||||
Enabled.Value = hasBeatmap && hasEnoughTime;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -10,6 +10,7 @@ using osu.Framework.Graphics.Containers;
|
|||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Online.Multiplayer;
|
using osu.Game.Online.Multiplayer;
|
||||||
|
using osu.Game.Screens.Multi.Timeshift;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Multi.Match.Components
|
namespace osu.Game.Screens.Multi.Match.Components
|
||||||
@ -31,7 +32,7 @@ namespace osu.Game.Screens.Multi.Match.Components
|
|||||||
InternalChildren = new[]
|
InternalChildren = new[]
|
||||||
{
|
{
|
||||||
background = new Box { RelativeSizeAxes = Axes.Both },
|
background = new Box { RelativeSizeAxes = Axes.Both },
|
||||||
new ReadyButton
|
new TimeshiftReadyButton
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
|
@ -0,0 +1,123 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Linq;
|
||||||
|
using JetBrains.Annotations;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Graphics.Backgrounds;
|
||||||
|
using osu.Game.Online.API;
|
||||||
|
using osu.Game.Online.Multiplayer;
|
||||||
|
using osu.Game.Online.RealtimeMultiplayer;
|
||||||
|
using osu.Game.Screens.Multi.Components;
|
||||||
|
using osuTK;
|
||||||
|
|
||||||
|
namespace osu.Game.Screens.Multi.RealtimeMultiplayer
|
||||||
|
{
|
||||||
|
public class RealtimeReadyButton : RealtimeRoomComposite
|
||||||
|
{
|
||||||
|
public Bindable<PlaylistItem> SelectedItem => button.SelectedItem;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private IAPIProvider api { get; set; }
|
||||||
|
|
||||||
|
[CanBeNull]
|
||||||
|
private MultiplayerRoomUser localUser;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private OsuColour colours { get; set; }
|
||||||
|
|
||||||
|
private readonly ButtonWithTrianglesExposed button;
|
||||||
|
|
||||||
|
public RealtimeReadyButton()
|
||||||
|
{
|
||||||
|
InternalChild = button = new ButtonWithTrianglesExposed
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Size = Vector2.One,
|
||||||
|
Enabled = { Value = true },
|
||||||
|
Action = onClick
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnRoomChanged()
|
||||||
|
{
|
||||||
|
base.OnRoomChanged();
|
||||||
|
|
||||||
|
localUser = Room?.Users.Single(u => u.User?.Id == api.LocalUser.Value.Id);
|
||||||
|
button.Enabled.Value = Client.Room?.State == MultiplayerRoomState.Open;
|
||||||
|
updateState();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateState()
|
||||||
|
{
|
||||||
|
if (localUser == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Debug.Assert(Room != null);
|
||||||
|
|
||||||
|
switch (localUser.State)
|
||||||
|
{
|
||||||
|
case MultiplayerUserState.Idle:
|
||||||
|
button.Text = "Ready";
|
||||||
|
updateButtonColour(true);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MultiplayerUserState.Ready:
|
||||||
|
if (Room?.Host?.Equals(localUser) == true)
|
||||||
|
{
|
||||||
|
int countReady = Room.Users.Count(u => u.State == MultiplayerUserState.Ready);
|
||||||
|
button.Text = $"Start match ({countReady} / {Room.Users.Count} ready)";
|
||||||
|
updateButtonColour(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
button.Text = "Waiting for host...";
|
||||||
|
updateButtonColour(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateButtonColour(bool green)
|
||||||
|
{
|
||||||
|
if (green)
|
||||||
|
{
|
||||||
|
button.BackgroundColour = colours.Green;
|
||||||
|
button.Triangles.ColourDark = colours.Green;
|
||||||
|
button.Triangles.ColourLight = colours.GreenLight;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
button.BackgroundColour = colours.YellowDark;
|
||||||
|
button.Triangles.ColourDark = colours.YellowDark;
|
||||||
|
button.Triangles.ColourLight = colours.Yellow;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onClick()
|
||||||
|
{
|
||||||
|
if (localUser == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (localUser.State == MultiplayerUserState.Idle)
|
||||||
|
Client.ChangeState(MultiplayerUserState.Ready);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (Room?.Host?.Equals(localUser) == true)
|
||||||
|
Client.StartMatch();
|
||||||
|
else
|
||||||
|
Client.ChangeState(MultiplayerUserState.Idle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ButtonWithTrianglesExposed : ReadyButton
|
||||||
|
{
|
||||||
|
public new Triangles Triangles => base.Triangles;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -51,7 +51,7 @@ namespace osu.Game.Screens.Multi.RealtimeMultiplayer
|
|||||||
var joinedRoom = JoinedRoom.Value;
|
var joinedRoom = JoinedRoom.Value;
|
||||||
|
|
||||||
base.PartRoom();
|
base.PartRoom();
|
||||||
multiplayerClient.LeaveRoom().Wait();
|
multiplayerClient.LeaveRoom();
|
||||||
|
|
||||||
// Todo: This is not the way to do this. Basically when we're the only participant and the room closes, there's no way to know if this is actually the case.
|
// Todo: This is not the way to do this. Basically when we're the only participant and the room closes, there's no way to know if this is actually the case.
|
||||||
// This is delayed one frame because upon exiting the match subscreen, multiplayer updates the polling rate and messes with polling.
|
// This is delayed one frame because upon exiting the match subscreen, multiplayer updates the polling rate and messes with polling.
|
||||||
|
38
osu.Game/Screens/Multi/Timeshift/TimeshiftReadyButton.cs
Normal file
38
osu.Game/Screens/Multi/Timeshift/TimeshiftReadyButton.cs
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Online.Multiplayer;
|
||||||
|
using osu.Game.Screens.Multi.Components;
|
||||||
|
|
||||||
|
namespace osu.Game.Screens.Multi.Timeshift
|
||||||
|
{
|
||||||
|
public class TimeshiftReadyButton : ReadyButton
|
||||||
|
{
|
||||||
|
[Resolved(typeof(Room), nameof(Room.EndDate))]
|
||||||
|
private Bindable<DateTimeOffset> endDate { get; set; }
|
||||||
|
|
||||||
|
public TimeshiftReadyButton()
|
||||||
|
{
|
||||||
|
Text = "Start";
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OsuColour colours)
|
||||||
|
{
|
||||||
|
BackgroundColour = colours.Green;
|
||||||
|
Triangles.ColourDark = colours.Green;
|
||||||
|
Triangles.ColourLight = colours.GreenLight;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Update()
|
||||||
|
{
|
||||||
|
base.Update();
|
||||||
|
|
||||||
|
Enabled.Value = DateTimeOffset.UtcNow.AddSeconds(30).AddMilliseconds(GameBeatmap.Value.Track.Length) < endDate.Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user