mirror of
https://github.com/ppy/osu.git
synced 2025-03-04 06:12:57 +08:00
Add "auto" bank selection during placement
This commit is contained in:
parent
fc22c75464
commit
3a05dffa50
@ -32,6 +32,11 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public PlacementState PlacementActive { get; private set; }
|
public PlacementState PlacementActive { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether the sample bank should be taken from the previous hit object.
|
||||||
|
/// </summary>
|
||||||
|
public bool AutomaticBankAssignment;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The <see cref="HitObject"/> that is being placed.
|
/// The <see cref="HitObject"/> that is being placed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -86,11 +91,6 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
/// <param name="commitStart">Whether this call is committing a value for HitObject.StartTime and continuing with further adjustments.</param>
|
/// <param name="commitStart">Whether this call is committing a value for HitObject.StartTime and continuing with further adjustments.</param>
|
||||||
protected void BeginPlacement(bool commitStart = false)
|
protected void BeginPlacement(bool commitStart = false)
|
||||||
{
|
{
|
||||||
// Take the hitnormal sample of the last hit object
|
|
||||||
var lastHitNormal = getPreviousHitObject()?.Samples?.FirstOrDefault(o => o.Name == HitSampleInfo.HIT_NORMAL);
|
|
||||||
if (lastHitNormal != null)
|
|
||||||
HitObject.Samples[0] = lastHitNormal;
|
|
||||||
|
|
||||||
placementHandler.BeginPlacement(HitObject);
|
placementHandler.BeginPlacement(HitObject);
|
||||||
if (commitStart)
|
if (commitStart)
|
||||||
PlacementActive = PlacementState.Active;
|
PlacementActive = PlacementState.Active;
|
||||||
@ -155,6 +155,14 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
if (HitObject is IHasComboInformation comboInformation)
|
if (HitObject is IHasComboInformation comboInformation)
|
||||||
comboInformation.UpdateComboInformation(getPreviousHitObject() as IHasComboInformation);
|
comboInformation.UpdateComboInformation(getPreviousHitObject() as IHasComboInformation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (AutomaticBankAssignment)
|
||||||
|
{
|
||||||
|
// Take the hitnormal sample of the last hit object
|
||||||
|
var lastHitNormal = getPreviousHitObject()?.Samples?.FirstOrDefault(o => o.Name == HitSampleInfo.HIT_NORMAL);
|
||||||
|
if (lastHitNormal != null)
|
||||||
|
HitObject.Samples[0] = lastHitNormal;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -201,6 +201,8 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
{
|
{
|
||||||
if (CurrentPlacement == null) return;
|
if (CurrentPlacement == null) return;
|
||||||
|
|
||||||
|
if (bankName == EditorSelectionHandler.HIT_BANK_AUTO)
|
||||||
|
CurrentPlacement.AutomaticBankAssignment = state == TernaryState.True;
|
||||||
if (state == TernaryState.True)
|
if (state == TernaryState.True)
|
||||||
CurrentPlacement.HitObject.Samples = CurrentPlacement.HitObject.Samples.Select(s => s.With(newBank: bankName)).ToList();
|
CurrentPlacement.HitObject.Samples = CurrentPlacement.HitObject.Samples.Select(s => s.With(newBank: bankName)).ToList();
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,12 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
{
|
{
|
||||||
public partial class EditorSelectionHandler : SelectionHandler<HitObject>
|
public partial class EditorSelectionHandler : SelectionHandler<HitObject>
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A special bank name that is only used in the editor UI.
|
||||||
|
/// When selected and in placement mode, the bank of the last hit object will always be used.
|
||||||
|
/// </summary>
|
||||||
|
public const string HIT_BANK_AUTO = "auto";
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
protected EditorBeatmap EditorBeatmap { get; private set; }
|
protected EditorBeatmap EditorBeatmap { get; private set; }
|
||||||
|
|
||||||
@ -59,7 +65,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void createStateBindables()
|
private void createStateBindables()
|
||||||
{
|
{
|
||||||
foreach (string bankName in HitSampleInfo.AllBanks)
|
foreach (string bankName in HitSampleInfo.AllBanks.Prepend(HIT_BANK_AUTO))
|
||||||
{
|
{
|
||||||
var bindable = new Bindable<TernaryState>
|
var bindable = new Bindable<TernaryState>
|
||||||
{
|
{
|
||||||
@ -100,6 +106,14 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// Auto should just not apply if there's a selection already made.
|
||||||
|
// Maybe we could make it a disabled button in the future, but right now the editor buttons don't support disabled state.
|
||||||
|
if (bankName == HIT_BANK_AUTO)
|
||||||
|
{
|
||||||
|
bindable.Value = TernaryState.False;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
AddSampleBank(bankName);
|
AddSampleBank(bankName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user