Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_EditorSettingsSubMenu.c
Go to the documentation of this file.
1
3{
4 SCR_SelectionWidgetComponent m_wHorizontalCameraSpeedCheckbox;
5 SCR_SelectionWidgetComponent m_wATLSpeedCheckbox;
6 SCR_SliderComponent m_wSpeedCoefSlider;
7
8 private static const string GAME_MASTER = "Game Master";
9 private static const string LAYER_EDITING = "m_bLayerEditing";
10 private static const string PREVIEW_VERTICAL_SNAP = "m_PreviewVerticalSnap";
11 private static const string PREVIEW_VERTICLE_MODE = "m_PreviewVerticleMode";
12 private static const string CAMERA_MOVE_ATL = "m_bCameraMoveATL";
13 private static const string CAMERA_SPEED_ATL = "m_bCameraSpeedATL";
14 private static const string CAMERA_SPEED_COEF = "m_fCameraSpeedCoef";
15 private static const string CAMERA_ABOVE_TERRAIN = "m_bCameraAboveTerrain";
16 private static const string CAMERA_ROTATE_WITH_MODIFIER = "m_bCameraRotateWithModifier";
17 private static const string SHOW_IDENTITY_BIO_TOOLTIP = "m_bShowIdentityBioTooltip";
18
19 //------------------------------------------------------------------------------------------------
20 override void OnTabCreate(Widget menuRoot, ResourceName buttonsLayout, int index)
21 {
22 BaseContainer editorCameraSettings = GetGame().GetGameUserSettings().GetModule("SCR_ManualCameraSettings");
23 BaseContainer editorSettings = GetGame().GetGameUserSettings().GetModule("SCR_EditorSettings");
24
25 super.OnTabCreate(menuRoot, buttonsLayout, index);
26
27 if (!editorCameraSettings)
28 return;
29 if (!editorSettings)
30 return;
31
32 //Layer Editing
34 if (checkBox)
35 {
36 bool state;
37 editorSettings.Get(LAYER_EDITING, state);
38
39 checkBox.SetCurrentItem(state, false, false);
40 checkBox.m_OnChanged.Insert(SetEnableLayerEditing);
41 }
42 else
43 {
44 Print("Editor setting 'LayerEditing' not found", LogLevel.WARNING);
45 }
46
47 //Snap to terrain
49 if (checkBox)
50 {
51 int value;
52 editorSettings.Get(PREVIEW_VERTICAL_SNAP, value);
53
54 checkBox.SetCurrentItem(value, false, false);
55 checkBox.m_OnChanged.Insert(SetVerticalSnap);
56 }
57 else
58 {
59 Print("Editor setting 'VerticalSnap' not found", LogLevel.WARNING);
60 }
61
62 //Orient to terrain
63 checkBox = SCR_SelectionWidgetComponent.GetSelectionComponent("VerticalOrientation", m_wRoot);
64 if (checkBox)
65 {
66 int value;
67 editorSettings.Get(PREVIEW_VERTICLE_MODE, value);
68
69 checkBox.SetCurrentItem(value >> 1, false, false); //--- Shift the value, because it's a flag
70 checkBox.m_OnChanged.Insert(SetVerticalMode);
71 }
72 else
73 {
74 Print("Editor setting 'VerticalOrientation' not found", LogLevel.WARNING);
75 }
76
77 m_wHorizontalCameraSpeedCheckbox = SCR_SelectionWidgetComponent.GetSelectionComponent("HorizontalCameraSpeed", m_wRoot);
78 if (m_wHorizontalCameraSpeedCheckbox)
79 {
80 bool value;
81 editorCameraSettings.Get(CAMERA_MOVE_ATL, value);
82
83 m_wHorizontalCameraSpeedCheckbox.SetCurrentItem(value, false, false);
84 m_wHorizontalCameraSpeedCheckbox.m_OnChanged.Insert(SetHorizontalCameraSpeed);
85 }
86 else
87 {
88 Print("Editor setting 'HorizontalCameraSpeed' not found", LogLevel.WARNING);
89 }
90
91 m_wATLSpeedCheckbox = SCR_SelectionWidgetComponent.GetSelectionComponent("ATLSpeed", m_wRoot);
92 if (m_wATLSpeedCheckbox)
93 {
94 bool value;
95 editorCameraSettings.Get(CAMERA_SPEED_ATL, value);
96
97 m_wATLSpeedCheckbox.SetCurrentItem(value, false, false);
98 m_wATLSpeedCheckbox.SetEnabled(m_wHorizontalCameraSpeedCheckbox.GetCurrentIndex() > 0);
99
100 m_wATLSpeedCheckbox.m_OnChanged.Insert(SetATLSpeed);
101
102 //Indent
103 TextWidget text = TextWidget.Cast(m_wATLSpeedCheckbox.GetLabelWidget());
104
105 if (text)
106 text.SetTextOffset(20, 0);
107 }
108 else
109 {
110 Print("Editor setting 'ATLSpeed' not found", LogLevel.WARNING);
111 }
112
113 //Todo: Add formatting. Add slider UI
114 m_wSpeedCoefSlider = SCR_SliderComponent.GetSliderComponent("SpeedCoef", m_wRoot);
115 if (m_wSpeedCoefSlider)
116 {
117 m_wSpeedCoefSlider.SetSliderSettings(0.1, 10, 0.05, "#AR-ValueUnit_Short_Multiplier");
118 float value;
119 editorCameraSettings.Get(CAMERA_SPEED_COEF, value);
120
121 m_wSpeedCoefSlider.SetValue(value);
122 m_wSpeedCoefSlider.ShowCustomValue(GetSliderText(value, 2));
123 m_wSpeedCoefSlider.m_OnChanged.Insert(SetSpeedCoef);
124 }
125 else
126 {
127 Print("Editor setting 'SpeedCoef' not found", LogLevel.WARNING);
128 }
129
130 SCR_SelectionWidgetComponent wb_CameraAboveTerrain = SCR_SelectionWidgetComponent.GetSelectionComponent("WB_CameraAboveTerrain", m_wRoot);
131 if (wb_CameraAboveTerrain)
132 {
133 bool value;
134 editorCameraSettings.Get(CAMERA_ABOVE_TERRAIN, value);
135
136 wb_CameraAboveTerrain.SetCurrentItem(value, false, false);
137 wb_CameraAboveTerrain.m_OnChanged.Insert(SetCameraAboveTerrain);
138 }
139 else
140 {
141 Print("Editor setting 'WB_CameraAboveTerrain' not found", LogLevel.WARNING);
142 }
143
144 SCR_SelectionWidgetComponent wb_CameraRotateWithModifier = SCR_SelectionWidgetComponent.GetSelectionComponent("WB_CameraRotateWithModifier", m_wRoot);
145 if (wb_CameraRotateWithModifier)
146 {
147 bool value;
148 editorCameraSettings.Get(CAMERA_ROTATE_WITH_MODIFIER, value);
149
150 wb_CameraRotateWithModifier.SetCurrentItem(value, false, false);
151 wb_CameraRotateWithModifier.m_OnChanged.Insert(SetCameraRotateWithModifier);
152 }
153 else
154 {
155 Print("Editor setting 'm_bCameraRotateWithModifier' not found", LogLevel.WARNING);
156 }
157
159 if (showIdentityTooltip)
160 {
161 bool state;
162 editorSettings.Get(SHOW_IDENTITY_BIO_TOOLTIP, state);
163
164 showIdentityTooltip.SetCurrentItem(state, false, false);
165 showIdentityTooltip.m_OnChanged.Insert(SetShowIdentityTooltip);
166 }
167
168 //Workbench only
169 #ifndef WORKBENCH
170 Widget wb_Seperator = m_wRoot.FindAnyWidget("WB_Separator");
171 if (wb_Seperator) wb_Seperator.SetVisible(false);
172 if (wb_CameraAboveTerrain) wb_CameraAboveTerrain.GetRootWidget().SetVisible(false);
173 if (wb_CameraRotateWithModifier) wb_CameraRotateWithModifier.GetRootWidget().SetVisible(false);
174 #endif
175
176 }
177
178 //------------------------------------------------------------------------------------------------
179 void SetEnableLayerEditing(SCR_SelectionWidgetComponent checkBox, bool state)
180 {
181 BaseContainer editorSettings = GetGame().GetGameUserSettings().GetModule("SCR_EditorSettings");
182 if (!editorSettings)
183 return;
184
185 editorSettings.Set(LAYER_EDITING, state);
186 //SCR_AnalyticsApplication.GetInstance().ChangeSetting(GAME_MASTER, LAYER_EDITING);
187
188 GetGame().UserSettingsChanged();
189 }
190
191 void SetVerticalSnap(SCR_SelectionWidgetComponent checkBox, bool state)
192 {
193 BaseContainer editorSettings = GetGame().GetGameUserSettings().GetModule("SCR_EditorSettings");
194 if (!editorSettings)
195 return;
196
197 editorSettings.Set(PREVIEW_VERTICAL_SNAP, state);
198 //SCR_AnalyticsApplication.GetInstance().ChangeSetting(GAME_MASTER, PREVIEW_VERTICAL_SNAP);
199
200 GetGame().UserSettingsChanged();
201 }
202
203 void SetVerticalMode(SCR_SelectionWidgetComponent checkBox, int state)
204 {
205 BaseContainer editorSettings = GetGame().GetGameUserSettings().GetModule("SCR_EditorSettings");
206 if (!editorSettings)
207 return;
208
209 state = 1 << state; //--- Shift the value, because it's a flag
210
211 editorSettings.Set(PREVIEW_VERTICLE_MODE, state);
212 //SCR_AnalyticsApplication.GetInstance().ChangeSetting(GAME_MASTER, PREVIEW_VERTICLE_MODE);
213
214 GetGame().UserSettingsChanged();
215
217 if (!previewComponent)
218 return;
219
220 previewComponent.SetVerticalMode(state);
221 }
222
223 //------------------------------------------------------------------------------------------------
224 void SetHorizontalCameraSpeed(SCR_SelectionWidgetComponent checkBox, bool state)
225 {
226 m_wATLSpeedCheckbox.SetEnabled(state);
227
228 BaseContainer settings = GetGame().GetGameUserSettings().GetModule("SCR_ManualCameraSettings");
229 if (!settings)
230 return;
231
232 settings.Set(CAMERA_MOVE_ATL, state);
233 //SCR_AnalyticsApplication.GetInstance().ChangeSetting(GAME_MASTER, CAMERA_MOVE_ATL);
234
235 GetGame().UserSettingsChanged();
236 }
237
238 //------------------------------------------------------------------------------------------------
239 void SetATLSpeed(SCR_SelectionWidgetComponent checkBox, bool state)
240 {
241 BaseContainer settings = GetGame().GetGameUserSettings().GetModule("SCR_ManualCameraSettings");
242 if (!settings)
243 return;
244
245 settings.Set(CAMERA_SPEED_ATL, state);
246 //SCR_AnalyticsApplication.GetInstance().ChangeSetting(GAME_MASTER, CAMERA_SPEED_ATL);
247
248 GetGame().UserSettingsChanged();
249 }
250
251 //------------------------------------------------------------------------------------------------
252 void SetSpeedCoef(SCR_SliderComponent slider, float value)
253 {
254 m_wSpeedCoefSlider.ShowCustomValue(GetSliderText(value, 2));
255
256 BaseContainer settings = GetGame().GetGameUserSettings().GetModule("SCR_ManualCameraSettings");
257 if (!settings)
258 return;
259
260 settings.Set(CAMERA_SPEED_COEF, value);
261 //SCR_AnalyticsApplication.GetInstance().ChangeSetting(GAME_MASTER, CAMERA_SPEED_COEF);
262
263 GetGame().UserSettingsChanged();
264 }
265
266 //------------------------------------------------------------------------------------------------
267 void SetCameraAboveTerrain(SCR_SelectionWidgetComponent checkBox, bool state)
268 {
269 BaseContainer settings = GetGame().GetGameUserSettings().GetModule("SCR_ManualCameraSettings");
270 if (!settings)
271 return;
272
273 settings.Set(CAMERA_ABOVE_TERRAIN, state);
274 //SCR_AnalyticsApplication.GetInstance().ChangeSetting(GAME_MASTER, CAMERA_ABOVE_TERRAIN);
275
276 GetGame().UserSettingsChanged();
277 }
278
279 //------------------------------------------------------------------------------------------------
280 void SetCameraRotateWithModifier(SCR_SelectionWidgetComponent checkBox, bool state)
281 {
282 BaseContainer settings = GetGame().GetGameUserSettings().GetModule("SCR_ManualCameraSettings");
283 if (!settings)
284 return;
285
286 settings.Set(CAMERA_ROTATE_WITH_MODIFIER, state);
287 //SCR_AnalyticsApplication.GetInstance().ChangeSetting(GAME_MASTER, CAMERA_ROTATE_WITH_MODIFIER);
288
289 GetGame().UserSettingsChanged();
290 }
291
292 //------------------------------------------------------------------------------------------------
293 protected void SetShowIdentityTooltip(SCR_SelectionWidgetComponent checkBox, bool state)
294 {
295 BaseContainer editorSettings = GetGame().GetGameUserSettings().GetModule("SCR_EditorSettings");
296 if (!editorSettings)
297 return;
298
299 editorSettings.Set(SHOW_IDENTITY_BIO_TOOLTIP, state);
300 //SCR_AnalyticsApplication.GetInstance().ChangeSetting(GAME_MASTER, SHOW_IDENTITY_BIO_TOOLTIP);
301
302 GetGame().UserSettingsChanged();
303 }
304
305 string GetSliderText(float value, int decimals)
306 {
307 float coef = Math.Pow(10, decimals);
308 value = Math.Round(value * coef);
309 string valueText = value.ToString();
310 if (decimals > 0)
311 {
312 for (int i = 0, count = decimals - valueText.Length() + 1; i < count; i++)
313 {
314 valueText = "0" + valueText;
315 }
316 int length = valueText.Length();
317 valueText = valueText.Substring(0, length - decimals) + "." + valueText.Substring(length - decimals, decimals);
318 }
319
320 return valueText;
321 }
322};
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
Definition Math.c:13
string GetSliderText(float value, int decimals)
void SetShowIdentityTooltip(SCR_SelectionWidgetComponent checkBox, bool state)
void SetVerticalMode(EEditorTransformVertical mode)
bool SetCurrentItem(int i, bool playSound=false, bool animate=false)
static SCR_SelectionWidgetComponent GetSelectionComponent(string name, Widget parent, bool searchAllChildren=true)
static SCR_SliderComponent GetSliderComponent(string name, Widget parent, bool searchAllChildren=true)
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
Definition LogLevel.c:14