1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 09:32:55 +08:00

Merge branch 'master' into wiggle-repeat-points

This commit is contained in:
Fayne Aldan 2018-10-08 15:23:45 -06:00 committed by GitHub
commit edf87bfdd8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
208 changed files with 2018 additions and 1282 deletions

View File

@ -10,8 +10,8 @@ before_build:
- cmd: nuget restore -verbosity quiet - cmd: nuget restore -verbosity quiet
build_script: build_script:
- ps: iex ((New-Object Net.WebClient).DownloadString('https://raw.githubusercontent.com/appveyor/secure-file/master/install.ps1')) - ps: iex ((New-Object Net.WebClient).DownloadString('https://raw.githubusercontent.com/appveyor/secure-file/master/install.ps1'))
- appveyor DownloadFile https://puu.sh/A6g5K/4d08705438.enc # signing certificate - appveyor DownloadFile https://puu.sh/BCrS8/7faccf7876.enc # signing certificate
- cmd: appveyor-tools\secure-file -decrypt 4d08705438.enc -secret %decode_secret% -out %HOMEPATH%\deanherbert.pfx - cmd: appveyor-tools\secure-file -decrypt 7faccf7876.enc -secret %decode_secret% -out %HOMEPATH%\deanherbert.pfx
- appveyor DownloadFile https://puu.sh/A6g75/fdc6f19b04.enc # deploy configuration - appveyor DownloadFile https://puu.sh/A6g75/fdc6f19b04.enc # deploy configuration
- cd osu-deploy - cd osu-deploy
- nuget restore -verbosity quiet - nuget restore -verbosity quiet

View File

@ -27,9 +27,6 @@ namespace osu.Desktop.Overlays
private NotificationOverlay notificationOverlay; private NotificationOverlay notificationOverlay;
private GameHost host; private GameHost host;
public override bool HandleKeyboardInput => false;
public override bool HandleMouseInput => false;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(NotificationOverlay notification, OsuColour colours, TextureStore textures, OsuGameBase game, OsuConfigManager config, GameHost host) private void load(NotificationOverlay notification, OsuColour colours, TextureStore textures, OsuGameBase game, OsuConfigManager config, GameHost host)
{ {

View File

@ -16,7 +16,7 @@ namespace osu.Game.Rulesets.Catch.Objects
public int IndexInBeatmap { get; set; } public int IndexInBeatmap { get; set; }
public virtual FruitVisualRepresentation VisualRepresentation => (FruitVisualRepresentation)(IndexInBeatmap % 4); public virtual FruitVisualRepresentation VisualRepresentation => (FruitVisualRepresentation)(ComboIndex % 4);
public virtual bool NewCombo { get; set; } public virtual bool NewCombo { get; set; }

View File

@ -5,6 +5,7 @@ using System;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Configuration;
using osu.Game.Rulesets.Catch.Objects; using osu.Game.Rulesets.Catch.Objects;
using osu.Game.Rulesets.Catch.Objects.Drawable; using osu.Game.Rulesets.Catch.Objects.Drawable;
using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Judgements;
@ -24,6 +25,8 @@ namespace osu.Game.Rulesets.Catch.UI
protected override bool UserScrollSpeedAdjustment => false; protected override bool UserScrollSpeedAdjustment => false;
protected override SpeedChangeVisualisationMethod VisualisationMethod => SpeedChangeVisualisationMethod.Constant;
public CatchPlayfield(BeatmapDifficulty difficulty, Func<CatchHitObject, DrawableHitObject<CatchHitObject>> getVisualRepresentation) public CatchPlayfield(BeatmapDifficulty difficulty, Func<CatchHitObject, DrawableHitObject<CatchHitObject>> getVisualRepresentation)
: base(BASE_WIDTH) : base(BASE_WIDTH)
{ {
@ -55,6 +58,8 @@ namespace osu.Game.Rulesets.Catch.UI
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
}, },
}); });
VisibleTimeRange.Value = BeatmapDifficulty.DifficultyRange(difficulty.ApproachRate, 1800, 1200, 450);
} }
public bool CheckIfWeCanCatch(CatchHitObject obj) => catcherArea.AttemptCatch(obj); public bool CheckIfWeCanCatch(CatchHitObject obj) => catcherArea.AttemptCatch(obj);

View File

@ -78,7 +78,7 @@ namespace osu.Game.Rulesets.Mania.Edit.Layers.Selection.Overlays
} }
// Todo: This is temporary, since the note masks don't do anything special yet. In the future they will handle input. // Todo: This is temporary, since the note masks don't do anything special yet. In the future they will handle input.
public override bool HandleMouseInput => false; public override bool HandlePositionalInput => false;
} }
} }
} }

View File

@ -30,10 +30,11 @@ namespace osu.Game.Rulesets.Mania.UI
if (Result.IsHit) if (Result.IsHit)
{ {
this.ScaleTo(0.8f); JudgementBody.ScaleTo(0.8f);
this.ScaleTo(1, 250, Easing.OutElastic); JudgementBody.ScaleTo(1, 250, Easing.OutElastic);
this.Delay(50).FadeOut(200).ScaleTo(0.75f, 250); JudgementBody.Delay(50).ScaleTo(0.75f, 250);
this.Delay(50).FadeOut(200);
} }
Expire(); Expire();

View File

@ -56,6 +56,6 @@ namespace osu.Game.Rulesets.Osu.Edit.Layers.Selection.Overlays
} }
// Todo: This is temporary, since the slider circle masks don't do anything special yet. In the future they will handle input. // Todo: This is temporary, since the slider circle masks don't do anything special yet. In the future they will handle input.
public override bool HandleMouseInput => false; public override bool HandlePositionalInput => false;
} }
} }

View File

@ -59,7 +59,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Layers.Selection.Overlays
body.UpdateProgress(0); body.UpdateProgress(0);
} }
public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => body.ReceiveMouseInputAt(screenSpacePos); public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => body.ReceivePositionalInputAt(screenSpacePos);
public override Vector2 SelectionPoint => ToScreenSpace(OriginPosition); public override Vector2 SelectionPoint => ToScreenSpace(OriginPosition);
public override Quad SelectionQuad => body.PathDrawQuad; public override Quad SelectionQuad => body.PathDrawQuad;

View File

@ -4,7 +4,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using osu.Framework.Input.States;
using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Objects.Types;
using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Osu.Objects;
@ -77,7 +76,7 @@ namespace osu.Game.Rulesets.Osu.Mods
wasLeft = !wasLeft; wasLeft = !wasLeft;
} }
osuInputManager.HandleCustomInput(new InputState(), state); state.Apply(osuInputManager.CurrentState, osuInputManager);
} }
public void ApplyToRulesetContainer(RulesetContainer<OsuHitObject> rulesetContainer) public void ApplyToRulesetContainer(RulesetContainer<OsuHitObject> rulesetContainer)

View File

@ -184,6 +184,6 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
public Drawable ProxiedLayer => HeadCircle.ApproachCircle; public Drawable ProxiedLayer => HeadCircle.ApproachCircle;
public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => Body.ReceiveMouseInputAt(screenSpacePos); public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => Body.ReceivePositionalInputAt(screenSpacePos);
} }
} }

View File

@ -12,6 +12,9 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
{ {
public class CirclePiece : Container, IKeyBindingHandler<OsuAction> public class CirclePiece : Container, IKeyBindingHandler<OsuAction>
{ {
// IsHovered is used
public override bool HandlePositionalInput => true;
public Func<bool> Hit; public Func<bool> Hit;
public CirclePiece() public CirclePiece()

View File

@ -5,11 +5,11 @@ using System.Linq;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.EventArgs; using osu.Framework.Input.Events;
using osu.Framework.Input.States;
using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Objects.Types;
using OpenTK.Graphics; using OpenTK.Graphics;
using osu.Game.Skinning; using osu.Game.Skinning;
using OpenTK;
namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
{ {
@ -102,24 +102,24 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
}; };
} }
private InputState lastState; private Vector2? lastScreenSpaceMousePosition;
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) protected override bool OnMouseDown(MouseDownEvent e)
{ {
lastState = state; lastScreenSpaceMousePosition = e.ScreenSpaceMousePosition;
return base.OnMouseDown(state, args); return base.OnMouseDown(e);
} }
protected override bool OnMouseUp(InputState state, MouseUpEventArgs args) protected override bool OnMouseUp(MouseUpEvent e)
{ {
lastState = state; lastScreenSpaceMousePosition = e.ScreenSpaceMousePosition;
return base.OnMouseUp(state, args); return base.OnMouseUp(e);
} }
protected override bool OnMouseMove(InputState state) protected override bool OnMouseMove(MouseMoveEvent e)
{ {
lastState = state; lastScreenSpaceMousePosition = e.ScreenSpaceMousePosition;
return base.OnMouseMove(state); return base.OnMouseMove(e);
} }
public override void ClearTransformsAfter(double time, bool propagateChildren = false, string targetMember = null) public override void ClearTransformsAfter(double time, bool propagateChildren = false, string targetMember = null)
@ -153,10 +153,10 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
if (Time.Current < slider.EndTime) if (Time.Current < slider.EndTime)
{ {
// Make sure to use the base version of ReceiveMouseInputAt so that we correctly check the position. // Make sure to use the base version of ReceivePositionalInputAt so that we correctly check the position.
Tracking = canCurrentlyTrack Tracking = canCurrentlyTrack
&& lastState != null && lastScreenSpaceMousePosition.HasValue
&& ReceiveMouseInputAt(lastState.Mouse.NativeState.Position) && ReceivePositionalInputAt(lastScreenSpaceMousePosition.Value)
&& (drawableSlider?.OsuActionInputManager?.PressedActions.Any(x => x == OsuAction.LeftButton || x == OsuAction.RightButton) ?? false); && (drawableSlider?.OsuActionInputManager?.PressedActions.Any(x => x == OsuAction.LeftButton || x == OsuAction.RightButton) ?? false);
} }
} }

View File

@ -112,7 +112,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
container.Attach(RenderbufferInternalFormat.DepthComponent16); container.Attach(RenderbufferInternalFormat.DepthComponent16);
} }
public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => path.ReceiveMouseInputAt(screenSpacePos); public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => path.ReceivePositionalInputAt(screenSpacePos);
public void SetRange(double p0, double p1) public void SetRange(double p0, double p1)
{ {

View File

@ -11,9 +11,6 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
{ {
public class SpinnerBackground : CircularContainer, IHasAccentColour public class SpinnerBackground : CircularContainer, IHasAccentColour
{ {
public override bool HandleKeyboardInput => false;
public override bool HandleMouseInput => false;
protected Box Disc; protected Box Disc;
public Color4 AccentColour public Color4 AccentColour

View File

@ -4,7 +4,7 @@
using System; using System;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Input.States; using osu.Framework.Input.Events;
using osu.Game.Graphics; using osu.Game.Graphics;
using OpenTK; using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
@ -40,7 +40,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
}; };
} }
public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => true; public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true;
private bool tracking; private bool tracking;
public bool Tracking public bool Tracking
@ -68,10 +68,10 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
} }
} }
protected override bool OnMouseMove(InputState state) protected override bool OnMouseMove(MouseMoveEvent e)
{ {
mousePosition = Parent.ToLocalSpace(state.Mouse.NativeState.Position); mousePosition = Parent.ToLocalSpace(e.ScreenSpaceMousePosition);
return base.OnMouseMove(state); return base.OnMouseMove(e);
} }
private Vector2 mousePosition; private Vector2 mousePosition;

View File

@ -4,8 +4,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using osu.Framework.Input.Bindings; using osu.Framework.Input.Bindings;
using osu.Framework.Input.EventArgs; using osu.Framework.Input.Events;
using osu.Framework.Input.States;
using osu.Game.Rulesets.UI; using osu.Game.Rulesets.UI;
namespace osu.Game.Rulesets.Osu namespace osu.Game.Rulesets.Osu
@ -36,13 +35,11 @@ namespace osu.Game.Rulesets.Osu
{ {
} }
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) => AllowUserPresses && base.OnKeyDown(state, args); protected override bool Handle(UIEvent e)
protected override bool OnKeyUp(InputState state, KeyUpEventArgs args) => AllowUserPresses && base.OnKeyUp(state, args); {
protected override bool OnJoystickPress(InputState state, JoystickEventArgs args) => AllowUserPresses && base.OnJoystickPress(state, args); if (!AllowUserPresses) return false;
protected override bool OnJoystickRelease(InputState state, JoystickEventArgs args) => AllowUserPresses && base.OnJoystickRelease(state, args); return base.Handle(e);
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) => AllowUserPresses && base.OnMouseDown(state, args); }
protected override bool OnMouseUp(InputState state, MouseUpEventArgs args) => AllowUserPresses && base.OnMouseUp(state, args);
protected override bool OnScroll(InputState state) => AllowUserPresses && base.OnScroll(state);
} }
} }

View File

@ -12,7 +12,7 @@ using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.Shaders; using osu.Framework.Graphics.Shaders;
using osu.Framework.Graphics.Textures; using osu.Framework.Graphics.Textures;
using osu.Framework.Input; using osu.Framework.Input;
using osu.Framework.Input.States; using osu.Framework.Input.Events;
using osu.Framework.Timing; using osu.Framework.Timing;
using OpenTK; using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
@ -76,7 +76,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
} }
} }
public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => true; public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(ShaderManager shaders, TextureStore textures) private void load(ShaderManager shaders, TextureStore textures)
@ -117,15 +117,15 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
timeOffset = Time.Current; timeOffset = Time.Current;
} }
protected override bool OnMouseMove(InputState state) protected override bool OnMouseMove(MouseMoveEvent e)
{ {
Vector2 pos = state.Mouse.NativeState.Position; Vector2 pos = e.ScreenSpaceMousePosition;
if (lastPosition == null) if (lastPosition == null)
{ {
lastPosition = pos; lastPosition = pos;
resampler.AddPosition(lastPosition.Value); resampler.AddPosition(lastPosition.Value);
return base.OnMouseMove(state); return base.OnMouseMove(e);
} }
foreach (Vector2 pos2 in resampler.AddPosition(pos)) foreach (Vector2 pos2 in resampler.AddPosition(pos))
@ -147,7 +147,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
} }
} }
return base.OnMouseMove(state); return base.OnMouseMove(e);
} }
private void addPosition(Vector2 pos) private void addPosition(Vector2 pos)

View File

@ -72,7 +72,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
return false; return false;
} }
public override bool HandleMouseInput => true; // OverlayContainer will set this false when we go hidden, but we always want to receive input. public override bool HandlePositionalInput => true; // OverlayContainer will set this false when we go hidden, but we always want to receive input.
protected override void PopIn() protected override void PopIn()
{ {

View File

@ -72,7 +72,8 @@ namespace osu.Game.Rulesets.Osu.UI
DrawableOsuJudgement explosion = new DrawableOsuJudgement(result, judgedObject) DrawableOsuJudgement explosion = new DrawableOsuJudgement(result, judgedObject)
{ {
Origin = Anchor.Centre, Origin = Anchor.Centre,
Position = ((OsuHitObject)judgedObject.HitObject).StackedEndPosition Position = ((OsuHitObject)judgedObject.HitObject).StackedEndPosition,
Scale = new Vector2(((OsuHitObject)judgedObject.HitObject).Scale * 1.65f)
}; };
judgementLayer.Add(explosion); judgementLayer.Add(explosion);

View File

@ -24,6 +24,8 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
private bool validActionPressed; private bool validActionPressed;
private bool pressHandledThisFrame;
protected DrawableHit(Hit hit) protected DrawableHit(Hit hit)
: base(hit) : base(hit)
{ {
@ -51,6 +53,9 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
public override bool OnPressed(TaikoAction action) public override bool OnPressed(TaikoAction action)
{ {
if (pressHandledThisFrame)
return true;
if (Judged) if (Judged)
return false; return false;
@ -62,6 +67,10 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
if (IsHit) if (IsHit)
HitAction = action; HitAction = action;
// Regardless of whether we've hit or not, any secondary key presses in the same frame should be discarded
// E.g. hitting a non-strong centre as a strong should not fall through and perform a hit on the next note
pressHandledThisFrame = true;
return result; return result;
} }
@ -76,6 +85,10 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
{ {
base.Update(); base.Update();
// The input manager processes all input prior to us updating, so this is the perfect time
// for us to remove the extra press blocking, before input is handled in the next frame
pressHandledThisFrame = false;
Size = BaseSize * Parent.RelativeChildSize; Size = BaseSize * Parent.RelativeChildSize;
} }

View File

@ -31,10 +31,10 @@ namespace osu.Game.Rulesets.Taiko.UI
switch (Result.Type) switch (Result.Type)
{ {
case HitResult.Good: case HitResult.Good:
Colour = colours.GreenLight; JudgementBody.Colour = colours.GreenLight;
break; break;
case HitResult.Great: case HitResult.Great:
Colour = colours.BlueLight; JudgementBody.Colour = colours.BlueLight;
break; break;
} }
} }

View File

@ -1,23 +1,24 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Shapes;
using osu.Game.Rulesets.Taiko.Objects;
using OpenTK;
using OpenTK.Graphics;
using osu.Game.Rulesets.Taiko.Judgements;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Extensions.Color4Extensions;
using System.Linq; using System.Linq;
using osu.Game.Rulesets.Judgements; using osu.Framework.Allocation;
using osu.Game.Rulesets.Taiko.Objects.Drawables; using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Beatmaps.ControlPoints; using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Configuration;
using osu.Game.Graphics;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.UI; using osu.Game.Rulesets.UI;
using osu.Game.Rulesets.UI.Scrolling; using osu.Game.Rulesets.UI.Scrolling;
using osu.Game.Rulesets.Taiko.Objects;
using osu.Game.Rulesets.Taiko.Objects.Drawables;
using osu.Game.Rulesets.Taiko.Judgements;
using OpenTK;
using OpenTK.Graphics;
namespace osu.Game.Rulesets.Taiko.UI namespace osu.Game.Rulesets.Taiko.UI
{ {
@ -40,6 +41,8 @@ namespace osu.Game.Rulesets.Taiko.UI
protected override bool UserScrollSpeedAdjustment => false; protected override bool UserScrollSpeedAdjustment => false;
protected override SpeedChangeVisualisationMethod VisualisationMethod => SpeedChangeVisualisationMethod.Overlapping;
private readonly Container<HitExplosion> hitExplosionContainer; private readonly Container<HitExplosion> hitExplosionContainer;
private readonly Container<KiaiHitExplosion> kiaiExplosionContainer; private readonly Container<KiaiHitExplosion> kiaiExplosionContainer;
private readonly JudgementContainer<DrawableTaikoJudgement> judgementContainer; private readonly JudgementContainer<DrawableTaikoJudgement> judgementContainer;

View File

@ -165,7 +165,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
} }
[Test] [Test]
public void TestDecodeBeatmapColors() public void TestDecodeBeatmapColours()
{ {
var decoder = new LegacySkinDecoder(); var decoder = new LegacySkinDecoder();
using (var resStream = Resource.OpenResource("Soleily - Renatus (Gamu) [Insane].osu")) using (var resStream = Resource.OpenResource("Soleily - Renatus (Gamu) [Insane].osu"))
@ -181,6 +181,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
new Color4(128, 255, 128, 255), new Color4(128, 255, 128, 255),
new Color4(255, 187, 255, 255), new Color4(255, 187, 255, 255),
new Color4(255, 177, 140, 255), new Color4(255, 177, 140, 255),
new Color4(100, 100, 100, 100),
}; };
Assert.AreEqual(expectedColors.Length, comboColors.Count); Assert.AreEqual(expectedColors.Length, comboColors.Count);
for (int i = 0; i < expectedColors.Length; i++) for (int i = 0; i < expectedColors.Length; i++)

View File

@ -101,6 +101,7 @@ Combo3 : 128,255,255
Combo4 : 128,255,128 Combo4 : 128,255,128
Combo5 : 255,187,255 Combo5 : 255,187,255
Combo6 : 255,177,140 Combo6 : 255,177,140
Combo7 : 100,100,100,100
[HitObjects] [HitObjects]
192,168,956,6,0,P|184:128|200:80,1,90,4|0,1:2|0:0,0:0:0:0: 192,168,956,6,0,P|184:128|200:80,1,90,4|0,1:2|0:0,0:0:0:0:

View File

@ -7,7 +7,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.States; using osu.Framework.Input.Events;
using osu.Framework.MathUtils; using osu.Framework.MathUtils;
using osu.Game.Graphics.Cursor; using osu.Game.Graphics.Cursor;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
@ -184,7 +184,7 @@ namespace osu.Game.Tests.Visual
/// </summary> /// </summary>
/// <param name="cursorContainer">The cursor to check.</param> /// <param name="cursorContainer">The cursor to check.</param>
private bool checkAtMouse(CursorContainer cursorContainer) private bool checkAtMouse(CursorContainer cursorContainer)
=> Precision.AlmostEquals(InputManager.CurrentState.Mouse.NativeState.Position, cursorContainer.ToScreenSpace(cursorContainer.ActiveCursor.DrawPosition)); => Precision.AlmostEquals(InputManager.CurrentState.Mouse.Position, cursorContainer.ToScreenSpace(cursorContainer.ActiveCursor.DrawPosition));
private class CustomCursorBox : Container, IProvideCursor private class CustomCursorBox : Container, IProvideCursor
{ {
@ -193,7 +193,7 @@ namespace osu.Game.Tests.Visual
public CursorContainer Cursor { get; } public CursorContainer Cursor { get; }
public bool ProvidingUserCursor { get; } public bool ProvidingUserCursor { get; }
public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => base.ReceiveMouseInputAt(screenSpacePos) || SmoothTransition && !ProvidingUserCursor; public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => base.ReceivePositionalInputAt(screenSpacePos) || SmoothTransition && !ProvidingUserCursor;
private readonly Box background; private readonly Box background;
@ -224,16 +224,16 @@ namespace osu.Game.Tests.Visual
}; };
} }
protected override bool OnHover(InputState state) protected override bool OnHover(HoverEvent e)
{ {
background.FadeTo(0.4f, 250, Easing.OutQuint); background.FadeTo(0.4f, 250, Easing.OutQuint);
return false; return false;
} }
protected override void OnHoverLost(InputState state) protected override void OnHoverLost(HoverLostEvent e)
{ {
background.FadeTo(0.1f, 250); background.FadeTo(0.1f, 250);
base.OnHoverLost(state); base.OnHoverLost(e);
} }
} }

