6 protected string m_sToggleActionName;
8 [
Attribute(
desc:
"Pressing this action activates previously activated item.")]
9 protected string m_sRepeatActionName;
14 [
Attribute(
"-1",
desc:
"When >= 0, it will hide parent of main screen widget when the dialog version is opened.\n0 means this widget will be hidden, 1 means its parent will, etc.")]
15 protected int m_iHideLinkedIndex;
17 protected bool m_bIsInDialog;
18 protected bool m_CanCloseWithToggleAction =
true;
23 protected void AllowFocus(Widget w)
26 w.ClearFlags(WidgetFlags.NOFOCUS);
28 w.SetFlags(WidgetFlags.NOFOCUS);
32 protected void FocusWidget(Widget w)
34 GetGame().GetWorkspace().SetFocusedWidget(w);
38 protected void SetLinkedWidgetVisibility(
bool show)
41 for (
int i = 0; i < m_iHideLinkedIndex; i++)
43 parent = parent.GetParent();
45 parent.SetVisible(show);
49 protected void OnInput(
float value, EActionTrigger reason)
51 MenuManager menuManager =
GetGame().GetMenuManager();
64 else if (m_DialogPreset != 0 && !menuManager.IsAnyDialogOpen() && CanOpenDialog())
66 menuManager.OpenDialog(m_DialogPreset);
67 SetLinkedWidgetVisibility(
false);
72 protected void OnRepeat()
77 protected bool CanOpenDialog()
83 protected void CloseDialog()
94 protected void OnInputDeviceIsGamepad(
bool isGamepad)
100 protected void OnMenuUpdate(
float timeSlice)
102 m_EditorMenu.GetOnMenuUpdate().Invoke(timeSlice);
112 override void HandlerAttachedScripted(Widget w)
114 super.HandlerAttachedScripted(w);
123 if (m_LinkedComponent)
124 GetGame().GetCallqueue().Call(OnDialogOpened, m_LinkedComponent);
128 menuComponent.SetVisible(
true);
132 statesManager.SetSafeDialog(
true);
135 InputManager inputManager =
GetGame().GetInputManager();
138 if (!m_sToggleActionName.IsEmpty())
139 inputManager.AddActionListener(m_sToggleActionName, EActionTrigger.DOWN, OnInput);
141 if (!m_sRepeatActionName.IsEmpty())
142 inputManager.AddActionListener(m_sRepeatActionName, EActionTrigger.DOWN, OnRepeat);
145 inputManager.AddActionListener(
"MenuBack", EActionTrigger.DOWN, CloseDialog);
148 GetGame().OnInputDeviceIsGamepadInvoker().Insert(OnInputDeviceIsGamepad);
150 if (m_bIsInDialog && m_EditorMenu)
151 menu.GetOnMenuUpdate().Insert(OnMenuUpdate);
155 override void HandlerDeattached(Widget w)
157 super.HandlerDeattached(w);
160 GetGame().OnInputDeviceIsGamepadInvoker().Remove(OnInputDeviceIsGamepad);
169 linkedComponent.SetLinkedWidgetVisibility(
true);
170 linkedComponent.OnDialogClosed(
this);
176 statesManager.SetSafeDialog(
false);
179 InputManager inputManager =
GetGame().GetInputManager();
182 if (!m_sToggleActionName.IsEmpty())
183 inputManager.RemoveActionListener(m_sToggleActionName, EActionTrigger.DOWN, OnInput);
185 if (!m_sRepeatActionName.IsEmpty())
186 inputManager.RemoveActionListener(m_sRepeatActionName, EActionTrigger.DOWN, OnRepeat);
189 inputManager.RemoveActionListener(
"MenuBack", EActionTrigger.DOWN, CloseDialog);
193 if (menu && m_bIsInDialog)
194 menu.GetOnMenuUpdate().Remove(OnMenuUpdate);