1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 19:22:54 +08:00

Merge branch 'master' into fix-alljudged-usages

This commit is contained in:
Dean Herbert 2018-01-15 16:39:16 +09:00 committed by GitHub
commit 20923321ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 171 additions and 63 deletions

View File

@ -1,15 +1,12 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Graphics.Cursor;
using osu.Game.Rulesets.Osu.UI;
namespace osu.Game.Rulesets.Osu.Edit
{
public class OsuEditPlayfield : OsuPlayfield
{
protected override CursorContainer CreateCursor() => null;
protected override bool ProxyApproachCircles => false;
}
}

View File

@ -1,6 +1,7 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Graphics.Cursor;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Osu.UI;
using osu.Game.Rulesets.UI;
@ -15,5 +16,7 @@ namespace osu.Game.Rulesets.Osu.Edit
}
protected override Playfield CreatePlayfield() => new OsuEditPlayfield();
protected override CursorContainer CreateCursor() => null;
}
}

View File

@ -159,5 +159,17 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
return false;
}
protected override void PopIn()
{
ActiveCursor.FadeTo(1, 250, Easing.OutQuint);
ActiveCursor.ScaleTo(1, 400, Easing.OutQuint);
}
protected override void PopOut()
{
ActiveCursor.FadeTo(0, 250, Easing.OutQuint);
ActiveCursor.ScaleTo(0.6f, 250, Easing.In);
}
}
}

View File

@ -12,8 +12,6 @@ using osu.Game.Rulesets.UI;
using System.Linq;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Osu.Judgements;
using osu.Game.Rulesets.Osu.UI.Cursor;
using osu.Framework.Graphics.Cursor;
namespace osu.Game.Rulesets.Osu.UI
{
@ -23,8 +21,6 @@ namespace osu.Game.Rulesets.Osu.UI
private readonly Container judgementLayer;
private readonly ConnectionRenderer<OsuHitObject> connectionLayer;
public override bool ProvidingUserCursor => true;
// Todo: This should not be a thing, but is currently required for the editor
// https://github.com/ppy/osu-framework/issues/1283
protected virtual bool ProxyApproachCircles => true;
@ -70,15 +66,6 @@ namespace osu.Game.Rulesets.Osu.UI
});
}
protected override void LoadComplete()
{
base.LoadComplete();
var cursor = CreateCursor();
if (cursor != null)
AddInternal(cursor);
}
public override void Add(DrawableHitObject h)
{
h.Depth = (float)h.HitObject.StartTime;
@ -113,7 +100,5 @@ namespace osu.Game.Rulesets.Osu.UI
judgementLayer.Add(explosion);
}
protected virtual CursorContainer CreateCursor() => new GameplayCursor();
}
}

View File

@ -1,6 +1,7 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Graphics.Cursor;
using osu.Framework.Input;
using OpenTK;
using osu.Game.Beatmaps;
@ -10,6 +11,7 @@ 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;
using osu.Game.Rulesets.Replays;
@ -49,5 +51,7 @@ namespace osu.Game.Rulesets.Osu.UI
protected override FramedReplayInputHandler CreateReplayInputHandler(Replay replay) => new OsuReplayInputHandler(replay);
protected override Vector2 GetPlayfieldAspectAdjust() => new Vector2(0.75f);
protected override CursorContainer CreateCursor() => new GameplayCursor();
}
}

View File