View File

@ -8,14 +8,14 @@ using System.Linq;
using OpenTK.Input; using OpenTK.Input;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Input.EventArgs;
using osu.Framework.Logging; using osu.Framework.Logging;
using osu.Game.Screens.Play; using osu.Game.Screens.Play;
using OpenTK;
namespace osu.Game.Tests.Visual namespace osu.Game.Tests.Visual
{ {
[Description("player pause/fail screens")] [Description("player pause/fail screens")]
public class TestCaseGameplayMenuOverlay : OsuTestCase public class TestCaseGameplayMenuOverlay : ManualInputManagerTestCase
{ {
public override IReadOnlyList<Type> RequiredTypes => new[] { typeof(FailOverlay), typeof(PauseContainer) }; public override IReadOnlyList<Type> RequiredTypes => new[] { typeof(FailOverlay), typeof(PauseContainer) };
@ -73,12 +73,18 @@ namespace osu.Game.Tests.Visual
{ {
AddStep("Show overlay", () => failOverlay.Show()); AddStep("Show overlay", () => failOverlay.Show());
AddStep("Hover first button", () => failOverlay.Buttons.First().TriggerOnMouseMove(null)); AddStep("Hover first button", () => InputManager.MoveMouseTo(failOverlay.Buttons.First()));
AddStep("Hide overlay", () => failOverlay.Hide()); AddStep("Hide overlay", () => failOverlay.Hide());
AddAssert("Overlay state is reset", () => !failOverlay.Buttons.Any(b => b.Selected)); AddAssert("Overlay state is reset", () => !failOverlay.Buttons.Any(b => b.Selected));
} }
private void press(Key key)
{
InputManager.PressKey(key);
InputManager.ReleaseKey(key);
}
/// <summary> /// <summary>
/// Tests that pressing enter after an overlay shows doesn't trigger an event because a selection hasn't occurred. /// Tests that pressing enter after an overlay shows doesn't trigger an event because a selection hasn't occurred.
/// </summary> /// </summary>
@ -86,7 +92,7 @@ namespace osu.Game.Tests.Visual
{ {
AddStep("Show overlay", () => pauseOverlay.Show()); AddStep("Show overlay", () => pauseOverlay.Show());
AddStep("Press enter", () => pauseOverlay.TriggerOnKeyDown(null, new KeyDownEventArgs { Key = Key.Enter })); AddStep("Press enter", () => press(Key.Enter));
AddAssert("Overlay still open", () => pauseOverlay.State == Visibility.Visible); AddAssert("Overlay still open", () => pauseOverlay.State == Visibility.Visible);
AddStep("Hide overlay", () => pauseOverlay.Hide()); AddStep("Hide overlay", () => pauseOverlay.Hide());
@ -99,7 +105,7 @@ namespace osu.Game.Tests.Visual
{ {
AddStep("Show overlay", () => pauseOverlay.Show()); AddStep("Show overlay", () => pauseOverlay.Show());
AddStep("Up arrow", () => pauseOverlay.TriggerOnKeyDown(null, new KeyDownEventArgs { Key = Key.Up })); AddStep("Up arrow", () => press(Key.Up));
AddAssert("Last button selected", () => pauseOverlay.Buttons.Last().Selected); AddAssert("Last button selected", () => pauseOverlay.Buttons.Last().Selected);
AddStep("Hide overlay", () => pauseOverlay.Hide()); AddStep("Hide overlay", () => pauseOverlay.Hide());
@ -112,7 +118,7 @@ namespace osu.Game.Tests.Visual
{ {
AddStep("Show overlay", () => pauseOverlay.Show()); AddStep("Show overlay", () => pauseOverlay.Show());
AddStep("Down arrow", () => pauseOverlay.TriggerOnKeyDown(null, new KeyDownEventArgs { Key = Key.Down })); AddStep("Down arrow", () => press(Key.Down));
AddAssert("First button selected", () => pauseOverlay.Buttons.First().Selected); AddAssert("First button selected", () => pauseOverlay.Buttons.First().Selected);
AddStep("Hide overlay", () => pauseOverlay.Hide()); AddStep("Hide overlay", () => pauseOverlay.Hide());
@ -125,11 +131,11 @@ namespace osu.Game.Tests.Visual
{ {
AddStep("Show overlay", () => failOverlay.Show()); AddStep("Show overlay", () => failOverlay.Show());
AddStep("Up arrow", () => failOverlay.TriggerOnKeyDown(null, new KeyDownEventArgs { Key = Key.Up })); AddStep("Up arrow", () => press(Key.Up));
AddAssert("Last button selected", () => failOverlay.Buttons.Last().Selected); AddAssert("Last button selected", () => failOverlay.Buttons.Last().Selected);
AddStep("Up arrow", () => failOverlay.TriggerOnKeyDown(null, new KeyDownEventArgs { Key = Key.Up })); AddStep("Up arrow", () => press(Key.Up));
AddAssert("First button selected", () => failOverlay.Buttons.First().Selected); AddAssert("First button selected", () => failOverlay.Buttons.First().Selected);
AddStep("Up arrow", () => failOverlay.TriggerOnKeyDown(null, new KeyDownEventArgs { Key = Key.Up })); AddStep("Up arrow", () => press(Key.Up));
AddAssert("Last button selected", () => failOverlay.Buttons.Last().Selected); AddAssert("Last button selected", () => failOverlay.Buttons.Last().Selected);
AddStep("Hide overlay", () => failOverlay.Hide()); AddStep("Hide overlay", () => failOverlay.Hide());
@ -142,11 +148,11 @@ namespace osu.Game.Tests.Visual
{ {
AddStep("Show overlay", () => failOverlay.Show()); AddStep("Show overlay", () => failOverlay.Show());
AddStep("Down arrow", () => failOverlay.TriggerOnKeyDown(null, new KeyDownEventArgs { Key = Key.Down })); AddStep("Down arrow", () => press(Key.Down));
AddAssert("First button selected", () => failOverlay.Buttons.First().Selected); AddAssert("First button selected", () => failOverlay.Buttons.First().Selected);
AddStep("Down arrow", () => failOverlay.TriggerOnKeyDown(null, new KeyDownEventArgs { Key = Key.Down })); AddStep("Down arrow", () => press(Key.Down));
AddAssert("Last button selected", () => failOverlay.Buttons.Last().Selected); AddAssert("Last button selected", () => failOverlay.Buttons.Last().Selected);
AddStep("Down arrow", () => failOverlay.TriggerOnKeyDown(null, new KeyDownEventArgs { Key = Key.Down })); AddStep("Down arrow", () => press(Key.Down));
AddAssert("First button selected", () => failOverlay.Buttons.First().Selected); AddAssert("First button selected", () => failOverlay.Buttons.First().Selected);
AddStep("Hide overlay", () => failOverlay.Hide()); AddStep("Hide overlay", () => failOverlay.Hide());
@ -161,8 +167,8 @@ namespace osu.Game.Tests.Visual
var secondButton = pauseOverlay.Buttons.Skip(1).First(); var secondButton = pauseOverlay.Buttons.Skip(1).First();
AddStep("Down arrow", () => pauseOverlay.TriggerOnKeyDown(null, new KeyDownEventArgs { Key = Key.Down })); AddStep("Down arrow", () => press(Key.Down));
AddStep("Hover second button", () => secondButton.TriggerOnMouseMove(null)); AddStep("Hover second button", () => InputManager.MoveMouseTo(secondButton));
AddAssert("First button not selected", () => !pauseOverlay.Buttons.First().Selected); AddAssert("First button not selected", () => !pauseOverlay.Buttons.First().Selected);
AddAssert("Second button selected", () => secondButton.Selected); AddAssert("Second button selected", () => secondButton.Selected);
@ -174,12 +180,16 @@ namespace osu.Game.Tests.Visual
/// </summary> /// </summary>
private void testKeySelectionAfterMouseSelection() private void testKeySelectionAfterMouseSelection()
{ {
AddStep("Show overlay", () => pauseOverlay.Show()); AddStep("Show overlay", () =>
{
pauseOverlay.Show();
InputManager.MoveMouseTo(Vector2.Zero);
});
var secondButton = pauseOverlay.Buttons.Skip(1).First(); var secondButton = pauseOverlay.Buttons.Skip(1).First();
AddStep("Hover second button", () => secondButton.TriggerOnMouseMove(null)); AddStep("Hover second button", () => InputManager.MoveMouseTo(secondButton));
AddStep("Up arrow", () => pauseOverlay.TriggerOnKeyDown(null, new KeyDownEventArgs { Key = Key.Up })); AddStep("Up arrow", () => press(Key.Up));
AddAssert("Second button not selected", () => !secondButton.Selected); AddAssert("Second button not selected", () => !secondButton.Selected);
AddAssert("First button selected", () => pauseOverlay.Buttons.First().Selected); AddAssert("First button selected", () => pauseOverlay.Buttons.First().Selected);
@ -195,9 +205,9 @@ namespace osu.Game.Tests.Visual
var secondButton = pauseOverlay.Buttons.Skip(1).First(); var secondButton = pauseOverlay.Buttons.Skip(1).First();
AddStep("Hover second button", () => secondButton.TriggerOnMouseMove(null)); AddStep("Hover second button", () => InputManager.MoveMouseTo(secondButton));
AddStep("Unhover second button", () => secondButton.TriggerOnHoverLost(null)); AddStep("Unhover second button", () => InputManager.MoveMouseTo(Vector2.Zero));
AddStep("Down arrow", () => pauseOverlay.TriggerOnKeyDown(null, new KeyDownEventArgs { Key = Key.Down })); AddStep("Down arrow", () => press(Key.Down));
AddAssert("First button selected", () => pauseOverlay.Buttons.First().Selected); // Initial state condition AddAssert("First button selected", () => pauseOverlay.Buttons.First().Selected); // Initial state condition
AddStep("Hide overlay", () => pauseOverlay.Hide()); AddStep("Hide overlay", () => pauseOverlay.Hide());
@ -218,7 +228,7 @@ namespace osu.Game.Tests.Visual
var lastAction = pauseOverlay.OnRetry; var lastAction = pauseOverlay.OnRetry;
pauseOverlay.OnRetry = () => triggered = true; pauseOverlay.OnRetry = () => triggered = true;
retryButton.TriggerOnClick(); retryButton.Click();
pauseOverlay.OnRetry = lastAction; pauseOverlay.OnRetry = lastAction;
}); });
@ -235,23 +245,28 @@ namespace osu.Game.Tests.Visual
AddStep("Select second button", () => AddStep("Select second button", () =>
{ {
pauseOverlay.TriggerOnKeyDown(null, new KeyDownEventArgs { Key = Key.Down }); press(Key.Down);
pauseOverlay.TriggerOnKeyDown(null, new KeyDownEventArgs { Key = Key.Down }); press(Key.Down);
}); });
var retryButton = pauseOverlay.Buttons.Skip(1).First();
bool triggered = false; bool triggered = false;
Action lastAction = null;
AddStep("Press enter", () => AddStep("Press enter", () =>
{ {
var lastAction = pauseOverlay.OnRetry; lastAction = pauseOverlay.OnRetry;
pauseOverlay.OnRetry = () => triggered = true; pauseOverlay.OnRetry = () => triggered = true;
press(Key.Enter);
retryButton.TriggerOnKeyDown(null, new KeyDownEventArgs { Key = Key.Enter });
pauseOverlay.OnRetry = lastAction;
}); });
AddAssert("Action was triggered", () => triggered); AddAssert("Action was triggered", () =>
{
if (lastAction != null)
{
pauseOverlay.OnRetry = lastAction;
lastAction = null;
}
return triggered;
});
AddAssert("Overlay is closed", () => pauseOverlay.State == Visibility.Hidden); AddAssert("Overlay is closed", () => pauseOverlay.State == Visibility.Hidden);
} }
} }

View File

@ -6,7 +6,6 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Input.EventArgs;
using osu.Framework.MathUtils; using osu.Framework.MathUtils;
using osu.Framework.Timing; using osu.Framework.Timing;
using osu.Game.Screens.Play; using osu.Game.Screens.Play;
@ -15,7 +14,7 @@ using OpenTK.Input;
namespace osu.Game.Tests.Visual namespace osu.Game.Tests.Visual
{ {
[TestFixture] [TestFixture]
public class TestCaseKeyCounter : OsuTestCase public class TestCaseKeyCounter : ManualInputManagerTestCase
{ {
public override IReadOnlyList<Type> RequiredTypes => new[] public override IReadOnlyList<Type> RequiredTypes => new[]
{ {
@ -53,16 +52,16 @@ namespace osu.Game.Tests.Visual
AddStep($"Press {testKey} key", () => AddStep($"Press {testKey} key", () =>
{ {
rewindTestKeyCounterKeyboard.TriggerOnKeyDown(null, new KeyDownEventArgs { Key = testKey, Repeat = false }); InputManager.PressKey(testKey);
rewindTestKeyCounterKeyboard.TriggerOnKeyUp(null, new KeyUpEventArgs { Key = testKey }); InputManager.ReleaseKey(testKey);
}); });
AddAssert($"Check {testKey} counter after keypress", () => rewindTestKeyCounterKeyboard.CountPresses == 1); AddAssert($"Check {testKey} counter after keypress", () => rewindTestKeyCounterKeyboard.CountPresses == 1);
AddStep($"Press {testKey} key", () => AddStep($"Press {testKey} key", () =>
{ {
rewindTestKeyCounterKeyboard.TriggerOnKeyDown(null, new KeyDownEventArgs { Key = testKey, Repeat = false }); InputManager.PressKey(testKey);
rewindTestKeyCounterKeyboard.TriggerOnKeyUp(null, new KeyUpEventArgs { Key = testKey }); InputManager.ReleaseKey(testKey);
time1 = Clock.CurrentTime; time1 = Clock.CurrentTime;
}); });

View File

@ -27,13 +27,15 @@ namespace osu.Game.Beatmaps
[JsonProperty("id")] [JsonProperty("id")]
public int? OnlineBeatmapID public int? OnlineBeatmapID
{ {
get { return onlineBeatmapID; } get => onlineBeatmapID;
set { onlineBeatmapID = value > 0 ? value : null; } set => onlineBeatmapID = value > 0 ? value : null;
} }
[JsonIgnore] [JsonIgnore]
public int BeatmapSetInfoID { get; set; } public int BeatmapSetInfoID { get; set; }
public BeatmapSetOnlineStatus Status { get; set; } = BeatmapSetOnlineStatus.None;
[Required] [Required]
public BeatmapSetInfo BeatmapSet { get; set; } public BeatmapSetInfo BeatmapSet { get; set; }
@ -82,7 +84,7 @@ namespace osu.Game.Beatmaps
[JsonIgnore] [JsonIgnore]
public string StoredBookmarks public string StoredBookmarks
{ {
get { return string.Join(",", Bookmarks); } get => string.Join(",", Bookmarks);
set set
{ {
if (string.IsNullOrEmpty(value)) if (string.IsNullOrEmpty(value))
@ -93,8 +95,7 @@ namespace osu.Game.Beatmaps
Bookmarks = value.Split(',').Select(v => Bookmarks = value.Split(',').Select(v =>
{ {
int val; bool result = int.TryParse(v, out int val);
bool result = int.TryParse(v, out val);
return new { result, val }; return new { result, val };
}).Where(p => p.result).Select(p => p.val).ToArray(); }).Where(p => p.result).Select(p => p.val).ToArray();
} }

View File

@ -1,4 +1,4 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System; using System;
@ -104,7 +104,7 @@ namespace osu.Game.Beatmaps
validateOnlineIds(beatmapSet.Beatmaps); validateOnlineIds(beatmapSet.Beatmaps);
foreach (BeatmapInfo b in beatmapSet.Beatmaps) foreach (BeatmapInfo b in beatmapSet.Beatmaps)
fetchAndPopulateOnlineIDs(b, beatmapSet.Beatmaps); fetchAndPopulateOnlineValues(b, beatmapSet.Beatmaps);
// check if a set already exists with the same online id, delete if it does. // check if a set already exists with the same online id, delete if it does.
if (beatmapSet.OnlineBeatmapSetID != null) if (beatmapSet.OnlineBeatmapSetID != null)
@ -388,21 +388,22 @@ namespace osu.Game.Beatmaps
} }
/// <summary> /// <summary>
/// Query the API to populate mising OnlineBeatmapID / OnlineBeatmapSetID properties. /// Query the API to populate missing values like OnlineBeatmapID / OnlineBeatmapSetID or (Rank-)Status.
/// </summary> /// </summary>
/// <param name="beatmap">The beatmap to populate.</param> /// <param name="beatmap">The beatmap to populate.</param>
/// <param name="otherBeatmaps">The other beatmaps contained within this set.</param> /// <param name="otherBeatmaps">The other beatmaps contained within this set.</param>
/// <param name="force">Whether to re-query if the provided beatmap already has populated values.</param> /// <param name="force">Whether to re-query if the provided beatmap already has populated values.</param>
/// <returns>True if population was successful.</returns> /// <returns>True if population was successful.</returns>
private bool fetchAndPopulateOnlineIDs(BeatmapInfo beatmap, IEnumerable<BeatmapInfo> otherBeatmaps, bool force = false) private bool fetchAndPopulateOnlineValues(BeatmapInfo beatmap, IEnumerable<BeatmapInfo> otherBeatmaps, bool force = false)
{ {
if (api?.State != APIState.Online) if (api?.State != APIState.Online)
return false; return false;
if (!force && beatmap.OnlineBeatmapID != null && beatmap.BeatmapSet.OnlineBeatmapSetID != null) if (!force && beatmap.OnlineBeatmapID != null && beatmap.BeatmapSet.OnlineBeatmapSetID != null
&& beatmap.Status != BeatmapSetOnlineStatus.None && beatmap.BeatmapSet.Status != BeatmapSetOnlineStatus.None)
return true; return true;
Logger.Log("Attempting online lookup for IDs...", LoggingTarget.Database); Logger.Log("Attempting online lookup for the missing values...", LoggingTarget.Database);
try try
{ {
@ -414,6 +415,9 @@ namespace osu.Game.Beatmaps
Logger.Log($"Successfully mapped to {res.OnlineBeatmapSetID} / {res.OnlineBeatmapID}.", LoggingTarget.Database); Logger.Log($"Successfully mapped to {res.OnlineBeatmapSetID} / {res.OnlineBeatmapID}.", LoggingTarget.Database);
beatmap.Status = res.Status;
beatmap.BeatmapSet.Status = res.BeatmapSet.Status;
if (otherBeatmaps.Any(b => b.OnlineBeatmapID == res.OnlineBeatmapID)) if (otherBeatmaps.Any(b => b.OnlineBeatmapID == res.OnlineBeatmapID))
{ {
Logger.Log("Another beatmap in the same set already mapped to this ID. We'll skip adding it this time.", LoggingTarget.Database); Logger.Log("Another beatmap in the same set already mapped to this ID. We'll skip adding it this time.", LoggingTarget.Database);
@ -422,6 +426,7 @@ namespace osu.Game.Beatmaps
beatmap.BeatmapSet.OnlineBeatmapSetID = res.OnlineBeatmapSetID; beatmap.BeatmapSet.OnlineBeatmapSetID = res.OnlineBeatmapSetID;
beatmap.OnlineBeatmapID = res.OnlineBeatmapID; beatmap.OnlineBeatmapID = res.OnlineBeatmapID;
return true; return true;
} }
catch (Exception e) catch (Exception e)

View File

@ -2,6 +2,7 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Linq; using System.Linq;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Objects.Types;
namespace osu.Game.Beatmaps namespace osu.Game.Beatmaps
@ -44,6 +45,25 @@ namespace osu.Game.Beatmaps
public virtual void PostProcess() public virtual void PostProcess()
{ {
void updateNestedCombo(HitObject obj, int comboIndex, int indexInCurrentCombo)
{
if (obj is IHasComboInformation objectComboInfo)
{
objectComboInfo.ComboIndex = comboIndex;
objectComboInfo.IndexInCurrentCombo = indexInCurrentCombo;
foreach (var nestedObject in obj.NestedHitObjects)
updateNestedCombo(nestedObject, comboIndex, indexInCurrentCombo);
}
}
foreach (var hitObject in Beatmap.HitObjects)
{
if (hitObject is IHasComboInformation objectComboInfo)
{
foreach (var nested in hitObject.NestedHitObjects)
updateNestedCombo(nested, objectComboInfo.ComboIndex, objectComboInfo.IndexInCurrentCombo);
}
}
} }
} }
} }

View File

@ -17,10 +17,12 @@ namespace osu.Game.Beatmaps
public int? OnlineBeatmapSetID public int? OnlineBeatmapSetID
{ {
get { return onlineBeatmapSetID; } get => onlineBeatmapSetID;
set { onlineBeatmapSetID = value > 0 ? value : null; } set => onlineBeatmapSetID = value > 0 ? value : null;
} }
public BeatmapSetOnlineStatus Status { get; set; } = BeatmapSetOnlineStatus.None;
public BeatmapMetadata Metadata { get; set; } public BeatmapMetadata Metadata { get; set; }
public List<BeatmapInfo> Beatmaps { get; set; } public List<BeatmapInfo> Beatmaps { get; set; }

View File

@ -1,7 +1,6 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
@ -14,20 +13,35 @@ namespace osu.Game.Beatmaps.Drawables
{ {
private readonly OsuSpriteText statusText; private readonly OsuSpriteText statusText;
private BeatmapSetOnlineStatus status = BeatmapSetOnlineStatus.None; private BeatmapSetOnlineStatus status;
public BeatmapSetOnlineStatus Status public BeatmapSetOnlineStatus Status
{ {
get { return status; } get => status;
set set
{ {
if (value == status) return; if (status == value)
return;
status = value; status = value;
statusText.Text = Enum.GetName(typeof(BeatmapSetOnlineStatus), Status)?.ToUpperInvariant(); Alpha = value == BeatmapSetOnlineStatus.None ? 0 : 1;
statusText.Text = value.ToString().ToUpperInvariant();
} }
} }
public BeatmapSetOnlineStatusPill(float textSize, MarginPadding textPadding) public float TextSize
{
get => statusText.TextSize;
set => statusText.TextSize = value;
}
public MarginPadding TextPadding
{
get => statusText.Padding;
set => statusText.Padding = value;
}
public BeatmapSetOnlineStatusPill()
{ {
AutoSizeAxes = Axes.Both; AutoSizeAxes = Axes.Both;
Masking = true; Masking = true;
@ -45,10 +59,10 @@ namespace osu.Game.Beatmaps.Drawables
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
Font = @"Exo2.0-Bold", Font = @"Exo2.0-Bold",
TextSize = textSize,
Padding = textPadding,
}, },
}; };
Status = BeatmapSetOnlineStatus.None;
} }
} }
} }

View File

@ -85,13 +85,19 @@ namespace osu.Game.Beatmaps.Formats
string[] split = pair.Value.Split(','); string[] split = pair.Value.Split(',');
if (split.Length != 3) if (split.Length != 3 && split.Length != 4)
throw new InvalidOperationException($@"Color specified in incorrect format (should be R,G,B): {pair.Value}"); throw new InvalidOperationException($@"Color specified in incorrect format (should be R,G,B or R,G,B,A): {pair.Value}");
if (!byte.TryParse(split[0], out var r) || !byte.TryParse(split[1], out var g) || !byte.TryParse(split[2], out var b)) Color4 colour;
try
{
colour = new Color4(byte.Parse(split[0]), byte.Parse(split[1]), byte.Parse(split[2]), split.Length == 4 ? byte.Parse(split[3]) : (byte)255);
}
catch (Exception e)
{
throw new InvalidOperationException(@"Color must be specified with 8-bit integer components"); throw new InvalidOperationException(@"Color must be specified with 8-bit integer components");
}
Color4 colour = new Color4(r, g, b, 255);
if (isCombo) if (isCombo)
{ {

View File

@ -83,8 +83,6 @@ namespace osu.Game.Configuration
Set(OsuSetting.ScoreDisplayMode, ScoringMode.Standardised); Set(OsuSetting.ScoreDisplayMode, ScoringMode.Standardised);
Set(OsuSetting.SpeedChangeVisualisation, SpeedChangeVisualisationMethod.Sequential);
Set(OsuSetting.IncreaseFirstObjectVisibility, true); Set(OsuSetting.IncreaseFirstObjectVisibility, true);
// Update // Update
@ -143,7 +141,6 @@ namespace osu.Game.Configuration
ChatDisplayHeight, ChatDisplayHeight,
Version, Version,
ShowConvertedBeatmaps, ShowConvertedBeatmaps,
SpeedChangeVisualisation,
Skin, Skin,
ScreenshotFormat, ScreenshotFormat,
ScreenshotCaptureMenuCursor, ScreenshotCaptureMenuCursor,

View File

@ -10,6 +10,8 @@ namespace osu.Game.Configuration
[Description("Sequential")] [Description("Sequential")]
Sequential, Sequential,
[Description("Overlapping")] [Description("Overlapping")]
Overlapping Overlapping,
[Description("Constant")]
Constant
} }
} }

View File

@ -96,7 +96,8 @@ namespace osu.Game.Database
private void handleEvent(Action a) private void handleEvent(Action a)
{ {
if (delayingEvents) if (delayingEvents)
lock (queuedEvents) queuedEvents.Add(a); lock (queuedEvents)
queuedEvents.Add(a);
else else
a.Invoke(); a.Invoke();
} }
@ -281,17 +282,19 @@ namespace osu.Game.Database
/// Is a no-op for already deleted items. /// Is a no-op for already deleted items.
/// </summary> /// </summary>
/// <param name="item">The item to delete.</param> /// <param name="item">The item to delete.</param>
public void Delete(TModel item) /// <returns>false if no operation was performed</returns>
public bool Delete(TModel item)
{ {
using (ContextFactory.GetForWrite()) using (ContextFactory.GetForWrite())
{ {
// re-fetch the model on the import context. // re-fetch the model on the import context.
var foundModel = queryModel().Include(s => s.Files).ThenInclude(f => f.FileInfo).First(s => s.ID == item.ID); var foundModel = queryModel().Include(s => s.Files).ThenInclude(f => f.FileInfo).FirstOrDefault(s => s.ID == item.ID);
if (foundModel.DeletePending) return; if (foundModel == null || foundModel.DeletePending) return false;
if (ModelStore.Delete(foundModel)) if (ModelStore.Delete(foundModel))
Files.Dereference(foundModel.Files.Select(f => f.FileInfo).ToArray()); Files.Dereference(foundModel.Files.Select(f => f.FileInfo).ToArray());
return true;
} }
} }
@ -438,6 +441,13 @@ namespace osu.Game.Database
return Task.CompletedTask; return Task.CompletedTask;
} }
if (!stable.ExistsDirectory(ImportFromStablePath))
{
// This handles situations like when the user does not have a Skins folder
Logger.Log($"No {ImportFromStablePath} folder available in osu!stable installation", LoggingTarget.Information, LogLevel.Error);
return Task.CompletedTask;
}
return Task.Factory.StartNew(() => Import(stable.GetDirectories(ImportFromStablePath).Select(f => stable.GetFullPath(f)).ToArray()), TaskCreationOptions.LongRunning); return Task.Factory.StartNew(() => Import(stable.GetDirectories(ImportFromStablePath).Select(f => stable.GetFullPath(f)).ToArray()), TaskCreationOptions.LongRunning);
} }

View File

@ -6,7 +6,6 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures; using osu.Framework.Graphics.Textures;
using OpenTK.Graphics;
namespace osu.Game.Graphics.Backgrounds namespace osu.Game.Graphics.Backgrounds
{ {
@ -28,7 +27,6 @@ namespace osu.Game.Graphics.Backgrounds
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
Colour = Color4.DarkGray,
FillMode = FillMode.Fill, FillMode = FillMode.Fill,
}); });
} }

