mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 22:22:55 +08:00
Move ready-up logic to match sub-screen
This commit is contained in:
parent
903dca875e
commit
9ff2140232
@ -1,6 +1,7 @@
|
||||
// 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.Framework.Extensions.Color4Extensions;
|
||||
@ -19,7 +20,13 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
|
||||
|
||||
public readonly Bindable<PlaylistItem> SelectedItem = new Bindable<PlaylistItem>();
|
||||
|
||||
public Action OnReady
|
||||
{
|
||||
set => readyButton.OnReady = value;
|
||||
}
|
||||
|
||||
private readonly Drawable background;
|
||||
private readonly MultiplayerReadyButton readyButton;
|
||||
|
||||
public MultiplayerMatchFooter()
|
||||
{
|
||||
@ -29,7 +36,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
|
||||
InternalChildren = new[]
|
||||
{
|
||||
background = new Box { RelativeSizeAxes = Axes.Both },
|
||||
new MultiplayerReadyButton
|
||||
readyButton = new MultiplayerReadyButton
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
|
@ -1,15 +1,14 @@
|
||||
// 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 System.Diagnostics;
|
||||
using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Audio.Sample;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Extensions;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Backgrounds;
|
||||
using osu.Game.Online.API;
|
||||
@ -24,6 +23,11 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
|
||||
{
|
||||
public Bindable<PlaylistItem> SelectedItem => button.SelectedItem;
|
||||
|
||||
public Action OnReady
|
||||
{
|
||||
set => button.Action = value;
|
||||
}
|
||||
|
||||
[Resolved]
|
||||
private IAPIProvider api { get; set; }
|
||||
|
||||
@ -47,7 +51,6 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Size = Vector2.One,
|
||||
Enabled = { Value = true },
|
||||
Action = onClick
|
||||
};
|
||||
}
|
||||
|
||||
@ -136,27 +139,6 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
|
||||
}
|
||||
}
|
||||
|
||||
private void onClick()
|
||||
{
|
||||
var localUser = Client.LocalUser;
|
||||
|
||||
if (localUser == null)
|
||||
return;
|
||||
|
||||
if (localUser.State == MultiplayerUserState.Idle)
|
||||
Client.ChangeState(MultiplayerUserState.Ready).CatchUnobservedExceptions(true);
|
||||
else
|
||||
{
|
||||
if (Room?.Host?.Equals(localUser) == true)
|
||||
{
|
||||
gameplayStartTracker.BeginOperation();
|
||||
Client.StartMatch().CatchUnobservedExceptions(true);
|
||||
}
|
||||
else
|
||||
Client.ChangeState(MultiplayerUserState.Idle).CatchUnobservedExceptions(true);
|
||||
}
|
||||
}
|
||||
|
||||
private class ButtonWithTrianglesExposed : ReadyButton
|
||||
{
|
||||
public new Triangles Triangles => base.Triangles;
|
||||
|
@ -9,6 +9,7 @@ using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Game.Extensions;
|
||||
using osu.Game.Online.Multiplayer;
|
||||
using osu.Game.Online.Rooms;
|
||||
using osu.Game.Screens.OnlinePlay.Components;
|
||||
@ -153,7 +154,11 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
||||
},
|
||||
new Drawable[]
|
||||
{
|
||||
new MultiplayerMatchFooter { SelectedItem = { BindTarget = SelectedItem } }
|
||||
new MultiplayerMatchFooter
|
||||
{
|
||||
SelectedItem = { BindTarget = SelectedItem },
|
||||
OnReady = onReady
|
||||
}
|
||||
}
|
||||
},
|
||||
RowDimensions = new[]
|
||||
@ -199,6 +204,27 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
||||
|
||||
private void onPlaylistChanged(object sender, NotifyCollectionChangedEventArgs e) => SelectedItem.Value = Playlist.FirstOrDefault();
|
||||
|
||||
private void onReady()
|
||||
{
|
||||
var localUser = client.LocalUser;
|
||||
|
||||
if (localUser == null)
|
||||
return;
|
||||
|
||||
if (localUser.State == MultiplayerUserState.Idle)
|
||||
client.ChangeState(MultiplayerUserState.Ready).CatchUnobservedExceptions(true);
|
||||
else
|
||||
{
|
||||
if (client.Room?.Host?.Equals(localUser) == true)
|
||||
{
|
||||
gameplayStartTracker.BeginOperation();
|
||||
client.StartMatch().CatchUnobservedExceptions(true);
|
||||
}
|
||||
else
|
||||
client.ChangeState(MultiplayerUserState.Idle).CatchUnobservedExceptions(true);
|
||||
}
|
||||
}
|
||||
|
||||
private void onLoadRequested()
|
||||
{
|
||||
Debug.Assert(client.Room != null);
|
||||
|
Loading…
Reference in New Issue
Block a user