mirror of
https://github.com/osukey/osukey.git
synced 2025-05-08 07:07:18 +09:00
Merge branch 'master' into editor-load-audio
This commit is contained in:
commit
204024c76e
@ -41,10 +41,10 @@ namespace osu.Game.Rulesets.Osu.Edit
|
|||||||
|
|
||||||
private readonly BindableBool distanceSnapToggle = new BindableBool(true) { Description = "Distance Snap" };
|
private readonly BindableBool distanceSnapToggle = new BindableBool(true) { Description = "Distance Snap" };
|
||||||
|
|
||||||
protected override IEnumerable<BindableBool> Toggles => new[]
|
protected override IEnumerable<Bindable<bool>> Toggles => base.Toggles.Concat(new[]
|
||||||
{
|
{
|
||||||
distanceSnapToggle
|
distanceSnapToggle
|
||||||
};
|
});
|
||||||
|
|
||||||
private BindableList<HitObject> selectedHitObjects;
|
private BindableList<HitObject> selectedHitObjects;
|
||||||
|
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics.UserInterface;
|
using osu.Framework.Graphics.UserInterface;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Rulesets.Edit;
|
using osu.Game.Rulesets.Edit;
|
||||||
@ -14,75 +15,80 @@ namespace osu.Game.Rulesets.Taiko.Edit
|
|||||||
{
|
{
|
||||||
public class TaikoSelectionHandler : SelectionHandler
|
public class TaikoSelectionHandler : SelectionHandler
|
||||||
{
|
{
|
||||||
|
private readonly Bindable<TernaryState> selectionRimState = new Bindable<TernaryState>();
|
||||||
|
private readonly Bindable<TernaryState> selectionStrongState = new Bindable<TernaryState>();
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
|
{
|
||||||
|
selectionStrongState.ValueChanged += state =>
|
||||||
|
{
|
||||||
|
switch (state.NewValue)
|
||||||
|
{
|
||||||
|
case TernaryState.False:
|
||||||
|
SetStrongState(false);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TernaryState.True:
|
||||||
|
SetStrongState(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
selectionRimState.ValueChanged += state =>
|
||||||
|
{
|
||||||
|
switch (state.NewValue)
|
||||||
|
{
|
||||||
|
case TernaryState.False:
|
||||||
|
SetRimState(false);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TernaryState.True:
|
||||||
|
SetRimState(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetStrongState(bool state)
|
||||||
|
{
|
||||||
|
var hits = SelectedHitObjects.OfType<Hit>();
|
||||||
|
|
||||||
|
ChangeHandler.BeginChange();
|
||||||
|
|
||||||
|
foreach (var h in hits)
|
||||||
|
h.IsStrong = state;
|
||||||
|
|
||||||
|
ChangeHandler.EndChange();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetRimState(bool state)
|
||||||
|
{
|
||||||
|
var hits = SelectedHitObjects.OfType<Hit>();
|
||||||
|
|
||||||
|
ChangeHandler.BeginChange();
|
||||||
|
|
||||||
|
foreach (var h in hits)
|
||||||
|
h.Type = state ? HitType.Rim : HitType.Centre;
|
||||||
|
|
||||||
|
ChangeHandler.EndChange();
|
||||||
|
}
|
||||||
|
|
||||||
protected override IEnumerable<MenuItem> GetContextMenuItemsForSelection(IEnumerable<SelectionBlueprint> selection)
|
protected override IEnumerable<MenuItem> GetContextMenuItemsForSelection(IEnumerable<SelectionBlueprint> selection)
|
||||||
{
|
{
|
||||||
if (selection.All(s => s.HitObject is Hit))
|
if (selection.All(s => s.HitObject is Hit))
|
||||||
{
|
yield return new TernaryStateMenuItem("Rim") { State = { BindTarget = selectionRimState } };
|
||||||
var hits = selection.Select(s => s.HitObject).OfType<Hit>();
|
|
||||||
|
|
||||||
yield return new TernaryStateMenuItem("Rim", action: state =>
|
|
||||||
{
|
|
||||||
ChangeHandler.BeginChange();
|
|
||||||
|
|
||||||
foreach (var h in hits)
|
|
||||||
{
|
|
||||||
switch (state)
|
|
||||||
{
|
|
||||||
case TernaryState.True:
|
|
||||||
h.Type = HitType.Rim;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case TernaryState.False:
|
|
||||||
h.Type = HitType.Centre;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ChangeHandler.EndChange();
|
|
||||||
})
|
|
||||||
{
|
|
||||||
State = { Value = getTernaryState(hits, h => h.Type == HitType.Rim) }
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (selection.All(s => s.HitObject is TaikoHitObject))
|
if (selection.All(s => s.HitObject is TaikoHitObject))
|
||||||
{
|
yield return new TernaryStateMenuItem("Strong") { State = { BindTarget = selectionStrongState } };
|
||||||
var hits = selection.Select(s => s.HitObject).OfType<TaikoHitObject>();
|
|
||||||
|
|
||||||
yield return new TernaryStateMenuItem("Strong", action: state =>
|
|
||||||
{
|
|
||||||
ChangeHandler.BeginChange();
|
|
||||||
|
|
||||||
foreach (var h in hits)
|
|
||||||
{
|
|
||||||
switch (state)
|
|
||||||
{
|
|
||||||
case TernaryState.True:
|
|
||||||
h.IsStrong = true;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case TernaryState.False:
|
|
||||||
h.IsStrong = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
EditorBeatmap?.UpdateHitObject(h);
|
|
||||||
}
|
|
||||||
|
|
||||||
ChangeHandler.EndChange();
|
|
||||||
})
|
|
||||||
{
|
|
||||||
State = { Value = getTernaryState(hits, h => h.IsStrong) }
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private TernaryState getTernaryState<T>(IEnumerable<T> selection, Func<T, bool> func)
|
protected override void UpdateTernaryStates()
|
||||||
{
|
{
|
||||||
if (selection.Any(func))
|
base.UpdateTernaryStates();
|
||||||
return selection.All(func) ? TernaryState.True : TernaryState.Indeterminate;
|
|
||||||
|
|
||||||
return TernaryState.False;
|
selectionRimState.Value = GetStateFromSelection(SelectedHitObjects.OfType<Hit>(), h => h.Type == HitType.Rim);
|
||||||
|
selectionStrongState.Value = GetStateFromSelection(SelectedHitObjects.OfType<TaikoHitObject>(), h => h.IsStrong);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,35 +36,64 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
|||||||
|
|
||||||
private bool pressHandledThisFrame;
|
private bool pressHandledThisFrame;
|
||||||
|
|
||||||
private Bindable<HitType> type;
|
private readonly Bindable<HitType> type;
|
||||||
|
|
||||||
public DrawableHit(Hit hit)
|
public DrawableHit(Hit hit)
|
||||||
: base(hit)
|
: base(hit)
|
||||||
{
|
{
|
||||||
|
type = HitObject.TypeBindable.GetBoundCopy();
|
||||||
FillMode = FillMode.Fit;
|
FillMode = FillMode.Fit;
|
||||||
|
|
||||||
|
updateActionsFromType();
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
type = HitObject.TypeBindable.GetBoundCopy();
|
|
||||||
type.BindValueChanged(_ =>
|
type.BindValueChanged(_ =>
|
||||||
{
|
{
|
||||||
updateType();
|
updateActionsFromType();
|
||||||
|
|
||||||
|
// will overwrite samples, should only be called on change.
|
||||||
|
updateSamplesFromTypeChange();
|
||||||
|
|
||||||
RecreatePieces();
|
RecreatePieces();
|
||||||
});
|
});
|
||||||
|
|
||||||
updateType();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateType()
|
private HitSampleInfo[] getRimSamples() => HitObject.Samples.Where(s => s.Name == HitSampleInfo.HIT_CLAP || s.Name == HitSampleInfo.HIT_WHISTLE).ToArray();
|
||||||
|
|
||||||
|
protected override void LoadSamples()
|
||||||
|
{
|
||||||
|
base.LoadSamples();
|
||||||
|
|
||||||
|
type.Value = getRimSamples().Any() ? HitType.Rim : HitType.Centre;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateSamplesFromTypeChange()
|
||||||
|
{
|
||||||
|
var rimSamples = getRimSamples();
|
||||||
|
|
||||||
|
bool isRimType = HitObject.Type == HitType.Rim;
|
||||||
|
|
||||||
|
if (isRimType != rimSamples.Any())
|
||||||
|
{
|
||||||
|
if (isRimType)
|
||||||
|
HitObject.Samples.Add(new HitSampleInfo { Name = HitSampleInfo.HIT_CLAP });
|
||||||
|
else
|
||||||
|
{
|
||||||
|
foreach (var sample in rimSamples)
|
||||||
|
HitObject.Samples.Remove(sample);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateActionsFromType()
|
||||||
{
|
{
|
||||||
HitActions =
|
HitActions =
|
||||||
HitObject.Type == HitType.Centre
|
HitObject.Type == HitType.Centre
|
||||||
? new[] { TaikoAction.LeftCentre, TaikoAction.RightCentre }
|
? new[] { TaikoAction.LeftCentre, TaikoAction.RightCentre }
|
||||||
: new[] { TaikoAction.LeftRim, TaikoAction.RightRim };
|
: new[] { TaikoAction.LeftRim, TaikoAction.RightRim };
|
||||||
|
|
||||||
RecreatePieces();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override SkinnableDrawable CreateMainPiece() => HitObject.Type == HitType.Centre
|
protected override SkinnableDrawable CreateMainPiece() => HitObject.Type == HitType.Centre
|
||||||
|
@ -1,19 +1,19 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using osu.Framework.Graphics;
|
|
||||||
using osu.Framework.Input.Bindings;
|
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
|
||||||
using osuTK;
|
|
||||||
using System.Linq;
|
|
||||||
using osu.Game.Audio;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Primitives;
|
using osu.Framework.Graphics.Primitives;
|
||||||
|
using osu.Framework.Input.Bindings;
|
||||||
|
using osu.Game.Audio;
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
|
using osuTK;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
||||||
{
|
{
|
||||||
@ -120,7 +120,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
|||||||
protected Vector2 BaseSize;
|
protected Vector2 BaseSize;
|
||||||
protected SkinnableDrawable MainPiece;
|
protected SkinnableDrawable MainPiece;
|
||||||
|
|
||||||
private Bindable<bool> isStrong;
|
private readonly Bindable<bool> isStrong;
|
||||||
|
|
||||||
private readonly Container<DrawableStrongNestedHit> strongHitContainer;
|
private readonly Container<DrawableStrongNestedHit> strongHitContainer;
|
||||||
|
|
||||||
@ -128,6 +128,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
|||||||
: base(hitObject)
|
: base(hitObject)
|
||||||
{
|
{
|
||||||
HitObject = hitObject;
|
HitObject = hitObject;
|
||||||
|
isStrong = HitObject.IsStrongBindable.GetBoundCopy();
|
||||||
|
|
||||||
Anchor = Anchor.CentreLeft;
|
Anchor = Anchor.CentreLeft;
|
||||||
Origin = Anchor.Custom;
|
Origin = Anchor.Custom;
|
||||||
@ -140,8 +141,40 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
isStrong = HitObject.IsStrongBindable.GetBoundCopy();
|
isStrong.BindValueChanged(_ =>
|
||||||
isStrong.BindValueChanged(_ => RecreatePieces(), true);
|
{
|
||||||
|
// will overwrite samples, should only be called on change.
|
||||||
|
updateSamplesFromStrong();
|
||||||
|
|
||||||
|
RecreatePieces();
|
||||||
|
});
|
||||||
|
|
||||||
|
RecreatePieces();
|
||||||
|
}
|
||||||
|
|
||||||
|
private HitSampleInfo[] getStrongSamples() => HitObject.Samples.Where(s => s.Name == HitSampleInfo.HIT_FINISH).ToArray();
|
||||||
|
|
||||||
|
protected override void LoadSamples()
|
||||||
|
{
|
||||||
|
base.LoadSamples();
|
||||||
|
|
||||||
|
isStrong.Value = getStrongSamples().Any();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateSamplesFromStrong()
|
||||||
|
{
|
||||||
|
var strongSamples = getStrongSamples();
|
||||||
|
|
||||||
|
if (isStrong.Value != strongSamples.Any())
|
||||||
|
{
|
||||||
|
if (isStrong.Value)
|
||||||
|
HitObject.Samples.Add(new HitSampleInfo { Name = HitSampleInfo.HIT_FINISH });
|
||||||
|
else
|
||||||
|
{
|
||||||
|
foreach (var sample in strongSamples)
|
||||||
|
HitObject.Samples.Remove(sample);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void RecreatePieces()
|
protected virtual void RecreatePieces()
|
||||||
|
@ -46,6 +46,7 @@ namespace osu.Game.Graphics.UserInterfaceV2
|
|||||||
|
|
||||||
protected virtual OsuTextBox CreateTextBox() => new OsuTextBox
|
protected virtual OsuTextBox CreateTextBox() => new OsuTextBox
|
||||||
{
|
{
|
||||||
|
CommitOnFocusLost = true,
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
|
@ -31,6 +31,11 @@ using osuTK.Input;
|
|||||||
|
|
||||||
namespace osu.Game.Rulesets.Edit
|
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))]
|
[Cached(Type = typeof(IPlacementHandler))]
|
||||||
public abstract class HitObjectComposer<TObject> : HitObjectComposer, IPlacementHandler
|
public abstract class HitObjectComposer<TObject> : HitObjectComposer, IPlacementHandler
|
||||||
where TObject : HitObject
|
where TObject : HitObject
|
||||||
@ -165,7 +170,7 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
/// A collection of toggles which will be displayed to the user.
|
/// A collection of toggles which will be displayed to the user.
|
||||||
/// The display name will be decided by <see cref="Bindable{T}.Description"/>.
|
/// The display name will be decided by <see cref="Bindable{T}.Description"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected virtual IEnumerable<BindableBool> Toggles => Enumerable.Empty<BindableBool>();
|
protected virtual IEnumerable<Bindable<bool>> Toggles => BlueprintContainer.Toggles;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Construct a relevant blueprint container. This will manage hitobject selection/placement input handling and display logic.
|
/// Construct a relevant blueprint container. This will manage hitobject selection/placement input handling and display logic.
|
||||||
@ -192,6 +197,9 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
|
|
||||||
protected override bool OnKeyDown(KeyDownEvent e)
|
protected override bool OnKeyDown(KeyDownEvent e)
|
||||||
{
|
{
|
||||||
|
if (e.ControlPressed || e.AltPressed || e.SuperPressed)
|
||||||
|
return false;
|
||||||
|
|
||||||
if (checkLeftToggleFromKey(e.Key, out var leftIndex))
|
if (checkLeftToggleFromKey(e.Key, out var leftIndex))
|
||||||
{
|
{
|
||||||
var item = toolboxCollection.Items.ElementAtOrDefault(leftIndex);
|
var item = toolboxCollection.Items.ElementAtOrDefault(leftIndex);
|
||||||
|
@ -29,7 +29,7 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The <see cref="HitObject"/> that is being placed.
|
/// The <see cref="HitObject"/> that is being placed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected readonly HitObject HitObject;
|
public readonly HitObject HitObject;
|
||||||
|
|
||||||
[Resolved(canBeNull: true)]
|
[Resolved(canBeNull: true)]
|
||||||
protected EditorClock EditorClock { get; private set; }
|
protected EditorClock EditorClock { get; private set; }
|
||||||
|
@ -157,6 +157,9 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
|||||||
updateState(ArmedState.Idle, true);
|
updateState(ArmedState.Idle, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Invoked by the base <see cref="DrawableHitObject"/> to populate samples, once on initial load and potentially again on any change to the samples collection.
|
||||||
|
/// </summary>
|
||||||
protected virtual void LoadSamples()
|
protected virtual void LoadSamples()
|
||||||
{
|
{
|
||||||
if (Samples != null)
|
if (Samples != null)
|
||||||
|
@ -24,7 +24,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A container which provides a "blueprint" display of hitobjects.
|
/// A container which provides a "blueprint" display of hitobjects.
|
||||||
/// Includes selection and manipulation support via a <see cref="SelectionHandler"/>.
|
/// Includes selection and manipulation support via a <see cref="Components.SelectionHandler"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class BlueprintContainer : CompositeDrawable, IKeyBindingHandler<PlatformAction>
|
public abstract class BlueprintContainer : CompositeDrawable, IKeyBindingHandler<PlatformAction>
|
||||||
{
|
{
|
||||||
@ -32,7 +32,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
|
|
||||||
public Container<SelectionBlueprint> SelectionBlueprints { get; private set; }
|
public Container<SelectionBlueprint> SelectionBlueprints { get; private set; }
|
||||||
|
|
||||||
private SelectionHandler selectionHandler;
|
protected SelectionHandler SelectionHandler { get; private set; }
|
||||||
|
|
||||||
[Resolved(CanBeNull = true)]
|
[Resolved(CanBeNull = true)]
|
||||||
private IEditorChangeHandler changeHandler { get; set; }
|
private IEditorChangeHandler changeHandler { get; set; }
|
||||||
@ -41,7 +41,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
private EditorClock editorClock { get; set; }
|
private EditorClock editorClock { get; set; }
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private EditorBeatmap beatmap { get; set; }
|
protected EditorBeatmap Beatmap { get; private set; }
|
||||||
|
|
||||||
private readonly BindableList<HitObject> selectedHitObjects = new BindableList<HitObject>();
|
private readonly BindableList<HitObject> selectedHitObjects = new BindableList<HitObject>();
|
||||||
|
|
||||||
@ -56,22 +56,22 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
selectionHandler = CreateSelectionHandler();
|
SelectionHandler = CreateSelectionHandler();
|
||||||
selectionHandler.DeselectAll = deselectAll;
|
SelectionHandler.DeselectAll = deselectAll;
|
||||||
|
|
||||||
AddRangeInternal(new[]
|
AddRangeInternal(new[]
|
||||||
{
|
{
|
||||||
DragBox = CreateDragBox(selectBlueprintsFromDragRectangle),
|
DragBox = CreateDragBox(selectBlueprintsFromDragRectangle),
|
||||||
selectionHandler,
|
SelectionHandler,
|
||||||
SelectionBlueprints = CreateSelectionBlueprintContainer(),
|
SelectionBlueprints = CreateSelectionBlueprintContainer(),
|
||||||
selectionHandler.CreateProxy(),
|
SelectionHandler.CreateProxy(),
|
||||||
DragBox.CreateProxy().With(p => p.Depth = float.MinValue)
|
DragBox.CreateProxy().With(p => p.Depth = float.MinValue)
|
||||||
});
|
});
|
||||||
|
|
||||||
foreach (var obj in beatmap.HitObjects)
|
foreach (var obj in Beatmap.HitObjects)
|
||||||
AddBlueprintFor(obj);
|
AddBlueprintFor(obj);
|
||||||
|
|
||||||
selectedHitObjects.BindTo(beatmap.SelectedHitObjects);
|
selectedHitObjects.BindTo(Beatmap.SelectedHitObjects);
|
||||||
selectedHitObjects.CollectionChanged += (selectedObjects, args) =>
|
selectedHitObjects.CollectionChanged += (selectedObjects, args) =>
|
||||||
{
|
{
|
||||||
switch (args.Action)
|
switch (args.Action)
|
||||||
@ -94,15 +94,15 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
beatmap.HitObjectAdded += AddBlueprintFor;
|
Beatmap.HitObjectAdded += AddBlueprintFor;
|
||||||
beatmap.HitObjectRemoved += removeBlueprintFor;
|
Beatmap.HitObjectRemoved += removeBlueprintFor;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual Container<SelectionBlueprint> CreateSelectionBlueprintContainer() =>
|
protected virtual Container<SelectionBlueprint> CreateSelectionBlueprintContainer() =>
|
||||||
new Container<SelectionBlueprint> { RelativeSizeAxes = Axes.Both };
|
new Container<SelectionBlueprint> { RelativeSizeAxes = Axes.Both };
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a <see cref="SelectionHandler"/> which outlines <see cref="DrawableHitObject"/>s and handles movement of selections.
|
/// Creates a <see cref="Components.SelectionHandler"/> which outlines <see cref="DrawableHitObject"/>s and handles movement of selections.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected virtual SelectionHandler CreateSelectionHandler() => new SelectionHandler();
|
protected virtual SelectionHandler CreateSelectionHandler() => new SelectionHandler();
|
||||||
|
|
||||||
@ -130,7 +130,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// store for double-click handling
|
// store for double-click handling
|
||||||
clickedBlueprint = selectionHandler.SelectedBlueprints.FirstOrDefault(b => b.IsHovered);
|
clickedBlueprint = SelectionHandler.SelectedBlueprints.FirstOrDefault(b => b.IsHovered);
|
||||||
|
|
||||||
// Deselection should only occur if no selected blueprints are hovered
|
// Deselection should only occur if no selected blueprints are hovered
|
||||||
// A special case for when a blueprint was selected via this click is added since OnClick() may occur outside the hitobject and should not trigger deselection
|
// A special case for when a blueprint was selected via this click is added since OnClick() may occur outside the hitobject and should not trigger deselection
|
||||||
@ -147,7 +147,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// ensure the blueprint which was hovered for the first click is still the hovered blueprint.
|
// ensure the blueprint which was hovered for the first click is still the hovered blueprint.
|
||||||
if (clickedBlueprint == null || selectionHandler.SelectedBlueprints.FirstOrDefault(b => b.IsHovered) != clickedBlueprint)
|
if (clickedBlueprint == null || SelectionHandler.SelectedBlueprints.FirstOrDefault(b => b.IsHovered) != clickedBlueprint)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
editorClock?.SeekTo(clickedBlueprint.HitObject.StartTime);
|
editorClock?.SeekTo(clickedBlueprint.HitObject.StartTime);
|
||||||
@ -208,7 +208,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
if (DragBox.State == Visibility.Visible)
|
if (DragBox.State == Visibility.Visible)
|
||||||
{
|
{
|
||||||
DragBox.Hide();
|
DragBox.Hide();
|
||||||
selectionHandler.UpdateVisibility();
|
SelectionHandler.UpdateVisibility();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -217,7 +217,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
switch (e.Key)
|
switch (e.Key)
|
||||||
{
|
{
|
||||||
case Key.Escape:
|
case Key.Escape:
|
||||||
if (!selectionHandler.SelectedBlueprints.Any())
|
if (!SelectionHandler.SelectedBlueprints.Any())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
deselectAll();
|
deselectAll();
|
||||||
@ -271,7 +271,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
blueprint.Selected += onBlueprintSelected;
|
blueprint.Selected += onBlueprintSelected;
|
||||||
blueprint.Deselected += onBlueprintDeselected;
|
blueprint.Deselected += onBlueprintDeselected;
|
||||||
|
|
||||||
if (beatmap.SelectedHitObjects.Contains(hitObject))
|
if (Beatmap.SelectedHitObjects.Contains(hitObject))
|
||||||
blueprint.Select();
|
blueprint.Select();
|
||||||
|
|
||||||
SelectionBlueprints.Add(blueprint);
|
SelectionBlueprints.Add(blueprint);
|
||||||
@ -298,14 +298,14 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
bool allowDeselection = e.ControlPressed && e.Button == MouseButton.Left;
|
bool allowDeselection = e.ControlPressed && e.Button == MouseButton.Left;
|
||||||
|
|
||||||
// Todo: This is probably incorrectly disallowing multiple selections on stacked objects
|
// Todo: This is probably incorrectly disallowing multiple selections on stacked objects
|
||||||
if (!allowDeselection && selectionHandler.SelectedBlueprints.Any(s => s.IsHovered))
|
if (!allowDeselection && SelectionHandler.SelectedBlueprints.Any(s => s.IsHovered))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
foreach (SelectionBlueprint blueprint in SelectionBlueprints.AliveChildren)
|
foreach (SelectionBlueprint blueprint in SelectionBlueprints.AliveChildren)
|
||||||
{
|
{
|
||||||
if (blueprint.IsHovered)
|
if (blueprint.IsHovered)
|
||||||
{
|
{
|
||||||
selectionHandler.HandleSelectionRequested(blueprint, e.CurrentState);
|
SelectionHandler.HandleSelectionRequested(blueprint, e.CurrentState);
|
||||||
clickSelectionBegan = true;
|
clickSelectionBegan = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -358,23 +358,23 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
private void selectAll()
|
private void selectAll()
|
||||||
{
|
{
|
||||||
SelectionBlueprints.ToList().ForEach(m => m.Select());
|
SelectionBlueprints.ToList().ForEach(m => m.Select());
|
||||||
selectionHandler.UpdateVisibility();
|
SelectionHandler.UpdateVisibility();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Deselects all selected <see cref="SelectionBlueprint"/>s.
|
/// Deselects all selected <see cref="SelectionBlueprint"/>s.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void deselectAll() => selectionHandler.SelectedBlueprints.ToList().ForEach(m => m.Deselect());
|
private void deselectAll() => SelectionHandler.SelectedBlueprints.ToList().ForEach(m => m.Deselect());
|
||||||
|
|
||||||
private void onBlueprintSelected(SelectionBlueprint blueprint)
|
private void onBlueprintSelected(SelectionBlueprint blueprint)
|
||||||
{
|
{
|
||||||
selectionHandler.HandleSelected(blueprint);
|
SelectionHandler.HandleSelected(blueprint);
|
||||||
SelectionBlueprints.ChangeChildDepth(blueprint, 1);
|
SelectionBlueprints.ChangeChildDepth(blueprint, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onBlueprintDeselected(SelectionBlueprint blueprint)
|
private void onBlueprintDeselected(SelectionBlueprint blueprint)
|
||||||
{
|
{
|
||||||
selectionHandler.HandleDeselected(blueprint);
|
SelectionHandler.HandleDeselected(blueprint);
|
||||||
SelectionBlueprints.ChangeChildDepth(blueprint, 0);
|
SelectionBlueprints.ChangeChildDepth(blueprint, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -391,16 +391,16 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void prepareSelectionMovement()
|
private void prepareSelectionMovement()
|
||||||
{
|
{
|
||||||
if (!selectionHandler.SelectedBlueprints.Any())
|
if (!SelectionHandler.SelectedBlueprints.Any())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Any selected blueprint that is hovered can begin the movement of the group, however only the earliest hitobject is used for movement
|
// Any selected blueprint that is hovered can begin the movement of the group, however only the earliest hitobject is used for movement
|
||||||
// A special case is added for when a click selection occurred before the drag
|
// A special case is added for when a click selection occurred before the drag
|
||||||
if (!clickSelectionBegan && !selectionHandler.SelectedBlueprints.Any(b => b.IsHovered))
|
if (!clickSelectionBegan && !SelectionHandler.SelectedBlueprints.Any(b => b.IsHovered))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Movement is tracked from the blueprint of the earliest hitobject, since it only makes sense to distance snap from that hitobject
|
// Movement is tracked from the blueprint of the earliest hitobject, since it only makes sense to distance snap from that hitobject
|
||||||
movementBlueprint = selectionHandler.SelectedBlueprints.OrderBy(b => b.HitObject.StartTime).First();
|
movementBlueprint = SelectionHandler.SelectedBlueprints.OrderBy(b => b.HitObject.StartTime).First();
|
||||||
movementBlueprintOriginalPosition = movementBlueprint.ScreenSpaceSelectionPoint; // todo: unsure if correct
|
movementBlueprintOriginalPosition = movementBlueprint.ScreenSpaceSelectionPoint; // todo: unsure if correct
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -425,14 +425,14 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
var result = snapProvider.SnapScreenSpacePositionToValidTime(movePosition);
|
var result = snapProvider.SnapScreenSpacePositionToValidTime(movePosition);
|
||||||
|
|
||||||
// Move the hitobjects.
|
// Move the hitobjects.
|
||||||
if (!selectionHandler.HandleMovement(new MoveSelectionEvent(movementBlueprint, result.ScreenSpacePosition)))
|
if (!SelectionHandler.HandleMovement(new MoveSelectionEvent(movementBlueprint, result.ScreenSpacePosition)))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (result.Time.HasValue)
|
if (result.Time.HasValue)
|
||||||
{
|
{
|
||||||
// Apply the start time at the newly snapped-to position
|
// Apply the start time at the newly snapped-to position
|
||||||
double offset = result.Time.Value - draggedObject.StartTime;
|
double offset = result.Time.Value - draggedObject.StartTime;
|
||||||
foreach (HitObject obj in selectionHandler.SelectedHitObjects)
|
foreach (HitObject obj in SelectionHandler.SelectedHitObjects)
|
||||||
obj.StartTime += offset;
|
obj.StartTime += offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -460,10 +460,10 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
{
|
{
|
||||||
base.Dispose(isDisposing);
|
base.Dispose(isDisposing);
|
||||||
|
|
||||||
if (beatmap != null)
|
if (Beatmap != null)
|
||||||
{
|
{
|
||||||
beatmap.HitObjectAdded -= AddBlueprintFor;
|
Beatmap.HitObjectAdded -= AddBlueprintFor;
|
||||||
beatmap.HitObjectRemoved -= removeBlueprintFor;
|
Beatmap.HitObjectRemoved -= removeBlueprintFor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Input;
|
using osu.Framework.Input;
|
||||||
@ -11,6 +12,7 @@ using osu.Game.Rulesets.Edit;
|
|||||||
using osu.Game.Rulesets.Edit.Tools;
|
using osu.Game.Rulesets.Edit.Tools;
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
|
using osu.Game.Rulesets.Objects.Types;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Edit.Compose.Components
|
namespace osu.Game.Screens.Edit.Compose.Components
|
||||||
@ -54,8 +56,38 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
inputManager = GetContainingInputManager();
|
inputManager = GetContainingInputManager();
|
||||||
|
|
||||||
|
Beatmap.SelectedHitObjects.CollectionChanged += (_, __) => updateTogglesFromSelection();
|
||||||
|
|
||||||
|
// the updated object may be in the selection
|
||||||
|
Beatmap.HitObjectUpdated += _ => updateTogglesFromSelection();
|
||||||
|
|
||||||
|
NewCombo.ValueChanged += combo =>
|
||||||
|
{
|
||||||
|
if (Beatmap.SelectedHitObjects.Count > 0)
|
||||||
|
{
|
||||||
|
SelectionHandler.SetNewCombo(combo.NewValue);
|
||||||
|
}
|
||||||
|
else if (currentPlacement != null)
|
||||||
|
{
|
||||||
|
// update placement object from toggle
|
||||||
|
if (currentPlacement.HitObject is IHasComboInformation c)
|
||||||
|
c.NewCombo = combo.NewValue;
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateTogglesFromSelection() =>
|
||||||
|
NewCombo.Value = Beatmap.SelectedHitObjects.OfType<IHasComboInformation>().All(c => c.NewCombo);
|
||||||
|
|
||||||
|
public readonly Bindable<bool> NewCombo = new Bindable<bool> { Description = "New Combo" };
|
||||||
|
|
||||||
|
public virtual IEnumerable<Bindable<bool>> Toggles => new[]
|
||||||
|
{
|
||||||
|
//TODO: this should only be enabled (visible?) for rulesets that provide combo-supporting HitObjects.
|
||||||
|
NewCombo
|
||||||
|
};
|
||||||
|
|
||||||
#region Placement
|
#region Placement
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -86,7 +118,9 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
removePlacement();
|
removePlacement();
|
||||||
|
|
||||||
if (currentPlacement != null)
|
if (currentPlacement != null)
|
||||||
|
{
|
||||||
updatePlacementPosition();
|
updatePlacementPosition();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected sealed override SelectionBlueprint CreateBlueprintFor(HitObject hitObject)
|
protected sealed override SelectionBlueprint CreateBlueprintFor(HitObject hitObject)
|
||||||
|
@ -4,7 +4,9 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Humanizer;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Cursor;
|
using osu.Framework.Graphics.Cursor;
|
||||||
@ -35,6 +37,8 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
public IEnumerable<SelectionBlueprint> SelectedBlueprints => selectedBlueprints;
|
public IEnumerable<SelectionBlueprint> SelectedBlueprints => selectedBlueprints;
|
||||||
private readonly List<SelectionBlueprint> selectedBlueprints;
|
private readonly List<SelectionBlueprint> selectedBlueprints;
|
||||||
|
|
||||||
|
public int SelectedCount => selectedBlueprints.Count;
|
||||||
|
|
||||||
public IEnumerable<HitObject> SelectedHitObjects => selectedBlueprints.Select(b => b.HitObject);
|
public IEnumerable<HitObject> SelectedHitObjects => selectedBlueprints.Select(b => b.HitObject);
|
||||||
|
|
||||||
private Drawable content;
|
private Drawable content;
|
||||||
@ -59,6 +63,8 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours)
|
private void load(OsuColour colours)
|
||||||
{
|
{
|
||||||
|
createStateBindables();
|
||||||
|
|
||||||
InternalChild = content = new Container
|
InternalChild = content = new Container
|
||||||
{
|
{
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
@ -283,7 +289,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
var comboInfo = h as IHasComboInformation;
|
var comboInfo = h as IHasComboInformation;
|
||||||
|
|
||||||
if (comboInfo == null)
|
if (comboInfo == null)
|
||||||
throw new InvalidOperationException($"Tried to change combo state of a {h.GetType()}, which doesn't implement {nameof(IHasComboInformation)}");
|
continue;
|
||||||
|
|
||||||
comboInfo.NewCombo = state;
|
comboInfo.NewCombo = state;
|
||||||
EditorBeatmap?.UpdateHitObject(h);
|
EditorBeatmap?.UpdateHitObject(h);
|
||||||
@ -308,6 +314,90 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Selection State
|
||||||
|
|
||||||
|
private readonly Bindable<TernaryState> selectionNewComboState = new Bindable<TernaryState>();
|
||||||
|
|
||||||
|
private readonly Dictionary<string, Bindable<TernaryState>> selectionSampleStates = new Dictionary<string, Bindable<TernaryState>>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set up ternary state bindables and bind them to selection/hitobject changes (in both directions)
|
||||||
|
/// </summary>
|
||||||
|
private void createStateBindables()
|
||||||
|
{
|
||||||
|
// hit samples
|
||||||
|
var sampleTypes = new[] { HitSampleInfo.HIT_WHISTLE, HitSampleInfo.HIT_CLAP, HitSampleInfo.HIT_FINISH };
|
||||||
|
|
||||||
|
foreach (var sampleName in sampleTypes)
|
||||||
|
{
|
||||||
|
var bindable = new Bindable<TernaryState>
|
||||||
|
{
|
||||||
|
Description = sampleName.Replace("hit", string.Empty).Titleize()
|
||||||
|
};
|
||||||
|
|
||||||
|
bindable.ValueChanged += state =>
|
||||||
|
{
|
||||||
|
switch (state.NewValue)
|
||||||
|
{
|
||||||
|
case TernaryState.False:
|
||||||
|
RemoveHitSample(sampleName);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TernaryState.True:
|
||||||
|
AddHitSample(sampleName);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
selectionSampleStates[sampleName] = bindable;
|
||||||
|
}
|
||||||
|
|
||||||
|
// new combo
|
||||||
|
selectionNewComboState.ValueChanged += state =>
|
||||||
|
{
|
||||||
|
switch (state.NewValue)
|
||||||
|
{
|
||||||
|
case TernaryState.False:
|
||||||
|
SetNewCombo(false);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TernaryState.True:
|
||||||
|
SetNewCombo(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// bring in updates from selection changes
|
||||||
|
EditorBeatmap.HitObjectUpdated += _ => UpdateTernaryStates();
|
||||||
|
EditorBeatmap.SelectedHitObjects.CollectionChanged += (sender, args) => UpdateTernaryStates();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Called when context menu ternary states may need to be recalculated (selection changed or hitobject updated).
|
||||||
|
/// </summary>
|
||||||
|
protected virtual void UpdateTernaryStates()
|
||||||
|
{
|
||||||
|
selectionNewComboState.Value = GetStateFromSelection(SelectedHitObjects.OfType<IHasComboInformation>(), h => h.NewCombo);
|
||||||
|
|
||||||
|
foreach (var (sampleName, bindable) in selectionSampleStates)
|
||||||
|
{
|
||||||
|
bindable.Value = GetStateFromSelection(SelectedHitObjects, h => h.Samples.Any(s => s.Name == sampleName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Given a selection target and a function of truth, retrieve the correct ternary state for display.
|
||||||
|
/// </summary>
|
||||||
|
protected TernaryState GetStateFromSelection<T>(IEnumerable<T> selection, Func<T, bool> func)
|
||||||
|
{
|
||||||
|
if (selection.Any(func))
|
||||||
|
return selection.All(func) ? TernaryState.True : TernaryState.Indeterminate;
|
||||||
|
|
||||||
|
return TernaryState.False;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region Context Menu
|
#region Context Menu
|
||||||
|
|
||||||
public MenuItem[] ContextMenuItems
|
public MenuItem[] ContextMenuItems
|
||||||
@ -322,7 +412,9 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
items.AddRange(GetContextMenuItemsForSelection(selectedBlueprints));
|
items.AddRange(GetContextMenuItemsForSelection(selectedBlueprints));
|
||||||
|
|
||||||
if (selectedBlueprints.All(b => b.HitObject is IHasComboInformation))
|
if (selectedBlueprints.All(b => b.HitObject is IHasComboInformation))
|
||||||
items.Add(createNewComboMenuItem());
|
{
|
||||||
|
items.Add(new TernaryStateMenuItem("New combo") { State = { BindTarget = selectionNewComboState } });
|
||||||
|
}
|
||||||
|
|
||||||
if (selectedBlueprints.Count == 1)
|
if (selectedBlueprints.Count == 1)
|
||||||
items.AddRange(selectedBlueprints[0].ContextMenuItems);
|
items.AddRange(selectedBlueprints[0].ContextMenuItems);
|
||||||
@ -331,12 +423,8 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
{
|
{
|
||||||
new OsuMenuItem("Sound")
|
new OsuMenuItem("Sound")
|
||||||
{
|
{
|
||||||
Items = new[]
|
Items = selectionSampleStates.Select(kvp =>
|
||||||
{
|
new TernaryStateMenuItem(kvp.Value.Description) { State = { BindTarget = kvp.Value } }).ToArray()
|
||||||
createHitSampleMenuItem("Whistle", HitSampleInfo.HIT_WHISTLE),
|
|
||||||
createHitSampleMenuItem("Clap", HitSampleInfo.HIT_CLAP),
|
|
||||||
createHitSampleMenuItem("Finish", HitSampleInfo.HIT_FINISH)
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
new OsuMenuItem("Delete", MenuItemType.Destructive, deleteSelected),
|
new OsuMenuItem("Delete", MenuItemType.Destructive, deleteSelected),
|
||||||
});
|
});
|
||||||
@ -353,76 +441,6 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
protected virtual IEnumerable<MenuItem> GetContextMenuItemsForSelection(IEnumerable<SelectionBlueprint> selection)
|
protected virtual IEnumerable<MenuItem> GetContextMenuItemsForSelection(IEnumerable<SelectionBlueprint> selection)
|
||||||
=> Enumerable.Empty<MenuItem>();
|
=> Enumerable.Empty<MenuItem>();
|
||||||
|
|
||||||
private MenuItem createNewComboMenuItem()
|
|
||||||
{
|
|
||||||
return new TernaryStateMenuItem("New combo", MenuItemType.Standard, setNewComboState)
|
|
||||||
{
|
|
||||||
State = { Value = getHitSampleState() }
|
|
||||||
};
|
|
||||||
|
|
||||||
void setNewComboState(TernaryState state)
|
|
||||||
{
|
|
||||||
switch (state)
|
|
||||||
{
|
|
||||||
case TernaryState.False:
|
|
||||||
SetNewCombo(false);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case TernaryState.True:
|
|
||||||
SetNewCombo(true);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TernaryState getHitSampleState()
|
|
||||||
{
|
|
||||||
int countExisting = selectedBlueprints.Select(b => (IHasComboInformation)b.HitObject).Count(h => h.NewCombo);
|
|
||||||
|
|
||||||
if (countExisting == 0)
|
|
||||||
return TernaryState.False;
|
|
||||||
|
|
||||||
if (countExisting < SelectedHitObjects.Count())
|
|
||||||
return TernaryState.Indeterminate;
|
|
||||||
|
|
||||||
return TernaryState.True;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private MenuItem createHitSampleMenuItem(string name, string sampleName)
|
|
||||||
{
|
|
||||||
return new TernaryStateMenuItem(name, MenuItemType.Standard, setHitSampleState)
|
|
||||||
{
|
|
||||||
State = { Value = getHitSampleState() }
|
|
||||||
};
|
|
||||||
|
|
||||||
void setHitSampleState(TernaryState state)
|
|
||||||
{
|
|
||||||
switch (state)
|
|
||||||
{
|
|
||||||
case TernaryState.False:
|
|
||||||
RemoveHitSample(sampleName);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case TernaryState.True:
|
|
||||||
AddHitSample(sampleName);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TernaryState getHitSampleState()
|
|
||||||
{
|
|
||||||
int countExisting = SelectedHitObjects.Count(h => h.Samples.Any(s => s.Name == sampleName));
|
|
||||||
|
|
||||||
if (countExisting == 0)
|
|
||||||
return TernaryState.False;
|
|
||||||
|
|
||||||
if (countExisting < SelectedHitObjects.Count())
|
|
||||||
return TernaryState.Indeterminate;
|
|
||||||
|
|
||||||
return TernaryState.True;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user