View File

@ -30,10 +30,6 @@ namespace osu.Game.Graphics.Backgrounds
/// </summary> /// </summary>
private const float edge_smoothness = 1; private const float edge_smoothness = 1;
public override bool HandleKeyboardInput => false;
public override bool HandleMouseInput => false;
public Color4 ColourLight = Color4.White; public Color4 ColourLight = Color4.White;
public Color4 ColourDark = Color4.Black; public Color4 ColourDark = Color4.Black;

View File

@ -20,8 +20,6 @@ namespace osu.Game.Graphics.Containers
{ {
} }
public override bool HandleMouseInput => true;
private OsuGame game; private OsuGame game;
private Action showNotImplementedError; private Action showNotImplementedError;

View File

@ -8,7 +8,7 @@ using osu.Framework.Graphics.Containers;
using OpenTK; using OpenTK;
using osu.Framework.Configuration; using osu.Framework.Configuration;
using osu.Framework.Input.Bindings; using osu.Framework.Input.Bindings;
using osu.Framework.Input.States; using osu.Framework.Input.Events;
using osu.Game.Audio; using osu.Game.Audio;
using osu.Game.Input.Bindings; using osu.Game.Input.Bindings;
using osu.Game.Overlays; using osu.Game.Overlays;
@ -22,7 +22,7 @@ namespace osu.Game.Graphics.Containers
protected virtual bool PlaySamplesOnStateChange => true; protected virtual bool PlaySamplesOnStateChange => true;
protected override bool BlockPassThroughKeyboard => true; protected override bool BlockNonPositionalInput => true;
private PreviewTrackManager previewTrackManager; private PreviewTrackManager previewTrackManager;
@ -54,20 +54,20 @@ namespace osu.Game.Graphics.Containers
/// Whether mouse input should be blocked screen-wide while this overlay is visible. /// Whether mouse input should be blocked screen-wide while this overlay is visible.
/// Performing mouse actions outside of the valid extents will hide the overlay. /// Performing mouse actions outside of the valid extents will hide the overlay.
/// </summary> /// </summary>
public virtual bool BlockScreenWideMouse => BlockPassThroughMouse; public virtual bool BlockScreenWideMouse => BlockPositionalInput;
// receive input outside our bounds so we can trigger a close event on ourselves. // receive input outside our bounds so we can trigger a close event on ourselves.
public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => BlockScreenWideMouse || base.ReceiveMouseInputAt(screenSpacePos); public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => BlockScreenWideMouse || base.ReceivePositionalInputAt(screenSpacePos);
protected override bool OnClick(InputState state) protected override bool OnClick(ClickEvent e)
{ {
if (!base.ReceiveMouseInputAt(state.Mouse.NativeState.Position)) if (!base.ReceivePositionalInputAt(e.ScreenSpaceMousePosition))
{ {
State = Visibility.Hidden; State = Visibility.Hidden;
return true; return true;
} }
return base.OnClick(state); return base.OnClick(e);
} }
public virtual bool OnPressed(GlobalAction action) public virtual bool OnPressed(GlobalAction action)

View File

