Action container rejig (#20260)
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user