mirror of
https://github.com/ppy/osu.git
synced 2024-11-15 17:57:29 +08:00
Make "double ternary button" specific to samples
We can generalise *when* there is the need to generalise. So far the generalisation only looked like *obfuscation*.
This commit is contained in:
parent
55e9bb6a5d
commit
32821be046
@ -270,7 +270,7 @@ namespace osu.Game.Rulesets.Edit
|
||||
TernaryStates = CreateTernaryButtons().ToArray();
|
||||
togglesCollection.AddRange(TernaryStates.Select(b => new DrawableTernaryButton(b)));
|
||||
|
||||
sampleBankTogglesCollection.AddRange(BlueprintContainer.SampleBankTernaryStates.Zip(BlueprintContainer.SampleAdditionBankTernaryStates).Select(b => new DoubleDrawableTernaryButton(b.First, b.Second)));
|
||||
sampleBankTogglesCollection.AddRange(BlueprintContainer.SampleBankTernaryStates.Zip(BlueprintContainer.SampleAdditionBankTernaryStates).Select(b => new SampleBankTernaryButton(b.First, b.Second)));
|
||||
|
||||
setSelectTool();
|
||||
|
||||
@ -422,40 +422,28 @@ namespace osu.Game.Rulesets.Edit
|
||||
{
|
||||
if (e.ShiftPressed || e.AltPressed)
|
||||
{
|
||||
if (e.ShiftPressed)
|
||||
attemptToggle(rightIndex, sampleBankTogglesCollection);
|
||||
if (sampleBankTogglesCollection.ElementAtOrDefault(rightIndex) is SampleBankTernaryButton sampleBankTernaryButton)
|
||||
{
|
||||
if (e.ShiftPressed)
|
||||
sampleBankTernaryButton.NormalButton.Toggle();
|
||||
|
||||
if (e.AltPressed)
|
||||
attemptToggle(rightIndex, sampleBankTogglesCollection, true);
|
||||
if (e.AltPressed)
|
||||
sampleBankTernaryButton.AdditionsButton.Toggle();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
attemptToggle(rightIndex, togglesCollection);
|
||||
}
|
||||
|
||||
return handled || base.OnKeyDown(e);
|
||||
|
||||
void attemptToggle(int index, FillFlowContainer collection, bool second = false)
|
||||
{
|
||||
var item = collection.ElementAtOrDefault(index);
|
||||
|
||||
switch (item)
|
||||
{
|
||||
case DrawableTernaryButton button:
|
||||
button.Button.Toggle();
|
||||
handled = true;
|
||||
break;
|
||||
|
||||
case DoubleDrawableTernaryButton doubleButton:
|
||||
if (togglesCollection.ElementAtOrDefault(rightIndex) is DrawableTernaryButton button)
|
||||
{
|
||||
if (second)
|
||||
doubleButton.Button2.Toggle();
|
||||
else
|
||||
doubleButton.Button1.Toggle();
|
||||
handled = true;
|
||||
break;
|
||||
button.Button.Toggle();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return base.OnKeyDown(e);
|
||||
}
|
||||
|
||||
private bool checkLeftToggleFromKey(Key key, out int index)
|
||||
|
@ -9,15 +9,15 @@ using osu.Game.Rulesets.Edit;
|
||||
|
||||
namespace osu.Game.Screens.Edit.Components.TernaryButtons
|
||||
{
|
||||
public partial class DoubleDrawableTernaryButton : CompositeDrawable
|
||||
public partial class SampleBankTernaryButton : CompositeDrawable
|
||||
{
|
||||
public readonly TernaryButton Button1;
|
||||
public readonly TernaryButton Button2;
|
||||
public readonly TernaryButton NormalButton;
|
||||
public readonly TernaryButton AdditionsButton;
|
||||
|
||||
public DoubleDrawableTernaryButton(TernaryButton button1, TernaryButton button2)
|
||||
public SampleBankTernaryButton(TernaryButton normalButton, TernaryButton additionsButton)
|
||||
{
|
||||
Button1 = button1;
|
||||
Button2 = button2;
|
||||
NormalButton = normalButton;
|
||||
AdditionsButton = additionsButton;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
@ -36,7 +36,7 @@ namespace osu.Game.Screens.Edit.Components.TernaryButtons
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Width = 0.5f,
|
||||
Padding = new MarginPadding { Right = 1 },
|
||||
Child = new InlineDrawableTernaryButton(Button1),
|
||||
Child = new InlineDrawableTernaryButton(NormalButton),
|
||||
},
|
||||
new Container
|
||||
{
|
||||
@ -46,33 +46,33 @@ namespace osu.Game.Screens.Edit.Components.TernaryButtons
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Width = 0.5f,
|
||||
Padding = new MarginPadding { Left = 1 },
|
||||
Child = new InlineDrawableTernaryButton(Button2),
|
||||
Child = new InlineDrawableTernaryButton(AdditionsButton),
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public partial class InlineDrawableTernaryButton : DrawableTernaryButton
|
||||
{
|
||||
public InlineDrawableTernaryButton(TernaryButton button)
|
||||
: base(button)
|
||||
private partial class InlineDrawableTernaryButton : DrawableTernaryButton
|
||||
{
|
||||
public InlineDrawableTernaryButton(TernaryButton button)
|
||||
: base(button)
|
||||
{
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
Content.Masking = false;
|
||||
Content.CornerRadius = 0;
|
||||
Icon.X = 4.5f;
|
||||
}
|
||||
|
||||
protected override SpriteText CreateText() => new ExpandableSpriteText
|
||||
{
|
||||
Depth = -1,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Anchor = Anchor.CentreLeft,
|
||||
X = 31f
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
Content.Masking = false;
|
||||
Content.CornerRadius = 0;
|
||||
Icon.X = 4.5f;
|
||||
}
|
||||
|
||||
protected override SpriteText CreateText() => new ExpandableSpriteText
|
||||
{
|
||||
Depth = -1,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Anchor = Anchor.CentreLeft,
|
||||
X = 31f
|
||||
};
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user