@ -6,7 +6,7 @@ using OpenTK.Graphics;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Input.States; using osu.Framework.Input.Events;
namespace osu.Game.Graphics.Containers namespace osu.Game.Graphics.Containers
{ {
@ -18,16 +18,16 @@ namespace osu.Game.Graphics.Containers
protected virtual IEnumerable<Drawable> EffectTargets => new[] { Content }; protected virtual IEnumerable<Drawable> EffectTargets => new[] { Content };
protected override bool OnHover(InputState state) protected override bool OnHover(HoverEvent e)
{ {
EffectTargets.ForEach(d => d.FadeColour(HoverColour, 500, Easing.OutQuint)); EffectTargets.ForEach(d => d.FadeColour(HoverColour, 500, Easing.OutQuint));
return base.OnHover(state); return base.OnHover(e);
} }
protected override void OnHoverLost(InputState state) protected override void OnHoverLost(HoverLostEvent e)
{ {
EffectTargets.ForEach(d => d.FadeColour(IdleColour, 500, Easing.OutQuint)); EffectTargets.ForEach(d => d.FadeColour(IdleColour, 500, Easing.OutQuint));
base.OnHoverLost(state); base.OnHoverLost(e);
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]

View File

@ -2,8 +2,7 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Input.EventArgs; using osu.Framework.Input.Events;
using osu.Framework.Input.States;
using OpenTK.Input; using OpenTK.Input;
namespace osu.Game.Graphics.Containers namespace osu.Game.Graphics.Containers
@ -21,7 +20,7 @@ namespace osu.Game.Graphics.Containers
/// </summary> /// </summary>
public double DistanceDecayOnRightMouseScrollbar = 0.02; public double DistanceDecayOnRightMouseScrollbar = 0.02;
private bool shouldPerformRightMouseScroll(InputState state) => RightMouseScrollbar && state.Mouse.IsPressed(MouseButton.Right); private bool shouldPerformRightMouseScroll(MouseButtonEvent e) => RightMouseScrollbar && e.Button == MouseButton.Right;
private void scrollToRelative(float value) => ScrollTo(Clamp((value - Scrollbar.DrawSize[ScrollDim] / 2) / Scrollbar.Size[ScrollDim]), true, DistanceDecayOnRightMouseScrollbar); private void scrollToRelative(float value) => ScrollTo(Clamp((value - Scrollbar.DrawSize[ScrollDim] / 2) / Scrollbar.Size[ScrollDim]), true, DistanceDecayOnRightMouseScrollbar);
@ -29,40 +28,40 @@ namespace osu.Game.Graphics.Containers
protected override bool IsDragging => base.IsDragging || mouseScrollBarDragging; protected override bool IsDragging => base.IsDragging || mouseScrollBarDragging;
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) protected override bool OnMouseDown(MouseDownEvent e)
{ {
if (shouldPerformRightMouseScroll(state)) if (shouldPerformRightMouseScroll(e))
{ {
scrollToRelative(state.Mouse.Position[ScrollDim]); scrollToRelative(e.MousePosition[ScrollDim]);
return true; return true;
} }
return base.OnMouseDown(state, args); return base.OnMouseDown(e);
} }
protected override bool OnDrag(InputState state) protected override bool OnDrag(DragEvent e)
{ {
if (mouseScrollBarDragging) if (mouseScrollBarDragging)
{ {
scrollToRelative(state.Mouse.Position[ScrollDim]); scrollToRelative(e.MousePosition[ScrollDim]);
return true; return true;
} }
return base.OnDrag(state); return base.OnDrag(e);
} }
protected override bool OnDragStart(InputState state) protected override bool OnDragStart(DragStartEvent e)
{ {
if (shouldPerformRightMouseScroll(state)) if (shouldPerformRightMouseScroll(e))
{ {
mouseScrollBarDragging = true; mouseScrollBarDragging = true;
return true; return true;
} }
return base.OnDragStart(state); return base.OnDragStart(e);
} }
protected override bool OnDragEnd(InputState state) protected override bool OnDragEnd(DragEndEvent e)
{ {
if (mouseScrollBarDragging) if (mouseScrollBarDragging)
{ {
@ -70,7 +69,7 @@ namespace osu.Game.Graphics.Containers
return true; return true;
} }
return base.OnDragEnd(state); return base.OnDragEnd(e);
} }
} }
} }

View File

@ -67,7 +67,7 @@ namespace osu.Game.Graphics.Containers
if (parallaxEnabled) if (parallaxEnabled)
{ {
Vector2 offset = (input.CurrentState.Mouse == null ? Vector2.Zero : ToLocalSpace(input.CurrentState.Mouse.NativeState.Position) - DrawSize / 2) * ParallaxAmount; Vector2 offset = (input.CurrentState.Mouse == null ? Vector2.Zero : ToLocalSpace(input.CurrentState.Mouse.Position) - DrawSize / 2) * ParallaxAmount;
double elapsed = MathHelper.Clamp(Clock.ElapsedFrameTime, 0, 1000); double elapsed = MathHelper.Clamp(Clock.ElapsedFrameTime, 0, 1000);

View File

@ -12,8 +12,7 @@ using osu.Game.Configuration;
using System; using System;
using JetBrains.Annotations; using JetBrains.Annotations;
using osu.Framework.Graphics.Textures; using osu.Framework.Graphics.Textures;
using osu.Framework.Input.EventArgs; using osu.Framework.Input.Events;
using osu.Framework.Input.States;
using OpenTK.Input; using OpenTK.Input;
namespace osu.Game.Graphics.Cursor namespace osu.Game.Graphics.Cursor
@ -40,11 +39,11 @@ namespace osu.Game.Graphics.Cursor
screenshotCursorVisibility.BindTo(screenshotManager.CursorVisibility); screenshotCursorVisibility.BindTo(screenshotManager.CursorVisibility);
} }
protected override bool OnMouseMove(InputState state) protected override bool OnMouseMove(MouseMoveEvent e)
{ {
if (dragRotationState != DragRotationState.NotDragging) if (dragRotationState != DragRotationState.NotDragging)
{ {
var position = state.Mouse.Position; var position = e.MousePosition;
var distance = Vector2Extensions.Distance(position, positionMouseDown); var distance = Vector2Extensions.Distance(position, positionMouseDown);
// don't start rotating until we're moved a minimum distance away from the mouse down location, // don't start rotating until we're moved a minimum distance away from the mouse down location,
// else it can have an annoying effect. // else it can have an annoying effect.
@ -53,7 +52,7 @@ namespace osu.Game.Graphics.Cursor
// don't rotate when distance is zero to avoid NaN // don't rotate when distance is zero to avoid NaN
if (dragRotationState == DragRotationState.Rotating && distance > 0) if (dragRotationState == DragRotationState.Rotating && distance > 0)
{ {
Vector2 offset = state.Mouse.Position - positionMouseDown; Vector2 offset = e.MousePosition - positionMouseDown;
float degrees = (float)MathHelper.RadiansToDegrees(Math.Atan2(-offset.X, offset.Y)) + 24.3f; float degrees = (float)MathHelper.RadiansToDegrees(Math.Atan2(-offset.X, offset.Y)) + 24.3f;
// Always rotate in the direction of least distance // Always rotate in the direction of least distance
@ -66,13 +65,13 @@ namespace osu.Game.Graphics.Cursor
} }
} }
return base.OnMouseMove(state); return base.OnMouseMove(e);
} }
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) protected override bool OnMouseDown(MouseDownEvent e)
{ {
// only trigger animation for main mouse buttons // only trigger animation for main mouse buttons
if (args.Button <= MouseButton.Right) if (e.Button <= MouseButton.Right)
{ {
activeCursor.Scale = new Vector2(1); activeCursor.Scale = new Vector2(1);
activeCursor.ScaleTo(0.90f, 800, Easing.OutQuint); activeCursor.ScaleTo(0.90f, 800, Easing.OutQuint);
@ -81,29 +80,29 @@ namespace osu.Game.Graphics.Cursor
activeCursor.AdditiveLayer.FadeInFromZero(800, Easing.OutQuint); activeCursor.AdditiveLayer.FadeInFromZero(800, Easing.OutQuint);
} }
if (args.Button == MouseButton.Left && cursorRotate) if (e.Button == MouseButton.Left && cursorRotate)
{ {
dragRotationState = DragRotationState.DragStarted; dragRotationState = DragRotationState.DragStarted;
positionMouseDown = state.Mouse.Position; positionMouseDown = e.MousePosition;
} }
return base.OnMouseDown(state, args); return base.OnMouseDown(e);
} }
protected override bool OnMouseUp(InputState state, MouseUpEventArgs args) protected override bool OnMouseUp(MouseUpEvent e)
{ {
if (!state.Mouse.HasMainButtonPressed) if (!e.IsPressed(MouseButton.Left) && !e.IsPressed(MouseButton.Right))
{ {
activeCursor.AdditiveLayer.FadeOutFromOne(500, Easing.OutQuint); activeCursor.AdditiveLayer.FadeOutFromOne(500, Easing.OutQuint);
activeCursor.ScaleTo(1, 500, Easing.OutElastic); activeCursor.ScaleTo(1, 500, Easing.OutElastic);
} }
if (args.Button == MouseButton.Left) if (e.Button == MouseButton.Left)
{ {
if (dragRotationState == DragRotationState.Rotating) if (dragRotationState == DragRotationState.Rotating)
activeCursor.RotateTo(0, 600 * (1 + Math.Abs(activeCursor.Rotation / 720)), Easing.OutElasticHalf); activeCursor.RotateTo(0, 600 * (1 + Math.Abs(activeCursor.Rotation / 720)), Easing.OutElasticHalf);
dragRotationState = DragRotationState.NotDragging; dragRotationState = DragRotationState.NotDragging;
} }
return base.OnMouseUp(state, args); return base.OnMouseUp(e);
} }
protected override void PopIn() protected override void PopIn()

View File

@ -54,8 +54,6 @@ namespace osu.Game.Graphics
Scheduler.AddDelayed(updateTimeWithReschedule, timeUntilNextUpdate); Scheduler.AddDelayed(updateTimeWithReschedule, timeUntilNextUpdate);
} }
public override bool HandleMouseInput => true;
protected virtual string Format() => Date.Humanize(); protected virtual string Format() => Date.Humanize();
private void updateTime() => Text = Format(); private void updateTime() => Text = Format();

View File

@ -47,10 +47,10 @@ namespace osu.Game.Graphics.UserInterface
public readonly SpriteIcon Chevron; public readonly SpriteIcon Chevron;
//don't allow clicking between transitions and don't make the chevron clickable //don't allow clicking between transitions and don't make the chevron clickable
public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => Alpha == 1f && Text.ReceiveMouseInputAt(screenSpacePos); public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => Alpha == 1f && Text.ReceivePositionalInputAt(screenSpacePos);
public override bool HandleKeyboardInput => State == Visibility.Visible; public override bool HandleNonPositionalInput => State == Visibility.Visible;
public override bool HandleMouseInput => State == Visibility.Visible; public override bool HandlePositionalInput => State == Visibility.Visible;
public override bool IsRemovable => true; public override bool IsRemovable => true;
private Visibility state; private Visibility state;

View File

@ -13,7 +13,7 @@ using osu.Game.Graphics.Sprites;
using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.Color4Extensions;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Framework.Configuration; using osu.Framework.Configuration;
using osu.Framework.Input.States; using osu.Framework.Input.Events;
namespace osu.Game.Graphics.UserInterface namespace osu.Game.Graphics.UserInterface
{ {
@ -211,9 +211,9 @@ namespace osu.Game.Graphics.UserInterface
} }
} }
public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => backgroundContainer.ReceiveMouseInputAt(screenSpacePos); public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => backgroundContainer.ReceivePositionalInputAt(screenSpacePos);
protected override bool OnClick(InputState state) protected override bool OnClick(ClickEvent e)
{ {
colourContainer.ResizeTo(new Vector2(1.5f, 1f), click_duration, Easing.In); colourContainer.ResizeTo(new Vector2(1.5f, 1f), click_duration, Easing.In);
flash(); flash();
@ -225,20 +225,20 @@ namespace osu.Game.Graphics.UserInterface
glowContainer.FadeOut(); glowContainer.FadeOut();
}); });
return base.OnClick(state); return base.OnClick(e);
} }
protected override bool OnHover(InputState state) protected override bool OnHover(HoverEvent e)
{ {
base.OnHover(state); base.OnHover(e);
Selected.Value = true; Selected.Value = true;
return true; return true;
} }
protected override void OnHoverLost(InputState state) protected override void OnHoverLost(HoverLostEvent e)
{ {
base.OnHoverLost(state); base.OnHoverLost(e);
Selected.Value = false; Selected.Value = false;
} }

View File

@ -5,7 +5,7 @@ using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Cursor;
using osu.Framework.Input.States; using osu.Framework.Input.Events;
using osu.Framework.Platform; using osu.Framework.Platform;
using OpenTK; using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
@ -37,19 +37,19 @@ namespace osu.Game.Graphics.UserInterface
this.host = host; this.host = host;
} }
protected override bool OnHover(InputState state) protected override bool OnHover(HoverEvent e)
{ {
InternalChild.FadeColour(hoverColour, 500, Easing.OutQuint); InternalChild.FadeColour(hoverColour, 500, Easing.OutQuint);
return base.OnHover(state); return base.OnHover(e);
} }
protected override void OnHoverLost(InputState state) protected override void OnHoverLost(HoverLostEvent e)
{ {
InternalChild.FadeColour(Color4.White, 500, Easing.OutQuint); InternalChild.FadeColour(Color4.White, 500, Easing.OutQuint);
base.OnHoverLost(state); base.OnHoverLost(e);
} }
protected override bool OnClick(InputState state) protected override bool OnClick(ClickEvent e)
{ {
if(Link != null) if(Link != null)
host.OpenUrlExternally(Link); host.OpenUrlExternally(Link);

View File

@ -3,8 +3,7 @@
using OpenTK.Graphics; using OpenTK.Graphics;
using System; using System;
using osu.Framework.Input.EventArgs; using osu.Framework.Input.Events;
using osu.Framework.Input.States;
using osu.Game.Input.Bindings; using osu.Game.Input.Bindings;
using OpenTK.Input; using OpenTK.Input;
@ -34,22 +33,22 @@ namespace osu.Game.Graphics.UserInterface
} }
// We may not be focused yet, but we need to handle keyboard input to be able to request focus // We may not be focused yet, but we need to handle keyboard input to be able to request focus
public override bool HandleKeyboardInput => HoldFocus || base.HandleKeyboardInput; public override bool HandleNonPositionalInput => HoldFocus || base.HandleNonPositionalInput;
protected override void OnFocus(InputState state) protected override void OnFocus(FocusEvent e)
{ {
base.OnFocus(state); base.OnFocus(e);
BorderThickness = 0; BorderThickness = 0;
} }
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) protected override bool OnKeyDown(KeyDownEvent e)
{ {
if (!HasFocus) return false; if (!HasFocus) return false;
if (args.Key == Key.Escape) if (e.Key == Key.Escape)
return false; // disable the framework-level handling of escape key for confority (we use GlobalAction.Back). return false; // disable the framework-level handling of escape key for confority (we use GlobalAction.Back).
return base.OnKeyDown(state, args); return base.OnKeyDown(e);
} }
public override bool OnPressed(GlobalAction action) public override bool OnPressed(GlobalAction action)

View File

@ -5,7 +5,7 @@ using osu.Framework.Allocation;
using osu.Framework.Audio; using osu.Framework.Audio;
using osu.Framework.Audio.Sample; using osu.Framework.Audio.Sample;
using osu.Framework.Extensions; using osu.Framework.Extensions;
using osu.Framework.Input.States; using osu.Framework.Input.Events;
namespace osu.Game.Graphics.UserInterface namespace osu.Game.Graphics.UserInterface
{ {
@ -21,10 +21,10 @@ namespace osu.Game.Graphics.UserInterface
{ {
} }
protected override bool OnClick(InputState state) protected override bool OnClick(ClickEvent e)
{ {
sampleClick?.Play(); sampleClick?.Play();
return base.OnClick(state); return base.OnClick(e);
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]

View File

@ -8,7 +8,7 @@ using osu.Framework.Audio.Sample;
using osu.Framework.Extensions; using osu.Framework.Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Input.States; using osu.Framework.Input.Events;
namespace osu.Game.Graphics.UserInterface namespace osu.Game.Graphics.UserInterface
{ {
@ -28,10 +28,10 @@ namespace osu.Game.Graphics.UserInterface
RelativeSizeAxes = Axes.Both; RelativeSizeAxes = Axes.Both;
} }
protected override bool OnHover(InputState state) protected override bool OnHover(HoverEvent e)
{ {
sampleHover?.Play(); sampleHover?.Play();
return base.OnHover(state); return base.OnHover(e);
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]

View File

@ -4,7 +4,7 @@
using OpenTK; using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Input.States; using osu.Framework.Input.Events;
namespace osu.Game.Graphics.UserInterface namespace osu.Game.Graphics.UserInterface
{ {
@ -84,16 +84,16 @@ namespace osu.Game.Graphics.UserInterface
}); });
} }
protected override bool OnHover(InputState state) protected override bool OnHover(HoverEvent e)
{ {
icon.FadeColour(IconHoverColour, 500, Easing.OutQuint); icon.FadeColour(IconHoverColour, 500, Easing.OutQuint);
return base.OnHover(state); return base.OnHover(e);
} }
protected override void OnHoverLost(InputState state) protected override void OnHoverLost(HoverLostEvent e)
{ {
icon.FadeColour(IconColour, 500, Easing.OutQuint); icon.FadeColour(IconColour, 500, Easing.OutQuint);
base.OnHoverLost(state); base.OnHoverLost(e);
} }
} }
} }

View File

@ -6,8 +6,7 @@ using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.EventArgs; using osu.Framework.Input.Events;
using osu.Framework.Input.States;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using OpenTK.Graphics; using OpenTK.Graphics;
@ -77,34 +76,34 @@ namespace osu.Game.Graphics.UserInterface
Enabled.BindValueChanged(enabled => this.FadeColour(enabled ? Color4.White : colours.Gray9, 200, Easing.OutQuint), true); Enabled.BindValueChanged(enabled => this.FadeColour(enabled ? Color4.White : colours.Gray9, 200, Easing.OutQuint), true);
} }
protected override bool OnHover(InputState state) protected override bool OnHover(HoverEvent e)
{ {
hover.FadeIn(500, Easing.OutQuint); hover.FadeIn(500, Easing.OutQuint);
return base.OnHover(state); return base.OnHover(e);
} }
protected override void OnHoverLost(InputState state) protected override void OnHoverLost(HoverLostEvent e)
{ {
hover.FadeOut(500, Easing.OutQuint); hover.FadeOut(500, Easing.OutQuint);
base.OnHoverLost(state); base.OnHoverLost(e);
} }
protected override bool OnClick(InputState state) protected override bool OnClick(ClickEvent e)
{ {
hover.FlashColour(FlashColour, 800, Easing.OutQuint); hover.FlashColour(FlashColour, 800, Easing.OutQuint);
return base.OnClick(state); return base.OnClick(e);
} }
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) protected override bool OnMouseDown(MouseDownEvent e)
{ {
Content.ScaleTo(0.75f, 2000, Easing.OutQuint); Content.ScaleTo(0.75f, 2000, Easing.OutQuint);
return base.OnMouseDown(state, args); return base.OnMouseDown(e);
} }
protected override bool OnMouseUp(InputState state, MouseUpEventArgs args) protected override bool OnMouseUp(MouseUpEvent e)
{ {
Content.ScaleTo(1, 1000, Easing.OutElastic); Content.ScaleTo(1, 1000, Easing.OutElastic);
return base.OnMouseUp(state, args); return base.OnMouseUp(e);
} }
} }
} }

View File

