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>();
|
||||
LayoutContainer.SetAnchorPreset(_window, LayoutContainer.LayoutPreset.CenterTop);
|
||||
|
||||
|
||||
_window.OnClose += DeactivateButton;
|
||||
_window.OnOpen += ActivateButton;
|
||||
|
||||
CommandBinds.Builder
|
||||
.Bind(ContentKeyFunctions.OpenCharacterMenu,
|
||||
InputCmdHandler.FromDelegate(_ => ToggleWindow()))
|
||||
.Register<CharacterUIController>();
|
||||
InputCmdHandler.FromDelegate(_ => ToggleWindow()))
|
||||
.Register<CharacterUIController>();
|
||||
}
|
||||
|
||||
public void OnStateExited(GameplayState state)
|
||||
{
|
||||
if (_window != null)
|
||||
{
|
||||
_window.Dispose();
|
||||
_window.Close();
|
||||
_window = null;
|
||||
}
|
||||
|
||||
@@ -105,18 +106,27 @@ public sealed class CharacterUIController : UIController, IOnStateEntered<Gamepl
|
||||
}
|
||||
|
||||
CharacterButton.OnPressed += CharacterButtonPressed;
|
||||
}
|
||||
|
||||
if (_window == null)
|
||||
private void DeactivateButton()
|
||||
{
|
||||
if (CharacterButton == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_window.OnClose += DeactivateButton;
|
||||
_window.OnOpen += ActivateButton;
|
||||
CharacterButton.Pressed = false;
|
||||
}
|
||||
|
||||
private void DeactivateButton() => CharacterButton!.Pressed = false;
|
||||
private void ActivateButton() => CharacterButton!.Pressed = true;
|
||||
private void ActivateButton()
|
||||
{
|
||||
if (CharacterButton == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CharacterButton.Pressed = true;
|
||||
}
|
||||
|
||||
private void CharacterUpdated(CharacterData data)
|
||||
{
|
||||
@@ -150,7 +160,7 @@ public sealed class CharacterUIController : UIController, IOnStateEntered<Gamepl
|
||||
|
||||
var objectiveLabel = new RichTextLabel
|
||||
{
|
||||
StyleClasses = {StyleNano.StyleClassTooltipActionTitle}
|
||||
StyleClasses = { StyleNano.StyleClassTooltipActionTitle }
|
||||
};
|
||||
objectiveLabel.SetMessage(objectiveText);
|
||||
|
||||
@@ -245,10 +255,7 @@ public sealed class CharacterUIController : UIController, IOnStateEntered<Gamepl
|
||||
if (_window == null)
|
||||
return;
|
||||
|
||||
if (CharacterButton != null)
|
||||
{
|
||||
CharacterButton.SetClickPressed(!_window.IsOpen);
|
||||
}
|
||||
CharacterButton?.SetClickPressed(!_window.IsOpen);
|
||||
|
||||
if (_window.IsOpen)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user