Fix character menu button not untoggling when window closes (#33712)
This commit is contained in:
@@ -56,19 +56,20 @@ public sealed class CharacterUIController : UIController, IOnStateEntered<Gamepl
|
|||||||
_window = UIManager.CreateWindow<CharacterWindow>();
|
_window = UIManager.CreateWindow<CharacterWindow>();
|
||||||
LayoutContainer.SetAnchorPreset(_window, LayoutContainer.LayoutPreset.CenterTop);
|
LayoutContainer.SetAnchorPreset(_window, LayoutContainer.LayoutPreset.CenterTop);
|
||||||
|
|
||||||
|
_window.OnClose += DeactivateButton;
|
||||||
|
_window.OnOpen += ActivateButton;
|
||||||
|
|
||||||
CommandBinds.Builder
|
CommandBinds.Builder
|
||||||
.Bind(ContentKeyFunctions.OpenCharacterMenu,
|
.Bind(ContentKeyFunctions.OpenCharacterMenu,
|
||||||
InputCmdHandler.FromDelegate(_ => ToggleWindow()))
|
InputCmdHandler.FromDelegate(_ => ToggleWindow()))
|
||||||
.Register<CharacterUIController>();
|
.Register<CharacterUIController>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnStateExited(GameplayState state)
|
public void OnStateExited(GameplayState state)
|
||||||
{
|
{
|
||||||
if (_window != null)
|
if (_window != null)
|
||||||
{
|
{
|
||||||
_window.Dispose();
|
_window.Close();
|
||||||
_window = null;
|
_window = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,18 +106,27 @@ public sealed class CharacterUIController : UIController, IOnStateEntered<Gamepl
|
|||||||
}
|
}
|
||||||
|
|
||||||
CharacterButton.OnPressed += CharacterButtonPressed;
|
CharacterButton.OnPressed += CharacterButtonPressed;
|
||||||
|
}
|
||||||
|
|
||||||
if (_window == null)
|
private void DeactivateButton()
|
||||||
|
{
|
||||||
|
if (CharacterButton == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_window.OnClose += DeactivateButton;
|
CharacterButton.Pressed = false;
|
||||||
_window.OnOpen += ActivateButton;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DeactivateButton() => CharacterButton!.Pressed = false;
|
private void ActivateButton()
|
||||||
private void ActivateButton() => CharacterButton!.Pressed = true;
|
{
|
||||||
|
if (CharacterButton == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
CharacterButton.Pressed = true;
|
||||||
|
}
|
||||||
|
|
||||||
private void CharacterUpdated(CharacterData data)
|
private void CharacterUpdated(CharacterData data)
|
||||||
{
|
{
|
||||||
@@ -150,7 +160,7 @@ public sealed class CharacterUIController : UIController, IOnStateEntered<Gamepl
|
|||||||
|
|
||||||
var objectiveLabel = new RichTextLabel
|
var objectiveLabel = new RichTextLabel
|
||||||
{
|
{
|
||||||
StyleClasses = {StyleNano.StyleClassTooltipActionTitle}
|
StyleClasses = { StyleNano.StyleClassTooltipActionTitle }
|
||||||
};
|
};
|
||||||
objectiveLabel.SetMessage(objectiveText);
|
objectiveLabel.SetMessage(objectiveText);
|
||||||
|
|
||||||
@@ -245,10 +255,7 @@ public sealed class CharacterUIController : UIController, IOnStateEntered<Gamepl
|
|||||||
if (_window == null)
|
if (_window == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (CharacterButton != null)
|
CharacterButton?.SetClickPressed(!_window.IsOpen);
|
||||||
{
|
|
||||||
CharacterButton.SetClickPressed(!_window.IsOpen);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_window.IsOpen)
|
if (_window.IsOpen)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user