mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 21:02:55 +08:00
Merge branch 'master' into beatmap-overlay-ruleset-selector
This commit is contained in:
commit
923041c3f9
8
.github/ISSUE_TEMPLATE/mobile-issues.md
vendored
Normal file
8
.github/ISSUE_TEMPLATE/mobile-issues.md
vendored
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
name: Mobile Report
|
||||||
|
about: ⚠ Due to current development priorities we are not accepting mobile reports at this time (unless you're willing to fix them yourself!)
|
||||||
|
---
|
||||||
|
|
||||||
|
⚠ **PLEASE READ** ⚠: Due to prioritising finishing the client for desktop first we are not accepting reports related to mobile platforms for the time being, unless you're willing to fix them.
|
||||||
|
If you'd like to report a problem or suggest a feature and then work on it, feel free to open an issue and highlight that you'd like to address it yourself in the issue body; mobile pull requests are also welcome.
|
||||||
|
Otherwise, please check back in the future when the focus of development shifts towards mobile!
|
@ -62,6 +62,6 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.1010.0" />
|
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.1010.0" />
|
||||||
<PackageReference Include="ppy.osu.Framework.Android" Version="2019.1011.0" />
|
<PackageReference Include="ppy.osu.Framework.Android" Version="2019.1029.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -16,6 +16,11 @@ namespace osu.Android
|
|||||||
|
|
||||||
protected override void OnCreate(Bundle savedInstanceState)
|
protected override void OnCreate(Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
|
// The default current directory on android is '/'.
|
||||||
|
// On some devices '/' maps to the app data directory. On others it maps to the root of the internal storage.
|
||||||
|
// In order to have a consistent current directory on all devices the full path of the app data directory is set as the current directory.
|
||||||
|
System.Environment.CurrentDirectory = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
|
||||||
|
|
||||||
base.OnCreate(savedInstanceState);
|
base.OnCreate(savedInstanceState);
|
||||||
|
|
||||||
Window.AddFlags(WindowManagerFlags.Fullscreen);
|
Window.AddFlags(WindowManagerFlags.Fullscreen);
|
||||||
|
@ -38,7 +38,7 @@ namespace osu.Game.Rulesets.Catch.Tests
|
|||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
var controlPointInfo = new ControlPointInfo();
|
var controlPointInfo = new ControlPointInfo();
|
||||||
controlPointInfo.TimingPoints.Add(new TimingControlPoint());
|
controlPointInfo.Add(0, new TimingControlPoint());
|
||||||
|
|
||||||
WorkingBeatmap beatmap = CreateWorkingBeatmap(new Beatmap
|
WorkingBeatmap beatmap = CreateWorkingBeatmap(new Beatmap
|
||||||
{
|
{
|
||||||
|
@ -2,35 +2,50 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Game.Rulesets.Objects;
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Catch.Objects.Drawable
|
namespace osu.Game.Rulesets.Catch.Objects.Drawable
|
||||||
{
|
{
|
||||||
public class DrawableBananaShower : DrawableCatchHitObject<BananaShower>
|
public class DrawableBananaShower : DrawableCatchHitObject<BananaShower>
|
||||||
{
|
{
|
||||||
|
private readonly Func<CatchHitObject, DrawableHitObject<CatchHitObject>> createDrawableRepresentation;
|
||||||
private readonly Container bananaContainer;
|
private readonly Container bananaContainer;
|
||||||
|
|
||||||
public DrawableBananaShower(BananaShower s, Func<CatchHitObject, DrawableHitObject<CatchHitObject>> createDrawableRepresentation = null)
|
public DrawableBananaShower(BananaShower s, Func<CatchHitObject, DrawableHitObject<CatchHitObject>> createDrawableRepresentation = null)
|
||||||
: base(s)
|
: base(s)
|
||||||
{
|
{
|
||||||
|
this.createDrawableRepresentation = createDrawableRepresentation;
|
||||||
RelativeSizeAxes = Axes.X;
|
RelativeSizeAxes = Axes.X;
|
||||||
Origin = Anchor.BottomLeft;
|
Origin = Anchor.BottomLeft;
|
||||||
X = 0;
|
X = 0;
|
||||||
|
|
||||||
AddInternal(bananaContainer = new Container { RelativeSizeAxes = Axes.Both });
|
AddInternal(bananaContainer = new Container { RelativeSizeAxes = Axes.Both });
|
||||||
|
|
||||||
foreach (var b in s.NestedHitObjects.Cast<Banana>())
|
|
||||||
AddNested(createDrawableRepresentation?.Invoke(b));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void AddNested(DrawableHitObject h)
|
protected override void AddNestedHitObject(DrawableHitObject hitObject)
|
||||||
{
|
{
|
||||||
((DrawableCatchHitObject)h).CheckPosition = o => CheckPosition?.Invoke(o) ?? false;
|
base.AddNestedHitObject(hitObject);
|
||||||
bananaContainer.Add(h);
|
bananaContainer.Add(hitObject);
|
||||||
base.AddNested(h);
|
}
|
||||||
|
|
||||||
|
protected override void ClearNestedHitObjects()
|
||||||
|
{
|
||||||
|
base.ClearNestedHitObjects();
|
||||||
|
bananaContainer.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override DrawableHitObject CreateNestedHitObject(HitObject hitObject)
|
||||||
|
{
|
||||||
|
switch (hitObject)
|
||||||
|
{
|
||||||
|
case Banana banana:
|
||||||
|
return createDrawableRepresentation?.Invoke(banana)?.With(o => ((DrawableCatchHitObject)o).CheckPosition = p => CheckPosition?.Invoke(p) ?? false);
|
||||||
|
}
|
||||||
|
|
||||||
|
return base.CreateNestedHitObject(hitObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,38 +2,50 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Game.Rulesets.Objects;
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Catch.Objects.Drawable
|
namespace osu.Game.Rulesets.Catch.Objects.Drawable
|
||||||
{
|
{
|
||||||
public class DrawableJuiceStream : DrawableCatchHitObject<JuiceStream>
|
public class DrawableJuiceStream : DrawableCatchHitObject<JuiceStream>
|
||||||
{
|
{
|
||||||
|
private readonly Func<CatchHitObject, DrawableHitObject<CatchHitObject>> createDrawableRepresentation;
|
||||||
private readonly Container dropletContainer;
|
private readonly Container dropletContainer;
|
||||||
|
|
||||||
public DrawableJuiceStream(JuiceStream s, Func<CatchHitObject, DrawableHitObject<CatchHitObject>> createDrawableRepresentation = null)
|
public DrawableJuiceStream(JuiceStream s, Func<CatchHitObject, DrawableHitObject<CatchHitObject>> createDrawableRepresentation = null)
|
||||||
: base(s)
|
: base(s)
|
||||||
{
|
{
|
||||||
|
this.createDrawableRepresentation = createDrawableRepresentation;
|
||||||
RelativeSizeAxes = Axes.Both;
|
RelativeSizeAxes = Axes.Both;
|
||||||
Origin = Anchor.BottomLeft;
|
Origin = Anchor.BottomLeft;
|
||||||
X = 0;
|
X = 0;
|
||||||
|
|
||||||
AddInternal(dropletContainer = new Container { RelativeSizeAxes = Axes.Both, });
|
AddInternal(dropletContainer = new Container { RelativeSizeAxes = Axes.Both, });
|
||||||
|
|
||||||
foreach (var o in s.NestedHitObjects.Cast<CatchHitObject>())
|
|
||||||
AddNested(createDrawableRepresentation?.Invoke(o));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void AddNested(DrawableHitObject h)
|
protected override void AddNestedHitObject(DrawableHitObject hitObject)
|
||||||
{
|
{
|
||||||
var catchObject = (DrawableCatchHitObject)h;
|
base.AddNestedHitObject(hitObject);
|
||||||
|
dropletContainer.Add(hitObject);
|
||||||
|
}
|
||||||
|
|
||||||
catchObject.CheckPosition = o => CheckPosition?.Invoke(o) ?? false;
|
protected override void ClearNestedHitObjects()
|
||||||
|
{
|
||||||
|
base.ClearNestedHitObjects();
|
||||||
|
dropletContainer.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
dropletContainer.Add(h);
|
protected override DrawableHitObject CreateNestedHitObject(HitObject hitObject)
|
||||||
base.AddNested(h);
|
{
|
||||||
|
switch (hitObject)
|
||||||
|
{
|
||||||
|
case CatchHitObject catchObject:
|
||||||
|
return createDrawableRepresentation?.Invoke(catchObject)?.With(o => ((DrawableCatchHitObject)o).CheckPosition = p => CheckPosition?.Invoke(p) ?? false);
|
||||||
|
}
|
||||||
|
|
||||||
|
return base.CreateNestedHitObject(hitObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,45 +16,51 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
|||||||
{
|
{
|
||||||
public class HoldNoteSelectionBlueprint : ManiaSelectionBlueprint
|
public class HoldNoteSelectionBlueprint : ManiaSelectionBlueprint
|
||||||
{
|
{
|
||||||
public new DrawableHoldNote HitObject => (DrawableHoldNote)base.HitObject;
|
public new DrawableHoldNote DrawableObject => (DrawableHoldNote)base.DrawableObject;
|
||||||
|
|
||||||
private readonly IBindable<ScrollingDirection> direction = new Bindable<ScrollingDirection>();
|
private readonly IBindable<ScrollingDirection> direction = new Bindable<ScrollingDirection>();
|
||||||
|
|
||||||
private readonly BodyPiece body;
|
[Resolved]
|
||||||
|
private OsuColour colours { get; set; }
|
||||||
|
|
||||||
public HoldNoteSelectionBlueprint(DrawableHoldNote hold)
|
public HoldNoteSelectionBlueprint(DrawableHoldNote hold)
|
||||||
: base(hold)
|
: base(hold)
|
||||||
{
|
{
|
||||||
InternalChildren = new Drawable[]
|
|
||||||
{
|
|
||||||
new HoldNoteNoteSelectionBlueprint(hold.Head),
|
|
||||||
new HoldNoteNoteSelectionBlueprint(hold.Tail),
|
|
||||||
body = new BodyPiece
|
|
||||||
{
|
|
||||||
AccentColour = Color4.Transparent
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours, IScrollingInfo scrollingInfo)
|
private void load(IScrollingInfo scrollingInfo)
|
||||||
{
|
{
|
||||||
body.BorderColour = colours.Yellow;
|
|
||||||
|
|
||||||
direction.BindTo(scrollingInfo.Direction);
|
direction.BindTo(scrollingInfo.Direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
|
||||||
|
InternalChildren = new Drawable[]
|
||||||
|
{
|
||||||
|
new HoldNoteNoteSelectionBlueprint(DrawableObject.Head),
|
||||||
|
new HoldNoteNoteSelectionBlueprint(DrawableObject.Tail),
|
||||||
|
new BodyPiece
|
||||||
|
{
|
||||||
|
AccentColour = Color4.Transparent,
|
||||||
|
BorderColour = colours.Yellow
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
|
|
||||||
Size = HitObject.DrawSize + new Vector2(0, HitObject.Tail.DrawHeight);
|
Size = DrawableObject.DrawSize + new Vector2(0, DrawableObject.Tail.DrawHeight);
|
||||||
|
|
||||||
// This is a side-effect of not matching the hitobject's anchors/origins, which is kinda hard to do
|
// This is a side-effect of not matching the hitobject's anchors/origins, which is kinda hard to do
|
||||||
// When scrolling upwards our origin is already at the top of the head note (which is the intended location),
|
// When scrolling upwards our origin is already at the top of the head note (which is the intended location),
|
||||||
// but when scrolling downwards our origin is at the _bottom_ of the tail note (where we need to be at the _top_ of the tail note)
|
// but when scrolling downwards our origin is at the _bottom_ of the tail note (where we need to be at the _top_ of the tail note)
|
||||||
if (direction.Value == ScrollingDirection.Down)
|
if (direction.Value == ScrollingDirection.Down)
|
||||||
Y -= HitObject.Tail.DrawHeight;
|
Y -= DrawableObject.Tail.DrawHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Quad SelectionQuad => ScreenSpaceDrawQuad;
|
public override Quad SelectionQuad => ScreenSpaceDrawQuad;
|
||||||
@ -71,10 +77,10 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
|||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
|
|
||||||
Anchor = HitObject.Anchor;
|
Anchor = DrawableObject.Anchor;
|
||||||
Origin = HitObject.Origin;
|
Origin = DrawableObject.Origin;
|
||||||
|
|
||||||
Position = HitObject.DrawPosition;
|
Position = DrawableObject.DrawPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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.
|
||||||
|
@ -18,7 +18,7 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
|||||||
public Vector2 ScreenSpaceDragPosition { get; private set; }
|
public Vector2 ScreenSpaceDragPosition { get; private set; }
|
||||||
public Vector2 DragPosition { get; private set; }
|
public Vector2 DragPosition { get; private set; }
|
||||||
|
|
||||||
public new DrawableManiaHitObject HitObject => (DrawableManiaHitObject)base.HitObject;
|
public new DrawableManiaHitObject DrawableObject => (DrawableManiaHitObject)base.DrawableObject;
|
||||||
|
|
||||||
protected IClock EditorClock { get; private set; }
|
protected IClock EditorClock { get; private set; }
|
||||||
|
|
||||||
@ -28,8 +28,8 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private IManiaHitObjectComposer composer { get; set; }
|
private IManiaHitObjectComposer composer { get; set; }
|
||||||
|
|
||||||
public ManiaSelectionBlueprint(DrawableHitObject hitObject)
|
public ManiaSelectionBlueprint(DrawableHitObject drawableObject)
|
||||||
: base(hitObject)
|
: base(drawableObject)
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.None;
|
RelativeSizeAxes = Axes.None;
|
||||||
}
|
}
|
||||||
@ -44,13 +44,13 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
|||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
|
|
||||||
Position = Parent.ToLocalSpace(HitObject.ToScreenSpace(Vector2.Zero));
|
Position = Parent.ToLocalSpace(DrawableObject.ToScreenSpace(Vector2.Zero));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnMouseDown(MouseDownEvent e)
|
protected override bool OnMouseDown(MouseDownEvent e)
|
||||||
{
|
{
|
||||||
ScreenSpaceDragPosition = e.ScreenSpaceMousePosition;
|
ScreenSpaceDragPosition = e.ScreenSpaceMousePosition;
|
||||||
DragPosition = HitObject.ToLocalSpace(e.ScreenSpaceMousePosition);
|
DragPosition = DrawableObject.ToLocalSpace(e.ScreenSpaceMousePosition);
|
||||||
|
|
||||||
return base.OnMouseDown(e);
|
return base.OnMouseDown(e);
|
||||||
}
|
}
|
||||||
@ -60,20 +60,20 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
|||||||
var result = base.OnDrag(e);
|
var result = base.OnDrag(e);
|
||||||
|
|
||||||
ScreenSpaceDragPosition = e.ScreenSpaceMousePosition;
|
ScreenSpaceDragPosition = e.ScreenSpaceMousePosition;
|
||||||
DragPosition = HitObject.ToLocalSpace(e.ScreenSpaceMousePosition);
|
DragPosition = DrawableObject.ToLocalSpace(e.ScreenSpaceMousePosition);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Show()
|
public override void Show()
|
||||||
{
|
{
|
||||||
HitObject.AlwaysAlive = true;
|
DrawableObject.AlwaysAlive = true;
|
||||||
base.Show();
|
base.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Hide()
|
public override void Hide()
|
||||||
{
|
{
|
||||||
HitObject.AlwaysAlive = false;
|
DrawableObject.AlwaysAlive = false;
|
||||||
base.Hide();
|
base.Hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
|||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
|
|
||||||
Size = HitObject.DrawSize;
|
Size = DrawableObject.DrawSize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ namespace osu.Game.Rulesets.Mania.Edit
|
|||||||
public override void HandleMovement(MoveSelectionEvent moveEvent)
|
public override void HandleMovement(MoveSelectionEvent moveEvent)
|
||||||
{
|
{
|
||||||
var maniaBlueprint = (ManiaSelectionBlueprint)moveEvent.Blueprint;
|
var maniaBlueprint = (ManiaSelectionBlueprint)moveEvent.Blueprint;
|
||||||
int lastColumn = maniaBlueprint.HitObject.HitObject.Column;
|
int lastColumn = maniaBlueprint.DrawableObject.HitObject.Column;
|
||||||
|
|
||||||
adjustOrigins(maniaBlueprint);
|
adjustOrigins(maniaBlueprint);
|
||||||
performDragMovement(moveEvent);
|
performDragMovement(moveEvent);
|
||||||
@ -48,19 +48,19 @@ namespace osu.Game.Rulesets.Mania.Edit
|
|||||||
/// <param name="reference">The <see cref="ManiaSelectionBlueprint"/> that received the drag event.</param>
|
/// <param name="reference">The <see cref="ManiaSelectionBlueprint"/> that received the drag event.</param>
|
||||||
private void adjustOrigins(ManiaSelectionBlueprint reference)
|
private void adjustOrigins(ManiaSelectionBlueprint reference)
|
||||||
{
|
{
|
||||||
var referenceParent = (HitObjectContainer)reference.HitObject.Parent;
|
var referenceParent = (HitObjectContainer)reference.DrawableObject.Parent;
|
||||||
|
|
||||||
float offsetFromReferenceOrigin = reference.DragPosition.Y - reference.HitObject.OriginPosition.Y;
|
float offsetFromReferenceOrigin = reference.DragPosition.Y - reference.DrawableObject.OriginPosition.Y;
|
||||||
float targetPosition = referenceParent.ToLocalSpace(reference.ScreenSpaceDragPosition).Y - offsetFromReferenceOrigin;
|
float targetPosition = referenceParent.ToLocalSpace(reference.ScreenSpaceDragPosition).Y - offsetFromReferenceOrigin;
|
||||||
|
|
||||||
// Flip the vertical coordinate space when scrolling downwards
|
// Flip the vertical coordinate space when scrolling downwards
|
||||||
if (scrollingInfo.Direction.Value == ScrollingDirection.Down)
|
if (scrollingInfo.Direction.Value == ScrollingDirection.Down)
|
||||||
targetPosition = targetPosition - referenceParent.DrawHeight;
|
targetPosition = targetPosition - referenceParent.DrawHeight;
|
||||||
|
|
||||||
float movementDelta = targetPosition - reference.HitObject.Position.Y;
|
float movementDelta = targetPosition - reference.DrawableObject.Position.Y;
|
||||||
|
|
||||||
foreach (var b in SelectedBlueprints.OfType<ManiaSelectionBlueprint>())
|
foreach (var b in SelectedBlueprints.OfType<ManiaSelectionBlueprint>())
|
||||||
b.HitObject.Y += movementDelta;
|
b.DrawableObject.Y += movementDelta;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void performDragMovement(MoveSelectionEvent moveEvent)
|
private void performDragMovement(MoveSelectionEvent moveEvent)
|
||||||
@ -70,11 +70,11 @@ namespace osu.Game.Rulesets.Mania.Edit
|
|||||||
// When scrolling downwards the anchor position is at the bottom of the screen, however the movement event assumes the anchor is at the top of the screen.
|
// When scrolling downwards the anchor position is at the bottom of the screen, however the movement event assumes the anchor is at the top of the screen.
|
||||||
// This causes the delta to assume a positive hitobject position, and which can be corrected for by subtracting the parent height.
|
// This causes the delta to assume a positive hitobject position, and which can be corrected for by subtracting the parent height.
|
||||||
if (scrollingInfo.Direction.Value == ScrollingDirection.Down)
|
if (scrollingInfo.Direction.Value == ScrollingDirection.Down)
|
||||||
delta -= moveEvent.Blueprint.HitObject.Parent.DrawHeight;
|
delta -= moveEvent.Blueprint.DrawableObject.Parent.DrawHeight;
|
||||||
|
|
||||||
foreach (var b in SelectedBlueprints)
|
foreach (var b in SelectedBlueprints)
|
||||||
{
|
{
|
||||||
var hitObject = b.HitObject;
|
var hitObject = b.DrawableObject;
|
||||||
var objectParent = (HitObjectContainer)hitObject.Parent;
|
var objectParent = (HitObjectContainer)hitObject.Parent;
|
||||||
|
|
||||||
// StartTime could be used to adjust the position if only one movement event was received per frame.
|
// StartTime could be used to adjust the position if only one movement event was received per frame.
|
||||||
|
@ -9,8 +9,8 @@ namespace osu.Game.Rulesets.Mania.Edit.Masks
|
|||||||
{
|
{
|
||||||
public abstract class ManiaSelectionBlueprint : SelectionBlueprint
|
public abstract class ManiaSelectionBlueprint : SelectionBlueprint
|
||||||
{
|
{
|
||||||
protected ManiaSelectionBlueprint(DrawableHitObject hitObject)
|
protected ManiaSelectionBlueprint(DrawableHitObject drawableObject)
|
||||||
: base(hitObject)
|
: base(drawableObject)
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.None;
|
RelativeSizeAxes = Axes.None;
|
||||||
}
|
}
|
||||||
|
@ -2,13 +2,12 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Game.Rulesets.Mania.Objects.Drawables.Pieces;
|
using osu.Game.Rulesets.Mania.Objects.Drawables.Pieces;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Input.Bindings;
|
using osu.Framework.Input.Bindings;
|
||||||
|
using osu.Game.Rulesets.Objects;
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
using osu.Game.Rulesets.UI.Scrolling;
|
using osu.Game.Rulesets.UI.Scrolling;
|
||||||
@ -22,8 +21,12 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
|
|||||||
{
|
{
|
||||||
public override bool DisplayResult => false;
|
public override bool DisplayResult => false;
|
||||||
|
|
||||||
public readonly DrawableNote Head;
|
public DrawableNote Head => headContainer.Child;
|
||||||
public readonly DrawableNote Tail;
|
public DrawableNote Tail => tailContainer.Child;
|
||||||
|
|
||||||
|
private readonly Container<DrawableHeadNote> headContainer;
|
||||||
|
private readonly Container<DrawableTailNote> tailContainer;
|
||||||
|
private readonly Container<DrawableHoldNoteTick> tickContainer;
|
||||||
|
|
||||||
private readonly BodyPiece bodyPiece;
|
private readonly BodyPiece bodyPiece;
|
||||||
|
|
||||||
@ -40,50 +43,81 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
|
|||||||
public DrawableHoldNote(HoldNote hitObject)
|
public DrawableHoldNote(HoldNote hitObject)
|
||||||
: base(hitObject)
|
: base(hitObject)
|
||||||
{
|
{
|
||||||
Container<DrawableHoldNoteTick> tickContainer;
|
|
||||||
RelativeSizeAxes = Axes.X;
|
RelativeSizeAxes = Axes.X;
|
||||||
|
|
||||||
AddRangeInternal(new Drawable[]
|
AddRangeInternal(new Drawable[]
|
||||||
{
|
{
|
||||||
bodyPiece = new BodyPiece
|
bodyPiece = new BodyPiece { RelativeSizeAxes = Axes.X },
|
||||||
{
|
tickContainer = new Container<DrawableHoldNoteTick> { RelativeSizeAxes = Axes.Both },
|
||||||
RelativeSizeAxes = Axes.X,
|
headContainer = new Container<DrawableHeadNote> { RelativeSizeAxes = Axes.Both },
|
||||||
},
|
tailContainer = new Container<DrawableTailNote> { RelativeSizeAxes = Axes.Both },
|
||||||
tickContainer = new Container<DrawableHoldNoteTick>
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
ChildrenEnumerable = HitObject.NestedHitObjects.OfType<HoldNoteTick>().Select(tick => new DrawableHoldNoteTick(tick)
|
|
||||||
{
|
|
||||||
HoldStartTime = () => holdStartTime
|
|
||||||
})
|
|
||||||
},
|
|
||||||
Head = new DrawableHeadNote(this)
|
|
||||||
{
|
|
||||||
Anchor = Anchor.TopCentre,
|
|
||||||
Origin = Anchor.TopCentre
|
|
||||||
},
|
|
||||||
Tail = new DrawableTailNote(this)
|
|
||||||
{
|
|
||||||
Anchor = Anchor.TopCentre,
|
|
||||||
Origin = Anchor.TopCentre
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
foreach (var tick in tickContainer)
|
|
||||||
AddNested(tick);
|
|
||||||
|
|
||||||
AddNested(Head);
|
|
||||||
AddNested(Tail);
|
|
||||||
|
|
||||||
AccentColour.BindValueChanged(colour =>
|
AccentColour.BindValueChanged(colour =>
|
||||||
{
|
{
|
||||||
bodyPiece.AccentColour = colour.NewValue;
|
bodyPiece.AccentColour = colour.NewValue;
|
||||||
Head.AccentColour.Value = colour.NewValue;
|
|
||||||
Tail.AccentColour.Value = colour.NewValue;
|
|
||||||
tickContainer.ForEach(t => t.AccentColour.Value = colour.NewValue);
|
|
||||||
}, true);
|
}, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void AddNestedHitObject(DrawableHitObject hitObject)
|
||||||
|
{
|
||||||
|
base.AddNestedHitObject(hitObject);
|
||||||
|
|
||||||
|
switch (hitObject)
|
||||||
|
{
|
||||||
|
case DrawableHeadNote head:
|
||||||
|
headContainer.Child = head;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DrawableTailNote tail:
|
||||||
|
tailContainer.Child = tail;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DrawableHoldNoteTick tick:
|
||||||
|
tickContainer.Add(tick);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void ClearNestedHitObjects()
|
||||||
|
{
|
||||||
|
base.ClearNestedHitObjects();
|
||||||
|
headContainer.Clear();
|
||||||
|
tailContainer.Clear();
|
||||||
|
tickContainer.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override DrawableHitObject CreateNestedHitObject(HitObject hitObject)
|
||||||
|
{
|
||||||
|
switch (hitObject)
|
||||||
|
{
|
||||||
|
case TailNote _:
|
||||||
|
return new DrawableTailNote(this)
|
||||||
|
{
|
||||||
|
Anchor = Anchor.TopCentre,
|
||||||
|
Origin = Anchor.TopCentre,
|
||||||
|
AccentColour = { BindTarget = AccentColour }
|
||||||
|
};
|
||||||
|
|
||||||
|
case Note _:
|
||||||
|
return new DrawableHeadNote(this)
|
||||||
|
{
|
||||||
|
Anchor = Anchor.TopCentre,
|
||||||
|
Origin = Anchor.TopCentre,
|
||||||
|
AccentColour = { BindTarget = AccentColour }
|
||||||
|
};
|
||||||
|
|
||||||
|
case HoldNoteTick tick:
|
||||||
|
return new DrawableHoldNoteTick(tick)
|
||||||
|
{
|
||||||
|
HoldStartTime = () => holdStartTime,
|
||||||
|
AccentColour = { BindTarget = AccentColour }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return base.CreateNestedHitObject(hitObject);
|
||||||
|
}
|
||||||
|
|
||||||
protected override void OnDirectionChanged(ValueChangedEvent<ScrollingDirection> e)
|
protected override void OnDirectionChanged(ValueChangedEvent<ScrollingDirection> e)
|
||||||
{
|
{
|
||||||
base.OnDirectionChanged(e);
|
base.OnDirectionChanged(e);
|
||||||
|
@ -52,12 +52,19 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
AddAssert("blueprint positioned over hitobject", () => blueprint.CirclePiece.Position == hitCircle.Position);
|
AddAssert("blueprint positioned over hitobject", () => blueprint.CirclePiece.Position == hitCircle.Position);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestStackedHitObject()
|
||||||
|
{
|
||||||
|
AddStep("set stacking", () => hitCircle.StackHeight = 5);
|
||||||
|
AddAssert("blueprint positioned over hitobject", () => blueprint.CirclePiece.Position == hitCircle.StackedPosition);
|
||||||
|
}
|
||||||
|
|
||||||
private class TestBlueprint : HitCircleSelectionBlueprint
|
private class TestBlueprint : HitCircleSelectionBlueprint
|
||||||
{
|
{
|
||||||
public new HitCirclePiece CirclePiece => base.CirclePiece;
|
public new HitCirclePiece CirclePiece => base.CirclePiece;
|
||||||
|
|
||||||
public TestBlueprint(DrawableHitCircle hitCircle)
|
public TestBlueprint(DrawableHitCircle drawableCircle)
|
||||||
: base(hitCircle)
|
: base(drawableCircle)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
@ -10,10 +11,12 @@ using osu.Framework.Graphics.Shapes;
|
|||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
using osu.Framework.MathUtils;
|
using osu.Framework.MathUtils;
|
||||||
using osu.Game.Beatmaps.ControlPoints;
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
|
using osu.Game.Rulesets.Edit;
|
||||||
using osu.Game.Rulesets.Osu.Beatmaps;
|
using osu.Game.Rulesets.Osu.Beatmaps;
|
||||||
using osu.Game.Rulesets.Osu.Edit;
|
using osu.Game.Rulesets.Osu.Edit;
|
||||||
using osu.Game.Rulesets.Osu.Objects;
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
using osu.Game.Screens.Edit;
|
using osu.Game.Screens.Edit;
|
||||||
|
using osu.Game.Screens.Edit.Compose.Components;
|
||||||
using osu.Game.Tests.Visual;
|
using osu.Game.Tests.Visual;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
@ -25,32 +28,44 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
private const double beat_length = 100;
|
private const double beat_length = 100;
|
||||||
private static readonly Vector2 grid_position = new Vector2(512, 384);
|
private static readonly Vector2 grid_position = new Vector2(512, 384);
|
||||||
|
|
||||||
|
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||||
|
{
|
||||||
|
typeof(CircularDistanceSnapGrid)
|
||||||
|
};
|
||||||
|
|
||||||
[Cached(typeof(IEditorBeatmap))]
|
[Cached(typeof(IEditorBeatmap))]
|
||||||
private readonly EditorBeatmap<OsuHitObject> editorBeatmap;
|
private readonly EditorBeatmap<OsuHitObject> editorBeatmap;
|
||||||
|
|
||||||
[Cached]
|
[Cached]
|
||||||
private readonly BindableBeatDivisor beatDivisor = new BindableBeatDivisor();
|
private readonly BindableBeatDivisor beatDivisor = new BindableBeatDivisor();
|
||||||
|
|
||||||
private TestOsuDistanceSnapGrid grid;
|
[Cached(typeof(IDistanceSnapProvider))]
|
||||||
|
private readonly SnapProvider snapProvider = new SnapProvider();
|
||||||
|
|
||||||
|
private readonly TestOsuDistanceSnapGrid grid;
|
||||||
|
|
||||||
public TestSceneOsuDistanceSnapGrid()
|
public TestSceneOsuDistanceSnapGrid()
|
||||||
{
|
{
|
||||||
editorBeatmap = new EditorBeatmap<OsuHitObject>(new OsuBeatmap());
|
editorBeatmap = new EditorBeatmap<OsuHitObject>(new OsuBeatmap());
|
||||||
|
|
||||||
createGrid();
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Colour = Color4.SlateGray
|
||||||
|
},
|
||||||
|
grid = new TestOsuDistanceSnapGrid(new HitCircle { Position = grid_position }),
|
||||||
|
new SnappingCursorContainer { GetSnapPosition = v => grid.GetSnappedPosition(grid.ToLocalSpace(v)).position }
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public void Setup() => Schedule(() =>
|
public void Setup() => Schedule(() =>
|
||||||
{
|
{
|
||||||
Clear();
|
|
||||||
|
|
||||||
editorBeatmap.BeatmapInfo.BaseDifficulty.SliderMultiplier = 1;
|
editorBeatmap.BeatmapInfo.BaseDifficulty.SliderMultiplier = 1;
|
||||||
editorBeatmap.ControlPointInfo.DifficultyPoints.Clear();
|
editorBeatmap.ControlPointInfo.Clear();
|
||||||
editorBeatmap.ControlPointInfo.TimingPoints.Clear();
|
editorBeatmap.ControlPointInfo.Add(0, new TimingControlPoint { BeatLength = beat_length });
|
||||||
editorBeatmap.ControlPointInfo.TimingPoints.Add(new TimingControlPoint { BeatLength = beat_length });
|
|
||||||
|
|
||||||
beatDivisor.Value = 1;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
[TestCase(1)]
|
[TestCase(1)]
|
||||||
@ -64,53 +79,11 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
public void TestBeatDivisor(int divisor)
|
public void TestBeatDivisor(int divisor)
|
||||||
{
|
{
|
||||||
AddStep($"set beat divisor = {divisor}", () => beatDivisor.Value = divisor);
|
AddStep($"set beat divisor = {divisor}", () => beatDivisor.Value = divisor);
|
||||||
createGrid();
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestCase(100, 100)]
|
|
||||||
[TestCase(200, 100)]
|
|
||||||
public void TestBeatLength(float beatLength, float expectedSpacing)
|
|
||||||
{
|
|
||||||
AddStep($"set beat length = {beatLength}", () =>
|
|
||||||
{
|
|
||||||
editorBeatmap.ControlPointInfo.TimingPoints.Clear();
|
|
||||||
editorBeatmap.ControlPointInfo.TimingPoints.Add(new TimingControlPoint { BeatLength = beatLength });
|
|
||||||
});
|
|
||||||
|
|
||||||
createGrid();
|
|
||||||
AddAssert($"spacing = {expectedSpacing}", () => Precision.AlmostEquals(expectedSpacing, grid.DistanceSpacing));
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestCase(0.5f, 50)]
|
|
||||||
[TestCase(1, 100)]
|
|
||||||
[TestCase(1.5f, 150)]
|
|
||||||
public void TestSpeedMultiplier(float multiplier, float expectedSpacing)
|
|
||||||
{
|
|
||||||
AddStep($"set speed multiplier = {multiplier}", () =>
|
|
||||||
{
|
|
||||||
editorBeatmap.ControlPointInfo.DifficultyPoints.Clear();
|
|
||||||
editorBeatmap.ControlPointInfo.DifficultyPoints.Add(new DifficultyControlPoint { SpeedMultiplier = multiplier });
|
|
||||||
});
|
|
||||||
|
|
||||||
createGrid();
|
|
||||||
AddAssert($"spacing = {expectedSpacing}", () => Precision.AlmostEquals(expectedSpacing, grid.DistanceSpacing));
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestCase(0.5f, 50)]
|
|
||||||
[TestCase(1, 100)]
|
|
||||||
[TestCase(1.5f, 150)]
|
|
||||||
public void TestSliderMultiplier(float multiplier, float expectedSpacing)
|
|
||||||
{
|
|
||||||
AddStep($"set speed multiplier = {multiplier}", () => editorBeatmap.BeatmapInfo.BaseDifficulty.SliderMultiplier = multiplier);
|
|
||||||
createGrid();
|
|
||||||
AddAssert($"spacing = {expectedSpacing}", () => Precision.AlmostEquals(expectedSpacing, grid.DistanceSpacing));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestCursorInCentre()
|
public void TestCursorInCentre()
|
||||||
{
|
{
|
||||||
createGrid();
|
|
||||||
|
|
||||||
AddStep("move mouse to centre", () => InputManager.MoveMouseTo(grid.ToScreenSpace(grid_position)));
|
AddStep("move mouse to centre", () => InputManager.MoveMouseTo(grid.ToScreenSpace(grid_position)));
|
||||||
assertSnappedDistance((float)beat_length);
|
assertSnappedDistance((float)beat_length);
|
||||||
}
|
}
|
||||||
@ -118,8 +91,6 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestCursorBeforeMovementPoint()
|
public void TestCursorBeforeMovementPoint()
|
||||||
{
|
{
|
||||||
createGrid();
|
|
||||||
|
|
||||||
AddStep("move mouse to just before movement point", () => InputManager.MoveMouseTo(grid.ToScreenSpace(grid_position + new Vector2((float)beat_length, 0) * 1.49f)));
|
AddStep("move mouse to just before movement point", () => InputManager.MoveMouseTo(grid.ToScreenSpace(grid_position + new Vector2((float)beat_length, 0) * 1.49f)));
|
||||||
assertSnappedDistance((float)beat_length);
|
assertSnappedDistance((float)beat_length);
|
||||||
}
|
}
|
||||||
@ -127,37 +98,17 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestCursorAfterMovementPoint()
|
public void TestCursorAfterMovementPoint()
|
||||||
{
|
{
|
||||||
createGrid();
|
|
||||||
|
|
||||||
AddStep("move mouse to just after movement point", () => InputManager.MoveMouseTo(grid.ToScreenSpace(grid_position + new Vector2((float)beat_length, 0) * 1.51f)));
|
AddStep("move mouse to just after movement point", () => InputManager.MoveMouseTo(grid.ToScreenSpace(grid_position + new Vector2((float)beat_length, 0) * 1.51f)));
|
||||||
assertSnappedDistance((float)beat_length * 2);
|
assertSnappedDistance((float)beat_length * 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertSnappedDistance(float expectedDistance) => AddAssert($"snap distance = {expectedDistance}", () =>
|
private void assertSnappedDistance(float expectedDistance) => AddAssert($"snap distance = {expectedDistance}", () =>
|
||||||
{
|
{
|
||||||
Vector2 snappedPosition = grid.GetSnapPosition(grid.ToLocalSpace(InputManager.CurrentState.Mouse.Position));
|
Vector2 snappedPosition = grid.GetSnappedPosition(grid.ToLocalSpace(InputManager.CurrentState.Mouse.Position)).position;
|
||||||
float distance = Vector2.Distance(snappedPosition, grid_position);
|
|
||||||
|
|
||||||
return Precision.AlmostEquals(expectedDistance, distance);
|
return Precision.AlmostEquals(expectedDistance, Vector2.Distance(snappedPosition, grid_position));
|
||||||
});
|
});
|
||||||
|
|
||||||
private void createGrid()
|
|
||||||
{
|
|
||||||
AddStep("create grid", () =>
|
|
||||||
{
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
new Box
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Colour = Color4.SlateGray
|
|
||||||
},
|
|
||||||
grid = new TestOsuDistanceSnapGrid(new HitCircle { Position = grid_position }),
|
|
||||||
new SnappingCursorContainer { GetSnapPosition = v => grid.GetSnapPosition(grid.ToLocalSpace(v)) }
|
|
||||||
};
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private class SnappingCursorContainer : CompositeDrawable
|
private class SnappingCursorContainer : CompositeDrawable
|
||||||
{
|
{
|
||||||
public Func<Vector2, Vector2> GetSnapPosition;
|
public Func<Vector2, Vector2> GetSnapPosition;
|
||||||
@ -206,5 +157,20 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class SnapProvider : IDistanceSnapProvider
|
||||||
|
{
|
||||||
|
public (Vector2 position, double time) GetSnappedPosition(Vector2 position, double time) => (position, time);
|
||||||
|
|
||||||
|
public float GetBeatSnapDistanceAt(double referenceTime) => (float)beat_length;
|
||||||
|
|
||||||
|
public float DurationToDistance(double referenceTime, double duration) => 0;
|
||||||
|
|
||||||
|
public double DistanceToDuration(double referenceTime, float distance) => 0;
|
||||||
|
|
||||||
|
public double GetSnappedDurationFromDistance(double referenceTime, float distance) => 0;
|
||||||
|
|
||||||
|
public float GetSnappedDistanceFromDistance(double referenceTime, float distance) => 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,6 +111,21 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
AddStep("Distance Overflow 1 Repeat", () => SetContents(() => testDistanceOverflow(1)));
|
AddStep("Distance Overflow 1 Repeat", () => SetContents(() => testDistanceOverflow(1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestChangeStackHeight()
|
||||||
|
{
|
||||||
|
DrawableSlider slider = null;
|
||||||
|
|
||||||
|
AddStep("create slider", () =>
|
||||||
|
{
|
||||||
|
slider = (DrawableSlider)createSlider(repeats: 1);
|
||||||
|
Add(slider);
|
||||||
|
});
|
||||||
|
|
||||||
|
AddStep("change stack height", () => slider.HitObject.StackHeight = 10);
|
||||||
|
AddAssert("body positioned correctly", () => slider.Position == slider.HitObject.StackedPosition);
|
||||||
|
}
|
||||||
|
|
||||||
private Drawable testSimpleBig(int repeats = 0) => createSlider(2, repeats: repeats);
|
private Drawable testSimpleBig(int repeats = 0) => createSlider(2, repeats: repeats);
|
||||||
|
|
||||||
private Drawable testSimpleBigLargeStackOffset(int repeats = 0) => createSlider(2, repeats: repeats, stackHeight: 10);
|
private Drawable testSimpleBigLargeStackOffset(int repeats = 0) => createSlider(2, repeats: repeats, stackHeight: 10);
|
||||||
@ -293,7 +308,7 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
private Drawable createDrawable(Slider slider, float circleSize, double speedMultiplier)
|
private Drawable createDrawable(Slider slider, float circleSize, double speedMultiplier)
|
||||||
{
|
{
|
||||||
var cpi = new ControlPointInfo();
|
var cpi = new ControlPointInfo();
|
||||||
cpi.DifficultyPoints.Add(new DifficultyControlPoint { SpeedMultiplier = speedMultiplier });
|
cpi.Add(0, new DifficultyControlPoint { SpeedMultiplier = speedMultiplier });
|
||||||
|
|
||||||
slider.ApplyDefaults(cpi, new BeatmapDifficulty { CircleSize = circleSize, SliderTickRate = 3 });
|
slider.ApplyDefaults(cpi, new BeatmapDifficulty { CircleSize = circleSize, SliderTickRate = 3 });
|
||||||
|
|
||||||
|
@ -313,10 +313,6 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
}, 25),
|
}, 25),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ControlPointInfo =
|
|
||||||
{
|
|
||||||
DifficultyPoints = { new DifficultyControlPoint { SpeedMultiplier = 0.1f } }
|
|
||||||
},
|
|
||||||
BeatmapInfo =
|
BeatmapInfo =
|
||||||
{
|
{
|
||||||
BaseDifficulty = new BeatmapDifficulty { SliderTickRate = 3 },
|
BaseDifficulty = new BeatmapDifficulty { SliderTickRate = 3 },
|
||||||
@ -324,6 +320,8 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Beatmap.Value.Beatmap.ControlPointInfo.Add(0, new DifficultyControlPoint { SpeedMultiplier = 0.1f });
|
||||||
|
|
||||||
var p = new ScoreAccessibleReplayPlayer(new Score { Replay = new Replay { Frames = frames } });
|
var p = new ScoreAccessibleReplayPlayer(new Score { Replay = new Replay { Frames = frames } });
|
||||||
|
|
||||||
p.OnLoadComplete += _ =>
|
p.OnLoadComplete += _ =>
|
||||||
|
@ -78,6 +78,13 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
checkPositions();
|
checkPositions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestStackedHitObject()
|
||||||
|
{
|
||||||
|
AddStep("set stacking", () => slider.StackHeight = 5);
|
||||||
|
checkPositions();
|
||||||
|
}
|
||||||
|
|
||||||
private void moveHitObject()
|
private void moveHitObject()
|
||||||
{
|
{
|
||||||
AddStep("move hitobject", () =>
|
AddStep("move hitobject", () =>
|
||||||
@ -88,7 +95,7 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
|
|
||||||
private void checkPositions()
|
private void checkPositions()
|
||||||
{
|
{
|
||||||
AddAssert("body positioned correctly", () => blueprint.BodyPiece.Position == slider.Position);
|
AddAssert("body positioned correctly", () => blueprint.BodyPiece.Position == slider.StackedPosition);
|
||||||
|
|
||||||
AddAssert("head positioned correctly",
|
AddAssert("head positioned correctly",
|
||||||
() => Precision.AlmostEquals(blueprint.HeadBlueprint.CirclePiece.ScreenSpaceDrawQuad.Centre, drawableObject.HeadCircle.ScreenSpaceDrawQuad.Centre));
|
() => Precision.AlmostEquals(blueprint.HeadBlueprint.CirclePiece.ScreenSpaceDrawQuad.Centre, drawableObject.HeadCircle.ScreenSpaceDrawQuad.Centre));
|
||||||
|
@ -19,7 +19,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints
|
|||||||
/// <param name="hitObject">The <see cref="OsuHitObject"/> to reference properties from.</param>
|
/// <param name="hitObject">The <see cref="OsuHitObject"/> to reference properties from.</param>
|
||||||
public virtual void UpdateFrom(T hitObject)
|
public virtual void UpdateFrom(T hitObject)
|
||||||
{
|
{
|
||||||
Position = hitObject.Position;
|
Position = hitObject.StackedPosition;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,22 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using osu.Framework.Graphics.Primitives;
|
||||||
using osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles.Components;
|
using osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles.Components;
|
||||||
using osu.Game.Rulesets.Osu.Objects;
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
||||||
|
using osuTK;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles
|
namespace osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles
|
||||||
{
|
{
|
||||||
public class HitCircleSelectionBlueprint : OsuSelectionBlueprint<HitCircle>
|
public class HitCircleSelectionBlueprint : OsuSelectionBlueprint<HitCircle>
|
||||||
{
|
{
|
||||||
|
protected new DrawableHitCircle DrawableObject => (DrawableHitCircle)base.DrawableObject;
|
||||||
|
|
||||||
protected readonly HitCirclePiece CirclePiece;
|
protected readonly HitCirclePiece CirclePiece;
|
||||||
|
|
||||||
public HitCircleSelectionBlueprint(DrawableHitCircle hitCircle)
|
public HitCircleSelectionBlueprint(DrawableHitCircle drawableCircle)
|
||||||
: base(hitCircle)
|
: base(drawableCircle)
|
||||||
{
|
{
|
||||||
InternalChild = CirclePiece = new HitCirclePiece();
|
InternalChild = CirclePiece = new HitCirclePiece();
|
||||||
}
|
}
|
||||||
@ -23,5 +27,9 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles
|
|||||||
|
|
||||||
CirclePiece.UpdateFrom(HitObject);
|
CirclePiece.UpdateFrom(HitObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => DrawableObject.HitArea.ReceivePositionalInputAt(screenSpacePos);
|
||||||
|
|
||||||
|
public override Quad SelectionQuad => DrawableObject.HitArea.ScreenSpaceDrawQuad;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,10 +10,10 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints
|
|||||||
public abstract class OsuSelectionBlueprint<T> : SelectionBlueprint
|
public abstract class OsuSelectionBlueprint<T> : SelectionBlueprint
|
||||||
where T : OsuHitObject
|
where T : OsuHitObject
|
||||||
{
|
{
|
||||||
protected new T HitObject => (T)base.HitObject.HitObject;
|
protected T HitObject => (T)DrawableObject.HitObject;
|
||||||
|
|
||||||
protected OsuSelectionBlueprint(DrawableHitObject hitObject)
|
protected OsuSelectionBlueprint(DrawableHitObject drawableObject)
|
||||||
: base(hitObject)
|
: base(drawableObject)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
@ -8,7 +9,6 @@ using osu.Framework.Graphics.Lines;
|
|||||||
using osu.Framework.Graphics.Shapes;
|
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.Objects;
|
|
||||||
using osu.Game.Rulesets.Osu.Objects;
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
|
||||||
@ -16,6 +16,8 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
|||||||
{
|
{
|
||||||
public class PathControlPointPiece : BlueprintPiece<Slider>
|
public class PathControlPointPiece : BlueprintPiece<Slider>
|
||||||
{
|
{
|
||||||
|
public Action<Vector2[]> ControlPointsChanged;
|
||||||
|
|
||||||
private readonly Slider slider;
|
private readonly Slider slider;
|
||||||
private readonly int index;
|
private readonly int index;
|
||||||
|
|
||||||
@ -96,7 +98,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
|||||||
if (isSegmentSeparatorWithPrevious)
|
if (isSegmentSeparatorWithPrevious)
|
||||||
newControlPoints[index - 1] = newControlPoints[index];
|
newControlPoints[index - 1] = newControlPoints[index];
|
||||||
|
|
||||||
slider.Path = new SliderPath(slider.Path.Type, newControlPoints);
|
ControlPointsChanged?.Invoke(newControlPoints);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,18 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Game.Rulesets.Osu.Objects;
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
|
using osuTK;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
||||||
{
|
{
|
||||||
public class PathControlPointVisualiser : CompositeDrawable
|
public class PathControlPointVisualiser : CompositeDrawable
|
||||||
{
|
{
|
||||||
|
public Action<Vector2[]> ControlPointsChanged;
|
||||||
|
|
||||||
private readonly Slider slider;
|
private readonly Slider slider;
|
||||||
|
|
||||||
private readonly Container<PathControlPointPiece> pieces;
|
private readonly Container<PathControlPointPiece> pieces;
|
||||||
@ -25,7 +29,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
|||||||
base.Update();
|
base.Update();
|
||||||
|
|
||||||
while (slider.Path.ControlPoints.Length > pieces.Count)
|
while (slider.Path.ControlPoints.Length > pieces.Count)
|
||||||
pieces.Add(new PathControlPointPiece(slider, pieces.Count));
|
pieces.Add(new PathControlPointPiece(slider, pieces.Count) { ControlPointsChanged = c => ControlPointsChanged?.Invoke(c) });
|
||||||
while (slider.Path.ControlPoints.Length < pieces.Count)
|
while (slider.Path.ControlPoints.Length < pieces.Count)
|
||||||
pieces.Remove(pieces[pieces.Count - 1]);
|
pieces.Remove(pieces[pieces.Count - 1]);
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ using System.Linq;
|
|||||||
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;
|
||||||
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;
|
||||||
@ -28,9 +29,13 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
|
|||||||
|
|
||||||
private readonly List<Segment> segments = new List<Segment>();
|
private readonly List<Segment> segments = new List<Segment>();
|
||||||
private Vector2 cursor;
|
private Vector2 cursor;
|
||||||
|
private InputManager inputManager;
|
||||||
|
|
||||||
private PlacementState state;
|
private PlacementState state;
|
||||||
|
|
||||||
|
[Resolved(CanBeNull = true)]
|
||||||
|
private HitObjectComposer composer { get; set; }
|
||||||
|
|
||||||
public SliderPlacementBlueprint()
|
public SliderPlacementBlueprint()
|
||||||
: base(new Objects.Slider())
|
: base(new Objects.Slider())
|
||||||
{
|
{
|
||||||
@ -46,12 +51,18 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
|
|||||||
bodyPiece = new SliderBodyPiece(),
|
bodyPiece = new SliderBodyPiece(),
|
||||||
headCirclePiece = new HitCirclePiece(),
|
headCirclePiece = new HitCirclePiece(),
|
||||||
tailCirclePiece = new HitCirclePiece(),
|
tailCirclePiece = new HitCirclePiece(),
|
||||||
new PathControlPointVisualiser(HitObject),
|
new PathControlPointVisualiser(HitObject) { ControlPointsChanged = _ => updateSlider() },
|
||||||
};
|
};
|
||||||
|
|
||||||
setState(PlacementState.Initial);
|
setState(PlacementState.Initial);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
inputManager = GetContainingInputManager();
|
||||||
|
}
|
||||||
|
|
||||||
public override void UpdatePosition(Vector2 screenSpacePosition)
|
public override void UpdatePosition(Vector2 screenSpacePosition)
|
||||||
{
|
{
|
||||||
switch (state)
|
switch (state)
|
||||||
@ -61,7 +72,9 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case PlacementState.Body:
|
case PlacementState.Body:
|
||||||
cursor = ToLocalSpace(screenSpacePosition) - HitObject.Position;
|
// The given screen-space position may have been externally snapped, but the unsnapped position from the input manager
|
||||||
|
// is used instead since snapping control points doesn't make much sense
|
||||||
|
cursor = ToLocalSpace(inputManager.CurrentState.Mouse.Position) - HitObject.Position;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -121,8 +134,12 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
|
|||||||
|
|
||||||
private void updateSlider()
|
private void updateSlider()
|
||||||
{
|
{
|
||||||
var newControlPoints = segments.SelectMany(s => s.ControlPoints).Concat(cursor.Yield()).ToArray();
|
Vector2[] newControlPoints = segments.SelectMany(s => s.ControlPoints).Concat(cursor.Yield()).ToArray();
|
||||||
HitObject.Path = new SliderPath(newControlPoints.Length > 2 ? PathType.Bezier : PathType.Linear, newControlPoints);
|
|
||||||
|
var unsnappedPath = new SliderPath(newControlPoints.Length > 2 ? PathType.Bezier : PathType.Linear, newControlPoints);
|
||||||
|
var snappedDistance = composer?.GetSnappedDistanceFromDistance(HitObject.StartTime, (float)unsnappedPath.Distance) ?? (float)unsnappedPath.Distance;
|
||||||
|
|
||||||
|
HitObject.Path = new SliderPath(unsnappedPath.Type, newControlPoints, snappedDistance);
|
||||||
|
|
||||||
bodyPiece.UpdateFrom(HitObject);
|
bodyPiece.UpdateFrom(HitObject);
|
||||||
headCirclePiece.UpdateFrom(HitObject.HeadCircle);
|
headCirclePiece.UpdateFrom(HitObject.HeadCircle);
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Game.Rulesets.Edit;
|
||||||
|
using osu.Game.Rulesets.Objects;
|
||||||
|
using osu.Game.Rulesets.Objects.Types;
|
||||||
using osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components;
|
using osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components;
|
||||||
using osu.Game.Rulesets.Osu.Objects;
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
||||||
@ -15,6 +19,9 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
|
|||||||
protected readonly SliderCircleSelectionBlueprint HeadBlueprint;
|
protected readonly SliderCircleSelectionBlueprint HeadBlueprint;
|
||||||
protected readonly SliderCircleSelectionBlueprint TailBlueprint;
|
protected readonly SliderCircleSelectionBlueprint TailBlueprint;
|
||||||
|
|
||||||
|
[Resolved(CanBeNull = true)]
|
||||||
|
private HitObjectComposer composer { get; set; }
|
||||||
|
|
||||||
public SliderSelectionBlueprint(DrawableSlider slider)
|
public SliderSelectionBlueprint(DrawableSlider slider)
|
||||||
: base(slider)
|
: base(slider)
|
||||||
{
|
{
|
||||||
@ -25,7 +32,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
|
|||||||
BodyPiece = new SliderBodyPiece(),
|
BodyPiece = new SliderBodyPiece(),
|
||||||
HeadBlueprint = CreateCircleSelectionBlueprint(slider, SliderPosition.Start),
|
HeadBlueprint = CreateCircleSelectionBlueprint(slider, SliderPosition.Start),
|
||||||
TailBlueprint = CreateCircleSelectionBlueprint(slider, SliderPosition.End),
|
TailBlueprint = CreateCircleSelectionBlueprint(slider, SliderPosition.End),
|
||||||
new PathControlPointVisualiser(sliderObject),
|
new PathControlPointVisualiser(sliderObject) { ControlPointsChanged = onNewControlPoints },
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,8 +43,18 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
|
|||||||
BodyPiece.UpdateFrom(HitObject);
|
BodyPiece.UpdateFrom(HitObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void onNewControlPoints(Vector2[] controlPoints)
|
||||||
|
{
|
||||||
|
var unsnappedPath = new SliderPath(controlPoints.Length > 2 ? PathType.Bezier : PathType.Linear, controlPoints);
|
||||||
|
var snappedDistance = composer?.GetSnappedDistanceFromDistance(HitObject.StartTime, (float)unsnappedPath.Distance) ?? (float)unsnappedPath.Distance;
|
||||||
|
|
||||||
|
HitObject.Path = new SliderPath(unsnappedPath.Type, controlPoints, snappedDistance);
|
||||||
|
}
|
||||||
|
|
||||||
public override Vector2 SelectionPoint => HeadBlueprint.SelectionPoint;
|
public override Vector2 SelectionPoint => HeadBlueprint.SelectionPoint;
|
||||||
|
|
||||||
|
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => BodyPiece.ReceivePositionalInputAt(screenSpacePos);
|
||||||
|
|
||||||
protected virtual SliderCircleSelectionBlueprint CreateCircleSelectionBlueprint(DrawableSlider slider, SliderPosition position) => new SliderCircleSelectionBlueprint(slider, position);
|
protected virtual SliderCircleSelectionBlueprint CreateCircleSelectionBlueprint(DrawableSlider slider, SliderPosition position) => new SliderCircleSelectionBlueprint(slider, position);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using osu.Game.Beatmaps;
|
|
||||||
using osu.Game.Beatmaps.ControlPoints;
|
|
||||||
using osu.Game.Rulesets.Osu.Objects;
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
using osu.Game.Screens.Edit.Compose.Components;
|
using osu.Game.Screens.Edit.Compose.Components;
|
||||||
|
|
||||||
@ -13,16 +11,7 @@ namespace osu.Game.Rulesets.Osu.Edit
|
|||||||
public OsuDistanceSnapGrid(OsuHitObject hitObject)
|
public OsuDistanceSnapGrid(OsuHitObject hitObject)
|
||||||
: base(hitObject, hitObject.StackedEndPosition)
|
: base(hitObject, hitObject.StackedEndPosition)
|
||||||
{
|
{
|
||||||
}
|
Masking = true;
|
||||||
|
|
||||||
protected override float GetVelocity(double time, ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
|
|
||||||
{
|
|
||||||
TimingControlPoint timingPoint = controlPointInfo.TimingPointAt(time);
|
|
||||||
DifficultyControlPoint difficultyPoint = controlPointInfo.DifficultyPointAt(time);
|
|
||||||
|
|
||||||
double scoringDistance = OsuHitObject.BASE_SCORING_DISTANCE * difficulty.SliderMultiplier * difficultyPoint.SpeedMultiplier;
|
|
||||||
|
|
||||||
return (float)(scoringDistance / timingPoint.BeatLength);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,10 +2,12 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Rulesets.Edit;
|
using osu.Game.Rulesets.Edit;
|
||||||
using osu.Game.Rulesets.Edit.Tools;
|
using osu.Game.Rulesets.Edit.Tools;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
|
using osu.Game.Rulesets.Objects;
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
using osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles;
|
using osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles;
|
||||||
using osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders;
|
using osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders;
|
||||||
@ -52,5 +54,31 @@ namespace osu.Game.Rulesets.Osu.Edit
|
|||||||
|
|
||||||
return base.CreateBlueprintFor(hitObject);
|
return base.CreateBlueprintFor(hitObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override DistanceSnapGrid CreateDistanceSnapGrid(IEnumerable<HitObject> selectedHitObjects)
|
||||||
|
{
|
||||||
|
var objects = selectedHitObjects.ToList();
|
||||||
|
|
||||||
|
if (objects.Count == 0)
|
||||||
|
{
|
||||||
|
var lastObject = EditorBeatmap.HitObjects.LastOrDefault(h => h.StartTime <= EditorClock.CurrentTime);
|
||||||
|
|
||||||
|
if (lastObject == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return new OsuDistanceSnapGrid(lastObject);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
double minTime = objects.Min(h => h.StartTime);
|
||||||
|
|
||||||
|
var lastObject = EditorBeatmap.HitObjects.LastOrDefault(h => h.StartTime < minTime);
|
||||||
|
|
||||||
|
if (lastObject == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return new OsuDistanceSnapGrid(lastObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,14 +24,12 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
private readonly IBindable<int> stackHeightBindable = new Bindable<int>();
|
private readonly IBindable<int> stackHeightBindable = new Bindable<int>();
|
||||||
private readonly IBindable<float> scaleBindable = new Bindable<float>();
|
private readonly IBindable<float> scaleBindable = new Bindable<float>();
|
||||||
|
|
||||||
public OsuAction? HitAction => hitArea.HitAction;
|
public OsuAction? HitAction => HitArea.HitAction;
|
||||||
|
|
||||||
|
public readonly HitReceptor HitArea;
|
||||||
|
public readonly SkinnableDrawable CirclePiece;
|
||||||
private readonly Container scaleContainer;
|
private readonly Container scaleContainer;
|
||||||
|
|
||||||
private readonly HitArea hitArea;
|
|
||||||
|
|
||||||
public SkinnableDrawable CirclePiece { get; }
|
|
||||||
|
|
||||||
public DrawableHitCircle(HitCircle h)
|
public DrawableHitCircle(HitCircle h)
|
||||||
: base(h)
|
: base(h)
|
||||||
{
|
{
|
||||||
@ -48,7 +46,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
hitArea = new HitArea
|
HitArea = new HitReceptor
|
||||||
{
|
{
|
||||||
Hit = () =>
|
Hit = () =>
|
||||||
{
|
{
|
||||||
@ -69,7 +67,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
Size = hitArea.DrawSize;
|
Size = HitArea.DrawSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
@ -153,7 +151,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
|
|
||||||
Expire(true);
|
Expire(true);
|
||||||
|
|
||||||
hitArea.HitAction = null;
|
HitArea.HitAction = null;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ArmedState.Miss:
|
case ArmedState.Miss:
|
||||||
@ -172,7 +170,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
|
|
||||||
public Drawable ProxiedLayer => ApproachCircle;
|
public Drawable ProxiedLayer => ApproachCircle;
|
||||||
|
|
||||||
private class HitArea : Drawable, IKeyBindingHandler<OsuAction>
|
public class HitReceptor : Drawable, IKeyBindingHandler<OsuAction>
|
||||||
{
|
{
|
||||||
// IsHovered is used
|
// IsHovered is used
|
||||||
public override bool HandlePositionalInput => true;
|
public override bool HandlePositionalInput => true;
|
||||||
@ -181,7 +179,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
|
|
||||||
public OsuAction? HitAction;
|
public OsuAction? HitAction;
|
||||||
|
|
||||||
public HitArea()
|
public HitReceptor()
|
||||||
{
|
{
|
||||||
Size = new Vector2(OsuHitObject.OBJECT_RADIUS * 2);
|
Size = new Vector2(OsuHitObject.OBJECT_RADIUS * 2);
|
||||||
|
|
||||||
|
@ -5,7 +5,6 @@ using osuTK;
|
|||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces;
|
using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
@ -21,16 +20,21 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
{
|
{
|
||||||
public class DrawableSlider : DrawableOsuHitObject, IDrawableHitObjectWithProxiedApproach
|
public class DrawableSlider : DrawableOsuHitObject, IDrawableHitObjectWithProxiedApproach
|
||||||
{
|
{
|
||||||
private readonly Slider slider;
|
public DrawableSliderHead HeadCircle => headContainer.Child;
|
||||||
private readonly List<Drawable> components = new List<Drawable>();
|
public DrawableSliderTail TailCircle => tailContainer.Child;
|
||||||
|
|
||||||
public readonly DrawableHitCircle HeadCircle;
|
|
||||||
public readonly DrawableSliderTail TailCircle;
|
|
||||||
|
|
||||||
public readonly SnakingSliderBody Body;
|
public readonly SnakingSliderBody Body;
|
||||||
public readonly SliderBall Ball;
|
public readonly SliderBall Ball;
|
||||||
|
|
||||||
|
private readonly Container<DrawableSliderHead> headContainer;
|
||||||
|
private readonly Container<DrawableSliderTail> tailContainer;
|
||||||
|
private readonly Container<DrawableSliderTick> tickContainer;
|
||||||
|
private readonly Container<DrawableRepeatPoint> repeatContainer;
|
||||||
|
|
||||||
|
private readonly Slider slider;
|
||||||
|
|
||||||
private readonly IBindable<Vector2> positionBindable = new Bindable<Vector2>();
|
private readonly IBindable<Vector2> positionBindable = new Bindable<Vector2>();
|
||||||
|
private readonly IBindable<int> stackHeightBindable = new Bindable<int>();
|
||||||
private readonly IBindable<float> scaleBindable = new Bindable<float>();
|
private readonly IBindable<float> scaleBindable = new Bindable<float>();
|
||||||
private readonly IBindable<SliderPath> pathBindable = new Bindable<SliderPath>();
|
private readonly IBindable<SliderPath> pathBindable = new Bindable<SliderPath>();
|
||||||
|
|
||||||
@ -44,14 +48,11 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
|
|
||||||
Position = s.StackedPosition;
|
Position = s.StackedPosition;
|
||||||
|
|
||||||
Container<DrawableSliderTick> ticks;
|
|
||||||
Container<DrawableRepeatPoint> repeatPoints;
|
|
||||||
|
|
||||||
InternalChildren = new Drawable[]
|
InternalChildren = new Drawable[]
|
||||||
{
|
{
|
||||||
Body = new SnakingSliderBody(s),
|
Body = new SnakingSliderBody(s),
|
||||||
ticks = new Container<DrawableSliderTick> { RelativeSizeAxes = Axes.Both },
|
tickContainer = new Container<DrawableSliderTick> { RelativeSizeAxes = Axes.Both },
|
||||||
repeatPoints = new Container<DrawableRepeatPoint> { RelativeSizeAxes = Axes.Both },
|
repeatContainer = new Container<DrawableRepeatPoint> { RelativeSizeAxes = Axes.Both },
|
||||||
Ball = new SliderBall(s, this)
|
Ball = new SliderBall(s, this)
|
||||||
{
|
{
|
||||||
GetInitialHitAction = () => HeadCircle.HitAction,
|
GetInitialHitAction = () => HeadCircle.HitAction,
|
||||||
@ -60,45 +61,9 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
AlwaysPresent = true,
|
AlwaysPresent = true,
|
||||||
Alpha = 0
|
Alpha = 0
|
||||||
},
|
},
|
||||||
HeadCircle = new DrawableSliderHead(s, s.HeadCircle)
|
headContainer = new Container<DrawableSliderHead> { RelativeSizeAxes = Axes.Both },
|
||||||
{
|
tailContainer = new Container<DrawableSliderTail> { RelativeSizeAxes = Axes.Both },
|
||||||
OnShake = Shake
|
|
||||||
},
|
|
||||||
TailCircle = new DrawableSliderTail(s, s.TailCircle)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
components.Add(Body);
|
|
||||||
components.Add(Ball);
|
|
||||||
|
|
||||||
AddNested(HeadCircle);
|
|
||||||
|
|
||||||
AddNested(TailCircle);
|
|
||||||
components.Add(TailCircle);
|
|
||||||
|
|
||||||
foreach (var tick in s.NestedHitObjects.OfType<SliderTick>())
|
|
||||||
{
|
|
||||||
var drawableTick = new DrawableSliderTick(tick) { Position = tick.Position - s.Position };
|
|
||||||
|
|
||||||
ticks.Add(drawableTick);
|
|
||||||
components.Add(drawableTick);
|
|
||||||
AddNested(drawableTick);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var repeatPoint in s.NestedHitObjects.OfType<RepeatPoint>())
|
|
||||||
{
|
|
||||||
var drawableRepeatPoint = new DrawableRepeatPoint(repeatPoint, this) { Position = repeatPoint.Position - s.Position };
|
|
||||||
|
|
||||||
repeatPoints.Add(drawableRepeatPoint);
|
|
||||||
components.Add(drawableRepeatPoint);
|
|
||||||
AddNested(drawableRepeatPoint);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void UpdateInitialTransforms()
|
|
||||||
{
|
|
||||||
base.UpdateInitialTransforms();
|
|
||||||
|
|
||||||
Body.FadeInFromZero(HitObject.TimeFadeIn);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
@ -108,6 +73,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
config?.BindWith(OsuRulesetSetting.SnakingOutSliders, Body.SnakingOut);
|
config?.BindWith(OsuRulesetSetting.SnakingOutSliders, Body.SnakingOut);
|
||||||
|
|
||||||
positionBindable.BindValueChanged(_ => Position = HitObject.StackedPosition);
|
positionBindable.BindValueChanged(_ => Position = HitObject.StackedPosition);
|
||||||
|
stackHeightBindable.BindValueChanged(_ => Position = HitObject.StackedPosition);
|
||||||
scaleBindable.BindValueChanged(scale =>
|
scaleBindable.BindValueChanged(scale =>
|
||||||
{
|
{
|
||||||
updatePathRadius();
|
updatePathRadius();
|
||||||
@ -115,6 +81,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
});
|
});
|
||||||
|
|
||||||
positionBindable.BindTo(HitObject.PositionBindable);
|
positionBindable.BindTo(HitObject.PositionBindable);
|
||||||
|
stackHeightBindable.BindTo(HitObject.StackHeightBindable);
|
||||||
scaleBindable.BindTo(HitObject.ScaleBindable);
|
scaleBindable.BindTo(HitObject.ScaleBindable);
|
||||||
pathBindable.BindTo(slider.PathBindable);
|
pathBindable.BindTo(slider.PathBindable);
|
||||||
|
|
||||||
@ -129,6 +96,67 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
}, true);
|
}, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void AddNestedHitObject(DrawableHitObject hitObject)
|
||||||
|
{
|
||||||
|
base.AddNestedHitObject(hitObject);
|
||||||
|
|
||||||
|
switch (hitObject)
|
||||||
|
{
|
||||||
|
case DrawableSliderHead head:
|
||||||
|
headContainer.Child = head;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DrawableSliderTail tail:
|
||||||
|
tailContainer.Child = tail;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DrawableSliderTick tick:
|
||||||
|
tickContainer.Add(tick);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DrawableRepeatPoint repeat:
|
||||||
|
repeatContainer.Add(repeat);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void ClearNestedHitObjects()
|
||||||
|
{
|
||||||
|
base.ClearNestedHitObjects();
|
||||||
|
|
||||||
|
headContainer.Clear();
|
||||||
|
tailContainer.Clear();
|
||||||
|
repeatContainer.Clear();
|
||||||
|
tickContainer.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override DrawableHitObject CreateNestedHitObject(HitObject hitObject)
|
||||||
|
{
|
||||||
|
switch (hitObject)
|
||||||
|
{
|
||||||
|
case SliderTailCircle tail:
|
||||||
|
return new DrawableSliderTail(slider, tail);
|
||||||
|
|
||||||
|
case HitCircle head:
|
||||||
|
return new DrawableSliderHead(slider, head) { OnShake = Shake };
|
||||||
|
|
||||||
|
case SliderTick tick:
|
||||||
|
return new DrawableSliderTick(tick) { Position = tick.Position - slider.Position };
|
||||||
|
|
||||||
|
case RepeatPoint repeat:
|
||||||
|
return new DrawableRepeatPoint(repeat, this) { Position = repeat.Position - slider.Position };
|
||||||
|
}
|
||||||
|
|
||||||
|
return base.CreateNestedHitObject(hitObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void UpdateInitialTransforms()
|
||||||
|
{
|
||||||
|
base.UpdateInitialTransforms();
|
||||||
|
|
||||||
|
Body.FadeInFromZero(HitObject.TimeFadeIn);
|
||||||
|
}
|
||||||
|
|
||||||
public readonly Bindable<bool> Tracking = new Bindable<bool>();
|
public readonly Bindable<bool> Tracking = new Bindable<bool>();
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
@ -139,9 +167,14 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
|
|
||||||
double completionProgress = MathHelper.Clamp((Time.Current - slider.StartTime) / slider.Duration, 0, 1);
|
double completionProgress = MathHelper.Clamp((Time.Current - slider.StartTime) / slider.Duration, 0, 1);
|
||||||
|
|
||||||
foreach (var c in components.OfType<ISliderProgress>()) c.UpdateProgress(completionProgress);
|
Ball.UpdateProgress(completionProgress);
|
||||||
foreach (var c in components.OfType<ITrackSnaking>()) c.UpdateSnakingPosition(slider.Path.PositionAt(Body.SnakedStart ?? 0), slider.Path.PositionAt(Body.SnakedEnd ?? 0));
|
Body.UpdateProgress(completionProgress);
|
||||||
foreach (var t in components.OfType<IRequireTracking>()) t.Tracking = Ball.Tracking;
|
|
||||||
|
foreach (DrawableHitObject hitObject in NestedHitObjects)
|
||||||
|
{
|
||||||
|
if (hitObject is ITrackSnaking s) s.UpdateSnakingPosition(slider.Path.PositionAt(Body.SnakedStart ?? 0), slider.Path.PositionAt(Body.SnakedEnd ?? 0));
|
||||||
|
if (hitObject is IRequireTracking t) t.Tracking = Ball.Tracking;
|
||||||
|
}
|
||||||
|
|
||||||
Size = Body.Size;
|
Size = Body.Size;
|
||||||
OriginPosition = Body.PathOffset;
|
OriginPosition = Body.PathOffset;
|
||||||
@ -187,7 +220,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
|
|
||||||
ApplyResult(r =>
|
ApplyResult(r =>
|
||||||
{
|
{
|
||||||
var judgementsCount = NestedHitObjects.Count();
|
var judgementsCount = NestedHitObjects.Count;
|
||||||
var judgementsHit = NestedHitObjects.Count(h => h.IsHit);
|
var judgementsHit = NestedHitObjects.Count(h => h.IsHit);
|
||||||
|
|
||||||
var hitFraction = (double)judgementsHit / judgementsCount;
|
var hitFraction = (double)judgementsHit / judgementsCount;
|
||||||
@ -228,7 +261,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Drawable ProxiedLayer => HeadCircle.ApproachCircle;
|
public Drawable ProxiedLayer => HeadCircle.ProxiedLayer;
|
||||||
|
|
||||||
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => Body.ReceivePositionalInputAt(screenSpacePos);
|
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => Body.ReceivePositionalInputAt(screenSpacePos);
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@ using osu.Framework.Graphics.Containers;
|
|||||||
using osu.Framework.Graphics.Effects;
|
using osu.Framework.Graphics.Effects;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
using osu.Framework.Graphics.Shapes;
|
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
|
|
||||||
@ -30,17 +29,15 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
|||||||
|
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new CircularContainer
|
new Container
|
||||||
{
|
{
|
||||||
Masking = true,
|
Masking = true,
|
||||||
Origin = Anchor.Centre,
|
|
||||||
EdgeEffect = new EdgeEffectParameters
|
EdgeEffect = new EdgeEffectParameters
|
||||||
{
|
{
|
||||||
Type = EdgeEffectType.Glow,
|
Type = EdgeEffectType.Glow,
|
||||||
Radius = 60,
|
Radius = 60,
|
||||||
Colour = Color4.White.Opacity(0.5f),
|
Colour = Color4.White.Opacity(0.5f),
|
||||||
},
|
},
|
||||||
Child = new Box()
|
|
||||||
},
|
},
|
||||||
number = new SkinnableSpriteText(new OsuSkinComponent(OsuSkinComponents.HitCircleText), _ => new OsuSpriteText
|
number = new SkinnableSpriteText(new OsuSkinComponent(OsuSkinComponents.HitCircleText), _ => new OsuSpriteText
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System.Linq;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
@ -98,6 +99,15 @@ namespace osu.Game.Rulesets.Osu.Objects
|
|||||||
set => LastInComboBindable.Value = value;
|
set => LastInComboBindable.Value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected OsuHitObject()
|
||||||
|
{
|
||||||
|
StackHeightBindable.BindValueChanged(height =>
|
||||||
|
{
|
||||||
|
foreach (var nested in NestedHitObjects.OfType<OsuHitObject>())
|
||||||
|
nested.StackHeight = height.NewValue;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
|
protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
|
||||||
{
|
{
|
||||||
base.ApplyDefaultsToSelf(controlPointInfo, difficulty);
|
base.ApplyDefaultsToSelf(controlPointInfo, difficulty);
|
||||||
|
@ -163,6 +163,7 @@ namespace osu.Game.Rulesets.Osu.Objects
|
|||||||
{
|
{
|
||||||
StartTime = e.Time,
|
StartTime = e.Time,
|
||||||
Position = Position,
|
Position = Position,
|
||||||
|
StackHeight = StackHeight,
|
||||||
Samples = getNodeSamples(0),
|
Samples = getNodeSamples(0),
|
||||||
SampleControlPoint = SampleControlPoint,
|
SampleControlPoint = SampleControlPoint,
|
||||||
});
|
});
|
||||||
@ -176,6 +177,7 @@ namespace osu.Game.Rulesets.Osu.Objects
|
|||||||
{
|
{
|
||||||
StartTime = e.Time,
|
StartTime = e.Time,
|
||||||
Position = EndPosition,
|
Position = EndPosition,
|
||||||
|
StackHeight = StackHeight
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -143,14 +143,14 @@
|
|||||||
"Objects": [{
|
"Objects": [{
|
||||||
"StartTime": 34989,
|
"StartTime": 34989,
|
||||||
"EndTime": 34989,
|
"EndTime": 34989,
|
||||||
"X": 163,
|
"X": 156.597382,
|
||||||
"Y": 138
|
"Y": 131.597382
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"StartTime": 35018,
|
"StartTime": 35018,
|
||||||
"EndTime": 35018,
|
"EndTime": 35018,
|
||||||
"X": 188,
|
"X": 181.597382,
|
||||||
"Y": 138
|
"Y": 131.597382
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@ -159,14 +159,14 @@
|
|||||||
"Objects": [{
|
"Objects": [{
|
||||||
"StartTime": 35106,
|
"StartTime": 35106,
|
||||||
"EndTime": 35106,
|
"EndTime": 35106,
|
||||||
"X": 163,
|
"X": 159.798691,
|
||||||
"Y": 138
|
"Y": 134.798691
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"StartTime": 35135,
|
"StartTime": 35135,
|
||||||
"EndTime": 35135,
|
"EndTime": 35135,
|
||||||
"X": 188,
|
"X": 184.798691,
|
||||||
"Y": 138
|
"Y": 134.798691
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@ -191,20 +191,20 @@
|
|||||||
"Objects": [{
|
"Objects": [{
|
||||||
"StartTime": 35695,
|
"StartTime": 35695,
|
||||||
"EndTime": 35695,
|
"EndTime": 35695,
|
||||||
"X": 166,
|
"X": 162.798691,
|
||||||
"Y": 76
|
"Y": 72.79869
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"StartTime": 35871,
|
"StartTime": 35871,
|
||||||
"EndTime": 35871,
|
"EndTime": 35871,
|
||||||
"X": 240.99855,
|
"X": 237.797241,
|
||||||
"Y": 75.53417
|
"Y": 72.33286
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"StartTime": 36011,
|
"StartTime": 36011,
|
||||||
"EndTime": 36011,
|
"EndTime": 36011,
|
||||||
"X": 315.9971,
|
"X": 312.795776,
|
||||||
"Y": 75.0683441
|
"Y": 71.8670349
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@ -235,20 +235,20 @@
|
|||||||
"Objects": [{
|
"Objects": [{
|
||||||
"StartTime": 36518,
|
"StartTime": 36518,
|
||||||
"EndTime": 36518,
|
"EndTime": 36518,
|
||||||
"X": 166,
|
"X": 169.201309,
|
||||||
"Y": 76
|
"Y": 79.20131
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"StartTime": 36694,
|
"StartTime": 36694,
|
||||||
"EndTime": 36694,
|
"EndTime": 36694,
|
||||||
"X": 240.99855,
|
"X": 244.19986,
|
||||||
"Y": 75.53417
|
"Y": 78.73548
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"StartTime": 36834,
|
"StartTime": 36834,
|
||||||
"EndTime": 36834,
|
"EndTime": 36834,
|
||||||
"X": 315.9971,
|
"X": 319.198425,
|
||||||
"Y": 75.0683441
|
"Y": 78.26965
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@ -257,20 +257,20 @@
|
|||||||
"Objects": [{
|
"Objects": [{
|
||||||
"StartTime": 36929,
|
"StartTime": 36929,
|
||||||
"EndTime": 36929,
|
"EndTime": 36929,
|
||||||
"X": 315,
|
"X": 324.603943,
|
||||||
"Y": 75
|
"Y": 84.6039352
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"StartTime": 37105,
|
"StartTime": 37105,
|
||||||
"EndTime": 37105,
|
"EndTime": 37105,
|
||||||
"X": 240.001526,
|
"X": 249.605469,
|
||||||
"Y": 75.47769
|
"Y": 85.08163
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"StartTime": 37245,
|
"StartTime": 37245,
|
||||||
"EndTime": 37245,
|
"EndTime": 37245,
|
||||||
"X": 165.003052,
|
"X": 174.607,
|
||||||
"Y": 75.95539
|
"Y": 85.5593262
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -2,14 +2,11 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
|
||||||
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.Graphics.Effects;
|
using osu.Framework.Graphics.Effects;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Game.Beatmaps;
|
|
||||||
using osu.Game.Configuration;
|
|
||||||
using osu.Game.Rulesets.Osu.Skinning;
|
using osu.Game.Rulesets.Osu.Skinning;
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
@ -23,12 +20,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
|
|||||||
|
|
||||||
private bool cursorExpand;
|
private bool cursorExpand;
|
||||||
|
|
||||||
private Bindable<float> cursorScale;
|
|
||||||
private Bindable<bool> autoCursorScale;
|
|
||||||
private readonly IBindable<WorkingBeatmap> beatmap = new Bindable<WorkingBeatmap>();
|
|
||||||
|
|
||||||
private Container expandTarget;
|
private Container expandTarget;
|
||||||
private Drawable scaleTarget;
|
|
||||||
|
|
||||||
public OsuCursor()
|
public OsuCursor()
|
||||||
{
|
{
|
||||||
@ -43,43 +35,19 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
|
|||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuConfigManager config, IBindable<WorkingBeatmap> beatmap)
|
private void load()
|
||||||
{
|
{
|
||||||
InternalChild = expandTarget = new Container
|
InternalChild = expandTarget = new Container
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Child = scaleTarget = new SkinnableDrawable(new OsuSkinComponent(OsuSkinComponents.Cursor), _ => new DefaultCursor(), confineMode: ConfineMode.NoScaling)
|
Child = new SkinnableDrawable(new OsuSkinComponent(OsuSkinComponents.Cursor), _ => new DefaultCursor(), confineMode: ConfineMode.NoScaling)
|
||||||
{
|
{
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.beatmap.BindTo(beatmap);
|
|
||||||
this.beatmap.ValueChanged += _ => calculateScale();
|
|
||||||
|
|
||||||
cursorScale = config.GetBindable<float>(OsuSetting.GameplayCursorSize);
|
|
||||||
cursorScale.ValueChanged += _ => calculateScale();
|
|
||||||
|
|
||||||
autoCursorScale = config.GetBindable<bool>(OsuSetting.AutoCursorSize);
|
|
||||||
autoCursorScale.ValueChanged += _ => calculateScale();
|
|
||||||
|
|
||||||
calculateScale();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void calculateScale()
|
|
||||||
{
|
|
||||||
float scale = cursorScale.Value;
|
|
||||||
|
|
||||||
if (autoCursorScale.Value && beatmap.Value != null)
|
|
||||||
{
|
|
||||||
// if we have a beatmap available, let's get its circle size to figure out an automatic cursor scale modifier.
|
|
||||||
scale *= 1f - 0.7f * (1f + beatmap.Value.BeatmapInfo.BaseDifficulty.CircleSize - BeatmapDifficulty.DEFAULT_DIFFICULTY) / BeatmapDifficulty.DEFAULT_DIFFICULTY;
|
|
||||||
}
|
|
||||||
|
|
||||||
scaleTarget.Scale = new Vector2(scale);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private const float pressed_scale = 1.2f;
|
private const float pressed_scale = 1.2f;
|
||||||
|
@ -8,6 +8,8 @@ using osu.Framework.Graphics;
|
|||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Textures;
|
using osu.Framework.Graphics.Textures;
|
||||||
using osu.Framework.Input.Bindings;
|
using osu.Framework.Input.Bindings;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Rulesets.Osu.Configuration;
|
using osu.Game.Rulesets.Osu.Configuration;
|
||||||
using osu.Game.Rulesets.UI;
|
using osu.Game.Rulesets.UI;
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
@ -27,6 +29,11 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
|
|||||||
|
|
||||||
private readonly Drawable cursorTrail;
|
private readonly Drawable cursorTrail;
|
||||||
|
|
||||||
|
public Bindable<float> CursorScale;
|
||||||
|
private Bindable<float> userCursorScale;
|
||||||
|
private Bindable<bool> autoCursorScale;
|
||||||
|
private readonly IBindable<WorkingBeatmap> beatmap = new Bindable<WorkingBeatmap>();
|
||||||
|
|
||||||
public OsuCursorContainer()
|
public OsuCursorContainer()
|
||||||
{
|
{
|
||||||
InternalChild = fadeContainer = new Container
|
InternalChild = fadeContainer = new Container
|
||||||
@ -37,9 +44,36 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
|
|||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader(true)]
|
[BackgroundDependencyLoader(true)]
|
||||||
private void load(OsuRulesetConfigManager config)
|
private void load(OsuConfigManager config, OsuRulesetConfigManager rulesetConfig, IBindable<WorkingBeatmap> beatmap)
|
||||||
{
|
{
|
||||||
config?.BindWith(OsuRulesetSetting.ShowCursorTrail, showTrail);
|
rulesetConfig?.BindWith(OsuRulesetSetting.ShowCursorTrail, showTrail);
|
||||||
|
|
||||||
|
this.beatmap.BindTo(beatmap);
|
||||||
|
this.beatmap.ValueChanged += _ => calculateScale();
|
||||||
|
|
||||||
|
userCursorScale = config.GetBindable<float>(OsuSetting.GameplayCursorSize);
|
||||||
|
userCursorScale.ValueChanged += _ => calculateScale();
|
||||||
|
|
||||||
|
autoCursorScale = config.GetBindable<bool>(OsuSetting.AutoCursorSize);
|
||||||
|
autoCursorScale.ValueChanged += _ => calculateScale();
|
||||||
|
|
||||||
|
CursorScale = new Bindable<float>();
|
||||||
|
CursorScale.ValueChanged += e => ActiveCursor.Scale = cursorTrail.Scale = new Vector2(e.NewValue);
|
||||||
|
|
||||||
|
calculateScale();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void calculateScale()
|
||||||
|
{
|
||||||
|
float scale = userCursorScale.Value;
|
||||||
|
|
||||||
|
if (autoCursorScale.Value && beatmap.Value != null)
|
||||||
|
{
|
||||||
|
// if we have a beatmap available, let's get its circle size to figure out an automatic cursor scale modifier.
|
||||||
|
scale *= 1f - 0.7f * (1f + beatmap.Value.BeatmapInfo.BaseDifficulty.CircleSize - BeatmapDifficulty.DEFAULT_DIFFICULTY) / BeatmapDifficulty.DEFAULT_DIFFICULTY;
|
||||||
|
}
|
||||||
|
|
||||||
|
CursorScale.Value = scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
@ -95,13 +129,13 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
|
|||||||
protected override void PopIn()
|
protected override void PopIn()
|
||||||
{
|
{
|
||||||
fadeContainer.FadeTo(1, 300, Easing.OutQuint);
|
fadeContainer.FadeTo(1, 300, Easing.OutQuint);
|
||||||
ActiveCursor.ScaleTo(1, 400, Easing.OutQuint);
|
ActiveCursor.ScaleTo(CursorScale.Value, 400, Easing.OutQuint);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void PopOut()
|
protected override void PopOut()
|
||||||
{
|
{
|
||||||
fadeContainer.FadeTo(0.05f, 450, Easing.OutQuint);
|
fadeContainer.FadeTo(0.05f, 450, Easing.OutQuint);
|
||||||
ActiveCursor.ScaleTo(0.8f, 450, Easing.OutQuint);
|
ActiveCursor.ScaleTo(CursorScale.Value * 0.8f, 450, Easing.OutQuint);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class DefaultCursorTrail : CursorTrail
|
private class DefaultCursorTrail : CursorTrail
|
||||||
|
@ -57,21 +57,15 @@ namespace osu.Game.Rulesets.Osu.UI
|
|||||||
public override void Add(DrawableHitObject h)
|
public override void Add(DrawableHitObject h)
|
||||||
{
|
{
|
||||||
h.OnNewResult += onNewResult;
|
h.OnNewResult += onNewResult;
|
||||||
|
h.OnLoadComplete += d =>
|
||||||
if (h is IDrawableHitObjectWithProxiedApproach c)
|
|
||||||
{
|
{
|
||||||
var original = c.ProxiedLayer;
|
if (d is IDrawableHitObjectWithProxiedApproach c)
|
||||||
|
approachCircles.Add(c.ProxiedLayer.CreateProxy());
|
||||||
// Hitobjects only have lifetimes set on LoadComplete. For nested hitobjects (e.g. SliderHeads), this only happens when the parenting slider becomes visible.
|
};
|
||||||
// This delegation is required to make sure that the approach circles for those not-yet-loaded objects aren't added prematurely.
|
|
||||||
original.OnLoadComplete += addApproachCircleProxy;
|
|
||||||
}
|
|
||||||
|
|
||||||
base.Add(h);
|
base.Add(h);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addApproachCircleProxy(Drawable d) => approachCircles.Add(d.CreateProxy());
|
|
||||||
|
|
||||||
public override void PostProcess()
|
public override void PostProcess()
|
||||||
{
|
{
|
||||||
connectionLayer.HitObjects = HitObjectContainer.Objects.Select(d => d.HitObject).OfType<OsuHitObject>();
|
connectionLayer.HitObjects = HitObjectContainer.Objects.Select(d => d.HitObject).OfType<OsuHitObject>();
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
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;
|
||||||
using osu.Framework.Input.Bindings;
|
using osu.Framework.Input.Bindings;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
using osu.Game.Rulesets.Osu.UI.Cursor;
|
using osu.Game.Rulesets.Osu.UI.Cursor;
|
||||||
using osu.Game.Rulesets.UI;
|
|
||||||
using osu.Game.Screens.Play;
|
using osu.Game.Screens.Play;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
@ -18,9 +18,11 @@ namespace osu.Game.Rulesets.Osu.UI
|
|||||||
{
|
{
|
||||||
public class OsuResumeOverlay : ResumeOverlay
|
public class OsuResumeOverlay : ResumeOverlay
|
||||||
{
|
{
|
||||||
|
private Container cursorScaleContainer;
|
||||||
private OsuClickToResumeCursor clickToResumeCursor;
|
private OsuClickToResumeCursor clickToResumeCursor;
|
||||||
|
|
||||||
private GameplayCursorContainer localCursorContainer;
|
private OsuCursorContainer localCursorContainer;
|
||||||
|
private Bindable<float> localCursorScale;
|
||||||
|
|
||||||
public override CursorContainer LocalCursor => State.Value == Visibility.Visible ? localCursorContainer : null;
|
public override CursorContainer LocalCursor => State.Value == Visibility.Visible ? localCursorContainer : null;
|
||||||
|
|
||||||
@ -29,22 +31,35 @@ namespace osu.Game.Rulesets.Osu.UI
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
Add(clickToResumeCursor = new OsuClickToResumeCursor { ResumeRequested = Resume });
|
Add(cursorScaleContainer = new Container
|
||||||
|
{
|
||||||
|
RelativePositionAxes = Axes.Both,
|
||||||
|
Child = clickToResumeCursor = new OsuClickToResumeCursor { ResumeRequested = Resume }
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Show()
|
public override void Show()
|
||||||
{
|
{
|
||||||
base.Show();
|
base.Show();
|
||||||
clickToResumeCursor.ShowAt(GameplayCursor.ActiveCursor.Position);
|
GameplayCursor.ActiveCursor.Hide();
|
||||||
|
cursorScaleContainer.MoveTo(GameplayCursor.ActiveCursor.Position);
|
||||||
|
clickToResumeCursor.Appear();
|
||||||
|
|
||||||
if (localCursorContainer == null)
|
if (localCursorContainer == null)
|
||||||
|
{
|
||||||
Add(localCursorContainer = new OsuCursorContainer());
|
Add(localCursorContainer = new OsuCursorContainer());
|
||||||
|
|
||||||
|
localCursorScale = new Bindable<float>();
|
||||||
|
localCursorScale.BindTo(localCursorContainer.CursorScale);
|
||||||
|
localCursorScale.BindValueChanged(scale => cursorScaleContainer.Scale = new Vector2(scale.NewValue), true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Hide()
|
public override void Hide()
|
||||||
{
|
{
|
||||||
localCursorContainer?.Expire();
|
localCursorContainer?.Expire();
|
||||||
localCursorContainer = null;
|
localCursorContainer = null;
|
||||||
|
GameplayCursor.ActiveCursor.Show();
|
||||||
|
|
||||||
base.Hide();
|
base.Hide();
|
||||||
}
|
}
|
||||||
@ -82,7 +97,7 @@ namespace osu.Game.Rulesets.Osu.UI
|
|||||||
case OsuAction.RightButton:
|
case OsuAction.RightButton:
|
||||||
if (!IsHovered) return false;
|
if (!IsHovered) return false;
|
||||||
|
|
||||||
this.ScaleTo(new Vector2(2), TRANSITION_TIME, Easing.OutQuint);
|
this.ScaleTo(2, TRANSITION_TIME, Easing.OutQuint);
|
||||||
|
|
||||||
ResumeRequested?.Invoke();
|
ResumeRequested?.Invoke();
|
||||||
return true;
|
return true;
|
||||||
@ -93,11 +108,10 @@ namespace osu.Game.Rulesets.Osu.UI
|
|||||||
|
|
||||||
public bool OnReleased(OsuAction action) => false;
|
public bool OnReleased(OsuAction action) => false;
|
||||||
|
|
||||||
public void ShowAt(Vector2 activeCursorPosition) => Schedule(() =>
|
public void Appear() => Schedule(() =>
|
||||||
{
|
{
|
||||||
updateColour();
|
updateColour();
|
||||||
this.MoveTo(activeCursorPosition);
|
this.ScaleTo(4).Then().ScaleTo(1, 1000, Easing.OutQuint);
|
||||||
this.ScaleTo(new Vector2(4)).Then().ScaleTo(Vector2.One, 1000, Easing.OutQuint);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
private void updateColour()
|
private void updateColour()
|
||||||
|
@ -66,7 +66,7 @@ namespace osu.Game.Rulesets.Taiko.Tests
|
|||||||
AddStep("Reset height", () => changePlayfieldSize(6));
|
AddStep("Reset height", () => changePlayfieldSize(6));
|
||||||
|
|
||||||
var controlPointInfo = new ControlPointInfo();
|
var controlPointInfo = new ControlPointInfo();
|
||||||
controlPointInfo.TimingPoints.Add(new TimingControlPoint());
|
controlPointInfo.Add(0, new TimingControlPoint());
|
||||||
|
|
||||||
WorkingBeatmap beatmap = CreateWorkingBeatmap(new Beatmap
|
WorkingBeatmap beatmap = CreateWorkingBeatmap(new Beatmap
|
||||||
{
|
{
|
||||||
@ -142,7 +142,7 @@ namespace osu.Game.Rulesets.Taiko.Tests
|
|||||||
HitResult hitResult = RNG.Next(2) == 0 ? HitResult.Good : HitResult.Great;
|
HitResult hitResult = RNG.Next(2) == 0 ? HitResult.Good : HitResult.Great;
|
||||||
|
|
||||||
var cpi = new ControlPointInfo();
|
var cpi = new ControlPointInfo();
|
||||||
cpi.EffectPoints.Add(new EffectControlPoint { KiaiMode = kiai });
|
cpi.Add(0, new EffectControlPoint { KiaiMode = kiai });
|
||||||
|
|
||||||
Hit hit = new Hit();
|
Hit hit = new Hit();
|
||||||
hit.ApplyDefaults(cpi, new BeatmapDifficulty());
|
hit.ApplyDefaults(cpi, new BeatmapDifficulty());
|
||||||
@ -157,7 +157,7 @@ namespace osu.Game.Rulesets.Taiko.Tests
|
|||||||
HitResult hitResult = RNG.Next(2) == 0 ? HitResult.Good : HitResult.Great;
|
HitResult hitResult = RNG.Next(2) == 0 ? HitResult.Good : HitResult.Great;
|
||||||
|
|
||||||
var cpi = new ControlPointInfo();
|
var cpi = new ControlPointInfo();
|
||||||
cpi.EffectPoints.Add(new EffectControlPoint { KiaiMode = kiai });
|
cpi.Add(0, new EffectControlPoint { KiaiMode = kiai });
|
||||||
|
|
||||||
Hit hit = new Hit();
|
Hit hit = new Hit();
|
||||||
hit.ApplyDefaults(cpi, new BeatmapDifficulty());
|
hit.ApplyDefaults(cpi, new BeatmapDifficulty());
|
||||||
@ -239,7 +239,7 @@ namespace osu.Game.Rulesets.Taiko.Tests
|
|||||||
private class TestStrongNestedHit : DrawableStrongNestedHit
|
private class TestStrongNestedHit : DrawableStrongNestedHit
|
||||||
{
|
{
|
||||||
public TestStrongNestedHit(DrawableHitObject mainObject)
|
public TestStrongNestedHit(DrawableHitObject mainObject)
|
||||||
: base(null, mainObject)
|
: base(new StrongHitObject { StartTime = mainObject.HitObject.StartTime }, mainObject)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,12 +19,7 @@ namespace osu.Game.Rulesets.Taiko.Audio
|
|||||||
{
|
{
|
||||||
this.controlPoints = controlPoints;
|
this.controlPoints = controlPoints;
|
||||||
|
|
||||||
IEnumerable<SampleControlPoint> samplePoints;
|
IEnumerable<SampleControlPoint> samplePoints = controlPoints.SamplePoints.Count == 0 ? new[] { controlPoints.SamplePointAt(double.MinValue) } : controlPoints.SamplePoints;
|
||||||
if (controlPoints.SamplePoints.Count == 0)
|
|
||||||
// Get the default sample point
|
|
||||||
samplePoints = new[] { controlPoints.SamplePointAt(double.MinValue) };
|
|
||||||
else
|
|
||||||
samplePoints = controlPoints.SamplePoints;
|
|
||||||
|
|
||||||
foreach (var s in samplePoints)
|
foreach (var s in samplePoints)
|
||||||
{
|
{
|
||||||
|
@ -12,6 +12,7 @@ using osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces;
|
|||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Game.Rulesets.Judgements;
|
using osu.Game.Rulesets.Judgements;
|
||||||
|
using osu.Game.Rulesets.Objects;
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
||||||
@ -28,31 +29,18 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private int rollingHits;
|
private int rollingHits;
|
||||||
|
|
||||||
|
private readonly Container<DrawableDrumRollTick> tickContainer;
|
||||||
|
|
||||||
|
private Color4 colourIdle;
|
||||||
|
private Color4 colourEngaged;
|
||||||
|
|
||||||
public DrawableDrumRoll(DrumRoll drumRoll)
|
public DrawableDrumRoll(DrumRoll drumRoll)
|
||||||
: base(drumRoll)
|
: base(drumRoll)
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Y;
|
RelativeSizeAxes = Axes.Y;
|
||||||
|
|
||||||
Container<DrawableDrumRollTick> tickContainer;
|
|
||||||
MainPiece.Add(tickContainer = new Container<DrawableDrumRollTick> { RelativeSizeAxes = Axes.Both });
|
MainPiece.Add(tickContainer = new Container<DrawableDrumRollTick> { RelativeSizeAxes = Axes.Both });
|
||||||
|
|
||||||
foreach (var tick in drumRoll.NestedHitObjects.OfType<DrumRollTick>())
|
|
||||||
{
|
|
||||||
var newTick = new DrawableDrumRollTick(tick);
|
|
||||||
newTick.OnNewResult += onNewTickResult;
|
|
||||||
|
|
||||||
AddNested(newTick);
|
|
||||||
tickContainer.Add(newTick);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override TaikoPiece CreateMainPiece() => new ElongatedCirclePiece();
|
|
||||||
|
|
||||||
public override bool OnPressed(TaikoAction action) => false;
|
|
||||||
|
|
||||||
private Color4 colourIdle;
|
|
||||||
private Color4 colourEngaged;
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours)
|
private void load(OsuColour colours)
|
||||||
{
|
{
|
||||||
@ -60,8 +48,51 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
|||||||
colourEngaged = colours.YellowDarker;
|
colourEngaged = colours.YellowDarker;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onNewTickResult(DrawableHitObject obj, JudgementResult result)
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
|
||||||
|
OnNewResult += onNewResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void AddNestedHitObject(DrawableHitObject hitObject)
|
||||||
|
{
|
||||||
|
base.AddNestedHitObject(hitObject);
|
||||||
|
|
||||||
|
switch (hitObject)
|
||||||
|
{
|
||||||
|
case DrawableDrumRollTick tick:
|
||||||
|
tickContainer.Add(tick);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void ClearNestedHitObjects()
|
||||||
|
{
|
||||||
|
base.ClearNestedHitObjects();
|
||||||
|
tickContainer.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override DrawableHitObject CreateNestedHitObject(HitObject hitObject)
|
||||||
|
{
|
||||||
|
switch (hitObject)
|
||||||
|
{
|
||||||
|
case DrumRollTick tick:
|
||||||
|
return new DrawableDrumRollTick(tick);
|
||||||
|
}
|
||||||
|
|
||||||
|
return base.CreateNestedHitObject(hitObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override TaikoPiece CreateMainPiece() => new ElongatedCirclePiece();
|
||||||
|
|
||||||
|
public override bool OnPressed(TaikoAction action) => false;
|
||||||
|
|
||||||
|
private void onNewResult(DrawableHitObject obj, JudgementResult result)
|
||||||
|
{
|
||||||
|
if (!(obj is DrawableDrumRollTick))
|
||||||
|
return;
|
||||||
|
|
||||||
if (result.Type > HitResult.Miss)
|
if (result.Type > HitResult.Miss)
|
||||||
rollingHits++;
|
rollingHits++;
|
||||||
else
|
else
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Extensions.Color4Extensions;
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
@ -14,6 +13,7 @@ using osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces;
|
|||||||
using osuTK;
|
using osuTK;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Game.Rulesets.Objects;
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
||||||
@ -30,8 +30,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private const double ring_appear_offset = 100;
|
private const double ring_appear_offset = 100;
|
||||||
|
|
||||||
private readonly List<DrawableSwellTick> ticks = new List<DrawableSwellTick>();
|
private readonly Container<DrawableSwellTick> ticks;
|
||||||
|
|
||||||
private readonly Container bodyContainer;
|
private readonly Container bodyContainer;
|
||||||
private readonly CircularContainer targetRing;
|
private readonly CircularContainer targetRing;
|
||||||
private readonly CircularContainer expandingRing;
|
private readonly CircularContainer expandingRing;
|
||||||
@ -108,16 +107,9 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
AddInternal(ticks = new Container<DrawableSwellTick> { RelativeSizeAxes = Axes.Both });
|
||||||
|
|
||||||
MainPiece.Add(symbol = new SwellSymbolPiece());
|
MainPiece.Add(symbol = new SwellSymbolPiece());
|
||||||
|
|
||||||
foreach (var tick in HitObject.NestedHitObjects.OfType<SwellTick>())
|
|
||||||
{
|
|
||||||
var vis = new DrawableSwellTick(tick);
|
|
||||||
|
|
||||||
ticks.Add(vis);
|
|
||||||
AddInternal(vis);
|
|
||||||
AddNested(vis);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
@ -136,11 +128,49 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
|||||||
Width *= Parent.RelativeChildSize.X;
|
Width *= Parent.RelativeChildSize.X;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void AddNestedHitObject(DrawableHitObject hitObject)
|
||||||
|
{
|
||||||
|
base.AddNestedHitObject(hitObject);
|
||||||
|
|
||||||
|
switch (hitObject)
|
||||||
|
{
|
||||||
|
case DrawableSwellTick tick:
|
||||||
|
ticks.Add(tick);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void ClearNestedHitObjects()
|
||||||
|
{
|
||||||
|
base.ClearNestedHitObjects();
|
||||||
|
ticks.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override DrawableHitObject CreateNestedHitObject(HitObject hitObject)
|
||||||
|
{
|
||||||
|
switch (hitObject)
|
||||||
|
{
|
||||||
|
case SwellTick tick:
|
||||||
|
return new DrawableSwellTick(tick);
|
||||||
|
}
|
||||||
|
|
||||||
|
return base.CreateNestedHitObject(hitObject);
|
||||||
|
}
|
||||||
|
|
||||||
protected override void CheckForResult(bool userTriggered, double timeOffset)
|
protected override void CheckForResult(bool userTriggered, double timeOffset)
|
||||||
{
|
{
|
||||||
if (userTriggered)
|
if (userTriggered)
|
||||||
{
|
{
|
||||||
var nextTick = ticks.Find(j => !j.IsHit);
|
DrawableSwellTick nextTick = null;
|
||||||
|
|
||||||
|
foreach (var t in ticks)
|
||||||
|
{
|
||||||
|
if (!t.IsHit)
|
||||||
|
{
|
||||||
|
nextTick = t;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
nextTick?.TriggerResult(HitResult.Great);
|
nextTick?.TriggerResult(HitResult.Great);
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ using osu.Game.Audio;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Primitives;
|
using osu.Framework.Graphics.Primitives;
|
||||||
|
using osu.Game.Rulesets.Objects;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
||||||
{
|
{
|
||||||
@ -109,11 +110,12 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
|||||||
{
|
{
|
||||||
public override Vector2 OriginPosition => new Vector2(DrawHeight / 2);
|
public override Vector2 OriginPosition => new Vector2(DrawHeight / 2);
|
||||||
|
|
||||||
protected readonly Vector2 BaseSize;
|
public new TaikoHitType HitObject;
|
||||||
|
|
||||||
|
protected readonly Vector2 BaseSize;
|
||||||
protected readonly TaikoPiece MainPiece;
|
protected readonly TaikoPiece MainPiece;
|
||||||
|
|
||||||
public new TaikoHitType HitObject;
|
private readonly Container<DrawableStrongNestedHit> strongHitContainer;
|
||||||
|
|
||||||
protected DrawableTaikoHitObject(TaikoHitType hitObject)
|
protected DrawableTaikoHitObject(TaikoHitType hitObject)
|
||||||
: base(hitObject)
|
: base(hitObject)
|
||||||
@ -129,17 +131,38 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
|||||||
Content.Add(MainPiece = CreateMainPiece());
|
Content.Add(MainPiece = CreateMainPiece());
|
||||||
MainPiece.KiaiMode = HitObject.Kiai;
|
MainPiece.KiaiMode = HitObject.Kiai;
|
||||||
|
|
||||||
var strongObject = HitObject.NestedHitObjects.OfType<StrongHitObject>().FirstOrDefault();
|
AddInternal(strongHitContainer = new Container<DrawableStrongNestedHit>());
|
||||||
|
}
|
||||||
|
|
||||||
if (strongObject != null)
|
protected override void AddNestedHitObject(DrawableHitObject hitObject)
|
||||||
|
{
|
||||||
|
base.AddNestedHitObject(hitObject);
|
||||||
|
|
||||||
|
switch (hitObject)
|
||||||
{
|
{
|
||||||
var strongHit = CreateStrongHit(strongObject);
|
case DrawableStrongNestedHit strong:
|
||||||
|
strongHitContainer.Add(strong);
|
||||||
AddNested(strongHit);
|
break;
|
||||||
AddInternal(strongHit);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void ClearNestedHitObjects()
|
||||||
|
{
|
||||||
|
base.ClearNestedHitObjects();
|
||||||
|
strongHitContainer.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override DrawableHitObject CreateNestedHitObject(HitObject hitObject)
|
||||||
|
{
|
||||||
|
switch (hitObject)
|
||||||
|
{
|
||||||
|
case StrongHitObject strong:
|
||||||
|
return CreateStrongHit(strong);
|
||||||
|
}
|
||||||
|
|
||||||
|
return base.CreateNestedHitObject(hitObject);
|
||||||
|
}
|
||||||
|
|
||||||
// Normal and clap samples are handled by the drum
|
// Normal and clap samples are handled by the drum
|
||||||
protected override IEnumerable<HitSampleInfo> GetSamples() => HitObject.Samples.Where(s => s.Name != HitSampleInfo.HIT_NORMAL && s.Name != HitSampleInfo.HIT_CLAP);
|
protected override IEnumerable<HitSampleInfo> GetSamples() => HitObject.Samples.Where(s => s.Name != HitSampleInfo.HIT_NORMAL && s.Name != HitSampleInfo.HIT_CLAP);
|
||||||
|
|
||||||
|
@ -167,9 +167,9 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
|||||||
var controlPoints = beatmap.ControlPointInfo;
|
var controlPoints = beatmap.ControlPointInfo;
|
||||||
|
|
||||||
Assert.AreEqual(4, controlPoints.TimingPoints.Count);
|
Assert.AreEqual(4, controlPoints.TimingPoints.Count);
|
||||||
Assert.AreEqual(42, controlPoints.DifficultyPoints.Count);
|
Assert.AreEqual(5, controlPoints.DifficultyPoints.Count);
|
||||||
Assert.AreEqual(42, controlPoints.SamplePoints.Count);
|
Assert.AreEqual(34, controlPoints.SamplePoints.Count);
|
||||||
Assert.AreEqual(42, controlPoints.EffectPoints.Count);
|
Assert.AreEqual(8, controlPoints.EffectPoints.Count);
|
||||||
|
|
||||||
var timingPoint = controlPoints.TimingPointAt(0);
|
var timingPoint = controlPoints.TimingPointAt(0);
|
||||||
Assert.AreEqual(956, timingPoint.Time);
|
Assert.AreEqual(956, timingPoint.Time);
|
||||||
@ -191,7 +191,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
|||||||
Assert.AreEqual(1.0, difficultyPoint.SpeedMultiplier);
|
Assert.AreEqual(1.0, difficultyPoint.SpeedMultiplier);
|
||||||
|
|
||||||
difficultyPoint = controlPoints.DifficultyPointAt(48428);
|
difficultyPoint = controlPoints.DifficultyPointAt(48428);
|
||||||
Assert.AreEqual(48428, difficultyPoint.Time);
|
Assert.AreEqual(0, difficultyPoint.Time);
|
||||||
Assert.AreEqual(1.0, difficultyPoint.SpeedMultiplier);
|
Assert.AreEqual(1.0, difficultyPoint.SpeedMultiplier);
|
||||||
|
|
||||||
difficultyPoint = controlPoints.DifficultyPointAt(116999);
|
difficultyPoint = controlPoints.DifficultyPointAt(116999);
|
||||||
@ -224,7 +224,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
|||||||
Assert.IsFalse(effectPoint.OmitFirstBarLine);
|
Assert.IsFalse(effectPoint.OmitFirstBarLine);
|
||||||
|
|
||||||
effectPoint = controlPoints.EffectPointAt(119637);
|
effectPoint = controlPoints.EffectPointAt(119637);
|
||||||
Assert.AreEqual(119637, effectPoint.Time);
|
Assert.AreEqual(95901, effectPoint.Time);
|
||||||
Assert.IsFalse(effectPoint.KiaiMode);
|
Assert.IsFalse(effectPoint.KiaiMode);
|
||||||
Assert.IsFalse(effectPoint.OmitFirstBarLine);
|
Assert.IsFalse(effectPoint.OmitFirstBarLine);
|
||||||
}
|
}
|
||||||
@ -262,6 +262,21 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestTimingPointResetsSpeedMultiplier()
|
||||||
|
{
|
||||||
|
var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false };
|
||||||
|
|
||||||
|
using (var resStream = TestResources.OpenResource("timingpoint-speedmultiplier-reset.osu"))
|
||||||
|
using (var stream = new LineBufferedReader(resStream))
|
||||||
|
{
|
||||||
|
var controlPoints = decoder.Decode(stream).ControlPointInfo;
|
||||||
|
|
||||||
|
Assert.That(controlPoints.DifficultyPointAt(0).SpeedMultiplier, Is.EqualTo(0.5).Within(0.1));
|
||||||
|
Assert.That(controlPoints.DifficultyPointAt(2000).SpeedMultiplier, Is.EqualTo(1).Within(0.1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestDecodeBeatmapColours()
|
public void TestDecodeBeatmapColours()
|
||||||
{
|
{
|
||||||
@ -362,6 +377,23 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestDecodeControlPointDifficultyChange()
|
||||||
|
{
|
||||||
|
var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false };
|
||||||
|
|
||||||
|
using (var resStream = TestResources.OpenResource("controlpoint-difficulty-multiplier.osu"))
|
||||||
|
using (var stream = new LineBufferedReader(resStream))
|
||||||
|
{
|
||||||
|
var controlPointInfo = decoder.Decode(stream).ControlPointInfo;
|
||||||
|
|
||||||
|
Assert.That(controlPointInfo.DifficultyPointAt(5).SpeedMultiplier, Is.EqualTo(1));
|
||||||
|
Assert.That(controlPointInfo.DifficultyPointAt(1000).SpeedMultiplier, Is.EqualTo(10));
|
||||||
|
Assert.That(controlPointInfo.DifficultyPointAt(2000).SpeedMultiplier, Is.EqualTo(1.8518518518518519d));
|
||||||
|
Assert.That(controlPointInfo.DifficultyPointAt(3000).SpeedMultiplier, Is.EqualTo(0.5));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestDecodeControlPointCustomSampleBank()
|
public void TestDecodeControlPointCustomSampleBank()
|
||||||
{
|
{
|
||||||
|
@ -273,6 +273,96 @@ namespace osu.Game.Tests.Chat
|
|||||||
Assert.AreEqual(21, result.Links[0].Length);
|
Assert.AreEqual(21, result.Links[0].Length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestMarkdownFormatLinkWithInlineTitle()
|
||||||
|
{
|
||||||
|
Message result = MessageFormatter.FormatMessage(new Message { Content = "I haven't seen [this link format](https://osu.ppy.sh \"osu!\") before..." });
|
||||||
|
|
||||||
|
Assert.AreEqual("I haven't seen this link format before...", result.DisplayContent);
|
||||||
|
Assert.AreEqual(1, result.Links.Count);
|
||||||
|
Assert.AreEqual("https://osu.ppy.sh", result.Links[0].Url);
|
||||||
|
Assert.AreEqual(15, result.Links[0].Index);
|
||||||
|
Assert.AreEqual(16, result.Links[0].Length);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestMarkdownFormatLinkWithInlineTitleAndEscapedQuotes()
|
||||||
|
{
|
||||||
|
Message result = MessageFormatter.FormatMessage(new Message { Content = "I haven't seen [this link format](https://osu.ppy.sh \"inner quote \\\" just to confuse \") before..." });
|
||||||
|
|
||||||
|
Assert.AreEqual("I haven't seen this link format before...", result.DisplayContent);
|
||||||
|
Assert.AreEqual(1, result.Links.Count);
|
||||||
|
Assert.AreEqual("https://osu.ppy.sh", result.Links[0].Url);
|
||||||
|
Assert.AreEqual(15, result.Links[0].Index);
|
||||||
|
Assert.AreEqual(16, result.Links[0].Length);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestMarkdownFormatLinkWithUrlInTextAndInlineTitle()
|
||||||
|
{
|
||||||
|
Message result = MessageFormatter.FormatMessage(new Message { Content = "I haven't seen [https://osu.ppy.sh](https://osu.ppy.sh \"https://osu.ppy.sh\") before..." });
|
||||||
|
|
||||||
|
Assert.AreEqual("I haven't seen https://osu.ppy.sh before...", result.DisplayContent);
|
||||||
|
Assert.AreEqual(1, result.Links.Count);
|
||||||
|
Assert.AreEqual("https://osu.ppy.sh", result.Links[0].Url);
|
||||||
|
Assert.AreEqual(15, result.Links[0].Index);
|
||||||
|
Assert.AreEqual(18, result.Links[0].Length);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestMarkdownFormatLinkWithUrlAndTextInTitle()
|
||||||
|
{
|
||||||
|
Message result = MessageFormatter.FormatMessage(new Message { Content = "I haven't seen [oh no, text here! https://osu.ppy.sh](https://osu.ppy.sh) before..." });
|
||||||
|
|
||||||
|
Assert.AreEqual("I haven't seen oh no, text here! https://osu.ppy.sh before...", result.DisplayContent);
|
||||||
|
Assert.AreEqual(1, result.Links.Count);
|
||||||
|
Assert.AreEqual("https://osu.ppy.sh", result.Links[0].Url);
|
||||||
|
Assert.AreEqual(15, result.Links[0].Index);
|
||||||
|
Assert.AreEqual(36, result.Links[0].Length);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestMarkdownFormatLinkWithMisleadingUrlInText()
|
||||||
|
{
|
||||||
|
Message result = MessageFormatter.FormatMessage(new Message { Content = "I haven't seen [https://google.com](https://osu.ppy.sh) before..." });
|
||||||
|
|
||||||
|
Assert.AreEqual("I haven't seen https://google.com before...", result.DisplayContent);
|
||||||
|
Assert.AreEqual(1, result.Links.Count);
|
||||||
|
Assert.AreEqual("https://osu.ppy.sh", result.Links[0].Url);
|
||||||
|
Assert.AreEqual(15, result.Links[0].Index);
|
||||||
|
Assert.AreEqual(18, result.Links[0].Length);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestMarkdownFormatLinkThatContractsIntoLargerLink()
|
||||||
|
{
|
||||||
|
Message result = MessageFormatter.FormatMessage(new Message { Content = "super broken https://[osu.ppy](https://reddit.com).sh/" });
|
||||||
|
|
||||||
|
Assert.AreEqual("super broken https://osu.ppy.sh/", result.DisplayContent);
|
||||||
|
Assert.AreEqual(1, result.Links.Count);
|
||||||
|
Assert.AreEqual("https://reddit.com", result.Links[0].Url);
|
||||||
|
Assert.AreEqual(21, result.Links[0].Index);
|
||||||
|
Assert.AreEqual(7, result.Links[0].Length);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestMarkdownFormatLinkDirectlyNextToRawLink()
|
||||||
|
{
|
||||||
|
// the raw link has a port at the end of it, so that the raw link regex terminates at the port and doesn't consume display text from the formatted one
|
||||||
|
Message result = MessageFormatter.FormatMessage(new Message { Content = "https://localhost:8080[https://osu.ppy.sh](https://osu.ppy.sh) should be two links" });
|
||||||
|
|
||||||
|
Assert.AreEqual("https://localhost:8080https://osu.ppy.sh should be two links", result.DisplayContent);
|
||||||
|
Assert.AreEqual(2, result.Links.Count);
|
||||||
|
|
||||||
|
Assert.AreEqual("https://localhost:8080", result.Links[0].Url);
|
||||||
|
Assert.AreEqual(0, result.Links[0].Index);
|
||||||
|
Assert.AreEqual(22, result.Links[0].Length);
|
||||||
|
|
||||||
|
Assert.AreEqual("https://osu.ppy.sh", result.Links[1].Url);
|
||||||
|
Assert.AreEqual(22, result.Links[1].Index);
|
||||||
|
Assert.AreEqual(18, result.Links[1].Length);
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestChannelLink()
|
public void TestChannelLink()
|
||||||
{
|
{
|
||||||
|
@ -0,0 +1,194 @@
|
|||||||
|
// 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 NUnit.Framework;
|
||||||
|
using osu.Framework.Testing;
|
||||||
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
|
using osu.Game.Rulesets.Osu;
|
||||||
|
using osu.Game.Rulesets.Osu.Edit;
|
||||||
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
|
using osu.Game.Screens.Edit;
|
||||||
|
using osu.Game.Tests.Visual;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Editor
|
||||||
|
{
|
||||||
|
[HeadlessTest]
|
||||||
|
public class TestSceneHitObjectComposerDistanceSnapping : EditorClockTestScene
|
||||||
|
{
|
||||||
|
private TestHitObjectComposer composer;
|
||||||
|
|
||||||
|
[SetUp]
|
||||||
|
public void Setup() => Schedule(() =>
|
||||||
|
{
|
||||||
|
Child = composer = new TestHitObjectComposer();
|
||||||
|
|
||||||
|
BeatDivisor.Value = 1;
|
||||||
|
|
||||||
|
composer.EditorBeatmap.BeatmapInfo.BaseDifficulty.SliderMultiplier = 1;
|
||||||
|
composer.EditorBeatmap.ControlPointInfo.Clear();
|
||||||
|
|
||||||
|
composer.EditorBeatmap.ControlPointInfo.Add(0, new DifficultyControlPoint { SpeedMultiplier = 1 });
|
||||||
|
composer.EditorBeatmap.ControlPointInfo.Add(0, new TimingControlPoint { BeatLength = 1000 });
|
||||||
|
});
|
||||||
|
|
||||||
|
[TestCase(1)]
|
||||||
|
[TestCase(2)]
|
||||||
|
public void TestSliderMultiplier(float multiplier)
|
||||||
|
{
|
||||||
|
AddStep($"set multiplier = {multiplier}", () => composer.EditorBeatmap.BeatmapInfo.BaseDifficulty.SliderMultiplier = multiplier);
|
||||||
|
|
||||||
|
assertSnapDistance(100 * multiplier);
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestCase(1)]
|
||||||
|
[TestCase(2)]
|
||||||
|
public void TestSpeedMultiplier(float multiplier)
|
||||||
|
{
|
||||||
|
AddStep($"set multiplier = {multiplier}", () =>
|
||||||
|
{
|
||||||
|
composer.EditorBeatmap.ControlPointInfo.Clear();
|
||||||
|
composer.EditorBeatmap.ControlPointInfo.Add(0, new DifficultyControlPoint { SpeedMultiplier = multiplier });
|
||||||
|
});
|
||||||
|
|
||||||
|
assertSnapDistance(100 * multiplier);
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestCase(1)]
|
||||||
|
[TestCase(2)]
|
||||||
|
public void TestBeatDivisor(int divisor)
|
||||||
|
{
|
||||||
|
AddStep($"set divisor = {divisor}", () => BeatDivisor.Value = divisor);
|
||||||
|
|
||||||
|
assertSnapDistance(100f / divisor);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestConvertDurationToDistance()
|
||||||
|
{
|
||||||
|
assertDurationToDistance(500, 50);
|
||||||
|
assertDurationToDistance(1000, 100);
|
||||||
|
|
||||||
|
AddStep("set slider multiplier = 2", () => composer.EditorBeatmap.BeatmapInfo.BaseDifficulty.SliderMultiplier = 2);
|
||||||
|
|
||||||
|
assertDurationToDistance(500, 100);
|
||||||
|
assertDurationToDistance(1000, 200);
|
||||||
|
|
||||||
|
AddStep("set beat length = 500", () =>
|
||||||
|
{
|
||||||
|
composer.EditorBeatmap.ControlPointInfo.Clear();
|
||||||
|
composer.EditorBeatmap.ControlPointInfo.Add(0, new TimingControlPoint { BeatLength = 500 });
|
||||||
|
});
|
||||||
|
|
||||||
|
assertDurationToDistance(500, 200);
|
||||||
|
assertDurationToDistance(1000, 400);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestConvertDistanceToDuration()
|
||||||
|
{
|
||||||
|
assertDistanceToDuration(50, 500);
|
||||||
|
assertDistanceToDuration(100, 1000);
|
||||||
|
|
||||||
|
AddStep("set slider multiplier = 2", () => composer.EditorBeatmap.BeatmapInfo.BaseDifficulty.SliderMultiplier = 2);
|
||||||
|
|
||||||
|
assertDistanceToDuration(100, 500);
|
||||||
|
assertDistanceToDuration(200, 1000);
|
||||||
|
|
||||||
|
AddStep("set beat length = 500", () =>
|
||||||
|
{
|
||||||
|
composer.EditorBeatmap.ControlPointInfo.Clear();
|
||||||
|
composer.EditorBeatmap.ControlPointInfo.Add(0, new TimingControlPoint { BeatLength = 500 });
|
||||||
|
});
|
||||||
|
|
||||||
|
assertDistanceToDuration(200, 500);
|
||||||
|
assertDistanceToDuration(400, 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestGetSnappedDurationFromDistance()
|
||||||
|
{
|
||||||
|
assertSnappedDuration(50, 0);
|
||||||
|
assertSnappedDuration(100, 1000);
|
||||||
|
assertSnappedDuration(150, 1000);
|
||||||
|
assertSnappedDuration(200, 2000);
|
||||||
|
assertSnappedDuration(250, 2000);
|
||||||
|
|
||||||
|
AddStep("set slider multiplier = 2", () => composer.EditorBeatmap.BeatmapInfo.BaseDifficulty.SliderMultiplier = 2);
|
||||||
|
|
||||||
|
assertSnappedDuration(50, 0);
|
||||||
|
assertSnappedDuration(100, 0);
|
||||||
|
assertSnappedDuration(150, 0);
|
||||||
|
assertSnappedDuration(200, 1000);
|
||||||
|
assertSnappedDuration(250, 1000);
|
||||||
|
|
||||||
|
AddStep("set beat length = 500", () =>
|
||||||
|
{
|
||||||
|
composer.EditorBeatmap.ControlPointInfo.Clear();
|
||||||
|
composer.EditorBeatmap.ControlPointInfo.Add(0, new TimingControlPoint { BeatLength = 500 });
|
||||||
|
});
|
||||||
|
|
||||||
|
assertSnappedDuration(50, 0);
|
||||||
|
assertSnappedDuration(100, 0);
|
||||||
|
assertSnappedDuration(150, 0);
|
||||||
|
assertSnappedDuration(200, 500);
|
||||||
|
assertSnappedDuration(250, 500);
|
||||||
|
assertSnappedDuration(400, 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void GetSnappedDistanceFromDistance()
|
||||||
|
{
|
||||||
|
assertSnappedDistance(50, 0);
|
||||||
|
assertSnappedDistance(100, 100);
|
||||||
|
assertSnappedDistance(150, 100);
|
||||||
|
assertSnappedDistance(200, 200);
|
||||||
|
assertSnappedDistance(250, 200);
|
||||||
|
|
||||||
|
AddStep("set slider multiplier = 2", () => composer.EditorBeatmap.BeatmapInfo.BaseDifficulty.SliderMultiplier = 2);
|
||||||
|
|
||||||
|
assertSnappedDistance(50, 0);
|
||||||
|
assertSnappedDistance(100, 0);
|
||||||
|
assertSnappedDistance(150, 0);
|
||||||
|
assertSnappedDistance(200, 200);
|
||||||
|
assertSnappedDistance(250, 200);
|
||||||
|
|
||||||
|
AddStep("set beat length = 500", () =>
|
||||||
|
{
|
||||||
|
composer.EditorBeatmap.ControlPointInfo.Clear();
|
||||||
|
composer.EditorBeatmap.ControlPointInfo.Add(0, new TimingControlPoint { BeatLength = 500 });
|
||||||
|
});
|
||||||
|
|
||||||
|
assertSnappedDistance(50, 0);
|
||||||
|
assertSnappedDistance(100, 0);
|
||||||
|
assertSnappedDistance(150, 0);
|
||||||
|
assertSnappedDistance(200, 200);
|
||||||
|
assertSnappedDistance(250, 200);
|
||||||
|
assertSnappedDistance(400, 400);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assertSnapDistance(float expectedDistance)
|
||||||
|
=> AddAssert($"distance is {expectedDistance}", () => composer.GetBeatSnapDistanceAt(0) == expectedDistance);
|
||||||
|
|
||||||
|
private void assertDurationToDistance(double duration, float expectedDistance)
|
||||||
|
=> AddAssert($"duration = {duration} -> distance = {expectedDistance}", () => composer.DurationToDistance(0, duration) == expectedDistance);
|
||||||
|
|
||||||
|
private void assertDistanceToDuration(float distance, double expectedDuration)
|
||||||
|
=> AddAssert($"distance = {distance} -> duration = {expectedDuration}", () => composer.DistanceToDuration(0, distance) == expectedDuration);
|
||||||
|
|
||||||
|
private void assertSnappedDuration(float distance, double expectedDuration)
|
||||||
|
=> AddAssert($"distance = {distance} -> duration = {expectedDuration} (snapped)", () => composer.GetSnappedDurationFromDistance(0, distance) == expectedDuration);
|
||||||
|
|
||||||
|
private void assertSnappedDistance(float distance, float expectedDistance)
|
||||||
|
=> AddAssert($"distance = {distance} -> distance = {expectedDistance} (snapped)", () => composer.GetSnappedDistanceFromDistance(0, distance) == expectedDistance);
|
||||||
|
|
||||||
|
private class TestHitObjectComposer : OsuHitObjectComposer
|
||||||
|
{
|
||||||
|
public new EditorBeatmap<OsuHitObject> EditorBeatmap => base.EditorBeatmap;
|
||||||
|
|
||||||
|
public TestHitObjectComposer()
|
||||||
|
: base(new OsuRuleset())
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
227
osu.Game.Tests/NonVisual/ControlPointInfoTest.cs
Normal file
227
osu.Game.Tests/NonVisual/ControlPointInfoTest.cs
Normal file
@ -0,0 +1,227 @@
|
|||||||
|
// 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 System.Linq;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.NonVisual
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class ControlPointInfoTest
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void TestAdd()
|
||||||
|
{
|
||||||
|
var cpi = new ControlPointInfo();
|
||||||
|
|
||||||
|
cpi.Add(0, new TimingControlPoint());
|
||||||
|
cpi.Add(1000, new TimingControlPoint { BeatLength = 500 });
|
||||||
|
|
||||||
|
Assert.That(cpi.Groups.Count, Is.EqualTo(2));
|
||||||
|
Assert.That(cpi.TimingPoints.Count, Is.EqualTo(2));
|
||||||
|
Assert.That(cpi.AllControlPoints.Count(), Is.EqualTo(2));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestAddRedundantTiming()
|
||||||
|
{
|
||||||
|
var cpi = new ControlPointInfo();
|
||||||
|
|
||||||
|
cpi.Add(0, new TimingControlPoint()); // is *not* redundant, special exception for first timing point.
|
||||||
|
cpi.Add(1000, new TimingControlPoint()); // is redundant
|
||||||
|
|
||||||
|
Assert.That(cpi.Groups.Count, Is.EqualTo(1));
|
||||||
|
Assert.That(cpi.TimingPoints.Count, Is.EqualTo(1));
|
||||||
|
Assert.That(cpi.AllControlPoints.Count(), Is.EqualTo(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestAddRedundantDifficulty()
|
||||||
|
{
|
||||||
|
var cpi = new ControlPointInfo();
|
||||||
|
|
||||||
|
cpi.Add(0, new DifficultyControlPoint()); // is redundant
|
||||||
|
cpi.Add(1000, new DifficultyControlPoint()); // is redundant
|
||||||
|
|
||||||
|
Assert.That(cpi.Groups.Count, Is.EqualTo(0));
|
||||||
|
Assert.That(cpi.TimingPoints.Count, Is.EqualTo(0));
|
||||||
|
Assert.That(cpi.AllControlPoints.Count(), Is.EqualTo(0));
|
||||||
|
|
||||||
|
cpi.Add(1000, new DifficultyControlPoint { SpeedMultiplier = 2 }); // is not redundant
|
||||||
|
|
||||||
|
Assert.That(cpi.Groups.Count, Is.EqualTo(1));
|
||||||
|
Assert.That(cpi.DifficultyPoints.Count, Is.EqualTo(1));
|
||||||
|
Assert.That(cpi.AllControlPoints.Count(), Is.EqualTo(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestAddRedundantSample()
|
||||||
|
{
|
||||||
|
var cpi = new ControlPointInfo();
|
||||||
|
|
||||||
|
cpi.Add(0, new SampleControlPoint()); // is redundant
|
||||||
|
cpi.Add(1000, new SampleControlPoint()); // is redundant
|
||||||
|
|
||||||
|
Assert.That(cpi.Groups.Count, Is.EqualTo(0));
|
||||||
|
Assert.That(cpi.TimingPoints.Count, Is.EqualTo(0));
|
||||||
|
Assert.That(cpi.AllControlPoints.Count(), Is.EqualTo(0));
|
||||||
|
|
||||||
|
cpi.Add(1000, new SampleControlPoint { SampleVolume = 50 }); // is not redundant
|
||||||
|
|
||||||
|
Assert.That(cpi.Groups.Count, Is.EqualTo(1));
|
||||||
|
Assert.That(cpi.SamplePoints.Count, Is.EqualTo(1));
|
||||||
|
Assert.That(cpi.AllControlPoints.Count(), Is.EqualTo(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestAddRedundantEffect()
|
||||||
|
{
|
||||||
|
var cpi = new ControlPointInfo();
|
||||||
|
|
||||||
|
cpi.Add(0, new EffectControlPoint()); // is redundant
|
||||||
|
cpi.Add(1000, new EffectControlPoint()); // is redundant
|
||||||
|
|
||||||
|
Assert.That(cpi.Groups.Count, Is.EqualTo(0));
|
||||||
|
Assert.That(cpi.TimingPoints.Count, Is.EqualTo(0));
|
||||||
|
Assert.That(cpi.AllControlPoints.Count(), Is.EqualTo(0));
|
||||||
|
|
||||||
|
cpi.Add(1000, new EffectControlPoint { KiaiMode = true }); // is not redundant
|
||||||
|
|
||||||
|
Assert.That(cpi.Groups.Count, Is.EqualTo(1));
|
||||||
|
Assert.That(cpi.EffectPoints.Count, Is.EqualTo(1));
|
||||||
|
Assert.That(cpi.AllControlPoints.Count(), Is.EqualTo(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestAddGroup()
|
||||||
|
{
|
||||||
|
var cpi = new ControlPointInfo();
|
||||||
|
|
||||||
|
var group = cpi.GroupAt(1000, true);
|
||||||
|
var group2 = cpi.GroupAt(1000, true);
|
||||||
|
|
||||||
|
Assert.That(group, Is.EqualTo(group2));
|
||||||
|
Assert.That(cpi.Groups.Count, Is.EqualTo(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestGroupAtLookupOnly()
|
||||||
|
{
|
||||||
|
var cpi = new ControlPointInfo();
|
||||||
|
|
||||||
|
var group = cpi.GroupAt(5000, true);
|
||||||
|
Assert.That(group, Is.Not.Null);
|
||||||
|
|
||||||
|
Assert.That(cpi.Groups.Count, Is.EqualTo(1));
|
||||||
|
Assert.That(cpi.GroupAt(1000), Is.Null);
|
||||||
|
Assert.That(cpi.GroupAt(5000), Is.Not.Null);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestAddRemoveGroup()
|
||||||
|
{
|
||||||
|
var cpi = new ControlPointInfo();
|
||||||
|
|
||||||
|
var group = cpi.GroupAt(1000, true);
|
||||||
|
|
||||||
|
Assert.That(cpi.Groups.Count, Is.EqualTo(1));
|
||||||
|
|
||||||
|
cpi.RemoveGroup(group);
|
||||||
|
|
||||||
|
Assert.That(cpi.Groups.Count, Is.EqualTo(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestAddControlPointToGroup()
|
||||||
|
{
|
||||||
|
var cpi = new ControlPointInfo();
|
||||||
|
|
||||||
|
var group = cpi.GroupAt(1000, true);
|
||||||
|
Assert.That(cpi.Groups.Count, Is.EqualTo(1));
|
||||||
|
|
||||||
|
// usually redundant, but adding to group forces it to be added
|
||||||
|
group.Add(new DifficultyControlPoint());
|
||||||
|
|
||||||
|
Assert.That(group.ControlPoints.Count, Is.EqualTo(1));
|
||||||
|
Assert.That(cpi.DifficultyPoints.Count, Is.EqualTo(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestAddDuplicateControlPointToGroup()
|
||||||
|
{
|
||||||
|
var cpi = new ControlPointInfo();
|
||||||
|
|
||||||
|
var group = cpi.GroupAt(1000, true);
|
||||||
|
Assert.That(cpi.Groups.Count, Is.EqualTo(1));
|
||||||
|
|
||||||
|
group.Add(new DifficultyControlPoint());
|
||||||
|
group.Add(new DifficultyControlPoint { SpeedMultiplier = 2 });
|
||||||
|
|
||||||
|
Assert.That(group.ControlPoints.Count, Is.EqualTo(1));
|
||||||
|
Assert.That(cpi.DifficultyPoints.Count, Is.EqualTo(1));
|
||||||
|
Assert.That(cpi.DifficultyPoints.First().SpeedMultiplier, Is.EqualTo(2));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestRemoveControlPointFromGroup()
|
||||||
|
{
|
||||||
|
var cpi = new ControlPointInfo();
|
||||||
|
|
||||||
|
var group = cpi.GroupAt(1000, true);
|
||||||
|
Assert.That(cpi.Groups.Count, Is.EqualTo(1));
|
||||||
|
|
||||||
|
var difficultyPoint = new DifficultyControlPoint();
|
||||||
|
|
||||||
|
group.Add(difficultyPoint);
|
||||||
|
group.Remove(difficultyPoint);
|
||||||
|
|
||||||
|
Assert.That(group.ControlPoints.Count, Is.EqualTo(0));
|
||||||
|
Assert.That(cpi.DifficultyPoints.Count, Is.EqualTo(0));
|
||||||
|
Assert.That(cpi.AllControlPoints.Count, Is.EqualTo(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestOrdering()
|
||||||
|
{
|
||||||
|
var cpi = new ControlPointInfo();
|
||||||
|
|
||||||
|
cpi.Add(0, new TimingControlPoint());
|
||||||
|
cpi.Add(1000, new TimingControlPoint { BeatLength = 500 });
|
||||||
|
cpi.Add(10000, new TimingControlPoint { BeatLength = 200 });
|
||||||
|
cpi.Add(5000, new TimingControlPoint { BeatLength = 100 });
|
||||||
|
cpi.Add(3000, new DifficultyControlPoint { SpeedMultiplier = 2 });
|
||||||
|
cpi.GroupAt(7000, true).Add(new DifficultyControlPoint { SpeedMultiplier = 4 });
|
||||||
|
cpi.GroupAt(1000).Add(new SampleControlPoint { SampleVolume = 0 });
|
||||||
|
cpi.GroupAt(8000, true).Add(new EffectControlPoint { KiaiMode = true });
|
||||||
|
|
||||||
|
Assert.That(cpi.AllControlPoints.Count, Is.EqualTo(8));
|
||||||
|
|
||||||
|
Assert.That(cpi.Groups, Is.Ordered.Ascending.By(nameof(ControlPointGroup.Time)));
|
||||||
|
|
||||||
|
Assert.That(cpi.AllControlPoints, Is.Ordered.Ascending.By(nameof(ControlPoint.Time)));
|
||||||
|
Assert.That(cpi.TimingPoints, Is.Ordered.Ascending.By(nameof(ControlPoint.Time)));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestClear()
|
||||||
|
{
|
||||||
|
var cpi = new ControlPointInfo();
|
||||||
|
|
||||||
|
cpi.Add(0, new TimingControlPoint());
|
||||||
|
cpi.Add(1000, new TimingControlPoint { BeatLength = 500 });
|
||||||
|
cpi.Add(10000, new TimingControlPoint { BeatLength = 200 });
|
||||||
|
cpi.Add(5000, new TimingControlPoint { BeatLength = 100 });
|
||||||
|
cpi.Add(3000, new DifficultyControlPoint { SpeedMultiplier = 2 });
|
||||||
|
cpi.GroupAt(7000, true).Add(new DifficultyControlPoint { SpeedMultiplier = 4 });
|
||||||
|
cpi.GroupAt(1000).Add(new SampleControlPoint { SampleVolume = 0 });
|
||||||
|
cpi.GroupAt(8000, true).Add(new EffectControlPoint { KiaiMode = true });
|
||||||
|
|
||||||
|
cpi.Clear();
|
||||||
|
|
||||||
|
Assert.That(cpi.Groups.Count, Is.EqualTo(0));
|
||||||
|
Assert.That(cpi.DifficultyPoints.Count, Is.EqualTo(0));
|
||||||
|
Assert.That(cpi.AllControlPoints.Count, Is.EqualTo(0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
osu file format v7
|
||||||
|
|
||||||
|
[TimingPoints]
|
||||||
|
0,100,4,2,0,100,1,0
|
||||||
|
12,500,4,2,0,100,1,0
|
||||||
|
1000,-10,4,2,0,100,0,0
|
||||||
|
2000,-54,4,2,0,100,0,0
|
||||||
|
3000,-200,4,2,0,100,0,0
|
@ -0,0 +1,5 @@
|
|||||||
|
osu file format v14
|
||||||
|
|
||||||
|
[TimingPoints]
|
||||||
|
0,-200,4,1,0,100,0,0
|
||||||
|
2000,100,1,1,0,100,1,0
|
@ -1,14 +1,12 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.MathUtils;
|
|
||||||
using osu.Game.Beatmaps;
|
|
||||||
using osu.Game.Beatmaps.ControlPoints;
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
|
using osu.Game.Rulesets.Edit;
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
using osu.Game.Rulesets.Osu.Beatmaps;
|
using osu.Game.Rulesets.Osu.Beatmaps;
|
||||||
using osu.Game.Rulesets.Osu.Objects;
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
@ -27,27 +25,25 @@ namespace osu.Game.Tests.Visual.Editor
|
|||||||
[Cached(typeof(IEditorBeatmap))]
|
[Cached(typeof(IEditorBeatmap))]
|
||||||
private readonly EditorBeatmap<OsuHitObject> editorBeatmap;
|
private readonly EditorBeatmap<OsuHitObject> editorBeatmap;
|
||||||
|
|
||||||
private TestDistanceSnapGrid grid;
|
[Cached(typeof(IDistanceSnapProvider))]
|
||||||
|
private readonly SnapProvider snapProvider = new SnapProvider();
|
||||||
|
|
||||||
public TestSceneDistanceSnapGrid()
|
public TestSceneDistanceSnapGrid()
|
||||||
{
|
{
|
||||||
editorBeatmap = new EditorBeatmap<OsuHitObject>(new OsuBeatmap());
|
editorBeatmap = new EditorBeatmap<OsuHitObject>(new OsuBeatmap());
|
||||||
editorBeatmap.ControlPointInfo.TimingPoints.Add(new TimingControlPoint { BeatLength = beat_length });
|
editorBeatmap.ControlPointInfo.Add(0, new TimingControlPoint { BeatLength = beat_length });
|
||||||
|
|
||||||
createGrid();
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Colour = Color4.SlateGray
|
||||||
|
},
|
||||||
|
new TestDistanceSnapGrid(new HitObject(), grid_position)
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
[SetUp]
|
|
||||||
public void Setup() => Schedule(() =>
|
|
||||||
{
|
|
||||||
Clear();
|
|
||||||
|
|
||||||
editorBeatmap.ControlPointInfo.TimingPoints.Clear();
|
|
||||||
editorBeatmap.ControlPointInfo.TimingPoints.Add(new TimingControlPoint { BeatLength = beat_length });
|
|
||||||
|
|
||||||
BeatDivisor.Value = 1;
|
|
||||||
});
|
|
||||||
|
|
||||||
[TestCase(1)]
|
[TestCase(1)]
|
||||||
[TestCase(2)]
|
[TestCase(2)]
|
||||||
[TestCase(3)]
|
[TestCase(3)]
|
||||||
@ -56,84 +52,13 @@ namespace osu.Game.Tests.Visual.Editor
|
|||||||
[TestCase(8)]
|
[TestCase(8)]
|
||||||
[TestCase(12)]
|
[TestCase(12)]
|
||||||
[TestCase(16)]
|
[TestCase(16)]
|
||||||
public void TestInitialBeatDivisor(int divisor)
|
public void TestBeatDivisor(int divisor)
|
||||||
{
|
{
|
||||||
AddStep($"set beat divisor = {divisor}", () => BeatDivisor.Value = divisor);
|
AddStep($"set beat divisor = {divisor}", () => BeatDivisor.Value = divisor);
|
||||||
createGrid();
|
|
||||||
|
|
||||||
float expectedDistance = (float)beat_length / divisor;
|
|
||||||
AddAssert($"spacing is {expectedDistance}", () => Precision.AlmostEquals(grid.DistanceSpacing, expectedDistance));
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void TestChangeBeatDivisor()
|
|
||||||
{
|
|
||||||
createGrid();
|
|
||||||
AddStep("set beat divisor = 2", () => BeatDivisor.Value = 2);
|
|
||||||
|
|
||||||
const float expected_distance = (float)beat_length / 2;
|
|
||||||
AddAssert($"spacing is {expected_distance}", () => Precision.AlmostEquals(grid.DistanceSpacing, expected_distance));
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestCase(100)]
|
|
||||||
[TestCase(200)]
|
|
||||||
public void TestBeatLength(double beatLength)
|
|
||||||
{
|
|
||||||
AddStep($"set beat length = {beatLength}", () =>
|
|
||||||
{
|
|
||||||
editorBeatmap.ControlPointInfo.TimingPoints.Clear();
|
|
||||||
editorBeatmap.ControlPointInfo.TimingPoints.Add(new TimingControlPoint { BeatLength = beatLength });
|
|
||||||
});
|
|
||||||
|
|
||||||
createGrid();
|
|
||||||
AddAssert($"spacing is {beatLength}", () => Precision.AlmostEquals(grid.DistanceSpacing, beatLength));
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestCase(1)]
|
|
||||||
[TestCase(2)]
|
|
||||||
public void TestGridVelocity(float velocity)
|
|
||||||
{
|
|
||||||
createGrid(g => g.Velocity = velocity);
|
|
||||||
|
|
||||||
float expectedDistance = (float)beat_length * velocity;
|
|
||||||
AddAssert($"spacing is {expectedDistance}", () => Precision.AlmostEquals(grid.DistanceSpacing, expectedDistance));
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void TestGetSnappedTime()
|
|
||||||
{
|
|
||||||
createGrid();
|
|
||||||
|
|
||||||
Vector2 snapPosition = Vector2.Zero;
|
|
||||||
AddStep("get first tick position", () => snapPosition = grid_position + new Vector2((float)beat_length, 0));
|
|
||||||
AddAssert("snap time is 1 beat away", () => Precision.AlmostEquals(beat_length, grid.GetSnapTime(snapPosition), 0.01));
|
|
||||||
|
|
||||||
createGrid(g => g.Velocity = 2, "with velocity = 2");
|
|
||||||
AddAssert("snap time is now 0.5 beats away", () => Precision.AlmostEquals(beat_length / 2, grid.GetSnapTime(snapPosition), 0.01));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createGrid(Action<TestDistanceSnapGrid> func = null, string description = null)
|
|
||||||
{
|
|
||||||
AddStep($"create grid {description ?? string.Empty}", () =>
|
|
||||||
{
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
new Box
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Colour = Color4.SlateGray
|
|
||||||
},
|
|
||||||
grid = new TestDistanceSnapGrid(new HitObject(), grid_position)
|
|
||||||
};
|
|
||||||
|
|
||||||
func?.Invoke(grid);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class TestDistanceSnapGrid : DistanceSnapGrid
|
private class TestDistanceSnapGrid : DistanceSnapGrid
|
||||||
{
|
{
|
||||||
public new float Velocity = 1;
|
|
||||||
|
|
||||||
public new float DistanceSpacing => base.DistanceSpacing;
|
public new float DistanceSpacing => base.DistanceSpacing;
|
||||||
|
|
||||||
public TestDistanceSnapGrid(HitObject hitObject, Vector2 centrePosition)
|
public TestDistanceSnapGrid(HitObject hitObject, Vector2 centrePosition)
|
||||||
@ -203,11 +128,23 @@ namespace osu.Game.Tests.Visual.Editor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override float GetVelocity(double time, ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
|
public override (Vector2 position, double time) GetSnappedPosition(Vector2 screenSpacePosition)
|
||||||
=> Velocity;
|
=> (Vector2.Zero, 0);
|
||||||
|
}
|
||||||
|
|
||||||
public override Vector2 GetSnapPosition(Vector2 screenSpacePosition)
|
private class SnapProvider : IDistanceSnapProvider
|
||||||
=> Vector2.Zero;
|
{
|
||||||
|
public (Vector2 position, double time) GetSnappedPosition(Vector2 position, double time) => (position, time);
|
||||||
|
|
||||||
|
public float GetBeatSnapDistanceAt(double referenceTime) => 10;
|
||||||
|
|
||||||
|
public float DurationToDistance(double referenceTime, double duration) => 0;
|
||||||
|
|
||||||
|
public double DistanceToDuration(double referenceTime, float distance) => 0;
|
||||||
|
|
||||||
|
public double GetSnappedDurationFromDistance(double referenceTime, float distance) => 0;
|
||||||
|
|
||||||
|
public float GetSnappedDistanceFromDistance(double referenceTime, float distance) => 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,18 +28,7 @@ namespace osu.Game.Tests.Visual.Editor
|
|||||||
{
|
{
|
||||||
var testBeatmap = new Beatmap
|
var testBeatmap = new Beatmap
|
||||||
{
|
{
|
||||||
ControlPointInfo = new ControlPointInfo
|
ControlPointInfo = new ControlPointInfo(),
|
||||||
{
|
|
||||||
TimingPoints =
|
|
||||||
{
|
|
||||||
new TimingControlPoint { Time = 0, BeatLength = 200 },
|
|
||||||
new TimingControlPoint { Time = 100, BeatLength = 400 },
|
|
||||||
new TimingControlPoint { Time = 175, BeatLength = 800 },
|
|
||||||
new TimingControlPoint { Time = 350, BeatLength = 200 },
|
|
||||||
new TimingControlPoint { Time = 450, BeatLength = 100 },
|
|
||||||
new TimingControlPoint { Time = 500, BeatLength = 307.69230769230802 }
|
|
||||||
}
|
|
||||||
},
|
|
||||||
HitObjects =
|
HitObjects =
|
||||||
{
|
{
|
||||||
new HitCircle { StartTime = 0 },
|
new HitCircle { StartTime = 0 },
|
||||||
@ -47,6 +36,13 @@ namespace osu.Game.Tests.Visual.Editor
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
testBeatmap.ControlPointInfo.Add(0, new TimingControlPoint { BeatLength = 200 });
|
||||||
|
testBeatmap.ControlPointInfo.Add(100, new TimingControlPoint { BeatLength = 400 });
|
||||||
|
testBeatmap.ControlPointInfo.Add(175, new TimingControlPoint { BeatLength = 800 });
|
||||||
|
testBeatmap.ControlPointInfo.Add(350, new TimingControlPoint { BeatLength = 200 });
|
||||||
|
testBeatmap.ControlPointInfo.Add(450, new TimingControlPoint { BeatLength = 100 });
|
||||||
|
testBeatmap.ControlPointInfo.Add(500, new TimingControlPoint { BeatLength = 307.69230769230802 });
|
||||||
|
|
||||||
Beatmap.Value = CreateWorkingBeatmap(testBeatmap);
|
Beatmap.Value = CreateWorkingBeatmap(testBeatmap);
|
||||||
|
|
||||||
Child = new TimingPointVisualiser(testBeatmap, 5000) { Clock = Clock };
|
Child = new TimingPointVisualiser(testBeatmap, 5000) { Clock = Clock };
|
||||||
|
@ -22,7 +22,7 @@ using osuTK;
|
|||||||
namespace osu.Game.Tests.Visual.Editor
|
namespace osu.Game.Tests.Visual.Editor
|
||||||
{
|
{
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class TestSceneHitObjectComposer : OsuTestScene
|
public class TestSceneHitObjectComposer : EditorClockTestScene
|
||||||
{
|
{
|
||||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||||
{
|
{
|
||||||
|
@ -47,7 +47,8 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestRelativeBeatLengthScaleSingleTimingPoint()
|
public void TestRelativeBeatLengthScaleSingleTimingPoint()
|
||||||
{
|
{
|
||||||
var beatmap = createBeatmap(new TimingControlPoint { BeatLength = time_range / 2 });
|
var beatmap = createBeatmap();
|
||||||
|
beatmap.ControlPointInfo.Add(0, new TimingControlPoint { BeatLength = time_range / 2 });
|
||||||
|
|
||||||
createTest(beatmap, d => d.RelativeScaleBeatLengthsOverride = true);
|
createTest(beatmap, d => d.RelativeScaleBeatLengthsOverride = true);
|
||||||
|
|
||||||
@ -61,10 +62,10 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestRelativeBeatLengthScaleTimingPointBeyondEndDoesNotBecomeDominant()
|
public void TestRelativeBeatLengthScaleTimingPointBeyondEndDoesNotBecomeDominant()
|
||||||
{
|
{
|
||||||
var beatmap = createBeatmap(
|
var beatmap = createBeatmap();
|
||||||
new TimingControlPoint { BeatLength = time_range / 2 },
|
beatmap.ControlPointInfo.Add(0, new TimingControlPoint { BeatLength = time_range / 2 });
|
||||||
new TimingControlPoint { Time = 12000, BeatLength = time_range },
|
beatmap.ControlPointInfo.Add(12000, new TimingControlPoint { BeatLength = time_range });
|
||||||
new TimingControlPoint { Time = 100000, BeatLength = time_range });
|
beatmap.ControlPointInfo.Add(100000, new TimingControlPoint { BeatLength = time_range });
|
||||||
|
|
||||||
createTest(beatmap, d => d.RelativeScaleBeatLengthsOverride = true);
|
createTest(beatmap, d => d.RelativeScaleBeatLengthsOverride = true);
|
||||||
|
|
||||||
@ -75,9 +76,9 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestRelativeBeatLengthScaleFromSecondTimingPoint()
|
public void TestRelativeBeatLengthScaleFromSecondTimingPoint()
|
||||||
{
|
{
|
||||||
var beatmap = createBeatmap(
|
var beatmap = createBeatmap();
|
||||||
new TimingControlPoint { BeatLength = time_range },
|
beatmap.ControlPointInfo.Add(0, new TimingControlPoint { BeatLength = time_range });
|
||||||
new TimingControlPoint { Time = 3 * time_range, BeatLength = time_range / 2 });
|
beatmap.ControlPointInfo.Add(3 * time_range, new TimingControlPoint { BeatLength = time_range / 2 });
|
||||||
|
|
||||||
createTest(beatmap, d => d.RelativeScaleBeatLengthsOverride = true);
|
createTest(beatmap, d => d.RelativeScaleBeatLengthsOverride = true);
|
||||||
|
|
||||||
@ -97,9 +98,9 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestNonRelativeScale()
|
public void TestNonRelativeScale()
|
||||||
{
|
{
|
||||||
var beatmap = createBeatmap(
|
var beatmap = createBeatmap();
|
||||||
new TimingControlPoint { BeatLength = time_range },
|
beatmap.ControlPointInfo.Add(0, new TimingControlPoint { BeatLength = time_range });
|
||||||
new TimingControlPoint { Time = 3 * time_range, BeatLength = time_range / 2 });
|
beatmap.ControlPointInfo.Add(3 * time_range, new TimingControlPoint { BeatLength = time_range / 2 });
|
||||||
|
|
||||||
createTest(beatmap);
|
createTest(beatmap);
|
||||||
|
|
||||||
@ -119,7 +120,8 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestSliderMultiplierDoesNotAffectRelativeBeatLength()
|
public void TestSliderMultiplierDoesNotAffectRelativeBeatLength()
|
||||||
{
|
{
|
||||||
var beatmap = createBeatmap(new TimingControlPoint { BeatLength = time_range });
|
var beatmap = createBeatmap();
|
||||||
|
beatmap.ControlPointInfo.Add(0, new TimingControlPoint { BeatLength = time_range });
|
||||||
beatmap.BeatmapInfo.BaseDifficulty.SliderMultiplier = 2;
|
beatmap.BeatmapInfo.BaseDifficulty.SliderMultiplier = 2;
|
||||||
|
|
||||||
createTest(beatmap, d => d.RelativeScaleBeatLengthsOverride = true);
|
createTest(beatmap, d => d.RelativeScaleBeatLengthsOverride = true);
|
||||||
@ -132,7 +134,8 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestSliderMultiplierAffectsNonRelativeBeatLength()
|
public void TestSliderMultiplierAffectsNonRelativeBeatLength()
|
||||||
{
|
{
|
||||||
var beatmap = createBeatmap(new TimingControlPoint { BeatLength = time_range });
|
var beatmap = createBeatmap();
|
||||||
|
beatmap.ControlPointInfo.Add(0, new TimingControlPoint { BeatLength = time_range });
|
||||||
beatmap.BeatmapInfo.BaseDifficulty.SliderMultiplier = 2;
|
beatmap.BeatmapInfo.BaseDifficulty.SliderMultiplier = 2;
|
||||||
|
|
||||||
createTest(beatmap);
|
createTest(beatmap);
|
||||||
@ -154,14 +157,11 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
/// Creates an <see cref="IBeatmap"/>, containing 10 hitobjects and user-provided timing points.
|
/// Creates an <see cref="IBeatmap"/>, containing 10 hitobjects and user-provided timing points.
|
||||||
/// The hitobjects are spaced <see cref="time_range"/> milliseconds apart.
|
/// The hitobjects are spaced <see cref="time_range"/> milliseconds apart.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="timingControlPoints">The timing points to add to the beatmap.</param>
|
|
||||||
/// <returns>The <see cref="IBeatmap"/>.</returns>
|
/// <returns>The <see cref="IBeatmap"/>.</returns>
|
||||||
private IBeatmap createBeatmap(params TimingControlPoint[] timingControlPoints)
|
private IBeatmap createBeatmap()
|
||||||
{
|
{
|
||||||
var beatmap = new Beatmap<HitObject> { BeatmapInfo = { Ruleset = new OsuRuleset().RulesetInfo } };
|
var beatmap = new Beatmap<HitObject> { BeatmapInfo = { Ruleset = new OsuRuleset().RulesetInfo } };
|
||||||
|
|
||||||
beatmap.ControlPointInfo.TimingPoints.AddRange(timingControlPoints);
|
|
||||||
|
|
||||||
for (int i = 0; i < 10; i++)
|
for (int i = 0; i < 10; i++)
|
||||||
beatmap.HitObjects.Add(new HitObject { StartTime = i * time_range });
|
beatmap.HitObjects.Add(new HitObject { StartTime = i * time_range });
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Screens.Play.HUD;
|
using osu.Game.Screens.Play.HUD;
|
||||||
using osu.Game.Screens.Play.PlayerSettings;
|
using osu.Game.Screens.Play.PlayerSettings;
|
||||||
@ -20,6 +21,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
{
|
{
|
||||||
Anchor = Anchor.TopRight,
|
Anchor = Anchor.TopRight,
|
||||||
Origin = Anchor.TopRight,
|
Origin = Anchor.TopRight,
|
||||||
|
State = { Value = Visibility.Visible }
|
||||||
});
|
});
|
||||||
|
|
||||||
Add(container = new ExampleContainer());
|
Add(container = new ExampleContainer());
|
||||||
|
@ -33,23 +33,15 @@ namespace osu.Game.Tests.Visual.Menus
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestInstantLoad()
|
public void TestInstantLoad()
|
||||||
{
|
{
|
||||||
bool logoVisible = false;
|
// visual only, very impossible to test this using asserts.
|
||||||
|
|
||||||
AddStep("begin loading", () =>
|
AddStep("load immediately", () =>
|
||||||
{
|
{
|
||||||
loader = new TestLoader();
|
loader = new TestLoader();
|
||||||
loader.AllowLoad.Set();
|
loader.AllowLoad.Set();
|
||||||
|
|
||||||
LoadScreen(loader);
|
LoadScreen(loader);
|
||||||
});
|
});
|
||||||
|
|
||||||
AddUntilStep("loaded", () =>
|
|
||||||
{
|
|
||||||
logoVisible = loader.Logo?.Alpha > 0;
|
|
||||||
return loader.Logo != null && loader.ScreenLoaded;
|
|
||||||
});
|
|
||||||
|
|
||||||
AddAssert("logo was not visible", () => !logoVisible);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -58,7 +50,7 @@ namespace osu.Game.Tests.Visual.Menus
|
|||||||
AddStep("begin loading", () => LoadScreen(loader = new TestLoader()));
|
AddStep("begin loading", () => LoadScreen(loader = new TestLoader()));
|
||||||
AddUntilStep("wait for logo visible", () => loader.Logo?.Alpha > 0);
|
AddUntilStep("wait for logo visible", () => loader.Logo?.Alpha > 0);
|
||||||
AddStep("finish loading", () => loader.AllowLoad.Set());
|
AddStep("finish loading", () => loader.AllowLoad.Set());
|
||||||
AddAssert("loaded", () => loader.Logo != null && loader.ScreenLoaded);
|
AddUntilStep("loaded", () => loader.Logo != null && loader.ScreenLoaded);
|
||||||
AddUntilStep("logo gone", () => loader.Logo?.Alpha == 0);
|
AddUntilStep("logo gone", () => loader.Logo?.Alpha == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,8 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
typeof(HeaderButton),
|
typeof(HeaderButton),
|
||||||
typeof(SortTabControl),
|
typeof(SortTabControl),
|
||||||
typeof(ShowChildrenButton),
|
typeof(ShowChildrenButton),
|
||||||
typeof(DeletedChildrenPlaceholder)
|
typeof(DeletedChildrenPlaceholder),
|
||||||
|
typeof(VotePill)
|
||||||
};
|
};
|
||||||
|
|
||||||
protected override bool UseOnlineAPI => true;
|
protected override bool UseOnlineAPI => true;
|
||||||
|
@ -6,6 +6,11 @@ using osu.Framework.Graphics;
|
|||||||
using osu.Game.Online.Chat;
|
using osu.Game.Online.Chat;
|
||||||
using osu.Game.Users;
|
using osu.Game.Users;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Game.Graphics.Containers;
|
||||||
|
using osu.Game.Overlays.Chat;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Online
|
namespace osu.Game.Tests.Visual.Online
|
||||||
{
|
{
|
||||||
@ -41,14 +46,14 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
[Cached]
|
[Cached]
|
||||||
private ChannelManager channelManager = new ChannelManager();
|
private ChannelManager channelManager = new ChannelManager();
|
||||||
|
|
||||||
private readonly StandAloneChatDisplay chatDisplay;
|
private readonly TestStandAloneChatDisplay chatDisplay;
|
||||||
private readonly StandAloneChatDisplay chatDisplay2;
|
private readonly TestStandAloneChatDisplay chatDisplay2;
|
||||||
|
|
||||||
public TestSceneStandAloneChatDisplay()
|
public TestSceneStandAloneChatDisplay()
|
||||||
{
|
{
|
||||||
Add(channelManager);
|
Add(channelManager);
|
||||||
|
|
||||||
Add(chatDisplay = new StandAloneChatDisplay
|
Add(chatDisplay = new TestStandAloneChatDisplay
|
||||||
{
|
{
|
||||||
Anchor = Anchor.CentreLeft,
|
Anchor = Anchor.CentreLeft,
|
||||||
Origin = Anchor.CentreLeft,
|
Origin = Anchor.CentreLeft,
|
||||||
@ -56,7 +61,7 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
Size = new Vector2(400, 80)
|
Size = new Vector2(400, 80)
|
||||||
});
|
});
|
||||||
|
|
||||||
Add(chatDisplay2 = new StandAloneChatDisplay(true)
|
Add(chatDisplay2 = new TestStandAloneChatDisplay(true)
|
||||||
{
|
{
|
||||||
Anchor = Anchor.CentreRight,
|
Anchor = Anchor.CentreRight,
|
||||||
Origin = Anchor.CentreRight,
|
Origin = Anchor.CentreRight,
|
||||||
@ -111,6 +116,56 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
Sender = longUsernameUser,
|
Sender = longUsernameUser,
|
||||||
Content = "Hi guys, my new username is lit!"
|
Content = "Hi guys, my new username is lit!"
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
AddStep("message with new date", () => testChannel.AddNewMessages(new Message(sequence++)
|
||||||
|
{
|
||||||
|
Sender = longUsernameUser,
|
||||||
|
Content = "Message from the future!",
|
||||||
|
Timestamp = DateTimeOffset.Now
|
||||||
|
}));
|
||||||
|
|
||||||
|
AddUntilStep("ensure still scrolled to bottom", () => chatDisplay.ScrolledToBottom);
|
||||||
|
|
||||||
|
const int messages_per_call = 10;
|
||||||
|
AddRepeatStep("add many messages", () =>
|
||||||
|
{
|
||||||
|
for (int i = 0; i < messages_per_call; i++)
|
||||||
|
testChannel.AddNewMessages(new Message(sequence++)
|
||||||
|
{
|
||||||
|
Sender = longUsernameUser,
|
||||||
|
Content = "Many messages! " + Guid.NewGuid(),
|
||||||
|
Timestamp = DateTimeOffset.Now
|
||||||
|
});
|
||||||
|
}, Channel.MAX_HISTORY / messages_per_call + 5);
|
||||||
|
|
||||||
|
AddAssert("Ensure no adjacent day separators", () =>
|
||||||
|
{
|
||||||
|
var indices = chatDisplay.FillFlow.OfType<DrawableChannel.DaySeparator>().Select(ds => chatDisplay.FillFlow.IndexOf(ds));
|
||||||
|
|
||||||
|
foreach (var i in indices)
|
||||||
|
if (i < chatDisplay.FillFlow.Count && chatDisplay.FillFlow[i + 1] is DrawableChannel.DaySeparator)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
AddUntilStep("ensure still scrolled to bottom", () => chatDisplay.ScrolledToBottom);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class TestStandAloneChatDisplay : StandAloneChatDisplay
|
||||||
|
{
|
||||||
|
public TestStandAloneChatDisplay(bool textbox = false)
|
||||||
|
: base(textbox)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected DrawableChannel DrawableChannel => InternalChildren.OfType<DrawableChannel>().First();
|
||||||
|
|
||||||
|
protected OsuScrollContainer ScrollContainer => (OsuScrollContainer)((Container)DrawableChannel.Child).Child;
|
||||||
|
|
||||||
|
public FillFlowContainer FillFlow => (FillFlowContainer)ScrollContainer.Child;
|
||||||
|
|
||||||
|
public bool ScrolledToBottom => ScrollContainer.IsScrolledToEnd(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -245,6 +245,28 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
AddAssert($"Check #{set_count} is at bottom", () => carousel.BeatmapSets.Last().Metadata.Title.EndsWith($"#{set_count}!"));
|
AddAssert($"Check #{set_count} is at bottom", () => carousel.BeatmapSets.Last().Metadata.Title.EndsWith($"#{set_count}!"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestSortingStability()
|
||||||
|
{
|
||||||
|
var sets = new List<BeatmapSetInfo>();
|
||||||
|
|
||||||
|
for (int i = 0; i < 20; i++)
|
||||||
|
{
|
||||||
|
var set = createTestBeatmapSet(i);
|
||||||
|
set.Metadata.Artist = "same artist";
|
||||||
|
set.Metadata.Title = "same title";
|
||||||
|
sets.Add(set);
|
||||||
|
}
|
||||||
|
|
||||||
|
loadBeatmaps(sets);
|
||||||
|
|
||||||
|
AddStep("Sort by artist", () => carousel.Filter(new FilterCriteria { Sort = SortMode.Artist }, false));
|
||||||
|
AddAssert("Items remain in original order", () => carousel.BeatmapSets.Select((set, index) => set.ID == index).All(b => b));
|
||||||
|
|
||||||
|
AddStep("Sort by title", () => carousel.Filter(new FilterCriteria { Sort = SortMode.Title }, false));
|
||||||
|
AddAssert("Items remain in original order", () => carousel.BeatmapSets.Select((set, index) => set.ID == index).All(b => b));
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestSortingWithFiltered()
|
public void TestSortingWithFiltered()
|
||||||
{
|
{
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Audio.Track;
|
using osu.Framework.Audio.Track;
|
||||||
@ -10,7 +11,6 @@ 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.Lists;
|
|
||||||
using osu.Framework.Timing;
|
using osu.Framework.Timing;
|
||||||
using osu.Game.Beatmaps.ControlPoints;
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
@ -153,7 +153,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private SortedList<TimingControlPoint> timingPoints => Beatmap.Value.Beatmap.ControlPointInfo.TimingPoints;
|
private List<TimingControlPoint> timingPoints => Beatmap.Value.Beatmap.ControlPointInfo.TimingPoints.ToList();
|
||||||
|
|
||||||
private TimingControlPoint getNextTimingPoint(TimingControlPoint current)
|
private TimingControlPoint getNextTimingPoint(TimingControlPoint current)
|
||||||
{
|
{
|
||||||
|
@ -11,7 +11,7 @@ using osuTK.Graphics;
|
|||||||
|
|
||||||
namespace osu.Game.Tests.Visual.UserInterface
|
namespace osu.Game.Tests.Visual.UserInterface
|
||||||
{
|
{
|
||||||
public class TestSceneLabelledComponent : OsuTestScene
|
public class TestSceneLabelledDrawable : OsuTestScene
|
||||||
{
|
{
|
||||||
[TestCase(false)]
|
[TestCase(false)]
|
||||||
[TestCase(true)]
|
[TestCase(true)]
|
||||||
@ -25,7 +25,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
{
|
{
|
||||||
AddStep("create component", () =>
|
AddStep("create component", () =>
|
||||||
{
|
{
|
||||||
LabelledComponent<Drawable> component;
|
LabelledDrawable<Drawable> component;
|
||||||
|
|
||||||
Child = new Container
|
Child = new Container
|
||||||
{
|
{
|
||||||
@ -33,7 +33,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
Width = 500,
|
Width = 500,
|
||||||
AutoSizeAxes = Axes.Y,
|
AutoSizeAxes = Axes.Y,
|
||||||
Child = component = padded ? (LabelledComponent<Drawable>)new PaddedLabelledComponent() : new NonPaddedLabelledComponent(),
|
Child = component = padded ? (LabelledDrawable<Drawable>)new PaddedLabelledDrawable() : new NonPaddedLabelledDrawable(),
|
||||||
};
|
};
|
||||||
|
|
||||||
component.Label = "a sample component";
|
component.Label = "a sample component";
|
||||||
@ -41,9 +41,9 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private class PaddedLabelledComponent : LabelledComponent<Drawable>
|
private class PaddedLabelledDrawable : LabelledDrawable<Drawable>
|
||||||
{
|
{
|
||||||
public PaddedLabelledComponent()
|
public PaddedLabelledDrawable()
|
||||||
: base(true)
|
: base(true)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -57,9 +57,9 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private class NonPaddedLabelledComponent : LabelledComponent<Drawable>
|
private class NonPaddedLabelledDrawable : LabelledDrawable<Drawable>
|
||||||
{
|
{
|
||||||
public NonPaddedLabelledComponent()
|
public NonPaddedLabelledDrawable()
|
||||||
: base(false)
|
: base(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
@ -7,7 +7,6 @@ using NUnit.Framework;
|
|||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Game.Graphics.UserInterface;
|
|
||||||
using osu.Game.Graphics.UserInterfaceV2;
|
using osu.Game.Graphics.UserInterfaceV2;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.UserInterface
|
namespace osu.Game.Tests.Visual.UserInterface
|
||||||
@ -28,7 +27,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
{
|
{
|
||||||
AddStep("create component", () =>
|
AddStep("create component", () =>
|
||||||
{
|
{
|
||||||
LabelledComponent<OsuTextBox> component;
|
LabelledTextBox component;
|
||||||
|
|
||||||
Child = new Container
|
Child = new Container
|
||||||
{
|
{
|
||||||
|
@ -89,7 +89,7 @@ namespace osu.Game.Tournament.Screens
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ActionableInfo : LabelledComponent<Drawable>
|
private class ActionableInfo : LabelledDrawable<Drawable>
|
||||||
{
|
{
|
||||||
private OsuButton button;
|
private OsuButton button;
|
||||||
|
|
||||||
|
@ -1,25 +1,30 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace osu.Game.Beatmaps.ControlPoints
|
namespace osu.Game.Beatmaps.ControlPoints
|
||||||
{
|
{
|
||||||
public class ControlPoint : IComparable<ControlPoint>, IEquatable<ControlPoint>
|
public abstract class ControlPoint : IComparable<ControlPoint>, IEquatable<ControlPoint>
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The time at which the control point takes effect.
|
/// The time at which the control point takes effect.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double Time;
|
public double Time => controlPointGroup?.Time ?? 0;
|
||||||
|
|
||||||
/// <summary>
|
private ControlPointGroup controlPointGroup;
|
||||||
/// Whether this timing point was generated internally, as opposed to parsed from the underlying beatmap.
|
|
||||||
/// </summary>
|
public void AttachGroup(ControlPointGroup pointGroup) => this.controlPointGroup = pointGroup;
|
||||||
internal bool AutoGenerated;
|
|
||||||
|
|
||||||
public int CompareTo(ControlPoint other) => Time.CompareTo(other.Time);
|
public int CompareTo(ControlPoint other) => Time.CompareTo(other.Time);
|
||||||
|
|
||||||
public bool Equals(ControlPoint other)
|
/// <summary>
|
||||||
=> Time.Equals(other?.Time);
|
/// Whether this control point is equivalent to another, ignoring time.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="other">Another control point to compare with.</param>
|
||||||
|
/// <returns>Whether equivalent.</returns>
|
||||||
|
public abstract bool EquivalentTo(ControlPoint other);
|
||||||
|
|
||||||
|
public bool Equals(ControlPoint other) => Time.Equals(other?.Time) && EquivalentTo(other);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
50
osu.Game/Beatmaps/ControlPoints/ControlPointGroup.cs
Normal file
50
osu.Game/Beatmaps/ControlPoints/ControlPointGroup.cs
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
// 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 System;
|
||||||
|
using System.Linq;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
|
|
||||||
|
namespace osu.Game.Beatmaps.ControlPoints
|
||||||
|
{
|
||||||
|
public class ControlPointGroup : IComparable<ControlPointGroup>
|
||||||
|
{
|
||||||
|
public event Action<ControlPoint> ItemAdded;
|
||||||
|
public event Action<ControlPoint> ItemRemoved;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The time at which the control point takes effect.
|
||||||
|
/// </summary>
|
||||||
|
public double Time { get; }
|
||||||
|
|
||||||
|
public IBindableList<ControlPoint> ControlPoints => controlPoints;
|
||||||
|
|
||||||
|
private readonly BindableList<ControlPoint> controlPoints = new BindableList<ControlPoint>();
|
||||||
|
|
||||||
|
public ControlPointGroup(double time)
|
||||||
|
{
|
||||||
|
Time = time;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int CompareTo(ControlPointGroup other) => Time.CompareTo(other.Time);
|
||||||
|
|
||||||
|
public void Add(ControlPoint point)
|
||||||
|
{
|
||||||
|
var existing = controlPoints.FirstOrDefault(p => p.GetType() == point.GetType());
|
||||||
|
|
||||||
|
if (existing != null)
|
||||||
|
Remove(existing);
|
||||||
|
|
||||||
|
point.AttachGroup(this);
|
||||||
|
|
||||||
|
controlPoints.Add(point);
|
||||||
|
ItemAdded?.Invoke(point);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Remove(ControlPoint point)
|
||||||
|
{
|
||||||
|
controlPoints.Remove(point);
|
||||||
|
ItemRemoved?.Invoke(point);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -5,6 +5,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Lists;
|
using osu.Framework.Lists;
|
||||||
|
|
||||||
namespace osu.Game.Beatmaps.ControlPoints
|
namespace osu.Game.Beatmaps.ControlPoints
|
||||||
@ -12,57 +13,78 @@ namespace osu.Game.Beatmaps.ControlPoints
|
|||||||
[Serializable]
|
[Serializable]
|
||||||
public class ControlPointInfo
|
public class ControlPointInfo
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// All control points grouped by time.
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty]
|
||||||
|
public IBindableList<ControlPointGroup> Groups => groups;
|
||||||
|
|
||||||
|
private readonly BindableList<ControlPointGroup> groups = new BindableList<ControlPointGroup>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// All timing points.
|
/// All timing points.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonProperty]
|
[JsonProperty]
|
||||||
public SortedList<TimingControlPoint> TimingPoints { get; private set; } = new SortedList<TimingControlPoint>(Comparer<TimingControlPoint>.Default);
|
public IReadOnlyList<TimingControlPoint> TimingPoints => timingPoints;
|
||||||
|
|
||||||
|
private readonly SortedList<TimingControlPoint> timingPoints = new SortedList<TimingControlPoint>(Comparer<TimingControlPoint>.Default);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// All difficulty points.
|
/// All difficulty points.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonProperty]
|
[JsonProperty]
|
||||||
public SortedList<DifficultyControlPoint> DifficultyPoints { get; private set; } = new SortedList<DifficultyControlPoint>(Comparer<DifficultyControlPoint>.Default);
|
public IReadOnlyList<DifficultyControlPoint> DifficultyPoints => difficultyPoints;
|
||||||
|
|
||||||
|
private readonly SortedList<DifficultyControlPoint> difficultyPoints = new SortedList<DifficultyControlPoint>(Comparer<DifficultyControlPoint>.Default);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// All sound points.
|
/// All sound points.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonProperty]
|
[JsonProperty]
|
||||||
public SortedList<SampleControlPoint> SamplePoints { get; private set; } = new SortedList<SampleControlPoint>(Comparer<SampleControlPoint>.Default);
|
public IReadOnlyList<SampleControlPoint> SamplePoints => samplePoints;
|
||||||
|
|
||||||
|
private readonly SortedList<SampleControlPoint> samplePoints = new SortedList<SampleControlPoint>(Comparer<SampleControlPoint>.Default);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// All effect points.
|
/// All effect points.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonProperty]
|
[JsonProperty]
|
||||||
public SortedList<EffectControlPoint> EffectPoints { get; private set; } = new SortedList<EffectControlPoint>(Comparer<EffectControlPoint>.Default);
|
public IReadOnlyList<EffectControlPoint> EffectPoints => effectPoints;
|
||||||
|
|
||||||
|
private readonly SortedList<EffectControlPoint> effectPoints = new SortedList<EffectControlPoint>(Comparer<EffectControlPoint>.Default);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// All control points, of all types.
|
||||||
|
/// </summary>
|
||||||
|
public IEnumerable<ControlPoint> AllControlPoints => Groups.SelectMany(g => g.ControlPoints).ToArray();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Finds the difficulty control point that is active at <paramref name="time"/>.
|
/// Finds the difficulty control point that is active at <paramref name="time"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="time">The time to find the difficulty control point at.</param>
|
/// <param name="time">The time to find the difficulty control point at.</param>
|
||||||
/// <returns>The difficulty control point.</returns>
|
/// <returns>The difficulty control point.</returns>
|
||||||
public DifficultyControlPoint DifficultyPointAt(double time) => binarySearch(DifficultyPoints, time);
|
public DifficultyControlPoint DifficultyPointAt(double time) => binarySearchWithFallback(DifficultyPoints, time);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Finds the effect control point that is active at <paramref name="time"/>.
|
/// Finds the effect control point that is active at <paramref name="time"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="time">The time to find the effect control point at.</param>
|
/// <param name="time">The time to find the effect control point at.</param>
|
||||||
/// <returns>The effect control point.</returns>
|
/// <returns>The effect control point.</returns>
|
||||||
public EffectControlPoint EffectPointAt(double time) => binarySearch(EffectPoints, time);
|
public EffectControlPoint EffectPointAt(double time) => binarySearchWithFallback(EffectPoints, time);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Finds the sound control point that is active at <paramref name="time"/>.
|
/// Finds the sound control point that is active at <paramref name="time"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="time">The time to find the sound control point at.</param>
|
/// <param name="time">The time to find the sound control point at.</param>
|
||||||
/// <returns>The sound control point.</returns>
|
/// <returns>The sound control point.</returns>
|
||||||
public SampleControlPoint SamplePointAt(double time) => binarySearch(SamplePoints, time, SamplePoints.Count > 0 ? SamplePoints[0] : null);
|
public SampleControlPoint SamplePointAt(double time) => binarySearchWithFallback(SamplePoints, time, SamplePoints.Count > 0 ? SamplePoints[0] : null);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Finds the timing control point that is active at <paramref name="time"/>.
|
/// Finds the timing control point that is active at <paramref name="time"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="time">The time to find the timing control point at.</param>
|
/// <param name="time">The time to find the timing control point at.</param>
|
||||||
/// <returns>The timing control point.</returns>
|
/// <returns>The timing control point.</returns>
|
||||||
public TimingControlPoint TimingPointAt(double time) => binarySearch(TimingPoints, time, TimingPoints.Count > 0 ? TimingPoints[0] : null);
|
public TimingControlPoint TimingPointAt(double time) => binarySearchWithFallback(TimingPoints, time, TimingPoints.Count > 0 ? TimingPoints[0] : null);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Finds the maximum BPM represented by any timing control point.
|
/// Finds the maximum BPM represented by any timing control point.
|
||||||
@ -85,24 +107,93 @@ namespace osu.Game.Beatmaps.ControlPoints
|
|||||||
public double BPMMode =>
|
public double BPMMode =>
|
||||||
60000 / (TimingPoints.GroupBy(c => c.BeatLength).OrderByDescending(grp => grp.Count()).FirstOrDefault()?.FirstOrDefault() ?? new TimingControlPoint()).BeatLength;
|
60000 / (TimingPoints.GroupBy(c => c.BeatLength).OrderByDescending(grp => grp.Count()).FirstOrDefault()?.FirstOrDefault() ?? new TimingControlPoint()).BeatLength;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Remove all <see cref="ControlPointGroup"/>s and return to a pristine state.
|
||||||
|
/// </summary>
|
||||||
|
public void Clear()
|
||||||
|
{
|
||||||
|
groups.Clear();
|
||||||
|
timingPoints.Clear();
|
||||||
|
difficultyPoints.Clear();
|
||||||
|
samplePoints.Clear();
|
||||||
|
effectPoints.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Add a new <see cref="ControlPoint"/>. Note that the provided control point may not be added if the correct state is already present at the provided time.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="time">The time at which the control point should be added.</param>
|
||||||
|
/// <param name="controlPoint">The control point to add.</param>
|
||||||
|
/// <returns>Whether the control point was added.</returns>
|
||||||
|
public bool Add(double time, ControlPoint controlPoint)
|
||||||
|
{
|
||||||
|
if (checkAlreadyExisting(time, controlPoint))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
GroupAt(time, true).Add(controlPoint);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ControlPointGroup GroupAt(double time, bool addIfNotExisting = false)
|
||||||
|
{
|
||||||
|
var newGroup = new ControlPointGroup(time);
|
||||||
|
|
||||||
|
int i = groups.BinarySearch(newGroup);
|
||||||
|
|
||||||
|
if (i >= 0)
|
||||||
|
return groups[i];
|
||||||
|
|
||||||
|
if (addIfNotExisting)
|
||||||
|
{
|
||||||
|
newGroup.ItemAdded += groupItemAdded;
|
||||||
|
newGroup.ItemRemoved += groupItemRemoved;
|
||||||
|
|
||||||
|
groups.Insert(~i, newGroup);
|
||||||
|
return newGroup;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RemoveGroup(ControlPointGroup group)
|
||||||
|
{
|
||||||
|
group.ItemAdded -= groupItemAdded;
|
||||||
|
group.ItemRemoved -= groupItemRemoved;
|
||||||
|
|
||||||
|
groups.Remove(group);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Binary searches one of the control point lists to find the active control point at <paramref name="time"/>.
|
/// Binary searches one of the control point lists to find the active control point at <paramref name="time"/>.
|
||||||
|
/// Includes logic for returning a specific point when no matching point is found.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="list">The list to search.</param>
|
/// <param name="list">The list to search.</param>
|
||||||
/// <param name="time">The time to find the control point at.</param>
|
/// <param name="time">The time to find the control point at.</param>
|
||||||
/// <param name="prePoint">The control point to use when <paramref name="time"/> is before any control points. If null, a new control point will be constructed.</param>
|
/// <param name="prePoint">The control point to use when <paramref name="time"/> is before any control points. If null, a new control point will be constructed.</param>
|
||||||
/// <returns>The active control point at <paramref name="time"/>.</returns>
|
/// <returns>The active control point at <paramref name="time"/>, or a fallback <see cref="ControlPoint"/> if none found.</returns>
|
||||||
private T binarySearch<T>(SortedList<T> list, double time, T prePoint = null)
|
private T binarySearchWithFallback<T>(IReadOnlyList<T> list, double time, T prePoint = null)
|
||||||
where T : ControlPoint, new()
|
where T : ControlPoint, new()
|
||||||
|
{
|
||||||
|
return binarySearch(list, time) ?? prePoint ?? new T();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Binary searches one of the control point lists to find the active control point at <paramref name="time"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="list">The list to search.</param>
|
||||||
|
/// <param name="time">The time to find the control point at.</param>
|
||||||
|
/// <returns>The active control point at <paramref name="time"/>.</returns>
|
||||||
|
private T binarySearch<T>(IReadOnlyList<T> list, double time)
|
||||||
|
where T : ControlPoint
|
||||||
{
|
{
|
||||||
if (list == null)
|
if (list == null)
|
||||||
throw new ArgumentNullException(nameof(list));
|
throw new ArgumentNullException(nameof(list));
|
||||||
|
|
||||||
if (list.Count == 0)
|
if (list.Count == 0)
|
||||||
return new T();
|
return null;
|
||||||
|
|
||||||
if (time < list[0].Time)
|
if (time < list[0].Time)
|
||||||
return prePoint ?? new T();
|
return null;
|
||||||
|
|
||||||
if (time >= list[list.Count - 1].Time)
|
if (time >= list[list.Count - 1].Time)
|
||||||
return list[list.Count - 1];
|
return list[list.Count - 1];
|
||||||
@ -125,5 +216,82 @@ namespace osu.Game.Beatmaps.ControlPoints
|
|||||||
// l will be the first control point with Time > time, but we want the one before it
|
// l will be the first control point with Time > time, but we want the one before it
|
||||||
return list[l - 1];
|
return list[l - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Check whether <see cref="newPoint"/> should be added.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="time">The time to find the timing control point at.</param>
|
||||||
|
/// <param name="newPoint">A point to be added.</param>
|
||||||
|
/// <returns>Whether the new point should be added.</returns>
|
||||||
|
private bool checkAlreadyExisting(double time, ControlPoint newPoint)
|
||||||
|
{
|
||||||
|
ControlPoint existing = null;
|
||||||
|
|
||||||
|
switch (newPoint)
|
||||||
|
{
|
||||||
|
case TimingControlPoint _:
|
||||||
|
// Timing points are a special case and need to be added regardless of fallback availability.
|
||||||
|
existing = binarySearch(TimingPoints, time);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EffectControlPoint _:
|
||||||
|
existing = EffectPointAt(time);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SampleControlPoint _:
|
||||||
|
existing = SamplePointAt(time);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DifficultyControlPoint _:
|
||||||
|
existing = DifficultyPointAt(time);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return existing?.EquivalentTo(newPoint) == true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void groupItemAdded(ControlPoint controlPoint)
|
||||||
|
{
|
||||||
|
switch (controlPoint)
|
||||||
|
{
|
||||||
|
case TimingControlPoint typed:
|
||||||
|
timingPoints.Add(typed);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EffectControlPoint typed:
|
||||||
|
effectPoints.Add(typed);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SampleControlPoint typed:
|
||||||
|
samplePoints.Add(typed);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DifficultyControlPoint typed:
|
||||||
|
difficultyPoints.Add(typed);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void groupItemRemoved(ControlPoint controlPoint)
|
||||||
|
{
|
||||||
|
switch (controlPoint)
|
||||||
|
{
|
||||||
|
case TimingControlPoint typed:
|
||||||
|
timingPoints.Remove(typed);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EffectControlPoint typed:
|
||||||
|
effectPoints.Remove(typed);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SampleControlPoint typed:
|
||||||
|
samplePoints.Remove(typed);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DifficultyControlPoint typed:
|
||||||
|
difficultyPoints.Remove(typed);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,26 +1,33 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using osu.Framework.Bindables;
|
||||||
using osuTK;
|
|
||||||
|
|
||||||
namespace osu.Game.Beatmaps.ControlPoints
|
namespace osu.Game.Beatmaps.ControlPoints
|
||||||
{
|
{
|
||||||
public class DifficultyControlPoint : ControlPoint, IEquatable<DifficultyControlPoint>
|
public class DifficultyControlPoint : ControlPoint
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The speed multiplier at this control point.
|
||||||
|
/// </summary>
|
||||||
|
public readonly BindableDouble SpeedMultiplierBindable = new BindableDouble(1)
|
||||||
|
{
|
||||||
|
Precision = 0.1,
|
||||||
|
Default = 1,
|
||||||
|
MinValue = 0.1,
|
||||||
|
MaxValue = 10
|
||||||
|
};
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The speed multiplier at this control point.
|
/// The speed multiplier at this control point.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double SpeedMultiplier
|
public double SpeedMultiplier
|
||||||
{
|
{
|
||||||
get => speedMultiplier;
|
get => SpeedMultiplierBindable.Value;
|
||||||
set => speedMultiplier = MathHelper.Clamp(value, 0.1, 10);
|
set => SpeedMultiplierBindable.Value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
private double speedMultiplier = 1;
|
public override bool EquivalentTo(ControlPoint other) =>
|
||||||
|
other is DifficultyControlPoint otherTyped && otherTyped.SpeedMultiplier.Equals(SpeedMultiplier);
|
||||||
public bool Equals(DifficultyControlPoint other)
|
|
||||||
=> base.Equals(other)
|
|
||||||
&& SpeedMultiplier.Equals(other?.SpeedMultiplier);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,42 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using osu.Framework.Bindables;
|
||||||
|
|
||||||
namespace osu.Game.Beatmaps.ControlPoints
|
namespace osu.Game.Beatmaps.ControlPoints
|
||||||
{
|
{
|
||||||
public class EffectControlPoint : ControlPoint, IEquatable<EffectControlPoint>
|
public class EffectControlPoint : ControlPoint
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether this control point enables Kiai mode.
|
/// Whether the first bar line of this control point is ignored.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool KiaiMode;
|
public readonly BindableBool OmitFirstBarLineBindable = new BindableBool();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether the first bar line of this control point is ignored.
|
/// Whether the first bar line of this control point is ignored.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool OmitFirstBarLine;
|
public bool OmitFirstBarLine
|
||||||
|
{
|
||||||
|
get => OmitFirstBarLineBindable.Value;
|
||||||
|
set => OmitFirstBarLineBindable.Value = value;
|
||||||
|
}
|
||||||
|
|
||||||
public bool Equals(EffectControlPoint other)
|
/// <summary>
|
||||||
=> base.Equals(other)
|
/// Whether this control point enables Kiai mode.
|
||||||
&& KiaiMode == other?.KiaiMode && OmitFirstBarLine == other.OmitFirstBarLine;
|
/// </summary>
|
||||||
|
public readonly BindableBool KiaiModeBindable = new BindableBool();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether this control point enables Kiai mode.
|
||||||
|
/// </summary>
|
||||||
|
public bool KiaiMode
|
||||||
|
{
|
||||||
|
get => KiaiModeBindable.Value;
|
||||||
|
set => KiaiModeBindable.Value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool EquivalentTo(ControlPoint other) =>
|
||||||
|
other is EffectControlPoint otherTyped &&
|
||||||
|
KiaiMode == otherTyped.KiaiMode && OmitFirstBarLine == otherTyped.OmitFirstBarLine;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,47 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using osu.Framework.Bindables;
|
||||||
using osu.Game.Audio;
|
using osu.Game.Audio;
|
||||||
|
|
||||||
namespace osu.Game.Beatmaps.ControlPoints
|
namespace osu.Game.Beatmaps.ControlPoints
|
||||||
{
|
{
|
||||||
public class SampleControlPoint : ControlPoint, IEquatable<SampleControlPoint>
|
public class SampleControlPoint : ControlPoint
|
||||||
{
|
{
|
||||||
public const string DEFAULT_BANK = "normal";
|
public const string DEFAULT_BANK = "normal";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The default sample bank at this control point.
|
/// The default sample bank at this control point.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string SampleBank = DEFAULT_BANK;
|
public readonly Bindable<string> SampleBankBindable = new Bindable<string>(DEFAULT_BANK) { Default = DEFAULT_BANK };
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The speed multiplier at this control point.
|
||||||
|
/// </summary>
|
||||||
|
public string SampleBank
|
||||||
|
{
|
||||||
|
get => SampleBankBindable.Value;
|
||||||
|
set => SampleBankBindable.Value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The default sample bank at this control point.
|
||||||
|
/// </summary>
|
||||||
|
public readonly BindableInt SampleVolumeBindable = new BindableInt(100)
|
||||||
|
{
|
||||||
|
MinValue = 0,
|
||||||
|
MaxValue = 100,
|
||||||
|
Default = 100
|
||||||
|
};
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The default sample volume at this control point.
|
/// The default sample volume at this control point.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int SampleVolume = 100;
|
public int SampleVolume
|
||||||
|
{
|
||||||
|
get => SampleVolumeBindable.Value;
|
||||||
|
set => SampleVolumeBindable.Value = value;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a SampleInfo based on the sample settings in this control point.
|
/// Create a SampleInfo based on the sample settings in this control point.
|
||||||
@ -45,8 +68,8 @@ namespace osu.Game.Beatmaps.ControlPoints
|
|||||||
return newSampleInfo;
|
return newSampleInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Equals(SampleControlPoint other)
|
public override bool EquivalentTo(ControlPoint other) =>
|
||||||
=> base.Equals(other)
|
other is SampleControlPoint otherTyped &&
|
||||||
&& string.Equals(SampleBank, other?.SampleBank) && SampleVolume == other?.SampleVolume;
|
string.Equals(SampleBank, otherTyped.SampleBank) && SampleVolume == otherTyped.SampleVolume;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,34 +1,50 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using osu.Framework.Bindables;
|
||||||
using osuTK;
|
|
||||||
using osu.Game.Beatmaps.Timing;
|
using osu.Game.Beatmaps.Timing;
|
||||||
|
|
||||||
namespace osu.Game.Beatmaps.ControlPoints
|
namespace osu.Game.Beatmaps.ControlPoints
|
||||||
{
|
{
|
||||||
public class TimingControlPoint : ControlPoint, IEquatable<TimingControlPoint>
|
public class TimingControlPoint : ControlPoint
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The time signature at this control point.
|
/// The time signature at this control point.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public TimeSignatures TimeSignature = TimeSignatures.SimpleQuadruple;
|
public readonly Bindable<TimeSignatures> TimeSignatureBindable = new Bindable<TimeSignatures>(TimeSignatures.SimpleQuadruple) { Default = TimeSignatures.SimpleQuadruple };
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The time signature at this control point.
|
||||||
|
/// </summary>
|
||||||
|
public TimeSignatures TimeSignature
|
||||||
|
{
|
||||||
|
get => TimeSignatureBindable.Value;
|
||||||
|
set => TimeSignatureBindable.Value = value;
|
||||||
|
}
|
||||||
|
|
||||||
public const double DEFAULT_BEAT_LENGTH = 1000;
|
public const double DEFAULT_BEAT_LENGTH = 1000;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The beat length at this control point.
|
/// The beat length at this control point.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual double BeatLength
|
public readonly BindableDouble BeatLengthBindable = new BindableDouble(DEFAULT_BEAT_LENGTH)
|
||||||
{
|
{
|
||||||
get => beatLength;
|
Default = DEFAULT_BEAT_LENGTH,
|
||||||
set => beatLength = MathHelper.Clamp(value, 6, 60000);
|
MinValue = 6,
|
||||||
|
MaxValue = 60000
|
||||||
|
};
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The beat length at this control point.
|
||||||
|
/// </summary>
|
||||||
|
public double BeatLength
|
||||||
|
{
|
||||||
|
get => BeatLengthBindable.Value;
|
||||||
|
set => BeatLengthBindable.Value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
private double beatLength = DEFAULT_BEAT_LENGTH;
|
public override bool EquivalentTo(ControlPoint other) =>
|
||||||
|
other is TimingControlPoint otherTyped
|
||||||
public bool Equals(TimingControlPoint other)
|
&& TimeSignature == otherTyped.TimeSignature && BeatLength.Equals(otherTyped.BeatLength);
|
||||||
=> base.Equals(other)
|
|
||||||
&& TimeSignature == other?.TimeSignature && beatLength.Equals(other.beatLength);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.IO.File;
|
using osu.Framework.IO.File;
|
||||||
@ -50,6 +51,8 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
|
|
||||||
base.ParseStreamInto(stream, beatmap);
|
base.ParseStreamInto(stream, beatmap);
|
||||||
|
|
||||||
|
flushPendingPoints();
|
||||||
|
|
||||||
// Objects may be out of order *only* if a user has manually edited an .osu file.
|
// Objects may be out of order *only* if a user has manually edited an .osu file.
|
||||||
// Unfortunately there are ranked maps in this state (example: https://osu.ppy.sh/s/594828).
|
// Unfortunately there are ranked maps in this state (example: https://osu.ppy.sh/s/594828).
|
||||||
// OrderBy is used to guarantee that the parsing order of hitobjects with equal start times is maintained (stably-sorted)
|
// OrderBy is used to guarantee that the parsing order of hitobjects with equal start times is maintained (stably-sorted)
|
||||||
@ -369,104 +372,64 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
if (timingChange)
|
if (timingChange)
|
||||||
{
|
{
|
||||||
var controlPoint = CreateTimingControlPoint();
|
var controlPoint = CreateTimingControlPoint();
|
||||||
controlPoint.Time = time;
|
|
||||||
controlPoint.BeatLength = beatLength;
|
controlPoint.BeatLength = beatLength;
|
||||||
controlPoint.TimeSignature = timeSignature;
|
controlPoint.TimeSignature = timeSignature;
|
||||||
|
|
||||||
handleTimingControlPoint(controlPoint);
|
addControlPoint(time, controlPoint, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleDifficultyControlPoint(new DifficultyControlPoint
|
addControlPoint(time, new LegacyDifficultyControlPoint
|
||||||
{
|
{
|
||||||
Time = time,
|
|
||||||
SpeedMultiplier = speedMultiplier,
|
SpeedMultiplier = speedMultiplier,
|
||||||
AutoGenerated = timingChange
|
}, timingChange);
|
||||||
});
|
|
||||||
|
|
||||||
handleEffectControlPoint(new EffectControlPoint
|
addControlPoint(time, new EffectControlPoint
|
||||||
{
|
{
|
||||||
Time = time,
|
|
||||||
KiaiMode = kiaiMode,
|
KiaiMode = kiaiMode,
|
||||||
OmitFirstBarLine = omitFirstBarSignature,
|
OmitFirstBarLine = omitFirstBarSignature,
|
||||||
AutoGenerated = timingChange
|
}, timingChange);
|
||||||
});
|
|
||||||
|
|
||||||
handleSampleControlPoint(new LegacySampleControlPoint
|
addControlPoint(time, new LegacySampleControlPoint
|
||||||
{
|
{
|
||||||
Time = time,
|
|
||||||
SampleBank = stringSampleSet,
|
SampleBank = stringSampleSet,
|
||||||
SampleVolume = sampleVolume,
|
SampleVolume = sampleVolume,
|
||||||
CustomSampleBank = customSampleBank,
|
CustomSampleBank = customSampleBank,
|
||||||
AutoGenerated = timingChange
|
}, timingChange);
|
||||||
});
|
|
||||||
|
// To handle the scenario where a non-timing line shares the same time value as a subsequent timing line but
|
||||||
|
// appears earlier in the file, we buffer non-timing control points and rewrite them *after* control points from the timing line
|
||||||
|
// with the same time value (allowing them to overwrite as necessary).
|
||||||
|
//
|
||||||
|
// The expected outcome is that we prefer the non-timing line's adjustments over the timing line's adjustments when time is equal.
|
||||||
|
if (timingChange)
|
||||||
|
flushPendingPoints();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleTimingControlPoint(TimingControlPoint newPoint)
|
private readonly List<ControlPoint> pendingControlPoints = new List<ControlPoint>();
|
||||||
|
private double pendingControlPointsTime;
|
||||||
|
|
||||||
|
private void addControlPoint(double time, ControlPoint point, bool timingChange)
|
||||||
{
|
{
|
||||||
var existing = beatmap.ControlPointInfo.TimingPointAt(newPoint.Time);
|
if (time != pendingControlPointsTime)
|
||||||
|
flushPendingPoints();
|
||||||
|
|
||||||
if (existing.Time == newPoint.Time)
|
if (timingChange)
|
||||||
{
|
{
|
||||||
// autogenerated points should not replace non-autogenerated.
|
beatmap.ControlPointInfo.Add(time, point);
|
||||||
// this allows for incorrectly ordered timing points to still be correctly handled.
|
return;
|
||||||
if (newPoint.AutoGenerated && !existing.AutoGenerated)
|
|
||||||
return;
|
|
||||||
|
|
||||||
beatmap.ControlPointInfo.TimingPoints.Remove(existing);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
beatmap.ControlPointInfo.TimingPoints.Add(newPoint);
|
pendingControlPoints.Add(point);
|
||||||
|
pendingControlPointsTime = time;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleDifficultyControlPoint(DifficultyControlPoint newPoint)
|
private void flushPendingPoints()
|
||||||
{
|
{
|
||||||
var existing = beatmap.ControlPointInfo.DifficultyPointAt(newPoint.Time);
|
foreach (var p in pendingControlPoints)
|
||||||
|
beatmap.ControlPointInfo.Add(pendingControlPointsTime, p);
|
||||||
|
|
||||||
if (existing.Time == newPoint.Time)
|
pendingControlPoints.Clear();
|
||||||
{
|
|
||||||
// autogenerated points should not replace non-autogenerated.
|
|
||||||
// this allows for incorrectly ordered timing points to still be correctly handled.
|
|
||||||
if (newPoint.AutoGenerated && !existing.AutoGenerated)
|
|
||||||
return;
|
|
||||||
|
|
||||||
beatmap.ControlPointInfo.DifficultyPoints.Remove(existing);
|
|
||||||
}
|
|
||||||
|
|
||||||
beatmap.ControlPointInfo.DifficultyPoints.Add(newPoint);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handleEffectControlPoint(EffectControlPoint newPoint)
|
|
||||||
{
|
|
||||||
var existing = beatmap.ControlPointInfo.EffectPointAt(newPoint.Time);
|
|
||||||
|
|
||||||
if (existing.Time == newPoint.Time)
|
|
||||||
{
|
|
||||||
// autogenerated points should not replace non-autogenerated.
|
|
||||||
// this allows for incorrectly ordered timing points to still be correctly handled.
|
|
||||||
if (newPoint.AutoGenerated && !existing.AutoGenerated)
|
|
||||||
return;
|
|
||||||
|
|
||||||
beatmap.ControlPointInfo.EffectPoints.Remove(existing);
|
|
||||||
}
|
|
||||||
|
|
||||||
beatmap.ControlPointInfo.EffectPoints.Add(newPoint);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handleSampleControlPoint(SampleControlPoint newPoint)
|
|
||||||
{
|
|
||||||
var existing = beatmap.ControlPointInfo.SamplePointAt(newPoint.Time);
|
|
||||||
|
|
||||||
if (existing.Time == newPoint.Time)
|
|
||||||
{
|
|
||||||
// autogenerated points should not replace non-autogenerated.
|
|
||||||
// this allows for incorrectly ordered timing points to still be correctly handled.
|
|
||||||
if (newPoint.AutoGenerated && !existing.AutoGenerated)
|
|
||||||
return;
|
|
||||||
|
|
||||||
beatmap.ControlPointInfo.SamplePoints.Remove(existing);
|
|
||||||
}
|
|
||||||
|
|
||||||
beatmap.ControlPointInfo.SamplePoints.Add(newPoint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleHitObject(string line)
|
private void handleHitObject(string line)
|
||||||
|
@ -189,7 +189,15 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
Foreground = 3
|
Foreground = 3
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class LegacySampleControlPoint : SampleControlPoint, IEquatable<LegacySampleControlPoint>
|
internal class LegacyDifficultyControlPoint : DifficultyControlPoint
|
||||||
|
{
|
||||||
|
public LegacyDifficultyControlPoint()
|
||||||
|
{
|
||||||
|
SpeedMultiplierBindable.Precision = double.Epsilon;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class LegacySampleControlPoint : SampleControlPoint
|
||||||
{
|
{
|
||||||
public int CustomSampleBank;
|
public int CustomSampleBank;
|
||||||
|
|
||||||
@ -203,9 +211,9 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
return baseInfo;
|
return baseInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Equals(LegacySampleControlPoint other)
|
public override bool EquivalentTo(ControlPoint other) =>
|
||||||
=> base.Equals(other)
|
base.EquivalentTo(other) && other is LegacySampleControlPoint otherTyped &&
|
||||||
&& CustomSampleBank == other?.CustomSampleBank;
|
CustomSampleBank == otherTyped.CustomSampleBank;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,11 +28,15 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected override TimingControlPoint CreateTimingControlPoint()
|
protected override TimingControlPoint CreateTimingControlPoint()
|
||||||
=> new LegacyDifficultyCalculatorControlPoint();
|
=> new LegacyDifficultyCalculatorTimingControlPoint();
|
||||||
|
|
||||||
private class LegacyDifficultyCalculatorControlPoint : TimingControlPoint
|
private class LegacyDifficultyCalculatorTimingControlPoint : TimingControlPoint
|
||||||
{
|
{
|
||||||
public override double BeatLength { get; set; } = DEFAULT_BEAT_LENGTH;
|
public LegacyDifficultyCalculatorTimingControlPoint()
|
||||||
|
{
|
||||||
|
BeatLengthBindable.MinValue = double.MinValue;
|
||||||
|
BeatLengthBindable.MaxValue = double.MaxValue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,7 @@ namespace osu.Game.Database
|
|||||||
return Import(notification, paths);
|
return Import(notification, paths);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async Task Import(ProgressNotification notification, params string[] paths)
|
protected async Task<IEnumerable<TModel>> Import(ProgressNotification notification, params string[] paths)
|
||||||
{
|
{
|
||||||
notification.Progress = 0;
|
notification.Progress = 0;
|
||||||
notification.Text = $"{HumanisedModelName.Humanize(LetterCasing.Title)} import is initialising...";
|
notification.Text = $"{HumanisedModelName.Humanize(LetterCasing.Title)} import is initialising...";
|
||||||
@ -168,6 +168,8 @@ namespace osu.Game.Database
|
|||||||
|
|
||||||
notification.State = ProgressNotificationState.Completed;
|
notification.State = ProgressNotificationState.Completed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return imported;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -76,7 +76,12 @@ namespace osu.Game.Database
|
|||||||
Task.Factory.StartNew(async () =>
|
Task.Factory.StartNew(async () =>
|
||||||
{
|
{
|
||||||
// This gets scheduled back to the update thread, but we want the import to run in the background.
|
// This gets scheduled back to the update thread, but we want the import to run in the background.
|
||||||
await Import(notification, filename);
|
var imported = await Import(notification, filename);
|
||||||
|
|
||||||
|
// for now a failed import will be marked as a failed download for simplicity.
|
||||||
|
if (!imported.Any())
|
||||||
|
DownloadFailed?.Invoke(request);
|
||||||
|
|
||||||
currentDownloads.Remove(request);
|
currentDownloads.Remove(request);
|
||||||
}, TaskCreationOptions.LongRunning);
|
}, TaskCreationOptions.LongRunning);
|
||||||
};
|
};
|
||||||
|
@ -166,19 +166,6 @@ namespace osu.Game.Database
|
|||||||
// no-op. called by tooling.
|
// no-op. called by tooling.
|
||||||
}
|
}
|
||||||
|
|
||||||
private class OsuDbLoggerProvider : ILoggerProvider
|
|
||||||
{
|
|
||||||
#region Disposal
|
|
||||||
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
public ILogger CreateLogger(string categoryName) => new OsuDbLogger();
|
|
||||||
}
|
|
||||||
|
|
||||||
private class OsuDbLogger : ILogger
|
private class OsuDbLogger : ILogger
|
||||||
{
|
{
|
||||||
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter)
|
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter)
|
||||||
|
@ -104,14 +104,10 @@ namespace osu.Game.Graphics.Containers
|
|||||||
defaultTiming = new TimingControlPoint
|
defaultTiming = new TimingControlPoint
|
||||||
{
|
{
|
||||||
BeatLength = default_beat_length,
|
BeatLength = default_beat_length,
|
||||||
AutoGenerated = true,
|
|
||||||
Time = 0
|
|
||||||
};
|
};
|
||||||
|
|
||||||
defaultEffect = new EffectControlPoint
|
defaultEffect = new EffectControlPoint
|
||||||
{
|
{
|
||||||
Time = 0,
|
|
||||||
AutoGenerated = true,
|
|
||||||
KiaiMode = false,
|
KiaiMode = false,
|
||||||
OmitFirstBarLine = false
|
OmitFirstBarLine = false
|
||||||
};
|
};
|
||||||
|
@ -159,8 +159,15 @@ namespace osu.Game.Graphics.Containers
|
|||||||
Height = Parent.Parent.DrawSize.Y * 1.5f;
|
Height = Parent.Parent.DrawSize.Y * 1.5f;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void PopIn() => this.MoveToY(FinalPosition, APPEAR_DURATION, easing_show);
|
protected override void PopIn() => Schedule(() => this.MoveToY(FinalPosition, APPEAR_DURATION, easing_show));
|
||||||
protected override void PopOut() => this.MoveToY(Parent.Parent.DrawSize.Y, DISAPPEAR_DURATION, easing_hide);
|
|
||||||
|
protected override void PopOut()
|
||||||
|
{
|
||||||
|
double duration = IsLoaded ? DISAPPEAR_DURATION : 0;
|
||||||
|
|
||||||
|
// scheduling is required as parent may not be present at the time this is called.
|
||||||
|
Schedule(() => this.MoveToY(Parent.Parent.DrawSize.Y, duration, easing_hide));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
85
osu.Game/Graphics/UserInterface/LoadingButton.cs
Normal file
85
osu.Game/Graphics/UserInterface/LoadingButton.cs
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
// 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.Input.Events;
|
||||||
|
using osu.Game.Graphics.Containers;
|
||||||
|
using osuTK;
|
||||||
|
|
||||||
|
namespace osu.Game.Graphics.UserInterface
|
||||||
|
{
|
||||||
|
public abstract class LoadingButton : OsuHoverContainer
|
||||||
|
{
|
||||||
|
private bool isLoading;
|
||||||
|
|
||||||
|
public bool IsLoading
|
||||||
|
{
|
||||||
|
get => isLoading;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
isLoading = value;
|
||||||
|
|
||||||
|
Enabled.Value = !isLoading;
|
||||||
|
|
||||||
|
if (value)
|
||||||
|
{
|
||||||
|
loading.Show();
|
||||||
|
OnLoadStarted();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
loading.Hide();
|
||||||
|
OnLoadFinished();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector2 LoadingAnimationSize
|
||||||
|
{
|
||||||
|
get => loading.Size;
|
||||||
|
set => loading.Size = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly LoadingAnimation loading;
|
||||||
|
|
||||||
|
protected LoadingButton()
|
||||||
|
{
|
||||||
|
AddRange(new[]
|
||||||
|
{
|
||||||
|
CreateContent(),
|
||||||
|
loading = new LoadingAnimation
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Size = new Vector2(12)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool OnClick(ClickEvent e)
|
||||||
|
{
|
||||||
|
if (!Enabled.Value)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return base.OnClick(e);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
// run afterwards as this will disable this button.
|
||||||
|
IsLoading = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void OnLoadStarted()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void OnLoadFinished()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract Drawable CreateContent();
|
||||||
|
}
|
||||||
|
}
|
@ -59,7 +59,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
protected override bool OnHover(HoverEvent e)
|
protected override bool OnHover(HoverEvent e)
|
||||||
{
|
{
|
||||||
hover.FadeIn(200);
|
hover.FadeIn(200);
|
||||||
return base.OnHover(e);
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnHoverLost(HoverLostEvent e)
|
protected override void OnHoverLost(HoverLostEvent e)
|
||||||
|
@ -17,7 +17,7 @@ using osu.Framework.Input.Events;
|
|||||||
namespace osu.Game.Graphics.UserInterface
|
namespace osu.Game.Graphics.UserInterface
|
||||||
{
|
{
|
||||||
public class OsuSliderBar<T> : SliderBar<T>, IHasTooltip, IHasAccentColour
|
public class OsuSliderBar<T> : SliderBar<T>, IHasTooltip, IHasAccentColour
|
||||||
where T : struct, IEquatable<T>, IComparable, IConvertible
|
where T : struct, IEquatable<T>, IComparable<T>, IConvertible
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Maximum number of decimal digits to be displayed in the tooltip.
|
/// Maximum number of decimal digits to be displayed in the tooltip.
|
||||||
|
@ -14,8 +14,6 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
{
|
{
|
||||||
protected virtual bool AllowCommit => false;
|
protected virtual bool AllowCommit => false;
|
||||||
|
|
||||||
public override bool HandleLeftRightArrows => false;
|
|
||||||
|
|
||||||
public SearchTextBox()
|
public SearchTextBox()
|
||||||
{
|
{
|
||||||
Height = 35;
|
Height = 35;
|
||||||
|
13
osu.Game/Graphics/UserInterface/SeekLimitedSearchTextBox.cs
Normal file
13
osu.Game/Graphics/UserInterface/SeekLimitedSearchTextBox.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
namespace osu.Game.Graphics.UserInterface
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A <see cref="SearchTextBox"/> which does not handle left/right arrow keys for seeking.
|
||||||
|
/// </summary>
|
||||||
|
public class SeekLimitedSearchTextBox : SearchTextBox
|
||||||
|
{
|
||||||
|
public override bool HandleLeftRightArrows => false;
|
||||||
|
}
|
||||||
|
}
|
@ -5,8 +5,6 @@ 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.Events;
|
|
||||||
using osu.Game.Graphics.Containers;
|
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
@ -14,9 +12,9 @@ using System.Collections.Generic;
|
|||||||
|
|
||||||
namespace osu.Game.Graphics.UserInterface
|
namespace osu.Game.Graphics.UserInterface
|
||||||
{
|
{
|
||||||
public class ShowMoreButton : OsuHoverContainer
|
public class ShowMoreButton : LoadingButton
|
||||||
{
|
{
|
||||||
private const float fade_duration = 200;
|
private const int duration = 200;
|
||||||
|
|
||||||
private Color4 chevronIconColour;
|
private Color4 chevronIconColour;
|
||||||
|
|
||||||
@ -32,100 +30,55 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
set => text.Text = value;
|
set => text.Text = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool isLoading;
|
|
||||||
|
|
||||||
public bool IsLoading
|
|
||||||
{
|
|
||||||
get => isLoading;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
isLoading = value;
|
|
||||||
|
|
||||||
Enabled.Value = !isLoading;
|
|
||||||
|
|
||||||
if (value)
|
|
||||||
{
|
|
||||||
loading.Show();
|
|
||||||
content.FadeOut(fade_duration, Easing.OutQuint);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
loading.Hide();
|
|
||||||
content.FadeIn(fade_duration, Easing.OutQuint);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private readonly Box background;
|
|
||||||
private readonly LoadingAnimation loading;
|
|
||||||
private readonly FillFlowContainer content;
|
|
||||||
private readonly ChevronIcon leftChevron;
|
|
||||||
private readonly ChevronIcon rightChevron;
|
|
||||||
private readonly SpriteText text;
|
|
||||||
|
|
||||||
protected override IEnumerable<Drawable> EffectTargets => new[] { background };
|
protected override IEnumerable<Drawable> EffectTargets => new[] { background };
|
||||||
|
|
||||||
|
private ChevronIcon leftChevron;
|
||||||
|
private ChevronIcon rightChevron;
|
||||||
|
private SpriteText text;
|
||||||
|
private Box background;
|
||||||
|
private FillFlowContainer textContainer;
|
||||||
|
|
||||||
public ShowMoreButton()
|
public ShowMoreButton()
|
||||||
{
|
{
|
||||||
AutoSizeAxes = Axes.Both;
|
AutoSizeAxes = Axes.Both;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override Drawable CreateContent() => new CircularContainer
|
||||||
|
{
|
||||||
|
Masking = true,
|
||||||
|
Size = new Vector2(140, 30),
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new CircularContainer
|
background = new Box
|
||||||
{
|
{
|
||||||
Masking = true,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Size = new Vector2(140, 30),
|
},
|
||||||
|
textContainer = new FillFlowContainer
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
AutoSizeAxes = Axes.Both,
|
||||||
|
Direction = FillDirection.Horizontal,
|
||||||
|
Spacing = new Vector2(7),
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
background = new Box
|
leftChevron = new ChevronIcon(),
|
||||||
{
|
text = new OsuSpriteText
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
},
|
|
||||||
content = new FillFlowContainer
|
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
AutoSizeAxes = Axes.Both,
|
Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold),
|
||||||
Direction = FillDirection.Horizontal,
|
Text = "show more".ToUpper(),
|
||||||
Spacing = new Vector2(7),
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
leftChevron = new ChevronIcon(),
|
|
||||||
text = new OsuSpriteText
|
|
||||||
{
|
|
||||||
Anchor = Anchor.Centre,
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold),
|
|
||||||
Text = "show more".ToUpper(),
|
|
||||||
},
|
|
||||||
rightChevron = new ChevronIcon(),
|
|
||||||
}
|
|
||||||
},
|
|
||||||
loading = new LoadingAnimation
|
|
||||||
{
|
|
||||||
Anchor = Anchor.Centre,
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
Size = new Vector2(12)
|
|
||||||
},
|
},
|
||||||
|
rightChevron = new ChevronIcon(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override bool OnClick(ClickEvent e)
|
|
||||||
{
|
|
||||||
if (!Enabled.Value)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return base.OnClick(e);
|
|
||||||
}
|
}
|
||||||
finally
|
};
|
||||||
{
|
|
||||||
// run afterwards as this will disable this button.
|
protected override void OnLoadStarted() => textContainer.FadeOut(duration, Easing.OutQuint);
|
||||||
IsLoading = true;
|
|
||||||
}
|
protected override void OnLoadFinished() => textContainer.FadeIn(duration, Easing.OutQuint);
|
||||||
}
|
|
||||||
|
|
||||||
private class ChevronIcon : SpriteIcon
|
private class ChevronIcon : SpriteIcon
|
||||||
{
|
{
|
||||||
|
@ -1,132 +1,24 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
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.UserInterface;
|
||||||
using osu.Framework.Graphics.Shapes;
|
|
||||||
using osu.Game.Graphics.Containers;
|
|
||||||
using osuTK;
|
|
||||||
|
|
||||||
namespace osu.Game.Graphics.UserInterfaceV2
|
namespace osu.Game.Graphics.UserInterfaceV2
|
||||||
{
|
{
|
||||||
public abstract class LabelledComponent<T> : CompositeDrawable
|
public abstract class LabelledComponent<T, U> : LabelledDrawable<T>, IHasCurrentValue<U>
|
||||||
where T : Drawable
|
where T : Drawable, IHasCurrentValue<U>
|
||||||
{
|
{
|
||||||
protected const float CONTENT_PADDING_VERTICAL = 10;
|
|
||||||
protected const float CONTENT_PADDING_HORIZONTAL = 15;
|
|
||||||
protected const float CORNER_RADIUS = 15;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The component that is being displayed.
|
|
||||||
/// </summary>
|
|
||||||
protected readonly T Component;
|
|
||||||
|
|
||||||
private readonly OsuTextFlowContainer labelText;
|
|
||||||
private readonly OsuTextFlowContainer descriptionText;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Creates a new <see cref="LabelledComponent{T}"/>.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="padded">Whether the component should be padded or should be expanded to the bounds of this <see cref="LabelledComponent{T}"/>.</param>
|
|
||||||
protected LabelledComponent(bool padded)
|
protected LabelledComponent(bool padded)
|
||||||
|
: base(padded)
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X;
|
|
||||||
AutoSizeAxes = Axes.Y;
|
|
||||||
|
|
||||||
CornerRadius = CORNER_RADIUS;
|
|
||||||
Masking = true;
|
|
||||||
|
|
||||||
InternalChildren = new Drawable[]
|
|
||||||
{
|
|
||||||
new Box
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Colour = OsuColour.FromHex("1c2125"),
|
|
||||||
},
|
|
||||||
new FillFlowContainer
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.X,
|
|
||||||
AutoSizeAxes = Axes.Y,
|
|
||||||
Direction = FillDirection.Vertical,
|
|
||||||
Padding = padded
|
|
||||||
? new MarginPadding { Horizontal = CONTENT_PADDING_HORIZONTAL, Vertical = CONTENT_PADDING_VERTICAL }
|
|
||||||
: new MarginPadding { Left = CONTENT_PADDING_HORIZONTAL },
|
|
||||||
Spacing = new Vector2(0, 12),
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
new GridContainer
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.X,
|
|
||||||
AutoSizeAxes = Axes.Y,
|
|
||||||
Content = new[]
|
|
||||||
{
|
|
||||||
new Drawable[]
|
|
||||||
{
|
|
||||||
labelText = new OsuTextFlowContainer(s => s.Font = OsuFont.GetFont(weight: FontWeight.Bold))
|
|
||||||
{
|
|
||||||
Anchor = Anchor.CentreLeft,
|
|
||||||
Origin = Anchor.CentreLeft,
|
|
||||||
AutoSizeAxes = Axes.Both,
|
|
||||||
Padding = new MarginPadding { Right = 20 }
|
|
||||||
},
|
|
||||||
new Container
|
|
||||||
{
|
|
||||||
Anchor = Anchor.CentreRight,
|
|
||||||
Origin = Anchor.CentreRight,
|
|
||||||
RelativeSizeAxes = Axes.X,
|
|
||||||
AutoSizeAxes = Axes.Y,
|
|
||||||
Child = Component = CreateComponent().With(d =>
|
|
||||||
{
|
|
||||||
d.Anchor = Anchor.CentreRight;
|
|
||||||
d.Origin = Anchor.CentreRight;
|
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
RowDimensions = new[] { new Dimension(GridSizeMode.AutoSize) },
|
|
||||||
ColumnDimensions = new[] { new Dimension(GridSizeMode.AutoSize) }
|
|
||||||
},
|
|
||||||
descriptionText = new OsuTextFlowContainer(s => s.Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold, italics: true))
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.X,
|
|
||||||
AutoSizeAxes = Axes.Y,
|
|
||||||
Padding = new MarginPadding { Bottom = padded ? 0 : CONTENT_PADDING_VERTICAL },
|
|
||||||
Alpha = 0,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
public Bindable<U> Current
|
||||||
private void load(OsuColour osuColour)
|
|
||||||
{
|
{
|
||||||
descriptionText.Colour = osuColour.Yellow;
|
get => Component.Current;
|
||||||
|
set => Component.Current = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Label
|
|
||||||
{
|
|
||||||
set => labelText.Text = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string Description
|
|
||||||
{
|
|
||||||
set
|
|
||||||
{
|
|
||||||
descriptionText.Text = value;
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(value))
|
|
||||||
descriptionText.Show();
|
|
||||||
else
|
|
||||||
descriptionText.Hide();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Creates the component that should be displayed.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>The component.</returns>
|
|
||||||
protected abstract T CreateComponent();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
132
osu.Game/Graphics/UserInterfaceV2/LabelledDrawable.cs
Normal file
132
osu.Game/Graphics/UserInterfaceV2/LabelledDrawable.cs
Normal file
@ -0,0 +1,132 @@
|
|||||||
|
// 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.Allocation;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Game.Graphics.Containers;
|
||||||
|
using osuTK;
|
||||||
|
|
||||||
|
namespace osu.Game.Graphics.UserInterfaceV2
|
||||||
|
{
|
||||||
|
public abstract class LabelledDrawable<T> : CompositeDrawable
|
||||||
|
where T : Drawable
|
||||||
|
{
|
||||||
|
protected const float CONTENT_PADDING_VERTICAL = 10;
|
||||||
|
protected const float CONTENT_PADDING_HORIZONTAL = 15;
|
||||||
|
protected const float CORNER_RADIUS = 15;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The component that is being displayed.
|
||||||
|
/// </summary>
|
||||||
|
protected readonly T Component;
|
||||||
|
|
||||||
|
private readonly OsuTextFlowContainer labelText;
|
||||||
|
private readonly OsuTextFlowContainer descriptionText;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new <see cref="LabelledComponent{T, U}"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="padded">Whether the component should be padded or should be expanded to the bounds of this <see cref="LabelledComponent{T, U}"/>.</param>
|
||||||
|
protected LabelledDrawable(bool padded)
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X;
|
||||||
|
AutoSizeAxes = Axes.Y;
|
||||||
|
|
||||||
|
CornerRadius = CORNER_RADIUS;
|
||||||
|
Masking = true;
|
||||||
|
|
||||||
|
InternalChildren = new Drawable[]
|
||||||
|
{
|
||||||
|
new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Colour = OsuColour.FromHex("1c2125"),
|
||||||
|
},
|
||||||
|
new FillFlowContainer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Direction = FillDirection.Vertical,
|
||||||
|
Padding = padded
|
||||||
|
? new MarginPadding { Horizontal = CONTENT_PADDING_HORIZONTAL, Vertical = CONTENT_PADDING_VERTICAL }
|
||||||
|
: new MarginPadding { Left = CONTENT_PADDING_HORIZONTAL },
|
||||||
|
Spacing = new Vector2(0, 12),
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new GridContainer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Content = new[]
|
||||||
|
{
|
||||||
|
new Drawable[]
|
||||||
|
{
|
||||||
|
labelText = new OsuTextFlowContainer(s => s.Font = OsuFont.GetFont(weight: FontWeight.Bold))
|
||||||
|
{
|
||||||
|
Anchor = Anchor.CentreLeft,
|
||||||
|
Origin = Anchor.CentreLeft,
|
||||||
|
AutoSizeAxes = Axes.Both,
|
||||||
|
Padding = new MarginPadding { Right = 20 }
|
||||||
|
},
|
||||||
|
new Container
|
||||||
|
{
|
||||||
|
Anchor = Anchor.CentreRight,
|
||||||
|
Origin = Anchor.CentreRight,
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Child = Component = CreateComponent().With(d =>
|
||||||
|
{
|
||||||
|
d.Anchor = Anchor.CentreRight;
|
||||||
|
d.Origin = Anchor.CentreRight;
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
RowDimensions = new[] { new Dimension(GridSizeMode.AutoSize) },
|
||||||
|
ColumnDimensions = new[] { new Dimension(GridSizeMode.AutoSize) }
|
||||||
|
},
|
||||||
|
descriptionText = new OsuTextFlowContainer(s => s.Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold, italics: true))
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Padding = new MarginPadding { Bottom = padded ? 0 : CONTENT_PADDING_VERTICAL },
|
||||||
|
Alpha = 0,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OsuColour osuColour)
|
||||||
|
{
|
||||||
|
descriptionText.Colour = osuColour.Yellow;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Label
|
||||||
|
{
|
||||||
|
set => labelText.Text = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Description
|
||||||
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
descriptionText.Text = value;
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(value))
|
||||||
|
descriptionText.Show();
|
||||||
|
else
|
||||||
|
descriptionText.Hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates the component that should be displayed.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The component.</returns>
|
||||||
|
protected abstract T CreateComponent();
|
||||||
|
}
|
||||||
|
}
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
namespace osu.Game.Graphics.UserInterfaceV2
|
namespace osu.Game.Graphics.UserInterfaceV2
|
||||||
{
|
{
|
||||||
public class LabelledSwitchButton : LabelledComponent<SwitchButton>
|
public class LabelledSwitchButton : LabelledComponent<SwitchButton, bool>
|
||||||
{
|
{
|
||||||
public LabelledSwitchButton()
|
public LabelledSwitchButton()
|
||||||
: base(true)
|
: base(true)
|
||||||
|
@ -8,7 +8,7 @@ using osu.Game.Graphics.UserInterface;
|
|||||||
|
|
||||||
namespace osu.Game.Graphics.UserInterfaceV2
|
namespace osu.Game.Graphics.UserInterfaceV2
|
||||||
{
|
{
|
||||||
public class LabelledTextBox : LabelledComponent<OsuTextBox>
|
public class LabelledTextBox : LabelledComponent<OsuTextBox, string>
|
||||||
{
|
{
|
||||||
public event TextBox.OnCommitHandler OnCommit;
|
public event TextBox.OnCommitHandler OnCommit;
|
||||||
|
|
||||||
|
36
osu.Game/Online/API/Requests/CommentVoteRequest.cs
Normal file
36
osu.Game/Online/API/Requests/CommentVoteRequest.cs
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
// 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.IO.Network;
|
||||||
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
|
using System.Net.Http;
|
||||||
|
|
||||||
|
namespace osu.Game.Online.API.Requests
|
||||||
|
{
|
||||||
|
public class CommentVoteRequest : APIRequest<CommentBundle>
|
||||||
|
{
|
||||||
|
private readonly long id;
|
||||||
|
private readonly CommentVoteAction action;
|
||||||
|
|
||||||
|
public CommentVoteRequest(long id, CommentVoteAction action)
|
||||||
|
{
|
||||||
|
this.id = id;
|
||||||
|
this.action = action;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override WebRequest CreateWebRequest()
|
||||||
|
{
|
||||||
|
var req = base.CreateWebRequest();
|
||||||
|
req.Method = action == CommentVoteAction.Vote ? HttpMethod.Post : HttpMethod.Delete;
|
||||||
|
return req;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override string Target => $@"comments/{id}/vote";
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum CommentVoteAction
|
||||||
|
{
|
||||||
|
Vote,
|
||||||
|
UnVote
|
||||||
|
}
|
||||||
|
}
|
@ -72,6 +72,8 @@ namespace osu.Game.Online.API.Requests.Responses
|
|||||||
|
|
||||||
public bool HasMessage => !string.IsNullOrEmpty(MessageHtml);
|
public bool HasMessage => !string.IsNullOrEmpty(MessageHtml);
|
||||||
|
|
||||||
|
public bool IsVoted { get; set; }
|
||||||
|
|
||||||
public string GetMessage => HasMessage ? WebUtility.HtmlDecode(Regex.Replace(MessageHtml, @"<(.|\n)*?>", string.Empty)) : string.Empty;
|
public string GetMessage => HasMessage ? WebUtility.HtmlDecode(Regex.Replace(MessageHtml, @"<(.|\n)*?>", string.Empty)) : string.Empty;
|
||||||
|
|
||||||
public int DeletedChildrenCount => ChildComments.Count(c => c.IsDeleted);
|
public int DeletedChildrenCount => ChildComments.Count(c => c.IsDeleted);
|
||||||
|
@ -47,6 +47,22 @@ namespace osu.Game.Online.API.Requests.Responses
|
|||||||
[JsonProperty(@"included_comments")]
|
[JsonProperty(@"included_comments")]
|
||||||
public List<Comment> IncludedComments { get; set; }
|
public List<Comment> IncludedComments { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty(@"user_votes")]
|
||||||
|
private List<long> userVotes
|
||||||
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
value.ForEach(v =>
|
||||||
|
{
|
||||||
|
Comments.ForEach(c =>
|
||||||
|
{
|
||||||
|
if (v == c.Id)
|
||||||
|
c.IsVoted = true;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private List<User> users;
|
private List<User> users;
|
||||||
|
|
||||||
[JsonProperty(@"users")]
|
[JsonProperty(@"users")]
|
||||||
|
@ -14,7 +14,7 @@ namespace osu.Game.Online.Chat
|
|||||||
{
|
{
|
||||||
public class Channel
|
public class Channel
|
||||||
{
|
{
|
||||||
public readonly int MaxHistory = 300;
|
public const int MAX_HISTORY = 300;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Contains every joined user except the current logged in user. Currently only returned for PM channels.
|
/// Contains every joined user except the current logged in user. Currently only returned for PM channels.
|
||||||
@ -80,8 +80,6 @@ namespace osu.Game.Online.Chat
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public Bindable<bool> Joined = new Bindable<bool>();
|
public Bindable<bool> Joined = new Bindable<bool>();
|
||||||
|
|
||||||
public const int MAX_HISTORY = 300;
|
|
||||||
|
|
||||||
[JsonConstructor]
|
[JsonConstructor]
|
||||||
public Channel()
|
public Channel()
|
||||||
{
|
{
|
||||||
@ -162,8 +160,8 @@ namespace osu.Game.Online.Chat
|
|||||||
{
|
{
|
||||||
// never purge local echos
|
// never purge local echos
|
||||||
int messageCount = Messages.Count - pendingMessages.Count;
|
int messageCount = Messages.Count - pendingMessages.Count;
|
||||||
if (messageCount > MaxHistory)
|
if (messageCount > MAX_HISTORY)
|
||||||
Messages.RemoveRange(0, messageCount - MaxHistory);
|
Messages.RemoveRange(0, messageCount - MAX_HISTORY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ namespace osu.Game.Online.Chat
|
|||||||
private static readonly Regex new_link_regex = new Regex(@"\[(?<url>[a-z]+://[^ ]+) (?<text>(((?<=\\)[\[\]])|[^\[\]])*(((?<open>\[)(((?<=\\)[\[\]])|[^\[\]])*)+((?<close-open>\])(((?<=\\)[\[\]])|[^\[\]])*)+)*(?(open)(?!)))\]");
|
private static readonly Regex new_link_regex = new Regex(@"\[(?<url>[a-z]+://[^ ]+) (?<text>(((?<=\\)[\[\]])|[^\[\]])*(((?<open>\[)(((?<=\\)[\[\]])|[^\[\]])*)+((?<close-open>\])(((?<=\\)[\[\]])|[^\[\]])*)+)*(?(open)(?!)))\]");
|
||||||
|
|
||||||
// [test](https://osu.ppy.sh/b/1234) -> test (https://osu.ppy.sh/b/1234) aka correct markdown format
|
// [test](https://osu.ppy.sh/b/1234) -> test (https://osu.ppy.sh/b/1234) aka correct markdown format
|
||||||
private static readonly Regex markdown_link_regex = new Regex(@"\[(?<text>(((?<=\\)[\[\]])|[^\[\]])*(((?<open>\[)(((?<=\\)[\[\]])|[^\[\]])*)+((?<close-open>\])(((?<=\\)[\[\]])|[^\[\]])*)+)*(?(open)(?!)))\]\((?<url>[a-z]+://[^ ]+)\)");
|
private static readonly Regex markdown_link_regex = new Regex(@"\[(?<text>(((?<=\\)[\[\]])|[^\[\]])*(((?<open>\[)(((?<=\\)[\[\]])|[^\[\]])*)+((?<close-open>\])(((?<=\\)[\[\]])|[^\[\]])*)+)*(?(open)(?!)))\]\((?<url>[a-z]+://[^ ]+)(\s+(?<title>""([^""]|(?<=\\)"")*""))?\)");
|
||||||
|
|
||||||
// advanced, RFC-compatible regular expression that matches any possible URL, *but* allows certain invalid characters that are widely used
|
// advanced, RFC-compatible regular expression that matches any possible URL, *but* allows certain invalid characters that are widely used
|
||||||
// This is in the format (<required>, [optional]):
|
// This is in the format (<required>, [optional]):
|
||||||
@ -95,11 +95,17 @@ namespace osu.Game.Online.Chat
|
|||||||
foreach (Match m in regex.Matches(result.Text, startIndex))
|
foreach (Match m in regex.Matches(result.Text, startIndex))
|
||||||
{
|
{
|
||||||
var index = m.Index;
|
var index = m.Index;
|
||||||
var link = m.Groups["link"].Value;
|
var linkText = m.Groups["link"].Value;
|
||||||
var indexLength = link.Length;
|
var indexLength = linkText.Length;
|
||||||
|
|
||||||
var details = getLinkDetails(link);
|
var details = getLinkDetails(linkText);
|
||||||
result.Links.Add(new Link(link, index, indexLength, details.Action, details.Argument));
|
var link = new Link(linkText, index, indexLength, details.Action, details.Argument);
|
||||||
|
|
||||||
|
// sometimes an already-processed formatted link can reduce to a simple URL, too
|
||||||
|
// (example: [mean example - https://osu.ppy.sh](https://osu.ppy.sh))
|
||||||
|
// therefore we need to check if any of the pre-existing links contains the raw one we found
|
||||||
|
if (result.Links.All(existingLink => !existingLink.Overlaps(link)))
|
||||||
|
result.Links.Add(link);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -292,6 +298,8 @@ namespace osu.Game.Online.Chat
|
|||||||
Argument = argument;
|
Argument = argument;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool Overlaps(Link otherLink) => Index < otherLink.Index + otherLink.Length && otherLink.Index < Index + Length;
|
||||||
|
|
||||||
public int CompareTo(Link otherLink) => Index > otherLink.Index ? 1 : -1;
|
public int CompareTo(Link otherLink) => Index > otherLink.Index ? 1 : -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +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.UserInterface;
|
using osu.Framework.Graphics.UserInterface;
|
||||||
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Overlays.Chat;
|
using osu.Game.Overlays.Chat;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
@ -124,6 +125,8 @@ namespace osu.Game.Online.Chat
|
|||||||
|
|
||||||
protected override ChatLine CreateChatLine(Message m) => CreateChatLineAction(m);
|
protected override ChatLine CreateChatLine(Message m) => CreateChatLineAction(m);
|
||||||
|
|
||||||
|
protected override DaySeparator CreateDaySeparator(DateTimeOffset time) => new CustomDaySeparator(time);
|
||||||
|
|
||||||
public StandAloneDrawableChannel(Channel channel)
|
public StandAloneDrawableChannel(Channel channel)
|
||||||
: base(channel)
|
: base(channel)
|
||||||
{
|
{
|
||||||
@ -134,6 +137,24 @@ namespace osu.Game.Online.Chat
|
|||||||
{
|
{
|
||||||
ChatLineFlow.Padding = new MarginPadding { Horizontal = 0 };
|
ChatLineFlow.Padding = new MarginPadding { Horizontal = 0 };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class CustomDaySeparator : DaySeparator
|
||||||
|
{
|
||||||
|
public CustomDaySeparator(DateTimeOffset time)
|
||||||
|
: base(time)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OsuColour colours)
|
||||||
|
{
|
||||||
|
Colour = colours.Yellow;
|
||||||
|
TextSize = 14;
|
||||||
|
LineHeight = 1;
|
||||||
|
Padding = new MarginPadding { Horizontal = 10 };
|
||||||
|
Margin = new MarginPadding { Vertical = 5 };
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected class StandAloneMessage : ChatLine
|
protected class StandAloneMessage : ChatLine
|
||||||
|
@ -138,18 +138,13 @@ namespace osu.Game.Overlays.AccountCreation
|
|||||||
passwordTextBox.Current.ValueChanged += password => { characterCheckText.ForEach(s => s.Colour = password.NewValue.Length == 0 ? Color4.White : Interpolation.ValueAt(password.NewValue.Length, Color4.OrangeRed, Color4.YellowGreen, 0, 8, Easing.In)); };
|
passwordTextBox.Current.ValueChanged += password => { characterCheckText.ForEach(s => s.Colour = password.NewValue.Length == 0 ? Color4.White : Interpolation.ValueAt(password.NewValue.Length, Color4.OrangeRed, Color4.YellowGreen, 0, 8, Easing.In)); };
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Update()
|
|
||||||
{
|
|
||||||
base.Update();
|
|
||||||
|
|
||||||
if (host?.OnScreenKeyboardOverlapsGameWindow != true && !textboxes.Any(t => t.HasFocus))
|
|
||||||
focusNextTextbox();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void OnEntering(IScreen last)
|
public override void OnEntering(IScreen last)
|
||||||
{
|
{
|
||||||
base.OnEntering(last);
|
base.OnEntering(last);
|
||||||
processingOverlay.Hide();
|
processingOverlay.Hide();
|
||||||
|
|
||||||
|
if (host?.OnScreenKeyboardOverlapsGameWindow != true)
|
||||||
|
focusNextTextbox();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void performRegistration()
|
private void performRegistration()
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
@ -12,15 +12,22 @@ using osu.Framework.Graphics.Containers;
|
|||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
using osu.Game.Graphics.Cursor;
|
using osu.Game.Graphics.Cursor;
|
||||||
using osu.Game.Online.Chat;
|
using osu.Game.Online.Chat;
|
||||||
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Chat
|
namespace osu.Game.Overlays.Chat
|
||||||
{
|
{
|
||||||
public class DrawableChannel : Container
|
public class DrawableChannel : Container
|
||||||
{
|
{
|
||||||
public readonly Channel Channel;
|
public readonly Channel Channel;
|
||||||
protected ChatLineContainer ChatLineFlow;
|
protected FillFlowContainer ChatLineFlow;
|
||||||
private OsuScrollContainer scroll;
|
private OsuScrollContainer scroll;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private OsuColour colours { get; set; }
|
||||||
|
|
||||||
public DrawableChannel(Channel channel)
|
public DrawableChannel(Channel channel)
|
||||||
{
|
{
|
||||||
Channel = channel;
|
Channel = channel;
|
||||||
@ -40,7 +47,7 @@ namespace osu.Game.Overlays.Chat
|
|||||||
// Some chat lines have effects that slightly protrude to the bottom,
|
// Some chat lines have effects that slightly protrude to the bottom,
|
||||||
// which we do not want to mask away, hence the padding.
|
// which we do not want to mask away, hence the padding.
|
||||||
Padding = new MarginPadding { Bottom = 5 },
|
Padding = new MarginPadding { Bottom = 5 },
|
||||||
Child = ChatLineFlow = new ChatLineContainer
|
Child = ChatLineFlow = new FillFlowContainer
|
||||||
{
|
{
|
||||||
Padding = new MarginPadding { Left = 20, Right = 20 },
|
Padding = new MarginPadding { Left = 20, Right = 20 },
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
@ -74,31 +81,61 @@ namespace osu.Game.Overlays.Chat
|
|||||||
|
|
||||||
protected virtual ChatLine CreateChatLine(Message m) => new ChatLine(m);
|
protected virtual ChatLine CreateChatLine(Message m) => new ChatLine(m);
|
||||||
|
|
||||||
|
protected virtual DaySeparator CreateDaySeparator(DateTimeOffset time) => new DaySeparator(time)
|
||||||
|
{
|
||||||
|
Margin = new MarginPadding { Vertical = 10 },
|
||||||
|
Colour = colours.ChatBlue.Lighten(0.7f),
|
||||||
|
};
|
||||||
|
|
||||||
private void newMessagesArrived(IEnumerable<Message> newMessages)
|
private void newMessagesArrived(IEnumerable<Message> newMessages)
|
||||||
{
|
{
|
||||||
|
bool shouldScrollToEnd = scroll.IsScrolledToEnd(10) || !chatLines.Any() || newMessages.Any(m => m is LocalMessage);
|
||||||
|
|
||||||
// Add up to last Channel.MAX_HISTORY messages
|
// Add up to last Channel.MAX_HISTORY messages
|
||||||
var displayMessages = newMessages.Skip(Math.Max(0, newMessages.Count() - Channel.MaxHistory));
|
var displayMessages = newMessages.Skip(Math.Max(0, newMessages.Count() - Channel.MAX_HISTORY));
|
||||||
|
|
||||||
ChatLineFlow.AddRange(displayMessages.Select(CreateChatLine));
|
Message lastMessage = chatLines.LastOrDefault()?.Message;
|
||||||
|
|
||||||
if (scroll.IsScrolledToEnd(10) || !ChatLineFlow.Children.Any() || newMessages.Any(m => m is LocalMessage))
|
foreach (var message in displayMessages)
|
||||||
scrollToEnd();
|
|
||||||
|
|
||||||
var staleMessages = ChatLineFlow.Children.Where(c => c.LifetimeEnd == double.MaxValue).ToArray();
|
|
||||||
int count = staleMessages.Length - Channel.MaxHistory;
|
|
||||||
|
|
||||||
for (int i = 0; i < count; i++)
|
|
||||||
{
|
{
|
||||||
var d = staleMessages[i];
|
if (lastMessage == null || lastMessage.Timestamp.ToLocalTime().Date != message.Timestamp.ToLocalTime().Date)
|
||||||
if (!scroll.IsScrolledToEnd(10))
|
ChatLineFlow.Add(CreateDaySeparator(message.Timestamp));
|
||||||
scroll.OffsetScrollPosition(-d.DrawHeight);
|
|
||||||
d.Expire();
|
ChatLineFlow.Add(CreateChatLine(message));
|
||||||
|
lastMessage = message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var staleMessages = chatLines.Where(c => c.LifetimeEnd == double.MaxValue).ToArray();
|
||||||
|
int count = staleMessages.Length - Channel.MAX_HISTORY;
|
||||||
|
|
||||||
|
if (count > 0)
|
||||||
|
{
|
||||||
|
void expireAndAdjustScroll(Drawable d)
|
||||||
|
{
|
||||||
|
scroll.OffsetScrollPosition(-d.DrawHeight);
|
||||||
|
d.Expire();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
expireAndAdjustScroll(staleMessages[i]);
|
||||||
|
|
||||||
|
// remove all adjacent day separators after stale message removal
|
||||||
|
for (int i = 0; i < ChatLineFlow.Count - 1; i++)
|
||||||
|
{
|
||||||
|
if (!(ChatLineFlow[i] is DaySeparator)) break;
|
||||||
|
if (!(ChatLineFlow[i + 1] is DaySeparator)) break;
|
||||||
|
|
||||||
|
expireAndAdjustScroll(ChatLineFlow[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (shouldScrollToEnd)
|
||||||
|
scrollToEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void pendingMessageResolved(Message existing, Message updated)
|
private void pendingMessageResolved(Message existing, Message updated)
|
||||||
{
|
{
|
||||||
var found = ChatLineFlow.Children.LastOrDefault(c => c.Message == existing);
|
var found = chatLines.LastOrDefault(c => c.Message == existing);
|
||||||
|
|
||||||
if (found != null)
|
if (found != null)
|
||||||
{
|
{
|
||||||
@ -112,19 +149,74 @@ namespace osu.Game.Overlays.Chat
|
|||||||
|
|
||||||
private void messageRemoved(Message removed)
|
private void messageRemoved(Message removed)
|
||||||
{
|
{
|
||||||
ChatLineFlow.Children.FirstOrDefault(c => c.Message == removed)?.FadeColour(Color4.Red, 400).FadeOut(600).Expire();
|
chatLines.FirstOrDefault(c => c.Message == removed)?.FadeColour(Color4.Red, 400).FadeOut(600).Expire();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private IEnumerable<ChatLine> chatLines => ChatLineFlow.Children.OfType<ChatLine>();
|
||||||
|
|
||||||
private void scrollToEnd() => ScheduleAfterChildren(() => scroll.ScrollToEnd());
|
private void scrollToEnd() => ScheduleAfterChildren(() => scroll.ScrollToEnd());
|
||||||
|
|
||||||
protected class ChatLineContainer : FillFlowContainer<ChatLine>
|
public class DaySeparator : Container
|
||||||
{
|
{
|
||||||
protected override int Compare(Drawable x, Drawable y)
|
public float TextSize
|
||||||
{
|
{
|
||||||
var xC = (ChatLine)x;
|
get => text.Font.Size;
|
||||||
var yC = (ChatLine)y;
|
set => text.Font = text.Font.With(size: value);
|
||||||
|
}
|
||||||
|
|
||||||
return xC.Message.CompareTo(yC.Message);
|
private float lineHeight = 2;
|
||||||
|
|
||||||
|
public float LineHeight
|
||||||
|
{
|
||||||
|
get => lineHeight;
|
||||||
|
set => lineHeight = leftBox.Height = rightBox.Height = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly SpriteText text;
|
||||||
|
private readonly Box leftBox;
|
||||||
|
private readonly Box rightBox;
|
||||||
|
|
||||||
|
public DaySeparator(DateTimeOffset time)
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X;
|
||||||
|
AutoSizeAxes = Axes.Y;
|
||||||
|
Child = new GridContainer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
ColumnDimensions = new[]
|
||||||
|
{
|
||||||
|
new Dimension(),
|
||||||
|
new Dimension(GridSizeMode.AutoSize),
|
||||||
|
new Dimension(),
|
||||||
|
},
|
||||||
|
RowDimensions = new[] { new Dimension(GridSizeMode.AutoSize), },
|
||||||
|
Content = new[]
|
||||||
|
{
|
||||||
|
new Drawable[]
|
||||||
|
{
|
||||||
|
leftBox = new Box
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Height = lineHeight,
|
||||||
|
},
|
||||||
|
text = new SpriteText
|
||||||
|
{
|
||||||
|
Margin = new MarginPadding { Horizontal = 10 },
|
||||||
|
Text = time.ToLocalTime().ToString("dd MMM yyyy"),
|
||||||
|
},
|
||||||
|
rightBox = new Box
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Height = lineHeight,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ namespace osu.Game.Overlays.Comments
|
|||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
AutoSizeAxes = Axes.Y,
|
AutoSizeAxes = Axes.Y,
|
||||||
Padding = new MarginPadding(margin),
|
Padding = new MarginPadding(margin) { Left = margin + 5 },
|
||||||
Child = content = new GridContainer
|
Child = content = new GridContainer
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
@ -81,11 +81,17 @@ namespace osu.Game.Overlays.Comments
|
|||||||
Spacing = new Vector2(5, 0),
|
Spacing = new Vector2(5, 0),
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
votePill = new VotePill(comment.VotesCount)
|
new Container
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
AlwaysPresent = true,
|
Width = 40,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Child = votePill = new VotePill(comment)
|
||||||
|
{
|
||||||
|
Anchor = Anchor.CentreRight,
|
||||||
|
Origin = Anchor.CentreRight,
|
||||||
|
}
|
||||||
},
|
},
|
||||||
new UpdateableAvatar(comment.User)
|
new UpdateableAvatar(comment.User)
|
||||||
{
|
{
|
||||||
@ -333,31 +339,5 @@ namespace osu.Game.Overlays.Comments
|
|||||||
return parentComment.HasMessage ? parentComment.GetMessage : parentComment.IsDeleted ? @"deleted" : string.Empty;
|
return parentComment.HasMessage ? parentComment.GetMessage : parentComment.IsDeleted ? @"deleted" : string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class VotePill : CircularContainer
|
|
||||||
{
|
|
||||||
public VotePill(int count)
|
|
||||||
{
|
|
||||||
AutoSizeAxes = Axes.X;
|
|
||||||
Height = 20;
|
|
||||||
Masking = true;
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
new Box
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Colour = OsuColour.Gray(0.05f)
|
|
||||||
},
|
|
||||||
new SpriteText
|
|
||||||
{
|
|
||||||
Anchor = Anchor.Centre,
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
Margin = new MarginPadding { Horizontal = margin },
|
|
||||||
Font = OsuFont.GetFont(size: 14),
|
|
||||||
Text = $"+{count}"
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
183
osu.Game/Overlays/Comments/VotePill.cs
Normal file
183
osu.Game/Overlays/Comments/VotePill.cs
Normal file
@ -0,0 +1,183 @@
|
|||||||
|
// 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.Containers;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Game.Graphics.Sprites;
|
||||||
|
using osuTK.Graphics;
|
||||||
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
|
using osu.Framework.Input.Events;
|
||||||
|
using osu.Game.Graphics.UserInterface;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using osuTK;
|
||||||
|
using osu.Game.Online.API;
|
||||||
|
using osu.Game.Online.API.Requests;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace osu.Game.Overlays.Comments
|
||||||
|
{
|
||||||
|
public class VotePill : LoadingButton, IHasAccentColour
|
||||||
|
{
|
||||||
|
private const int duration = 200;
|
||||||
|
|
||||||
|
public Color4 AccentColour { get; set; }
|
||||||
|
|
||||||
|
protected override IEnumerable<Drawable> EffectTargets => null;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private IAPIProvider api { get; set; }
|
||||||
|
|
||||||
|
private readonly Comment comment;
|
||||||
|
private Box background;
|
||||||
|
private Box hoverLayer;
|
||||||
|
private CircularContainer borderContainer;
|
||||||
|
private SpriteText sideNumber;
|
||||||
|
private OsuSpriteText votesCounter;
|
||||||
|
private CommentVoteRequest request;
|
||||||
|
|
||||||
|
private readonly BindableBool isVoted = new BindableBool();
|
||||||
|
private readonly BindableInt votesCount = new BindableInt();
|
||||||
|
|
||||||
|
public VotePill(Comment comment)
|
||||||
|
{
|
||||||
|
this.comment = comment;
|
||||||
|
|
||||||
|
Action = onAction;
|
||||||
|
|
||||||
|
AutoSizeAxes = Axes.X;
|
||||||
|
Height = 20;
|
||||||
|
LoadingAnimationSize = new Vector2(10);
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OsuColour colours)
|
||||||
|
{
|
||||||
|
AccentColour = borderContainer.BorderColour = sideNumber.Colour = colours.GreenLight;
|
||||||
|
hoverLayer.Colour = Color4.Black.Opacity(0.5f);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
isVoted.Value = comment.IsVoted;
|
||||||
|
votesCount.Value = comment.VotesCount;
|
||||||
|
isVoted.BindValueChanged(voted => background.Colour = voted.NewValue ? AccentColour : OsuColour.Gray(0.05f), true);
|
||||||
|
votesCount.BindValueChanged(count => votesCounter.Text = $"+{count.NewValue}", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onAction()
|
||||||
|
{
|
||||||
|
request = new CommentVoteRequest(comment.Id, isVoted.Value ? CommentVoteAction.UnVote : CommentVoteAction.Vote);
|
||||||
|
request.Success += onSuccess;
|
||||||
|
api.Queue(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onSuccess(CommentBundle response)
|
||||||
|
{
|
||||||
|
var receivedComment = response.Comments.Single();
|
||||||
|
isVoted.Value = receivedComment.IsVoted;
|
||||||
|
votesCount.Value = receivedComment.VotesCount;
|
||||||
|
IsLoading = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override Drawable CreateContent() => new Container
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Y,
|
||||||
|
AutoSizeAxes = Axes.X,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
borderContainer = new CircularContainer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Masking = true,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
background = new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both
|
||||||
|
},
|
||||||
|
hoverLayer = new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Alpha = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
sideNumber = new SpriteText
|
||||||
|
{
|
||||||
|
Anchor = Anchor.CentreLeft,
|
||||||
|
Origin = Anchor.CentreRight,
|
||||||
|
Text = "+1",
|
||||||
|
Font = OsuFont.GetFont(size: 14),
|
||||||
|
Margin = new MarginPadding { Right = 3 },
|
||||||
|
Alpha = 0,
|
||||||
|
},
|
||||||
|
votesCounter = new OsuSpriteText
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Margin = new MarginPadding { Horizontal = 10 },
|
||||||
|
Font = OsuFont.GetFont(size: 14),
|
||||||
|
AlwaysPresent = true,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
protected override void OnLoadStarted()
|
||||||
|
{
|
||||||
|
votesCounter.FadeOut(duration, Easing.OutQuint);
|
||||||
|
updateDisplay();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnLoadFinished()
|
||||||
|
{
|
||||||
|
votesCounter.FadeIn(duration, Easing.OutQuint);
|
||||||
|
|
||||||
|
if (IsHovered)
|
||||||
|
onHoverAction();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool OnHover(HoverEvent e)
|
||||||
|
{
|
||||||
|
onHoverAction();
|
||||||
|
return base.OnHover(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnHoverLost(HoverLostEvent e)
|
||||||
|
{
|
||||||
|
updateDisplay();
|
||||||
|
base.OnHoverLost(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateDisplay()
|
||||||
|
{
|
||||||
|
if (isVoted.Value)
|
||||||
|
{
|
||||||
|
hoverLayer.FadeTo(IsHovered ? 1 : 0);
|
||||||
|
sideNumber.Hide();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
sideNumber.FadeTo(IsHovered ? 1 : 0);
|
||||||
|
|
||||||
|
borderContainer.BorderThickness = IsHovered ? 3 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onHoverAction()
|
||||||
|
{
|
||||||
|
if (!IsLoading)
|
||||||
|
updateDisplay();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Dispose(bool isDisposing)
|
||||||
|
{
|
||||||
|
base.Dispose(isDisposing);
|
||||||
|
request?.Cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -200,6 +200,7 @@ namespace osu.Game.Overlays.Settings.Sections.General
|
|||||||
{
|
{
|
||||||
private TextBox username;
|
private TextBox username;
|
||||||
private TextBox password;
|
private TextBox password;
|
||||||
|
private ShakeContainer shakeSignIn;
|
||||||
private IAPIProvider api;
|
private IAPIProvider api;
|
||||||
|
|
||||||
public Action RequestHide;
|
public Action RequestHide;
|
||||||
@ -208,6 +209,8 @@ namespace osu.Game.Overlays.Settings.Sections.General
|
|||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(username.Text) && !string.IsNullOrEmpty(password.Text))
|
if (!string.IsNullOrEmpty(username.Text) && !string.IsNullOrEmpty(password.Text))
|
||||||
api.Login(username.Text, password.Text);
|
api.Login(username.Text, password.Text);
|
||||||
|
else
|
||||||
|
shakeSignIn.Shake();
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader(permitNulls: true)]
|
[BackgroundDependencyLoader(permitNulls: true)]
|
||||||
@ -244,10 +247,23 @@ namespace osu.Game.Overlays.Settings.Sections.General
|
|||||||
LabelText = "Stay signed in",
|
LabelText = "Stay signed in",
|
||||||
Bindable = config.GetBindable<bool>(OsuSetting.SavePassword),
|
Bindable = config.GetBindable<bool>(OsuSetting.SavePassword),
|
||||||
},
|
},
|
||||||
new SettingsButton
|
new Container
|
||||||
{
|
{
|
||||||
Text = "Sign in",
|
RelativeSizeAxes = Axes.X,
|
||||||
Action = performLogin
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
shakeSignIn = new ShakeContainer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Child = new SettingsButton
|
||||||
|
{
|
||||||
|
Text = "Sign in",
|
||||||
|
Action = performLogin
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
new SettingsButton
|
new SettingsButton
|
||||||
{
|
{
|
||||||
|
@ -8,12 +8,12 @@ using osu.Game.Graphics.UserInterface;
|
|||||||
namespace osu.Game.Overlays.Settings
|
namespace osu.Game.Overlays.Settings
|
||||||
{
|
{
|
||||||
public class SettingsSlider<T> : SettingsSlider<T, OsuSliderBar<T>>
|
public class SettingsSlider<T> : SettingsSlider<T, OsuSliderBar<T>>
|
||||||
where T : struct, IEquatable<T>, IComparable, IConvertible
|
where T : struct, IEquatable<T>, IComparable<T>, IConvertible
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SettingsSlider<T, U> : SettingsItem<T>
|
public class SettingsSlider<T, U> : SettingsItem<T>
|
||||||
where T : struct, IEquatable<T>, IComparable, IConvertible
|
where T : struct, IEquatable<T>, IComparable<T>, IConvertible
|
||||||
where U : OsuSliderBar<T>, new()
|
where U : OsuSliderBar<T>, new()
|
||||||
{
|
{
|
||||||
protected override Drawable CreateControl() => new U
|
protected override Drawable CreateControl() => new U
|
||||||
|
@ -37,7 +37,7 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
protected SettingsSectionsContainer SectionsContainer;
|
protected SettingsSectionsContainer SectionsContainer;
|
||||||
|
|
||||||
private SearchTextBox searchTextBox;
|
private SeekLimitedSearchTextBox searchTextBox;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Provide a source for the toolbar height.
|
/// Provide a source for the toolbar height.
|
||||||
@ -80,7 +80,7 @@ namespace osu.Game.Overlays
|
|||||||
Masking = true,
|
Masking = true,
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
ExpandableHeader = CreateHeader(),
|
ExpandableHeader = CreateHeader(),
|
||||||
FixedHeader = searchTextBox = new SearchTextBox
|
FixedHeader = searchTextBox = new SeekLimitedSearchTextBox
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
Origin = Anchor.TopCentre,
|
Origin = Anchor.TopCentre,
|
||||||
|
@ -4,14 +4,17 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using JetBrains.Annotations;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
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.Input;
|
using osu.Framework.Input;
|
||||||
using osu.Framework.Logging;
|
using osu.Framework.Logging;
|
||||||
|
using osu.Framework.Threading;
|
||||||
using osu.Framework.Timing;
|
using osu.Framework.Timing;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
using osu.Game.Rulesets.Configuration;
|
using osu.Game.Rulesets.Configuration;
|
||||||
using osu.Game.Rulesets.Edit.Tools;
|
using osu.Game.Rulesets.Edit.Tools;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
@ -22,6 +25,7 @@ using osu.Game.Screens.Edit;
|
|||||||
using osu.Game.Screens.Edit.Components.RadioButtons;
|
using osu.Game.Screens.Edit.Components.RadioButtons;
|
||||||
using osu.Game.Screens.Edit.Compose;
|
using osu.Game.Screens.Edit.Compose;
|
||||||
using osu.Game.Screens.Edit.Compose.Components;
|
using osu.Game.Screens.Edit.Compose.Components;
|
||||||
|
using osuTK;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Edit
|
namespace osu.Game.Rulesets.Edit
|
||||||
{
|
{
|
||||||
@ -30,16 +34,23 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
where TObject : HitObject
|
where TObject : HitObject
|
||||||
{
|
{
|
||||||
protected IRulesetConfigManager Config { get; private set; }
|
protected IRulesetConfigManager Config { get; private set; }
|
||||||
|
protected EditorBeatmap<TObject> EditorBeatmap { get; private set; }
|
||||||
protected readonly Ruleset Ruleset;
|
protected readonly Ruleset Ruleset;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
protected IFrameBasedClock EditorClock { get; private set; }
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private BindableBeatDivisor beatDivisor { get; set; }
|
||||||
|
|
||||||
private IWorkingBeatmap workingBeatmap;
|
private IWorkingBeatmap workingBeatmap;
|
||||||
private Beatmap<TObject> playableBeatmap;
|
private Beatmap<TObject> playableBeatmap;
|
||||||
private EditorBeatmap<TObject> editorBeatmap;
|
|
||||||
private IBeatmapProcessor beatmapProcessor;
|
private IBeatmapProcessor beatmapProcessor;
|
||||||
|
|
||||||
private DrawableEditRulesetWrapper<TObject> drawableRulesetWrapper;
|
private DrawableEditRulesetWrapper<TObject> drawableRulesetWrapper;
|
||||||
private BlueprintContainer blueprintContainer;
|
private BlueprintContainer blueprintContainer;
|
||||||
|
private Container distanceSnapGridContainer;
|
||||||
|
private DistanceSnapGrid distanceSnapGrid;
|
||||||
private readonly List<Container> layerContainers = new List<Container>();
|
private readonly List<Container> layerContainers = new List<Container>();
|
||||||
|
|
||||||
private InputManager inputManager;
|
private InputManager inputManager;
|
||||||
@ -67,11 +78,13 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var layerBelowRuleset = drawableRulesetWrapper.CreatePlayfieldAdjustmentContainer();
|
var layerBelowRuleset = drawableRulesetWrapper.CreatePlayfieldAdjustmentContainer().WithChildren(new Drawable[]
|
||||||
layerBelowRuleset.Child = new EditorPlayfieldBorder { RelativeSizeAxes = Axes.Both };
|
{
|
||||||
|
distanceSnapGridContainer = new Container { RelativeSizeAxes = Axes.Both },
|
||||||
|
new EditorPlayfieldBorder { RelativeSizeAxes = Axes.Both }
|
||||||
|
});
|
||||||
|
|
||||||
var layerAboveRuleset = drawableRulesetWrapper.CreatePlayfieldAdjustmentContainer();
|
var layerAboveRuleset = drawableRulesetWrapper.CreatePlayfieldAdjustmentContainer().WithChild(blueprintContainer = new BlueprintContainer());
|
||||||
layerAboveRuleset.Child = blueprintContainer = new BlueprintContainer();
|
|
||||||
|
|
||||||
layerContainers.Add(layerBelowRuleset);
|
layerContainers.Add(layerBelowRuleset);
|
||||||
layerContainers.Add(layerAboveRuleset);
|
layerContainers.Add(layerAboveRuleset);
|
||||||
@ -114,11 +127,13 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
};
|
};
|
||||||
|
|
||||||
toolboxCollection.Items =
|
toolboxCollection.Items =
|
||||||
CompositionTools.Select(t => new RadioButton(t.Name, () => blueprintContainer.CurrentTool = t))
|
CompositionTools.Select(t => new RadioButton(t.Name, () => selectTool(t)))
|
||||||
.Prepend(new RadioButton("Select", () => blueprintContainer.CurrentTool = null))
|
.Prepend(new RadioButton("Select", () => selectTool(null)))
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
toolboxCollection.Items[0].Select();
|
toolboxCollection.Items[0].Select();
|
||||||
|
|
||||||
|
blueprintContainer.SelectionChanged += selectionChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
||||||
@ -130,14 +145,14 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
|
|
||||||
beatmapProcessor = Ruleset.CreateBeatmapProcessor(playableBeatmap);
|
beatmapProcessor = Ruleset.CreateBeatmapProcessor(playableBeatmap);
|
||||||
|
|
||||||
editorBeatmap = new EditorBeatmap<TObject>(playableBeatmap);
|
EditorBeatmap = new EditorBeatmap<TObject>(playableBeatmap);
|
||||||
editorBeatmap.HitObjectAdded += addHitObject;
|
EditorBeatmap.HitObjectAdded += addHitObject;
|
||||||
editorBeatmap.HitObjectRemoved += removeHitObject;
|
EditorBeatmap.HitObjectRemoved += removeHitObject;
|
||||||
editorBeatmap.StartTimeChanged += updateHitObject;
|
EditorBeatmap.StartTimeChanged += updateHitObject;
|
||||||
|
|
||||||
var dependencies = new DependencyContainer(parent);
|
var dependencies = new DependencyContainer(parent);
|
||||||
dependencies.CacheAs<IEditorBeatmap>(editorBeatmap);
|
dependencies.CacheAs<IEditorBeatmap>(EditorBeatmap);
|
||||||
dependencies.CacheAs<IEditorBeatmap<TObject>>(editorBeatmap);
|
dependencies.CacheAs<IEditorBeatmap<TObject>>(EditorBeatmap);
|
||||||
|
|
||||||
Config = dependencies.Get<RulesetConfigCache>().GetConfigFor(Ruleset);
|
Config = dependencies.Get<RulesetConfigCache>().GetConfigFor(Ruleset);
|
||||||
|
|
||||||
@ -151,6 +166,16 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
inputManager = GetContainingInputManager();
|
inputManager = GetContainingInputManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private double lastGridUpdateTime;
|
||||||
|
|
||||||
|
protected override void Update()
|
||||||
|
{
|
||||||
|
base.Update();
|
||||||
|
|
||||||
|
if (EditorClock.CurrentTime != lastGridUpdateTime && blueprintContainer.CurrentTool != null)
|
||||||
|
showGridFor(Enumerable.Empty<HitObject>());
|
||||||
|
}
|
||||||
|
|
||||||
protected override void UpdateAfterChildren()
|
protected override void UpdateAfterChildren()
|
||||||
{
|
{
|
||||||
base.UpdateAfterChildren();
|
base.UpdateAfterChildren();
|
||||||
@ -164,19 +189,55 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addHitObject(HitObject hitObject) => updateHitObject(hitObject);
|
private void selectionChanged(IEnumerable<HitObject> selectedHitObjects)
|
||||||
|
|
||||||
private void removeHitObject(HitObject hitObject)
|
|
||||||
{
|
{
|
||||||
beatmapProcessor?.PreProcess();
|
var hitObjects = selectedHitObjects.ToArray();
|
||||||
beatmapProcessor?.PostProcess();
|
|
||||||
|
if (!hitObjects.Any())
|
||||||
|
distanceSnapGridContainer.Hide();
|
||||||
|
else
|
||||||
|
showGridFor(hitObjects);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateHitObject(HitObject hitObject)
|
private void selectTool(HitObjectCompositionTool tool)
|
||||||
{
|
{
|
||||||
beatmapProcessor?.PreProcess();
|
blueprintContainer.CurrentTool = tool;
|
||||||
hitObject.ApplyDefaults(playableBeatmap.ControlPointInfo, playableBeatmap.BeatmapInfo.BaseDifficulty);
|
|
||||||
beatmapProcessor?.PostProcess();
|
if (tool == null)
|
||||||
|
distanceSnapGridContainer.Hide();
|
||||||
|
else
|
||||||
|
showGridFor(Enumerable.Empty<HitObject>());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showGridFor(IEnumerable<HitObject> selectedHitObjects)
|
||||||
|
{
|
||||||
|
distanceSnapGridContainer.Clear();
|
||||||
|
distanceSnapGrid = CreateDistanceSnapGrid(selectedHitObjects);
|
||||||
|
|
||||||
|
if (distanceSnapGrid != null)
|
||||||
|
{
|
||||||
|
distanceSnapGridContainer.Child = distanceSnapGrid;
|
||||||
|
distanceSnapGridContainer.Show();
|
||||||
|
}
|
||||||
|
|
||||||
|
lastGridUpdateTime = EditorClock.CurrentTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ScheduledDelegate scheduledUpdate;
|
||||||
|
|
||||||
|
private void addHitObject(HitObject hitObject) => updateHitObject(hitObject);
|
||||||
|
|
||||||
|
private void removeHitObject(HitObject hitObject) => updateHitObject(null);
|
||||||
|
|
||||||
|
private void updateHitObject([CanBeNull] HitObject hitObject)
|
||||||
|
{
|
||||||
|
scheduledUpdate?.Cancel();
|
||||||
|
scheduledUpdate = Schedule(() =>
|
||||||
|
{
|
||||||
|
beatmapProcessor?.PreProcess();
|
||||||
|
hitObject?.ApplyDefaults(playableBeatmap.ControlPointInfo, playableBeatmap.BeatmapInfo.BaseDifficulty);
|
||||||
|
beatmapProcessor?.PostProcess();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public override IEnumerable<DrawableHitObject> HitObjects => drawableRulesetWrapper.Playfield.AllHitObjects;
|
public override IEnumerable<DrawableHitObject> HitObjects => drawableRulesetWrapper.Playfield.AllHitObjects;
|
||||||
@ -188,26 +249,73 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
|
|
||||||
public void BeginPlacement(HitObject hitObject)
|
public void BeginPlacement(HitObject hitObject)
|
||||||
{
|
{
|
||||||
|
if (distanceSnapGrid != null)
|
||||||
|
hitObject.StartTime = GetSnappedPosition(distanceSnapGrid.ToLocalSpace(inputManager.CurrentState.Mouse.Position), hitObject.StartTime).time;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void EndPlacement(HitObject hitObject) => editorBeatmap.Add(hitObject);
|
public void EndPlacement(HitObject hitObject)
|
||||||
|
{
|
||||||
|
EditorBeatmap.Add(hitObject);
|
||||||
|
showGridFor(Enumerable.Empty<HitObject>());
|
||||||
|
}
|
||||||
|
|
||||||
public void Delete(HitObject hitObject) => editorBeatmap.Remove(hitObject);
|
public void Delete(HitObject hitObject) => EditorBeatmap.Remove(hitObject);
|
||||||
|
|
||||||
|
public override (Vector2 position, double time) GetSnappedPosition(Vector2 position, double time) => distanceSnapGrid?.GetSnappedPosition(position) ?? (position, time);
|
||||||
|
|
||||||
|
public override float GetBeatSnapDistanceAt(double referenceTime)
|
||||||
|
{
|
||||||
|
DifficultyControlPoint difficultyPoint = EditorBeatmap.ControlPointInfo.DifficultyPointAt(referenceTime);
|
||||||
|
return (float)(100 * EditorBeatmap.BeatmapInfo.BaseDifficulty.SliderMultiplier * difficultyPoint.SpeedMultiplier / beatDivisor.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override float DurationToDistance(double referenceTime, double duration)
|
||||||
|
{
|
||||||
|
double beatLength = EditorBeatmap.ControlPointInfo.TimingPointAt(referenceTime).BeatLength / beatDivisor.Value;
|
||||||
|
return (float)(duration / beatLength * GetBeatSnapDistanceAt(referenceTime));
|
||||||
|
}
|
||||||
|
|
||||||
|
public override double DistanceToDuration(double referenceTime, float distance)
|
||||||
|
{
|
||||||
|
double beatLength = EditorBeatmap.ControlPointInfo.TimingPointAt(referenceTime).BeatLength / beatDivisor.Value;
|
||||||
|
return distance / GetBeatSnapDistanceAt(referenceTime) * beatLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override double GetSnappedDurationFromDistance(double referenceTime, float distance)
|
||||||
|
=> beatSnap(referenceTime, DistanceToDuration(referenceTime, distance));
|
||||||
|
|
||||||
|
public override float GetSnappedDistanceFromDistance(double referenceTime, float distance)
|
||||||
|
=> DurationToDistance(referenceTime, beatSnap(referenceTime, DistanceToDuration(referenceTime, distance)));
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Snaps a duration to the closest beat of a timing point applicable at the reference time.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="referenceTime">The time of the timing point which <paramref name="duration"/> resides in.</param>
|
||||||
|
/// <param name="duration">The duration to snap.</param>
|
||||||
|
/// <returns>A value that represents <paramref name="duration"/> snapped to the closest beat of the timing point.</returns>
|
||||||
|
private double beatSnap(double referenceTime, double duration)
|
||||||
|
{
|
||||||
|
double beatLength = EditorBeatmap.ControlPointInfo.TimingPointAt(referenceTime).BeatLength / beatDivisor.Value;
|
||||||
|
|
||||||
|
// A 1ms offset prevents rounding errors due to minute variations in duration
|
||||||
|
return (int)((duration + 1) / beatLength) * beatLength;
|
||||||
|
}
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
protected override void Dispose(bool isDisposing)
|
||||||
{
|
{
|
||||||
base.Dispose(isDisposing);
|
base.Dispose(isDisposing);
|
||||||
|
|
||||||
if (editorBeatmap != null)
|
if (EditorBeatmap != null)
|
||||||
{
|
{
|
||||||
editorBeatmap.HitObjectAdded -= addHitObject;
|
EditorBeatmap.HitObjectAdded -= addHitObject;
|
||||||
editorBeatmap.HitObjectRemoved -= removeHitObject;
|
EditorBeatmap.HitObjectRemoved -= removeHitObject;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Cached(typeof(HitObjectComposer))]
|
[Cached(typeof(HitObjectComposer))]
|
||||||
public abstract class HitObjectComposer : CompositeDrawable
|
[Cached(typeof(IDistanceSnapProvider))]
|
||||||
|
public abstract class HitObjectComposer : CompositeDrawable, IDistanceSnapProvider
|
||||||
{
|
{
|
||||||
internal HitObjectComposer()
|
internal HitObjectComposer()
|
||||||
{
|
{
|
||||||
@ -234,5 +342,20 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
/// Creates a <see cref="SelectionHandler"/> which outlines <see cref="DrawableHitObject"/>s and handles movement of selections.
|
/// Creates a <see cref="SelectionHandler"/> which outlines <see cref="DrawableHitObject"/>s and handles movement of selections.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual SelectionHandler CreateSelectionHandler() => new SelectionHandler();
|
public virtual SelectionHandler CreateSelectionHandler() => new SelectionHandler();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates the <see cref="DistanceSnapGrid"/> applicable for a <see cref="HitObject"/> selection.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="selectedHitObjects">The <see cref="HitObject"/> selection.</param>
|
||||||
|
/// <returns>The <see cref="DistanceSnapGrid"/> for <paramref name="selectedHitObjects"/>.</returns>
|
||||||
|
[CanBeNull]
|
||||||
|
protected virtual DistanceSnapGrid CreateDistanceSnapGrid([NotNull] IEnumerable<HitObject> selectedHitObjects) => null;
|
||||||
|
|
||||||
|
public abstract (Vector2 position, double time) GetSnappedPosition(Vector2 position, double time);
|
||||||
|
public abstract float GetBeatSnapDistanceAt(double referenceTime);
|
||||||
|
public abstract float DurationToDistance(double referenceTime, double duration);
|
||||||
|
public abstract double DistanceToDuration(double referenceTime, float distance);
|
||||||
|
public abstract double GetSnappedDurationFromDistance(double referenceTime, float distance);
|
||||||
|
public abstract float GetSnappedDistanceFromDistance(double referenceTime, float distance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
51
osu.Game/Rulesets/Edit/IDistanceSnapProvider.cs
Normal file
51
osu.Game/Rulesets/Edit/IDistanceSnapProvider.cs
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
// 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 osuTK;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Edit
|
||||||
|
{
|
||||||
|
public interface IDistanceSnapProvider
|
||||||
|
{
|
||||||
|
(Vector2 position, double time) GetSnappedPosition(Vector2 position, double time);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieves the distance between two points within a timing point that are one beat length apart.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="referenceTime">The time of the timing point.</param>
|
||||||
|
/// <returns>The distance between two points residing in the timing point that are one beat length apart.</returns>
|
||||||
|
float GetBeatSnapDistanceAt(double referenceTime);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Converts a duration to a distance.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="referenceTime">The time of the timing point which <paramref name="duration"/> resides in.</param>
|
||||||
|
/// <param name="duration">The duration to convert.</param>
|
||||||
|
/// <returns>A value that represents <paramref name="duration"/> as a distance in the timing point.</returns>
|
||||||
|
float DurationToDistance(double referenceTime, double duration);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Converts a distance to a duration.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="referenceTime">The time of the timing point which <paramref name="distance"/> resides in.</param>
|
||||||
|
/// <param name="distance">The distance to convert.</param>
|
||||||
|
/// <returns>A value that represents <paramref name="distance"/> as a duration in the timing point.</returns>
|
||||||
|
double DistanceToDuration(double referenceTime, float distance);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Converts a distance to a snapped duration.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="referenceTime">The time of the timing point which <paramref name="distance"/> resides in.</param>
|
||||||
|
/// <param name="distance">The distance to convert.</param>
|
||||||
|
/// <returns>A value that represents <paramref name="distance"/> as a duration snapped to the closest beat of the timing point.</returns>
|
||||||
|
double GetSnappedDurationFromDistance(double referenceTime, float distance);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Converts an unsnapped distance to a snapped distance.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="referenceTime">The time of the timing point which <paramref name="distance"/> resides in.</param>
|
||||||
|
/// <param name="distance">The distance to convert.</param>
|
||||||
|
/// <returns>A value that represents <paramref name="distance"/> snapped to the closest beat of the timing point.</returns>
|
||||||
|
float GetSnappedDistanceFromDistance(double referenceTime, float distance);
|
||||||
|
}
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user