mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 12:17:26 +08:00
Basic inter-column selection movement
This commit is contained in:
parent
df7515b66f
commit
f7fc2ca569
@ -46,5 +46,7 @@ namespace osu.Game.Rulesets.Mania.Tests
|
|||||||
protected override void AddHitObject(DrawableHitObject hitObject) => column.Add((DrawableManiaHitObject)hitObject);
|
protected override void AddHitObject(DrawableHitObject hitObject) => column.Add((DrawableManiaHitObject)hitObject);
|
||||||
|
|
||||||
public Column ColumnAt(Vector2 screenSpacePosition) => column;
|
public Column ColumnAt(Vector2 screenSpacePosition) => column;
|
||||||
|
|
||||||
|
public int TotalColumns => 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,14 +2,37 @@
|
|||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Timing;
|
using osu.Framework.Timing;
|
||||||
|
using osu.Game.Rulesets.Mania.Edit;
|
||||||
|
using osu.Game.Rulesets.Mania.UI;
|
||||||
using osu.Game.Tests.Visual;
|
using osu.Game.Tests.Visual;
|
||||||
|
using OpenTK;
|
||||||
|
using OpenTK.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Mania.Tests
|
namespace osu.Game.Rulesets.Mania.Tests
|
||||||
{
|
{
|
||||||
public abstract class ManiaSelectionBlueprintTestCase : SelectionBlueprintTestCase
|
[Cached(Type = typeof(IManiaHitObjectComposer))]
|
||||||
|
public abstract class ManiaSelectionBlueprintTestCase : SelectionBlueprintTestCase, IManiaHitObjectComposer
|
||||||
{
|
{
|
||||||
[Cached(Type = typeof(IAdjustableClock))]
|
[Cached(Type = typeof(IAdjustableClock))]
|
||||||
private readonly IAdjustableClock clock = new StopwatchClock();
|
private readonly IAdjustableClock clock = new StopwatchClock();
|
||||||
|
|
||||||
|
private readonly Column column;
|
||||||
|
|
||||||
|
protected ManiaSelectionBlueprintTestCase()
|
||||||
|
{
|
||||||
|
Add(column = new Column(0)
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
AccentColour = Color4.OrangeRed,
|
||||||
|
Clock = new FramedClock(new StopwatchClock()), // No scroll
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public Column ColumnAt(Vector2 screenSpacePosition) => column;
|
||||||
|
|
||||||
|
public int TotalColumns => 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,11 +2,15 @@
|
|||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
using osu.Framework.Timing;
|
using osu.Framework.Timing;
|
||||||
using osu.Game.Rulesets.Edit;
|
using osu.Game.Rulesets.Edit;
|
||||||
|
using osu.Game.Rulesets.Mania.Objects;
|
||||||
|
using osu.Game.Rulesets.Mania.Objects.Drawables;
|
||||||
|
using osu.Game.Rulesets.Mania.UI;
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
using osu.Game.Rulesets.UI.Scrolling;
|
using osu.Game.Rulesets.UI.Scrolling;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
@ -20,6 +24,9 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private IScrollingInfo scrollingInfo { get; set; }
|
private IScrollingInfo scrollingInfo { get; set; }
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private IManiaHitObjectComposer composer { get; set; }
|
||||||
|
|
||||||
public ManiaSelectionBlueprint(DrawableHitObject hitObject)
|
public ManiaSelectionBlueprint(DrawableHitObject hitObject)
|
||||||
: base(hitObject)
|
: base(hitObject)
|
||||||
{
|
{
|
||||||
@ -41,6 +48,8 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
|||||||
|
|
||||||
public override void AdjustPosition(DragEvent dragEvent, IEnumerable<DrawableHitObject> selectedObjects)
|
public override void AdjustPosition(DragEvent dragEvent, IEnumerable<DrawableHitObject> selectedObjects)
|
||||||
{
|
{
|
||||||
|
var maniaObject = (ManiaHitObject)HitObject.HitObject;
|
||||||
|
|
||||||
var objectParent = HitObject.Parent;
|
var objectParent = HitObject.Parent;
|
||||||
|
|
||||||
// Using the hitobject position is required since AdjustPosition can be invoked multiple times per frame
|
// Using the hitobject position is required since AdjustPosition can be invoked multiple times per frame
|
||||||
@ -60,6 +69,34 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
|||||||
EditorClock.CurrentTime,
|
EditorClock.CurrentTime,
|
||||||
scrollingInfo.TimeRange.Value,
|
scrollingInfo.TimeRange.Value,
|
||||||
objectParent.DrawHeight);
|
objectParent.DrawHeight);
|
||||||
|
|
||||||
|
var lastColumn = ColumnAt(dragEvent.ScreenSpaceLastMousePosition);
|
||||||
|
var currentColumn = ColumnAt(dragEvent.ScreenSpaceMousePosition);
|
||||||
|
if (lastColumn != null && currentColumn != null)
|
||||||
|
{
|
||||||
|
int columnDelta = currentColumn.Index - lastColumn.Index;
|
||||||
|
|
||||||
|
if (columnDelta != 0)
|
||||||
|
{
|
||||||
|
int minColumn = int.MaxValue;
|
||||||
|
int maxColumn = int.MinValue;
|
||||||
|
|
||||||
|
foreach (var obj in selectedObjects.OfType<DrawableManiaHitObject>())
|
||||||
|
{
|
||||||
|
if (obj.HitObject.Column < minColumn)
|
||||||
|
minColumn = obj.HitObject.Column;
|
||||||
|
if (obj.HitObject.Column > maxColumn)
|
||||||
|
maxColumn = obj.HitObject.Column;
|
||||||
|
}
|
||||||
|
|
||||||
|
columnDelta = MathHelper.Clamp(columnDelta, -minColumn, composer.TotalColumns - 1 - maxColumn);
|
||||||
|
}
|
||||||
|
|
||||||
|
Schedule(() => maniaObject.Column += columnDelta);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected Column ColumnAt(Vector2 screenSpacePosition) => composer.ColumnAt(screenSpacePosition);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,5 +9,7 @@ namespace osu.Game.Rulesets.Mania.Edit
|
|||||||
public interface IManiaHitObjectComposer
|
public interface IManiaHitObjectComposer
|
||||||
{
|
{
|
||||||
Column ColumnAt(Vector2 screenSpacePosition);
|
Column ColumnAt(Vector2 screenSpacePosition);
|
||||||
|
|
||||||
|
int TotalColumns { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,8 @@ namespace osu.Game.Rulesets.Mania.Edit
|
|||||||
|
|
||||||
public Column ColumnAt(Vector2 screenSpacePosition) => ((ManiaPlayfield)RulesetContainer.Playfield).GetColumnByPosition(screenSpacePosition);
|
public Column ColumnAt(Vector2 screenSpacePosition) => ((ManiaPlayfield)RulesetContainer.Playfield).GetColumnByPosition(screenSpacePosition);
|
||||||
|
|
||||||
|
public int TotalColumns => ((ManiaPlayfield)RulesetContainer.Playfield).TotalColumns;
|
||||||
|
|
||||||
protected override RulesetContainer<ManiaHitObject> CreateRulesetContainer(Ruleset ruleset, WorkingBeatmap beatmap)
|
protected override RulesetContainer<ManiaHitObject> CreateRulesetContainer(Ruleset ruleset, WorkingBeatmap beatmap)
|
||||||
{
|
{
|
||||||
var rulesetContainer = new ManiaEditRulesetContainer(ruleset, beatmap);
|
var rulesetContainer = new ManiaEditRulesetContainer(ruleset, beatmap);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using osu.Framework.Configuration;
|
||||||
using osu.Game.Rulesets.Mania.Objects.Types;
|
using osu.Game.Rulesets.Mania.Objects.Types;
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
|
|
||||||
@ -8,7 +9,13 @@ namespace osu.Game.Rulesets.Mania.Objects
|
|||||||
{
|
{
|
||||||
public abstract class ManiaHitObject : HitObject, IHasColumn
|
public abstract class ManiaHitObject : HitObject, IHasColumn
|
||||||
{
|
{
|
||||||
public virtual int Column { get; set; }
|
public readonly Bindable<int> ColumnBindable = new Bindable<int>();
|
||||||
|
|
||||||
|
public virtual int Column
|
||||||
|
{
|
||||||
|
get => ColumnBindable;
|
||||||
|
set => ColumnBindable.Value = value;
|
||||||
|
}
|
||||||
|
|
||||||
protected override HitWindows CreateHitWindows() => new ManiaHitWindows();
|
protected override HitWindows CreateHitWindows() => new ManiaHitWindows();
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ using osu.Framework.Graphics;
|
|||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using osu.Game.Rulesets.Mania.Beatmaps;
|
using osu.Game.Rulesets.Mania.Beatmaps;
|
||||||
using osu.Game.Rulesets.Mania.Objects;
|
using osu.Game.Rulesets.Mania.Objects;
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
@ -81,6 +82,11 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieves the total amount of columns across all stages in this playfield.
|
||||||
|
/// </summary>
|
||||||
|
public int TotalColumns => stages.Sum(s => s.Columns.Count);
|
||||||
|
|
||||||
private ManiaStage getStageByColumn(int column)
|
private ManiaStage getStageByColumn(int column)
|
||||||
{
|
{
|
||||||
int sum = 0;
|
int sum = 0;
|
||||||
|
@ -152,8 +152,18 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
public override void Add(DrawableHitObject h)
|
public override void Add(DrawableHitObject h)
|
||||||
{
|
{
|
||||||
var maniaObject = (ManiaHitObject)h.HitObject;
|
var maniaObject = (ManiaHitObject)h.HitObject;
|
||||||
int columnIndex = maniaObject.Column - firstColumnIndex;
|
|
||||||
|
int columnIndex = -1;
|
||||||
|
|
||||||
|
maniaObject.ColumnBindable.BindValueChanged(_ =>
|
||||||
|
{
|
||||||
|
if (columnIndex != -1)
|
||||||
|
Columns.ElementAt(columnIndex).Remove(h);
|
||||||
|
|
||||||
|
columnIndex = maniaObject.Column - firstColumnIndex;
|
||||||
Columns.ElementAt(columnIndex).Add(h);
|
Columns.ElementAt(columnIndex).Add(h);
|
||||||
|
}, true);
|
||||||
|
|
||||||
h.OnNewResult += OnNewResult;
|
h.OnNewResult += OnNewResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user