mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 14:12:54 +08:00
Merge branch 'master' into show-beatmap-id
This commit is contained in:
commit
c33cb9c02e
@ -1 +1 @@
|
|||||||
Subproject commit 85b3494117ccef1b396b70957e1cffaba06e2b54
|
Subproject commit 02d7a0fa4798d197cd08570ee48951edbb7c7860
|
62
osu.Game.Rulesets.Catch.Tests/TestCaseAutoJuiceStream.cs
Normal file
62
osu.Game.Rulesets.Catch.Tests/TestCaseAutoJuiceStream.cs
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Rulesets.Catch.Objects;
|
||||||
|
using osu.Game.Rulesets.Catch.UI;
|
||||||
|
using osu.Game.Rulesets.Objects.Types;
|
||||||
|
using osu.Game.Screens.Play;
|
||||||
|
using osu.Game.Tests.Visual;
|
||||||
|
using OpenTK;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Catch.Tests
|
||||||
|
{
|
||||||
|
public class TestCaseAutoJuiceStream : TestCasePlayer
|
||||||
|
{
|
||||||
|
public TestCaseAutoJuiceStream()
|
||||||
|
: base(new CatchRuleset())
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override Beatmap CreateBeatmap(Ruleset ruleset)
|
||||||
|
{
|
||||||
|
var beatmap = new Beatmap
|
||||||
|
{
|
||||||
|
BeatmapInfo = new BeatmapInfo
|
||||||
|
{
|
||||||
|
BaseDifficulty = new BeatmapDifficulty { CircleSize = 6, SliderMultiplier = 3 },
|
||||||
|
Ruleset = ruleset.RulesetInfo
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
for (int i = 0; i < 100; i++)
|
||||||
|
{
|
||||||
|
float width = (i % 10 + 1) / 20f;
|
||||||
|
|
||||||
|
beatmap.HitObjects.Add(new JuiceStream
|
||||||
|
{
|
||||||
|
X = 0.5f - width / 2,
|
||||||
|
ControlPoints = new List<Vector2>
|
||||||
|
{
|
||||||
|
Vector2.Zero,
|
||||||
|
new Vector2(width * CatchPlayfield.BASE_WIDTH, 0)
|
||||||
|
},
|
||||||
|
CurveType = CurveType.Linear,
|
||||||
|
Distance = width * CatchPlayfield.BASE_WIDTH,
|
||||||
|
StartTime = i * 2000,
|
||||||
|
NewCombo = i % 8 == 0
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return beatmap;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override Player CreatePlayer(WorkingBeatmap beatmap, Ruleset ruleset)
|
||||||
|
{
|
||||||
|
beatmap.Mods.Value = beatmap.Mods.Value.Concat(new[] { ruleset.GetAutoplayMod() });
|
||||||
|
return base.CreatePlayer(beatmap, ruleset);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -2,11 +2,10 @@
|
|||||||
// 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.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using osu.Framework.Testing;
|
|
||||||
|
|
||||||
// We publish our internal attributes to other sub-projects of the framework.
|
// We publish our internal attributes to other sub-projects of the framework.
|
||||||
// Note, that we omit visual tests as they are meant to test the framework
|
// Note, that we omit visual tests as they are meant to test the framework
|
||||||
// behavior "in the wild".
|
// behavior "in the wild".
|
||||||
|
|
||||||
[assembly: InternalsVisibleTo("osu.Game.Rulesets.Catch.Tests")]
|
[assembly: InternalsVisibleTo("osu.Game.Rulesets.Catch.Tests")]
|
||||||
[assembly: InternalsVisibleTo(DynamicClassCompiler.DYNAMIC_ASSEMBLY_NAME)]
|
[assembly: InternalsVisibleTo("osu.Game.Rulesets.Catch.Tests.Dynamic")]
|
||||||
|
@ -108,6 +108,7 @@ namespace osu.Game.Rulesets.Catch.Replays
|
|||||||
case BananaShower.Banana _:
|
case BananaShower.Banana _:
|
||||||
case TinyDroplet _:
|
case TinyDroplet _:
|
||||||
case Droplet _:
|
case Droplet _:
|
||||||
|
case Fruit _:
|
||||||
moveToNext(nestedObj);
|
moveToNext(nestedObj);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -30,10 +30,10 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
Anchor = Anchor.TopCentre;
|
Anchor = Anchor.TopCentre;
|
||||||
Origin = Anchor.TopCentre;
|
Origin = Anchor.TopCentre;
|
||||||
|
|
||||||
ScaledContent.Anchor = Anchor.BottomLeft;
|
base.Content.Anchor = Anchor.BottomLeft;
|
||||||
ScaledContent.Origin = Anchor.BottomLeft;
|
base.Content.Origin = Anchor.BottomLeft;
|
||||||
|
|
||||||
ScaledContent.AddRange(new Drawable[]
|
base.Content.AddRange(new Drawable[]
|
||||||
{
|
{
|
||||||
explodingFruitContainer = new Container
|
explodingFruitContainer = new Container
|
||||||
{
|
{
|
||||||
|
@ -2,11 +2,10 @@
|
|||||||
// 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.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using osu.Framework.Testing;
|
|
||||||
|
|
||||||
// We publish our internal attributes to other sub-projects of the framework.
|
// We publish our internal attributes to other sub-projects of the framework.
|
||||||
// Note, that we omit visual tests as they are meant to test the framework
|
// Note, that we omit visual tests as they are meant to test the framework
|
||||||
// behavior "in the wild".
|
// behavior "in the wild".
|
||||||
|
|
||||||
[assembly: InternalsVisibleTo("osu.Game.Rulesets.Mania.Tests")]
|
[assembly: InternalsVisibleTo("osu.Game.Rulesets.Mania.Tests")]
|
||||||
[assembly: InternalsVisibleTo(DynamicClassCompiler.DYNAMIC_ASSEMBLY_NAME)]
|
[assembly: InternalsVisibleTo("osu.Game.Rulesets.Mania.Tests.Dynamic")]
|
||||||
|
@ -21,6 +21,8 @@ namespace osu.Game.Rulesets.Osu.Edit.Layers.Selection.Overlays
|
|||||||
Size = hitCircle.Size;
|
Size = hitCircle.Size;
|
||||||
Scale = hitCircle.Scale;
|
Scale = hitCircle.Scale;
|
||||||
|
|
||||||
|
CornerRadius = Size.X / 2;
|
||||||
|
|
||||||
AddInternal(new RingPiece());
|
AddInternal(new RingPiece());
|
||||||
|
|
||||||
hitCircle.HitObject.PositionChanged += _ => Position = hitCircle.Position;
|
hitCircle.HitObject.PositionChanged += _ => Position = hitCircle.Position;
|
||||||
|
@ -38,6 +38,8 @@ namespace osu.Game.Rulesets.Osu.Edit.Layers.Selection.Overlays
|
|||||||
Scale = slider.HeadCircle.Scale;
|
Scale = slider.HeadCircle.Scale;
|
||||||
|
|
||||||
AddInternal(new RingPiece());
|
AddInternal(new RingPiece());
|
||||||
|
|
||||||
|
Select();
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
@ -52,5 +54,8 @@ namespace osu.Game.Rulesets.Osu.Edit.Layers.Selection.Overlays
|
|||||||
|
|
||||||
RelativeAnchorPosition = hitObject.RelativeAnchorPosition;
|
RelativeAnchorPosition = hitObject.RelativeAnchorPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Todo: This is temporary, since the slider circle masks don't do anything special yet. In the future they will handle input.
|
||||||
|
public override bool HandleMouseInput => false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Primitives;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Rulesets.Edit;
|
using osu.Game.Rulesets.Edit;
|
||||||
using osu.Game.Rulesets.Osu.Objects;
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
@ -59,5 +60,8 @@ namespace osu.Game.Rulesets.Osu.Edit.Layers.Selection.Overlays
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => body.ReceiveMouseInputAt(screenSpacePos);
|
public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => body.ReceiveMouseInputAt(screenSpacePos);
|
||||||
|
|
||||||
|
public override Vector2 SelectionPoint => ToScreenSpace(OriginPosition);
|
||||||
|
public override Quad SelectionQuad => body.PathDrawQuad;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,5 +8,6 @@ namespace osu.Game.Rulesets.Osu.Edit
|
|||||||
public class OsuEditPlayfield : OsuPlayfield
|
public class OsuEditPlayfield : OsuPlayfield
|
||||||
{
|
{
|
||||||
protected override bool ProxyApproachCircles => false;
|
protected override bool ProxyApproachCircles => false;
|
||||||
|
protected override bool DisplayJudgements => false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ namespace osu.Game.Rulesets.Osu.Mods
|
|||||||
{
|
{
|
||||||
public class OsuModAutoplay : ModAutoplay<OsuHitObject>
|
public class OsuModAutoplay : ModAutoplay<OsuHitObject>
|
||||||
{
|
{
|
||||||
public override Type[] IncompatibleMods => base.IncompatibleMods.Concat(new[] { typeof(OsuModAutopilot), typeof(OsuModSpunOut) }).ToArray();
|
public override Type[] IncompatibleMods => base.IncompatibleMods.Append(typeof(OsuModAutopilot)).Append(typeof(OsuModSpunOut)).ToArray();
|
||||||
|
|
||||||
protected override Score CreateReplayScore(Beatmap<OsuHitObject> beatmap)
|
protected override Score CreateReplayScore(Beatmap<OsuHitObject> beatmap)
|
||||||
{
|
{
|
||||||
|
@ -9,6 +9,6 @@ namespace osu.Game.Rulesets.Osu.Mods
|
|||||||
{
|
{
|
||||||
public class OsuModNoFail : ModNoFail
|
public class OsuModNoFail : ModNoFail
|
||||||
{
|
{
|
||||||
public override Type[] IncompatibleMods => base.IncompatibleMods.Concat(new[] { typeof(OsuModAutopilot) }).ToArray();
|
public override Type[] IncompatibleMods => base.IncompatibleMods.Append(typeof(OsuModAutopilot)).ToArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,6 @@ namespace osu.Game.Rulesets.Osu.Mods
|
|||||||
public class OsuModRelax : ModRelax
|
public class OsuModRelax : ModRelax
|
||||||
{
|
{
|
||||||
public override string Description => @"You don't need to click. Give your clicking/tapping fingers a break from the heat of things.";
|
public override string Description => @"You don't need to click. Give your clicking/tapping fingers a break from the heat of things.";
|
||||||
public override Type[] IncompatibleMods => base.IncompatibleMods.Concat(new[] { typeof(OsuModAutopilot) }).ToArray();
|
public override Type[] IncompatibleMods => base.IncompatibleMods.Append(typeof(OsuModAutopilot)).ToArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,6 @@ namespace osu.Game.Rulesets.Osu.Mods
|
|||||||
{
|
{
|
||||||
public class OsuModSuddenDeath : ModSuddenDeath
|
public class OsuModSuddenDeath : ModSuddenDeath
|
||||||
{
|
{
|
||||||
public override Type[] IncompatibleMods => base.IncompatibleMods.Concat(new[] { typeof(OsuModAutopilot) }).ToArray();
|
public override Type[] IncompatibleMods => base.IncompatibleMods.Append(typeof(OsuModAutopilot)).ToArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,6 @@ using System.Linq;
|
|||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Game.Rulesets.Osu.Judgements;
|
using osu.Game.Rulesets.Osu.Judgements;
|
||||||
using osu.Framework.Graphics.Primitives;
|
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
@ -177,8 +176,5 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
public Drawable ProxiedLayer => HeadCircle.ApproachCircle;
|
public Drawable ProxiedLayer => HeadCircle.ApproachCircle;
|
||||||
|
|
||||||
public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => Body.ReceiveMouseInputAt(screenSpacePos);
|
public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => Body.ReceiveMouseInputAt(screenSpacePos);
|
||||||
|
|
||||||
public override Vector2 SelectionPoint => ToScreenSpace(OriginPosition);
|
|
||||||
public override Quad SelectionQuad => Body.PathDrawQuad;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,10 +7,11 @@ using osu.Game.Rulesets.Objects;
|
|||||||
using OpenTK;
|
using OpenTK;
|
||||||
using osu.Game.Rulesets.Objects.Types;
|
using osu.Game.Rulesets.Objects.Types;
|
||||||
using osu.Game.Beatmaps.ControlPoints;
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
|
using osu.Game.Rulesets.Edit.Types;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.Objects
|
namespace osu.Game.Rulesets.Osu.Objects
|
||||||
{
|
{
|
||||||
public abstract class OsuHitObject : HitObject, IHasComboInformation, IHasPosition
|
public abstract class OsuHitObject : HitObject, IHasComboInformation, IHasEditablePosition
|
||||||
{
|
{
|
||||||
public const double OBJECT_RADIUS = 64;
|
public const double OBJECT_RADIUS = 64;
|
||||||
|
|
||||||
|
@ -2,11 +2,10 @@
|
|||||||
// 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.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using osu.Framework.Testing;
|
|
||||||
|
|
||||||
// We publish our internal attributes to other sub-projects of the framework.
|
// We publish our internal attributes to other sub-projects of the framework.
|
||||||
// Note, that we omit visual tests as they are meant to test the framework
|
// Note, that we omit visual tests as they are meant to test the framework
|
||||||
// behavior "in the wild".
|
// behavior "in the wild".
|
||||||
|
|
||||||
[assembly: InternalsVisibleTo("osu.Game.Rulesets.Osu.Tests")]
|
[assembly: InternalsVisibleTo("osu.Game.Rulesets.Osu.Tests")]
|
||||||
[assembly: InternalsVisibleTo(DynamicClassCompiler.DYNAMIC_ASSEMBLY_NAME)]
|
[assembly: InternalsVisibleTo("osu.Game.Rulesets.Osu.Tests.Dynamic")]
|
||||||
|
@ -36,7 +36,7 @@ namespace osu.Game.Rulesets.Osu.Replays
|
|||||||
{
|
{
|
||||||
new ReplayState<OsuAction>
|
new ReplayState<OsuAction>
|
||||||
{
|
{
|
||||||
Mouse = new ReplayMouseState(ToScreenSpace(Position ?? Vector2.Zero)),
|
Mouse = new ReplayMouseState(GamefieldToScreenSpace(Position ?? Vector2.Zero)),
|
||||||
PressedActions = CurrentFrame.Actions
|
PressedActions = CurrentFrame.Actions
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -24,6 +24,7 @@ namespace osu.Game.Rulesets.Osu.UI
|
|||||||
// Todo: This should not be a thing, but is currently required for the editor
|
// Todo: This should not be a thing, but is currently required for the editor
|
||||||
// https://github.com/ppy/osu-framework/issues/1283
|
// https://github.com/ppy/osu-framework/issues/1283
|
||||||
protected virtual bool ProxyApproachCircles => true;
|
protected virtual bool ProxyApproachCircles => true;
|
||||||
|
protected virtual bool DisplayJudgements => true;
|
||||||
|
|
||||||
public static readonly Vector2 BASE_SIZE = new Vector2(512, 384);
|
public static readonly Vector2 BASE_SIZE = new Vector2(512, 384);
|
||||||
|
|
||||||
@ -73,7 +74,7 @@ namespace osu.Game.Rulesets.Osu.UI
|
|||||||
|
|
||||||
private void onJudgement(DrawableHitObject judgedObject, Judgement judgement)
|
private void onJudgement(DrawableHitObject judgedObject, Judgement judgement)
|
||||||
{
|
{
|
||||||
if (!judgedObject.DisplayJudgement)
|
if (!judgedObject.DisplayJudgement || !DisplayJudgements)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
DrawableOsuJudgement explosion = new DrawableOsuJudgement(judgement, judgedObject)
|
DrawableOsuJudgement explosion = new DrawableOsuJudgement(judgement, judgedObject)
|
||||||
|
@ -2,11 +2,10 @@
|
|||||||
// 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.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using osu.Framework.Testing;
|
|
||||||
|
|
||||||
// We publish our internal attributes to other sub-projects of the framework.
|
// We publish our internal attributes to other sub-projects of the framework.
|
||||||
// Note, that we omit visual tests as they are meant to test the framework
|
// Note, that we omit visual tests as they are meant to test the framework
|
||||||
// behavior "in the wild".
|
// behavior "in the wild".
|
||||||
|
|
||||||
[assembly: InternalsVisibleTo("osu.Game.Rulesets.Taiko.Tests")]
|
[assembly: InternalsVisibleTo("osu.Game.Rulesets.Taiko.Tests")]
|
||||||
[assembly: InternalsVisibleTo(DynamicClassCompiler.DYNAMIC_ASSEMBLY_NAME)]
|
[assembly: InternalsVisibleTo("osu.Game.Rulesets.Taiko.Tests.Dynamic")]
|
||||||
|
@ -2,7 +2,9 @@
|
|||||||
// 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 NUnit.Framework;
|
using NUnit.Framework;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual
|
namespace osu.Game.Tests.Visual
|
||||||
@ -10,10 +12,12 @@ namespace osu.Game.Tests.Visual
|
|||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class TestCaseBreadcrumbs : OsuTestCase
|
public class TestCaseBreadcrumbs : OsuTestCase
|
||||||
{
|
{
|
||||||
|
private readonly BreadcrumbControl<BreadcrumbTab> breadcrumbs;
|
||||||
|
|
||||||
public TestCaseBreadcrumbs()
|
public TestCaseBreadcrumbs()
|
||||||
{
|
{
|
||||||
BreadcrumbControl<BreadcrumbTab> c;
|
|
||||||
Add(c = new BreadcrumbControl<BreadcrumbTab>
|
Add(breadcrumbs = new BreadcrumbControl<BreadcrumbTab>
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
@ -21,9 +25,15 @@ namespace osu.Game.Tests.Visual
|
|||||||
Width = 0.5f,
|
Width = 0.5f,
|
||||||
});
|
});
|
||||||
|
|
||||||
AddStep(@"first", () => c.Current.Value = BreadcrumbTab.Click);
|
AddStep(@"first", () => breadcrumbs.Current.Value = BreadcrumbTab.Click);
|
||||||
AddStep(@"second", () => c.Current.Value = BreadcrumbTab.The);
|
AddStep(@"second", () => breadcrumbs.Current.Value = BreadcrumbTab.The);
|
||||||
AddStep(@"third", () => c.Current.Value = BreadcrumbTab.Circles);
|
AddStep(@"third", () => breadcrumbs.Current.Value = BreadcrumbTab.Circles);
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OsuColour colours)
|
||||||
|
{
|
||||||
|
breadcrumbs.StripColour = colours.Blue;
|
||||||
}
|
}
|
||||||
|
|
||||||
private enum BreadcrumbTab
|
private enum BreadcrumbTab
|
||||||
|
@ -9,7 +9,6 @@ using osu.Framework.Graphics.Cursor;
|
|||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Input;
|
using osu.Framework.Input;
|
||||||
using osu.Framework.MathUtils;
|
using osu.Framework.MathUtils;
|
||||||
using osu.Framework.Testing.Input;
|
|
||||||
using osu.Game.Graphics.Cursor;
|
using osu.Game.Graphics.Cursor;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
@ -18,15 +17,12 @@ using OpenTK.Graphics;
|
|||||||
namespace osu.Game.Tests.Visual
|
namespace osu.Game.Tests.Visual
|
||||||
{
|
{
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class TestCaseCursors : OsuTestCase
|
public class TestCaseCursors : ManualInputManagerTestCase
|
||||||
{
|
{
|
||||||
private readonly ManualInputManager inputManager;
|
|
||||||
private readonly CursorOverrideContainer cursorOverrideContainer;
|
private readonly CursorOverrideContainer cursorOverrideContainer;
|
||||||
private readonly CustomCursorBox[] cursorBoxes = new CustomCursorBox[6];
|
private readonly CustomCursorBox[] cursorBoxes = new CustomCursorBox[6];
|
||||||
|
|
||||||
public TestCaseCursors()
|
public TestCaseCursors()
|
||||||
{
|
|
||||||
Child = inputManager = new ManualInputManager
|
|
||||||
{
|
{
|
||||||
Child = cursorOverrideContainer = new CursorOverrideContainer
|
Child = cursorOverrideContainer = new CursorOverrideContainer
|
||||||
{
|
{
|
||||||
@ -80,26 +76,15 @@ namespace osu.Game.Tests.Visual
|
|||||||
Size = new Vector2(0.2f, 1),
|
Size = new Vector2(0.2f, 1),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
returnUserInput();
|
|
||||||
|
|
||||||
AddToggleStep("Smooth transitions", b => cursorBoxes.ForEach(box => box.SmoothTransition = b));
|
AddToggleStep("Smooth transitions", b => cursorBoxes.ForEach(box => box.SmoothTransition = b));
|
||||||
|
|
||||||
testUserCursor();
|
testUserCursor();
|
||||||
testLocalCursor();
|
testLocalCursor();
|
||||||
testUserCursorOverride();
|
testUserCursorOverride();
|
||||||
testMultipleLocalCursors();
|
testMultipleLocalCursors();
|
||||||
returnUserInput();
|
ReturnUserInput();
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns input back to the user.
|
|
||||||
/// </summary>
|
|
||||||
private void returnUserInput()
|
|
||||||
{
|
|
||||||
AddStep("Return user input", () => inputManager.UseParentState = true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -109,7 +94,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void testUserCursor()
|
private void testUserCursor()
|
||||||
{
|
{
|
||||||
AddStep("Move to green area", () => inputManager.MoveMouseTo(cursorBoxes[0]));
|
AddStep("Move to green area", () => InputManager.MoveMouseTo(cursorBoxes[0]));
|
||||||
AddAssert("Check green cursor visible", () => checkVisible(cursorBoxes[0].Cursor));
|
AddAssert("Check green cursor visible", () => checkVisible(cursorBoxes[0].Cursor));
|
||||||
AddAssert("Check green cursor at mouse", () => checkAtMouse(cursorBoxes[0].Cursor));
|
AddAssert("Check green cursor at mouse", () => checkAtMouse(cursorBoxes[0].Cursor));
|
||||||
AddStep("Move out", moveOut);
|
AddStep("Move out", moveOut);
|
||||||
@ -124,7 +109,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void testLocalCursor()
|
private void testLocalCursor()
|
||||||
{
|
{
|
||||||
AddStep("Move to purple area", () => inputManager.MoveMouseTo(cursorBoxes[3]));
|
AddStep("Move to purple area", () => InputManager.MoveMouseTo(cursorBoxes[3]));
|
||||||
AddAssert("Check purple cursor visible", () => checkVisible(cursorBoxes[3].Cursor));
|
AddAssert("Check purple cursor visible", () => checkVisible(cursorBoxes[3].Cursor));
|
||||||
AddAssert("Check purple cursor at mouse", () => checkAtMouse(cursorBoxes[3].Cursor));
|
AddAssert("Check purple cursor at mouse", () => checkAtMouse(cursorBoxes[3].Cursor));
|
||||||
AddAssert("Check global cursor visible", () => checkVisible(cursorOverrideContainer.Cursor));
|
AddAssert("Check global cursor visible", () => checkVisible(cursorOverrideContainer.Cursor));
|
||||||
@ -141,7 +126,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void testUserCursorOverride()
|
private void testUserCursorOverride()
|
||||||
{
|
{
|
||||||
AddStep("Move to blue-green boundary", () => inputManager.MoveMouseTo(cursorBoxes[1].ScreenSpaceDrawQuad.BottomRight - new Vector2(10)));
|
AddStep("Move to blue-green boundary", () => InputManager.MoveMouseTo(cursorBoxes[1].ScreenSpaceDrawQuad.BottomRight - new Vector2(10)));
|
||||||
AddAssert("Check blue cursor visible", () => checkVisible(cursorBoxes[1].Cursor));
|
AddAssert("Check blue cursor visible", () => checkVisible(cursorBoxes[1].Cursor));
|
||||||
AddAssert("Check green cursor invisible", () => !checkVisible(cursorBoxes[0].Cursor));
|
AddAssert("Check green cursor invisible", () => !checkVisible(cursorBoxes[0].Cursor));
|
||||||
AddAssert("Check blue cursor at mouse", () => checkAtMouse(cursorBoxes[1].Cursor));
|
AddAssert("Check blue cursor at mouse", () => checkAtMouse(cursorBoxes[1].Cursor));
|
||||||
@ -156,7 +141,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void testMultipleLocalCursors()
|
private void testMultipleLocalCursors()
|
||||||
{
|
{
|
||||||
AddStep("Move to yellow-purple boundary", () => inputManager.MoveMouseTo(cursorBoxes[5].ScreenSpaceDrawQuad.BottomRight - new Vector2(10)));
|
AddStep("Move to yellow-purple boundary", () => InputManager.MoveMouseTo(cursorBoxes[5].ScreenSpaceDrawQuad.BottomRight - new Vector2(10)));
|
||||||
AddAssert("Check purple cursor visible", () => checkVisible(cursorBoxes[3].Cursor));
|
AddAssert("Check purple cursor visible", () => checkVisible(cursorBoxes[3].Cursor));
|
||||||
AddAssert("Check purple cursor at mouse", () => checkAtMouse(cursorBoxes[3].Cursor));
|
AddAssert("Check purple cursor at mouse", () => checkAtMouse(cursorBoxes[3].Cursor));
|
||||||
AddAssert("Check yellow cursor visible", () => checkVisible(cursorBoxes[5].Cursor));
|
AddAssert("Check yellow cursor visible", () => checkVisible(cursorBoxes[5].Cursor));
|
||||||
@ -172,7 +157,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void testUserOverrideWithLocal()
|
private void testUserOverrideWithLocal()
|
||||||
{
|
{
|
||||||
AddStep("Move to yellow-blue boundary", () => inputManager.MoveMouseTo(cursorBoxes[5].ScreenSpaceDrawQuad.TopRight - new Vector2(10)));
|
AddStep("Move to yellow-blue boundary", () => InputManager.MoveMouseTo(cursorBoxes[5].ScreenSpaceDrawQuad.TopRight - new Vector2(10)));
|
||||||
AddAssert("Check blue cursor visible", () => checkVisible(cursorBoxes[1].Cursor));
|
AddAssert("Check blue cursor visible", () => checkVisible(cursorBoxes[1].Cursor));
|
||||||
AddAssert("Check blue cursor at mouse", () => checkAtMouse(cursorBoxes[1].Cursor));
|
AddAssert("Check blue cursor at mouse", () => checkAtMouse(cursorBoxes[1].Cursor));
|
||||||
AddAssert("Check yellow cursor visible", () => checkVisible(cursorBoxes[5].Cursor));
|
AddAssert("Check yellow cursor visible", () => checkVisible(cursorBoxes[5].Cursor));
|
||||||
@ -186,7 +171,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
/// Moves the cursor to a point not covered by any cursor containers.
|
/// Moves the cursor to a point not covered by any cursor containers.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void moveOut()
|
private void moveOut()
|
||||||
=> inputManager.MoveMouseTo(new Vector2(inputManager.ScreenSpaceDrawQuad.Centre.X, inputManager.ScreenSpaceDrawQuad.TopLeft.Y));
|
=> InputManager.MoveMouseTo(new Vector2(InputManager.ScreenSpaceDrawQuad.Centre.X, InputManager.ScreenSpaceDrawQuad.TopLeft.Y));
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Checks if a cursor is visible.
|
/// Checks if a cursor is visible.
|
||||||
@ -199,7 +184,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="cursorContainer">The cursor to check.</param>
|
/// <param name="cursorContainer">The cursor to check.</param>
|
||||||
private bool checkAtMouse(CursorContainer cursorContainer)
|
private bool checkAtMouse(CursorContainer cursorContainer)
|
||||||
=> Precision.AlmostEquals(inputManager.CurrentState.Mouse.NativeState.Position, cursorContainer.ToScreenSpace(cursorContainer.ActiveCursor.DrawPosition));
|
=> Precision.AlmostEquals(InputManager.CurrentState.Mouse.NativeState.Position, cursorContainer.ToScreenSpace(cursorContainer.ActiveCursor.DrawPosition));
|
||||||
|
|
||||||
private class CustomCursorBox : Container, IProvideCursor
|
private class CustomCursorBox : Container, IProvideCursor
|
||||||
{
|
{
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using JetBrains.Annotations;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Timing;
|
using osu.Framework.Timing;
|
||||||
@ -12,7 +13,6 @@ using osu.Game.Rulesets.Edit;
|
|||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
using osu.Game.Rulesets.Osu;
|
using osu.Game.Rulesets.Osu;
|
||||||
using osu.Game.Rulesets.Osu.Edit;
|
using osu.Game.Rulesets.Osu.Edit;
|
||||||
using osu.Game.Rulesets.Osu.Edit.Layers.Selection.Overlays;
|
|
||||||
using osu.Game.Rulesets.Osu.Objects;
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
using osu.Game.Screens.Edit.Screens.Compose.Layers;
|
using osu.Game.Screens.Edit.Screens.Compose.Layers;
|
||||||
using osu.Game.Tests.Beatmaps;
|
using osu.Game.Tests.Beatmaps;
|
||||||
@ -20,19 +20,16 @@ using osu.Game.Tests.Beatmaps;
|
|||||||
namespace osu.Game.Tests.Visual
|
namespace osu.Game.Tests.Visual
|
||||||
{
|
{
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class TestCaseEditorSelectionLayer : OsuTestCase
|
public class TestCaseHitObjectComposer : OsuTestCase
|
||||||
{
|
{
|
||||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||||
{
|
{
|
||||||
typeof(SelectionLayer),
|
typeof(MaskSelection),
|
||||||
typeof(SelectionBox),
|
typeof(DragLayer),
|
||||||
typeof(HitObjectComposer),
|
typeof(HitObjectComposer),
|
||||||
typeof(OsuHitObjectComposer),
|
typeof(OsuHitObjectComposer),
|
||||||
typeof(HitObjectMaskLayer),
|
typeof(HitObjectMaskLayer),
|
||||||
typeof(HitObjectMask),
|
typeof(NotNullAttribute)
|
||||||
typeof(HitCircleMask),
|
|
||||||
typeof(SliderMask),
|
|
||||||
typeof(SliderCircleMask)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
private DependencyContainer dependencies;
|
private DependencyContainer dependencies;
|
@ -122,7 +122,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
Direction = direction;
|
Direction = direction;
|
||||||
|
|
||||||
Padding = new MarginPadding(2);
|
Padding = new MarginPadding(2);
|
||||||
ScaledContent.Masking = true;
|
Content.Masking = true;
|
||||||
|
|
||||||
AddInternal(new Box
|
AddInternal(new Box
|
||||||
{
|
{
|
||||||
|
@ -16,7 +16,7 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
public TOutput Decode(StreamReader primaryStream, params StreamReader[] otherStreams)
|
public TOutput Decode(StreamReader primaryStream, params StreamReader[] otherStreams)
|
||||||
{
|
{
|
||||||
var output = CreateTemplateObject();
|
var output = CreateTemplateObject();
|
||||||
foreach (StreamReader stream in new[] { primaryStream }.Concat(otherStreams))
|
foreach (StreamReader stream in otherStreams.Prepend(primaryStream))
|
||||||
ParseStreamInto(stream, output);
|
ParseStreamInto(stream, output);
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,8 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
|
|
||||||
protected override TabItem<T> CreateTabItem(T value) => new BreadcrumbTabItem(value);
|
protected override TabItem<T> CreateTabItem(T value) => new BreadcrumbTabItem(value);
|
||||||
|
|
||||||
|
protected override float StripWidth() => base.StripWidth() - (padding + 8);
|
||||||
|
|
||||||
public BreadcrumbControl()
|
public BreadcrumbControl()
|
||||||
{
|
{
|
||||||
Height = 26;
|
Height = 26;
|
||||||
|
@ -14,22 +14,36 @@ using osu.Framework.Graphics.Shapes;
|
|||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Framework.Graphics.UserInterface;
|
using osu.Framework.Graphics.UserInterface;
|
||||||
using osu.Framework.Input;
|
using osu.Framework.Input;
|
||||||
|
using osu.Framework.MathUtils;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
|
|
||||||
namespace osu.Game.Graphics.UserInterface
|
namespace osu.Game.Graphics.UserInterface
|
||||||
{
|
{
|
||||||
public class OsuTabControl<T> : TabControl<T>
|
public class OsuTabControl<T> : TabControl<T>
|
||||||
{
|
{
|
||||||
|
private readonly Box strip;
|
||||||
|
|
||||||
protected override Dropdown<T> CreateDropdown() => new OsuTabDropdown();
|
protected override Dropdown<T> CreateDropdown() => new OsuTabDropdown();
|
||||||
|
|
||||||
protected override TabItem<T> CreateTabItem(T value) => new OsuTabItem(value);
|
protected override TabItem<T> CreateTabItem(T value) => new OsuTabItem(value);
|
||||||
|
|
||||||
|
protected virtual float StripWidth() => TabContainer.Children.Sum(c => c.IsPresent ? c.DrawWidth + TabContainer.Spacing.X : 0) - TabContainer.Spacing.X;
|
||||||
|
protected virtual float StripHeight() => 1;
|
||||||
|
|
||||||
private static bool isEnumType => typeof(T).IsEnum;
|
private static bool isEnumType => typeof(T).IsEnum;
|
||||||
|
|
||||||
public OsuTabControl()
|
public OsuTabControl()
|
||||||
{
|
{
|
||||||
TabContainer.Spacing = new Vector2(10f, 0f);
|
TabContainer.Spacing = new Vector2(10f, 0f);
|
||||||
|
|
||||||
|
Add(strip = new Box
|
||||||
|
{
|
||||||
|
Anchor = Anchor.BottomLeft,
|
||||||
|
Origin = Anchor.BottomLeft,
|
||||||
|
Height = StripHeight(),
|
||||||
|
Colour = Color4.White.Opacity(0),
|
||||||
|
});
|
||||||
|
|
||||||
if (isEnumType)
|
if (isEnumType)
|
||||||
foreach (var val in (T[])Enum.GetValues(typeof(T)))
|
foreach (var val in (T[])Enum.GetValues(typeof(T)))
|
||||||
AddItem(val);
|
AddItem(val);
|
||||||
@ -57,6 +71,12 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Color4 StripColour
|
||||||
|
{
|
||||||
|
get => strip.Colour;
|
||||||
|
set => strip.Colour = value;
|
||||||
|
}
|
||||||
|
|
||||||
protected override TabFillFlowContainer CreateTabFlow() => new OsuTabFillFlowContainer
|
protected override TabFillFlowContainer CreateTabFlow() => new OsuTabFillFlowContainer
|
||||||
{
|
{
|
||||||
Direction = FillDirection.Full,
|
Direction = FillDirection.Full,
|
||||||
@ -65,6 +85,15 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
Masking = true
|
Masking = true
|
||||||
};
|
};
|
||||||
|
|
||||||
|
protected override void UpdateAfterChildren()
|
||||||
|
{
|
||||||
|
base.UpdateAfterChildren();
|
||||||
|
|
||||||
|
// dont bother calculating if the strip is invisible
|
||||||
|
if (strip.Colour.MaxAlpha > 0)
|
||||||
|
strip.Width = Interpolation.ValueAt(MathHelper.Clamp(Clock.ElapsedFrameTime, 0, 1000), strip.Width, StripWidth(), 0, 500, Easing.OutQuint);
|
||||||
|
}
|
||||||
|
|
||||||
public class OsuTabItem : TabItem<T>, IHasAccentColour
|
public class OsuTabItem : TabItem<T>, IHasAccentColour
|
||||||
{
|
{
|
||||||
protected readonly SpriteText Text;
|
protected readonly SpriteText Text;
|
||||||
|
@ -45,7 +45,7 @@ namespace osu.Game.Input.Bindings
|
|||||||
};
|
};
|
||||||
|
|
||||||
protected override IEnumerable<Drawable> KeyBindingInputQueue =>
|
protected override IEnumerable<Drawable> KeyBindingInputQueue =>
|
||||||
handler == null ? base.KeyBindingInputQueue : new[] { handler }.Concat(base.KeyBindingInputQueue);
|
handler == null ? base.KeyBindingInputQueue : base.KeyBindingInputQueue.Prepend(handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum GlobalAction
|
public enum GlobalAction
|
||||||
|
@ -13,9 +13,9 @@ namespace osu.Game.Input.Handlers
|
|||||||
public abstract class ReplayInputHandler : InputHandler
|
public abstract class ReplayInputHandler : InputHandler
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A function provided to convert replay coordinates from gamefield to screen space.
|
/// A function that converts coordinates from gamefield to screen space.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Func<Vector2, Vector2> ToScreenSpace { protected get; set; }
|
public Func<Vector2, Vector2> GamefieldToScreenSpace { protected get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Update the current frame based on an incoming time value.
|
/// Update the current frame based on an incoming time value.
|
||||||
|
@ -13,7 +13,6 @@ namespace osu.Game.Overlays.Direct
|
|||||||
public class Header : SearchableListHeader<DirectTab>
|
public class Header : SearchableListHeader<DirectTab>
|
||||||
{
|
{
|
||||||
protected override Color4 BackgroundColour => OsuColour.FromHex(@"252f3a");
|
protected override Color4 BackgroundColour => OsuColour.FromHex(@"252f3a");
|
||||||
protected override float TabStripWidth => 298;
|
|
||||||
|
|
||||||
protected override DirectTab DefaultTab => DirectTab.Search;
|
protected override DirectTab DefaultTab => DirectTab.Search;
|
||||||
protected override Drawable CreateHeaderText() => new OsuSpriteText { Text = @"osu!direct", TextSize = 25 };
|
protected override Drawable CreateHeaderText() => new OsuSpriteText { Text = @"osu!direct", TextSize = 25 };
|
||||||
|
@ -47,7 +47,7 @@ namespace osu.Game.Overlays.KeyBinding
|
|||||||
|
|
||||||
private FillFlowContainer<KeyButton> buttons;
|
private FillFlowContainer<KeyButton> buttons;
|
||||||
|
|
||||||
public IEnumerable<string> FilterTerms => new[] { text.Text }.Concat(bindings.Select(b => b.KeyCombination.ReadableString()));
|
public IEnumerable<string> FilterTerms => bindings.Select(b => b.KeyCombination.ReadableString()).Prepend(text.Text);
|
||||||
|
|
||||||
public KeyBindingRow(object action, IEnumerable<Framework.Input.Bindings.KeyBinding> bindings)
|
public KeyBindingRow(object action, IEnumerable<Framework.Input.Bindings.KeyBinding> bindings)
|
||||||
{
|
{
|
||||||
|
@ -14,12 +14,9 @@ namespace osu.Game.Overlays.SearchableList
|
|||||||
{
|
{
|
||||||
public abstract class SearchableListHeader<T> : Container
|
public abstract class SearchableListHeader<T> : Container
|
||||||
{
|
{
|
||||||
private readonly Box tabStrip;
|
|
||||||
|
|
||||||
public readonly HeaderTabControl<T> Tabs;
|
public readonly HeaderTabControl<T> Tabs;
|
||||||
|
|
||||||
protected abstract Color4 BackgroundColour { get; }
|
protected abstract Color4 BackgroundColour { get; }
|
||||||
protected abstract float TabStripWidth { get; } //can be removed once (if?) TabControl support auto sizing
|
|
||||||
protected abstract T DefaultTab { get; }
|
protected abstract T DefaultTab { get; }
|
||||||
protected abstract Drawable CreateHeaderText();
|
protected abstract Drawable CreateHeaderText();
|
||||||
protected abstract FontAwesome Icon { get; }
|
protected abstract FontAwesome Icon { get; }
|
||||||
@ -63,13 +60,6 @@ namespace osu.Game.Overlays.SearchableList
|
|||||||
CreateHeaderText(),
|
CreateHeaderText(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
tabStrip = new Box
|
|
||||||
{
|
|
||||||
Anchor = Anchor.BottomLeft,
|
|
||||||
Origin = Anchor.BottomLeft,
|
|
||||||
Width = TabStripWidth,
|
|
||||||
Height = 1,
|
|
||||||
},
|
|
||||||
Tabs = new HeaderTabControl<T>
|
Tabs = new HeaderTabControl<T>
|
||||||
{
|
{
|
||||||
Anchor = Anchor.BottomLeft,
|
Anchor = Anchor.BottomLeft,
|
||||||
@ -87,7 +77,7 @@ namespace osu.Game.Overlays.SearchableList
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours)
|
private void load(OsuColour colours)
|
||||||
{
|
{
|
||||||
tabStrip.Colour = colours.Green;
|
Tabs.StripColour = colours.Green;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,6 @@ namespace osu.Game.Overlays.Social
|
|||||||
private OsuSpriteText browser;
|
private OsuSpriteText browser;
|
||||||
|
|
||||||
protected override Color4 BackgroundColour => OsuColour.FromHex(@"38202e");
|
protected override Color4 BackgroundColour => OsuColour.FromHex(@"38202e");
|
||||||
protected override float TabStripWidth => 438;
|
|
||||||
|
|
||||||
protected override SocialTab DefaultTab => SocialTab.AllPlayers;
|
protected override SocialTab DefaultTab => SocialTab.AllPlayers;
|
||||||
protected override FontAwesome Icon => FontAwesome.fa_users;
|
protected override FontAwesome Icon => FontAwesome.fa_users;
|
||||||
|
11
osu.Game/Properties/AssemblyInfo.cs
Normal file
11
osu.Game/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
|
||||||
|
// We publish our internal attributes to other sub-projects of the framework.
|
||||||
|
// Note, that we omit visual tests as they are meant to test the framework
|
||||||
|
// behavior "in the wild".
|
||||||
|
|
||||||
|
[assembly: InternalsVisibleTo("osu.Game.Tests")]
|
||||||
|
[assembly: InternalsVisibleTo("osu.Game.Tests.Dynamic")]
|
@ -65,9 +65,6 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
HitObjectMaskLayer hitObjectMaskLayer = new HitObjectMaskLayer(this);
|
|
||||||
SelectionLayer selectionLayer = new SelectionLayer(rulesetContainer.Playfield);
|
|
||||||
|
|
||||||
var layerBelowRuleset = new BorderLayer
|
var layerBelowRuleset = new BorderLayer
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
@ -75,12 +72,7 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
};
|
};
|
||||||
|
|
||||||
var layerAboveRuleset = CreateLayerContainer();
|
var layerAboveRuleset = CreateLayerContainer();
|
||||||
layerAboveRuleset.Children = new Drawable[]
|
layerAboveRuleset.Child = new HitObjectMaskLayer(rulesetContainer.Playfield, this);
|
||||||
{
|
|
||||||
selectionLayer, // Below object overlays for input
|
|
||||||
hitObjectMaskLayer,
|
|
||||||
selectionLayer.CreateProxy() // Proxy above object overlays for selections
|
|
||||||
};
|
|
||||||
|
|
||||||
layerContainers.Add(layerBelowRuleset);
|
layerContainers.Add(layerBelowRuleset);
|
||||||
layerContainers.Add(layerAboveRuleset);
|
layerContainers.Add(layerAboveRuleset);
|
||||||
@ -122,16 +114,9 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
selectionLayer.ObjectSelected += hitObjectMaskLayer.AddOverlay;
|
|
||||||
selectionLayer.ObjectDeselected += hitObjectMaskLayer.RemoveOverlay;
|
|
||||||
selectionLayer.SelectionCleared += hitObjectMaskLayer.RemoveSelectionOverlay;
|
|
||||||
selectionLayer.SelectionFinished += hitObjectMaskLayer.AddSelectionOverlay;
|
|
||||||
|
|
||||||
toolboxCollection.Items =
|
toolboxCollection.Items =
|
||||||
new[] { new RadioButton("Select", () => setCompositionTool(null)) }
|
|
||||||
.Concat(
|
|
||||||
CompositionTools.Select(t => new RadioButton(t.Name, () => setCompositionTool(t)))
|
CompositionTools.Select(t => new RadioButton(t.Name, () => setCompositionTool(t)))
|
||||||
)
|
.Prepend(new RadioButton("Select", () => setCompositionTool(null)))
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
toolboxCollection.Items[0].Select();
|
toolboxCollection.Items[0].Select();
|
||||||
@ -263,11 +248,10 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
public virtual HitObjectMask CreateMaskFor(DrawableHitObject hitObject) => null;
|
public virtual HitObjectMask CreateMaskFor(DrawableHitObject hitObject) => null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a <see cref="SelectionBox"/> which outlines <see cref="DrawableHitObject"/>s
|
/// Creates a <see cref="MaskSelection"/> which outlines <see cref="DrawableHitObject"/>s
|
||||||
/// and handles all hitobject movement/pattern adjustments.
|
/// and handles hitobject pattern adjustments.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="overlays">The <see cref="DrawableHitObject"/> overlays.</param>
|
public virtual MaskSelection CreateMaskSelection() => new MaskSelection();
|
||||||
public virtual SelectionBox CreateSelectionOverlay(IReadOnlyList<HitObjectMask> overlays) => new SelectionBox(overlays);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a <see cref="ScalableContainer"/> which provides a layer above or below the <see cref="Playfield"/>.
|
/// Creates a <see cref="ScalableContainer"/> which provides a layer above or below the <see cref="Playfield"/>.
|
||||||
|
@ -1,21 +1,146 @@
|
|||||||
// 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 System;
|
||||||
|
using osu.Framework;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Primitives;
|
||||||
|
using osu.Framework.Input;
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
|
using OpenTK;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Edit
|
namespace osu.Game.Rulesets.Edit
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A mask placed above a <see cref="DrawableHitObject"/> adding editing functionality.
|
/// A mask placed above a <see cref="DrawableHitObject"/> adding editing functionality.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class HitObjectMask : Container
|
public class HitObjectMask : CompositeDrawable, IStateful<SelectionState>
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Invoked when this <see cref="HitObjectMask"/> has been selected.
|
||||||
|
/// </summary>
|
||||||
|
public event Action<HitObjectMask> Selected;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Invoked when this <see cref="HitObjectMask"/> has been deselected.
|
||||||
|
/// </summary>
|
||||||
|
public event Action<HitObjectMask> Deselected;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Invoked when this <see cref="HitObjectMask"/> has requested selection.
|
||||||
|
/// Will fire even if already selected. Does not actually perform selection.
|
||||||
|
/// </summary>
|
||||||
|
public event Action<HitObjectMask, InputState> SelectionRequested;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Invoked when this <see cref="HitObjectMask"/> has requested drag.
|
||||||
|
/// </summary>
|
||||||
|
public event Action<HitObjectMask, InputState> DragRequested;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The <see cref="DrawableHitObject"/> which this <see cref="HitObjectMask"/> applies to.
|
||||||
|
/// </summary>
|
||||||
public readonly DrawableHitObject HitObject;
|
public readonly DrawableHitObject HitObject;
|
||||||
|
|
||||||
|
protected override bool ShouldBeAlive => HitObject.IsAlive && HitObject.IsPresent || State == SelectionState.Selected;
|
||||||
|
public override bool HandleMouseInput => ShouldBeAlive;
|
||||||
|
public override bool RemoveWhenNotAlive => false;
|
||||||
|
|
||||||
public HitObjectMask(DrawableHitObject hitObject)
|
public HitObjectMask(DrawableHitObject hitObject)
|
||||||
{
|
{
|
||||||
HitObject = hitObject;
|
HitObject = hitObject;
|
||||||
|
|
||||||
|
AlwaysPresent = true;
|
||||||
|
Alpha = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private SelectionState state;
|
||||||
|
|
||||||
|
public event Action<SelectionState> StateChanged;
|
||||||
|
|
||||||
|
public SelectionState State
|
||||||
|
{
|
||||||
|
get => state;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (state == value) return;
|
||||||
|
|
||||||
|
state = value;
|
||||||
|
switch (state)
|
||||||
|
{
|
||||||
|
case SelectionState.Selected:
|
||||||
|
Show();
|
||||||
|
Selected?.Invoke(this);
|
||||||
|
break;
|
||||||
|
case SelectionState.NotSelected:
|
||||||
|
Hide();
|
||||||
|
Deselected?.Invoke(this);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Selects this <see cref="HitObjectMask"/>, causing it to become visible.
|
||||||
|
/// </summary>
|
||||||
|
public void Select() => State = SelectionState.Selected;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Deselects this <see cref="HitObjectMask"/>, causing it to become invisible.
|
||||||
|
/// </summary>
|
||||||
|
public void Deselect() => State = SelectionState.NotSelected;
|
||||||
|
|
||||||
|
public bool IsSelected => State == SelectionState.Selected;
|
||||||
|
|
||||||
|
private bool selectionRequested;
|
||||||
|
|
||||||
|
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
|
||||||
|
{
|
||||||
|
selectionRequested = false;
|
||||||
|
|
||||||
|
if (State == SelectionState.NotSelected)
|
||||||
|
{
|
||||||
|
SelectionRequested?.Invoke(this, state);
|
||||||
|
selectionRequested = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return IsSelected;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool OnClick(InputState state)
|
||||||
|
{
|
||||||
|
if (State == SelectionState.Selected && !selectionRequested)
|
||||||
|
{
|
||||||
|
selectionRequested = true;
|
||||||
|
SelectionRequested?.Invoke(this, state);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return base.OnClick(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool OnDragStart(InputState state) => true;
|
||||||
|
|
||||||
|
protected override bool OnDrag(InputState state)
|
||||||
|
{
|
||||||
|
DragRequested?.Invoke(this, state);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The screen-space point that causes this <see cref="HitObjectMask"/> to be selected.
|
||||||
|
/// </summary>
|
||||||
|
public virtual Vector2 SelectionPoint => ScreenSpaceDrawQuad.Centre;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The screen-space quad that outlines this <see cref="HitObjectMask"/> for selections.
|
||||||
|
/// </summary>
|
||||||
|
public virtual Quad SelectionQuad => ScreenSpaceDrawQuad;
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum SelectionState
|
||||||
|
{
|
||||||
|
NotSelected,
|
||||||
|
Selected
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -23,6 +23,8 @@ namespace osu.Game.Rulesets.Judgements
|
|||||||
{
|
{
|
||||||
private const float judgement_size = 80;
|
private const float judgement_size = 80;
|
||||||
|
|
||||||
|
private OsuColour colours;
|
||||||
|
|
||||||
protected readonly Judgement Judgement;
|
protected readonly Judgement Judgement;
|
||||||
|
|
||||||
public readonly DrawableHitObject JudgedObject;
|
public readonly DrawableHitObject JudgedObject;
|
||||||
@ -45,11 +47,13 @@ namespace osu.Game.Rulesets.Judgements
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours)
|
private void load(OsuColour colours)
|
||||||
{
|
{
|
||||||
|
this.colours = colours;
|
||||||
|
|
||||||
Child = new SkinnableDrawable($"Play/{Judgement.Result}", _ => JudgementText = new OsuSpriteText
|
Child = new SkinnableDrawable($"Play/{Judgement.Result}", _ => JudgementText = new OsuSpriteText
|
||||||
{
|
{
|
||||||
Text = Judgement.Result.GetDescription().ToUpper(),
|
Text = Judgement.Result.GetDescription().ToUpper(),
|
||||||
Font = @"Venera",
|
Font = @"Venera",
|
||||||
Colour = Judgement.Result == HitResult.Miss ? colours.Red : Color4.White,
|
Colour = judgementColour(Judgement.Result),
|
||||||
Scale = new Vector2(0.85f, 1),
|
Scale = new Vector2(0.85f, 1),
|
||||||
TextSize = 12
|
TextSize = 12
|
||||||
}, restrictSize: false);
|
}, restrictSize: false);
|
||||||
@ -84,5 +88,24 @@ namespace osu.Game.Rulesets.Judgements
|
|||||||
|
|
||||||
Expire(true);
|
Expire(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Color4 judgementColour(HitResult judgement)
|
||||||
|
{
|
||||||
|
switch (judgement)
|
||||||
|
{
|
||||||
|
case HitResult.Perfect:
|
||||||
|
case HitResult.Great:
|
||||||
|
return colours.Blue;
|
||||||
|
case HitResult.Ok:
|
||||||
|
case HitResult.Good:
|
||||||
|
return colours.Green;
|
||||||
|
case HitResult.Meh:
|
||||||
|
return colours.Yellow;
|
||||||
|
case HitResult.Miss:
|
||||||
|
return colours.Red;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Color4.White;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,14 +6,12 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Configuration;
|
using osu.Framework.Configuration;
|
||||||
using osu.Framework.Graphics.Primitives;
|
|
||||||
using osu.Game.Audio;
|
using osu.Game.Audio;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Rulesets.Judgements;
|
using osu.Game.Rulesets.Judgements;
|
||||||
using osu.Game.Rulesets.Objects.Types;
|
using osu.Game.Rulesets.Objects.Types;
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
using OpenTK;
|
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Objects.Drawables
|
namespace osu.Game.Rulesets.Objects.Drawables
|
||||||
@ -231,16 +229,6 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
|||||||
protected virtual void CheckForJudgements(bool userTriggered, double timeOffset)
|
protected virtual void CheckForJudgements(bool userTriggered, double timeOffset)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The screen-space point that causes this <see cref="DrawableHitObject"/> to be selected in the Editor.
|
|
||||||
/// </summary>
|
|
||||||
public virtual Vector2 SelectionPoint => ScreenSpaceDrawQuad.Centre;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The screen-space quad that outlines this <see cref="DrawableHitObject"/> for selections in the Editor.
|
|
||||||
/// </summary>
|
|
||||||
public virtual Quad SelectionQuad => ScreenSpaceDrawQuad;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract class DrawableHitObject<TObject> : DrawableHitObject
|
public abstract class DrawableHitObject<TObject> : DrawableHitObject
|
||||||
|
@ -290,7 +290,7 @@ namespace osu.Game.Rulesets.UI
|
|||||||
base.SetReplay(replay);
|
base.SetReplay(replay);
|
||||||
|
|
||||||
if (ReplayInputManager?.ReplayInputHandler != null)
|
if (ReplayInputManager?.ReplayInputHandler != null)
|
||||||
ReplayInputManager.ReplayInputHandler.ToScreenSpace = input => Playfield.ScaledContent.ToScreenSpace(input);
|
ReplayInputManager.ReplayInputHandler.GamefieldToScreenSpace = Playfield.GamefieldToScreenSpace;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -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 System;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
@ -12,13 +13,16 @@ namespace osu.Game.Rulesets.UI
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class ScalableContainer : Container
|
public class ScalableContainer : Container
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A function that converts coordinates from gamefield to screen space.
|
||||||
|
/// </summary>
|
||||||
|
public Func<Vector2, Vector2> GamefieldToScreenSpace => scaledContent.GamefieldToScreenSpace;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The scaled content.
|
/// The scaled content.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly Container ScaledContent;
|
private readonly ScaledContainer scaledContent;
|
||||||
|
protected override Container<Drawable> Content => scaledContent;
|
||||||
protected override Container<Drawable> Content => content;
|
|
||||||
private readonly Container content;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A <see cref="Container"/> which can have its internal coordinate system scaled to a specific size.
|
/// A <see cref="Container"/> which can have its internal coordinate system scaled to a specific size.
|
||||||
@ -31,17 +35,21 @@ namespace osu.Game.Rulesets.UI
|
|||||||
/// </param>
|
/// </param>
|
||||||
public ScalableContainer(float? customWidth = null, float? customHeight = null)
|
public ScalableContainer(float? customWidth = null, float? customHeight = null)
|
||||||
{
|
{
|
||||||
AddInternal(ScaledContent = new ScaledContainer
|
AddInternal(scaledContent = new ScaledContainer
|
||||||
{
|
{
|
||||||
CustomWidth = customWidth,
|
CustomWidth = customWidth,
|
||||||
CustomHeight = customHeight,
|
CustomHeight = customHeight,
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Child = content = new Container { RelativeSizeAxes = Axes.Both }
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ScaledContainer : Container
|
private class ScaledContainer : Container
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A function that converts coordinates from gamefield to screen space.
|
||||||
|
/// </summary>
|
||||||
|
public Func<Vector2, Vector2> GamefieldToScreenSpace => content.ToScreenSpace;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The value to scale the width of the content to match.
|
/// The value to scale the width of the content to match.
|
||||||
/// If null, <see cref="CustomHeight"/> is used.
|
/// If null, <see cref="CustomHeight"/> is used.
|
||||||
@ -54,6 +62,22 @@ namespace osu.Game.Rulesets.UI
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public float? CustomHeight;
|
public float? CustomHeight;
|
||||||
|
|
||||||
|
private readonly Container content;
|
||||||
|
protected override Container<Drawable> Content => content;
|
||||||
|
|
||||||
|
public ScaledContainer()
|
||||||
|
{
|
||||||
|
AddInternal(content = new Container { RelativeSizeAxes = Axes.Both });
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Update()
|
||||||
|
{
|
||||||
|
base.Update();
|
||||||
|
|
||||||
|
content.Scale = sizeScale;
|
||||||
|
content.Size = Vector2.Divide(Vector2.One, sizeScale);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The scale that is required for the size of the content to match <see cref="CustomWidth"/> and <see cref="CustomHeight"/>.
|
/// The scale that is required for the size of the content to match <see cref="CustomWidth"/> and <see cref="CustomHeight"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -70,17 +94,6 @@ namespace osu.Game.Rulesets.UI
|
|||||||
return Vector2.One;
|
return Vector2.One;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Scale the content to the required container size by multiplying by <see cref="sizeScale"/>.
|
|
||||||
/// </summary>
|
|
||||||
protected override Vector2 DrawScale => sizeScale * base.DrawScale;
|
|
||||||
|
|
||||||
protected override void Update()
|
|
||||||
{
|
|
||||||
base.Update();
|
|
||||||
RelativeChildSize = new Vector2(CustomWidth.HasValue ? sizeScale.X : RelativeChildSize.X, CustomHeight.HasValue ? sizeScale.Y : RelativeChildSize.Y);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
92
osu.Game/Screens/Edit/Screens/Compose/Layers/DragLayer.cs
Normal file
92
osu.Game/Screens/Edit/Screens/Compose/Layers/DragLayer.cs
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Primitives;
|
||||||
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Framework.Input;
|
||||||
|
using osu.Game.Rulesets.Edit;
|
||||||
|
using OpenTK.Graphics;
|
||||||
|
|
||||||
|
namespace osu.Game.Screens.Edit.Screens.Compose.Layers
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A layer that handles and displays drag selection for a collection of <see cref="HitObjectMask"/>s.
|
||||||
|
/// </summary>
|
||||||
|
public class DragLayer : CompositeDrawable
|
||||||
|
{
|
||||||
|
private readonly Action<RectangleF> performSelection;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Invoked when the drag selection has finished.
|
||||||
|
/// </summary>
|
||||||
|
public event Action DragEnd;
|
||||||
|
|
||||||
|
private Drawable box;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new <see cref="DragLayer"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="maskContainer">The selectable <see cref="HitObjectMask"/>s.</param>
|
||||||
|
public DragLayer(Action<RectangleF> performSelection)
|
||||||
|
{
|
||||||
|
this.performSelection = performSelection;
|
||||||
|
|
||||||
|
RelativeSizeAxes = Axes.Both;
|
||||||
|
AlwaysPresent = true;
|
||||||
|
Alpha = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
|
{
|
||||||
|
InternalChild = box = new Container
|
||||||
|
{
|
||||||
|
Masking = true,
|
||||||
|
BorderColour = Color4.White,
|
||||||
|
BorderThickness = MaskSelection.BORDER_RADIUS,
|
||||||
|
Child = new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Alpha = 0.1f
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool OnDragStart(InputState state)
|
||||||
|
{
|
||||||
|
this.FadeIn(250, Easing.OutQuint);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool OnDrag(InputState state)
|
||||||
|
{
|
||||||
|
var dragPosition = state.Mouse.NativeState.Position;
|
||||||
|
var dragStartPosition = state.Mouse.NativeState.PositionMouseDown ?? dragPosition;
|
||||||
|
|
||||||
|
var dragQuad = new Quad(dragStartPosition.X, dragStartPosition.Y, dragPosition.X - dragStartPosition.X, dragPosition.Y - dragStartPosition.Y);
|
||||||
|
|
||||||
|
// We use AABBFloat instead of RectangleF since it handles negative sizes for us
|
||||||
|
var dragRectangle = dragQuad.AABBFloat;
|
||||||
|
|
||||||
|
var topLeft = ToLocalSpace(dragRectangle.TopLeft);
|
||||||
|
var bottomRight = ToLocalSpace(dragRectangle.BottomRight);
|
||||||
|
|
||||||
|
box.Position = topLeft;
|
||||||
|
box.Size = bottomRight - topLeft;
|
||||||
|
|
||||||
|
performSelection?.Invoke(dragRectangle);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool OnDragEnd(InputState state)
|
||||||
|
{
|
||||||
|
this.FadeOut(250, Easing.OutQuint);
|
||||||
|
DragEnd?.Invoke();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -2,65 +2,92 @@
|
|||||||
// 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.Linq;
|
using System.Linq;
|
||||||
|
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.Game.Rulesets.Edit;
|
using osu.Game.Rulesets.Edit;
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
|
using osu.Game.Rulesets.UI;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Edit.Screens.Compose.Layers
|
namespace osu.Game.Screens.Edit.Screens.Compose.Layers
|
||||||
{
|
{
|
||||||
public class HitObjectMaskLayer : CompositeDrawable
|
public class HitObjectMaskLayer : CompositeDrawable
|
||||||
{
|
{
|
||||||
|
private readonly Playfield playfield;
|
||||||
private readonly HitObjectComposer composer;
|
private readonly HitObjectComposer composer;
|
||||||
private readonly Container<HitObjectMask> overlayContainer;
|
|
||||||
|
|
||||||
public HitObjectMaskLayer(HitObjectComposer composer)
|
private MaskContainer maskContainer;
|
||||||
|
|
||||||
|
public HitObjectMaskLayer(Playfield playfield, HitObjectComposer composer)
|
||||||
{
|
{
|
||||||
|
// we need the playfield as HitObjects may not be initialised until its BDL.
|
||||||
|
this.playfield = playfield;
|
||||||
|
|
||||||
this.composer = composer;
|
this.composer = composer;
|
||||||
|
|
||||||
RelativeSizeAxes = Axes.Both;
|
RelativeSizeAxes = Axes.Both;
|
||||||
|
}
|
||||||
|
|
||||||
InternalChild = overlayContainer = new Container<HitObjectMask> { RelativeSizeAxes = Axes.Both };
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
|
{
|
||||||
|
maskContainer = new MaskContainer();
|
||||||
|
|
||||||
|
var maskSelection = composer.CreateMaskSelection();
|
||||||
|
|
||||||
|
maskContainer.MaskSelected += maskSelection.HandleSelected;
|
||||||
|
maskContainer.MaskDeselected += maskSelection.HandleDeselected;
|
||||||
|
maskContainer.MaskSelectionRequested += maskSelection.HandleSelectionRequested;
|
||||||
|
maskContainer.MaskDragRequested += maskSelection.HandleDrag;
|
||||||
|
|
||||||
|
maskSelection.DeselectAll = maskContainer.DeselectAll;
|
||||||
|
|
||||||
|
var dragLayer = new DragLayer(maskContainer.Select);
|
||||||
|
dragLayer.DragEnd += () => maskSelection.UpdateVisibility();
|
||||||
|
|
||||||
|
InternalChildren = new Drawable[]
|
||||||
|
{
|
||||||
|
dragLayer,
|
||||||
|
maskSelection,
|
||||||
|
maskContainer,
|
||||||
|
dragLayer.CreateProxy()
|
||||||
|
};
|
||||||
|
|
||||||
|
foreach (var obj in playfield.HitObjects.Objects)
|
||||||
|
addMask(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
|
||||||
|
{
|
||||||
|
maskContainer.DeselectAll();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Adds an overlay for a <see cref="DrawableHitObject"/> which adds movement support.
|
/// Adds a mask for a <see cref="DrawableHitObject"/> which adds movement support.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="hitObject">The <see cref="DrawableHitObject"/> to create an overlay for.</param>
|
/// <param name="hitObject">The <see cref="DrawableHitObject"/> to create a mask for.</param>
|
||||||
public void AddOverlay(DrawableHitObject hitObject)
|
private void addMask(DrawableHitObject hitObject)
|
||||||
{
|
{
|
||||||
var overlay = composer.CreateMaskFor(hitObject);
|
var mask = composer.CreateMaskFor(hitObject);
|
||||||
if (overlay == null)
|
if (mask == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
overlayContainer.Add(overlay);
|
maskContainer.Add(mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Removes the overlay for a <see cref="DrawableHitObject"/>.
|
/// Removes the mask for a <see cref="DrawableHitObject"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="hitObject">The <see cref="DrawableHitObject"/> to remove the overlay for.</param>
|
/// <param name="hitObject">The <see cref="DrawableHitObject"/> to remove the mask for.</param>
|
||||||
public void RemoveOverlay(DrawableHitObject hitObject)
|
private void removeMask(DrawableHitObject hitObject)
|
||||||
{
|
{
|
||||||
var existing = overlayContainer.FirstOrDefault(h => h.HitObject == hitObject);
|
var mask = maskContainer.FirstOrDefault(h => h.HitObject == hitObject);
|
||||||
if (existing == null)
|
if (mask == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
existing.Hide();
|
maskContainer.Remove(mask);
|
||||||
existing.Expire();
|
|
||||||
}
|
|
||||||
|
|
||||||
private SelectionBox currentSelectionBox;
|
|
||||||
|
|
||||||
public void AddSelectionOverlay()
|
|
||||||
{
|
|
||||||
if (overlayContainer.Count > 0)
|
|
||||||
AddInternal(currentSelectionBox = composer.CreateSelectionOverlay(overlayContainer));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void RemoveSelectionOverlay()
|
|
||||||
{
|
|
||||||
currentSelectionBox?.Hide();
|
|
||||||
currentSelectionBox?.Expire();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
123
osu.Game/Screens/Edit/Screens/Compose/Layers/MaskContainer.cs
Normal file
123
osu.Game/Screens/Edit/Screens/Compose/Layers/MaskContainer.cs
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Input;
|
||||||
|
using osu.Game.Rulesets.Edit;
|
||||||
|
using RectangleF = osu.Framework.Graphics.Primitives.RectangleF;
|
||||||
|
|
||||||
|
namespace osu.Game.Screens.Edit.Screens.Compose.Layers
|
||||||
|
{
|
||||||
|
public class MaskContainer : Container<HitObjectMask>
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Invoked when any <see cref="HitObjectMask"/> is selected.
|
||||||
|
/// </summary>
|
||||||
|
public event Action<HitObjectMask> MaskSelected;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Invoked when any <see cref="HitObjectMask"/> is deselected.
|
||||||
|
/// </summary>
|
||||||
|
public event Action<HitObjectMask> MaskDeselected;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Invoked when any <see cref="HitObjectMask"/> requests selection.
|
||||||
|
/// </summary>
|
||||||
|
public event Action<HitObjectMask, InputState> MaskSelectionRequested;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Invoked when any <see cref="HitObjectMask"/> requests drag.
|
||||||
|
/// </summary>
|
||||||
|
public event Action<HitObjectMask, InputState> MaskDragRequested;
|
||||||
|
|
||||||
|
private IEnumerable<HitObjectMask> aliveMasks => AliveInternalChildren.Cast<HitObjectMask>();
|
||||||
|
|
||||||
|
public MaskContainer()
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Add(HitObjectMask drawable)
|
||||||
|
{
|
||||||
|
base.Add(drawable);
|
||||||
|
|
||||||
|
drawable.Selected += onMaskSelected;
|
||||||
|
drawable.Deselected += onMaskDeselected;
|
||||||
|
drawable.SelectionRequested += onSelectionRequested;
|
||||||
|
drawable.DragRequested += onDragRequested;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool Remove(HitObjectMask drawable)
|
||||||
|
{
|
||||||
|
var result = base.Remove(drawable);
|
||||||
|
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
drawable.Selected -= onMaskSelected;
|
||||||
|
drawable.Deselected -= onMaskDeselected;
|
||||||
|
drawable.SelectionRequested -= onSelectionRequested;
|
||||||
|
drawable.DragRequested -= onDragRequested;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Select all masks in a given rectangle selection area.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="rect">The rectangle to perform a selection on in screen-space coordinates.</param>
|
||||||
|
public void Select(RectangleF rect)
|
||||||
|
{
|
||||||
|
foreach (var mask in aliveMasks.ToList())
|
||||||
|
{
|
||||||
|
if (mask.IsPresent && rect.Contains(mask.SelectionPoint))
|
||||||
|
mask.Select();
|
||||||
|
else
|
||||||
|
mask.Deselect();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Deselects all selected <see cref="HitObjectMask"/>s.
|
||||||
|
/// </summary>
|
||||||
|
public void DeselectAll() => aliveMasks.ToList().ForEach(m => m.Deselect());
|
||||||
|
|
||||||
|
private void onMaskSelected(HitObjectMask mask)
|
||||||
|
{
|
||||||
|
MaskSelected?.Invoke(mask);
|
||||||
|
ChangeChildDepth(mask, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onMaskDeselected(HitObjectMask mask)
|
||||||
|
{
|
||||||
|
MaskDeselected?.Invoke(mask);
|
||||||
|
ChangeChildDepth(mask, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onSelectionRequested(HitObjectMask mask, InputState state) => MaskSelectionRequested?.Invoke(mask, state);
|
||||||
|
private void onDragRequested(HitObjectMask mask, InputState state) => MaskDragRequested?.Invoke(mask, state);
|
||||||
|
|
||||||
|
protected override int Compare(Drawable x, Drawable y)
|
||||||
|
{
|
||||||
|
if (!(x is HitObjectMask xMask) || !(y is HitObjectMask yMask))
|
||||||
|
return base.Compare(x, y);
|
||||||
|
return Compare(xMask, yMask);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Compare(HitObjectMask x, HitObjectMask y)
|
||||||
|
{
|
||||||
|
// dpeth is used to denote selected status (we always want selected masks to handle input first).
|
||||||
|
int d = x.Depth.CompareTo(y.Depth);
|
||||||
|
if (d != 0)
|
||||||
|
return d;
|
||||||
|
|
||||||
|
// Put earlier hitobjects towards the end of the list, so they handle input first
|
||||||
|
int i = y.HitObject.HitObject.StartTime.CompareTo(x.HitObject.HitObject.StartTime);
|
||||||
|
return i == 0 ? CompareReverseChildID(x, y) : i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
164
osu.Game/Screens/Edit/Screens/Compose/Layers/MaskSelection.cs
Normal file
164
osu.Game/Screens/Edit/Screens/Compose/Layers/MaskSelection.cs
Normal file
@ -0,0 +1,164 @@
|
|||||||
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Framework.Input;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Rulesets.Edit;
|
||||||
|
using osu.Game.Rulesets.Edit.Types;
|
||||||
|
using OpenTK;
|
||||||
|
|
||||||
|
namespace osu.Game.Screens.Edit.Screens.Compose.Layers
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A box which surrounds <see cref="HitObjectMask"/>s and provides interactive handles, context menus etc.
|
||||||
|
/// </summary>
|
||||||
|
public class MaskSelection : CompositeDrawable
|
||||||
|
{
|
||||||
|
public const float BORDER_RADIUS = 2;
|
||||||
|
|
||||||
|
private readonly List<HitObjectMask> selectedMasks;
|
||||||
|
|
||||||
|
private Drawable outline;
|
||||||
|
|
||||||
|
public MaskSelection()
|
||||||
|
{
|
||||||
|
selectedMasks = new List<HitObjectMask>();
|
||||||
|
|
||||||
|
RelativeSizeAxes = Axes.Both;
|
||||||
|
AlwaysPresent = true;
|
||||||
|
Alpha = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OsuColour colours)
|
||||||
|
{
|
||||||
|
InternalChild = outline = new Container
|
||||||
|
{
|
||||||
|
Masking = true,
|
||||||
|
BorderThickness = BORDER_RADIUS,
|
||||||
|
BorderColour = colours.Yellow,
|
||||||
|
Child = new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
AlwaysPresent = true,
|
||||||
|
Alpha = 0
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#region User Input Handling
|
||||||
|
|
||||||
|
public void HandleDrag(HitObjectMask m, InputState state)
|
||||||
|
{
|
||||||
|
// Todo: Various forms of snapping
|
||||||
|
|
||||||
|
foreach (var mask in selectedMasks)
|
||||||
|
{
|
||||||
|
switch (mask.HitObject.HitObject)
|
||||||
|
{
|
||||||
|
case IHasEditablePosition editablePosition:
|
||||||
|
editablePosition.OffsetPosition(state.Mouse.Delta);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Selection Handling
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Bind an action to deselect all selected masks.
|
||||||
|
/// </summary>
|
||||||
|
public Action DeselectAll { private get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Handle a mask becoming selected.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="mask">The mask.</param>
|
||||||
|
public void HandleSelected(HitObjectMask mask) => selectedMasks.Add(mask);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Handle a mask becoming deselected.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="mask">The mask.</param>
|
||||||
|
public void HandleDeselected(HitObjectMask mask)
|
||||||
|
{
|
||||||
|
selectedMasks.Remove(mask);
|
||||||
|
|
||||||
|
// We don't want to update visibility if > 0, since we may be deselecting masks during drag-selection
|
||||||
|
if (selectedMasks.Count == 0)
|
||||||
|
UpdateVisibility();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Handle a mask requesting selection.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="mask">The mask.</param>
|
||||||
|
public void HandleSelectionRequested(HitObjectMask mask, InputState state)
|
||||||
|
{
|
||||||
|
if (state.Keyboard.ControlPressed)
|
||||||
|
{
|
||||||
|
if (mask.IsSelected)
|
||||||
|
mask.Deselect();
|
||||||
|
else
|
||||||
|
mask.Select();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (mask.IsSelected)
|
||||||
|
return;
|
||||||
|
|
||||||
|
DeselectAll?.Invoke();
|
||||||
|
mask.Select();
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateVisibility();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Updates whether this <see cref="MaskSelection"/> is visible.
|
||||||
|
/// </summary>
|
||||||
|
internal void UpdateVisibility()
|
||||||
|
{
|
||||||
|
if (selectedMasks.Count > 0)
|
||||||
|
Show();
|
||||||
|
else
|
||||||
|
Hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Update()
|
||||||
|
{
|
||||||
|
base.Update();
|
||||||
|
|
||||||
|
if (selectedMasks.Count == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Move the rectangle to cover the hitobjects
|
||||||
|
var topLeft = new Vector2(float.MaxValue, float.MaxValue);
|
||||||
|
var bottomRight = new Vector2(float.MinValue, float.MinValue);
|
||||||
|
|
||||||
|
bool hasSelection = false;
|
||||||
|
|
||||||
|
foreach (var mask in selectedMasks)
|
||||||
|
{
|
||||||
|
topLeft = Vector2.ComponentMin(topLeft, ToLocalSpace(mask.SelectionQuad.TopLeft));
|
||||||
|
bottomRight = Vector2.ComponentMax(bottomRight, ToLocalSpace(mask.SelectionQuad.BottomRight));
|
||||||
|
}
|
||||||
|
|
||||||
|
topLeft -= new Vector2(5);
|
||||||
|
bottomRight += new Vector2(5);
|
||||||
|
|
||||||
|
outline.Size = bottomRight - topLeft;
|
||||||
|
outline.Position = topLeft;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,102 +0,0 @@
|
|||||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
||||||
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using osu.Framework.Allocation;
|
|
||||||
using osu.Framework.Graphics;
|
|
||||||
using osu.Framework.Graphics.Containers;
|
|
||||||
using osu.Framework.Graphics.Shapes;
|
|
||||||
using osu.Framework.Input;
|
|
||||||
using osu.Game.Graphics;
|
|
||||||
using osu.Game.Rulesets.Edit;
|
|
||||||
using osu.Game.Rulesets.Edit.Types;
|
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
|
||||||
using OpenTK;
|
|
||||||
|
|
||||||
namespace osu.Game.Screens.Edit.Screens.Compose.Layers
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// A box which surrounds <see cref="DrawableHitObject"/>s and provides interactive handles, context menus etc.
|
|
||||||
/// </summary>
|
|
||||||
public class SelectionBox : VisibilityContainer
|
|
||||||
{
|
|
||||||
private readonly IReadOnlyList<HitObjectMask> overlays;
|
|
||||||
|
|
||||||
public const float BORDER_RADIUS = 2;
|
|
||||||
|
|
||||||
public SelectionBox(IReadOnlyList<HitObjectMask> overlays)
|
|
||||||
{
|
|
||||||
this.overlays = overlays;
|
|
||||||
|
|
||||||
Masking = true;
|
|
||||||
BorderThickness = BORDER_RADIUS;
|
|
||||||
|
|
||||||
InternalChild = new Box
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
AlwaysPresent = true,
|
|
||||||
Alpha = 0
|
|
||||||
};
|
|
||||||
|
|
||||||
State = Visibility.Visible;
|
|
||||||
}
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
|
||||||
private void load(OsuColour colours)
|
|
||||||
{
|
|
||||||
BorderColour = colours.Yellow;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Update()
|
|
||||||
{
|
|
||||||
base.Update();
|
|
||||||
|
|
||||||
// Todo: We might need to optimise this
|
|
||||||
|
|
||||||
// Move the rectangle to cover the hitobjects
|
|
||||||
var topLeft = new Vector2(float.MaxValue, float.MaxValue);
|
|
||||||
var bottomRight = new Vector2(float.MinValue, float.MinValue);
|
|
||||||
|
|
||||||
foreach (var obj in overlays)
|
|
||||||
{
|
|
||||||
topLeft = Vector2.ComponentMin(topLeft, Parent.ToLocalSpace(obj.HitObject.SelectionQuad.TopLeft));
|
|
||||||
bottomRight = Vector2.ComponentMax(bottomRight, Parent.ToLocalSpace(obj.HitObject.SelectionQuad.BottomRight));
|
|
||||||
}
|
|
||||||
|
|
||||||
topLeft -= new Vector2(5);
|
|
||||||
bottomRight += new Vector2(5);
|
|
||||||
|
|
||||||
Size = bottomRight - topLeft;
|
|
||||||
Position = topLeft;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => overlays.Any(o => o.ReceiveMouseInputAt(screenSpacePos));
|
|
||||||
|
|
||||||
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) => true;
|
|
||||||
|
|
||||||
protected override bool OnDragStart(InputState state) => true;
|
|
||||||
|
|
||||||
protected override bool OnDrag(InputState state)
|
|
||||||
{
|
|
||||||
// Todo: Various forms of snapping
|
|
||||||
foreach (var hitObject in overlays.Select(o => o.HitObject.HitObject))
|
|
||||||
{
|
|
||||||
switch (hitObject)
|
|
||||||
{
|
|
||||||
case IHasEditablePosition editablePosition:
|
|
||||||
editablePosition.OffsetPosition(state.Mouse.Delta);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override bool OnDragEnd(InputState state) => true;
|
|
||||||
|
|
||||||
public override bool DisposeOnDeathRemoval => true;
|
|
||||||
|
|
||||||
protected override void PopIn() => this.FadeIn();
|
|
||||||
protected override void PopOut() => this.FadeOut();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,240 +0,0 @@
|
|||||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
|
||||||
using osu.Framework.Graphics;
|
|
||||||
using osu.Framework.Graphics.Containers;
|
|
||||||
using osu.Framework.Graphics.Primitives;
|
|
||||||
using osu.Framework.Graphics.Shapes;
|
|
||||||
using osu.Framework.Input;
|
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
|
||||||
using osu.Game.Rulesets.UI;
|
|
||||||
using OpenTK;
|
|
||||||
using OpenTK.Graphics;
|
|
||||||
using RectangleF = osu.Framework.Graphics.Primitives.RectangleF;
|
|
||||||
|
|
||||||
namespace osu.Game.Screens.Edit.Screens.Compose.Layers
|
|
||||||
{
|
|
||||||
public class SelectionLayer : CompositeDrawable
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Invoked when a <see cref="DrawableHitObject"/> is selected.
|
|
||||||
/// </summary>
|
|
||||||
public event Action<DrawableHitObject> ObjectSelected;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Invoked when a <see cref="DrawableHitObject"/> is deselected.
|
|
||||||
/// </summary>
|
|
||||||
public event Action<DrawableHitObject> ObjectDeselected;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Invoked when the selection has been cleared.
|
|
||||||
/// </summary>
|
|
||||||
public event Action SelectionCleared;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Invoked when the user has finished selecting all <see cref="DrawableHitObject"/>s.
|
|
||||||
/// </summary>
|
|
||||||
public event Action SelectionFinished;
|
|
||||||
|
|
||||||
private readonly Playfield playfield;
|
|
||||||
|
|
||||||
public SelectionLayer(Playfield playfield)
|
|
||||||
{
|
|
||||||
this.playfield = playfield;
|
|
||||||
|
|
||||||
RelativeSizeAxes = Axes.Both;
|
|
||||||
}
|
|
||||||
|
|
||||||
private DragBox dragBox;
|
|
||||||
|
|
||||||
private readonly HashSet<DrawableHitObject> selectedHitObjects = new HashSet<DrawableHitObject>();
|
|
||||||
|
|
||||||
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
|
|
||||||
{
|
|
||||||
DeselectAll();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override bool OnDragStart(InputState state)
|
|
||||||
{
|
|
||||||
AddInternal(dragBox = new DragBox());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override bool OnDrag(InputState state)
|
|
||||||
{
|
|
||||||
dragBox.Show();
|
|
||||||
|
|
||||||
var dragPosition = state.Mouse.NativeState.Position;
|
|
||||||
var dragStartPosition = state.Mouse.NativeState.PositionMouseDown ?? dragPosition;
|
|
||||||
|
|
||||||
var screenSpaceDragQuad = new Quad(dragStartPosition.X, dragStartPosition.Y, dragPosition.X - dragStartPosition.X, dragPosition.Y - dragStartPosition.Y);
|
|
||||||
|
|
||||||
dragBox.SetDragRectangle(screenSpaceDragQuad.AABBFloat);
|
|
||||||
selectQuad(screenSpaceDragQuad);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override bool OnDragEnd(InputState state)
|
|
||||||
{
|
|
||||||
dragBox.Hide();
|
|
||||||
dragBox.Expire();
|
|
||||||
|
|
||||||
finishSelection();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override bool OnClick(InputState state)
|
|
||||||
{
|
|
||||||
selectPoint(state.Mouse.NativeState.Position);
|
|
||||||
finishSelection();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Selects a <see cref="DrawableHitObject"/>.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="hitObject">The <see cref="DrawableHitObject"/> to select.</param>
|
|
||||||
public void Select(DrawableHitObject hitObject)
|
|
||||||
{
|
|
||||||
if (!select(hitObject))
|
|
||||||
return;
|
|
||||||
|
|
||||||
clearSelection();
|
|
||||||
finishSelection();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Selects a <see cref="DrawableHitObject"/> without performing capture updates.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="hitObject">The <see cref="DrawableHitObject"/> to select.</param>
|
|
||||||
/// <returns>Whether <paramref name="hitObject"/> was selected.</returns>
|
|
||||||
private bool select(DrawableHitObject hitObject)
|
|
||||||
{
|
|
||||||
if (!selectedHitObjects.Add(hitObject))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
ObjectSelected?.Invoke(hitObject);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Deselects a <see cref="DrawableHitObject"/>.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="hitObject">The <see cref="DrawableHitObject"/> to deselect.</param>
|
|
||||||
public void Deselect(DrawableHitObject hitObject)
|
|
||||||
{
|
|
||||||
if (!deselect(hitObject))
|
|
||||||
return;
|
|
||||||
|
|
||||||
clearSelection();
|
|
||||||
finishSelection();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Deselects a <see cref="DrawableHitObject"/> without performing capture updates.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="hitObject">The <see cref="DrawableHitObject"/> to deselect.</param>
|
|
||||||
/// <returns>Whether the <see cref="DrawableHitObject"/> was deselected.</returns>
|
|
||||||
private bool deselect(DrawableHitObject hitObject)
|
|
||||||
{
|
|
||||||
if (!selectedHitObjects.Remove(hitObject))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
ObjectDeselected?.Invoke(hitObject);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Deselects all selected <see cref="DrawableHitObject"/>s.
|
|
||||||
/// </summary>
|
|
||||||
public void DeselectAll()
|
|
||||||
{
|
|
||||||
selectedHitObjects.ForEach(h => ObjectDeselected?.Invoke(h));
|
|
||||||
selectedHitObjects.Clear();
|
|
||||||
|
|
||||||
clearSelection();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Selects all hitobjects that are present within the area of a <see cref="Quad"/>.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="screenSpaceQuad">The selection <see cref="Quad"/>.</param>
|
|
||||||
// Todo: If needed we can severely reduce allocations in this method
|
|
||||||
private void selectQuad(Quad screenSpaceQuad)
|
|
||||||
{
|
|
||||||
var expectedSelection = playfield.HitObjects.Objects.Where(h => h.IsAlive && h.IsPresent && screenSpaceQuad.Contains(h.SelectionPoint)).ToList();
|
|
||||||
|
|
||||||
var toRemove = selectedHitObjects.Except(expectedSelection).ToList();
|
|
||||||
foreach (var obj in toRemove)
|
|
||||||
deselect(obj);
|
|
||||||
|
|
||||||
expectedSelection.ForEach(h => select(h));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Selects the top-most hitobject that is present under a specific point.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="screenSpacePoint">The <see cref="Vector2"/> to select at.</param>
|
|
||||||
private void selectPoint(Vector2 screenSpacePoint)
|
|
||||||
{
|
|
||||||
var target = playfield.HitObjects.Objects.Reverse().Where(h => h.IsAlive && h.IsPresent).FirstOrDefault(h => h.ReceiveMouseInputAt(screenSpacePoint));
|
|
||||||
if (target == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
select(target);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void clearSelection() => SelectionCleared?.Invoke();
|
|
||||||
|
|
||||||
private void finishSelection()
|
|
||||||
{
|
|
||||||
if (selectedHitObjects.Count == 0)
|
|
||||||
return;
|
|
||||||
SelectionFinished?.Invoke();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// A box that represents a drag selection.
|
|
||||||
/// </summary>
|
|
||||||
private class DragBox : VisibilityContainer
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Creates a new <see cref="DragBox"/>.
|
|
||||||
/// </summary>
|
|
||||||
public DragBox()
|
|
||||||
{
|
|
||||||
Masking = true;
|
|
||||||
BorderColour = Color4.White;
|
|
||||||
BorderThickness = SelectionBox.BORDER_RADIUS;
|
|
||||||
|
|
||||||
Child = new Box
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Alpha = 0.1f
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetDragRectangle(RectangleF rectangle)
|
|
||||||
{
|
|
||||||
var topLeft = Parent.ToLocalSpace(rectangle.TopLeft);
|
|
||||||
var bottomRight = Parent.ToLocalSpace(rectangle.BottomRight);
|
|
||||||
|
|
||||||
Position = topLeft;
|
|
||||||
Size = bottomRight - topLeft;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool DisposeOnDeathRemoval => true;
|
|
||||||
|
|
||||||
protected override void PopIn() => this.FadeIn(250, Easing.OutQuint);
|
|
||||||
protected override void PopOut() => this.FadeOut(250, Easing.OutQuint);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -150,7 +150,7 @@ namespace osu.Game.Screens.Select
|
|||||||
var mods = modSelect.SelectedMods.Value;
|
var mods = modSelect.SelectedMods.Value;
|
||||||
if (mods.All(m => m.GetType() != autoType))
|
if (mods.All(m => m.GetType() != autoType))
|
||||||
{
|
{
|
||||||
modSelect.SelectedMods.Value = mods.Concat(new[] { auto });
|
modSelect.SelectedMods.Value = mods.Append(auto);
|
||||||
removeAutoModOnResume = true;
|
removeAutoModOnResume = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
||||||
|
|
||||||
using NUnit.Framework;
|
|
||||||
using osu.Framework.Testing;
|
|
||||||
|
|
||||||
namespace osu.Game.Tests
|
|
||||||
{
|
|
||||||
[TestFixture]
|
|
||||||
internal class TestTestCase : TestCase
|
|
||||||
{
|
|
||||||
// This TestCase is required for nunit to not throw errors
|
|
||||||
// See: https://github.com/nunit/nunit/issues/1118
|
|
||||||
}
|
|
||||||
}
|
|
29
osu.Game/Tests/Visual/ManualInputManagerTestCase.cs
Normal file
29
osu.Game/Tests/Visual/ManualInputManagerTestCase.cs
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Testing.Input;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Visual
|
||||||
|
{
|
||||||
|
public abstract class ManualInputManagerTestCase : OsuTestCase
|
||||||
|
{
|
||||||
|
protected override Container<Drawable> Content => InputManager;
|
||||||
|
protected readonly ManualInputManager InputManager;
|
||||||
|
|
||||||
|
protected ManualInputManagerTestCase()
|
||||||
|
{
|
||||||
|
base.Content.Add(InputManager = new ManualInputManager());
|
||||||
|
ReturnUserInput();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns input back to the user.
|
||||||
|
/// </summary>
|
||||||
|
protected void ReturnUserInput()
|
||||||
|
{
|
||||||
|
AddStep("Return user input", () => InputManager.UseParentState = true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user