mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 00:33:21 +08:00
Tidy up layer container logic
This commit is contained in:
parent
b74cfffc6f
commit
7c942eb592
@ -6,7 +6,6 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
@ -27,12 +26,11 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
protected ICompositionTool CurrentTool { get; private set; }
|
protected ICompositionTool CurrentTool { get; private set; }
|
||||||
|
|
||||||
private RulesetContainer rulesetContainer;
|
private RulesetContainer rulesetContainer;
|
||||||
private readonly Container[] layerContainers = new Container[2];
|
private readonly List<Container> layerContainers = new List<Container>();
|
||||||
|
|
||||||
protected HitObjectComposer(Ruleset ruleset)
|
protected HitObjectComposer(Ruleset ruleset)
|
||||||
{
|
{
|
||||||
this.ruleset = ruleset;
|
this.ruleset = ruleset;
|
||||||
|
|
||||||
RelativeSizeAxes = Axes.Both;
|
RelativeSizeAxes = Axes.Both;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,6 +40,9 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
rulesetContainer = CreateRulesetContainer(ruleset, osuGame.Beatmap.Value);
|
rulesetContainer = CreateRulesetContainer(ruleset, osuGame.Beatmap.Value);
|
||||||
|
|
||||||
|
// TODO: should probably be done at a RulesetContainer level to share logic with Player.
|
||||||
|
rulesetContainer.Clock = new InterpolatingFramedClock((IAdjustableClock)osuGame.Beatmap.Value.Track ?? new StopwatchClock());
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@ -49,19 +50,13 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
layerContainers[0] = CreateLayerContainer();
|
ScalableContainer createLayerContainerWithContent(Drawable content)
|
||||||
layerContainers[0].Child = new Container
|
|
||||||
{
|
{
|
||||||
Name = "Border",
|
var container = CreateLayerContainer();
|
||||||
RelativeSizeAxes = Axes.Both,
|
container.Child = content;
|
||||||
Masking = true,
|
layerContainers.Add(container);
|
||||||
BorderColour = Color4.White,
|
return container;
|
||||||
BorderThickness = 2,
|
}
|
||||||
Child = new Box { RelativeSizeAxes = Axes.Both, Alpha = 0, AlwaysPresent = true }
|
|
||||||
};
|
|
||||||
|
|
||||||
layerContainers[1] = CreateLayerContainer();
|
|
||||||
layerContainers[1].Child = new SelectionLayer(rulesetContainer.Playfield);
|
|
||||||
|
|
||||||
RadioButtonCollection toolboxCollection;
|
RadioButtonCollection toolboxCollection;
|
||||||
InternalChild = new GridContainer
|
InternalChild = new GridContainer
|
||||||
@ -87,9 +82,17 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
layerContainers[0],
|
createLayerContainerWithContent(new Container
|
||||||
|
{
|
||||||
|
Name = "Border",
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Masking = true,
|
||||||
|
BorderColour = Color4.White,
|
||||||
|
BorderThickness = 2,
|
||||||
|
Child = new Box { RelativeSizeAxes = Axes.Both, Alpha = 0, AlwaysPresent = true }
|
||||||
|
}),
|
||||||
rulesetContainer,
|
rulesetContainer,
|
||||||
layerContainers[1]
|
createLayerContainerWithContent(new SelectionLayer(rulesetContainer.Playfield))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -100,8 +103,6 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
rulesetContainer.Clock = new InterpolatingFramedClock((IAdjustableClock)osuGame.Beatmap.Value.Track ?? new StopwatchClock());
|
|
||||||
|
|
||||||
toolboxCollection.Items =
|
toolboxCollection.Items =
|
||||||
new[] { new RadioButton("Select", () => setCompositionTool(null)) }
|
new[] { new RadioButton("Select", () => setCompositionTool(null)) }
|
||||||
.Concat(
|
.Concat(
|
||||||
@ -134,6 +135,6 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
/// <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"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected virtual ScalableContainer CreateLayerContainer() => new ScalableContainer();
|
protected virtual ScalableContainer CreateLayerContainer() => new ScalableContainer { RelativeSizeAxes = Axes.Both };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user