Action container rejig (#20260)

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
Leon Friedrich
2023-09-23 04:49:39 -04:00
committed by GitHub
parent c80c90ed65
commit 684b334806
50 changed files with 889 additions and 740 deletions

View File

@@ -19,14 +19,6 @@ public class ActionButtonContainer : GridContainer
public ActionButton this[int index]
{
get => (ActionButton) GetChild(index);
set
{
AddChild(value);
value.SetPositionInParent(index);
value.ActionPressed += ActionPressed;
value.ActionUnpressed += ActionUnpressed;
value.ActionFocusExited += ActionFocusExited;
}
}
public void SetActionData(params EntityUid?[] actionTypes)
@@ -63,6 +55,16 @@ public class ActionButtonContainer : GridContainer
button.ActionFocusExited += ActionFocusExited;
}
protected override void ChildRemoved(Control newChild)
{
if (newChild is not ActionButton button)
return;
button.ActionPressed -= ActionPressed;
button.ActionUnpressed -= ActionUnpressed;
button.ActionFocusExited -= ActionFocusExited;
}
public bool TryGetButtonIndex(ActionButton button, out int position)
{
if (button.Parent != this)