1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 05:22:54 +08:00

Add new combo toggle to main composer interface

This commit is contained in:
Dean Herbert 2020-09-25 14:10:30 +09:00
parent bca774a0d4
commit e009264f10
4 changed files with 53 additions and 10 deletions

View File

@ -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; }

View File

@ -41,7 +41,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
private EditorClock editorClock { get; set; }
[Resolved]
private EditorBeatmap beatmap { get; set; }
protected EditorBeatmap Beatmap { get; private set; }
private readonly BindableList<HitObject> selectedHitObjects = new BindableList<HitObject>();
@ -68,10 +68,10 @@ namespace osu.Game.Screens.Edit.Compose.Components
DragBox.CreateProxy().With(p => p.Depth = float.MinValue)
});
foreach (var obj in beatmap.HitObjects)
foreach (var obj in Beatmap.HitObjects)
AddBlueprintFor(obj);
selectedHitObjects.BindTo(beatmap.SelectedHitObjects);
selectedHitObjects.BindTo(Beatmap.SelectedHitObjects);
selectedHitObjects.CollectionChanged += (selectedObjects, args) =>
{
switch (args.Action)
@ -94,8 +94,8 @@ namespace osu.Game.Screens.Edit.Compose.Components
{
base.LoadComplete();
beatmap.HitObjectAdded += AddBlueprintFor;
beatmap.HitObjectRemoved += removeBlueprintFor;
Beatmap.HitObjectAdded += AddBlueprintFor;
Beatmap.HitObjectRemoved += removeBlueprintFor;
}
protected virtual Container<SelectionBlueprint> CreateSelectionBlueprintContainer() =>
@ -271,7 +271,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
blueprint.Selected += onBlueprintSelected;
blueprint.Deselected += onBlueprintDeselected;
if (beatmap.SelectedHitObjects.Contains(hitObject))
if (Beatmap.SelectedHitObjects.Contains(hitObject))
blueprint.Select();
SelectionBlueprints.Add(blueprint);
@ -460,10 +460,10 @@ namespace osu.Game.Screens.Edit.Compose.Components
{
base.Dispose(isDisposing);
if (beatmap != null)
if (Beatmap != null)
{
beatmap.HitObjectAdded -= AddBlueprintFor;
beatmap.HitObjectRemoved -= removeBlueprintFor;
Beatmap.HitObjectAdded -= AddBlueprintFor;
Beatmap.HitObjectRemoved -= removeBlueprintFor;
}
}
}

View File

@ -4,6 +4,7 @@
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Input;
@ -11,6 +12,7 @@ using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Edit.Tools;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Objects.Types;
using osuTK;
namespace osu.Game.Screens.Edit.Compose.Components
@ -54,8 +56,45 @@ namespace osu.Game.Screens.Edit.Compose.Components
base.LoadComplete();
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)
{
foreach (var h in Beatmap.SelectedHitObjects)
{
if (h is IHasComboInformation c)
{
c.NewCombo = combo.NewValue;
Beatmap.UpdateHitObject(h);
}
}
}
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
/// <summary>
@ -86,7 +125,9 @@ namespace osu.Game.Screens.Edit.Compose.Components
removePlacement();
if (currentPlacement != null)
{
updatePlacementPosition();
}
}
protected sealed override SelectionBlueprint CreateBlueprintFor(HitObject hitObject)

View File

@ -35,6 +35,8 @@ namespace osu.Game.Screens.Edit.Compose.Components
public IEnumerable<SelectionBlueprint> SelectedBlueprints => selectedBlueprints;
private readonly List<SelectionBlueprint> selectedBlueprints;
public int SelectedCount => selectedBlueprints.Count;
public IEnumerable<HitObject> SelectedHitObjects => selectedBlueprints.Select(b => b.HitObject);
private Drawable content;