@ -7,8 +7,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.UserInterface; using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input.EventArgs; using osu.Framework.Input.Events;
using osu.Framework.Input.States;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using OpenTK.Graphics; using OpenTK.Graphics;
@ -56,28 +55,28 @@ namespace osu.Game.Graphics.UserInterface
this.FadeColour(enabled ? Color4.White : Color4.Gray, 200, Easing.OutQuint); this.FadeColour(enabled ? Color4.White : Color4.Gray, 200, Easing.OutQuint);
} }
protected override bool OnHover(InputState state) protected override bool OnHover(HoverEvent e)
{ {
hover.FadeIn(200); hover.FadeIn(200);
return base.OnHover(state); return base.OnHover(e);
} }
protected override void OnHoverLost(InputState state) protected override void OnHoverLost(HoverLostEvent e)
{ {
hover.FadeOut(200); hover.FadeOut(200);
base.OnHoverLost(state); base.OnHoverLost(e);
} }
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) protected override bool OnMouseDown(MouseDownEvent e)
{ {
Content.ScaleTo(0.9f, 4000, Easing.OutQuint); Content.ScaleTo(0.9f, 4000, Easing.OutQuint);
return base.OnMouseDown(state, args); return base.OnMouseDown(e);
} }
protected override bool OnMouseUp(InputState state, MouseUpEventArgs args) protected override bool OnMouseUp(MouseUpEvent e)
{ {
Content.ScaleTo(1, 1000, Easing.OutElastic); Content.ScaleTo(1, 1000, Easing.OutElastic);
return base.OnMouseUp(state, args); return base.OnMouseUp(e);
} }
protected override SpriteText CreateText() => new OsuSpriteText protected override SpriteText CreateText() => new OsuSpriteText

View File

@ -8,7 +8,7 @@ using osu.Framework.Configuration;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.UserInterface; using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input.States; using osu.Framework.Input.Events;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using OpenTK.Graphics; using OpenTK.Graphics;
@ -95,18 +95,18 @@ namespace osu.Game.Graphics.UserInterface
}; };
} }
protected override bool OnHover(InputState state) protected override bool OnHover(HoverEvent e)
{ {
Nub.Glowing = true; Nub.Glowing = true;
Nub.Expanded = true; Nub.Expanded = true;
return base.OnHover(state); return base.OnHover(e);
} }
protected override void OnHoverLost(InputState state) protected override void OnHoverLost(HoverLostEvent e)
{ {
Nub.Glowing = false; Nub.Glowing = false;
Nub.Expanded = false; Nub.Expanded = false;
base.OnHoverLost(state); base.OnHoverLost(e);
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]

View File

@ -51,6 +51,8 @@ namespace osu.Game.Graphics.UserInterface
#region OsuDropdownMenu #region OsuDropdownMenu
protected class OsuDropdownMenu : DropdownMenu, IHasAccentColour protected class OsuDropdownMenu : DropdownMenu, IHasAccentColour
{ {
public override bool HandleNonPositionalInput => State == MenuState.Open;
// todo: this uses the same styling as OsuMenu. hopefully we can just use OsuMenu in the future with some refactoring // todo: this uses the same styling as OsuMenu. hopefully we can just use OsuMenu in the future with some refactoring
public OsuDropdownMenu() public OsuDropdownMenu()
{ {
@ -97,6 +99,9 @@ namespace osu.Game.Graphics.UserInterface
#region DrawableOsuDropdownMenuItem #region DrawableOsuDropdownMenuItem
public class DrawableOsuDropdownMenuItem : DrawableDropdownMenuItem, IHasAccentColour public class DrawableOsuDropdownMenuItem : DrawableDropdownMenuItem, IHasAccentColour
{ {
// IsHovered is used
public override bool HandlePositionalInput => true;
private Color4? accentColour; private Color4? accentColour;
public Color4 AccentColour public Color4 AccentColour
{ {

View File

@ -10,7 +10,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.UserInterface; using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input.States; using osu.Framework.Input.Events;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using OpenTK; using OpenTK;
@ -97,25 +97,25 @@ namespace osu.Game.Graphics.UserInterface
} }
} }
protected override bool OnHover(InputState state) protected override bool OnHover(HoverEvent e)
{ {
sampleHover.Play(); sampleHover.Play();
text.BoldText.FadeIn(transition_length, Easing.OutQuint); text.BoldText.FadeIn(transition_length, Easing.OutQuint);
text.NormalText.FadeOut(transition_length, Easing.OutQuint); text.NormalText.FadeOut(transition_length, Easing.OutQuint);
return base.OnHover(state); return base.OnHover(e);
} }
protected override void OnHoverLost(InputState state) protected override void OnHoverLost(HoverLostEvent e)
{ {
text.BoldText.FadeOut(transition_length, Easing.OutQuint); text.BoldText.FadeOut(transition_length, Easing.OutQuint);
text.NormalText.FadeIn(transition_length, Easing.OutQuint); text.NormalText.FadeIn(transition_length, Easing.OutQuint);
base.OnHoverLost(state); base.OnHoverLost(e);
} }
protected override bool OnClick(InputState state) protected override bool OnClick(ClickEvent e)
{ {
sampleClick.Play(); sampleClick.Play();
return base.OnClick(state); return base.OnClick(e);
} }
protected sealed override Drawable CreateContent() => text = CreateTextContainer(); protected sealed override Drawable CreateContent() => text = CreateTextContainer();

View File

@ -9,8 +9,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.EventArgs; using osu.Framework.Input.Events;
using osu.Framework.Input.States;
using osu.Framework.Platform; using osu.Framework.Platform;
namespace osu.Game.Graphics.UserInterface namespace osu.Game.Graphics.UserInterface
@ -43,23 +42,23 @@ namespace osu.Game.Graphics.UserInterface
this.host = host; this.host = host;
} }
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) protected override bool OnKeyDown(KeyDownEvent e)
{ {
if (args.Key == Key.CapsLock) if (e.Key == Key.CapsLock)
updateCapsWarning(host.CapsLockEnabled); updateCapsWarning(host.CapsLockEnabled);
return base.OnKeyDown(state, args); return base.OnKeyDown(e);
} }
protected override void OnFocus(InputState state) protected override void OnFocus(FocusEvent e)
{ {
updateCapsWarning(host.CapsLockEnabled); updateCapsWarning(host.CapsLockEnabled);
base.OnFocus(state); base.OnFocus(e);
} }
protected override void OnFocusLost(InputState state) protected override void OnFocusLost(FocusLostEvent e)
{ {
updateCapsWarning(false); updateCapsWarning(false);
base.OnFocusLost(state); base.OnFocusLost(e);
} }
private void updateCapsWarning(bool visible) => warning.FadeTo(visible ? 1 : 0, 250, Easing.OutQuint); private void updateCapsWarning(bool visible) => warning.FadeTo(visible ? 1 : 0, 250, Easing.OutQuint);

View File

@ -13,8 +13,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.UserInterface; using osu.Framework.Graphics.UserInterface;
using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.EventArgs; using osu.Framework.Input.Events;
using osu.Framework.Input.States;
namespace osu.Game.Graphics.UserInterface namespace osu.Game.Graphics.UserInterface
{ {
@ -125,16 +124,16 @@ namespace osu.Game.Graphics.UserInterface
AccentColour = colours.Pink; AccentColour = colours.Pink;
} }
protected override bool OnHover(InputState state) protected override bool OnHover(HoverEvent e)
{ {
Nub.Glowing = true; Nub.Glowing = true;
return base.OnHover(state); return base.OnHover(e);
} }
protected override void OnHoverLost(InputState state) protected override void OnHoverLost(HoverLostEvent e)
{ {
Nub.Glowing = false; Nub.Glowing = false;
base.OnHoverLost(state); base.OnHoverLost(e);
} }
protected override void OnUserChange() protected override void OnUserChange()
@ -164,16 +163,16 @@ namespace osu.Game.Graphics.UserInterface
sample.Play(); sample.Play();
} }
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) protected override bool OnMouseDown(MouseDownEvent e)
{ {
Nub.Current.Value = true; Nub.Current.Value = true;
return base.OnMouseDown(state, args); return base.OnMouseDown(e);
} }
protected override bool OnMouseUp(InputState state, MouseUpEventArgs args) protected override bool OnMouseUp(MouseUpEvent e)
{ {
Nub.Current.Value = false; Nub.Current.Value = false;
return base.OnMouseUp(state, args); return base.OnMouseUp(e);
} }
protected override void UpdateAfterChildren() protected override void UpdateAfterChildren()

View File

@ -14,7 +14,7 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.UserInterface; using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input.States; using osu.Framework.Input.Events;
using osu.Framework.MathUtils; using osu.Framework.MathUtils;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
@ -126,14 +126,14 @@ namespace osu.Game.Graphics.UserInterface
Text.FadeColour(AccentColour, transition_length, Easing.OutQuint); Text.FadeColour(AccentColour, transition_length, Easing.OutQuint);
} }
protected override bool OnHover(InputState state) protected override bool OnHover(HoverEvent e)
{ {
if (!Active) if (!Active)
fadeActive(); fadeActive();
return true; return true;
} }
protected override void OnHoverLost(InputState state) protected override void OnHoverLost(HoverLostEvent e)
{ {
if (!Active) if (!Active)
fadeInactive(); fadeInactive();
@ -265,16 +265,16 @@ namespace osu.Game.Graphics.UserInterface
Padding = new MarginPadding { Left = 5, Right = 5 }; Padding = new MarginPadding { Left = 5, Right = 5 };
} }
protected override bool OnHover(InputState state) protected override bool OnHover(HoverEvent e)
{ {
Foreground.Colour = BackgroundColour; Foreground.Colour = BackgroundColour;
return base.OnHover(state); return base.OnHover(e);
} }
protected override void OnHoverLost(InputState state) protected override void OnHoverLost(HoverLostEvent e)
{ {
Foreground.Colour = BackgroundColourHover; Foreground.Colour = BackgroundColourHover;
base.OnHoverLost(state); base.OnHoverLost(e);
} }
} }
} }

View File

@ -10,7 +10,7 @@ using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.UserInterface; using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input.States; using osu.Framework.Input.Events;
namespace osu.Game.Graphics.UserInterface namespace osu.Game.Graphics.UserInterface
{ {
@ -59,18 +59,18 @@ namespace osu.Game.Graphics.UserInterface
text.FadeColour(AccentColour, transition_length, Easing.OutQuint); text.FadeColour(AccentColour, transition_length, Easing.OutQuint);
} }
protected override bool OnHover(InputState state) protected override bool OnHover(HoverEvent e)
{ {
fadeIn(); fadeIn();
return base.OnHover(state); return base.OnHover(e);
} }
protected override void OnHoverLost(InputState state) protected override void OnHoverLost(HoverLostEvent e)
{ {
if (!Current) if (!Current)
fadeOut(); fadeOut();
base.OnHoverLost(state); base.OnHoverLost(e);
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]

View File

@ -9,7 +9,7 @@ using osu.Game.Graphics.Sprites;
using OpenTK.Graphics; using OpenTK.Graphics;
using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Input.Bindings; using osu.Framework.Input.Bindings;
using osu.Framework.Input.States; using osu.Framework.Input.Events;
using osu.Game.Input.Bindings; using osu.Game.Input.Bindings;
namespace osu.Game.Graphics.UserInterface namespace osu.Game.Graphics.UserInterface
@ -44,17 +44,17 @@ namespace osu.Game.Graphics.UserInterface
BorderColour = colour.Yellow; BorderColour = colour.Yellow;
} }
protected override void OnFocus(InputState state) protected override void OnFocus(FocusEvent e)
{ {
BorderThickness = 3; BorderThickness = 3;
base.OnFocus(state); base.OnFocus(e);
} }
protected override void OnFocusLost(InputState state) protected override void OnFocusLost(FocusLostEvent e)
{ {
BorderThickness = 0; BorderThickness = 0;
base.OnFocusLost(state); base.OnFocusLost(e);
} }
protected override Drawable GetDrawableCharacter(char c) => new OsuSpriteText { Text = c.ToString(), TextSize = CalculatedTextSize }; protected override Drawable GetDrawableCharacter(char c) => new OsuSpriteText { Text = c.ToString(), TextSize = CalculatedTextSize };

View File

@ -10,7 +10,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.UserInterface; using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input.States; using osu.Framework.Input.Events;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
namespace osu.Game.Graphics.UserInterface namespace osu.Game.Graphics.UserInterface
@ -67,14 +67,14 @@ namespace osu.Game.Graphics.UserInterface
box.Colour = colours.Yellow; box.Colour = colours.Yellow;
} }
protected override bool OnHover(InputState state) protected override bool OnHover(HoverEvent e)
{ {
if (!Active) if (!Active)
slideActive(); slideActive();
return true; return true;
} }
protected override void OnHoverLost(InputState state) protected override void OnHoverLost(HoverLostEvent e)
{ {
if (!Active) if (!Active)
slideInactive(); slideInactive();

View File

@ -2,8 +2,7 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Input.EventArgs; using osu.Framework.Input.Events;
using osu.Framework.Input.States;
using OpenTK; using OpenTK;
using OpenTK.Input; using OpenTK.Input;
@ -33,11 +32,11 @@ namespace osu.Game.Graphics.UserInterface
PlaceholderText = "type to search"; PlaceholderText = "type to search";
} }
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) protected override bool OnKeyDown(KeyDownEvent e)
{ {
if (!state.Keyboard.ControlPressed && !state.Keyboard.ShiftPressed) if (!e.ControlPressed && !e.ShiftPressed)
{ {
switch (args.Key) switch (e.Key)
{ {
case Key.Left: case Key.Left:
case Key.Right: case Key.Right:
@ -49,7 +48,7 @@ namespace osu.Game.Graphics.UserInterface
if (!AllowCommit) if (!AllowCommit)
{ {
switch (args.Key) switch (e.Key)
{ {
case Key.KeypadEnter: case Key.KeypadEnter:
case Key.Enter: case Key.Enter:
@ -57,16 +56,16 @@ namespace osu.Game.Graphics.UserInterface
} }
} }
if (state.Keyboard.ShiftPressed) if (e.ShiftPressed)
{ {
switch (args.Key) switch (e.Key)
{ {
case Key.Delete: case Key.Delete:
return false; return false;
} }
} }
return base.OnKeyDown(state, args); return base.OnKeyDown(e);
} }
} }
} }

View File

@ -13,8 +13,7 @@ using osu.Game.Beatmaps.ControlPoints;
using osu.Framework.Audio.Track; using osu.Framework.Audio.Track;
using System; using System;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.EventArgs; using osu.Framework.Input.Events;
using osu.Framework.Input.States;
namespace osu.Game.Graphics.UserInterface namespace osu.Game.Graphics.UserInterface
{ {
@ -170,9 +169,9 @@ namespace osu.Game.Graphics.UserInterface
} }
} }
public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => IconLayer.ReceiveMouseInputAt(screenSpacePos) || TextLayer.ReceiveMouseInputAt(screenSpacePos); public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => IconLayer.ReceivePositionalInputAt(screenSpacePos) || TextLayer.ReceivePositionalInputAt(screenSpacePos);
protected override bool OnHover(InputState state) protected override bool OnHover(HoverEvent e)
{ {
this.ResizeTo(SIZE_EXTENDED, transform_time, Easing.OutElastic); this.ResizeTo(SIZE_EXTENDED, transform_time, Easing.OutElastic);
IconLayer.FadeColour(HoverColour, transform_time, Easing.OutElastic); IconLayer.FadeColour(HoverColour, transform_time, Easing.OutElastic);
@ -182,7 +181,7 @@ namespace osu.Game.Graphics.UserInterface
return true; return true;
} }
protected override void OnHoverLost(InputState state) protected override void OnHoverLost(HoverLostEvent e)
{ {
this.ResizeTo(SIZE_RETRACTED, transform_time, Easing.OutElastic); this.ResizeTo(SIZE_RETRACTED, transform_time, Easing.OutElastic);
IconLayer.FadeColour(TextLayer.Colour, transform_time, Easing.OutElastic); IconLayer.FadeColour(TextLayer.Colour, transform_time, Easing.OutElastic);
@ -190,12 +189,12 @@ namespace osu.Game.Graphics.UserInterface
bouncingIcon.ScaleTo(1, transform_time, Easing.OutElastic); bouncingIcon.ScaleTo(1, transform_time, Easing.OutElastic);
} }
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) protected override bool OnMouseDown(MouseDownEvent e)
{ {
return true; return true;
} }
protected override bool OnClick(InputState state) protected override bool OnClick(ClickEvent e)
{ {
var flash = new Box var flash = new Box
{ {
@ -209,7 +208,7 @@ namespace osu.Game.Graphics.UserInterface
flash.FadeOut(500, Easing.OutQuint); flash.FadeOut(500, Easing.OutQuint);
flash.Expire(); flash.Expire();
return base.OnClick(state); return base.OnClick(e);
} }
private class BouncingIcon : BeatSyncedContainer private class BouncingIcon : BeatSyncedContainer

View File

@ -37,7 +37,7 @@ namespace osu.Game.IPC
return; return;
} }
if (importer.HandledExtensions.Contains(Path.GetExtension(path))) if (importer.HandledExtensions.Contains(Path.GetExtension(path)?.ToLowerInvariant()))
importer.Import(path); importer.Import(path);
} }
} }

View File

@ -3,10 +3,13 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using osu.Framework.Input.Handlers; using osu.Framework.Input.Handlers;
using osu.Framework.Input.StateChanges; using osu.Framework.Input.StateChanges;
using osu.Framework.Input.StateChanges.Events;
using osu.Framework.Input.States; using osu.Framework.Input.States;
using osu.Framework.Platform; using osu.Framework.Platform;
using osu.Game.Rulesets.UI;
using OpenTK; using OpenTK;
namespace osu.Game.Input.Handlers namespace osu.Game.Input.Handlers
@ -40,7 +43,29 @@ namespace osu.Game.Input.Handlers
public void Apply(InputState state, IInputStateChangeHandler handler) public void Apply(InputState state, IInputStateChangeHandler handler)
{ {
handler.HandleCustomInput(state, this); if (!(state is RulesetInputManagerInputState<T> inputState))
throw new InvalidOperationException($"{nameof(ReplayState<T>)} should only be applied to a {nameof(RulesetInputManagerInputState<T>)}");
var lastPressed = inputState.LastReplayState?.PressedActions ?? new List<T>();
var released = lastPressed.Except(PressedActions).ToArray();
var pressed = PressedActions.Except(lastPressed).ToArray();
inputState.LastReplayState = this;
handler.HandleInputStateChange(new ReplayStateChangeEvent<T>(state, this, released, pressed));
}
}
public class ReplayStateChangeEvent<T> : InputStateChangeEvent
{
public readonly T[] ReleasedActions;
public readonly T[] PressedActions;
public ReplayStateChangeEvent(InputState state, IInput input, T[] releasedActions, T[] pressedActions)
: base(state, input)
{
ReleasedActions = releasedActions;
PressedActions = pressedActions;
} }
} }
} }

