mirror of
https://github.com/ppy/osu.git
synced 2024-11-15 20:27:30 +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();
|
TernaryStates = CreateTernaryButtons().ToArray();
|
||||||
togglesCollection.AddRange(TernaryStates.Select(b => new DrawableTernaryButton(b)));
|
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();
|
setSelectTool();
|
||||||
|
|
||||||
@ -422,40 +422,28 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
{
|
{
|
||||||
if (e.ShiftPressed || e.AltPressed)
|
if (e.ShiftPressed || e.AltPressed)
|
||||||
{
|
{
|
||||||
if (e.ShiftPressed)
|
if (sampleBankTogglesCollection.ElementAtOrDefault(rightIndex) is SampleBankTernaryButton sampleBankTernaryButton)
|
||||||
attemptToggle(rightIndex, sampleBankTogglesCollection);
|
{
|
||||||
|
if (e.ShiftPressed)
|
||||||
|
sampleBankTernaryButton.NormalButton.Toggle();
|
||||||
|
|
||||||
if (e.AltPressed)
|
if (e.AltPressed)
|
||||||
attemptToggle(rightIndex, sampleBankTogglesCollection, true);
|
sampleBankTernaryButton.AdditionsButton.Toggle();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
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:
|
if (togglesCollection.ElementAtOrDefault(rightIndex) is DrawableTernaryButton button)
|
||||||
button.Button.Toggle();
|
|
||||||
handled = true;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case DoubleDrawableTernaryButton doubleButton:
|
|
||||||
{
|
{
|
||||||
if (second)
|
button.Button.Toggle();
|
||||||
doubleButton.Button2.Toggle();
|
return true;
|
||||||
else
|
|
||||||
doubleButton.Button1.Toggle();
|
|
||||||
handled = true;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return base.OnKeyDown(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool checkLeftToggleFromKey(Key key, out int index)
|
private bool checkLeftToggleFromKey(Key key, out int index)
|
||||||
|
@ -9,15 +9,15 @@ using osu.Game.Rulesets.Edit;
|
|||||||
|
|
||||||
namespace osu.Game.Screens.Edit.Components.TernaryButtons
|
namespace osu.Game.Screens.Edit.Components.TernaryButtons
|
||||||
{
|
{
|
||||||
public partial class DoubleDrawableTernaryButton : CompositeDrawable
|
public partial class SampleBankTernaryButton : CompositeDrawable
|
||||||
{
|
{
|
||||||
public readonly TernaryButton Button1;
|
public readonly TernaryButton NormalButton;
|
||||||
public readonly TernaryButton Button2;
|
public readonly TernaryButton AdditionsButton;
|
||||||
|
|
||||||
public DoubleDrawableTernaryButton(TernaryButton button1, TernaryButton button2)
|
public SampleBankTernaryButton(TernaryButton normalButton, TernaryButton additionsButton)
|
||||||
{
|
{
|
||||||
Button1 = button1;
|
NormalButton = normalButton;
|
||||||
Button2 = button2;
|
AdditionsButton = additionsButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
@ -36,7 +36,7 @@ namespace osu.Game.Screens.Edit.Components.TernaryButtons
|
|||||||
AutoSizeAxes = Axes.Y,
|
AutoSizeAxes = Axes.Y,
|
||||||
Width = 0.5f,
|
Width = 0.5f,
|
||||||
Padding = new MarginPadding { Right = 1 },
|
Padding = new MarginPadding { Right = 1 },
|
||||||
Child = new InlineDrawableTernaryButton(Button1),
|
Child = new InlineDrawableTernaryButton(NormalButton),
|
||||||
},
|
},
|
||||||
new Container
|
new Container
|
||||||
{
|
{
|
||||||
@ -46,33 +46,33 @@ namespace osu.Game.Screens.Edit.Components.TernaryButtons
|
|||||||
AutoSizeAxes = Axes.Y,
|
AutoSizeAxes = Axes.Y,
|
||||||
Width = 0.5f,
|
Width = 0.5f,
|
||||||
Padding = new MarginPadding { Left = 1 },
|
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)
|
|
||||||
{
|
{
|
||||||
|
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