mirror of
https://github.com/ppy/osu.git
synced 2025-02-12 03:43:22 +08:00
Merge branch 'master' into skin-editor-load-gameplay
This commit is contained in:
commit
e8730fae84
@ -175,6 +175,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
|
||||
if (controlPointCount > 2 || (controlPointCount == 2 && HitObject.Path.ControlPoints.Last() != cursor))
|
||||
return base.OnDragStart(e);
|
||||
|
||||
bSplineBuilder.AddLinearPoint(Vector2.Zero);
|
||||
bSplineBuilder.AddLinearPoint(ToLocalSpace(e.ScreenSpaceMouseDownPosition) - HitObject.Position);
|
||||
state = SliderPlacementState.Drawing;
|
||||
return true;
|
||||
|
@ -35,7 +35,7 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
() => Game.Notifications.AllNotifications.Count(x => x.Text == EditorStrings.MustBeInEditorToHandleLinks),
|
||||
() => Is.EqualTo(1));
|
||||
|
||||
AddStep("enter song select", () => Game.ChildrenOfType<ButtonSystem>().Single().OnSolo.Invoke());
|
||||
AddStep("enter song select", () => Game.ChildrenOfType<ButtonSystem>().Single().OnSolo?.Invoke());
|
||||
AddUntilStep("entered song select", () => Game.ScreenStack.CurrentScreen is PlaySongSelect);
|
||||
|
||||
addStepClickLink("00:00:000 (1)", waitForSeek: false);
|
||||
|
@ -43,7 +43,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
private TestSpectatorClient spectatorClient => dependenciesScreen.SpectatorClient;
|
||||
private DependenciesScreen dependenciesScreen;
|
||||
private SoloSpectator spectatorScreen;
|
||||
private SoloSpectatorScreen spectatorScreen;
|
||||
|
||||
private BeatmapSetInfo importedBeatmap;
|
||||
private int importedBeatmapId;
|
||||
@ -100,19 +100,18 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
start();
|
||||
|
||||
AddUntilStep("wait for player loader", () => (Stack.CurrentScreen as PlayerLoader)?.IsLoaded == true);
|
||||
AddUntilStep("wait for player loader", () => this.ChildrenOfType<PlayerLoader>().SingleOrDefault()?.IsLoaded == true);
|
||||
|
||||
AddUntilStep("queue send frames on player load", () =>
|
||||
{
|
||||
var loadingPlayer = (Stack.CurrentScreen as PlayerLoader)?.CurrentPlayer;
|
||||
var loadingPlayer = this.ChildrenOfType<PlayerLoader>().SingleOrDefault()?.CurrentPlayer;
|
||||
|
||||
if (loadingPlayer == null)
|
||||
return false;
|
||||
|
||||
loadingPlayer.OnLoadComplete += _ =>
|
||||
{
|
||||
spectatorClient.SendFramesFromUser(streamingUser.Id, 10, gameplay_start);
|
||||
};
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
@ -127,7 +126,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
loadSpectatingScreen();
|
||||
|
||||
AddAssert("screen hasn't changed", () => Stack.CurrentScreen is SoloSpectator);
|
||||
AddAssert("screen hasn't changed", () => Stack.CurrentScreen is SoloSpectatorScreen);
|
||||
|
||||
start();
|
||||
waitForPlayer();
|
||||
@ -255,7 +254,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
start(-1234);
|
||||
sendFrames();
|
||||
|
||||
AddAssert("screen didn't change", () => Stack.CurrentScreen is SoloSpectator);
|
||||
AddAssert("screen didn't change", () => Stack.CurrentScreen is SoloSpectatorScreen);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -333,6 +332,8 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
AddStep("send quit", () => spectatorClient.SendEndPlay(streamingUser.Id));
|
||||
AddUntilStep("state is quit", () => spectatorClient.WatchedUserStates[streamingUser.Id].State == SpectatedUserState.Quit);
|
||||
|
||||
AddAssert("wait for player exit", () => Stack.CurrentScreen is SoloSpectatorScreen);
|
||||
|
||||
start();
|
||||
sendFrames();
|
||||
waitForPlayer();
|
||||
@ -360,12 +361,12 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
private OsuFramedReplayInputHandler replayHandler =>
|
||||
(OsuFramedReplayInputHandler)Stack.ChildrenOfType<OsuInputManager>().First().ReplayInputHandler;
|
||||
|
||||
private Player player => Stack.CurrentScreen as Player;
|
||||
private Player player => this.ChildrenOfType<Player>().Single();
|
||||
|
||||
private double currentFrameStableTime
|
||||
=> player.ChildrenOfType<FrameStabilityContainer>().First().CurrentTime;
|
||||
|
||||
private void waitForPlayer() => AddUntilStep("wait for player", () => (Stack.CurrentScreen as Player)?.IsLoaded == true);
|
||||
private void waitForPlayer() => AddUntilStep("wait for player", () => this.ChildrenOfType<Player>().SingleOrDefault()?.IsLoaded == true);
|
||||
|
||||
private void start(int? beatmapId = null) => AddStep("start play", () => spectatorClient.SendStartPlay(streamingUser.Id, beatmapId ?? importedBeatmapId));
|
||||
|
||||
@ -381,7 +382,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
private void loadSpectatingScreen()
|
||||
{
|
||||
AddStep("load spectator", () => LoadScreen(spectatorScreen = new SoloSpectator(streamingUser)));
|
||||
AddStep("load spectator", () => LoadScreen(spectatorScreen = new SoloSpectatorScreen(streamingUser)));
|
||||
AddUntilStep("wait for screen load", () => spectatorScreen.LoadState == LoadState.Loaded);
|
||||
}
|
||||
|
||||
|
@ -239,7 +239,7 @@ namespace osu.Game.Tests.Visual.Navigation
|
||||
{
|
||||
AddUntilStep("wait for dialog overlay", () => Game.ChildrenOfType<DialogOverlay>().SingleOrDefault() != null);
|
||||
|
||||
AddStep("open editor", () => Game.ChildrenOfType<ButtonSystem>().Single().OnEdit.Invoke());
|
||||
AddStep("open editor", () => Game.ChildrenOfType<ButtonSystem>().Single().OnEditBeatmap?.Invoke());
|
||||
AddUntilStep("wait for editor", () => Game.ScreenStack.CurrentScreen is Editor editor && editor.IsLoaded);
|
||||
AddStep("click on file", () =>
|
||||
{
|
||||
|
@ -97,7 +97,7 @@ namespace osu.Game.Tests.Visual.Navigation
|
||||
[Test]
|
||||
public void TestFromSongSelectWithFilter([Values] ScorePresentType type)
|
||||
{
|
||||
AddStep("enter song select", () => Game.ChildrenOfType<ButtonSystem>().Single().OnSolo.Invoke());
|
||||
AddStep("enter song select", () => Game.ChildrenOfType<ButtonSystem>().Single().OnSolo?.Invoke());
|
||||
AddUntilStep("song select is current", () => Game.ScreenStack.CurrentScreen is PlaySongSelect songSelect && songSelect.BeatmapSetsLoaded);
|
||||
|
||||
AddStep("filter to nothing", () => ((PlaySongSelect)Game.ScreenStack.CurrentScreen).FilterControl.CurrentTextSearch.Value = "fdsajkl;fgewq");
|
||||
@ -110,7 +110,7 @@ namespace osu.Game.Tests.Visual.Navigation
|
||||
[Test]
|
||||
public void TestFromSongSelectWithConvertRulesetChange([Values] ScorePresentType type)
|
||||
{
|
||||
AddStep("enter song select", () => Game.ChildrenOfType<ButtonSystem>().Single().OnSolo.Invoke());
|
||||
AddStep("enter song select", () => Game.ChildrenOfType<ButtonSystem>().Single().OnSolo?.Invoke());
|
||||
AddUntilStep("song select is current", () => Game.ScreenStack.CurrentScreen is PlaySongSelect songSelect && songSelect.BeatmapSetsLoaded);
|
||||
|
||||
AddStep("set convert to false", () => Game.LocalConfig.SetValue(OsuSetting.ShowConvertedBeatmaps, false));
|
||||
@ -122,7 +122,7 @@ namespace osu.Game.Tests.Visual.Navigation
|
||||
[Test]
|
||||
public void TestFromSongSelect([Values] ScorePresentType type)
|
||||
{
|
||||
AddStep("enter song select", () => Game.ChildrenOfType<ButtonSystem>().Single().OnSolo.Invoke());
|
||||
AddStep("enter song select", () => Game.ChildrenOfType<ButtonSystem>().Single().OnSolo?.Invoke());
|
||||
AddUntilStep("song select is current", () => Game.ScreenStack.CurrentScreen is PlaySongSelect songSelect && songSelect.BeatmapSetsLoaded);
|
||||
|
||||
var firstImport = importScore(1);
|
||||
@ -135,7 +135,7 @@ namespace osu.Game.Tests.Visual.Navigation
|
||||
[Test]
|
||||
public void TestFromSongSelectDifferentRuleset([Values] ScorePresentType type)
|
||||
{
|
||||
AddStep("enter song select", () => Game.ChildrenOfType<ButtonSystem>().Single().OnSolo.Invoke());
|
||||
AddStep("enter song select", () => Game.ChildrenOfType<ButtonSystem>().Single().OnSolo?.Invoke());
|
||||
AddUntilStep("song select is current", () => Game.ScreenStack.CurrentScreen is PlaySongSelect songSelect && songSelect.BeatmapSetsLoaded);
|
||||
|
||||
var firstImport = importScore(1);
|
||||
|
@ -180,11 +180,8 @@ namespace osu.Game.Tests.Visual.Online
|
||||
});
|
||||
AddStep("Show overlay", () => chatOverlay.Show());
|
||||
AddAssert("Overlay uses config height", () => chatOverlay.Height == configChatHeight.Default);
|
||||
AddStep("Click top bar", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(chatOverlayTopBar);
|
||||
InputManager.PressButton(MouseButton.Left);
|
||||
});
|
||||
AddStep("Move mouse to drag bar", () => InputManager.MoveMouseTo(chatOverlayTopBar.DragBar));
|
||||
AddStep("Click drag bar", () => InputManager.PressButton(MouseButton.Left));
|
||||
AddStep("Drag overlay to new height", () => InputManager.MoveMouseTo(chatOverlayTopBar, new Vector2(0, -300)));
|
||||
AddStep("Stop dragging", () => InputManager.ReleaseButton(MouseButton.Left));
|
||||
AddStep("Store new height", () => newHeight = chatOverlay.Height);
|
||||
|
@ -67,14 +67,15 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
AddStep("Enter mode", performEnterMode);
|
||||
}
|
||||
|
||||
[TestCase(Key.P, true)]
|
||||
[TestCase(Key.M, true)]
|
||||
[TestCase(Key.L, true)]
|
||||
[TestCase(Key.E, false)]
|
||||
[TestCase(Key.D, false)]
|
||||
[TestCase(Key.Q, false)]
|
||||
[TestCase(Key.O, false)]
|
||||
public void TestShortcutKeys(Key key, bool entersPlay)
|
||||
[TestCase(Key.P, Key.P)]
|
||||
[TestCase(Key.M, Key.P)]
|
||||
[TestCase(Key.L, Key.P)]
|
||||
[TestCase(Key.B, Key.E)]
|
||||
[TestCase(Key.S, Key.E)]
|
||||
[TestCase(Key.D, null)]
|
||||
[TestCase(Key.Q, null)]
|
||||
[TestCase(Key.O, null)]
|
||||
public void TestShortcutKeys(Key key, Key? subMenuEnterKey)
|
||||
{
|
||||
int activationCount = -1;
|
||||
AddStep("set up action", () =>
|
||||
@ -96,8 +97,12 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
buttons.OnPlaylists = action;
|
||||
break;
|
||||
|
||||
case Key.E:
|
||||
buttons.OnEdit = action;
|
||||
case Key.B:
|
||||
buttons.OnEditBeatmap = action;
|
||||
break;
|
||||
|
||||
case Key.S:
|
||||
buttons.OnEditSkin = action;
|
||||
break;
|
||||
|
||||
case Key.D:
|
||||
@ -117,10 +122,10 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
AddStep($"press {key}", () => InputManager.Key(key));
|
||||
AddAssert("state is top level", () => buttons.State == ButtonSystemState.TopLevel);
|
||||
|
||||
if (entersPlay)
|
||||
if (subMenuEnterKey != null)
|
||||
{
|
||||
AddStep("press P", () => InputManager.Key(Key.P));
|
||||
AddAssert("state is play", () => buttons.State == ButtonSystemState.Play);
|
||||
AddStep($"press {subMenuEnterKey}", () => InputManager.Key(subMenuEnterKey.Value));
|
||||
AddAssert("state is not top menu", () => buttons.State != ButtonSystemState.TopLevel);
|
||||
}
|
||||
|
||||
AddStep($"press {key}", () => InputManager.Key(key));
|
||||
|
@ -9,6 +9,11 @@ namespace osu.Game.Localisation
|
||||
{
|
||||
private const string prefix = @"osu.Game.Resources.Localisation.Editor";
|
||||
|
||||
/// <summary>
|
||||
/// "Beatmap editor"
|
||||
/// </summary>
|
||||
public static LocalisableString BeatmapEditor => new TranslatableString(getKey(@"beatmap_editor"), @"Beatmap editor");
|
||||
|
||||
/// <summary>
|
||||
/// "Waveform opacity"
|
||||
/// </summary>
|
||||
|
@ -48,7 +48,7 @@ namespace osu.Game.Online.Spectator
|
||||
/// <summary>
|
||||
/// Whether the local user is playing.
|
||||
/// </summary>
|
||||
protected internal bool IsPlaying { get; private set; }
|
||||
private bool isPlaying { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Called whenever new frames arrive from the server.
|
||||
@ -58,17 +58,17 @@ namespace osu.Game.Online.Spectator
|
||||
/// <summary>
|
||||
/// Called whenever a user starts a play session, or immediately if the user is being watched and currently in a play session.
|
||||
/// </summary>
|
||||
public virtual event Action<int, SpectatorState>? OnUserBeganPlaying;
|
||||
public event Action<int, SpectatorState>? OnUserBeganPlaying;
|
||||
|
||||
/// <summary>
|
||||
/// Called whenever a user finishes a play session.
|
||||
/// </summary>
|
||||
public virtual event Action<int, SpectatorState>? OnUserFinishedPlaying;
|
||||
public event Action<int, SpectatorState>? OnUserFinishedPlaying;
|
||||
|
||||
/// <summary>
|
||||
/// Called whenever a user-submitted score has been fully processed.
|
||||
/// </summary>
|
||||
public virtual event Action<int, long>? OnUserScoreProcessed;
|
||||
public event Action<int, long>? OnUserScoreProcessed;
|
||||
|
||||
/// <summary>
|
||||
/// A dictionary containing all users currently being watched, with the number of watching components for each user.
|
||||
@ -114,7 +114,7 @@ namespace osu.Game.Online.Spectator
|
||||
}
|
||||
|
||||
// re-send state in case it wasn't received
|
||||
if (IsPlaying)
|
||||
if (isPlaying)
|
||||
// TODO: this is likely sent out of order after a reconnect scenario. needs further consideration.
|
||||
BeginPlayingInternal(currentScoreToken, currentState);
|
||||
}
|
||||
@ -179,10 +179,10 @@ namespace osu.Game.Online.Spectator
|
||||
// This schedule is only here to match the one below in `EndPlaying`.
|
||||
Schedule(() =>
|
||||
{
|
||||
if (IsPlaying)
|
||||
if (isPlaying)
|
||||
throw new InvalidOperationException($"Cannot invoke {nameof(BeginPlaying)} when already playing");
|
||||
|
||||
IsPlaying = true;
|
||||
isPlaying = true;
|
||||
|
||||
// transfer state at point of beginning play
|
||||
currentState.BeatmapID = score.ScoreInfo.BeatmapInfo!.OnlineID;
|
||||
@ -202,7 +202,7 @@ namespace osu.Game.Online.Spectator
|
||||
|
||||
public void HandleFrame(ReplayFrame frame) => Schedule(() =>
|
||||
{
|
||||
if (!IsPlaying)
|
||||
if (!isPlaying)
|
||||
{
|
||||
Logger.Log($"Frames arrived at {nameof(SpectatorClient)} outside of gameplay scope and will be ignored.");
|
||||
return;
|
||||
@ -224,7 +224,7 @@ namespace osu.Game.Online.Spectator
|
||||
// We probably need to find a better way to handle this...
|
||||
Schedule(() =>
|
||||
{
|
||||
if (!IsPlaying)
|
||||
if (!isPlaying)
|
||||
return;
|
||||
|
||||
// Disposal can take some time, leading to EndPlaying potentially being called after a future play session.
|
||||
@ -235,7 +235,7 @@ namespace osu.Game.Online.Spectator
|
||||
if (pendingFrames.Count > 0)
|
||||
purgePendingFrames();
|
||||
|
||||
IsPlaying = false;
|
||||
isPlaying = false;
|
||||
currentBeatmap = null;
|
||||
|
||||
if (state.HasPassed)
|
||||
|
@ -1,8 +1,8 @@
|
||||
// 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 osu.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
@ -13,25 +13,22 @@ using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Resources.Localisation.Web;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Overlays.Chat
|
||||
{
|
||||
public partial class ChatOverlayTopBar : Container
|
||||
{
|
||||
private Box background = null!;
|
||||
|
||||
private Color4 backgroundColour;
|
||||
public Drawable DragBar { get; private set; } = null!;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OverlayColourProvider colourProvider, TextureStore textures)
|
||||
{
|
||||
Children = new Drawable[]
|
||||
Children = new[]
|
||||
{
|
||||
background = new Box
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = backgroundColour = colourProvider.Background3,
|
||||
Colour = colourProvider.Background3,
|
||||
},
|
||||
new GridContainer
|
||||
{
|
||||
@ -50,7 +47,7 @@ namespace osu.Game.Overlays.Chat
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Icon = HexaconsIcons.Social,
|
||||
Size = new Vector2(18),
|
||||
Size = new Vector2(24),
|
||||
},
|
||||
// Placeholder text
|
||||
new OsuSpriteText
|
||||
@ -64,19 +61,92 @@ namespace osu.Game.Overlays.Chat
|
||||
},
|
||||
},
|
||||
},
|
||||
DragBar = new DragArea
|
||||
{
|
||||
Alpha = RuntimeInfo.IsMobile ? 1 : 0,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Colour = colourProvider.Background4,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected override bool OnHover(HoverEvent e)
|
||||
{
|
||||
background.FadeColour(backgroundColour.Lighten(0.1f), 300, Easing.OutQuint);
|
||||
if (!RuntimeInfo.IsMobile)
|
||||
DragBar.FadeIn(100);
|
||||
return base.OnHover(e);
|
||||
}
|
||||
|
||||
protected override void OnHoverLost(HoverLostEvent e)
|
||||
{
|
||||
background.FadeColour(backgroundColour, 300, Easing.OutQuint);
|
||||
if (!RuntimeInfo.IsMobile)
|
||||
DragBar.FadeOut(100);
|
||||
base.OnHoverLost(e);
|
||||
}
|
||||
|
||||
private partial class DragArea : CompositeDrawable
|
||||
{
|
||||
private readonly Circle circle;
|
||||
|
||||
public DragArea()
|
||||
{
|
||||
AutoSizeAxes = Axes.Both;
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
circle = new Circle
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Size = new Vector2(150, 7),
|
||||
Margin = new MarginPadding(12),
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected override bool OnHover(HoverEvent e)
|
||||
{
|
||||
updateScale();
|
||||
return base.OnHover(e);
|
||||
}
|
||||
|
||||
protected override void OnHoverLost(HoverLostEvent e)
|
||||
{
|
||||
updateScale();
|
||||
base.OnHoverLost(e);
|
||||
}
|
||||
|
||||
private bool dragging;
|
||||
|
||||
protected override bool OnMouseDown(MouseDownEvent e)
|
||||
{
|
||||
dragging = true;
|
||||
updateScale();
|
||||
return base.OnMouseDown(e);
|
||||
}
|
||||
|
||||
protected override void OnMouseUp(MouseUpEvent e)
|
||||
{
|
||||
dragging = false;
|
||||
updateScale();
|
||||
base.OnMouseUp(e);
|
||||
}
|
||||
|
||||
private void updateScale()
|
||||
{
|
||||
if (dragging || IsHovered)
|
||||
circle.FadeIn(100);
|
||||
else
|
||||
circle.FadeTo(0.6f, 100);
|
||||
|
||||
if (dragging)
|
||||
circle.ScaleTo(1f, 400, Easing.OutQuint);
|
||||
else if (IsHovered)
|
||||
circle.ScaleTo(1.05f, 400, Easing.OutElasticHalf);
|
||||
else
|
||||
circle.ScaleTo(1f, 500, Easing.OutQuint);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -253,10 +253,14 @@ namespace osu.Game.Overlays
|
||||
{
|
||||
}
|
||||
|
||||
protected override bool OnMouseDown(MouseDownEvent e)
|
||||
{
|
||||
isDraggingTopBar = topBar.DragBar.IsHovered;
|
||||
return base.OnMouseDown(e);
|
||||
}
|
||||
|
||||
protected override bool OnDragStart(DragStartEvent e)
|
||||
{
|
||||
isDraggingTopBar = topBar.IsHovered;
|
||||
|
||||
if (!isDraggingTopBar)
|
||||
return base.OnDragStart(e);
|
||||
|
||||
|
@ -212,7 +212,7 @@ namespace osu.Game.Overlays.Dashboard
|
||||
Text = "Spectate",
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
Action = () => performer?.PerformFromScreen(s => s.Push(new SoloSpectator(User))),
|
||||
Action = () => performer?.PerformFromScreen(s => s.Push(new SoloSpectatorScreen(User))),
|
||||
Enabled = { Value = User.Id != api.LocalUser.Value.Id }
|
||||
}
|
||||
}
|
||||
|
@ -1,18 +1,16 @@
|
||||
// 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.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using osu.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Audio.Sample;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Framework.Extensions.LocalisationExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
@ -36,29 +34,29 @@ namespace osu.Game.Screens.Menu
|
||||
{
|
||||
public partial class ButtonSystem : Container, IStateful<ButtonSystemState>, IKeyBindingHandler<GlobalAction>
|
||||
{
|
||||
public event Action<ButtonSystemState> StateChanged;
|
||||
|
||||
private readonly IBindable<bool> isIdle = new BindableBool();
|
||||
|
||||
public Action OnEdit;
|
||||
public Action OnExit;
|
||||
public Action OnBeatmapListing;
|
||||
public Action OnSolo;
|
||||
public Action OnSettings;
|
||||
public Action OnMultiplayer;
|
||||
public Action OnPlaylists;
|
||||
|
||||
public const float BUTTON_WIDTH = 140f;
|
||||
public const float WEDGE_WIDTH = 20;
|
||||
|
||||
[CanBeNull]
|
||||
private OsuLogo logo;
|
||||
public event Action<ButtonSystemState>? StateChanged;
|
||||
|
||||
public Action? OnEditBeatmap;
|
||||
public Action? OnEditSkin;
|
||||
public Action? OnExit;
|
||||
public Action? OnBeatmapListing;
|
||||
public Action? OnSolo;
|
||||
public Action? OnSettings;
|
||||
public Action? OnMultiplayer;
|
||||
public Action? OnPlaylists;
|
||||
|
||||
private readonly IBindable<bool> isIdle = new BindableBool();
|
||||
|
||||
private OsuLogo? logo;
|
||||
|
||||
/// <summary>
|
||||
/// Assign the <see cref="OsuLogo"/> that this ButtonSystem should manage the position of.
|
||||
/// </summary>
|
||||
/// <param name="logo">The instance of the logo to be assigned. If null, we are suspending from the screen that uses this ButtonSystem.</param>
|
||||
public void SetOsuLogo(OsuLogo logo)
|
||||
public void SetOsuLogo(OsuLogo? logo)
|
||||
{
|
||||
this.logo = logo;
|
||||
|
||||
@ -84,9 +82,10 @@ namespace osu.Game.Screens.Menu
|
||||
|
||||
private readonly List<MainMenuButton> buttonsTopLevel = new List<MainMenuButton>();
|
||||
private readonly List<MainMenuButton> buttonsPlay = new List<MainMenuButton>();
|
||||
private readonly List<MainMenuButton> buttonsEdit = new List<MainMenuButton>();
|
||||
|
||||
private Sample sampleBackToLogo;
|
||||
private Sample sampleLogoSwoosh;
|
||||
private Sample? sampleBackToLogo;
|
||||
private Sample? sampleLogoSwoosh;
|
||||
|
||||
private readonly LogoTrackingContainer logoTrackingContainer;
|
||||
|
||||
@ -108,7 +107,8 @@ namespace osu.Game.Screens.Menu
|
||||
backButton = new MainMenuButton(ButtonSystemStrings.Back, @"back-to-top", OsuIcon.LeftCircle, new Color4(51, 58, 94, 255), () => State = ButtonSystemState.TopLevel,
|
||||
-WEDGE_WIDTH)
|
||||
{
|
||||
VisibleState = ButtonSystemState.Play,
|
||||
VisibleStateMin = ButtonSystemState.Play,
|
||||
VisibleStateMax = ButtonSystemState.Edit,
|
||||
},
|
||||
logoTrackingContainer.LogoFacade.With(d => d.Scale = new Vector2(0.74f))
|
||||
});
|
||||
@ -116,31 +116,36 @@ namespace osu.Game.Screens.Menu
|
||||
buttonArea.Flow.CentreTarget = logoTrackingContainer.LogoFacade;
|
||||
}
|
||||
|
||||
[Resolved(CanBeNull = true)]
|
||||
private OsuGame game { get; set; }
|
||||
[Resolved]
|
||||
private IAPIProvider api { get; set; } = null!;
|
||||
|
||||
[Resolved]
|
||||
private IAPIProvider api { get; set; }
|
||||
private OsuGame? game { get; set; }
|
||||
|
||||
[Resolved(CanBeNull = true)]
|
||||
private LoginOverlay loginOverlay { get; set; }
|
||||
[Resolved]
|
||||
private LoginOverlay? loginOverlay { get; set; }
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load(AudioManager audio, IdleTracker idleTracker, GameHost host)
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(AudioManager audio, IdleTracker? idleTracker, GameHost host)
|
||||
{
|
||||
buttonsPlay.Add(new MainMenuButton(ButtonSystemStrings.Solo, @"button-default-select", FontAwesome.Solid.User, new Color4(102, 68, 204, 255), () => OnSolo?.Invoke(), WEDGE_WIDTH, Key.P));
|
||||
buttonsPlay.Add(new MainMenuButton(ButtonSystemStrings.Multi, @"button-default-select", FontAwesome.Solid.Users, new Color4(94, 63, 186, 255), onMultiplayer, 0, Key.M));
|
||||
buttonsPlay.Add(new MainMenuButton(ButtonSystemStrings.Playlists, @"button-default-select", OsuIcon.Charts, new Color4(94, 63, 186, 255), onPlaylists, 0, Key.L));
|
||||
buttonsPlay.ForEach(b => b.VisibleState = ButtonSystemState.Play);
|
||||
|
||||
buttonsEdit.Add(new MainMenuButton(EditorStrings.BeatmapEditor.ToLower(), @"button-default-select", HexaconsIcons.Beatmap, new Color4(238, 170, 0, 255), () => OnEditBeatmap?.Invoke(), WEDGE_WIDTH, Key.B));
|
||||
buttonsEdit.Add(new MainMenuButton(SkinEditorStrings.SkinEditor.ToLower(), @"button-default-select", HexaconsIcons.Editor, new Color4(220, 160, 0, 255), () => OnEditSkin?.Invoke(), 0, Key.S));
|
||||
buttonsEdit.ForEach(b => b.VisibleState = ButtonSystemState.Edit);
|
||||
|
||||
buttonsTopLevel.Add(new MainMenuButton(ButtonSystemStrings.Play, @"button-play-select", OsuIcon.Logo, new Color4(102, 68, 204, 255), () => State = ButtonSystemState.Play, WEDGE_WIDTH, Key.P));
|
||||
buttonsTopLevel.Add(new MainMenuButton(ButtonSystemStrings.Edit, @"button-default-select", OsuIcon.EditCircle, new Color4(238, 170, 0, 255), () => OnEdit?.Invoke(), 0, Key.E));
|
||||
buttonsTopLevel.Add(new MainMenuButton(ButtonSystemStrings.Edit, @"button-play-select", OsuIcon.EditCircle, new Color4(238, 170, 0, 255), () => State = ButtonSystemState.Edit, 0, Key.E));
|
||||
buttonsTopLevel.Add(new MainMenuButton(ButtonSystemStrings.Browse, @"button-default-select", OsuIcon.ChevronDownCircle, new Color4(165, 204, 0, 255), () => OnBeatmapListing?.Invoke(), 0, Key.B, Key.D));
|
||||
|
||||
if (host.CanExit)
|
||||
buttonsTopLevel.Add(new MainMenuButton(ButtonSystemStrings.Exit, string.Empty, OsuIcon.CrossCircle, new Color4(238, 51, 153, 255), () => OnExit?.Invoke(), 0, Key.Q));
|
||||
|
||||
buttonArea.AddRange(buttonsPlay);
|
||||
buttonArea.AddRange(buttonsEdit);
|
||||
buttonArea.AddRange(buttonsTopLevel);
|
||||
|
||||
buttonArea.ForEach(b =>
|
||||
@ -270,6 +275,7 @@ namespace osu.Game.Screens.Menu
|
||||
|
||||
return true;
|
||||
|
||||
case ButtonSystemState.Edit:
|
||||
case ButtonSystemState.Play:
|
||||
StopSamplePlayback();
|
||||
backButton.TriggerClick();
|
||||
@ -305,6 +311,10 @@ namespace osu.Game.Screens.Menu
|
||||
case ButtonSystemState.Play:
|
||||
buttonsPlay.First().TriggerClick();
|
||||
return false;
|
||||
|
||||
case ButtonSystemState.Edit:
|
||||
buttonsEdit.First().TriggerClick();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -328,6 +338,8 @@ namespace osu.Game.Screens.Menu
|
||||
|
||||
Logger.Log($"{nameof(ButtonSystem)}'s state changed from {lastState} to {state}");
|
||||
|
||||
buttonArea.FinishTransforms(true);
|
||||
|
||||
using (buttonArea.BeginDelayedSequence(lastState == ButtonSystemState.Initial ? 150 : 0))
|
||||
{
|
||||
buttonArea.ButtonSystemState = state;
|
||||
@ -340,7 +352,7 @@ namespace osu.Game.Screens.Menu
|
||||
}
|
||||
}
|
||||
|
||||
private ScheduledDelegate logoDelayedAction;
|
||||
private ScheduledDelegate? logoDelayedAction;
|
||||
|
||||
private void updateLogoState(ButtonSystemState lastState = ButtonSystemState.Initial)
|
||||
{
|
||||
@ -414,6 +426,7 @@ namespace osu.Game.Screens.Menu
|
||||
Initial,
|
||||
TopLevel,
|
||||
Play,
|
||||
Edit,
|
||||
EnteringMode,
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ using osu.Game.Input.Bindings;
|
||||
using osu.Game.IO;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Overlays.SkinEditor;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Screens.Backgrounds;
|
||||
using osu.Game.Screens.Edit;
|
||||
@ -93,6 +94,9 @@ namespace osu.Game.Screens.Menu
|
||||
|
||||
private Sample reappearSampleSwoosh;
|
||||
|
||||
[Resolved(canBeNull: true)]
|
||||
private SkinEditorOverlay skinEditor { get; set; }
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load(BeatmapListingOverlay beatmapListing, SettingsOverlay settings, OsuConfigManager config, SessionStatics statics, AudioManager audio)
|
||||
{
|
||||
@ -120,11 +124,15 @@ namespace osu.Game.Screens.Menu
|
||||
{
|
||||
Buttons = new ButtonSystem
|
||||
{
|
||||
OnEdit = delegate
|
||||
OnEditBeatmap = () =>
|
||||
{
|
||||
Beatmap.SetDefault();
|
||||
this.Push(new EditorLoader());
|
||||
},
|
||||
OnEditSkin = () =>
|
||||
{
|
||||
skinEditor?.Show();
|
||||
},
|
||||
OnSolo = loadSoloSongSelect,
|
||||
OnMultiplayer = () => this.Push(new Multiplayer()),
|
||||
OnPlaylists = () => this.Push(new Playlists()),
|
||||
|
@ -1,8 +1,6 @@
|
||||
// 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.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using osu.Framework;
|
||||
@ -33,7 +31,7 @@ namespace osu.Game.Screens.Menu
|
||||
/// </summary>
|
||||
public partial class MainMenuButton : BeatSyncedContainer, IStateful<ButtonState>
|
||||
{
|
||||
public event Action<ButtonState> StateChanged;
|
||||
public event Action<ButtonState>? StateChanged;
|
||||
|
||||
public readonly Key[] TriggerKeys;
|
||||
|
||||
@ -44,18 +42,28 @@ namespace osu.Game.Screens.Menu
|
||||
private readonly string sampleName;
|
||||
|
||||
/// <summary>
|
||||
/// The menu state for which we are visible for.
|
||||
/// The menu state for which we are visible for (assuming only one).
|
||||
/// </summary>
|
||||
public ButtonSystemState VisibleState = ButtonSystemState.TopLevel;
|
||||
public ButtonSystemState VisibleState
|
||||
{
|
||||
set
|
||||
{
|
||||
VisibleStateMin = value;
|
||||
VisibleStateMax = value;
|
||||
}
|
||||
}
|
||||
|
||||
private readonly Action clickAction;
|
||||
private Sample sampleClick;
|
||||
private Sample sampleHover;
|
||||
private SampleChannel sampleChannel;
|
||||
public ButtonSystemState VisibleStateMin = ButtonSystemState.TopLevel;
|
||||
public ButtonSystemState VisibleStateMax = ButtonSystemState.TopLevel;
|
||||
|
||||
private readonly Action? clickAction;
|
||||
private Sample? sampleClick;
|
||||
private Sample? sampleHover;
|
||||
private SampleChannel? sampleChannel;
|
||||
|
||||
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => box.ReceivePositionalInputAt(screenSpacePos);
|
||||
|
||||
public MainMenuButton(LocalisableString text, string sampleName, IconUsage symbol, Color4 colour, Action clickAction = null, float extraWidth = 0, params Key[] triggerKeys)
|
||||
public MainMenuButton(LocalisableString text, string sampleName, IconUsage symbol, Color4 colour, Action? clickAction = null, float extraWidth = 0, params Key[] triggerKeys)
|
||||
{
|
||||
this.sampleName = sampleName;
|
||||
this.clickAction = clickAction;
|
||||
@ -315,9 +323,9 @@ namespace osu.Game.Screens.Menu
|
||||
break;
|
||||
|
||||
default:
|
||||
if (value == VisibleState)
|
||||
if (value <= VisibleStateMax && value >= VisibleStateMin)
|
||||
State = ButtonState.Expanded;
|
||||
else if (value < VisibleState)
|
||||
else if (value < VisibleStateMin)
|
||||
State = ButtonState.Contracted;
|
||||
else
|
||||
State = ButtonState.Exploded;
|
||||
|
@ -228,7 +228,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
|
||||
{
|
||||
}
|
||||
|
||||
protected override void StartGameplay(int userId, SpectatorGameplayState spectatorGameplayState)
|
||||
protected override void StartGameplay(int userId, SpectatorGameplayState spectatorGameplayState) => Schedule(() =>
|
||||
{
|
||||
var playerArea = instances.Single(i => i.UserId == userId);
|
||||
|
||||
@ -242,9 +242,9 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
|
||||
return;
|
||||
|
||||
playerArea.LoadScore(spectatorGameplayState.Score);
|
||||
}
|
||||
});
|
||||
|
||||
protected override void QuitGameplay(int userId)
|
||||
protected override void QuitGameplay(int userId) => Schedule(() =>
|
||||
{
|
||||
RemoveUser(userId);
|
||||
|
||||
@ -252,7 +252,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
|
||||
|
||||
instance.FadeColour(colours.Gray4, 400, Easing.OutQuint);
|
||||
syncManager.RemoveManagedClock(instance.SpectatorPlayerClock);
|
||||
}
|
||||
});
|
||||
|
||||
public override bool OnBackButton()
|
||||
{
|
||||
|
@ -1,10 +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.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System.Diagnostics;
|
||||
using JetBrains.Annotations;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
@ -33,41 +30,40 @@ using osuTK;
|
||||
namespace osu.Game.Screens.Play
|
||||
{
|
||||
[Cached(typeof(IPreviewTrackOwner))]
|
||||
public partial class SoloSpectator : SpectatorScreen, IPreviewTrackOwner
|
||||
public partial class SoloSpectatorScreen : SpectatorScreen, IPreviewTrackOwner
|
||||
{
|
||||
[NotNull]
|
||||
private readonly APIUser targetUser;
|
||||
[Resolved]
|
||||
private IAPIProvider api { get; set; } = null!;
|
||||
|
||||
[Resolved]
|
||||
private IAPIProvider api { get; set; }
|
||||
private PreviewTrackManager previewTrackManager { get; set; } = null!;
|
||||
|
||||
[Resolved]
|
||||
private PreviewTrackManager previewTrackManager { get; set; }
|
||||
private BeatmapManager beatmaps { get; set; } = null!;
|
||||
|
||||
[Resolved]
|
||||
private BeatmapManager beatmaps { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private BeatmapModelDownloader beatmapDownloader { get; set; }
|
||||
private BeatmapModelDownloader beatmapDownloader { get; set; } = null!;
|
||||
|
||||
[Cached]
|
||||
private OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Purple);
|
||||
|
||||
private Container beatmapPanelContainer;
|
||||
private RoundedButton watchButton;
|
||||
private SettingsCheckbox automaticDownload;
|
||||
private Container beatmapPanelContainer = null!;
|
||||
private RoundedButton watchButton = null!;
|
||||
private SettingsCheckbox automaticDownload = null!;
|
||||
|
||||
private readonly APIUser targetUser;
|
||||
|
||||
/// <summary>
|
||||
/// The player's immediate online gameplay state.
|
||||
/// This doesn't always reflect the gameplay state being watched.
|
||||
/// </summary>
|
||||
private SpectatorGameplayState immediateSpectatorGameplayState;
|
||||
private SpectatorGameplayState? immediateSpectatorGameplayState;
|
||||
|
||||
private GetBeatmapSetRequest onlineBeatmapRequest;
|
||||
private GetBeatmapSetRequest? onlineBeatmapRequest;
|
||||
|
||||
private APIBeatmapSet beatmapSet;
|
||||
private APIBeatmapSet? beatmapSet;
|
||||
|
||||
public SoloSpectator([NotNull] APIUser targetUser)
|
||||
public SoloSpectatorScreen(APIUser targetUser)
|
||||
: base(targetUser.Id)
|
||||
{
|
||||
this.targetUser = targetUser;
|
||||
@ -168,27 +164,33 @@ namespace osu.Game.Screens.Play
|
||||
automaticDownload.Current.BindValueChanged(_ => checkForAutomaticDownload());
|
||||
}
|
||||
|
||||
protected override void OnNewPlayingUserState(int userId, SpectatorState spectatorState)
|
||||
protected override void OnNewPlayingUserState(int userId, SpectatorState spectatorState) => Schedule(() =>
|
||||
{
|
||||
clearDisplay();
|
||||
showBeatmapPanel(spectatorState);
|
||||
}
|
||||
});
|
||||
|
||||
protected override void StartGameplay(int userId, SpectatorGameplayState spectatorGameplayState)
|
||||
protected override void StartGameplay(int userId, SpectatorGameplayState spectatorGameplayState) => Schedule(() =>
|
||||
{
|
||||
immediateSpectatorGameplayState = spectatorGameplayState;
|
||||
watchButton.Enabled.Value = true;
|
||||
|
||||
scheduleStart(spectatorGameplayState);
|
||||
}
|
||||
});
|
||||
|
||||
protected override void QuitGameplay(int userId)
|
||||
{
|
||||
scheduledStart?.Cancel();
|
||||
immediateSpectatorGameplayState = null;
|
||||
watchButton.Enabled.Value = false;
|
||||
// Importantly, don't schedule this call, as a child screen may be present (and will cause the schedule to not be run as expected).
|
||||
this.MakeCurrent();
|
||||
|
||||
clearDisplay();
|
||||
Schedule(() =>
|
||||
{
|
||||
scheduledStart?.Cancel();
|
||||
immediateSpectatorGameplayState = null;
|
||||
watchButton.Enabled.Value = false;
|
||||
|
||||
clearDisplay();
|
||||
});
|
||||
}
|
||||
|
||||
private void clearDisplay()
|
||||
@ -199,10 +201,12 @@ namespace osu.Game.Screens.Play
|
||||
previewTrackManager.StopAnyPlaying(this);
|
||||
}
|
||||
|
||||
private ScheduledDelegate scheduledStart;
|
||||
private ScheduledDelegate? scheduledStart;
|
||||
|
||||
private void scheduleStart(SpectatorGameplayState spectatorGameplayState)
|
||||
private void scheduleStart(SpectatorGameplayState? spectatorGameplayState)
|
||||
{
|
||||
Debug.Assert(spectatorGameplayState != null);
|
||||
|
||||
// This function may be called multiple times in quick succession once the screen becomes current again.
|
||||
scheduledStart?.Cancel();
|
||||
scheduledStart = Schedule(() =>
|
@ -1,13 +1,10 @@
|
||||
// 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.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions;
|
||||
@ -33,22 +30,27 @@ namespace osu.Game.Screens.Spectate
|
||||
private readonly List<int> users = new List<int>();
|
||||
|
||||
[Resolved]
|
||||
private BeatmapManager beatmaps { get; set; }
|
||||
private BeatmapManager beatmaps { get; set; } = null!;
|
||||
|
||||
[Resolved]
|
||||
private RulesetStore rulesets { get; set; }
|
||||
private RulesetStore rulesets { get; set; } = null!;
|
||||
|
||||
[Resolved]
|
||||
private SpectatorClient spectatorClient { get; set; }
|
||||
private SpectatorClient spectatorClient { get; set; } = null!;
|
||||
|
||||
[Resolved]
|
||||
private UserLookupCache userLookupCache { get; set; }
|
||||
private UserLookupCache userLookupCache { get; set; } = null!;
|
||||
|
||||
[Resolved]
|
||||
private RealmAccess realm { get; set; } = null!;
|
||||
|
||||
private readonly IBindableDictionary<int, SpectatorState> userStates = new BindableDictionary<int, SpectatorState>();
|
||||
|
||||
private readonly Dictionary<int, APIUser> userMap = new Dictionary<int, APIUser>();
|
||||
private readonly Dictionary<int, SpectatorGameplayState> gameplayStates = new Dictionary<int, SpectatorGameplayState>();
|
||||
|
||||
private IDisposable? realmSubscription;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="SpectatorScreen"/>.
|
||||
/// </summary>
|
||||
@ -58,11 +60,6 @@ namespace osu.Game.Screens.Spectate
|
||||
this.users.AddRange(users);
|
||||
}
|
||||
|
||||
[Resolved]
|
||||
private RealmAccess realm { get; set; }
|
||||
|
||||
private IDisposable realmSubscription;
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
@ -90,7 +87,7 @@ namespace osu.Game.Screens.Spectate
|
||||
}));
|
||||
}
|
||||
|
||||
private void beatmapsChanged(IRealmCollection<BeatmapSetInfo> items, ChangeSet changes)
|
||||
private void beatmapsChanged(IRealmCollection<BeatmapSetInfo> items, ChangeSet? changes)
|
||||
{
|
||||
if (changes?.InsertedIndices == null) return;
|
||||
|
||||
@ -109,7 +106,7 @@ namespace osu.Game.Screens.Spectate
|
||||
}
|
||||
}
|
||||
|
||||
private void onUserStatesChanged(object sender, NotifyDictionaryChangedEventArgs<int, SpectatorState> e)
|
||||
private void onUserStatesChanged(object? sender, NotifyDictionaryChangedEventArgs<int, SpectatorState> e)
|
||||
{
|
||||
switch (e.Action)
|
||||
{
|
||||
@ -132,7 +129,7 @@ namespace osu.Game.Screens.Spectate
|
||||
switch (newState.State)
|
||||
{
|
||||
case SpectatedUserState.Playing:
|
||||
Schedule(() => OnNewPlayingUserState(userId, newState));
|
||||
OnNewPlayingUserState(userId, newState);
|
||||
startGameplay(userId);
|
||||
break;
|
||||
|
||||
@ -176,7 +173,7 @@ namespace osu.Game.Screens.Spectate
|
||||
var gameplayState = new SpectatorGameplayState(score, resolvedRuleset, beatmaps.GetWorkingBeatmap(resolvedBeatmap));
|
||||
|
||||
gameplayStates[userId] = gameplayState;
|
||||
Schedule(() => StartGameplay(userId, gameplayState));
|
||||
StartGameplay(userId, gameplayState);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -199,25 +196,28 @@ namespace osu.Game.Screens.Spectate
|
||||
markReceivedAllFrames(userId);
|
||||
|
||||
gameplayStates.Remove(userId);
|
||||
Schedule(() => QuitGameplay(userId));
|
||||
QuitGameplay(userId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when a spectated user's state has changed to a new state indicating the player is currently playing.
|
||||
/// Thread safety is not guaranteed – should be scheduled as required.
|
||||
/// </summary>
|
||||
/// <param name="userId">The user whose state has changed.</param>
|
||||
/// <param name="spectatorState">The new state.</param>
|
||||
protected abstract void OnNewPlayingUserState(int userId, [NotNull] SpectatorState spectatorState);
|
||||
protected abstract void OnNewPlayingUserState(int userId, SpectatorState spectatorState);
|
||||
|
||||
/// <summary>
|
||||
/// Starts gameplay for a user.
|
||||
/// Thread safety is not guaranteed – should be scheduled as required.
|
||||
/// </summary>
|
||||
/// <param name="userId">The user to start gameplay for.</param>
|
||||
/// <param name="spectatorGameplayState">The gameplay state.</param>
|
||||
protected abstract void StartGameplay(int userId, [NotNull] SpectatorGameplayState spectatorGameplayState);
|
||||
protected abstract void StartGameplay(int userId, SpectatorGameplayState spectatorGameplayState);
|
||||
|
||||
/// <summary>
|
||||
/// Quits gameplay for a user.
|
||||
/// Thread safety is not guaranteed – should be scheduled as required.
|
||||
/// </summary>
|
||||
/// <param name="userId">The user to quit gameplay for.</param>
|
||||
protected abstract void QuitGameplay(int userId);
|
||||
@ -243,7 +243,7 @@ namespace osu.Game.Screens.Spectate
|
||||
{
|
||||
base.Dispose(isDisposing);
|
||||
|
||||
if (spectatorClient != null)
|
||||
if (spectatorClient.IsNotNull())
|
||||
{
|
||||
foreach ((int userId, var _) in userMap)
|
||||
spectatorClient.StopWatchingUser(userId);
|
||||
|
Loading…
Reference in New Issue
Block a user