@ -0,0 +1,67 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Linq;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Input;
namespace osu.Game.Graphics.Cursor
{
/// <summary>
/// A container which provides a <see cref="MenuCursor"/> which can be overridden by hovered <see cref="Drawable"/>s.
/// </summary>
public class CursorOverrideContainer : Container, IProvideCursor
{
protected override Container<Drawable> Content => content;
private readonly Container content;
/// <summary>
/// Whether any cursors can be displayed.
/// </summary>
public bool CanShowCursor;
public CursorContainer Cursor { get; }
public bool ProvidingUserCursor => true;
public CursorOverrideContainer()
{
AddRangeInternal(new Drawable[]
{
Cursor = new MenuCursor { State = Visibility.Hidden },
content = new Container { RelativeSizeAxes = Axes.Both }
});
}
private InputManager inputManager;
protected override void LoadComplete()
{
base.LoadComplete();
inputManager = GetContainingInputManager();
}
private IProvideCursor currentTarget;
protected override void Update()
{
base.Update();
if (!CanShowCursor)
{
currentTarget?.Cursor?.Hide();
return;
}
var newTarget = inputManager.HoveredDrawables.OfType<IProvideCursor>().FirstOrDefault(t => t.ProvidingUserCursor) ?? this;
if (currentTarget == newTarget)
return;
currentTarget?.Cursor?.Hide();
newTarget.Cursor?.Show();
currentTarget = newTarget;
}
}
}

View File

@ -0,0 +1,26 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Graphics;
using osu.Framework.Graphics.Cursor;
namespace osu.Game.Graphics.Cursor
{
/// <summary>
/// Interface for <see cref="IDrawable"/>s that display cursors which can replace the user's cursor.
/// </summary>
public interface IProvideCursor : IDrawable
{
/// <summary>
/// The cursor provided by this <see cref="IDrawable"/>.
/// May be null if no cursor should be visible.
/// </summary>
CursorContainer Cursor { get; }
/// <summary>
/// Whether <see cref="Cursor"/> should be displayed as the singular user cursor. This will temporarily hide any other user cursor.
/// This value is checked every frame and may be used to control whether multiple cursors are displayed (e.g. watching replays).
/// </summary>
bool ProvidingUserCursor { get; }
}
}

View File

@ -99,8 +99,8 @@ namespace osu.Game.Graphics.Cursor
protected override void PopOut()
{
ActiveCursor.FadeTo(0, 900, Easing.OutQuint);
ActiveCursor.ScaleTo(0, 500, Easing.In);
ActiveCursor.FadeTo(0, 250, Easing.OutQuint);
ActiveCursor.ScaleTo(0.6f, 250, Easing.In);
}
[BackgroundDependencyLoader]

View File

@ -297,8 +297,6 @@ namespace osu.Game
else
Toolbar.State = Visibility.Visible;
};
Cursor.State = Visibility.Hidden;
}
private void forwardLoggedErrorsToNotifications()
@ -447,7 +445,7 @@ namespace osu.Game
mainContent.Padding = new MarginPadding { Top = ToolbarOffset };
Cursor.State = currentScreen?.HasLocalCursorDisplayed == false ? Visibility.Visible : Visibility.Hidden;
CursorOverrideContainer.CanShowCursor = currentScreen?.CursorVisible ?? false;
}
private void screenAdded(Screen newScreen)

View File

@ -44,6 +44,8 @@ namespace osu.Game
protected KeyBindingStore KeyBindingStore;
protected CursorOverrideContainer CursorOverrideContainer;
protected override string MainResourceFile => @"osu.Game.Resources.dll";
public APIAccess API;
@ -52,8 +54,6 @@ namespace osu.Game
protected override Container<Drawable> Content => content;
protected MenuCursor Cursor;
public Bindable<WorkingBeatmap> Beatmap { get; private set; }
private Bindable<bool> fpsDisplayVisible;
@ -211,21 +211,14 @@ namespace osu.Game
GlobalKeyBindingInputManager globalBinding;
base.Content.Add(new DrawSizePreservingFillContainer
CursorOverrideContainer = new CursorOverrideContainer { RelativeSizeAxes = Axes.Both };
CursorOverrideContainer.Child = globalBinding = new GlobalKeyBindingInputManager(this)
{
Children = new Drawable[]
{
Cursor = new MenuCursor(),
globalBinding = new GlobalKeyBindingInputManager(this)
{
RelativeSizeAxes = Axes.Both,
Child = content = new OsuTooltipContainer(Cursor)
{
RelativeSizeAxes = Axes.Both,
}
}
}
});
RelativeSizeAxes = Axes.Both,
Child = content = new OsuTooltipContainer(CursorOverrideContainer.Cursor) { RelativeSizeAxes = Axes.Both }
};
base.Content.Add(new DrawSizePreservingFillContainer { Child = CursorOverrideContainer });
KeyBindingStore.Register(globalBinding);
dependencies.Cache(globalBinding);

