Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_InterfaceSettingsSubMenu.c
Go to the documentation of this file.
2{
3 protected const string CHAT_SPINBOX_WIDGET_NAME = "Chat";
4 protected const string NOTIFICATIONS_SPINBOX_WIDGET_NAME = "Notifications";
5 protected const string VON_SPINBOX_WIDGET_NAME = "VoN";
6 protected const string CONTROLHINTS_SPINBOX_WIDGET_NAME = "ControlHints";
7 protected const string HINTS_SPINBOX_WIDGET_NAME = "Hints";
8 protected const string NEARBYINTERACTION_SPINBOX_WIDGET_NAME = "NearbyInteractions";
9 protected const string NAMETAGS_SPINBOX_WIDGET_NAME = "NameTags";
10 protected const string FPS_SPINBOX_WIDGET_NAME = "FPS";
11 protected const string SERVER_FPS_SPINBOX_WIDGET_NAME = "ServerFPS";
12 protected const string PACKETLOSS_SPINBOX_WIDGET_NAME = "PacketLoss";
13 protected const string LATENCY_SPINBOX_WIDGET_NAME = "Latency";
14 protected const string GAMEVERSION_SPINBOX_WIDGET_NAME = "GameVersion";
15 protected const string WEAPONINFO_SPINBOX_WIDGET_NAME = "WeaponInfo";
16 protected const string VEHICLEINFO_SPINBOX_WIDGET_NAME = "VehicleInfo";
17 protected const string MASTERSWITCH_SPINBOX_WIDGET_NAME = "MasterSwitch";
18 protected const string SERVERNAME_SPINBOX_WIDGET_NAME = "ServerName";
19 protected const string INTERACTION_HINT_SPINBOX_WIDGET_NAME = "InteractionHint";
20
21 protected const string MASTER_SWITCH_HIDE_STATE_NAME = "#AR-Settings_Hide_All";
22 protected const string MASTER_SWITCH_SHOW_STATE_NAME = "#AR-Settings_Show_All";
23 protected const string MASTER_SWITCH_CUSTOM_STATE_NAME = "#AR-Settings_Interface_Custom";
24
26
30
31 protected bool m_bIsAllShown;
32 protected bool m_bIsCustom;
33
34 protected ref array<ref SCR_SpinBoxComponent> m_aAllSpinBoxes = {};
35
36 //------------------------------------------------------------------------------------------------
40 protected void SetupSpinboxes(string widgetName, string settingName)
41 {
44 {
46 data.SetSettingName(settingName);
47
48 bool state;
49 m_InterfaceSettings.Get(settingName, state);
50 m_SpinnerBoxComp.SetCurrentItem(state);
51
52
53 m_SpinnerBoxComp.SetData(data);
55 }
56 else
57 {
58 PrintFormat("Interface setting widget '%1' not found", widgetName, level: LogLevel.WARNING);
59 }
60 }
61
62 //------------------------------------------------------------------------------------------------
75
76 //------------------------------------------------------------------------------------------------
77 protected void ChangeMasterSwitchState()
78 {
80 return;
81
82 // Remove invoker to prevent it from triggering the function when Item is removed
83 m_MasterSpinBoxComp.m_OnChanged.Remove(OnMasterChange);
84
85 int state;
86 m_bIsCustom = false;
87
88 foreach (int index, SCR_SpinBoxComponent spinBoxComponent : m_aAllSpinBoxes)
89 {
90 state = spinBoxComponent.GetCurrentIndex();
91
92 // Check the first index to define what is expected of the others
93 // In the end this defines what the MasterSwitch should show.
94 if (index == 0)
95 m_bIsAllShown = state;
96
97 if (m_bIsAllShown != state)
98 {
99 // If one SpinBox has not the state we expect, the MasterSwitch needs to show a custom state
100 m_bIsCustom = true;
101 break;
102 }
103 }
104
106 {
108 }
109 else if (!m_bIsCustom)
110 {
112 m_MasterSpinBoxComp.RemoveItem(m_MasterSpinBoxComp.GetCurrentIndex());
113
114 m_MasterSpinBoxComp.SetCurrentItem(m_bIsAllShown);
115 }
116
117 // Add the invoker again once everything is done
118 m_MasterSpinBoxComp.m_OnChanged.Insert(OnMasterChange);
119
120 }
121
122 //------------------------------------------------------------------------------------------------
123 protected void SetCustomState()
124 {
127 }
128
129 //------------------------------------------------------------------------------------------------
130 override void OnTabCreate(Widget menuRoot, ResourceName buttonsLayout, int index)
131 {
132 super.OnTabCreate(menuRoot, buttonsLayout, index);
133
134 m_InterfaceSettings = GetGame().GetGameUserSettings().GetModule("SCR_InterfaceSettings");
135
137 return;
138
139 // Setup Chat
142 m_SpinnerBoxComp.m_OnChanged.Insert(OnSpinBoxChange);
143
144 // Setup Notifications
145 SetupSpinboxes(NOTIFICATIONS_SPINBOX_WIDGET_NAME, "m_bShowNotifications");
147 m_SpinnerBoxComp.m_OnChanged.Insert(OnSpinBoxChange);
148
149 // Setup VoN
152 m_SpinnerBoxComp.m_OnChanged.Insert(OnSpinBoxChange);
153
154 // Setup Control hints
155 SetupSpinboxes(CONTROLHINTS_SPINBOX_WIDGET_NAME, "m_bShowControlHints");
157 m_SpinnerBoxComp.m_OnChanged.Insert(OnSpinBoxChange);
158
159 // Setup hints
162 m_SpinnerBoxComp.m_OnChanged.Insert(OnSpinBoxChange);
163
164 // Setup nearby interactions
165 SetupSpinboxes(NEARBYINTERACTION_SPINBOX_WIDGET_NAME, "m_bShowNearbyInteractions");
167 m_SpinnerBoxComp.m_OnChanged.Insert(OnSpinBoxChange);
168
169 // Setup Nametags
172 m_SpinnerBoxComp.m_OnChanged.Insert(OnSpinBoxChange);
173
174 // Setup FPS
177 m_SpinnerBoxComp.m_OnChanged.Insert(OnSpinBoxChange);
178
179 // Setup ServerFPS
182 m_SpinnerBoxComp.m_OnChanged.Insert(OnSpinBoxChange);
183
184 // Setup PacketLoss
187 m_SpinnerBoxComp.m_OnChanged.Insert(OnSpinBoxChange);
188
189 // Setup Latency
192 m_SpinnerBoxComp.m_OnChanged.Insert(OnSpinBoxChange);
193
194 // Setup GameVersion
195 SetupSpinboxes(GAMEVERSION_SPINBOX_WIDGET_NAME, "m_bShowGameVersion");
197 m_SpinnerBoxComp.m_OnChanged.Insert(OnSpinBoxChange);
198
199 // Setup WeaponInfo
202 m_SpinnerBoxComp.m_OnChanged.Insert(OnSpinBoxChange);
203
204 // Setup VehicleInfo
205 SetupSpinboxes(VEHICLEINFO_SPINBOX_WIDGET_NAME, "m_bShowVehicleInfo");
207 m_SpinnerBoxComp.m_OnChanged.Insert(OnSpinBoxChange);
208
209 // Setup ServerName
212 m_SpinnerBoxComp.m_OnChanged.Insert(OnSpinBoxChange);
213
214 // Setup InteractionNames
215 SetupSpinboxes(INTERACTION_HINT_SPINBOX_WIDGET_NAME, "m_bShowInteractionHint");
217 m_SpinnerBoxComp.m_OnChanged.Insert(OnSpinBoxChange);
218
219 // Setup Master switch
221 }
222
223 //------------------------------------------------------------------------------------------------
224 void OnSpinBoxChange(SCR_SpinBoxComponent spinBox, int currentItem)
225 {
227 if (!data)
228 return;
229
230 string settingsName = data.GetSettingName();
231 if (settingsName.IsEmpty())
232 return;
233
234 m_InterfaceSettings.Set(settingsName, currentItem);
235
236 if (settingsName == "m_bShowHints")
237 {
238 BaseContainer hintSetings = GetGame().GetGameUserSettings().GetModule("SCR_HintSettings");
239 if (hintSetings)
240 hintSetings.Set("m_bHintsEnabled", currentItem);
241 }
242
243 GetGame().UserSettingsChanged();
245
246 //SCR_AnalyticsApplication.GetInstance().ChangeSetting("Interface", settingsName);
247 }
248
249 //------------------------------------------------------------------------------------------------
250 void OnMasterChange(SCR_SpinBoxComponent spinBox, int currentItem)
251 {
252 // Remove invoker to prevent it from triggering this function again when Item is removed
253 m_MasterSpinBoxComp.m_OnChanged.Remove(OnMasterChange);
254
255 string settingName;
257
258 foreach (SCR_SpinBoxComponent spinBoxComponent : m_aAllSpinBoxes)
259 {
260 data = SCR_SettingSpinBoxUserData.Cast(spinBoxComponent.GetData());
261 if (!data)
262 continue;
263
264 settingName = data.GetSettingName();
265 if (settingName.IsEmpty())
266 continue;
267
268 m_InterfaceSettings.Set(settingName, currentItem);
269
270 spinBoxComponent.m_OnChanged.Remove(OnSpinBoxChange);
271 spinBoxComponent.SetCurrentItem(currentItem);
272 spinBoxComponent.m_OnChanged.Insert(OnSpinBoxChange);
273 }
274
275 GetGame().UserSettingsChanged();
276
278 {
280 m_MasterSpinBoxComp.SetCurrentItem(currentItem);
281 }
282
283 // Add the invoker again once everything is done
284 m_MasterSpinBoxComp.m_OnChanged.Insert(OnMasterChange);
285
286 //SCR_AnalyticsApplication.GetInstance().SetHudVisibilitySetting(currentItem);
287 }
288}
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
Get all prefabs that have the spawner data
void OnSpinBoxChange(SCR_SpinBoxComponent spinBox, int currentItem)
override void OnTabCreate(Widget menuRoot, ResourceName buttonsLayout, int index)
void SetupSpinboxes(string widgetName, string settingName)
ref array< ref SCR_SpinBoxComponent > m_aAllSpinBoxes
void OnMasterChange(SCR_SpinBoxComponent spinBox, int currentItem)
static SCR_SpinBoxComponent GetSpinBoxComponent(string name, Widget parent, bool searchAllChildren=true)
LogLevel
Enum with severity of the logging message.
Definition LogLevel.c:14
proto void PrintFormat(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL, LogLevel level=LogLevel.NORMAL)