5 [
Attribute(
"10", UIWidgets.Auto,
"Speed of smooth transition between visible and hidden state.")]
6 protected float m_fTransitionSpeed;
8 [
Attribute(
desc:
"Show interface again when any of these actions is triggered")]
9 protected ref array<string> m_aShowActions;
12 protected float m_fTargetOpacity = 1;
13 protected bool m_bInTransition;
14 protected ref ScriptInvoker Event_OnOpacityChange;
20 void SetVisible(
bool visible,
bool instant =
false)
26 widget.SetEnabled(visible);
34 SetWidgetOpacity(widget, m_fTargetOpacity);
36 m_bInTransition =
true;
41 ScriptInvoker GetOnOpacityChange()
43 if (!Event_OnOpacityChange)
44 Event_OnOpacityChange =
new ScriptInvoker();
46 return Event_OnOpacityChange;
53 GetGame().GetCallqueue().CallLater(SetMenuVisible, 1,
false,
true);
57 protected void SetMenuVisible(
bool visible)
59 if (m_EditorMenuManager)
60 m_EditorMenuManager.SetVisible(visible);
64 protected void SetWidgetOpacity(Widget widget,
float opacity)
67 widget.SetOpacity(opacity);
69 if (Event_OnOpacityChange)
70 Event_OnOpacityChange.Invoke(opacity);
74 protected void OnMenuUpdate(
float tDelta)
91 float opacity = widget.GetOpacity();
92 if (Math.AbsFloat(opacity - m_fTargetOpacity) < 0.01)
94 SetWidgetOpacity(widget, m_fTargetOpacity);
95 m_bInTransition =
false;
98 SetWidgetOpacity(widget, Math.Lerp(opacity, m_fTargetOpacity, m_fTransitionSpeed * tDelta));
103 protected void OnMenuInit()
105 if (m_EditorMenuManager)
106 SetVisible(m_EditorMenuManager.IsVisible(),
true);
110 override void HandlerAttachedScripted(Widget w)
112 super.HandlerAttachedScripted(w);
121 menu.GetOnMenuInit().Insert(OnMenuInit);
122 menu.GetOnMenuUpdate().Insert(OnMenuUpdate);
126 InputManager inputManager =
GetGame().GetInputManager();
129 foreach (
string showAction : m_aShowActions)
131 inputManager.AddActionListener(showAction, EActionTrigger.DOWN, Show);
137 override void HandlerDeattached(Widget w)
139 super.HandlerDeattached(w);
141 InputManager inputManager =
GetGame().GetInputManager();
144 foreach (
string showAction : m_aShowActions)
146 inputManager.RemoveActionListener(showAction, EActionTrigger.DOWN, Show);