mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 23:07:26 +08:00
Merge remote-tracking branch 'origin/master' into gameplay-clock-container
# Conflicts: # osu.Game/Screens/Play/Player.cs
This commit is contained in:
commit
7c5ca67691
@ -1,7 +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.
|
||||
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Osu.UI;
|
||||
using osu.Game.Rulesets.UI;
|
||||
@ -16,8 +15,14 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
{
|
||||
}
|
||||
|
||||
protected override CursorContainer CreateCursor() => null;
|
||||
protected override Playfield CreatePlayfield() => new OsuPlayfieldNoCursor { Size = Vector2.One };
|
||||
|
||||
protected override Playfield CreatePlayfield() => new OsuPlayfield { Size = Vector2.One };
|
||||
private class OsuPlayfieldNoCursor : OsuPlayfield
|
||||
{
|
||||
public OsuPlayfieldNoCursor()
|
||||
{
|
||||
Cursor?.Expire();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
|
||||
public OsuCursor()
|
||||
{
|
||||
Origin = Anchor.Centre;
|
||||
Size = new Vector2(42);
|
||||
Size = new Vector2(28);
|
||||
}
|
||||
|
||||
protected override void SkinChanged(ISkinSource skin, bool allowFallback)
|
||||
|
@ -10,7 +10,9 @@ using osu.Game.Rulesets.Osu.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Osu.Objects.Drawables.Connections;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using System.Linq;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Osu.UI.Cursor;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.UI
|
||||
{
|
||||
@ -22,6 +24,12 @@ namespace osu.Game.Rulesets.Osu.UI
|
||||
|
||||
public static readonly Vector2 BASE_SIZE = new Vector2(512, 384);
|
||||
|
||||
private readonly PlayfieldAdjustmentContainer adjustmentContainer;
|
||||
|
||||
protected override Container CursorTargetContainer => adjustmentContainer;
|
||||
|
||||
protected override CursorContainer CreateCursor() => new GameplayCursorContainer();
|
||||
|
||||
public OsuPlayfield()
|
||||
{
|
||||
Anchor = Anchor.Centre;
|
||||
@ -29,7 +37,7 @@ namespace osu.Game.Rulesets.Osu.UI
|
||||
|
||||
Size = new Vector2(0.75f);
|
||||
|
||||
InternalChild = new PlayfieldAdjustmentContainer
|
||||
InternalChild = adjustmentContainer = new PlayfieldAdjustmentContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
|
@ -2,7 +2,6 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Linq;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Input;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Input.Handlers;
|
||||
@ -13,7 +12,6 @@ using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Osu.Replays;
|
||||
using osu.Game.Rulesets.Osu.Scoring;
|
||||
using osu.Game.Rulesets.Osu.UI.Cursor;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Rulesets.UI;
|
||||
|
||||
@ -59,7 +57,5 @@ namespace osu.Game.Rulesets.Osu.UI
|
||||
return first.StartTime - first.TimePreempt;
|
||||
}
|
||||
}
|
||||
|
||||
protected override CursorContainer CreateCursor() => new GameplayCursorContainer();
|
||||
}
|
||||
}
|
||||
|
@ -24,10 +24,13 @@ namespace osu.Game.Tests.Visual
|
||||
public TestCaseToolbar()
|
||||
{
|
||||
var toolbar = new Toolbar { State = Visibility.Visible };
|
||||
ToolbarNotificationButton notificationButton = null;
|
||||
|
||||
AddStep("create toolbar", () =>
|
||||
{
|
||||
Add(toolbar);
|
||||
|
||||
var notificationButton = toolbar.Children.OfType<FillFlowContainer>().Last().Children.OfType<ToolbarNotificationButton>().First();
|
||||
notificationButton = toolbar.Children.OfType<FillFlowContainer>().Last().Children.OfType<ToolbarNotificationButton>().First();
|
||||
});
|
||||
|
||||
void setNotifications(int count) => AddStep($"set notification count to {count}", () => notificationButton.NotificationCount.Value = count);
|
||||
|
||||
|
@ -70,13 +70,15 @@ namespace osu.Game.Online.API
|
||||
|
||||
internal new void Schedule(Action action) => base.Schedule(action);
|
||||
|
||||
/// <summary>
|
||||
/// Register a component to receive API events.
|
||||
/// Fires <see cref="IOnlineComponent.APIStateChanged"/> once immediately to ensure a correct state.
|
||||
/// </summary>
|
||||
/// <param name="component"></param>
|
||||
public void Register(IOnlineComponent component)
|
||||
{
|
||||
Scheduler.Add(delegate
|
||||
{
|
||||
components.Add(component);
|
||||
Scheduler.Add(delegate { components.Add(component); });
|
||||
component.APIStateChanged(this, state);
|
||||
});
|
||||
}
|
||||
|
||||
public void Unregister(IOnlineComponent component)
|
||||
|
@ -22,7 +22,7 @@ namespace osu.Game.Overlays.Toolbar
|
||||
|
||||
public Action OnHome;
|
||||
|
||||
private readonly ToolbarUserArea userArea;
|
||||
private ToolbarUserArea userArea;
|
||||
|
||||
protected override bool BlockPositionalInput => false;
|
||||
|
||||
@ -34,6 +34,13 @@ namespace osu.Game.Overlays.Toolbar
|
||||
private readonly Bindable<OverlayActivation> overlayActivationMode = new Bindable<OverlayActivation>(OverlayActivation.All);
|
||||
|
||||
public Toolbar()
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
Size = new Vector2(1, HEIGHT);
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load(OsuGame osuGame)
|
||||
{
|
||||
Children = new Drawable[]
|
||||
{
|
||||
@ -76,13 +83,6 @@ namespace osu.Game.Overlays.Toolbar
|
||||
}
|
||||
};
|
||||
|
||||
RelativeSizeAxes = Axes.X;
|
||||
Size = new Vector2(1, HEIGHT);
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load(OsuGame osuGame)
|
||||
{
|
||||
StateChanged += visibility =>
|
||||
{
|
||||
if (overlayActivationMode.Value == OverlayActivation.Disabled)
|
||||
|
@ -10,6 +10,7 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osuTK;
|
||||
@ -63,6 +64,10 @@ namespace osu.Game.Rulesets.UI
|
||||
private void load(IBindable<WorkingBeatmap> beatmap)
|
||||
{
|
||||
this.beatmap = beatmap.Value;
|
||||
|
||||
Cursor = CreateCursor();
|
||||
if (Cursor != null)
|
||||
CursorTargetContainer.Add(Cursor);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -82,6 +87,23 @@ namespace osu.Game.Rulesets.UI
|
||||
/// <param name="h">The DrawableHitObject to remove.</param>
|
||||
public virtual bool Remove(DrawableHitObject h) => HitObjectContainer.Remove(h);
|
||||
|
||||
/// <summary>
|
||||
/// The cursor currently being used by this <see cref="Playfield"/>. May be null if no cursor is provided.
|
||||
/// </summary>
|
||||
public CursorContainer Cursor { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Provide an optional cursor which is to be used for gameplay.
|
||||
/// If providing a cursor, <see cref="CursorTargetContainer"/> must also point to a valid target container.
|
||||
/// </summary>
|
||||
/// <returns>The cursor, or null if a cursor is not rqeuired.</returns>
|
||||
protected virtual CursorContainer CreateCursor() => null;
|
||||
|
||||
/// <summary>
|
||||
/// The target container to add the cursor after it is created.
|
||||
/// </summary>
|
||||
protected virtual Container CursorTargetContainer => null;
|
||||
|
||||
/// <summary>
|
||||
/// Registers a <see cref="Playfield"/> as a nested <see cref="Playfield"/>.
|
||||
/// This does not add the <see cref="Playfield"/> to the draw hierarchy.
|
||||
|
@ -76,12 +76,9 @@ namespace osu.Game.Rulesets.UI
|
||||
/// </summary>
|
||||
public Container Overlays { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// The cursor provided by this <see cref="RulesetContainer"/>. May be null if no cursor is provided.
|
||||
/// </summary>
|
||||
public CursorContainer Cursor { get; }
|
||||
public CursorContainer Cursor => Playfield.Cursor;
|
||||
|
||||
public bool ProvidingUserCursor => Cursor != null && !HasReplayLoaded.Value;
|
||||
public bool ProvidingUserCursor => Playfield.Cursor != null && !HasReplayLoaded.Value;
|
||||
|
||||
protected override bool OnHover(HoverEvent e) => true; // required for IProvideCursor
|
||||
|
||||
@ -107,8 +104,6 @@ namespace osu.Game.Rulesets.UI
|
||||
|
||||
KeyBindingInputManager.UseParentInput = !paused.NewValue;
|
||||
};
|
||||
|
||||
Cursor = CreateCursor();
|
||||
}
|
||||
|
||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
||||
@ -265,9 +260,6 @@ namespace osu.Game.Rulesets.UI
|
||||
Playfield
|
||||
});
|
||||
|
||||
if (Cursor != null)
|
||||
KeyBindingInputManager.Add(Cursor);
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
KeyBindingInputManager,
|
||||
|
@ -133,6 +133,7 @@ namespace osu.Game.Screens.Play
|
||||
Origin = Anchor.Centre,
|
||||
Breaks = working.Beatmap.Breaks
|
||||
},
|
||||
// display the cursor above some HUD elements.
|
||||
RulesetContainer.Cursor?.CreateProxy() ?? new Container(),
|
||||
HUDOverlay = new HUDOverlay(ScoreProcessor, RulesetContainer, working)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user