mirror of
https://github.com/osukey/osukey.git
synced 2025-08-05 07:33:55 +09:00
Merge branch 'master' into visible-playfield-boundary
This commit is contained in:
@ -40,14 +40,29 @@ namespace osu.Game.Rulesets.Edit
|
||||
Playfield.DisplayJudgements.Value = false;
|
||||
}
|
||||
|
||||
[Resolved(canBeNull: true)]
|
||||
private IEditorChangeHandler changeHandler { get; set; }
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
beatmap.HitObjectAdded += addHitObject;
|
||||
beatmap.HitObjectRemoved += removeHitObject;
|
||||
|
||||
if (changeHandler != null)
|
||||
{
|
||||
// for now only regenerate replay on a finalised state change, not HitObjectUpdated.
|
||||
changeHandler.OnStateChange += updateReplay;
|
||||
}
|
||||
else
|
||||
{
|
||||
beatmap.HitObjectUpdated += _ => updateReplay();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateReplay() => drawableRuleset.RegenerateAutoplay();
|
||||
|
||||
private void addHitObject(HitObject hitObject)
|
||||
{
|
||||
var drawableObject = drawableRuleset.CreateDrawableRepresentation((TObject)hitObject);
|
||||
|
@ -23,6 +23,7 @@ using osu.Game.Rulesets.UI.Scrolling;
|
||||
using osu.Game.Screens;
|
||||
using osu.Game.Screens.Edit;
|
||||
using osu.Game.Screens.Edit.Components.RadioButtons;
|
||||
using osu.Game.Screens.Edit.Components.TernaryButtons;
|
||||
using osu.Game.Screens.Edit.Compose;
|
||||
using osu.Game.Screens.Edit.Compose.Components;
|
||||
using osuTK;
|
||||
@ -30,6 +31,11 @@ using osuTK.Input;
|
||||
|
||||
namespace osu.Game.Rulesets.Edit
|
||||
{
|
||||
/// <summary>
|
||||
/// Top level container for editor compose mode.
|
||||
/// Responsible for providing snapping and generally gluing components together.
|
||||
/// </summary>
|
||||
/// <typeparam name="TObject">The base type of supported objects.</typeparam>
|
||||
[Cached(Type = typeof(IPlacementHandler))]
|
||||
public abstract class HitObjectComposer<TObject> : HitObjectComposer, IPlacementHandler
|
||||
where TObject : HitObject
|
||||
@ -57,6 +63,8 @@ namespace osu.Game.Rulesets.Edit
|
||||
|
||||
private RadioButtonCollection toolboxCollection;
|
||||
|
||||
private FillFlowContainer togglesCollection;
|
||||
|
||||
protected HitObjectComposer(Ruleset ruleset)
|
||||
{
|
||||
Ruleset = ruleset;
|
||||
@ -69,7 +77,7 @@ namespace osu.Game.Rulesets.Edit
|
||||
|
||||
try
|
||||
{
|
||||
drawableRulesetWrapper = new DrawableEditRulesetWrapper<TObject>(CreateDrawableRuleset(Ruleset, EditorBeatmap.PlayableBeatmap))
|
||||
drawableRulesetWrapper = new DrawableEditRulesetWrapper<TObject>(CreateDrawableRuleset(Ruleset, EditorBeatmap.PlayableBeatmap, new[] { Ruleset.GetAutoplayMod() }))
|
||||
{
|
||||
Clock = EditorClock,
|
||||
ProcessCustomClock = false
|
||||
@ -77,59 +85,68 @@ namespace osu.Game.Rulesets.Edit
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Error(e, "Could not load beatmap sucessfully!");
|
||||
Logger.Error(e, "Could not load beatmap successfully!");
|
||||
return;
|
||||
}
|
||||
|
||||
InternalChild = new GridContainer
|
||||
const float toolbar_width = 200;
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Content = new[]
|
||||
new Container
|
||||
{
|
||||
new Drawable[]
|
||||
Name = "Content",
|
||||
Padding = new MarginPadding { Left = toolbar_width },
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new FillFlowContainer
|
||||
// layers below playfield
|
||||
drawableRulesetWrapper.CreatePlayfieldAdjustmentContainer().WithChildren(new Drawable[]
|
||||
{
|
||||
Name = "Sidebar",
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Padding = new MarginPadding { Right = 10 },
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new ToolboxGroup { Child = toolboxCollection = new RadioButtonCollection { RelativeSizeAxes = Axes.X } }
|
||||
}
|
||||
},
|
||||
new Container
|
||||
{
|
||||
Name = "Content",
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Masking = true,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
// layers below playfield
|
||||
drawableRulesetWrapper.CreatePlayfieldAdjustmentContainer().WithChildren(new Drawable[]
|
||||
{
|
||||
LayerBelowRuleset,
|
||||
new PlayfieldBorder { RelativeSizeAxes = Axes.Both }
|
||||
}),
|
||||
drawableRulesetWrapper,
|
||||
// layers above playfield
|
||||
drawableRulesetWrapper.CreatePlayfieldAdjustmentContainer()
|
||||
.WithChild(BlueprintContainer = CreateBlueprintContainer(HitObjects))
|
||||
}
|
||||
}
|
||||
},
|
||||
LayerBelowRuleset,
|
||||
new EditorPlayfieldBorder { RelativeSizeAxes = Axes.Both }
|
||||
}),
|
||||
drawableRulesetWrapper,
|
||||
// layers above playfield
|
||||
drawableRulesetWrapper.CreatePlayfieldAdjustmentContainer()
|
||||
.WithChild(BlueprintContainer = CreateBlueprintContainer(HitObjects))
|
||||
}
|
||||
},
|
||||
ColumnDimensions = new[]
|
||||
new FillFlowContainer
|
||||
{
|
||||
new Dimension(GridSizeMode.Absolute, 200),
|
||||
}
|
||||
Name = "Sidebar",
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Width = toolbar_width,
|
||||
Padding = new MarginPadding { Right = 10 },
|
||||
Spacing = new Vector2(10),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new ToolboxGroup("toolbox (1-9)")
|
||||
{
|
||||
Child = toolboxCollection = new RadioButtonCollection { RelativeSizeAxes = Axes.X }
|
||||
},
|
||||
new ToolboxGroup("toggles (Q~P)")
|
||||
{
|
||||
Child = togglesCollection = new FillFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Direction = FillDirection.Vertical,
|
||||
Spacing = new Vector2(0, 5),
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
toolboxCollection.Items = CompositionTools
|
||||
.Prepend(new SelectTool())
|
||||
.Select(t => new RadioButton(t.Name, () => toolSelected(t)))
|
||||
.Select(t => new RadioButton(t.Name, () => toolSelected(t), t.CreateIcon))
|
||||
.ToList();
|
||||
|
||||
TernaryStates = CreateTernaryButtons().ToArray();
|
||||
togglesCollection.AddRange(TernaryStates.Select(b => new DrawableTernaryButton(b)));
|
||||
|
||||
setSelectTool();
|
||||
|
||||
EditorBeatmap.SelectedHitObjects.CollectionChanged += selectionChanged;
|
||||
@ -157,6 +174,16 @@ namespace osu.Game.Rulesets.Edit
|
||||
/// </remarks>
|
||||
protected abstract IReadOnlyList<HitObjectCompositionTool> CompositionTools { get; }
|
||||
|
||||
/// <summary>
|
||||
/// A collection of states which will be displayed to the user in the toolbox.
|
||||
/// </summary>
|
||||
public TernaryButton[] TernaryStates { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Create all ternary states required to be displayed to the user.
|
||||
/// </summary>
|
||||
protected virtual IEnumerable<TernaryButton> CreateTernaryButtons() => BlueprintContainer.TernaryStates;
|
||||
|
||||
/// <summary>
|
||||
/// Construct a relevant blueprint container. This will manage hitobject selection/placement input handling and display logic.
|
||||
/// </summary>
|
||||
@ -182,9 +209,12 @@ namespace osu.Game.Rulesets.Edit
|
||||
|
||||
protected override bool OnKeyDown(KeyDownEvent e)
|
||||
{
|
||||
if (e.Key >= Key.Number1 && e.Key <= Key.Number9)
|
||||
if (e.ControlPressed || e.AltPressed || e.SuperPressed)
|
||||
return false;
|
||||
|
||||
if (checkLeftToggleFromKey(e.Key, out var leftIndex))
|
||||
{
|
||||
var item = toolboxCollection.Items.ElementAtOrDefault(e.Key - Key.Number1);
|
||||
var item = toolboxCollection.Items.ElementAtOrDefault(leftIndex);
|
||||
|
||||
if (item != null)
|
||||
{
|
||||
@ -193,9 +223,84 @@ namespace osu.Game.Rulesets.Edit
|
||||
}
|
||||
}
|
||||
|
||||
if (checkRightToggleFromKey(e.Key, out var rightIndex))
|
||||
{
|
||||
var item = togglesCollection.ElementAtOrDefault(rightIndex);
|
||||
|
||||
if (item is DrawableTernaryButton button)
|
||||
{
|
||||
button.Button.Toggle();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return base.OnKeyDown(e);
|
||||
}
|
||||
|
||||
private bool checkLeftToggleFromKey(Key key, out int index)
|
||||
{
|
||||
if (key < Key.Number1 || key > Key.Number9)
|
||||
{
|
||||
index = -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
index = key - Key.Number1;
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool checkRightToggleFromKey(Key key, out int index)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case Key.Q:
|
||||
index = 0;
|
||||
break;
|
||||
|
||||
case Key.W:
|
||||
index = 1;
|
||||
break;
|
||||
|
||||
case Key.E:
|
||||
index = 2;
|
||||
break;
|
||||
|
||||
case Key.R:
|
||||
index = 3;
|
||||
break;
|
||||
|
||||
case Key.T:
|
||||
index = 4;
|
||||
break;
|
||||
|
||||
case Key.Y:
|
||||
index = 5;
|
||||
break;
|
||||
|
||||
case Key.U:
|
||||
index = 6;
|
||||
break;
|
||||
|
||||
case Key.I:
|
||||
index = 7;
|
||||
break;
|
||||
|
||||
case Key.O:
|
||||
index = 8;
|
||||
break;
|
||||
|
||||
case Key.P:
|
||||
index = 9;
|
||||
break;
|
||||
|
||||
default:
|
||||
index = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
return index >= 0;
|
||||
}
|
||||
|
||||
private void selectionChanged(object sender, NotifyCollectionChangedEventArgs changedArgs)
|
||||
{
|
||||
if (EditorBeatmap.SelectedHitObjects.Any())
|
||||
|
@ -29,7 +29,7 @@ namespace osu.Game.Rulesets.Edit
|
||||
/// <summary>
|
||||
/// The <see cref="HitObject"/> that is being placed.
|
||||
/// </summary>
|
||||
protected readonly HitObject HitObject;
|
||||
public readonly HitObject HitObject;
|
||||
|
||||
[Resolved(canBeNull: true)]
|
||||
protected EditorClock EditorClock { get; private set; }
|
||||
|
@ -89,9 +89,23 @@ namespace osu.Game.Rulesets.Edit
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void OnDeselected() => Hide();
|
||||
protected virtual void OnDeselected()
|
||||
{
|
||||
// selection blueprints are AlwaysPresent while the related DrawableHitObject is visible
|
||||
// set the body piece's alpha directly to avoid arbitrarily rendering frame buffers etc. of children.
|
||||
foreach (var d in InternalChildren)
|
||||
d.Hide();
|
||||
|
||||
protected virtual void OnSelected() => Show();
|
||||
Hide();
|
||||
}
|
||||
|
||||
protected virtual void OnSelected()
|
||||
{
|
||||
foreach (var d in InternalChildren)
|
||||
d.Show();
|
||||
|
||||
Show();
|
||||
}
|
||||
|
||||
// When not selected, input is only required for the blueprint itself to receive IsHovering
|
||||
protected override bool ShouldBeConsideredForInput(Drawable child) => State == SelectionState.Selected;
|
||||
|
@ -8,9 +8,8 @@ namespace osu.Game.Rulesets.Edit
|
||||
{
|
||||
public class ToolboxGroup : PlayerSettingsGroup
|
||||
{
|
||||
protected override string Title => "toolbox";
|
||||
|
||||
public ToolboxGroup()
|
||||
public ToolboxGroup(string title)
|
||||
: base(title)
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
Width = 1;
|
||||
|
@ -1,6 +1,8 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Graphics;
|
||||
|
||||
namespace osu.Game.Rulesets.Edit.Tools
|
||||
{
|
||||
public abstract class HitObjectCompositionTool
|
||||
@ -14,6 +16,8 @@ namespace osu.Game.Rulesets.Edit.Tools
|
||||
|
||||
public abstract PlacementBlueprint CreatePlacementBlueprint();
|
||||
|
||||
public virtual Drawable CreateIcon() => null;
|
||||
|
||||
public override string ToString() => Name;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,9 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
|
||||
namespace osu.Game.Rulesets.Edit.Tools
|
||||
{
|
||||
public class SelectTool : HitObjectCompositionTool
|
||||
@ -10,6 +13,8 @@ namespace osu.Game.Rulesets.Edit.Tools
|
||||
{
|
||||
}
|
||||
|
||||
public override Drawable CreateIcon() => new SpriteIcon { Icon = FontAwesome.Solid.MousePointer };
|
||||
|
||||
public override PlacementBlueprint CreatePlacementBlueprint() => null;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user