Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
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  //------------------------------------------------------------------------------------------------
9  override void OnTabCreate(Widget menuRoot, ResourceName buttonsLayout, int index)
10  {
11  BaseContainer editorCameraSettings = GetGame().GetGameUserSettings().GetModule("SCR_ManualCameraSettings");
12  BaseContainer editorSettings = GetGame().GetGameUserSettings().GetModule("SCR_EditorSettings");
13 
14  super.OnTabCreate(menuRoot, buttonsLayout, index);
15 
16  if (!editorCameraSettings)
17  return;
18  if (!editorSettings)
19  return;
20 
21  //Layer Editing
22  SCR_SelectionWidgetComponent checkBox = SCR_SelectionWidgetComponent.GetSelectionComponent("LayerEditing", m_wRoot);
23  if (checkBox)
24  {
25  bool state;
26  editorSettings.Get("m_bLayerEditing", state);
27 
28  checkBox.SetCurrentItem(state, false, false);
29  checkBox.m_OnChanged.Insert(SetEnableLayerEditing);
30  }
31  else
32  {
33  Print("Editor setting 'LayerEditing' not found", LogLevel.WARNING);
34  }
35 
36  //Snap to terrain
37  checkBox = SCR_SelectionWidgetComponent.GetSelectionComponent("VerticalSnap", m_wRoot);
38  if (checkBox)
39  {
40  int value;
41  editorSettings.Get("m_PreviewVerticalSnap", value);
42 
43  checkBox.SetCurrentItem(value, false, false);
44  checkBox.m_OnChanged.Insert(SetVerticalSnap);
45  }
46  else
47  {
48  Print("Editor setting 'VerticalSnap' not found", LogLevel.WARNING);
49  }
50 
51  //Orient to terrain
52  checkBox = SCR_SelectionWidgetComponent.GetSelectionComponent("VerticalOrientation", m_wRoot);
53  if (checkBox)
54  {
55  int value;
56  editorSettings.Get("m_PreviewVerticleMode", value);
57 
58  checkBox.SetCurrentItem(value >> 1, false, false); //--- Shift the value, because it's a flag
59  checkBox.m_OnChanged.Insert(SetVerticalMode);
60  }
61  else
62  {
63  Print("Editor setting 'VerticalOrientation' not found", LogLevel.WARNING);
64  }
65 
66  m_wHorizontalCameraSpeedCheckbox = SCR_SelectionWidgetComponent.GetSelectionComponent("HorizontalCameraSpeed", m_wRoot);
67  if (m_wHorizontalCameraSpeedCheckbox)
68  {
69  bool value;
70  editorCameraSettings.Get("m_bCameraMoveATL", value);
71 
72  m_wHorizontalCameraSpeedCheckbox.SetCurrentItem(value, false, false);
73  m_wHorizontalCameraSpeedCheckbox.m_OnChanged.Insert(SetHorizontalCameraSpeed);
74  }
75  else
76  {
77  Print("Editor setting 'HorizontalCameraSpeed' not found", LogLevel.WARNING);
78  }
79 
80  m_wATLSpeedCheckbox = SCR_SelectionWidgetComponent.GetSelectionComponent("ATLSpeed", m_wRoot);
81  if (m_wATLSpeedCheckbox)
82  {
83  bool value;
84  editorCameraSettings.Get("m_bCameraSpeedATL", value);
85 
86  m_wATLSpeedCheckbox.SetCurrentItem(value, false, false);
87  m_wATLSpeedCheckbox.SetEnabled(m_wHorizontalCameraSpeedCheckbox.GetCurrentIndex() > 0);
88 
89  m_wATLSpeedCheckbox.m_OnChanged.Insert(SetATLSpeed);
90 
91  //Indent
92  TextWidget text = TextWidget.Cast(m_wATLSpeedCheckbox.GetLabelWidget());
93 
94  if (text)
95  text.SetTextOffset(20, 0);
96  }
97  else
98  {
99  Print("Editor setting 'ATLSpeed' not found", LogLevel.WARNING);
100  }
101 
102  //Todo: Add formatting. Add slider UI
103  m_wSpeedCoefSlider = SCR_SliderComponent.GetSliderComponent("SpeedCoef", m_wRoot);
104  if (m_wSpeedCoefSlider)
105  {
106  m_wSpeedCoefSlider.SetSliderSettings(0.1, 10, 0.05, "#AR-ValueUnit_Short_Multiplier");
107  float value;
108  editorCameraSettings.Get("m_fCameraSpeedCoef", value);
109 
110  m_wSpeedCoefSlider.SetValue(value);
111  m_wSpeedCoefSlider.ShowCustomValue(GetSliderText(value, 2));
112  m_wSpeedCoefSlider.m_OnChanged.Insert(SetSpeedCoef);
113  }
114  else
115  {
116  Print("Editor setting 'SpeedCoef' not found", LogLevel.WARNING);
117  }
118 
119  SCR_SelectionWidgetComponent wb_CameraAboveTerrain = SCR_SelectionWidgetComponent.GetSelectionComponent("WB_CameraAboveTerrain", m_wRoot);
120  if (wb_CameraAboveTerrain)
121  {
122  bool value;
123  editorCameraSettings.Get("m_bCameraAboveTerrain", value);
124 
125  wb_CameraAboveTerrain.SetCurrentItem(value, false, false);
126  wb_CameraAboveTerrain.m_OnChanged.Insert(SetCameraAboveTerrain);
127  }
128  else
129  {
130  Print("Editor setting 'WB_CameraAboveTerrain' not found", LogLevel.WARNING);
131  }
132 
133  SCR_SelectionWidgetComponent wb_CameraRotateWithModifier = SCR_SelectionWidgetComponent.GetSelectionComponent("WB_CameraRotateWithModifier", m_wRoot);
134  if (wb_CameraRotateWithModifier)
135  {
136  bool value;
137  editorCameraSettings.Get("m_bCameraRotateWithModifier", value);
138 
139  wb_CameraRotateWithModifier.SetCurrentItem(value, false, false);
140  wb_CameraRotateWithModifier.m_OnChanged.Insert(SetCameraRotateWithModifier);
141  }
142  else
143  {
144  Print("Editor setting 'm_bCameraRotateWithModifier' not found", LogLevel.WARNING);
145  }
146 
147 
148  //Workbench only
149  #ifndef WORKBENCH
150  Widget wb_Seperator = m_wRoot.FindAnyWidget("WB_Separator");
151  if (wb_Seperator) wb_Seperator.SetVisible(false);
152  if (wb_CameraAboveTerrain) wb_CameraAboveTerrain.GetRootWidget().SetVisible(false);
153  if (wb_CameraRotateWithModifier) wb_CameraRotateWithModifier.GetRootWidget().SetVisible(false);
154  #endif
155 
156  }
157 
158  //------------------------------------------------------------------------------------------------
159  void SetEnableLayerEditing(SCR_SelectionWidgetComponent checkBox, bool state)
160  {
161  BaseContainer editorSettings = GetGame().GetGameUserSettings().GetModule("SCR_EditorSettings");
162  if (!editorSettings)
163  return;
164 
165  editorSettings.Set("m_bLayerEditing", state);
166 
167  GetGame().UserSettingsChanged();
168  }
169 
170  void SetVerticalSnap(SCR_SelectionWidgetComponent checkBox, bool state)
171  {
172  BaseContainer editorSettings = GetGame().GetGameUserSettings().GetModule("SCR_EditorSettings");
173  if (!editorSettings)
174  return;
175 
176  editorSettings.Set("m_PreviewVerticalSnap", state);
177  GetGame().UserSettingsChanged();
178  }
179 
180  void SetVerticalMode(SCR_SelectionWidgetComponent checkBox, int state)
181  {
182  BaseContainer editorSettings = GetGame().GetGameUserSettings().GetModule("SCR_EditorSettings");
183  if (!editorSettings)
184  return;
185 
186  state = 1 << state; //--- Shift the value, because it's a flag
187 
188  editorSettings.Set("m_PreviewVerticleMode", state);
189  GetGame().UserSettingsChanged();
190 
192  if (!previewComponent)
193  return;
194 
195  previewComponent.SetVerticalMode(state);
196  }
197 
198  //------------------------------------------------------------------------------------------------
199  void SetHorizontalCameraSpeed(SCR_SelectionWidgetComponent checkBox, bool state)
200  {
201  m_wATLSpeedCheckbox.SetEnabled(state);
202 
203  BaseContainer settings = GetGame().GetGameUserSettings().GetModule("SCR_ManualCameraSettings");
204  if (!settings) return;
205  settings.Set("m_bCameraMoveATL", state);
206 
207  GetGame().UserSettingsChanged();
208  }
209 
210  //------------------------------------------------------------------------------------------------
211  void SetATLSpeed(SCR_SelectionWidgetComponent checkBox, bool state)
212  {
213  BaseContainer settings = GetGame().GetGameUserSettings().GetModule("SCR_ManualCameraSettings");
214  if (!settings) return;
215  settings.Set("m_bCameraSpeedATL", state);
216 
217  GetGame().UserSettingsChanged();
218  }
219 
220  //------------------------------------------------------------------------------------------------
221  void SetSpeedCoef(SCR_SliderComponent slider, float value)
222  {
223  m_wSpeedCoefSlider.ShowCustomValue(GetSliderText(value, 2));
224 
225  BaseContainer settings = GetGame().GetGameUserSettings().GetModule("SCR_ManualCameraSettings");
226  if (!settings) return;
227  settings.Set("m_fCameraSpeedCoef", value);
228 
229  GetGame().UserSettingsChanged();
230  }
231 
232  //------------------------------------------------------------------------------------------------
233  void SetCameraAboveTerrain(SCR_SelectionWidgetComponent checkBox, bool state)
234  {
235  BaseContainer settings = GetGame().GetGameUserSettings().GetModule("SCR_ManualCameraSettings");
236  if (!settings) return;
237  settings.Set("m_bCameraAboveTerrain", state);
238 
239  GetGame().UserSettingsChanged();
240  }
241 
242  //------------------------------------------------------------------------------------------------
243  void SetCameraRotateWithModifier(SCR_SelectionWidgetComponent checkBox, bool state)
244  {
245  BaseContainer settings = GetGame().GetGameUserSettings().GetModule("SCR_ManualCameraSettings");
246  if (!settings) return;
247  settings.Set("m_bCameraRotateWithModifier", state);
248 
249  GetGame().UserSettingsChanged();
250  }
251 
252  string GetSliderText(float value, int decimals)
253  {
254  float coef = Math.Pow(10, decimals);
255  value = Math.Round(value * coef);
256  string valueText = value.ToString();
257  if (decimals > 0)
258  {
259  for (int i = 0, count = decimals - valueText.Length() + 1; i < count; i++)
260  {
261  valueText = "0" + valueText;
262  }
263  int length = valueText.Length();
264  valueText = valueText.Substring(0, length - decimals) + "." + valueText.Substring(length - decimals, decimals);
265  }
266 
267  return valueText;
268  }
269 };
m_wRoot
protected Widget m_wRoot
Definition: SCR_ScenarioFrameworkLayerTaskDefend.c:59
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_SliderComponent
Definition: SCR_SliderComponent.c:2
index
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
Definition: SCR_DestructionSynchronizationComponent.c:17
SCR_EditorSettingsSubMenu
Definition: SCR_EditorSettingsSubMenu.c:2
SCR_SelectionWidgetComponent
Definition: SCR_SelectionWidgetComponent.c:1
SCR_SettingsSubMenuBase
Definition: SCR_SettingsSubMenuBase.c:1
SCR_PreviewEntityEditorComponent
Definition: SCR_PreviewEntityEditorComponent.c:12