Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_DialogEditorUIComponent.c
Go to the documentation of this file.
1
2
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))]
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;
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 SetLinkedWidgetVisibility(bool show)
33 {
34 Widget parent = GetWidget();
35 for (int i = 0; i < m_iHideLinkedIndex; i++)
36 {
37 parent = parent.GetParent();
38 }
39 parent.SetVisible(show);
40 }
41
42 //------------------------------------------------------------------------------------------------
43 protected void OnInput(float value, EActionTrigger reason)
44 {
45 MenuManager menuManager = GetGame().GetMenuManager();
46 if (!menuManager)
47 return;
48
49 if (m_bIsInDialog)
50 {
51 /*
52 //--- Close the dialog by pressing the same key which opened it
53 //--- Disabled, not compatible with grids where all directions are needed
54 if (m_CanCloseWithToggleAction)
55 CloseDialog();
56 */
57 }
58 else if (m_DialogPreset != 0 && !menuManager.IsAnyDialogOpen() && CanOpenDialog())
59 {
60 menuManager.OpenDialog(m_DialogPreset);
62 }
63 }
64
65 //------------------------------------------------------------------------------------------------
66 protected void OnRepeat()
67 {
68 }
69
70 //------------------------------------------------------------------------------------------------
71 protected bool CanOpenDialog()
72 {
73 return true;
74 }
75
76 //------------------------------------------------------------------------------------------------
77 protected void CloseDialog()
78 {
79 if (m_bIsInDialog)
80 {
82 if (menu)
83 menu.CloseSelf();
84 }
85 }
86
87 //------------------------------------------------------------------------------------------------
88 protected void OnInputDeviceIsGamepad(bool isGamepad)
89 {
91 }
92
93 //------------------------------------------------------------------------------------------------
94 protected void OnMenuUpdate(float timeSlice)
95 {
96 m_EditorMenu.GetOnMenuUpdate().Invoke(timeSlice); //--- ToDo: Better solution to update entity icons?
97 }
98
99 //------------------------------------------------------------------------------------------------
100 protected void OnDialogOpened(SCR_DialogEditorUIComponent linkedComponent);
101
102 //------------------------------------------------------------------------------------------------
103 protected void OnDialogClosed(SCR_DialogEditorUIComponent linkedComponent);
104
105 //------------------------------------------------------------------------------------------------
107 {
108 super.HandlerAttachedScripted(w);
109
110 MenuRootBase menu = GetMenu();
111 m_bIsInDialog = menu.Type() != EditorMenuUI;
112
113 if (m_bIsInDialog)
114 {
115 m_EditorMenu = EditorMenuBase.Cast(GetGame().GetMenuManager().FindMenuByPreset(ChimeraMenuPreset.EditorMenu));
116 m_LinkedComponent = SCR_DialogEditorUIComponent.Cast(m_EditorMenu.GetRootComponent().FindComponent(Type(), true));
118 GetGame().GetCallqueue().Call(OnDialogOpened, m_LinkedComponent); //--- Call later to make sure it's executed after HandlerAttachedScripted of inherited classes
119
121 if (menuComponent)
122 menuComponent.SetVisible(true);
123
125 if (statesManager)
126 statesManager.SetSafeDialog(true);
127 }
128
129 InputManager inputManager = GetGame().GetInputManager();
130 if (inputManager)
131 {
132 if (!m_sToggleActionName.IsEmpty())
133 inputManager.AddActionListener(m_sToggleActionName, EActionTrigger.DOWN, OnInput);
134
135 if (!m_sRepeatActionName.IsEmpty())
136 inputManager.AddActionListener(m_sRepeatActionName, EActionTrigger.DOWN, OnRepeat);
137
138 if (m_bIsInDialog)
139 inputManager.AddActionListener(UIConstants.MENU_ACTION_BACK, EActionTrigger.DOWN, CloseDialog);
140 }
141
142 GetGame().OnInputDeviceIsGamepadInvoker().Insert(OnInputDeviceIsGamepad);
143
145 menu.GetOnMenuUpdate().Insert(OnMenuUpdate);
146 }
147
148 //------------------------------------------------------------------------------------------------
149 override void HandlerDeattached(Widget w)
150 {
151 super.HandlerDeattached(w);
152
154 GetGame().OnInputDeviceIsGamepadInvoker().Remove(OnInputDeviceIsGamepad);
155
156 if (m_bIsInDialog)
157 {
158 if (m_EditorMenu)
159 {
160 SCR_DialogEditorUIComponent linkedComponent = SCR_DialogEditorUIComponent.Cast(m_EditorMenu.GetRootComponent().FindComponent(Type(), true));
161 if (linkedComponent)
162 {
163 linkedComponent.SetLinkedWidgetVisibility(true);
164 linkedComponent.OnDialogClosed(this);
165 }
166 }
167
169 if (statesManager)
170 statesManager.SetSafeDialog(false);
171 }
172
173 InputManager inputManager = GetGame().GetInputManager();
174 if (inputManager)
175 {
176 if (!m_sToggleActionName.IsEmpty())
177 inputManager.RemoveActionListener(m_sToggleActionName, EActionTrigger.DOWN, OnInput);
178
179 if (!m_sRepeatActionName.IsEmpty())
180 inputManager.RemoveActionListener(m_sRepeatActionName, EActionTrigger.DOWN, OnRepeat);
181
182 if (m_bIsInDialog)
183 inputManager.RemoveActionListener(UIConstants.MENU_ACTION_BACK, EActionTrigger.DOWN, CloseDialog);
184 }
185
186 MenuRootBase menu = GetMenu();
187 if (menu && m_bIsInDialog)
188 menu.GetOnMenuUpdate().Remove(OnMenuUpdate);
189 }
190}
ChimeraMenuPreset
Menu presets.
ArmaReforgerScripted GetGame()
Definition game.c:1398
ScriptInvoker OnInputDeviceIsGamepadInvoker()
Definition game.c:238
SCR_RadialMenu GetMenu()
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Widget GetWidget()
int Type
Input management system for user interactions.
proto external MenuBase OpenDialog(ScriptMenuPresetEnum preset, int priority=DialogPriority.INFORMATIVE, int iUserData=0, bool unique=false)
proto external bool IsAnyDialogOpen()
ScriptInvoker GetOnMenuUpdate()
void OnDialogClosed(SCR_DialogEditorUIComponent linkedComponent)
void OnDialogOpened(SCR_DialogEditorUIComponent linkedComponent)
SCR_DialogEditorUIComponent m_LinkedComponent
void OnInput(float value, EActionTrigger reason)
override void HandlerAttachedScripted(Widget w)
SCR_FieldOfViewSettings Attribute
EActionTrigger
WidgetFlags
Widget flags. See enf::Widget::SetFlags().
Definition WidgetFlags.c:14