1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-13 14:13:18 +08:00

Merge branch 'note-placement' into inter-column-movements

# Conflicts:
#	osu.Game.Rulesets.Mania/Edit/ManiaHitObjectComposer.cs
This commit is contained in:
smoogipoo 2018-11-26 11:47:22 +09:00
commit c0fcbc283e
7 changed files with 49 additions and 36 deletions

View File

@ -11,8 +11,8 @@ using osu.Game.Rulesets.Mania.UI;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.UI.Scrolling;
using osu.Game.Tests.Visual;
using OpenTK;
using OpenTK.Graphics;
using osuTK;
using osuTK.Graphics;
namespace osu.Game.Rulesets.Mania.Tests
{

View File

@ -4,16 +4,16 @@
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Input.Events;
using osu.Framework.Threading;
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Mania.Objects;
using osu.Game.Rulesets.Mania.Objects.Drawables.Pieces;
using osu.Game.Rulesets.Mania.UI;
using osu.Game.Rulesets.UI.Scrolling;
using OpenTK;
using osuTK;
namespace osu.Game.Rulesets.Mania.Edit.Blueprints
{
public class ManiaPlacementBlueprint<T> : PlacementBlueprint
public abstract class ManiaPlacementBlueprint<T> : PlacementBlueprint
where T : ManiaHitObject
{
protected new T HitObject => (T)base.HitObject;
@ -23,13 +23,18 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
/// </summary>
protected Vector2 SnappedMousePosition { get; private set; }
/// <summary>
/// The width of the closest column to the current mouse position.
/// </summary>
protected float SnappedWidth { get; private set; }
[Resolved]
private IManiaHitObjectComposer composer { get; set; }
[Resolved]
private IScrollingInfo scrollingInfo { get; set; }
public ManiaPlacementBlueprint(T hitObject)
protected ManiaPlacementBlueprint(T hitObject)
: base(hitObject)
{
RelativeSizeAxes = Axes.None;
@ -37,27 +42,20 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
protected override bool OnMouseMove(MouseMoveEvent e)
{
updateSnappedPosition(e);
return true;
}
Column column = ColumnAt(e.ScreenSpaceMousePosition);
private ScheduledDelegate scheduledSnappedPositionUpdate;
private void updateSnappedPosition(MouseMoveEvent e)
{
scheduledSnappedPositionUpdate?.Cancel();
scheduledSnappedPositionUpdate = Schedule(() =>
if (column == null)
SnappedMousePosition = e.MousePosition;
else
{
Column column = ColumnAt(e.ScreenSpaceMousePosition);
if (column == null)
SnappedMousePosition = e.MousePosition;
else
{
// Snap to the column
var parentPos = Parent.ToLocalSpace(column.ToScreenSpace(new Vector2(column.DrawWidth / 2, 0)));
SnappedMousePosition = new Vector2(parentPos.X, e.MousePosition.Y);
}
});
SnappedWidth = column.DrawWidth;
// Snap to the column
var parentPos = Parent.ToLocalSpace(column.ToScreenSpace(new Vector2(column.DrawWidth / 2, 0)));
SnappedMousePosition = new Vector2(parentPos.X, e.MousePosition.Y);
}
return true;
}
protected double TimeAt(Vector2 screenSpacePosition)
@ -88,10 +86,10 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
switch (scrollingInfo.Direction.Value)
{
case ScrollingDirection.Up:
position.Y -= DrawHeight / 2;
position.Y -= NotePiece.NOTE_HEIGHT / 2;
break;
case ScrollingDirection.Down:
position.Y += DrawHeight / 2;
position.Y += NotePiece.NOTE_HEIGHT / 2;
break;
}

View File

@ -17,7 +17,6 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
Origin = Anchor.Centre;
AutoSizeAxes = Axes.Y;
Width = 45;
InternalChild = new EditNotePiece { RelativeSizeAxes = Axes.X };
}
@ -26,6 +25,7 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
{
base.Update();
Width = SnappedWidth;
Position = SnappedMousePosition;
}

View File

@ -2,7 +2,7 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Game.Rulesets.Mania.UI;
using OpenTK;
using osuTK;
namespace osu.Game.Rulesets.Mania.Edit
{

View File

@ -13,35 +13,42 @@ using osu.Game.Rulesets.Mania.Edit.Blueprints;
using osu.Game.Rulesets.Mania.UI;
using osu.Game.Rulesets.UI;
using osu.Game.Screens.Edit.Compose.Components;
using OpenTK;
using osuTK;
namespace osu.Game.Rulesets.Mania.Edit
{
[Cached(Type = typeof(IManiaHitObjectComposer))]
public class ManiaHitObjectComposer : HitObjectComposer<ManiaHitObject>, IManiaHitObjectComposer
{
protected new ManiaEditRulesetContainer RulesetContainer { get; private set; }
public ManiaHitObjectComposer(Ruleset ruleset)
: base(ruleset)
{
}
/// <summary>
/// Retrieves the column that intersects a screen-space position.
/// </summary>
/// <param name="screenSpacePosition">The screen-space position.</param>
/// <returns>The column which intersects with <paramref name="screenSpacePosition"/>.</returns>
public Column ColumnAt(Vector2 screenSpacePosition) => RulesetContainer.GetColumnByPosition(screenSpacePosition);
private DependencyContainer dependencies;
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
=> dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
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)
{
var rulesetContainer = new ManiaEditRulesetContainer(ruleset, beatmap);
RulesetContainer = new ManiaEditRulesetContainer(ruleset, beatmap);
// This is the earliest we can cache the scrolling info to ourselves, before masks are added to the hierarchy and inject it
dependencies.CacheAs(rulesetContainer.ScrollingInfo);
dependencies.CacheAs(RulesetContainer.ScrollingInfo);
return rulesetContainer;
return RulesetContainer;
}
protected override IReadOnlyList<HitObjectCompositionTool> CompositionTools => new HitObjectCompositionTool[]

View File

@ -13,7 +13,7 @@ using osu.Framework.Input.Bindings;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Mania.UI.Components;
using osu.Game.Rulesets.UI.Scrolling;
using OpenTK;
using osuTK;
namespace osu.Game.Rulesets.Mania.UI
{

View File

@ -25,6 +25,7 @@ using osu.Game.Rulesets.Replays;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.UI;
using osu.Game.Rulesets.UI.Scrolling;
using osuTK;
namespace osu.Game.Rulesets.Mania.UI
{
@ -80,6 +81,13 @@ namespace osu.Game.Rulesets.Mania.UI
Config.BindWith(ManiaSetting.ScrollTime, TimeRange);
}
/// <summary>
/// Retrieves the column that intersects a screen-space position.
/// </summary>
/// <param name="screenSpacePosition">The screen-space position.</param>
/// <returns>The column which intersects with <paramref name="screenSpacePosition"/>.</returns>
public Column GetColumnByPosition(Vector2 screenSpacePosition) => Playfield.GetColumnByPosition(screenSpacePosition);
protected override Playfield CreatePlayfield() => new ManiaPlayfield(Beatmap.Stages)
{
Anchor = Anchor.Centre,