mirror of
https://github.com/ppy/osu.git
synced 2025-01-27 13:23:05 +08:00
Merge branch 'master' into fix-mania-placement
This commit is contained in:
commit
0fdb07346b
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Input.Events;
|
|
||||||
using osu.Game.Rulesets.Mania.Edit.Blueprints.Components;
|
using osu.Game.Rulesets.Mania.Edit.Blueprints.Components;
|
||||||
using osu.Game.Rulesets.Mania.Objects;
|
using osu.Game.Rulesets.Mania.Objects;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
@ -49,13 +48,13 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
|||||||
|
|
||||||
private double originalStartTime;
|
private double originalStartTime;
|
||||||
|
|
||||||
protected override bool OnMouseMove(MouseMoveEvent e)
|
public override void UpdatePosition(Vector2 screenSpacePosition)
|
||||||
{
|
{
|
||||||
base.OnMouseMove(e);
|
base.UpdatePosition(screenSpacePosition);
|
||||||
|
|
||||||
if (PlacementBegun)
|
if (PlacementBegun)
|
||||||
{
|
{
|
||||||
var endTime = TimeAt(e.ScreenSpaceMousePosition);
|
var endTime = TimeAt(screenSpacePosition);
|
||||||
|
|
||||||
HitObject.StartTime = endTime < originalStartTime ? endTime : originalStartTime;
|
HitObject.StartTime = endTime < originalStartTime ? endTime : originalStartTime;
|
||||||
HitObject.Duration = Math.Abs(endTime - originalStartTime);
|
HitObject.Duration = Math.Abs(endTime - originalStartTime);
|
||||||
@ -65,10 +64,8 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
|||||||
headPiece.Width = tailPiece.Width = SnappedWidth;
|
headPiece.Width = tailPiece.Width = SnappedWidth;
|
||||||
headPiece.X = tailPiece.X = SnappedMousePosition.X;
|
headPiece.X = tailPiece.X = SnappedMousePosition.X;
|
||||||
|
|
||||||
originalStartTime = HitObject.StartTime = TimeAt(e.ScreenSpaceMousePosition);
|
originalStartTime = HitObject.StartTime = TimeAt(screenSpacePosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,19 +62,18 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
|||||||
return base.OnMouseUp(e);
|
return base.OnMouseUp(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnMouseMove(MouseMoveEvent e)
|
public override void UpdatePosition(Vector2 screenSpacePosition)
|
||||||
{
|
{
|
||||||
if (!PlacementBegun)
|
if (!PlacementBegun)
|
||||||
Column = ColumnAt(e.ScreenSpaceMousePosition);
|
Column = ColumnAt(screenSpacePosition);
|
||||||
|
|
||||||
if (Column == null) return false;
|
if (Column == null) return;
|
||||||
|
|
||||||
SnappedWidth = Column.DrawWidth;
|
SnappedWidth = Column.DrawWidth;
|
||||||
|
|
||||||
// Snap to the column
|
// Snap to the column
|
||||||
var parentPos = Parent.ToLocalSpace(Column.ToScreenSpace(new Vector2(Column.DrawWidth / 2, 0)));
|
var parentPos = Parent.ToLocalSpace(Column.ToScreenSpace(new Vector2(Column.DrawWidth / 2, 0)));
|
||||||
SnappedMousePosition = new Vector2(parentPos.X, e.MousePosition.Y);
|
SnappedMousePosition = new Vector2(parentPos.X, Parent.ToLocalSpace(screenSpacePosition).Y);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected double TimeAt(Vector2 screenSpacePosition)
|
protected double TimeAt(Vector2 screenSpacePosition)
|
||||||
|
@ -19,14 +19,6 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles
|
|||||||
InternalChild = new HitCirclePiece(HitObject);
|
InternalChild = new HitCirclePiece(HitObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
|
||||||
{
|
|
||||||
base.LoadComplete();
|
|
||||||
|
|
||||||
// Fixes a 1-frame position discrepancy due to the first mouse move event happening in the next frame
|
|
||||||
HitObject.Position = Parent?.ToLocalSpace(GetContainingInputManager().CurrentState.Mouse.Position) ?? Vector2.Zero;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override bool OnClick(ClickEvent e)
|
protected override bool OnClick(ClickEvent e)
|
||||||
{
|
{
|
||||||
HitObject.StartTime = EditorClock.CurrentTime;
|
HitObject.StartTime = EditorClock.CurrentTime;
|
||||||
@ -34,10 +26,9 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnMouseMove(MouseMoveEvent e)
|
public override void UpdatePosition(Vector2 screenSpacePosition)
|
||||||
{
|
{
|
||||||
HitObject.Position = e.MousePosition;
|
HitObject.Position = ToLocalSpace(screenSpacePosition);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,28 +47,18 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
|
|||||||
setState(PlacementState.Initial);
|
setState(PlacementState.Initial);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
public override void UpdatePosition(Vector2 screenSpacePosition)
|
||||||
{
|
|
||||||
base.LoadComplete();
|
|
||||||
|
|
||||||
// Fixes a 1-frame position discrepancy due to the first mouse move event happening in the next frame
|
|
||||||
HitObject.Position = Parent?.ToLocalSpace(GetContainingInputManager().CurrentState.Mouse.Position) ?? Vector2.Zero;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override bool OnMouseMove(MouseMoveEvent e)
|
|
||||||
{
|
{
|
||||||
switch (state)
|
switch (state)
|
||||||
{
|
{
|
||||||
case PlacementState.Initial:
|
case PlacementState.Initial:
|
||||||
HitObject.Position = e.MousePosition;
|
HitObject.Position = ToLocalSpace(screenSpacePosition);
|
||||||
return true;
|
break;
|
||||||
|
|
||||||
case PlacementState.Body:
|
case PlacementState.Body:
|
||||||
cursor = e.MousePosition - HitObject.Position;
|
cursor = ToLocalSpace(screenSpacePosition) - HitObject.Position;
|
||||||
return true;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnClick(ClickEvent e)
|
protected override bool OnClick(ClickEvent e)
|
||||||
|
@ -7,6 +7,7 @@ using osu.Game.Rulesets.Edit;
|
|||||||
using osu.Game.Rulesets.Osu.Edit.Blueprints.Spinners.Components;
|
using osu.Game.Rulesets.Osu.Edit.Blueprints.Spinners.Components;
|
||||||
using osu.Game.Rulesets.Osu.Objects;
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
using osu.Game.Rulesets.Osu.UI;
|
using osu.Game.Rulesets.Osu.UI;
|
||||||
|
using osuTK;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Spinners
|
namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Spinners
|
||||||
{
|
{
|
||||||
@ -43,5 +44,9 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Spinners
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void UpdatePosition(Vector2 screenSpacePosition)
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -591,5 +591,27 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
|||||||
Assert.Throws<IOException>(() => Decoder.GetDecoder<Beatmap>(stream));
|
Assert.Throws<IOException>(() => Decoder.GetDecoder<Beatmap>(stream));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestAllowFallbackDecoderOverwrite()
|
||||||
|
{
|
||||||
|
Decoder<Beatmap> decoder = null;
|
||||||
|
|
||||||
|
using (var resStream = TestResources.OpenResource("corrupted-header.osu"))
|
||||||
|
using (var stream = new LineBufferedReader(resStream))
|
||||||
|
{
|
||||||
|
Assert.DoesNotThrow(() => decoder = Decoder.GetDecoder<Beatmap>(stream));
|
||||||
|
Assert.IsInstanceOf<LegacyBeatmapDecoder>(decoder);
|
||||||
|
}
|
||||||
|
|
||||||
|
Assert.DoesNotThrow(LegacyDifficultyCalculatorBeatmapDecoder.Register);
|
||||||
|
|
||||||
|
using (var resStream = TestResources.OpenResource("corrupted-header.osu"))
|
||||||
|
using (var stream = new LineBufferedReader(resStream))
|
||||||
|
{
|
||||||
|
Assert.DoesNotThrow(() => decoder = Decoder.GetDecoder<Beatmap>(stream));
|
||||||
|
Assert.IsInstanceOf<LegacyDifficultyCalculatorBeatmapDecoder>(decoder);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,8 +18,8 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
|
|
||||||
overlay.AddButton(@"Remove", @"from unplayed", FontAwesome.Regular.TimesCircle, Color4.Purple, null, Key.Number1);
|
overlay.AddButton(@"Remove", @"from unplayed", FontAwesome.Regular.TimesCircle, Color4.Purple, null, Key.Number1);
|
||||||
overlay.AddButton(@"Clear", @"local scores", FontAwesome.Solid.Eraser, Color4.Purple, null, Key.Number2);
|
overlay.AddButton(@"Clear", @"local scores", FontAwesome.Solid.Eraser, Color4.Purple, null, Key.Number2);
|
||||||
overlay.AddButton(@"Edit", @"Beatmap", FontAwesome.Solid.PencilAlt, Color4.Yellow, null, Key.Number3);
|
overlay.AddButton(@"Delete", @"all difficulties", FontAwesome.Solid.Trash, Color4.Pink, null, Key.Number3);
|
||||||
overlay.AddButton(@"Delete", @"Beatmap", FontAwesome.Solid.Trash, Color4.Pink, null, Key.Number4, float.MaxValue);
|
overlay.AddButton(@"Edit", @"beatmap", FontAwesome.Solid.PencilAlt, Color4.Yellow, null, Key.Number4);
|
||||||
|
|
||||||
Add(overlay);
|
Add(overlay);
|
||||||
|
|
||||||
|
@ -93,14 +93,12 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Registers a fallback decoder instantiation function.
|
/// Registers a fallback decoder instantiation function.
|
||||||
/// The fallback will be returned if the first non-empty line of the decoded stream does not match any known magic.
|
/// The fallback will be returned if the first non-empty line of the decoded stream does not match any known magic.
|
||||||
|
/// Calling this method will overwrite any existing global fallback registration for type <see cref="T"/> - use with caution.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="T">Type of object being decoded.</typeparam>
|
/// <typeparam name="T">Type of object being decoded.</typeparam>
|
||||||
/// <param name="constructor">A function that constructs the fallback<see cref="Decoder"/>.</param>
|
/// <param name="constructor">A function that constructs the fallback<see cref="Decoder"/>.</param>
|
||||||
protected static void SetFallbackDecoder<T>(Func<Decoder> constructor)
|
protected static void SetFallbackDecoder<T>(Func<Decoder> constructor)
|
||||||
{
|
{
|
||||||
if (fallback_decoders.ContainsKey(typeof(T)))
|
|
||||||
throw new InvalidOperationException($"A fallback decoder was already added for type {typeof(T)}.");
|
|
||||||
|
|
||||||
fallback_decoders[typeof(T)] = constructor;
|
fallback_decoders[typeof(T)] = constructor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -108,6 +108,12 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
placementHandler.EndPlacement(HitObject);
|
placementHandler.EndPlacement(HitObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Updates the position of this <see cref="PlacementBlueprint"/> to a new screen-space position.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="screenSpacePosition">The screen-space position.</param>
|
||||||
|
public abstract void UpdatePosition(Vector2 screenSpacePosition);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Invokes <see cref="Objects.HitObject.ApplyDefaults(ControlPointInfo,BeatmapDifficulty)"/>,
|
/// Invokes <see cref="Objects.HitObject.ApplyDefaults(ControlPointInfo,BeatmapDifficulty)"/>,
|
||||||
/// refreshing <see cref="Objects.HitObject.NestedHitObjects"/> and parameters for the <see cref="HitObject"/>.
|
/// refreshing <see cref="Objects.HitObject.NestedHitObjects"/> and parameters for the <see cref="HitObject"/>.
|
||||||
@ -125,7 +131,7 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
case ScrollEvent _:
|
case ScrollEvent _:
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
case MouseEvent _:
|
case MouseButtonEvent _:
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -7,6 +7,7 @@ using osu.Framework.Allocation;
|
|||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Primitives;
|
using osu.Framework.Graphics.Primitives;
|
||||||
|
using osu.Framework.Input;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
using osu.Framework.Input.States;
|
using osu.Framework.Input.States;
|
||||||
using osu.Game.Rulesets.Edit;
|
using osu.Game.Rulesets.Edit;
|
||||||
@ -22,8 +23,8 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
|
|
||||||
private Container<PlacementBlueprint> placementBlueprintContainer;
|
private Container<PlacementBlueprint> placementBlueprintContainer;
|
||||||
private PlacementBlueprint currentPlacement;
|
private PlacementBlueprint currentPlacement;
|
||||||
|
|
||||||
private SelectionHandler selectionHandler;
|
private SelectionHandler selectionHandler;
|
||||||
|
private InputManager inputManager;
|
||||||
|
|
||||||
private IEnumerable<SelectionBlueprint> selections => selectionBlueprints.Children.Where(c => c.IsAlive);
|
private IEnumerable<SelectionBlueprint> selections => selectionBlueprints.Children.Where(c => c.IsAlive);
|
||||||
|
|
||||||
@ -66,6 +67,8 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
|
|
||||||
beatmap.HitObjectAdded += addBlueprintFor;
|
beatmap.HitObjectAdded += addBlueprintFor;
|
||||||
beatmap.HitObjectRemoved += removeBlueprintFor;
|
beatmap.HitObjectRemoved += removeBlueprintFor;
|
||||||
|
|
||||||
|
inputManager = GetContainingInputManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
private HitObjectCompositionTool currentTool;
|
private HitObjectCompositionTool currentTool;
|
||||||
@ -136,6 +139,17 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override bool OnMouseMove(MouseMoveEvent e)
|
||||||
|
{
|
||||||
|
if (currentPlacement != null)
|
||||||
|
{
|
||||||
|
currentPlacement.UpdatePosition(e.ScreenSpaceMousePosition);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return base.OnMouseMove(e);
|
||||||
|
}
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
@ -158,8 +172,14 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
currentPlacement = null;
|
currentPlacement = null;
|
||||||
|
|
||||||
var blueprint = CurrentTool?.CreatePlacementBlueprint();
|
var blueprint = CurrentTool?.CreatePlacementBlueprint();
|
||||||
|
|
||||||
if (blueprint != null)
|
if (blueprint != null)
|
||||||
|
{
|
||||||
placementBlueprintContainer.Child = currentPlacement = blueprint;
|
placementBlueprintContainer.Child = currentPlacement = blueprint;
|
||||||
|
|
||||||
|
// Fixes a 1-frame position discrepancy due to the first mouse move event happening in the next frame
|
||||||
|
blueprint.UpdatePosition(inputManager.CurrentState.Mouse.Position);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -89,11 +89,7 @@ namespace osu.Game.Screens.Select.Options
|
|||||||
/// <param name="icon">Icon of the button.</param>
|
/// <param name="icon">Icon of the button.</param>
|
||||||
/// <param name="hotkey">Hotkey of the button.</param>
|
/// <param name="hotkey">Hotkey of the button.</param>
|
||||||
/// <param name="action">Binding the button does.</param>
|
/// <param name="action">Binding the button does.</param>
|
||||||
/// <param name="depth">
|
public void AddButton(string firstLine, string secondLine, IconUsage icon, Color4 colour, Action action, Key? hotkey = null)
|
||||||
/// <para>Lower depth to be put on the left, and higher to be put on the right.</para>
|
|
||||||
/// <para>Notice this is different to <see cref="Footer"/>!</para>
|
|
||||||
/// </param>
|
|
||||||
public void AddButton(string firstLine, string secondLine, IconUsage icon, Color4 colour, Action action, Key? hotkey = null, float depth = 0)
|
|
||||||
{
|
{
|
||||||
var button = new BeatmapOptionsButton
|
var button = new BeatmapOptionsButton
|
||||||
{
|
{
|
||||||
@ -101,7 +97,6 @@ namespace osu.Game.Screens.Select.Options
|
|||||||
SecondLineText = secondLine,
|
SecondLineText = secondLine,
|
||||||
Icon = icon,
|
Icon = icon,
|
||||||
ButtonColour = colour,
|
ButtonColour = colour,
|
||||||
Depth = depth,
|
|
||||||
Action = () =>
|
Action = () =>
|
||||||
{
|
{
|
||||||
Hide();
|
Hide();
|
||||||
@ -110,7 +105,7 @@ namespace osu.Game.Screens.Select.Options
|
|||||||
HotKey = hotkey
|
HotKey = hotkey
|
||||||
};
|
};
|
||||||
|
|
||||||
buttonsContainer.Insert((int)depth, button);
|
buttonsContainer.Add(button);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ namespace osu.Game.Screens.Select
|
|||||||
{
|
{
|
||||||
ValidForResume = false;
|
ValidForResume = false;
|
||||||
Edit();
|
Edit();
|
||||||
}, Key.Number3);
|
}, Key.Number4);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnResuming(IScreen last)
|
public override void OnResuming(IScreen last)
|
||||||
|
@ -230,9 +230,9 @@ namespace osu.Game.Screens.Select
|
|||||||
Footer.AddButton(new FooterButtonRandom { Action = triggerRandom });
|
Footer.AddButton(new FooterButtonRandom { Action = triggerRandom });
|
||||||
Footer.AddButton(new FooterButtonOptions(), BeatmapOptions);
|
Footer.AddButton(new FooterButtonOptions(), BeatmapOptions);
|
||||||
|
|
||||||
BeatmapOptions.AddButton(@"Delete", @"all difficulties", FontAwesome.Solid.Trash, colours.Pink, () => delete(Beatmap.Value.BeatmapSetInfo), Key.Number4, float.MaxValue);
|
|
||||||
BeatmapOptions.AddButton(@"Remove", @"from unplayed", FontAwesome.Regular.TimesCircle, colours.Purple, null, Key.Number1);
|
BeatmapOptions.AddButton(@"Remove", @"from unplayed", FontAwesome.Regular.TimesCircle, colours.Purple, null, Key.Number1);
|
||||||
BeatmapOptions.AddButton(@"Clear", @"local scores", FontAwesome.Solid.Eraser, colours.Purple, () => clearScores(Beatmap.Value.BeatmapInfo), Key.Number2);
|
BeatmapOptions.AddButton(@"Clear", @"local scores", FontAwesome.Solid.Eraser, colours.Purple, () => clearScores(Beatmap.Value.BeatmapInfo), Key.Number2);
|
||||||
|
BeatmapOptions.AddButton(@"Delete", @"all difficulties", FontAwesome.Solid.Trash, colours.Pink, () => delete(Beatmap.Value.BeatmapSetInfo), Key.Number3);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.beatmaps == null)
|
if (this.beatmaps == null)
|
||||||
@ -413,7 +413,7 @@ namespace osu.Game.Screens.Select
|
|||||||
Beatmap.Value = beatmaps.GetWorkingBeatmap(beatmap, previous);
|
Beatmap.Value = beatmaps.GetWorkingBeatmap(beatmap, previous);
|
||||||
|
|
||||||
if (this.IsCurrentScreen() && Beatmap.Value?.Track != previous?.Track)
|
if (this.IsCurrentScreen() && Beatmap.Value?.Track != previous?.Track)
|
||||||
ensurePlayingSelected();
|
ensurePlayingSelected(true);
|
||||||
|
|
||||||
if (beatmap != null)
|
if (beatmap != null)
|
||||||
{
|
{
|
||||||
@ -585,18 +585,14 @@ namespace osu.Game.Screens.Select
|
|||||||
{
|
{
|
||||||
Track track = Beatmap.Value.Track;
|
Track track = Beatmap.Value.Track;
|
||||||
|
|
||||||
if (!track.IsRunning || restart)
|
if (!track.IsRunning)
|
||||||
{
|
{
|
||||||
track.RestartPoint = Beatmap.Value.Metadata.PreviewTime;
|
track.RestartPoint = Beatmap.Value.Metadata.PreviewTime;
|
||||||
|
|
||||||
if (music != null)
|
if (restart)
|
||||||
{
|
|
||||||
// use the global music controller (when available) to cancel a potential local user paused state.
|
|
||||||
music.SeekTo(track.RestartPoint);
|
|
||||||
music.Play();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
track.Restart();
|
track.Restart();
|
||||||
|
else
|
||||||
|
track.Start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
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.Framework.Input;
|
||||||
|
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.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
@ -18,16 +20,17 @@ namespace osu.Game.Tests.Visual
|
|||||||
protected Container HitObjectContainer;
|
protected Container HitObjectContainer;
|
||||||
private PlacementBlueprint currentBlueprint;
|
private PlacementBlueprint currentBlueprint;
|
||||||
|
|
||||||
|
private InputManager inputManager;
|
||||||
|
|
||||||
protected PlacementBlueprintTestScene()
|
protected PlacementBlueprintTestScene()
|
||||||
{
|
{
|
||||||
Add(HitObjectContainer = CreateHitObjectContainer());
|
Add(HitObjectContainer = CreateHitObjectContainer().With(c => c.Clock = new FramedClock(new StopwatchClock())));
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
Beatmap.Value.BeatmapInfo.BaseDifficulty.CircleSize = 2;
|
Beatmap.Value.BeatmapInfo.BaseDifficulty.CircleSize = 2;
|
||||||
Add(currentBlueprint = CreateBlueprint());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
||||||
@ -38,6 +41,14 @@ namespace osu.Game.Tests.Visual
|
|||||||
return dependencies;
|
return dependencies;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
|
||||||
|
inputManager = GetContainingInputManager();
|
||||||
|
Add(currentBlueprint = CreateBlueprint());
|
||||||
|
}
|
||||||
|
|
||||||
public void BeginPlacement(HitObject hitObject)
|
public void BeginPlacement(HitObject hitObject)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -54,10 +65,27 @@ namespace osu.Game.Tests.Visual
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual Container CreateHitObjectContainer() => new Container { RelativeSizeAxes = Axes.Both };
|
protected override bool OnMouseMove(MouseMoveEvent e)
|
||||||
|
{
|
||||||
|
currentBlueprint.UpdatePosition(e.ScreenSpaceMousePosition);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Add(Drawable drawable)
|
||||||
|
{
|
||||||
|
base.Add(drawable);
|
||||||
|
|
||||||
|
if (drawable is PlacementBlueprint blueprint)
|
||||||
|
{
|
||||||
|
blueprint.Show();
|
||||||
|
blueprint.UpdatePosition(inputManager.CurrentState.Mouse.Position);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected virtual void AddHitObject(DrawableHitObject hitObject) => HitObjectContainer.Add(hitObject);
|
protected virtual void AddHitObject(DrawableHitObject hitObject) => HitObjectContainer.Add(hitObject);
|
||||||
|
|
||||||
|
protected virtual Container CreateHitObjectContainer() => new Container { RelativeSizeAxes = Axes.Both };
|
||||||
|
|
||||||
protected abstract DrawableHitObject CreateHitObject(HitObject hitObject);
|
protected abstract DrawableHitObject CreateHitObject(HitObject hitObject);
|
||||||
protected abstract PlacementBlueprint CreateBlueprint();
|
protected abstract PlacementBlueprint CreateBlueprint();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user