View File

@ -20,11 +20,6 @@ namespace osu.Game.Rulesets.UI
public Container<Drawable> ScaledContent;
/// <summary>
/// Whether we are currently providing the local user a gameplay cursor.
/// </summary>
public virtual bool ProvidingUserCursor => false;
protected override Container<Drawable> Content => content;
private readonly Container<Drawable> content;

View File

@ -13,6 +13,7 @@ using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Input;
using osu.Game.Rulesets.Replays;
using osu.Game.Rulesets.Scoring;
@ -43,11 +44,6 @@ namespace osu.Game.Rulesets.UI
/// </summary>
public PassThroughInputManager KeyBindingInputManager;
/// <summary>
/// Whether we are currently providing the local user a gameplay cursor.
/// </summary>
public virtual bool ProvidingUserCursor => false;
/// <summary>
/// Whether we have a replay loaded currently.
/// </summary>
@ -61,6 +57,11 @@ namespace osu.Game.Rulesets.UI
/// </summary>
public Playfield Playfield => playfield.Value;
/// <summary>
/// The cursor provided by this <see cref="RulesetContainer"/>. May be null if no cursor is provided.
/// </summary>
public readonly CursorContainer Cursor;
protected readonly Ruleset Ruleset;
/// <summary>
@ -71,6 +72,8 @@ namespace osu.Game.Rulesets.UI
{
Ruleset = ruleset;
playfield = new Lazy<Playfield>(CreatePlayfield);
Cursor = CreateCursor();
}
public abstract ScoreProcessor CreateScoreProcessor();
@ -98,6 +101,12 @@ namespace osu.Game.Rulesets.UI
ReplayInputManager.ReplayInputHandler = replay != null ? CreateReplayInputHandler(replay) : null;
}
/// <summary>
/// Creates the cursor. May be null if the <see cref="RulesetContainer"/> doesn't provide a custom cursor.
/// </summary>
protected virtual CursorContainer CreateCursor() => null;
/// <summary>
/// Creates a Playfield.
/// </summary>
@ -144,8 +153,6 @@ namespace osu.Game.Rulesets.UI
/// </summary>
protected readonly bool IsForCurrentRuleset;
public sealed override bool ProvidingUserCursor => !HasReplayLoaded && Playfield.ProvidingUserCursor;
public override ScoreProcessor CreateScoreProcessor() => new ScoreProcessor<TObject>(this);
protected override Container<Drawable> Content => content;
@ -212,6 +219,9 @@ namespace osu.Game.Rulesets.UI
AddInternal(KeyBindingInputManager);
KeyBindingInputManager.Add(Playfield);
if (Cursor != null)
KeyBindingInputManager.Add(Cursor);
loadObjects();
}

View File

