Merge branch 'master' into patch2

This commit is contained in:
Keijia 2020-08-22 18:53:40 +03:00 committed by GitHub
commit 6e19521528
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 51 additions and 33 deletions

View File

@ -8,6 +8,7 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Input.Bindings; using osu.Framework.Input.Bindings;
using osu.Game.Rulesets.Mania.UI;
using osu.Game.Rulesets.UI.Scrolling; using osu.Game.Rulesets.UI.Scrolling;
using osu.Game.Skinning; using osu.Game.Skinning;
using osuTK; using osuTK;
@ -20,9 +21,12 @@ namespace osu.Game.Rulesets.Mania.Skinning
private readonly IBindable<ScrollingDirection> direction = new Bindable<ScrollingDirection>(); private readonly IBindable<ScrollingDirection> direction = new Bindable<ScrollingDirection>();
private readonly bool isLastColumn; private readonly bool isLastColumn;
private Container borderLineContainer;
private Container lightContainer; private Container lightContainer;
private Sprite light; private Sprite light;
private float hitPosition;
public LegacyColumnBackground(bool isLastColumn) public LegacyColumnBackground(bool isLastColumn)
{ {
this.isLastColumn = isLastColumn; this.isLastColumn = isLastColumn;
@ -44,6 +48,9 @@ namespace osu.Game.Rulesets.Mania.Skinning
bool hasRightLine = rightLineWidth > 0 && skin.GetConfig<LegacySkinConfiguration.LegacySetting, decimal>(LegacySkinConfiguration.LegacySetting.Version)?.Value >= 2.4m bool hasRightLine = rightLineWidth > 0 && skin.GetConfig<LegacySkinConfiguration.LegacySetting, decimal>(LegacySkinConfiguration.LegacySetting.Version)?.Value >= 2.4m
|| isLastColumn; || isLastColumn;
hitPosition = GetColumnSkinConfig<float>(skin, LegacyManiaSkinConfigurationLookups.HitPosition)?.Value
?? Stage.HIT_TARGET_POSITION;
float lightPosition = GetColumnSkinConfig<float>(skin, LegacyManiaSkinConfigurationLookups.LightPosition)?.Value float lightPosition = GetColumnSkinConfig<float>(skin, LegacyManiaSkinConfigurationLookups.LightPosition)?.Value
?? 0; ?? 0;
@ -63,23 +70,30 @@ namespace osu.Game.Rulesets.Mania.Skinning
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Colour = backgroundColour Colour = backgroundColour
}, },
new Box borderLineContainer = new Container
{ {
RelativeSizeAxes = Axes.Y, RelativeSizeAxes = Axes.Both,
Width = leftLineWidth, Children = new[]
Scale = new Vector2(0.740f, 1), {
Colour = lineColour, new Box
Alpha = hasLeftLine ? 1 : 0 {
}, RelativeSizeAxes = Axes.Y,
new Box Width = leftLineWidth,
{ Scale = new Vector2(0.740f, 1),
Anchor = Anchor.TopRight, Colour = lineColour,
Origin = Anchor.TopRight, Alpha = hasLeftLine ? 1 : 0
RelativeSizeAxes = Axes.Y, },
Width = rightLineWidth, new Box
Scale = new Vector2(0.740f, 1), {
Colour = lineColour, Anchor = Anchor.TopRight,
Alpha = hasRightLine ? 1 : 0 Origin = Anchor.TopRight,
RelativeSizeAxes = Axes.Y,
Width = rightLineWidth,
Scale = new Vector2(0.740f, 1),
Colour = lineColour,
Alpha = hasRightLine ? 1 : 0
}
}
}, },
lightContainer = new Container lightContainer = new Container
{ {
@ -109,11 +123,15 @@ namespace osu.Game.Rulesets.Mania.Skinning
{ {
lightContainer.Anchor = Anchor.TopCentre; lightContainer.Anchor = Anchor.TopCentre;
lightContainer.Scale = new Vector2(1, -1); lightContainer.Scale = new Vector2(1, -1);
borderLineContainer.Padding = new MarginPadding { Top = hitPosition };
} }
else else
{ {
lightContainer.Anchor = Anchor.BottomCentre; lightContainer.Anchor = Anchor.BottomCentre;
lightContainer.Scale = Vector2.One; lightContainer.Scale = Vector2.One;
borderLineContainer.Padding = new MarginPadding { Bottom = hitPosition };
} }
} }

View File

