mirror of
https://github.com/ppy/osu.git
synced 2025-01-06 07:42:55 +08:00
Add the ability to toggle new combo state from composer context menu
This commit is contained in:
parent
7efaa37447
commit
a1ec167982
@ -81,7 +81,7 @@ namespace osu.Game.Tests.Gameplay
|
|||||||
|
|
||||||
private class TestHitObjectWithCombo : ConvertHitObject, IHasComboInformation
|
private class TestHitObjectWithCombo : ConvertHitObject, IHasComboInformation
|
||||||
{
|
{
|
||||||
public bool NewCombo { get; } = false;
|
public bool NewCombo { get; set; } = false;
|
||||||
public int ComboOffset { get; } = 0;
|
public int ComboOffset { get; } = 0;
|
||||||
|
|
||||||
public Bindable<int> IndexInCurrentComboBindable { get; } = new Bindable<int>();
|
public Bindable<int> IndexInCurrentComboBindable { get; } = new Bindable<int>();
|
||||||
|
@ -24,6 +24,11 @@ namespace osu.Game.Rulesets.Objects.Types
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
int ComboIndex { get; set; }
|
int ComboIndex { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether the HitObject starts a new combo.
|
||||||
|
/// </summary>
|
||||||
|
new bool NewCombo { get; set; }
|
||||||
|
|
||||||
Bindable<bool> LastInComboBindable { get; }
|
Bindable<bool> LastInComboBindable { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -20,6 +20,7 @@ using osu.Game.Graphics.UserInterface;
|
|||||||
using osu.Game.Rulesets.Edit;
|
using osu.Game.Rulesets.Edit;
|
||||||
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
|
||||||
@ -268,6 +269,24 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
changeHandler?.EndChange();
|
changeHandler?.EndChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetNewCombo(bool state)
|
||||||
|
{
|
||||||
|
changeHandler?.BeginChange();
|
||||||
|
|
||||||
|
foreach (var h in SelectedHitObjects)
|
||||||
|
{
|
||||||
|
var comboInfo = h as IHasComboInformation;
|
||||||
|
|
||||||
|
if (comboInfo == null)
|
||||||
|
throw new InvalidOperationException($"Tried to change combo state of a {h.GetType()}, which doesn't implement {nameof(IHasComboInformation)}");
|
||||||
|
|
||||||
|
comboInfo.NewCombo = state;
|
||||||
|
EditorBeatmap?.UpdateHitObject(h);
|
||||||
|
}
|
||||||
|
|
||||||
|
changeHandler?.EndChange();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Removes a hit sample from all selected <see cref="HitObject"/>s.
|
/// Removes a hit sample from all selected <see cref="HitObject"/>s.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -297,6 +316,9 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
|
|
||||||
items.AddRange(GetContextMenuItemsForSelection(selectedBlueprints));
|
items.AddRange(GetContextMenuItemsForSelection(selectedBlueprints));
|
||||||
|
|
||||||
|
if (selectedBlueprints.All(b => b.HitObject is IHasComboInformation))
|
||||||
|
items.Add(createNewComboMenuItem());
|
||||||
|
|
||||||
if (selectedBlueprints.Count == 1)
|
if (selectedBlueprints.Count == 1)
|
||||||
items.AddRange(selectedBlueprints[0].ContextMenuItems);
|
items.AddRange(selectedBlueprints[0].ContextMenuItems);
|
||||||
|
|
||||||
@ -326,6 +348,41 @@ 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 => b.HitObject as IHasComboInformation).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)
|
private MenuItem createHitSampleMenuItem(string name, string sampleName)
|
||||||
{
|
{
|
||||||
return new TernaryStateMenuItem(name, MenuItemType.Standard, setHitSampleState)
|
return new TernaryStateMenuItem(name, MenuItemType.Standard, setHitSampleState)
|
||||||
|
Loading…
Reference in New Issue
Block a user