1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 06:42:54 +08:00

Merge branch 'master' into update-multiplayer-room-diff-range

This commit is contained in:
timiimit 2023-05-15 07:36:43 +02:00 committed by GitHub
commit 0fd718478a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 43 additions and 13 deletions

View File

@ -9,7 +9,6 @@ using osu.Framework.Localisation;
using osu.Framework.Utils;
using osu.Game.Beatmaps;
using osu.Game.Configuration;
using osu.Game.Overlays.Settings;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Osu.Beatmaps;
@ -28,7 +27,7 @@ namespace osu.Game.Rulesets.Osu.Mods
public override Type[] IncompatibleMods => base.IncompatibleMods.Append(typeof(OsuModTargetPractice)).ToArray();
[SettingSource("Angle sharpness", "How sharp angles should be", SettingControlType = typeof(SettingsSlider<float>))]
[SettingSource("Angle sharpness", "How sharp angles should be")]
public BindableFloat AngleSharpness { get; } = new BindableFloat(7)
{
MinValue = 1,

View File

@ -79,5 +79,28 @@ namespace osu.Game.Tests.Visual.Editing
AddAssert("no active placement", () => this.ChildrenOfType<ComposeBlueprintContainer>().Single().CurrentPlacement.PlacementActive,
() => Is.EqualTo(PlacementBlueprint.PlacementState.Waiting));
}
[Test]
public void TestCommitPlacementViaToolChange()
{
Playfield playfield = null!;
AddStep("select slider placement tool", () => InputManager.Key(Key.Number3));
AddStep("move mouse to top left of playfield", () =>
{
playfield = this.ChildrenOfType<Playfield>().Single();
var location = (3 * playfield.ScreenSpaceDrawQuad.TopLeft + playfield.ScreenSpaceDrawQuad.BottomRight) / 4;
InputManager.MoveMouseTo(location);
});
AddStep("begin placement", () => InputManager.Click(MouseButton.Left));
AddStep("move mouse to bottom right of playfield", () =>
{
var location = (playfield.ScreenSpaceDrawQuad.TopLeft + 3 * playfield.ScreenSpaceDrawQuad.BottomRight) / 4;
InputManager.MoveMouseTo(location);
});
AddStep("change tool to circle", () => InputManager.Key(Key.Number2));
AddAssert("slider placed", () => EditorBeatmap.HitObjects.Count, () => Is.EqualTo(1));
}
}
}

View File

@ -317,12 +317,16 @@ namespace osu.Game.Screens.Edit.Compose.Components
}
}
private void commitIfPlacementActive()
{
CurrentPlacement?.EndPlacement(CurrentPlacement.PlacementActive == PlacementBlueprint.PlacementState.Active);
removePlacement();
}
private void removePlacement()
{
if (CurrentPlacement == null) return;
CurrentPlacement.EndPlacement(false);
CurrentPlacement.Expire();
CurrentPlacement?.EndPlacement(false);
CurrentPlacement?.Expire();
CurrentPlacement = null;
}
@ -342,7 +346,8 @@ namespace osu.Game.Screens.Edit.Compose.Components
currentTool = value;
refreshTool();
// As per stable editor, when changing tools, we should forcefully commit any pending placement.
commitIfPlacementActive();
}
}
}

View File

@ -15,6 +15,7 @@ using osuTK;
using osuTK.Graphics;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Allocation;
using osu.Framework.Layout;
using osu.Framework.Threading;
namespace osu.Game.Screens.Play
@ -51,7 +52,7 @@ namespace osu.Game.Screens.Play
if (value == values) return;
values = value;
graphNeedsUpdate = true;
layout.Invalidate();
}
}
@ -71,23 +72,25 @@ namespace osu.Game.Screens.Play
private ScheduledDelegate scheduledCreate;
private bool graphNeedsUpdate;
private readonly LayoutValue layout = new LayoutValue(Invalidation.DrawSize | Invalidation.DrawInfo);
private Vector2 previousDrawSize;
public SquareGraph()
{
AddLayout(layout);
}
protected override void Update()
{
base.Update();
if (graphNeedsUpdate || (values != null && DrawSize != previousDrawSize))
if (!layout.IsValid)
{
columns?.FadeOut(500, Easing.OutQuint).Expire();
scheduledCreate?.Cancel();
scheduledCreate = Scheduler.AddDelayed(RecreateGraph, 500);
previousDrawSize = DrawSize;
graphNeedsUpdate = false;
layout.Validate();
}
}