Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_DialogEditorUIComponent.c
Go to the documentation of this file.
1 
4 {
5  [Attribute(desc: "Pressing this action toggles the dialog.")]
6  protected string m_sToggleActionName;
7 
8  [Attribute(desc: "Pressing this action activates previously activated item.")]
9  protected string m_sRepeatActionName;
10 
11  [Attribute(desc: "Dialog opened on action press.", uiwidget: UIWidgets.ComboBox, enums: ParamEnumArray.FromEnum(ChimeraMenuPreset))]
12  protected ChimeraMenuPreset m_DialogPreset;
13 
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;
16 
17  protected bool m_bIsInDialog;
18  protected bool m_CanCloseWithToggleAction = true;
19  protected EditorMenuBase m_EditorMenu;
20  protected SCR_DialogEditorUIComponent m_LinkedComponent;
21 
22  //------------------------------------------------------------------------------------------------
23  protected void AllowFocus(Widget w)
24  {
25  if (m_bIsInDialog)
26  w.ClearFlags(WidgetFlags.NOFOCUS);
27  else
28  w.SetFlags(WidgetFlags.NOFOCUS);
29  }
30 
31  //------------------------------------------------------------------------------------------------
32  protected void FocusWidget(Widget w)
33  {
34  GetGame().GetWorkspace().SetFocusedWidget(w);
35  }
36 
37  //------------------------------------------------------------------------------------------------
38  protected void SetLinkedWidgetVisibility(bool show)
39  {
40  Widget parent = GetWidget();
41  for (int i = 0; i < m_iHideLinkedIndex; i++)
42  {
43  parent = parent.GetParent();
44  }
45  parent.SetVisible(show);
46  }
47 
48  //------------------------------------------------------------------------------------------------
49  protected void OnInput(float value, EActionTrigger reason)
50  {
51  MenuManager menuManager = GetGame().GetMenuManager();
52  if (!menuManager)
53  return;
54 
55  if (m_bIsInDialog)
56  {
57  /*
58  //--- Close the dialog by pressing the same key which opened it
59  //--- Disabled, not compatible with grids where all directions are needed
60  if (m_CanCloseWithToggleAction)
61  CloseDialog();
62  */
63  }
64  else if (m_DialogPreset != 0 && !menuManager.IsAnyDialogOpen() && CanOpenDialog())
65  {
66  menuManager.OpenDialog(m_DialogPreset);
67  SetLinkedWidgetVisibility(false);
68  }
69  }
70 
71  //------------------------------------------------------------------------------------------------
72  protected void OnRepeat()
73  {
74  }
75 
76  //------------------------------------------------------------------------------------------------
77  protected bool CanOpenDialog()
78  {
79  return true;
80  }
81 
82  //------------------------------------------------------------------------------------------------
83  protected void CloseDialog()
84  {
85  if (m_bIsInDialog)
86  {
87  EditorMenuBase menu = EditorMenuBase.Cast(GetMenu());
88  if (menu)
89  menu.CloseSelf();
90  }
91  }
92 
93  //------------------------------------------------------------------------------------------------
94  protected void OnInputDeviceIsGamepad(bool isGamepad)
95  {
96  CloseDialog();
97  }
98 
99  //------------------------------------------------------------------------------------------------
100  protected void OnMenuUpdate(float timeSlice)
101  {
102  m_EditorMenu.GetOnMenuUpdate().Invoke(timeSlice); //--- ToDo: Better solution to update entity icons?
103  }
104 
105  //------------------------------------------------------------------------------------------------
106  protected void OnDialogOpened(SCR_DialogEditorUIComponent linkedComponent);
107 
108  //------------------------------------------------------------------------------------------------
109  protected void OnDialogClosed(SCR_DialogEditorUIComponent linkedComponent);
110 
111  //------------------------------------------------------------------------------------------------
112  override void HandlerAttachedScripted(Widget w)
113  {
114  super.HandlerAttachedScripted(w);
115 
116  MenuRootBase menu = GetMenu();
117  m_bIsInDialog = menu.Type() != EditorMenuUI;
118 
119  if (m_bIsInDialog)
120  {
121  m_EditorMenu = EditorMenuBase.Cast(GetGame().GetMenuManager().FindMenuByPreset(ChimeraMenuPreset.EditorMenu));
122  m_LinkedComponent = SCR_DialogEditorUIComponent.Cast(m_EditorMenu.GetRootComponent().FindComponent(Type(), true));
123  if (m_LinkedComponent)
124  GetGame().GetCallqueue().Call(OnDialogOpened, m_LinkedComponent); //--- Call later to make sure it's executed after HandlerAttachedScripted of inherited classes
125 
127  if (menuComponent)
128  menuComponent.SetVisible(true);
129 
131  if (statesManager)
132  statesManager.SetSafeDialog(true);
133  }
134 
135  InputManager inputManager = GetGame().GetInputManager();
136  if (inputManager)
137  {
138  if (!m_sToggleActionName.IsEmpty())
139  inputManager.AddActionListener(m_sToggleActionName, EActionTrigger.DOWN, OnInput);
140 
141  if (!m_sRepeatActionName.IsEmpty())
142  inputManager.AddActionListener(m_sRepeatActionName, EActionTrigger.DOWN, OnRepeat);
143 
144  if (m_bIsInDialog)
145  inputManager.AddActionListener("MenuBack", EActionTrigger.DOWN, CloseDialog);
146  }
147 
148  GetGame().OnInputDeviceIsGamepadInvoker().Insert(OnInputDeviceIsGamepad);
149 
150  if (m_bIsInDialog && m_EditorMenu)
151  menu.GetOnMenuUpdate().Insert(OnMenuUpdate);
152  }
153 
154  //------------------------------------------------------------------------------------------------
155  override void HandlerDeattached(Widget w)
156  {
157  super.HandlerDeattached(w);
158 
160  GetGame().OnInputDeviceIsGamepadInvoker().Remove(OnInputDeviceIsGamepad);
161 
162  if (m_bIsInDialog)
163  {
164  if (m_EditorMenu)
165  {
166  SCR_DialogEditorUIComponent linkedComponent = SCR_DialogEditorUIComponent.Cast(m_EditorMenu.GetRootComponent().FindComponent(Type(), true));
167  if (linkedComponent)
168  {
169  linkedComponent.SetLinkedWidgetVisibility(true);
170  linkedComponent.OnDialogClosed(this);
171  }
172  }
173 
175  if (statesManager)
176  statesManager.SetSafeDialog(false);
177  }
178 
179  InputManager inputManager = GetGame().GetInputManager();
180  if (inputManager)
181  {
182  if (!m_sToggleActionName.IsEmpty())
183  inputManager.RemoveActionListener(m_sToggleActionName, EActionTrigger.DOWN, OnInput);
184 
185  if (!m_sRepeatActionName.IsEmpty())
186  inputManager.RemoveActionListener(m_sRepeatActionName, EActionTrigger.DOWN, OnRepeat);
187 
188  if (m_bIsInDialog)
189  inputManager.RemoveActionListener("MenuBack", EActionTrigger.DOWN, CloseDialog);
190  }
191 
192  MenuRootBase menu = GetMenu();
193  if (menu && m_bIsInDialog)
194  menu.GetOnMenuUpdate().Remove(OnMenuUpdate);
195  }
196 }
EditorMenuUI
Definition: EditorMenuUI.c:3
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
GetMenu
SCR_RadialMenu GetMenu()
Definition: SCR_RadialMenuGameModeComponent.c:41
Attribute
typedef Attribute
Post-process effect of scripted camera.
MenuRootBase
Definition: MenuRootBase.c:6
EditorMenuBase
Definition: EditorMenuBase.c:7
SCR_BaseEditorUIComponent
Definition: SCR_BaseEditorUIComponent.c:3
ChimeraMenuPreset
ChimeraMenuPreset
Menu presets.
Definition: ChimeraMenuBase.c:3
SCR_MenuEditorComponent
Definition: SCR_MenuEditorComponent.c:8
SCR_DialogEditorUIComponent
Definition: SCR_DialogEditorUIComponent.c:3
SCR_StatesEditorComponent
Definition: SCR_StatesEditorComponent.c:9
OnInputDeviceIsGamepadInvoker
ScriptInvoker OnInputDeviceIsGamepadInvoker()
Definition: game.c:246
GetWidget
protected Widget GetWidget()
Definition: SCR_VonDisplay.c:155