View File

@ -0,0 +1,380 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using osu.Game.Database;
namespace osu.Game.Migrations
{
[DbContext(typeof(OsuDbContext))]
[Migration("20180913080842_AddRankStatus")]
partial class AddRankStatus
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "2.1.2-rtm-30932");
modelBuilder.Entity("osu.Game.Beatmaps.BeatmapDifficulty", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd();
b.Property<float>("ApproachRate");
b.Property<float>("CircleSize");
b.Property<float>("DrainRate");
b.Property<float>("OverallDifficulty");
b.Property<double>("SliderMultiplier");
b.Property<double>("SliderTickRate");
b.HasKey("ID");
b.ToTable("BeatmapDifficulty");
});
modelBuilder.Entity("osu.Game.Beatmaps.BeatmapInfo", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd();
b.Property<int>("AudioLeadIn");
b.Property<int>("BaseDifficultyID");
b.Property<int>("BeatDivisor");
b.Property<int>("BeatmapSetInfoID");
b.Property<bool>("Countdown");
b.Property<double>("DistanceSpacing");
b.Property<int>("GridSize");
b.Property<string>("Hash");
b.Property<bool>("Hidden");
b.Property<bool>("LetterboxInBreaks");
b.Property<string>("MD5Hash");
b.Property<int?>("MetadataID");
b.Property<int?>("OnlineBeatmapID");
b.Property<string>("Path");
b.Property<int>("RulesetID");
b.Property<bool>("SpecialStyle");
b.Property<float>("StackLeniency");
b.Property<double>("StarDifficulty");
b.Property<int>("Status");
b.Property<string>("StoredBookmarks");
b.Property<double>("TimelineZoom");
b.Property<string>("Version");
b.Property<bool>("WidescreenStoryboard");
b.HasKey("ID");
b.HasIndex("BaseDifficultyID");
b.HasIndex("BeatmapSetInfoID");
b.HasIndex("Hash");
b.HasIndex("MD5Hash");
b.HasIndex("MetadataID");
b.HasIndex("OnlineBeatmapID")
.IsUnique();
b.HasIndex("RulesetID");
b.ToTable("BeatmapInfo");
});
modelBuilder.Entity("osu.Game.Beatmaps.BeatmapMetadata", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd();
b.Property<string>("Artist");
b.Property<string>("ArtistUnicode");
b.Property<string>("AudioFile");
b.Property<string>("AuthorString")
.HasColumnName("Author");
b.Property<string>("BackgroundFile");
b.Property<int>("PreviewTime");
b.Property<string>("Source");
b.Property<string>("Tags");
b.Property<string>("Title");
b.Property<string>("TitleUnicode");
b.HasKey("ID");
b.ToTable("BeatmapMetadata");
});
modelBuilder.Entity("osu.Game.Beatmaps.BeatmapSetFileInfo", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd();
b.Property<int>("BeatmapSetInfoID");
b.Property<int>("FileInfoID");
b.Property<string>("Filename")
.IsRequired();
b.HasKey("ID");
b.HasIndex("BeatmapSetInfoID");
b.HasIndex("FileInfoID");
b.ToTable("BeatmapSetFileInfo");
});
modelBuilder.Entity("osu.Game.Beatmaps.BeatmapSetInfo", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd();
b.Property<bool>("DeletePending");
b.Property<string>("Hash");
b.Property<int?>("MetadataID");
b.Property<int?>("OnlineBeatmapSetID");
b.Property<bool>("Protected");
b.Property<int>("Status");
b.HasKey("ID");
b.HasIndex("DeletePending");
b.HasIndex("Hash")
.IsUnique();
b.HasIndex("MetadataID");
b.HasIndex("OnlineBeatmapSetID")
.IsUnique();
b.ToTable("BeatmapSetInfo");
});
modelBuilder.Entity("osu.Game.Configuration.DatabasedSetting", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd();
b.Property<int>("IntKey")
.HasColumnName("Key");
b.Property<int?>("RulesetID");
b.Property<string>("StringValue")
.HasColumnName("Value");
b.Property<int?>("Variant");
b.HasKey("ID");
b.HasIndex("RulesetID", "Variant");
b.ToTable("Settings");
});
modelBuilder.Entity("osu.Game.Input.Bindings.DatabasedKeyBinding", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd();
b.Property<int>("IntAction")
.HasColumnName("Action");
b.Property<string>("KeysString")
.HasColumnName("Keys");
b.Property<int?>("RulesetID");
b.Property<int?>("Variant");
b.HasKey("ID");
b.HasIndex("IntAction");
b.HasIndex("RulesetID", "Variant");
b.ToTable("KeyBinding");
});
modelBuilder.Entity("osu.Game.IO.FileInfo", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd();
b.Property<string>("Hash");
b.Property<int>("ReferenceCount");
b.HasKey("ID");
b.HasIndex("Hash")
.IsUnique();
b.HasIndex("ReferenceCount");
b.ToTable("FileInfo");
});
modelBuilder.Entity("osu.Game.Rulesets.RulesetInfo", b =>
{
b.Property<int?>("ID")
.ValueGeneratedOnAdd();
b.Property<bool>("Available");
b.Property<string>("InstantiationInfo");
b.Property<string>("Name");
b.Property<string>("ShortName");
b.HasKey("ID");
b.HasIndex("Available");
b.HasIndex("ShortName")
.IsUnique();
b.ToTable("RulesetInfo");
});
modelBuilder.Entity("osu.Game.Skinning.SkinFileInfo", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd();
b.Property<int>("FileInfoID");
b.Property<string>("Filename")
.IsRequired();
b.Property<int>("SkinInfoID");
b.HasKey("ID");
b.HasIndex("FileInfoID");
b.HasIndex("SkinInfoID");
b.ToTable("SkinFileInfo");
});
modelBuilder.Entity("osu.Game.Skinning.SkinInfo", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd();
b.Property<string>("Creator");
b.Property<bool>("DeletePending");
b.Property<string>("Name");
b.HasKey("ID");
b.ToTable("SkinInfo");
});
modelBuilder.Entity("osu.Game.Beatmaps.BeatmapInfo", b =>
{
b.HasOne("osu.Game.Beatmaps.BeatmapDifficulty", "BaseDifficulty")
.WithMany()
.HasForeignKey("BaseDifficultyID")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("osu.Game.Beatmaps.BeatmapSetInfo", "BeatmapSet")
.WithMany("Beatmaps")
.HasForeignKey("BeatmapSetInfoID")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("osu.Game.Beatmaps.BeatmapMetadata", "Metadata")
.WithMany("Beatmaps")
.HasForeignKey("MetadataID");
b.HasOne("osu.Game.Rulesets.RulesetInfo", "Ruleset")
.WithMany()
.HasForeignKey("RulesetID")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("osu.Game.Beatmaps.BeatmapSetFileInfo", b =>
{
b.HasOne("osu.Game.Beatmaps.BeatmapSetInfo")
.WithMany("Files")
.HasForeignKey("BeatmapSetInfoID")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("osu.Game.IO.FileInfo", "FileInfo")
.WithMany()
.HasForeignKey("FileInfoID")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("osu.Game.Beatmaps.BeatmapSetInfo", b =>
{
b.HasOne("osu.Game.Beatmaps.BeatmapMetadata", "Metadata")
.WithMany("BeatmapSets")
.HasForeignKey("MetadataID");
});
modelBuilder.Entity("osu.Game.Skinning.SkinFileInfo", b =>
{
b.HasOne("osu.Game.IO.FileInfo", "FileInfo")
.WithMany()
.HasForeignKey("FileInfoID")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("osu.Game.Skinning.SkinInfo")
.WithMany("Files")
.HasForeignKey("SkinInfoID")
.OnDelete(DeleteBehavior.Cascade);
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,33 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace osu.Game.Migrations
{
public partial class AddRankStatus : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "Status",
table: "BeatmapSetInfo",
nullable: false,
defaultValue: -3); // NONE
migrationBuilder.AddColumn<int>(
name: "Status",
table: "BeatmapInfo",
nullable: false,
defaultValue: -3); // NONE
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Status",
table: "BeatmapSetInfo");
migrationBuilder.DropColumn(
name: "Status",
table: "BeatmapInfo");
}
}
}

View File

@ -1,7 +1,8 @@
// <auto-generated /> // <auto-generated />
using System;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using osu.Game.Database; using osu.Game.Database;
namespace osu.Game.Migrations namespace osu.Game.Migrations
@ -13,7 +14,7 @@ namespace osu.Game.Migrations
{ {
#pragma warning disable 612, 618 #pragma warning disable 612, 618
modelBuilder modelBuilder
.HasAnnotation("ProductVersion", "2.1.1-rtm-30846"); .HasAnnotation("ProductVersion", "2.1.2-rtm-30932");
modelBuilder.Entity("osu.Game.Beatmaps.BeatmapDifficulty", b => modelBuilder.Entity("osu.Game.Beatmaps.BeatmapDifficulty", b =>
{ {
@ -78,6 +79,8 @@ namespace osu.Game.Migrations
b.Property<double>("StarDifficulty"); b.Property<double>("StarDifficulty");
b.Property<int>("Status");
b.Property<string>("StoredBookmarks"); b.Property<string>("StoredBookmarks");
b.Property<double>("TimelineZoom"); b.Property<double>("TimelineZoom");
@ -173,6 +176,8 @@ namespace osu.Game.Migrations
b.Property<bool>("Protected"); b.Property<bool>("Protected");
b.Property<int>("Status");
b.HasKey("ID"); b.HasKey("ID");
b.HasIndex("DeletePending"); b.HasIndex("DeletePending");

View File

@ -2,6 +2,7 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Diagnostics; using System.Diagnostics;
using System.Net.Http;
using osu.Framework.Configuration; using osu.Framework.Configuration;
using osu.Framework.IO.Network; using osu.Framework.IO.Network;
@ -40,7 +41,7 @@ namespace osu.Game.Online.API
using (var req = new AccessTokenRequestPassword(username, password) using (var req = new AccessTokenRequestPassword(username, password)
{ {
Url = $@"{endpoint}/oauth/token", Url = $@"{endpoint}/oauth/token",
Method = HttpMethod.POST, Method = HttpMethod.Post,
ClientId = clientId, ClientId = clientId,
ClientSecret = clientSecret ClientSecret = clientSecret
}) })
@ -66,7 +67,7 @@ namespace osu.Game.Online.API
using (var req = new AccessTokenRequestRefresh(refresh) using (var req = new AccessTokenRequestRefresh(refresh)
{ {
Url = $@"{endpoint}/oauth/token", Url = $@"{endpoint}/oauth/token",
Method = HttpMethod.POST, Method = HttpMethod.Post,
ClientId = clientId, ClientId = clientId,
ClientSecret = clientSecret ClientSecret = clientSecret
}) })

View File

@ -2,34 +2,19 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using osu.Framework.IO.Network;
using osu.Game.Online.Chat; using osu.Game.Online.Chat;
namespace osu.Game.Online.API.Requests namespace osu.Game.Online.API.Requests
{ {
public class GetMessagesRequest : APIRequest<List<Message>> public class GetMessagesRequest : APIRequest<List<Message>>
{ {
private readonly List<Channel> channels; private readonly Channel channel;
private readonly long? since;
public GetMessagesRequest(List<Channel> channels, long? sinceId) public GetMessagesRequest(Channel channel)
{ {
this.channels = channels; this.channel = channel;
since = sinceId;
} }
protected override WebRequest CreateWebRequest() protected override string Target => $@"chat/channels/{channel.Id}/messages";
{
string channelString = string.Join(",", channels.Select(x => x.Id));
var req = base.CreateWebRequest();
req.AddParameter(@"channels", channelString);
if (since.HasValue) req.AddParameter(@"since", since.Value.ToString());
return req;
}
protected override string Target => @"chat/messages";
} }
} }

View File

@ -0,0 +1,32 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using JetBrains.Annotations;
using osu.Framework.IO.Network;
using osu.Game.Online.Chat;
namespace osu.Game.Online.API.Requests
{
public class GetUpdatesRequest : APIRequest<GetUpdatesResponse>
{
private readonly long since;
private readonly Channel channel;
public GetUpdatesRequest(long sinceId, [CanBeNull] Channel channel = null)
{
this.channel = channel;
since = sinceId;
}
protected override WebRequest CreateWebRequest()
{
var req = base.CreateWebRequest();
if (channel != null) req.AddParameter(@"channel", channel.Id.ToString());
req.AddParameter(@"since", since.ToString());
return req;
}
protected override string Target => @"chat/updates";
}
}

View File

@ -0,0 +1,18 @@
// 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.Collections.Generic;
using Newtonsoft.Json;
using osu.Game.Online.Chat;
namespace osu.Game.Online.API.Requests
{
public class GetUpdatesResponse
{
[JsonProperty]
public List<Channel> Presence;
[JsonProperty]
public List<Message> Messages;
}
}

View File

@ -0,0 +1,31 @@
// 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.Net.Http;
using osu.Framework.IO.Network;
using osu.Game.Online.Chat;
using osu.Game.Users;
namespace osu.Game.Online.API.Requests
{
public class JoinChannelRequest : APIRequest
{
private readonly Channel channel;
private readonly User user;
public JoinChannelRequest(Channel channel, User user)
{
this.channel = channel;
this.user = user;
}
protected override WebRequest CreateWebRequest()
{
var req = base.CreateWebRequest();
req.Method = HttpMethod.Put;
return req;
}
protected override string Target => $@"chat/channels/{channel.Id}/users/{user.Id}";
}
}

View File

@ -0,0 +1,31 @@
// 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.Net.Http;
using osu.Framework.IO.Network;
using osu.Game.Online.Chat;
using osu.Game.Users;
namespace osu.Game.Online.API.Requests
{
public class LeaveChannelRequest : APIRequest
{
private readonly Channel channel;
private readonly User user;
public LeaveChannelRequest(Channel channel, User user)
{
this.channel = channel;
this.user = user;
}
protected override WebRequest CreateWebRequest()
{
var req = base.CreateWebRequest();
req.Method = HttpMethod.Delete;
return req;
}
protected override string Target => $@"chat/channels/{channel.Id}/users/{user.Id}";
}
}

View File

@ -1,7 +1,7 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Extensions; using System.Net.Http;
using osu.Framework.IO.Network; using osu.Framework.IO.Network;
using osu.Game.Online.Chat; using osu.Game.Online.Chat;
@ -20,15 +20,13 @@ namespace osu.Game.Online.API.Requests
{ {
var req = base.CreateWebRequest(); var req = base.CreateWebRequest();
req.Method = HttpMethod.POST; req.Method = HttpMethod.Post;
req.AddParameter(@"target_type", message.TargetType.GetDescription());
req.AddParameter(@"target_id", message.TargetId.ToString());
req.AddParameter(@"is_action", message.IsAction.ToString().ToLowerInvariant()); req.AddParameter(@"is_action", message.IsAction.ToString().ToLowerInvariant());
req.AddParameter(@"message", message.Content); req.AddParameter(@"message", message.Content);
return req; return req;
} }
protected override string Target => @"chat/messages"; protected override string Target => $@"chat/channels/{message.ChannelId}/messages";
} }
} }

View File

@ -15,6 +15,12 @@ namespace osu.Game.Online.API.Requests.Responses
[JsonProperty(@"beatmapset_id")] [JsonProperty(@"beatmapset_id")]
public int OnlineBeatmapSetID { get; set; } public int OnlineBeatmapSetID { get; set; }
[JsonProperty(@"status")]
public BeatmapSetOnlineStatus Status { get; set; }
[JsonProperty(@"beatmapset")]
public APIBeatmapSet BeatmapSet { get; set; }
[JsonProperty(@"playcount")] [JsonProperty(@"playcount")]
private int playCount { get; set; } private int playCount { get; set; }
@ -59,11 +65,13 @@ namespace osu.Game.Online.API.Requests.Responses
Ruleset = rulesets.GetRuleset(ruleset), Ruleset = rulesets.GetRuleset(ruleset),
StarDifficulty = starDifficulty, StarDifficulty = starDifficulty,
OnlineBeatmapID = OnlineBeatmapID, OnlineBeatmapID = OnlineBeatmapID,
Version = version,
Status = Status,
BeatmapSet = new BeatmapSetInfo BeatmapSet = new BeatmapSetInfo
{ {
OnlineBeatmapSetID = OnlineBeatmapSetID, OnlineBeatmapSetID = OnlineBeatmapSetID,
Status = BeatmapSet?.Status ?? BeatmapSetOnlineStatus.None
}, },
Version = version,
BaseDifficulty = new BeatmapDifficulty BaseDifficulty = new BeatmapDifficulty
{ {
DrainRate = drainRate, DrainRate = drainRate,

View File

@ -20,10 +20,13 @@ namespace osu.Game.Online.API.Requests.Responses
[JsonProperty(@"id")] [JsonProperty(@"id")]
public int? OnlineBeatmapSetID public int? OnlineBeatmapSetID
{ {
get { return onlineBeatmapSetID; } get => onlineBeatmapSetID;
set { onlineBeatmapSetID = value > 0 ? value : null; } set => onlineBeatmapSetID = value > 0 ? value : null;
} }
[JsonProperty(@"status")]
public BeatmapSetOnlineStatus Status { get; set; }
[JsonProperty(@"preview_url")] [JsonProperty(@"preview_url")]
private string preview { get; set; } private string preview { get; set; }
@ -42,9 +45,6 @@ namespace osu.Game.Online.API.Requests.Responses
[JsonProperty(@"storyboard")] [JsonProperty(@"storyboard")]
private bool hasStoryboard { get; set; } private bool hasStoryboard { get; set; }
[JsonProperty(@"status")]
private BeatmapSetOnlineStatus status { get; set; }
[JsonProperty(@"submitted_date")] [JsonProperty(@"submitted_date")]
private DateTimeOffset submitted { get; set; } private DateTimeOffset submitted { get; set; }
@ -57,7 +57,7 @@ namespace osu.Game.Online.API.Requests.Responses
[JsonProperty(@"user_id")] [JsonProperty(@"user_id")]
private long creatorId private long creatorId
{ {
set { Author.Id = value; } set => Author.Id = value;
} }
[JsonProperty(@"beatmaps")] [JsonProperty(@"beatmaps")]
@ -69,6 +69,7 @@ namespace osu.Game.Online.API.Requests.Responses
{ {
OnlineBeatmapSetID = OnlineBeatmapSetID, OnlineBeatmapSetID = OnlineBeatmapSetID,
Metadata = this, Metadata = this,
Status = Status,
OnlineInfo = new BeatmapSetOnlineInfo OnlineInfo = new BeatmapSetOnlineInfo
{ {
Covers = covers, Covers = covers,
@ -76,7 +77,7 @@ namespace osu.Game.Online.API.Requests.Responses
PlayCount = playCount, PlayCount = playCount,
FavouriteCount = favouriteCount, FavouriteCount = favouriteCount,
BPM = bpm, BPM = bpm,
Status = status, Status = Status,
HasVideo = hasVideo, HasVideo = hasVideo,
HasStoryboard = hasStoryboard, HasStoryboard = hasStoryboard,
Submitted = submitted, Submitted = submitted,

View File

@ -19,11 +19,14 @@ namespace osu.Game.Online.Chat
public string Topic; public string Topic;
[JsonProperty(@"type")] [JsonProperty(@"type")]
public string Type; public ChannelType Type;
[JsonProperty(@"channel_id")] [JsonProperty(@"channel_id")]
public int Id; public int Id;
[JsonProperty(@"last_message_id")]
public long? LastMessageId;
public readonly SortedList<Message> Messages = new SortedList<Message>(Comparer<Message>.Default); public readonly SortedList<Message> Messages = new SortedList<Message>(Comparer<Message>.Default);
private readonly List<LocalEchoMessage> pendingMessages = new List<LocalEchoMessage>(); private readonly List<LocalEchoMessage> pendingMessages = new List<LocalEchoMessage>();
@ -51,11 +54,20 @@ namespace osu.Game.Online.Chat
NewMessagesArrived?.Invoke(new[] { message }); NewMessagesArrived?.Invoke(new[] { message });
} }
public bool MessagesLoaded { get; private set; }
public void AddNewMessages(params Message[] messages) public void AddNewMessages(params Message[] messages)
{ {
messages = messages.Except(Messages).ToArray(); messages = messages.Except(Messages).ToArray();
if (messages.Length == 0) return;
Messages.AddRange(messages); Messages.AddRange(messages);
MessagesLoaded = true;
var maxMessageId = messages.Max(m => m.Id);
if (maxMessageId > LastMessageId)
LastMessageId = maxMessageId;
purgeOldMessages(); purgeOldMessages();

View File

@ -0,0 +1,11 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
namespace osu.Game.Online.Chat
{
public enum ChannelType
{
PM,
Public
}
}

View File

@ -24,7 +24,7 @@ namespace osu.Game.Online.Chat
/// </summary> /// </summary>
public List<SpriteText> Parts; public List<SpriteText> Parts;
public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => Parts.Any(d => d.ReceiveMouseInputAt(screenSpacePos)); public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => Parts.Any(d => d.ReceivePositionalInputAt(screenSpacePos));
protected override HoverClickSounds CreateHoverClickSounds(HoverSampleSet sampleSet) => new LinkHoverSounds(sampleSet, Parts); protected override HoverClickSounds CreateHoverClickSounds(HoverSampleSet sampleSet) => new LinkHoverSounds(sampleSet, Parts);
@ -53,7 +53,7 @@ namespace osu.Game.Online.Chat
this.parts = parts; this.parts = parts;
} }
public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => parts.Any(d => d.ReceiveMouseInputAt(screenSpacePos)); public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => parts.Any(d => d.ReceivePositionalInputAt(screenSpacePos));
} }
} }
} }

View File

@ -18,11 +18,8 @@ namespace osu.Game.Online.Chat
[JsonProperty(@"sender_id")] [JsonProperty(@"sender_id")]
public int UserId; public int UserId;
[JsonProperty(@"target_type")] [JsonProperty(@"channel_id")]
public TargetType TargetType; public int ChannelId;
[JsonProperty(@"target_id")]
public int TargetId;
[JsonProperty(@"is_action")] [JsonProperty(@"is_action")]
public bool IsAction; public bool IsAction;

View File

@ -65,7 +65,8 @@ namespace osu.Game
private BeatmapSetOverlay beatmapSetOverlay; private BeatmapSetOverlay beatmapSetOverlay;
private ScreenshotManager screenshotManager; [Cached]
private readonly ScreenshotManager screenshotManager = new ScreenshotManager();
protected RavenLogger RavenLogger; protected RavenLogger RavenLogger;
@ -289,9 +290,6 @@ namespace osu.Game
protected override void LoadComplete() protected override void LoadComplete()
{ {
// this needs to be cached before base.LoadComplete as it is used by MenuCursorContainer.
dependencies.Cache(screenshotManager = new ScreenshotManager());
base.LoadComplete(); base.LoadComplete();
// The next time this is updated is in UpdateAfterChildren, which occurs too late and results // The next time this is updated is in UpdateAfterChildren, which occurs too late and results
@ -355,7 +353,7 @@ namespace osu.Game
loadComponentSingleFile(beatmapSetOverlay = new BeatmapSetOverlay { Depth = -3 }, mainContent.Add); loadComponentSingleFile(beatmapSetOverlay = new BeatmapSetOverlay { Depth = -3 }, mainContent.Add);
loadComponentSingleFile(musicController = new MusicController loadComponentSingleFile(musicController = new MusicController
{ {
Depth = -4, Depth = -5,
Position = new Vector2(0, Toolbar.HEIGHT), Position = new Vector2(0, Toolbar.HEIGHT),
Anchor = Anchor.TopRight, Anchor = Anchor.TopRight,
Origin = Anchor.TopRight, Origin = Anchor.TopRight,

View File

@ -154,7 +154,7 @@ namespace osu.Game
dependencies.Cache(RulesetStore = new RulesetStore(contextFactory)); dependencies.Cache(RulesetStore = new RulesetStore(contextFactory));
dependencies.Cache(FileStore = new FileStore(contextFactory, Host.Storage)); dependencies.Cache(FileStore = new FileStore(contextFactory, Host.Storage));
dependencies.Cache(BeatmapManager = new BeatmapManager(Host.Storage, contextFactory, RulesetStore, api, Audio, Host)); dependencies.Cache(BeatmapManager = new BeatmapManager(Host.Storage, contextFactory, RulesetStore, api, Audio, Host));
dependencies.Cache(ScoreStore = new ScoreStore(Host.Storage, contextFactory, Host, BeatmapManager, RulesetStore)); dependencies.Cache(ScoreStore = new ScoreStore(contextFactory, Host, BeatmapManager, RulesetStore));
dependencies.Cache(KeyBindingStore = new KeyBindingStore(contextFactory, RulesetStore)); dependencies.Cache(KeyBindingStore = new KeyBindingStore(contextFactory, RulesetStore));
dependencies.Cache(SettingsStore = new SettingsStore(contextFactory)); dependencies.Cache(SettingsStore = new SettingsStore(contextFactory));
dependencies.Cache(RulesetConfigCache = new RulesetConfigCache(SettingsStore)); dependencies.Cache(RulesetConfigCache = new RulesetConfigCache(SettingsStore));
@ -243,7 +243,7 @@ namespace osu.Game
public void Import(params string[] paths) public void Import(params string[] paths)
{ {
var extension = Path.GetExtension(paths.First()); var extension = Path.GetExtension(paths.First())?.ToLowerInvariant();
foreach (var importer in fileImporters) foreach (var importer in fileImporters)
if (importer.HandledExtensions.Contains(extension)) importer.Import(paths); if (importer.HandledExtensions.Contains(extension)) importer.Import(paths);

View File

@ -10,7 +10,7 @@ using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.States; using osu.Framework.Input.Events;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Beatmaps.Drawables; using osu.Game.Beatmaps.Drawables;
using osu.Game.Graphics; using osu.Game.Graphics;
@ -174,9 +174,9 @@ namespace osu.Game.Overlays.BeatmapSet
{ {
public Action OnLostHover; public Action OnLostHover;
protected override void OnHoverLost(InputState state) protected override void OnHoverLost(HoverLostEvent e)
{ {
base.OnHoverLost(state); base.OnHoverLost(e);
OnLostHover?.Invoke(); OnLostHover?.Invoke();
} }
} }
@ -241,24 +241,24 @@ namespace osu.Game.Overlays.BeatmapSet
}; };
} }
protected override bool OnHover(InputState state) protected override bool OnHover(HoverEvent e)
{ {
fadeIn(); fadeIn();
OnHovered?.Invoke(Beatmap); OnHovered?.Invoke(Beatmap);
return base.OnHover(state); return base.OnHover(e);
} }
protected override void OnHoverLost(InputState state) protected override void OnHoverLost(HoverLostEvent e)
{ {
if (State == DifficultySelectorState.NotSelected) if (State == DifficultySelectorState.NotSelected)
fadeOut(); fadeOut();
base.OnHoverLost(state); base.OnHoverLost(e);
} }
protected override bool OnClick(InputState state) protected override bool OnClick(ClickEvent e)
{ {
OnClicked?.Invoke(Beatmap); OnClicked?.Invoke(Beatmap);
return base.OnClick(state); return base.OnClick(e);
} }
private void fadeIn() private void fadeIn()

View File

@ -7,7 +7,7 @@ using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.States; using osu.Framework.Input.Events;
using osu.Game.Audio; using osu.Game.Audio;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Graphics; using osu.Game.Graphics;
@ -66,7 +66,7 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons
}, },
}; };
Action = () => playButton.TriggerOnClick(); Action = () => playButton.Click();
Playing.ValueChanged += newValue => progress.FadeTo(newValue ? 1 : 0, 100); Playing.ValueChanged += newValue => progress.FadeTo(newValue ? 1 : 0, 100);
} }
@ -89,16 +89,16 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons
progress.Width = 0; progress.Width = 0;
} }
protected override bool OnHover(InputState state) protected override bool OnHover(HoverEvent e)
{ {
bg.FadeColour(Color4.Black.Opacity(0.5f), 100); bg.FadeColour(Color4.Black.Opacity(0.5f), 100);
return base.OnHover(state); return base.OnHover(e);
} }
protected override void OnHoverLost(InputState state) protected override void OnHoverLost(HoverLostEvent e)
{ {
bg.FadeColour(Color4.Black.Opacity(0.25f), 100); bg.FadeColour(Color4.Black.Opacity(0.25f), 100);
base.OnHoverLost(state); base.OnHoverLost(e);
} }
} }
} }