@ -19,8 +19,7 @@ namespace osu.Game.Screens.Menu
private Color4 iconColour;
public override bool ShowOverlaysOnEnter => false;
public override bool HasLocalCursorDisplayed => true;
public override bool CursorVisible => false;
public Disclaimer()
{

View File

@ -31,9 +31,8 @@ namespace osu.Game.Screens.Menu
private SampleChannel welcome;
private SampleChannel seeya;
public override bool HasLocalCursorDisplayed => true;
public override bool ShowOverlaysOnEnter => false;
public override bool CursorVisible => false;
protected override BackgroundScreen CreateBackground() => new BackgroundScreenEmpty();

View File

@ -35,9 +35,12 @@ namespace osu.Game.Screens
/// </summary>
public virtual bool ShowOverlaysOnEnter => true;
protected new OsuGameBase Game => base.Game as OsuGameBase;
/// <summary>
/// Whether this <see cref="OsuScreen"/> allows the cursor to be displayed.
/// </summary>
public virtual bool CursorVisible => true;
public virtual bool HasLocalCursorDisplayed => false;
protected new OsuGameBase Game => base.Game as OsuGameBase;
private OsuLogo logo;

View File

@ -23,22 +23,22 @@ using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Scoring;
using osu.Game.Screens.Ranking;
using osu.Framework.Audio.Sample;
using osu.Framework.Graphics.Cursor;
using osu.Game.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Graphics.Cursor;
using osu.Game.Online.API;
using osu.Game.Screens.Play.BreaksOverlay;
using osu.Game.Storyboards.Drawables;
namespace osu.Game.Screens.Play
{
public class Player : OsuScreen
public class Player : OsuScreen, IProvideCursor
{
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap);
public override bool ShowOverlaysOnEnter => false;
public override bool HasLocalCursorDisplayed => !pauseContainer.IsPaused && !HasFailed && RulesetContainer.ProvidingUserCursor;
public Action RestartRequested;
public override bool AllowBeatmapRulesetChange => false;
@ -51,6 +51,9 @@ namespace osu.Game.Screens.Play
public int RestartCount;
public CursorContainer Cursor => RulesetContainer.Cursor;
public bool ProvidingUserCursor => RulesetContainer?.Cursor != null && !RulesetContainer.HasReplayLoaded;
private IAdjustableClock adjustableSourceClock;
private FramedOffsetClock offsetClock;
private DecoupleableInterpolatingFramedClock decoupledClock;
@ -176,13 +179,13 @@ namespace osu.Game.Screens.Play
},
Children = new Drawable[]
{
new SkipButton(firstObjectTime) { AudioClock = decoupledClock },
new Container
{
RelativeSizeAxes = Axes.Both,
Clock = offsetClock,
Child = RulesetContainer,
},
new SkipButton(firstObjectTime) { AudioClock = decoupledClock },
hudOverlay = new HUDOverlay
{
Anchor = Anchor.Centre,
@ -194,7 +197,7 @@ namespace osu.Game.Screens.Play
Origin = Anchor.Centre,
Clock = decoupledClock,
Breaks = beatmap.Breaks
},
}
}
},
failOverlay = new FailOverlay

View File

@ -21,7 +21,7 @@ using osu.Game.Input.Bindings;
namespace osu.Game.Screens.Play
{
public class SkipButton : Container, IKeyBindingHandler<GlobalAction>
public class SkipButton : OverlayContainer, IKeyBindingHandler<GlobalAction>
{
private readonly double startTime;
public IAdjustableClock AudioClock;
@ -36,6 +36,8 @@ namespace osu.Game.Screens.Play
{
this.startTime = startTime;
State = Visibility.Visible;
RelativePositionAxes = Axes.Both;
RelativeSizeAxes = Axes.Both;
@ -112,6 +114,16 @@ namespace osu.Game.Screens.Play
Expire();
}
protected override void PopIn()
{
this.FadeIn();
}
protected override void PopOut()
{
this.FadeOut();
}
protected override void Update()
{
base.Update();

View File

@ -388,8 +388,10 @@
<Compile Include="Graphics\Containers\ParallaxContainer.cs" />
<Compile Include="Graphics\Containers\ReverseChildIDFillFlowContainer.cs" />
<Compile Include="Graphics\Containers\SectionsContainer.cs" />
<Compile Include="Graphics\Cursor\IProvideCursor.cs" />
<Compile Include="Graphics\Cursor\MenuCursor.cs" />
<Compile Include="Graphics\Cursor\OsuContextMenuContainer.cs" />
<Compile Include="Graphics\Cursor\CursorOverrideContainer.cs" />
<Compile Include="Graphics\Cursor\OsuTooltipContainer.cs" />
<Compile Include="Graphics\IHasAccentColour.cs" />
<Compile Include="Graphics\OsuColour.cs" />