@ -68,22 +68,22 @@ namespace osu.Game.Tests.Visual.Settings
[Test] [Test]
public void TestClearButtonOnBindings() public void TestClearButtonOnBindings()
{ {
KeyBindingRow backBindingRow = null; KeyBindingRow multiBindingRow = null;
AddStep("click back binding row", () => AddStep("click first row with two bindings", () =>
{ {
backBindingRow = panel.ChildrenOfType<KeyBindingRow>().ElementAt(10); multiBindingRow = panel.ChildrenOfType<KeyBindingRow>().First(row => row.Defaults.Count() > 1);
InputManager.MoveMouseTo(backBindingRow); InputManager.MoveMouseTo(multiBindingRow);
InputManager.Click(MouseButton.Left); InputManager.Click(MouseButton.Left);
}); });
clickClearButton(); clickClearButton();
AddAssert("first binding cleared", () => string.IsNullOrEmpty(backBindingRow.ChildrenOfType<KeyBindingRow.KeyButton>().First().Text.Text)); AddAssert("first binding cleared", () => string.IsNullOrEmpty(multiBindingRow.ChildrenOfType<KeyBindingRow.KeyButton>().First().Text.Text));
AddStep("click second binding", () => AddStep("click second binding", () =>
{ {
var target = backBindingRow.ChildrenOfType<KeyBindingRow.KeyButton>().ElementAt(1); var target = multiBindingRow.ChildrenOfType<KeyBindingRow.KeyButton>().ElementAt(1);
InputManager.MoveMouseTo(target); InputManager.MoveMouseTo(target);
InputManager.Click(MouseButton.Left); InputManager.Click(MouseButton.Left);
@ -91,13 +91,13 @@ namespace osu.Game.Tests.Visual.Settings
clickClearButton(); clickClearButton();
AddAssert("second binding cleared", () => string.IsNullOrEmpty(backBindingRow.ChildrenOfType<KeyBindingRow.KeyButton>().ElementAt(1).Text.Text)); AddAssert("second binding cleared", () => string.IsNullOrEmpty(multiBindingRow.ChildrenOfType<KeyBindingRow.KeyButton>().ElementAt(1).Text.Text));
void clickClearButton() void clickClearButton()
{ {
AddStep("click clear button", () => AddStep("click clear button", () =>
{ {
var clearButton = backBindingRow.ChildrenOfType<KeyBindingRow.ClearButton>().Single(); var clearButton = multiBindingRow.ChildrenOfType<KeyBindingRow.ClearButton>().Single();
InputManager.MoveMouseTo(clearButton); InputManager.MoveMouseTo(clearButton);
InputManager.Click(MouseButton.Left); InputManager.Click(MouseButton.Left);
@ -108,20 +108,20 @@ namespace osu.Game.Tests.Visual.Settings
[Test] [Test]
public void TestClickRowSelectsFirstBinding() public void TestClickRowSelectsFirstBinding()
{ {
KeyBindingRow backBindingRow = null; KeyBindingRow multiBindingRow = null;
AddStep("click back binding row", () => AddStep("click first row with two bindings", () =>
{ {
backBindingRow = panel.ChildrenOfType<KeyBindingRow>().ElementAt(10); multiBindingRow = panel.ChildrenOfType<KeyBindingRow>().First(row => row.Defaults.Count() > 1);
InputManager.MoveMouseTo(backBindingRow); InputManager.MoveMouseTo(multiBindingRow);
InputManager.Click(MouseButton.Left); InputManager.Click(MouseButton.Left);
}); });
AddAssert("first binding selected", () => backBindingRow.ChildrenOfType<KeyBindingRow.KeyButton>().First().IsBinding); AddAssert("first binding selected", () => multiBindingRow.ChildrenOfType<KeyBindingRow.KeyButton>().First().IsBinding);
AddStep("click second binding", () => AddStep("click second binding", () =>
{ {
var target = backBindingRow.ChildrenOfType<KeyBindingRow.KeyButton>().ElementAt(1); var target = multiBindingRow.ChildrenOfType<KeyBindingRow.KeyButton>().ElementAt(1);
InputManager.MoveMouseTo(target); InputManager.MoveMouseTo(target);
InputManager.Click(MouseButton.Left); InputManager.Click(MouseButton.Left);
@ -129,12 +129,12 @@ namespace osu.Game.Tests.Visual.Settings
AddStep("click back binding row", () => AddStep("click back binding row", () =>
{ {
backBindingRow = panel.ChildrenOfType<KeyBindingRow>().ElementAt(10); multiBindingRow = panel.ChildrenOfType<KeyBindingRow>().ElementAt(10);
InputManager.MoveMouseTo(backBindingRow); InputManager.MoveMouseTo(multiBindingRow);
InputManager.Click(MouseButton.Left); InputManager.Click(MouseButton.Left);
}); });
AddAssert("first binding selected", () => backBindingRow.ChildrenOfType<KeyBindingRow.KeyButton>().First().IsBinding); AddAssert("first binding selected", () => multiBindingRow.ChildrenOfType<KeyBindingRow.KeyButton>().First().IsBinding);
} }
} }
} }