Merge remote-tracking branch 'origin/master' into editor-hitobject-overlays

This commit is contained in:
smoogipoo
2018-02-22 14:16:01 +09:00
3 changed files with 24 additions and 43 deletions

View File

@ -6,7 +6,6 @@ using System.Collections.Generic;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using OpenTK; using OpenTK;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Edit.Layers.Selection; using osu.Game.Rulesets.Edit.Layers.Selection;
using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Osu; using osu.Game.Rulesets.Osu;

View File

@ -27,12 +27,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 ScalableContainer[] layerContainers = new ScalableContainer[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 +41,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,6 +51,14 @@ namespace osu.Game.Rulesets.Edit
return; return;
} }
ScalableContainer createLayerContainerWithContent(Drawable content)
{
var container = CreateLayerContainer();
container.Child = content;
layerContainers.Add(container);
return container;
}
RadioButtonCollection toolboxCollection; RadioButtonCollection toolboxCollection;
InternalChild = new GridContainer InternalChild = new GridContainer
{ {
@ -73,9 +83,17 @@ namespace osu.Game.Rulesets.Edit
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Children = new Drawable[] Children = new Drawable[]
{ {
createBottomLayer(), 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,
createTopLayer() createLayerContainerWithContent(new SelectionLayer(rulesetContainer.Playfield))
} }
} }
}, },
@ -86,8 +104,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(
@ -98,40 +114,6 @@ namespace osu.Game.Rulesets.Edit
toolboxCollection.Items[0].Select(); toolboxCollection.Items[0].Select();
} }
private ScalableContainer createBottomLayer()
{
layerContainers[0] = CreateLayerContainer();
layerContainers[0].Child = new Container
{
Name = "Border",
RelativeSizeAxes = Axes.Both,
Masking = true,
BorderColour = Color4.White,
BorderThickness = 2,
Child = new Box { RelativeSizeAxes = Axes.Both, Alpha = 0, AlwaysPresent = true }
};
return layerContainers[0];
}
private ScalableContainer createTopLayer()
{
var overlayLayer = CreateHitObjectOverlayLayer();
var selectionLayer = new SelectionLayer(rulesetContainer.Playfield);
selectionLayer.ObjectSelected += overlayLayer.AddOverlay;
selectionLayer.ObjectDeselected += overlayLayer.RemoveOverlay;
layerContainers[1] = CreateLayerContainer();
layerContainers[1].Children = new Drawable[]
{
overlayLayer,
selectionLayer,
};
return layerContainers[1];
}
protected override void UpdateAfterChildren() protected override void UpdateAfterChildren()
{ {
base.UpdateAfterChildren(); base.UpdateAfterChildren();
@ -154,7 +136,7 @@ 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 };
/// <summary> /// <summary>
/// Creates the <see cref="HitObjectOverlayLayer"/> which overlays selected <see cref="DrawableHitObject"/>s. /// Creates the <see cref="HitObjectOverlayLayer"/> which overlays selected <see cref="DrawableHitObject"/>s.

View File

@ -79,7 +79,7 @@ namespace osu.Game.Rulesets.UI
protected override void Update() protected override void Update()
{ {
base.Update(); base.Update();
RelativeChildSize = sizeScale; RelativeChildSize = new Vector2(CustomWidth.HasValue ? sizeScale.X : RelativeChildSize.X, CustomHeight.HasValue ? sizeScale.Y : RelativeChildSize.Y);
} }
} }
} }