View File

@ -230,10 +230,12 @@ namespace osu.Game.Overlays.BeatmapSet
Spacing = new Vector2(10), Spacing = new Vector2(10),
Children = new Drawable[] Children = new Drawable[]
{ {
onlineStatusPill = new BeatmapSetOnlineStatusPill(14, new MarginPadding { Horizontal = 25, Vertical = 8 }) onlineStatusPill = new BeatmapSetOnlineStatusPill
{ {
Anchor = Anchor.TopRight, Anchor = Anchor.TopRight,
Origin = Anchor.TopRight, Origin = Anchor.TopRight,
TextSize = 14,
TextPadding = new MarginPadding { Horizontal = 25, Vertical = 8 }
}, },
Details = new Details(), Details = new Details(),
}, },

View File

@ -3,7 +3,7 @@
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Input.States; using osu.Framework.Input.Events;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Users; using osu.Game.Users;
@ -53,7 +53,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
this.profile = profile; this.profile = profile;
} }
protected override bool OnClick(InputState state) protected override bool OnClick(ClickEvent e)
{ {
profile?.ShowUser(user); profile?.ShowUser(user);
return true; return true;

View File

@ -6,7 +6,7 @@ using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.States; using osu.Framework.Input.Events;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.API.Requests.Responses;
@ -125,18 +125,18 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
background.Colour = colours.Gray4; background.Colour = colours.Gray4;
} }
protected override bool OnHover(InputState state) protected override bool OnHover(HoverEvent e)
{ {
background.FadeIn(fade_duration, Easing.OutQuint); background.FadeIn(fade_duration, Easing.OutQuint);
return base.OnHover(state); return base.OnHover(e);
} }
protected override void OnHoverLost(InputState state) protected override void OnHoverLost(HoverLostEvent e)
{ {
background.FadeOut(fade_duration, Easing.OutQuint); background.FadeOut(fade_duration, Easing.OutQuint);
base.OnHoverLost(state); base.OnHoverLost(e);
} }
protected override bool OnClick(InputState state) => true; protected override bool OnClick(ClickEvent e) => true;
} }
} }

View File

@ -8,7 +8,7 @@ using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.States; using osu.Framework.Input.Events;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.API.Requests.Responses;
@ -184,16 +184,16 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
BorderColour = rankText.Colour = colours.Yellow; BorderColour = rankText.Colour = colours.Yellow;
} }
protected override bool OnHover(InputState state) protected override bool OnHover(HoverEvent e)
{ {
background.FadeIn(fade_duration, Easing.OutQuint); background.FadeIn(fade_duration, Easing.OutQuint);
return base.OnHover(state); return base.OnHover(e);
} }
protected override void OnHoverLost(InputState state) protected override void OnHoverLost(HoverLostEvent e)
{ {
background.FadeOut(fade_duration, Easing.OutQuint); background.FadeOut(fade_duration, Easing.OutQuint);
base.OnHoverLost(state); base.OnHoverLost(e);
} }
private class InfoColumn : FillFlowContainer private class InfoColumn : FillFlowContainer

View File

@ -7,7 +7,7 @@ using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.States; using osu.Framework.Input.Events;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
@ -51,7 +51,7 @@ namespace osu.Game.Overlays
} }
// receive input outside our bounds so we can trigger a close event on ourselves. // receive input outside our bounds so we can trigger a close event on ourselves.
public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => true; public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true;
public BeatmapSetOverlay() public BeatmapSetOverlay()
{ {
@ -127,7 +127,7 @@ namespace osu.Game.Overlays
FadeEdgeEffectTo(0, WaveContainer.DISAPPEAR_DURATION, Easing.Out).OnComplete(_ => BeatmapSet = null); FadeEdgeEffectTo(0, WaveContainer.DISAPPEAR_DURATION, Easing.Out).OnComplete(_ => BeatmapSet = null);
} }
protected override bool OnClick(InputState state) protected override bool OnClick(ClickEvent e)
{ {
State = Visibility.Hidden; State = Visibility.Hidden;
return true; return true;

View File

@ -9,7 +9,7 @@ using osu.Framework.Allocation;
using osu.Framework.Configuration; using osu.Framework.Configuration;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Input.States; using osu.Framework.Input.Events;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Online.Chat; using osu.Game.Online.Chat;
@ -155,15 +155,15 @@ namespace osu.Game.Overlays.Chat
FinishTransforms(true); FinishTransforms(true);
} }
protected override bool OnHover(InputState state) protected override bool OnHover(HoverEvent e)
{ {
if (!channel.Joined.Value) if (!channel.Joined.Value)
name.FadeColour(hoverColour, 50, Easing.OutQuint); name.FadeColour(hoverColour, 50, Easing.OutQuint);
return base.OnHover(state); return base.OnHover(e);
} }
protected override void OnHoverLost(InputState state) protected override void OnHoverLost(HoverLostEvent e)
{ {
if (!channel.Joined.Value) if (!channel.Joined.Value)
name.FadeColour(Color4.White, transition_duration); name.FadeColour(Color4.White, transition_duration);

View File

@ -10,7 +10,7 @@ using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.States; using osu.Framework.Input.Events;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Backgrounds; using osu.Game.Graphics.Backgrounds;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
@ -150,10 +150,10 @@ namespace osu.Game.Overlays.Chat
headerBg.Colour = colours.Gray2.Opacity(0.75f); headerBg.Colour = colours.Gray2.Opacity(0.75f);
} }
protected override void OnFocus(InputState state) protected override void OnFocus(FocusEvent e)
{ {
GetContainingInputManager().ChangeFocus(search); GetContainingInputManager().ChangeFocus(search);
base.OnFocus(state); base.OnFocus(e);
} }
protected override void PopIn() protected override void PopIn()

View File

@ -13,11 +13,11 @@ using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osu.Game.Online.Chat; using osu.Game.Online.Chat;
using OpenTK; using OpenTK;
using OpenTK.Input;
using OpenTK.Graphics; using OpenTK.Graphics;
using osu.Framework.Configuration; using osu.Framework.Configuration;
using System; using System;
using osu.Framework.Input.EventArgs; using osu.Framework.Input.Events;
using osu.Framework.Input.States;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
namespace osu.Game.Overlays.Chat namespace osu.Game.Overlays.Chat
@ -143,7 +143,18 @@ namespace osu.Game.Overlays.Chat
textBold.FadeOut(transition_length, Easing.OutQuint); textBold.FadeOut(transition_length, Easing.OutQuint);
} }
protected override bool OnHover(InputState state) protected override bool OnMouseUp(MouseUpEvent e)
{
if (e.Button == MouseButton.Middle)
{
closeButton.Action();
return true;
}
return false;
}
protected override bool OnHover(HoverEvent e)
{ {
if (IsRemovable) if (IsRemovable)
closeButton.FadeIn(200, Easing.OutQuint); closeButton.FadeIn(200, Easing.OutQuint);
@ -153,7 +164,7 @@ namespace osu.Game.Overlays.Chat
return true; return true;
} }
protected override void OnHoverLost(InputState state) protected override void OnHoverLost(HoverLostEvent e)
{ {
closeButton.FadeOut(200, Easing.OutQuint); closeButton.FadeOut(200, Easing.OutQuint);
updateState(); updateState();
@ -279,28 +290,28 @@ namespace osu.Game.Overlays.Chat
}; };
} }
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) protected override bool OnMouseDown(MouseDownEvent e)
{ {
icon.ScaleTo(0.5f, 1000, Easing.OutQuint); icon.ScaleTo(0.5f, 1000, Easing.OutQuint);
return base.OnMouseDown(state, args); return base.OnMouseDown(e);
} }
protected override bool OnMouseUp(InputState state, MouseUpEventArgs args) protected override bool OnMouseUp(MouseUpEvent e)
{ {
icon.ScaleTo(0.75f, 1000, Easing.OutElastic); icon.ScaleTo(0.75f, 1000, Easing.OutElastic);
return base.OnMouseUp(state, args); return base.OnMouseUp(e);
} }
protected override bool OnHover(InputState state) protected override bool OnHover(HoverEvent e)
{ {
icon.FadeColour(Color4.Red, 200, Easing.OutQuint); icon.FadeColour(Color4.Red, 200, Easing.OutQuint);
return base.OnHover(state); return base.OnHover(e);
} }
protected override void OnHoverLost(InputState state) protected override void OnHoverLost(HoverLostEvent e)
{ {
icon.FadeColour(Color4.White, 200, Easing.OutQuint); icon.FadeColour(Color4.White, 200, Easing.OutQuint);
base.OnHoverLost(state); base.OnHoverLost(e);
} }
} }

