mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 01:43:20 +08:00
Merge branch 'master' into customized-mods
This commit is contained in:
commit
900cbd7af3
11
osu.Desktop/Properties/launchSettings.json
Normal file
11
osu.Desktop/Properties/launchSettings.json
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"profiles": {
|
||||||
|
"osu! Desktop": {
|
||||||
|
"commandName": "Project"
|
||||||
|
},
|
||||||
|
"osu! Tournament": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"commandLineArgs": "--tournament"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -12,14 +12,14 @@ namespace osu.Game.Rulesets.Catch.MathUtils
|
|||||||
{
|
{
|
||||||
private const double int_to_real = 1.0 / (int.MaxValue + 1.0);
|
private const double int_to_real = 1.0 / (int.MaxValue + 1.0);
|
||||||
private const uint int_mask = 0x7FFFFFFF;
|
private const uint int_mask = 0x7FFFFFFF;
|
||||||
private const uint y = 842502087;
|
private const uint y_initial = 842502087;
|
||||||
private const uint z = 3579807591;
|
private const uint z_initial = 3579807591;
|
||||||
private const uint w = 273326509;
|
private const uint w_initial = 273326509;
|
||||||
private uint _x, _y = y, _z = z, _w = w;
|
private uint x, y = y_initial, z = z_initial, w = w_initial;
|
||||||
|
|
||||||
public FastRandom(int seed)
|
public FastRandom(int seed)
|
||||||
{
|
{
|
||||||
_x = (uint)seed;
|
x = (uint)seed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FastRandom()
|
public FastRandom()
|
||||||
@ -33,11 +33,11 @@ namespace osu.Game.Rulesets.Catch.MathUtils
|
|||||||
/// <returns>The random value.</returns>
|
/// <returns>The random value.</returns>
|
||||||
public uint NextUInt()
|
public uint NextUInt()
|
||||||
{
|
{
|
||||||
uint t = _x ^ (_x << 11);
|
uint t = x ^ (x << 11);
|
||||||
_x = _y;
|
x = y;
|
||||||
_y = _z;
|
y = z;
|
||||||
_z = _w;
|
z = w;
|
||||||
return _w = _w ^ (_w >> 19) ^ t ^ (t >> 8);
|
return w = w ^ (w >> 19) ^ t ^ (t >> 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -11,6 +11,7 @@ using osu.Framework.Graphics.Shapes;
|
|||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Rulesets.Edit;
|
using osu.Game.Rulesets.Edit;
|
||||||
|
using osu.Game.Rulesets.Objects;
|
||||||
using osu.Game.Rulesets.Osu.Objects;
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
@ -20,10 +21,11 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
|||||||
{
|
{
|
||||||
public class PathControlPointPiece : BlueprintPiece<Slider>
|
public class PathControlPointPiece : BlueprintPiece<Slider>
|
||||||
{
|
{
|
||||||
public Action<int, MouseButtonEvent> RequestSelection;
|
public Action<PathControlPointPiece, MouseButtonEvent> RequestSelection;
|
||||||
|
|
||||||
public readonly BindableBool IsSelected = new BindableBool();
|
public readonly BindableBool IsSelected = new BindableBool();
|
||||||
public readonly int Index;
|
|
||||||
|
public readonly PathControlPoint ControlPoint;
|
||||||
|
|
||||||
private readonly Slider slider;
|
private readonly Slider slider;
|
||||||
private readonly Path path;
|
private readonly Path path;
|
||||||
@ -36,10 +38,14 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private OsuColour colours { get; set; }
|
private OsuColour colours { get; set; }
|
||||||
|
|
||||||
public PathControlPointPiece(Slider slider, int index)
|
private IBindable<Vector2> sliderPosition;
|
||||||
|
private IBindable<int> pathVersion;
|
||||||
|
|
||||||
|
public PathControlPointPiece(Slider slider, PathControlPoint controlPoint)
|
||||||
{
|
{
|
||||||
this.slider = slider;
|
this.slider = slider;
|
||||||
Index = index;
|
|
||||||
|
ControlPoint = controlPoint;
|
||||||
|
|
||||||
Origin = Anchor.Centre;
|
Origin = Anchor.Centre;
|
||||||
AutoSizeAxes = Axes.Both;
|
AutoSizeAxes = Axes.Both;
|
||||||
@ -85,48 +91,41 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Update()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
base.Update();
|
base.LoadComplete();
|
||||||
|
|
||||||
Position = slider.StackedPosition + slider.Path.ControlPoints[Index].Position.Value;
|
sliderPosition = slider.PositionBindable.GetBoundCopy();
|
||||||
|
sliderPosition.BindValueChanged(_ => updateDisplay());
|
||||||
|
|
||||||
|
pathVersion = slider.Path.Version.GetBoundCopy();
|
||||||
|
pathVersion.BindValueChanged(_ => updateDisplay());
|
||||||
|
|
||||||
|
IsSelected.BindValueChanged(_ => updateMarkerDisplay());
|
||||||
|
|
||||||
|
updateDisplay();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateDisplay()
|
||||||
|
{
|
||||||
updateMarkerDisplay();
|
updateMarkerDisplay();
|
||||||
updateConnectingPath();
|
updateConnectingPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Updates the state of the circular control point marker.
|
|
||||||
/// </summary>
|
|
||||||
private void updateMarkerDisplay()
|
|
||||||
{
|
|
||||||
markerRing.Alpha = IsSelected.Value ? 1 : 0;
|
|
||||||
|
|
||||||
Color4 colour = slider.Path.ControlPoints[Index].Type.Value.HasValue ? colours.Red : colours.Yellow;
|
|
||||||
if (IsHovered || IsSelected.Value)
|
|
||||||
colour = Color4.White;
|
|
||||||
marker.Colour = colour;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Updates the path connecting this control point to the previous one.
|
|
||||||
/// </summary>
|
|
||||||
private void updateConnectingPath()
|
|
||||||
{
|
|
||||||
path.ClearVertices();
|
|
||||||
|
|
||||||
if (Index != slider.Path.ControlPoints.Count - 1)
|
|
||||||
{
|
|
||||||
path.AddVertex(Vector2.Zero);
|
|
||||||
path.AddVertex(slider.Path.ControlPoints[Index + 1].Position.Value - slider.Path.ControlPoints[Index].Position.Value);
|
|
||||||
}
|
|
||||||
|
|
||||||
path.OriginPosition = path.PositionInBoundingBox(Vector2.Zero);
|
|
||||||
}
|
|
||||||
|
|
||||||
// The connecting path is excluded from positional input
|
// The connecting path is excluded from positional input
|
||||||
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => marker.ReceivePositionalInputAt(screenSpacePos);
|
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => marker.ReceivePositionalInputAt(screenSpacePos);
|
||||||
|
|
||||||
|
protected override bool OnHover(HoverEvent e)
|
||||||
|
{
|
||||||
|
updateMarkerDisplay();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnHoverLost(HoverLostEvent e)
|
||||||
|
{
|
||||||
|
updateMarkerDisplay();
|
||||||
|
}
|
||||||
|
|
||||||
protected override bool OnMouseDown(MouseDownEvent e)
|
protected override bool OnMouseDown(MouseDownEvent e)
|
||||||
{
|
{
|
||||||
if (RequestSelection == null)
|
if (RequestSelection == null)
|
||||||
@ -135,12 +134,12 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
|||||||
switch (e.Button)
|
switch (e.Button)
|
||||||
{
|
{
|
||||||
case MouseButton.Left:
|
case MouseButton.Left:
|
||||||
RequestSelection.Invoke(Index, e);
|
RequestSelection.Invoke(this, e);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case MouseButton.Right:
|
case MouseButton.Right:
|
||||||
if (!IsSelected.Value)
|
if (!IsSelected.Value)
|
||||||
RequestSelection.Invoke(Index, e);
|
RequestSelection.Invoke(this, e);
|
||||||
return false; // Allow context menu to show
|
return false; // Allow context menu to show
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,7 +154,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
|||||||
|
|
||||||
protected override bool OnDrag(DragEvent e)
|
protected override bool OnDrag(DragEvent e)
|
||||||
{
|
{
|
||||||
if (Index == 0)
|
if (ControlPoint == slider.Path.ControlPoints[0])
|
||||||
{
|
{
|
||||||
// Special handling for the head control point - the position of the slider changes which means the snapped position and time have to be taken into account
|
// Special handling for the head control point - the position of the slider changes which means the snapped position and time have to be taken into account
|
||||||
(Vector2 snappedPosition, double snappedTime) = snapProvider?.GetSnappedPosition(e.MousePosition, slider.StartTime) ?? (e.MousePosition, slider.StartTime);
|
(Vector2 snappedPosition, double snappedTime) = snapProvider?.GetSnappedPosition(e.MousePosition, slider.StartTime) ?? (e.MousePosition, slider.StartTime);
|
||||||
@ -169,11 +168,47 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
|||||||
slider.Path.ControlPoints[i].Position.Value -= movementDelta;
|
slider.Path.ControlPoints[i].Position.Value -= movementDelta;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
slider.Path.ControlPoints[Index].Position.Value += e.Delta;
|
ControlPoint.Position.Value += e.Delta;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnDragEnd(DragEndEvent e) => true;
|
protected override bool OnDragEnd(DragEndEvent e) => true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Updates the state of the circular control point marker.
|
||||||
|
/// </summary>
|
||||||
|
private void updateMarkerDisplay()
|
||||||
|
{
|
||||||
|
Position = slider.StackedPosition + ControlPoint.Position.Value;
|
||||||
|
|
||||||
|
markerRing.Alpha = IsSelected.Value ? 1 : 0;
|
||||||
|
|
||||||
|
Color4 colour = ControlPoint.Type.Value != null ? colours.Red : colours.Yellow;
|
||||||
|
if (IsHovered || IsSelected.Value)
|
||||||
|
colour = Color4.White;
|
||||||
|
marker.Colour = colour;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Updates the path connecting this control point to the previous one.
|
||||||
|
/// </summary>
|
||||||
|
private void updateConnectingPath()
|
||||||
|
{
|
||||||
|
path.ClearVertices();
|
||||||
|
|
||||||
|
int index = slider.Path.ControlPoints.IndexOf(ControlPoint);
|
||||||
|
|
||||||
|
if (index == -1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (++index != slider.Path.ControlPoints.Count)
|
||||||
|
{
|
||||||
|
path.AddVertex(Vector2.Zero);
|
||||||
|
path.AddVertex(slider.Path.ControlPoints[index].Position.Value - ControlPoint.Position.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
path.OriginPosition = path.PositionInBoundingBox(Vector2.Zero);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Humanizer;
|
using Humanizer;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
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;
|
||||||
@ -32,6 +33,8 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
|||||||
[Resolved(CanBeNull = true)]
|
[Resolved(CanBeNull = true)]
|
||||||
private IPlacementHandler placementHandler { get; set; }
|
private IPlacementHandler placementHandler { get; set; }
|
||||||
|
|
||||||
|
private IBindableList<PathControlPoint> controlPoints;
|
||||||
|
|
||||||
public PathControlPointVisualiser(Slider slider, bool allowSelection)
|
public PathControlPointVisualiser(Slider slider, bool allowSelection)
|
||||||
{
|
{
|
||||||
this.slider = slider;
|
this.slider = slider;
|
||||||
@ -47,24 +50,31 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
|||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
inputManager = GetContainingInputManager();
|
inputManager = GetContainingInputManager();
|
||||||
|
|
||||||
|
controlPoints = slider.Path.ControlPoints.GetBoundCopy();
|
||||||
|
controlPoints.ItemsAdded += addControlPoints;
|
||||||
|
controlPoints.ItemsRemoved += removeControlPoints;
|
||||||
|
|
||||||
|
addControlPoints(controlPoints);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Update()
|
private void addControlPoints(IEnumerable<PathControlPoint> controlPoints)
|
||||||
{
|
{
|
||||||
base.Update();
|
foreach (var point in controlPoints)
|
||||||
|
|
||||||
while (slider.Path.ControlPoints.Count > Pieces.Count)
|
|
||||||
{
|
{
|
||||||
var piece = new PathControlPointPiece(slider, Pieces.Count);
|
var piece = new PathControlPointPiece(slider, point);
|
||||||
|
|
||||||
if (allowSelection)
|
if (allowSelection)
|
||||||
piece.RequestSelection = selectPiece;
|
piece.RequestSelection = selectPiece;
|
||||||
|
|
||||||
Pieces.Add(piece);
|
Pieces.Add(piece);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
while (slider.Path.ControlPoints.Count < Pieces.Count)
|
private void removeControlPoints(IEnumerable<PathControlPoint> controlPoints)
|
||||||
Pieces.Remove(Pieces[Pieces.Count - 1]);
|
{
|
||||||
|
foreach (var point in controlPoints)
|
||||||
|
Pieces.RemoveAll(p => p.ControlPoint == point);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnClick(ClickEvent e)
|
protected override bool OnClick(ClickEvent e)
|
||||||
@ -87,20 +97,20 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
|||||||
|
|
||||||
public bool OnReleased(PlatformAction action) => action.ActionMethod == PlatformActionMethod.Delete;
|
public bool OnReleased(PlatformAction action) => action.ActionMethod == PlatformActionMethod.Delete;
|
||||||
|
|
||||||
private void selectPiece(int index, MouseButtonEvent e)
|
private void selectPiece(PathControlPointPiece piece, MouseButtonEvent e)
|
||||||
{
|
{
|
||||||
if (e.Button == MouseButton.Left && inputManager.CurrentState.Keyboard.ControlPressed)
|
if (e.Button == MouseButton.Left && inputManager.CurrentState.Keyboard.ControlPressed)
|
||||||
Pieces[index].IsSelected.Toggle();
|
piece.IsSelected.Toggle();
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
foreach (var piece in Pieces)
|
foreach (var p in Pieces)
|
||||||
piece.IsSelected.Value = piece.Index == index;
|
p.IsSelected.Value = p == piece;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool deleteSelected()
|
private bool deleteSelected()
|
||||||
{
|
{
|
||||||
List<PathControlPoint> toRemove = Pieces.Where(p => p.IsSelected.Value).Select(p => slider.Path.ControlPoints[p.Index]).ToList();
|
List<PathControlPoint> toRemove = Pieces.Where(p => p.IsSelected.Value).Select(p => p.ControlPoint).ToList();
|
||||||
|
|
||||||
// Ensure that there are any points to be deleted
|
// Ensure that there are any points to be deleted
|
||||||
if (toRemove.Count == 0)
|
if (toRemove.Count == 0)
|
||||||
|
@ -3,15 +3,14 @@
|
|||||||
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
|
using osu.Game.Rulesets.Osu.UI.Cursor;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.Skinning
|
namespace osu.Game.Rulesets.Osu.Skinning
|
||||||
{
|
{
|
||||||
public class LegacyCursor : CompositeDrawable
|
public class LegacyCursor : OsuCursorSprite
|
||||||
{
|
{
|
||||||
private NonPlayfieldSprite cursor;
|
|
||||||
private bool spin;
|
private bool spin;
|
||||||
|
|
||||||
public LegacyCursor()
|
public LegacyCursor()
|
||||||
@ -27,7 +26,7 @@ namespace osu.Game.Rulesets.Osu.Skinning
|
|||||||
{
|
{
|
||||||
spin = skin.GetConfig<OsuSkinConfiguration, bool>(OsuSkinConfiguration.CursorRotate)?.Value ?? true;
|
spin = skin.GetConfig<OsuSkinConfiguration, bool>(OsuSkinConfiguration.CursorRotate)?.Value ?? true;
|
||||||
|
|
||||||
InternalChildren = new Drawable[]
|
InternalChildren = new[]
|
||||||
{
|
{
|
||||||
new NonPlayfieldSprite
|
new NonPlayfieldSprite
|
||||||
{
|
{
|
||||||
@ -35,7 +34,7 @@ namespace osu.Game.Rulesets.Osu.Skinning
|
|||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
},
|
},
|
||||||
cursor = new NonPlayfieldSprite
|
ExpandTarget = new NonPlayfieldSprite
|
||||||
{
|
{
|
||||||
Texture = skin.GetTexture("cursor"),
|
Texture = skin.GetTexture("cursor"),
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
@ -47,7 +46,7 @@ namespace osu.Game.Rulesets.Osu.Skinning
|
|||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
if (spin)
|
if (spin)
|
||||||
cursor.Spin(10000, RotationDirection.Clockwise);
|
ExpandTarget.Spin(10000, RotationDirection.Clockwise);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,9 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
|
|||||||
|
|
||||||
private bool cursorExpand;
|
private bool cursorExpand;
|
||||||
|
|
||||||
private Container expandTarget;
|
private SkinnableDrawable cursorSprite;
|
||||||
|
|
||||||
|
private Drawable expandTarget => (cursorSprite.Drawable as OsuCursorSprite)?.ExpandTarget ?? cursorSprite;
|
||||||
|
|
||||||
public OsuCursor()
|
public OsuCursor()
|
||||||
{
|
{
|
||||||
@ -37,12 +39,12 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
InternalChild = expandTarget = new Container
|
InternalChild = new Container
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Child = new SkinnableDrawable(new OsuSkinComponent(OsuSkinComponents.Cursor), _ => new DefaultCursor(), confineMode: ConfineMode.NoScaling)
|
Child = cursorSprite = new SkinnableDrawable(new OsuSkinComponent(OsuSkinComponents.Cursor), _ => new DefaultCursor(), confineMode: ConfineMode.NoScaling)
|
||||||
{
|
{
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
@ -62,7 +64,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
|
|||||||
|
|
||||||
public void Contract() => expandTarget.ScaleTo(released_scale, 100, Easing.OutQuad);
|
public void Contract() => expandTarget.ScaleTo(released_scale, 100, Easing.OutQuad);
|
||||||
|
|
||||||
private class DefaultCursor : CompositeDrawable
|
private class DefaultCursor : OsuCursorSprite
|
||||||
{
|
{
|
||||||
public DefaultCursor()
|
public DefaultCursor()
|
||||||
{
|
{
|
||||||
@ -71,10 +73,12 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
|
|||||||
Anchor = Anchor.Centre;
|
Anchor = Anchor.Centre;
|
||||||
Origin = Anchor.Centre;
|
Origin = Anchor.Centre;
|
||||||
|
|
||||||
InternalChildren = new Drawable[]
|
InternalChildren = new[]
|
||||||
{
|
{
|
||||||
new CircularContainer
|
ExpandTarget = new CircularContainer
|
||||||
{
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Masking = true,
|
Masking = true,
|
||||||
BorderThickness = size / 6,
|
BorderThickness = size / 6,
|
||||||
|
17
osu.Game.Rulesets.Osu/UI/Cursor/OsuCursorSprite.cs
Normal file
17
osu.Game.Rulesets.Osu/UI/Cursor/OsuCursorSprite.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Osu.UI.Cursor
|
||||||
|
{
|
||||||
|
public abstract class OsuCursorSprite : CompositeDrawable
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The an optional piece of the cursor to expand when in a clicked state.
|
||||||
|
/// If null, the whole cursor will be affected by expansion.
|
||||||
|
/// </summary>
|
||||||
|
public Drawable ExpandTarget { get; protected set; }
|
||||||
|
}
|
||||||
|
}
|
@ -83,88 +83,81 @@ namespace osu.Game.Tournament.Screens.Drawings.Components
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private ScrollState _scrollState;
|
private ScrollState scrollState;
|
||||||
|
|
||||||
private ScrollState scrollState
|
private void setScrollState(ScrollState newstate)
|
||||||
{
|
{
|
||||||
get => _scrollState;
|
if (scrollState == newstate)
|
||||||
|
return;
|
||||||
|
|
||||||
set
|
delayedStateChangeDelegate?.Cancel();
|
||||||
|
|
||||||
|
switch (scrollState = newstate)
|
||||||
{
|
{
|
||||||
if (_scrollState == value)
|
case ScrollState.Scrolling:
|
||||||
return;
|
resetSelected();
|
||||||
|
|
||||||
_scrollState = value;
|
OnScrollStarted?.Invoke();
|
||||||
|
|
||||||
delayedStateChangeDelegate?.Cancel();
|
speedTo(1000f, 200);
|
||||||
|
tracker.FadeOut(100);
|
||||||
|
break;
|
||||||
|
|
||||||
switch (value)
|
case ScrollState.Stopping:
|
||||||
{
|
speedTo(0f, 2000);
|
||||||
case ScrollState.Scrolling:
|
tracker.FadeIn(200);
|
||||||
resetSelected();
|
|
||||||
|
|
||||||
OnScrollStarted?.Invoke();
|
delayedStateChangeDelegate = Scheduler.AddDelayed(() => setScrollState(ScrollState.Stopped), 2300);
|
||||||
|
break;
|
||||||
|
|
||||||
speedTo(1000f, 200);
|
case ScrollState.Stopped:
|
||||||
tracker.FadeOut(100);
|
// Find closest to center
|
||||||
|
if (!Children.Any())
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ScrollState.Stopping:
|
ScrollingTeam closest = null;
|
||||||
speedTo(0f, 2000);
|
|
||||||
tracker.FadeIn(200);
|
|
||||||
|
|
||||||
delayedStateChangeDelegate = Scheduler.AddDelayed(() => scrollState = ScrollState.Stopped, 2300);
|
foreach (var c in Children)
|
||||||
break;
|
{
|
||||||
|
if (!(c is ScrollingTeam stc))
|
||||||
|
continue;
|
||||||
|
|
||||||
case ScrollState.Stopped:
|
if (closest == null)
|
||||||
// Find closest to center
|
|
||||||
if (!Children.Any())
|
|
||||||
break;
|
|
||||||
|
|
||||||
ScrollingTeam closest = null;
|
|
||||||
|
|
||||||
foreach (var c in Children)
|
|
||||||
{
|
{
|
||||||
if (!(c is ScrollingTeam stc))
|
closest = stc;
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (closest == null)
|
|
||||||
{
|
|
||||||
closest = stc;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
float o = Math.Abs(c.Position.X + c.DrawWidth / 2f - DrawWidth / 2f);
|
|
||||||
float lastOffset = Math.Abs(closest.Position.X + closest.DrawWidth / 2f - DrawWidth / 2f);
|
|
||||||
|
|
||||||
if (o < lastOffset)
|
|
||||||
closest = stc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Trace.Assert(closest != null, "closest != null");
|
float o = Math.Abs(c.Position.X + c.DrawWidth / 2f - DrawWidth / 2f);
|
||||||
|
float lastOffset = Math.Abs(closest.Position.X + closest.DrawWidth / 2f - DrawWidth / 2f);
|
||||||
|
|
||||||
// ReSharper disable once PossibleNullReferenceException
|
if (o < lastOffset)
|
||||||
offset += DrawWidth / 2f - (closest.Position.X + closest.DrawWidth / 2f);
|
closest = stc;
|
||||||
|
}
|
||||||
|
|
||||||
ScrollingTeam st = closest;
|
Trace.Assert(closest != null, "closest != null");
|
||||||
|
|
||||||
availableTeams.RemoveAll(at => at == st.Team);
|
// ReSharper disable once PossibleNullReferenceException
|
||||||
|
offset += DrawWidth / 2f - (closest.Position.X + closest.DrawWidth / 2f);
|
||||||
|
|
||||||
st.Selected = true;
|
ScrollingTeam st = closest;
|
||||||
OnSelected?.Invoke(st.Team);
|
|
||||||
|
|
||||||
delayedStateChangeDelegate = Scheduler.AddDelayed(() => scrollState = ScrollState.Idle, 10000);
|
availableTeams.RemoveAll(at => at == st.Team);
|
||||||
break;
|
|
||||||
|
|
||||||
case ScrollState.Idle:
|
st.Selected = true;
|
||||||
resetSelected();
|
OnSelected?.Invoke(st.Team);
|
||||||
|
|
||||||
OnScrollStarted?.Invoke();
|
delayedStateChangeDelegate = Scheduler.AddDelayed(() => setScrollState(ScrollState.Idle), 10000);
|
||||||
|
break;
|
||||||
|
|
||||||
speedTo(40f, 200);
|
case ScrollState.Idle:
|
||||||
tracker.FadeOut(100);
|
resetSelected();
|
||||||
break;
|
|
||||||
}
|
OnScrollStarted?.Invoke();
|
||||||
|
|
||||||
|
speedTo(40f, 200);
|
||||||
|
tracker.FadeOut(100);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,7 +169,7 @@ namespace osu.Game.Tournament.Screens.Drawings.Components
|
|||||||
availableTeams.Add(team);
|
availableTeams.Add(team);
|
||||||
|
|
||||||
RemoveAll(c => c is ScrollingTeam);
|
RemoveAll(c => c is ScrollingTeam);
|
||||||
scrollState = ScrollState.Idle;
|
setScrollState(ScrollState.Idle);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddTeams(IEnumerable<TournamentTeam> teams)
|
public void AddTeams(IEnumerable<TournamentTeam> teams)
|
||||||
@ -192,7 +185,7 @@ namespace osu.Game.Tournament.Screens.Drawings.Components
|
|||||||
{
|
{
|
||||||
availableTeams.Clear();
|
availableTeams.Clear();
|
||||||
RemoveAll(c => c is ScrollingTeam);
|
RemoveAll(c => c is ScrollingTeam);
|
||||||
scrollState = ScrollState.Idle;
|
setScrollState(ScrollState.Idle);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RemoveTeam(TournamentTeam team)
|
public void RemoveTeam(TournamentTeam team)
|
||||||
@ -217,7 +210,7 @@ namespace osu.Game.Tournament.Screens.Drawings.Components
|
|||||||
if (availableTeams.Count == 0)
|
if (availableTeams.Count == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
scrollState = ScrollState.Scrolling;
|
setScrollState(ScrollState.Scrolling);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void StopScrolling()
|
public void StopScrolling()
|
||||||
@ -232,13 +225,13 @@ namespace osu.Game.Tournament.Screens.Drawings.Components
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
scrollState = ScrollState.Stopping;
|
setScrollState(ScrollState.Stopping);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
scrollState = ScrollState.Idle;
|
setScrollState(ScrollState.Idle);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void UpdateAfterChildren()
|
protected override void UpdateAfterChildren()
|
||||||
@ -305,7 +298,7 @@ namespace osu.Game.Tournament.Screens.Drawings.Components
|
|||||||
private void speedTo(float value, double duration = 0, Easing easing = Easing.None) =>
|
private void speedTo(float value, double duration = 0, Easing easing = Easing.None) =>
|
||||||
this.TransformTo(nameof(speed), value, duration, easing);
|
this.TransformTo(nameof(speed), value, duration, easing);
|
||||||
|
|
||||||
private enum ScrollState
|
protected enum ScrollState
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
Idle,
|
Idle,
|
||||||
|
@ -45,23 +45,25 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
[JsonProperty("beatmap")]
|
[JsonProperty("beatmap")]
|
||||||
private APIBeatmap apiBeatmap { get; set; }
|
private APIBeatmap apiBeatmap { get; set; }
|
||||||
|
|
||||||
|
private APIMod[] allowedModsBacking;
|
||||||
|
|
||||||
[JsonProperty("allowed_mods")]
|
[JsonProperty("allowed_mods")]
|
||||||
private APIMod[] allowedMods
|
private APIMod[] allowedMods
|
||||||
{
|
{
|
||||||
get => AllowedMods.Select(m => new APIMod { Acronym = m.Acronym }).ToArray();
|
get => AllowedMods.Select(m => new APIMod { Acronym = m.Acronym }).ToArray();
|
||||||
set => _allowedMods = value;
|
set => allowedModsBacking = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private APIMod[] requiredModsBacking;
|
||||||
|
|
||||||
[JsonProperty("required_mods")]
|
[JsonProperty("required_mods")]
|
||||||
private APIMod[] requiredMods
|
private APIMod[] requiredMods
|
||||||
{
|
{
|
||||||
get => RequiredMods.Select(m => new APIMod { Acronym = m.Acronym }).ToArray();
|
get => RequiredMods.Select(m => new APIMod { Acronym = m.Acronym }).ToArray();
|
||||||
set => _requiredMods = value;
|
set => requiredModsBacking = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
private BeatmapInfo beatmap;
|
private BeatmapInfo beatmap;
|
||||||
private APIMod[] _allowedMods;
|
|
||||||
private APIMod[] _requiredMods;
|
|
||||||
|
|
||||||
public void MapObjects(BeatmapManager beatmaps, RulesetStore rulesets)
|
public void MapObjects(BeatmapManager beatmaps, RulesetStore rulesets)
|
||||||
{
|
{
|
||||||
@ -70,20 +72,20 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
Beatmap = apiBeatmap == null ? beatmaps.QueryBeatmap(b => b.OnlineBeatmapID == BeatmapID) : apiBeatmap.ToBeatmap(rulesets);
|
Beatmap = apiBeatmap == null ? beatmaps.QueryBeatmap(b => b.OnlineBeatmapID == BeatmapID) : apiBeatmap.ToBeatmap(rulesets);
|
||||||
Ruleset = rulesets.GetRuleset(RulesetID);
|
Ruleset = rulesets.GetRuleset(RulesetID);
|
||||||
|
|
||||||
if (_allowedMods != null)
|
if (allowedModsBacking != null)
|
||||||
{
|
{
|
||||||
AllowedMods.Clear();
|
AllowedMods.Clear();
|
||||||
AllowedMods.AddRange(Ruleset.CreateInstance().GetAllMods().Where(mod => _allowedMods.Any(m => m.Acronym == mod.Acronym)));
|
AllowedMods.AddRange(Ruleset.CreateInstance().GetAllMods().Where(mod => allowedModsBacking.Any(m => m.Acronym == mod.Acronym)));
|
||||||
|
|
||||||
_allowedMods = null;
|
allowedModsBacking = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_requiredMods != null)
|
if (requiredModsBacking != null)
|
||||||
{
|
{
|
||||||
RequiredMods.Clear();
|
RequiredMods.Clear();
|
||||||
RequiredMods.AddRange(Ruleset.CreateInstance().GetAllMods().Where(mod => _requiredMods.Any(m => m.Acronym == mod.Acronym)));
|
RequiredMods.AddRange(Ruleset.CreateInstance().GetAllMods().Where(mod => requiredModsBacking.Any(m => m.Acronym == mod.Acronym)));
|
||||||
|
|
||||||
_requiredMods = null;
|
requiredModsBacking = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,26 +188,22 @@ namespace osu.Game.Screens.Play
|
|||||||
InternalButtons.Add(button);
|
InternalButtons.Add(button);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int _selectionIndex = -1;
|
private int selectionIndex = -1;
|
||||||
|
|
||||||
private int selectionIndex
|
private void setSelected(int value)
|
||||||
{
|
{
|
||||||
get => _selectionIndex;
|
if (selectionIndex == value)
|
||||||
set
|
return;
|
||||||
{
|
|
||||||
if (_selectionIndex == value)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Deselect the previously-selected button
|
// Deselect the previously-selected button
|
||||||
if (_selectionIndex != -1)
|
if (selectionIndex != -1)
|
||||||
InternalButtons[_selectionIndex].Selected.Value = false;
|
InternalButtons[selectionIndex].Selected.Value = false;
|
||||||
|
|
||||||
_selectionIndex = value;
|
selectionIndex = value;
|
||||||
|
|
||||||
// Select the newly-selected button
|
// Select the newly-selected button
|
||||||
if (_selectionIndex != -1)
|
if (selectionIndex != -1)
|
||||||
InternalButtons[_selectionIndex].Selected.Value = true;
|
InternalButtons[selectionIndex].Selected.Value = true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnKeyDown(KeyDownEvent e)
|
protected override bool OnKeyDown(KeyDownEvent e)
|
||||||
@ -218,16 +214,16 @@ namespace osu.Game.Screens.Play
|
|||||||
{
|
{
|
||||||
case Key.Up:
|
case Key.Up:
|
||||||
if (selectionIndex == -1 || selectionIndex == 0)
|
if (selectionIndex == -1 || selectionIndex == 0)
|
||||||
selectionIndex = InternalButtons.Count - 1;
|
setSelected(InternalButtons.Count - 1);
|
||||||
else
|
else
|
||||||
selectionIndex--;
|
setSelected(selectionIndex - 1);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case Key.Down:
|
case Key.Down:
|
||||||
if (selectionIndex == -1 || selectionIndex == InternalButtons.Count - 1)
|
if (selectionIndex == -1 || selectionIndex == InternalButtons.Count - 1)
|
||||||
selectionIndex = 0;
|
setSelected(0);
|
||||||
else
|
else
|
||||||
selectionIndex++;
|
setSelected(selectionIndex + 1);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -266,9 +262,9 @@ namespace osu.Game.Screens.Play
|
|||||||
private void buttonSelectionChanged(DialogButton button, bool isSelected)
|
private void buttonSelectionChanged(DialogButton button, bool isSelected)
|
||||||
{
|
{
|
||||||
if (!isSelected)
|
if (!isSelected)
|
||||||
selectionIndex = -1;
|
setSelected(-1);
|
||||||
else
|
else
|
||||||
selectionIndex = InternalButtons.IndexOf(button);
|
setSelected(InternalButtons.IndexOf(button));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateRetryCount()
|
private void updateRetryCount()
|
||||||
|
Loading…
Reference in New Issue
Block a user