mirror of
https://github.com/ppy/osu.git
synced 2024-11-15 20:37:26 +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();
|
||||
|
||||
@ -421,41 +421,29 @@ namespace osu.Game.Rulesets.Edit
|
||||
if (checkRightToggleFromKey(e.Key, out int rightIndex))
|
||||
{
|
||||
if (e.ShiftPressed || e.AltPressed)
|
||||
{
|
||||
if (sampleBankTogglesCollection.ElementAtOrDefault(rightIndex) is SampleBankTernaryButton sampleBankTernaryButton)
|
||||
{
|
||||
if (e.ShiftPressed)
|
||||
attemptToggle(rightIndex, sampleBankTogglesCollection);
|
||||
sampleBankTernaryButton.NormalButton.Toggle();
|
||||
|
||||
if (e.AltPressed)
|
||||
attemptToggle(rightIndex, sampleBankTogglesCollection, true);
|
||||
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)
|
||||
if (togglesCollection.ElementAtOrDefault(rightIndex) is DrawableTernaryButton button)
|
||||
{
|
||||
case DrawableTernaryButton button:
|
||||
button.Button.Toggle();
|
||||
handled = true;
|
||||
break;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
case DoubleDrawableTernaryButton doubleButton:
|
||||
{
|
||||
if (second)
|
||||
doubleButton.Button2.Toggle();
|
||||
else
|
||||
doubleButton.Button1.Toggle();
|
||||
handled = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
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,13 +46,12 @@ 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
|
||||
private partial class InlineDrawableTernaryButton : DrawableTernaryButton
|
||||
{
|
||||
public InlineDrawableTernaryButton(TernaryButton button)
|
||||
: base(button)
|
||||
@ -76,3 +75,4 @@ namespace osu.Game.Screens.Edit.Components.TernaryButtons
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user