View File

@ -3,7 +3,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.Linq; using System.Linq;
using OpenTK; using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
@ -13,7 +12,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.UserInterface; using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input.States; using osu.Framework.Input.Events;
using osu.Framework.Threading; using osu.Framework.Threading;
using osu.Game.Configuration; using osu.Game.Configuration;
using osu.Game.Graphics; using osu.Game.Graphics;
@ -47,12 +46,12 @@ namespace osu.Game.Overlays
public const float TAB_AREA_HEIGHT = 50; public const float TAB_AREA_HEIGHT = 50;
private GetMessagesRequest fetchReq; private GetUpdatesRequest fetchReq;
private readonly ChatTabControl channelTabs; private readonly ChatTabControl channelTabs;
private readonly Container chatContainer; private readonly Container chatContainer;
private readonly Container tabsArea; private readonly TabsArea tabsArea;
private readonly Box chatBackground; private readonly Box chatBackground;
private readonly Box tabBackground; private readonly Box tabBackground;
@ -62,7 +61,7 @@ namespace osu.Game.Overlays
private readonly Container channelSelectionContainer; private readonly Container channelSelectionContainer;
private readonly ChannelSelectionOverlay channelSelection; private readonly ChannelSelectionOverlay channelSelection;
public override bool Contains(Vector2 screenSpacePos) => chatContainer.ReceiveMouseInputAt(screenSpacePos) || channelSelection.State == Visibility.Visible && channelSelection.ReceiveMouseInputAt(screenSpacePos); public override bool Contains(Vector2 screenSpacePos) => chatContainer.ReceivePositionalInputAt(screenSpacePos) || channelSelection.State == Visibility.Visible && channelSelection.ReceivePositionalInputAt(screenSpacePos);
public ChatOverlay() public ChatOverlay()
{ {
@ -146,11 +145,8 @@ namespace osu.Game.Overlays
loading = new LoadingAnimation(), loading = new LoadingAnimation(),
} }
}, },
tabsArea = new Container tabsArea = new TabsArea
{ {
Name = @"tabs area",
RelativeSizeAxes = Axes.X,
Height = TAB_AREA_HEIGHT,
Children = new Drawable[] Children = new Drawable[]
{ {
tabBackground = new Box tabBackground = new Box
@ -191,25 +187,22 @@ namespace osu.Game.Overlays
public void OpenChannel(Channel channel) => addChannel(channel); public void OpenChannel(Channel channel) => addChannel(channel);
protected override bool OnDragStart(InputState state) protected override bool OnDragStart(DragStartEvent e)
{ {
isDragging = tabsArea.IsHovered; isDragging = tabsArea.IsHovered;
if (!isDragging) if (!isDragging)
return base.OnDragStart(state); return base.OnDragStart(e);
startDragChatHeight = ChatHeight.Value; startDragChatHeight = ChatHeight.Value;
return true; return true;
} }
protected override bool OnDrag(InputState state) protected override bool OnDrag(DragEvent e)
{ {
if (isDragging) if (isDragging)
{ {
Trace.Assert(state.Mouse.PositionMouseDown != null); double targetChatHeight = startDragChatHeight - (e.MousePosition.Y - e.MouseDownPosition.Y) / Parent.DrawSize.Y;
// ReSharper disable once PossibleInvalidOperationException
double targetChatHeight = startDragChatHeight - (state.Mouse.Position.Y - state.Mouse.PositionMouseDown.Value.Y) / Parent.DrawSize.Y;
// If the channel selection screen is shown, mind its minimum height // If the channel selection screen is shown, mind its minimum height
if (channelSelection.State == Visibility.Visible && targetChatHeight > 1f - channel_selection_min_height) if (channelSelection.State == Visibility.Visible && targetChatHeight > 1f - channel_selection_min_height)
@ -221,10 +214,10 @@ namespace osu.Game.Overlays
return true; return true;
} }
protected override bool OnDragEnd(InputState state) protected override bool OnDragEnd(DragEndEvent e)
{ {
isDragging = false; isDragging = false;
return base.OnDragEnd(state); return base.OnDragEnd(e);
} }
public void APIStateChanged(APIAccess api, APIState state) public void APIStateChanged(APIAccess api, APIState state)
@ -242,11 +235,11 @@ namespace osu.Game.Overlays
public override bool AcceptsFocus => true; public override bool AcceptsFocus => true;
protected override void OnFocus(InputState state) protected override void OnFocus(FocusEvent e)
{ {
//this is necessary as textbox is masked away and therefore can't get focus :( //this is necessary as textbox is masked away and therefore can't get focus :(
GetContainingInputManager().ChangeFocus(textbox); GetContainingInputManager().ChangeFocus(textbox);
base.OnFocus(state); base.OnFocus(e);
} }
protected override void PopIn() protected override void PopIn()
@ -285,7 +278,7 @@ namespace osu.Game.Overlays
chatBackground.Colour = colours.ChatBlue; chatBackground.Colour = colours.ChatBlue;
} }
private long? lastMessageId; private long lastMessageId;
private readonly List<Channel> careChannels = new List<Channel>(); private readonly List<Channel> careChannels = new List<Channel>();
@ -304,9 +297,9 @@ namespace osu.Game.Overlays
Scheduler.Add(delegate Scheduler.Add(delegate
{ {
//todo: decide how to handle default channels for a user now that they are saved server-side.
addChannel(channels.Find(c => c.Name == @"#lazer")); addChannel(channels.Find(c => c.Name == @"#lazer"));
addChannel(channels.Find(c => c.Name == @"#osu")); addChannel(channels.Find(c => c.Name == @"#osu"));
addChannel(channels.Find(c => c.Name == @"#lobby"));
channelSelection.OnRequestJoin = addChannel; channelSelection.OnRequestJoin = addChannel;
channelSelection.OnRequestLeave = removeChannel; channelSelection.OnRequestLeave = removeChannel;
@ -320,7 +313,7 @@ namespace osu.Game.Overlays
}; };
}); });
messageRequest = Scheduler.AddDelayed(fetchNewMessages, 1000, true); messageRequest = Scheduler.AddDelayed(fetchUpdates, 1000, true);
}; };
api.Queue(req); api.Queue(req);
@ -362,7 +355,7 @@ namespace osu.Game.Overlays
loadedChannels.Add(loaded); loadedChannels.Add(loaded);
LoadComponentAsync(loaded, l => LoadComponentAsync(loaded, l =>
{ {
if (currentChannel.Messages.Any()) if (currentChannel.MessagesLoaded)
loading.Hide(); loading.Hide();
currentChannelContainer.Clear(false); currentChannelContainer.Clear(false);
@ -394,6 +387,15 @@ namespace osu.Game.Overlays
{ {
careChannels.Add(channel); careChannels.Add(channel);
channelTabs.AddItem(channel); channelTabs.AddItem(channel);
if (channel.Type == ChannelType.Public && !channel.Joined)
{
var req = new JoinChannelRequest(channel, api.LocalUser);
req.Success += () => addChannel(channel);
req.Failure += ex => removeChannel(channel);
api.Queue(req);
return;
}
} }
// let's fetch a small number of messages to bring us up-to-date with the backlog. // let's fetch a small number of messages to bring us up-to-date with the backlog.
@ -415,47 +417,53 @@ namespace osu.Game.Overlays
loadedChannels.Remove(loadedChannels.Find(c => c.Channel == channel)); loadedChannels.Remove(loadedChannels.Find(c => c.Channel == channel));
channelTabs.RemoveItem(channel); channelTabs.RemoveItem(channel);
api.Queue(new LeaveChannelRequest(channel, api.LocalUser));
channel.Joined.Value = false; channel.Joined.Value = false;
} }
private void fetchInitialMessages(Channel channel) private void fetchInitialMessages(Channel channel)
{ {
var req = new GetMessagesRequest(new List<Channel> { channel }, null); var req = new GetMessagesRequest(channel);
req.Success += messages =>
req.Success += delegate (List<Message> messages)
{ {
loading.Hide();
channel.AddNewMessages(messages.ToArray()); channel.AddNewMessages(messages.ToArray());
Debug.Write("success!"); if (channel == currentChannel)
}; loading.Hide();
req.Failure += delegate
{
Debug.Write("failure!");
}; };
api.Queue(req); api.Queue(req);
} }
private void fetchNewMessages() private void fetchUpdates()
{ {
if (fetchReq != null) return; if (fetchReq != null) return;
fetchReq = new GetMessagesRequest(careChannels, lastMessageId); fetchReq = new GetUpdatesRequest(lastMessageId);
fetchReq.Success += delegate (List<Message> messages) fetchReq.Success += updates =>
{ {
foreach (var group in messages.Where(m => m.TargetType == TargetType.Channel).GroupBy(m => m.TargetId)) if (updates?.Presence != null)
careChannels.Find(c => c.Id == group.Key)?.AddNewMessages(group.ToArray()); {
foreach (var channel in updates.Presence)
{
if (careChannels.Find(c => c.Id == channel.Id) == null)
{
channel.Joined.Value = true;
addChannel(channel);
}
}
lastMessageId = messages.LastOrDefault()?.Id ?? lastMessageId; foreach (var group in updates.Messages.GroupBy(m => m.ChannelId))
careChannels.Find(c => c.Id == group.Key)?.AddNewMessages(group.ToArray());
lastMessageId = updates.Messages.LastOrDefault()?.Id ?? lastMessageId;
}
Debug.Write("success!");
fetchReq = null; fetchReq = null;
}; };
fetchReq.Failure += delegate fetchReq.Failure += delegate
{ {
Debug.Write("failure!");
fetchReq = null; fetchReq = null;
}; };
@ -517,8 +525,7 @@ namespace osu.Game.Overlays
{ {
Sender = api.LocalUser.Value, Sender = api.LocalUser.Value,
Timestamp = DateTimeOffset.Now, Timestamp = DateTimeOffset.Now,
TargetType = TargetType.Channel, //TODO: read this from channel ChannelId = target.Id,
TargetId = target.Id,
IsAction = isAction, IsAction = isAction,
Content = postText Content = postText
}; };
@ -531,5 +538,18 @@ namespace osu.Game.Overlays
api.Queue(req); api.Queue(req);
} }
private class TabsArea : Container
{
// IsHovered is used
public override bool HandlePositionalInput => true;
public TabsArea()
{
Name = @"tabs area";
RelativeSizeAxes = Axes.X;
Height = TAB_AREA_HEIGHT;
}
}
} }
} }

View File

@ -8,8 +8,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Input.EventArgs; using osu.Framework.Input.Events;
using osu.Framework.Input.States;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Backgrounds; using osu.Game.Graphics.Backgrounds;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
@ -26,7 +25,7 @@ namespace osu.Game.Overlays.Dialog
public static readonly float ENTER_DURATION = 500; public static readonly float ENTER_DURATION = 500;
public static readonly float EXIT_DURATION = 200; public static readonly float EXIT_DURATION = 200;
protected override bool BlockPassThroughMouse => false; protected override bool BlockPositionalInput => false;
private readonly Vector2 ringSize = new Vector2(100f); private readonly Vector2 ringSize = new Vector2(100f);
private readonly Vector2 ringMinifiedSize = new Vector2(20f); private readonly Vector2 ringMinifiedSize = new Vector2(20f);
@ -199,19 +198,19 @@ namespace osu.Game.Overlays.Dialog
switch (action) switch (action)
{ {
case GlobalAction.Select: case GlobalAction.Select:
Buttons.OfType<PopupDialogOkButton>().FirstOrDefault()?.TriggerOnClick(); Buttons.OfType<PopupDialogOkButton>().FirstOrDefault()?.Click();
return true; return true;
} }
return base.OnPressed(action); return base.OnPressed(action);
} }
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) protected override bool OnKeyDown(KeyDownEvent e)
{ {
if (args.Repeat) return false; if (e.Repeat) return false;
// press button at number if 1-9 on number row or keypad are pressed // press button at number if 1-9 on number row or keypad are pressed
var k = args.Key; var k = e.Key;
if (k >= Key.Number1 && k <= Key.Number9) if (k >= Key.Number1 && k <= Key.Number9)
{ {
pressButtonAtIndex(k - Key.Number1); pressButtonAtIndex(k - Key.Number1);
@ -224,7 +223,7 @@ namespace osu.Game.Overlays.Dialog
return true; return true;
} }
return base.OnKeyDown(state, args); return base.OnKeyDown(e);
} }
protected override void PopIn() protected override void PopIn()
@ -252,7 +251,7 @@ namespace osu.Game.Overlays.Dialog
if (!actionInvoked) if (!actionInvoked)
// In the case a user did not choose an action before a hide was triggered, press the last button. // In the case a user did not choose an action before a hide was triggered, press the last button.
// This is presumed to always be a sane default "cancel" action. // This is presumed to always be a sane default "cancel" action.
buttonsContainer.Last().TriggerOnClick(); buttonsContainer.Last().Click();
base.PopOut(); base.PopOut();
content.FadeOut(EXIT_DURATION, Easing.InSine); content.FadeOut(EXIT_DURATION, Easing.InSine);
@ -261,7 +260,7 @@ namespace osu.Game.Overlays.Dialog
private void pressButtonAtIndex(int index) private void pressButtonAtIndex(int index)
{ {
if (index < Buttons.Count()) if (index < Buttons.Count())
Buttons.Skip(index).First().TriggerOnClick(); Buttons.Skip(index).First().Click();
} }
} }
} }

View File

@ -43,7 +43,7 @@ namespace osu.Game.Overlays
protected override bool PlaySamplesOnStateChange => false; protected override bool PlaySamplesOnStateChange => false;
protected override bool BlockPassThroughKeyboard => true; protected override bool BlockNonPositionalInput => true;
private void onDialogOnStateChanged(VisibilityContainer dialog, Visibility v) private void onDialogOnStateChanged(VisibilityContainer dialog, Visibility v)
{ {

View File

@ -7,11 +7,11 @@ using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Localisation;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.States; using osu.Framework.Input.Events;
using osu.Framework.Localisation;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Beatmaps.Drawables; using osu.Game.Beatmaps.Drawables;
@ -44,7 +44,7 @@ namespace osu.Game.Overlays.Direct
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours, LocalisationEngine localisation) private void load(OsuColour colours)
{ {
Content.CornerRadius = 4; Content.CornerRadius = 4;
@ -74,13 +74,13 @@ namespace osu.Game.Overlays.Direct
{ {
new OsuSpriteText new OsuSpriteText
{ {
Text = localisation.GetUnicodePreference(SetInfo.Metadata.TitleUnicode, SetInfo.Metadata.Title), Text = new LocalisedString((SetInfo.Metadata.TitleUnicode, SetInfo.Metadata.Title)),
TextSize = 18, TextSize = 18,
Font = @"Exo2.0-BoldItalic", Font = @"Exo2.0-BoldItalic",
}, },
new OsuSpriteText new OsuSpriteText
{ {
Text = localisation.GetUnicodePreference(SetInfo.Metadata.ArtistUnicode, SetInfo.Metadata.Artist), Text = new LocalisedString((SetInfo.Metadata.ArtistUnicode, SetInfo.Metadata.Artist)),
Font = @"Exo2.0-BoldItalic", Font = @"Exo2.0-BoldItalic",
}, },
}, },
@ -217,23 +217,25 @@ namespace osu.Game.Overlays.Direct
statusContainer.Add(new IconPill(FontAwesome.fa_image)); statusContainer.Add(new IconPill(FontAwesome.fa_image));
} }
statusContainer.Add(new BeatmapSetOnlineStatusPill(12, new MarginPadding { Horizontal = 10, Vertical = 5 }) statusContainer.Add(new BeatmapSetOnlineStatusPill
{ {
TextSize = 12,
TextPadding = new MarginPadding { Horizontal = 10, Vertical = 5 },
Status = SetInfo.OnlineInfo?.Status ?? BeatmapSetOnlineStatus.None, Status = SetInfo.OnlineInfo?.Status ?? BeatmapSetOnlineStatus.None,
}); });
PreviewPlaying.ValueChanged += _ => updateStatusContainer(); PreviewPlaying.ValueChanged += _ => updateStatusContainer();
} }
protected override bool OnHover(InputState state) protected override bool OnHover(HoverEvent e)
{ {
updateStatusContainer(); updateStatusContainer();
return base.OnHover(state); return base.OnHover(e);
} }
protected override void OnHoverLost(InputState state) protected override void OnHoverLost(HoverLostEvent e)
{ {
base.OnHoverLost(state); base.OnHoverLost(e);
updateStatusContainer(); updateStatusContainer();
} }

View File

@ -10,8 +10,8 @@ using osu.Framework.Graphics.Colour;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Localisation;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Localisation;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
namespace osu.Game.Overlays.Direct namespace osu.Game.Overlays.Direct
@ -39,7 +39,7 @@ namespace osu.Game.Overlays.Direct
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(LocalisationEngine localisation, OsuColour colours) private void load(OsuColour colours)
{ {
Content.CornerRadius = 5; Content.CornerRadius = 5;
@ -94,13 +94,13 @@ namespace osu.Game.Overlays.Direct
{ {
new OsuSpriteText new OsuSpriteText
{ {
Current = localisation.GetUnicodePreference(SetInfo.Metadata.TitleUnicode, SetInfo.Metadata.Title), Text = new LocalisedString((SetInfo.Metadata.TitleUnicode, SetInfo.Metadata.Title)),
TextSize = 18, TextSize = 18,
Font = @"Exo2.0-BoldItalic", Font = @"Exo2.0-BoldItalic",
}, },
new OsuSpriteText new OsuSpriteText
{ {
Current = localisation.GetUnicodePreference(SetInfo.Metadata.ArtistUnicode, SetInfo.Metadata.Artist), Text = new LocalisedString((SetInfo.Metadata.ArtistUnicode, SetInfo.Metadata.Artist)),
Font = @"Exo2.0-BoldItalic", Font = @"Exo2.0-BoldItalic",
}, },
} }

Some files were not shown because too many files have changed in this diff Show More