mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-22 04:53:29 +01:00
improve gamepad priority calculation
This commit is contained in:
parent
d5f3453c71
commit
8fa94f1186
2 changed files with 8 additions and 6 deletions
|
@ -387,7 +387,7 @@ namespace MLEM.Ui {
|
||||||
continue;
|
continue;
|
||||||
var distSq = child.Area.DistanceSquared(this.SelectedElement.Area);
|
var distSq = child.Area.DistanceSquared(this.SelectedElement.Area);
|
||||||
// both distance and angle play a role in a destination button's priority, so we combine them
|
// both distance and angle play a role in a destination button's priority, so we combine them
|
||||||
var priority = distSq * (angle / MathHelper.TwoPi + 1);
|
var priority = (distSq + 1) * (angle / MathHelper.PiOver2 + 1);
|
||||||
if (closest == null || priority < closestPriority) {
|
if (closest == null || priority < closestPriority) {
|
||||||
closest = child;
|
closest = child;
|
||||||
closestPriority = priority;
|
closestPriority = priority;
|
||||||
|
|
|
@ -305,11 +305,13 @@ namespace Sandbox {
|
||||||
newPanel.AddChild(new Button(Anchor.TopLeft, new Vector2(100, 20), "Text", "Tooltip text"));
|
newPanel.AddChild(new Button(Anchor.TopLeft, new Vector2(100, 20), "Text", "Tooltip text"));
|
||||||
this.UiSystem.Add("Panel", newPanel);
|
this.UiSystem.Add("Panel", newPanel);
|
||||||
|
|
||||||
var keybind = new Keybind(MouseButton.Left, ModifierKey.Shift);
|
var keybindPanel = new Panel(Anchor.BottomRight, new Vector2(130, 150), new Vector2(5));
|
||||||
var keybindPanel = new Panel(Anchor.BottomRight, new Vector2(100, 100), new Vector2(5));
|
for (var i = 0; i < 15; i++) {
|
||||||
for (var i = 0; i < 3; i++) {
|
var button = keybindPanel.AddChild(new Button(default, default, i.ToString()));
|
||||||
var button = keybindPanel.AddChild(ElementHelper.KeybindButton(Anchor.AutoLeft, new Vector2(0.5F, 12), keybind, Input, "Press", Keys.Escape, index: i));
|
button.Anchor = Anchor.AutoInline;
|
||||||
button.Text.TextScale = 0.1F;
|
button.Padding = new Padding(0.5F);
|
||||||
|
button.SetHeightBasedOnChildren = false;
|
||||||
|
button.Size = new Vector2(30, 50);
|
||||||
}
|
}
|
||||||
this.UiSystem.Add("Keybinds", keybindPanel);
|
this.UiSystem.Add("Keybinds", keybindPanel);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue