Arma Reforger Explorer
1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Toggle main menu visibility
Loading...
Searching...
No Matches
SCR_VideoSettingsSubMenu.c
Go to the documentation of this file.
1
enum
EWindowMode
2
{
3
FULLSCREEN
= 0,
// keep order in the enum
4
WINDOWED
,
5
MAXIMIZED
,
6
BORDERLESS
,
7
};
8
9
/*
10
enum EAspectRatio
11
{
12
ASPECT_RATIO_AUTO = 0, // keep order in the enum
13
ASPECT_RATIO_16_9,
14
ASPECT_RATIO_16_10,
15
ASPECT_RATIO_4_3,
16
ASPECT_RATIO_5_4,
17
ASPECT_RATIO_32_9,
18
ASPECT_RATIO_48_9,
19
};
20
// */
21
22
class
SCR_VideoSettingsSubMenu
:
SCR_SettingsSubMenuBase
23
{
24
protected
ref array<int>
m_aWidths
= {};
25
protected
ref array<int>
m_aHeights
= {};
26
protected
ref array<int>
m_aAAvalues
= { 0, 2, 4, 8, 16, 32 };
27
28
protected
SCR_ComboBoxComponent
m_ResolutionCombo
;
29
protected
SCR_SliderComponent
m_ResolutionScale
;
30
// protected SCR_ComboBoxComponent m_AspectRatio;
31
protected
SCR_SpinBoxComponent
m_WindowMode
;
32
protected
SCR_SpinBoxComponent
m_MaxFPS
;
33
34
protected
string
m_sResolutionScaleLocalisation
=
"#AR-Settings_RenderScale"
;
35
36
protected
UserSettings
m_Video
;
37
protected
UserSettings
m_Pipeline
;
38
protected
UserSettings
m_ResourceManager
;
39
40
protected
static
const
string
RESOLUTION_FORMAT
=
"%1 × %2"
;
41
protected
static
const
int
CUSTOM_PRESET_INDEX
= 4;
// 4 is the custom option for quality preset
42
44
protected
static
const
ref array<string>
PRESET_SETTINGS
= {
45
/*
46
the following settings are out of presets; they were not forgotten:
47
"WindowMode"
48
"Resolution"
49
"ResolutionScale"
50
"AspectRatio"
51
"VSync"
52
"MaxFPS"
53
"DOF" // scripted
54
"NearDOF" // scripted
55
*/
56
"Detail"
,
57
"DistantShadows"
,
58
"EnvironmentQuality"
,
59
"FoliageSmoothing"
,
60
"GeometricDetail"
,
61
"GrassDistance"
,
62
"GrassLOD"
,
63
"HardwareAA"
,
64
"HBAO"
,
// ambient occlusion
65
"ObjectDrawDistance"
,
66
"PostprocessAA"
,
67
"RenderTargetFormat"
,
68
"ShadowQuality"
,
69
"SSDO"
,
// contact shadow
70
"SSR"
,
// post-process quality
71
// "TerrainDetail", //disabled setting for now
72
"TerrainSurfaceDetail"
,
73
"TextureDetail"
,
74
"TextureFiltering"
,
75
};
76
77
//------------------------------------------------------------------------------------------------
78
override
void
OnMenuItemChanged
(
SCR_SettingsBindingBase
binding)
79
{
80
// ignore this if we are loading settings
81
if
(
m_bLoadingSettings
)
82
return
;
83
84
if
(binding)
85
SetQualityPresetIndex
(binding.
GetWidgetName
());
86
87
super.OnMenuItemChanged(binding);
88
}
89
90
//------------------------------------------------------------------------------------------------
91
protected
void
OnCustomMenuItemChanged
(
string
widgetName)
92
{
93
OnMenuItemChanged
(
new
SCR_SettingsBindingBase
(
""
,
""
, widgetName));
94
//SCR_AnalyticsApplication.GetInstance().ChangeSetting("Video", widgetName);
95
}
96
97
//------------------------------------------------------------------------------------------------
98
protected
void
SetQualityPresetIndex
(
string
changedSetting)
99
{
100
if
(!
PRESET_SETTINGS
.Contains(changedSetting))
101
return
;
102
103
SCR_ComboBoxComponent
qualityPreset =
SCR_ComboBoxComponent
.GetComboBoxComponent(
"QualityPreset"
,
m_wRoot
);
104
if
(qualityPreset)
105
qualityPreset.
SetCurrentItem
(
CUSTOM_PRESET_INDEX
);
106
107
BaseContainer
display =
GetGame
().GetEngineUserSettings().GetModule(
"DisplayUserSettings"
);
108
display.Set(
"OverallQuality"
,
CUSTOM_PRESET_INDEX
);
109
}
110
111
//------------------------------------------------------------------------------------------------
112
override
void
OnTabCreate
(
Widget
menuRoot,
ResourceName
buttonsLayout,
int
index
)
113
{
114
super.OnTabCreate(menuRoot, buttonsLayout,
index
);
115
116
m_ResourceManager
=
GetGame
().GetEngineUserSettings().GetModule(
"ResourceManagerUserSettings"
);
117
m_Pipeline
=
GetGame
().GetEngineUserSettings().GetModule(
"PipelineUserSettings"
);
118
m_Video
=
GetGame
().GetEngineUserSettings().GetModule(
"VideoUserSettings"
);
119
120
m_ResolutionScale
=
SCR_SliderComponent
.
GetSliderComponent
(
"ResolutionScale"
,
m_wRoot
);
121
m_ResolutionCombo
=
SCR_ComboBoxComponent
.GetComboBoxComponent(
"Resolution"
,
m_wRoot
);
122
// m_AspectRatio = SCR_ComboBoxComponent.GetComboBoxComponent("AspectRatio", m_wRoot);
123
m_WindowMode
=
SCR_SpinBoxComponent
.
GetSpinBoxComponent
(
"WindowMode"
,
m_wRoot
);
124
m_MaxFPS
=
SCR_SpinBoxComponent
.
GetSpinBoxComponent
(
"MaxFPS"
,
m_wRoot
);
125
126
SCR_ComboBoxComponent
aspectRatio =
SCR_ComboBoxComponent
.GetComboBoxComponent(
"AspectRatio"
,
m_wRoot
);
127
if
(aspectRatio)
128
aspectRatio.SetVisible(
false
);
129
130
// Create bindings and load all standard entries
131
m_aSettingsBindings
.Clear();
132
133
m_aSettingsBindings
.Insert(
new
SCR_SettingBindingEngine
(
"ResourceManagerUserSettings"
,
"GeometricDetail"
,
"GeometricDetail"
));
134
m_aSettingsBindings
.Insert(
new
SCR_SettingBindingEngine
(
"TerrainGenMaterialSettings"
,
"GeometryLevel"
,
"TerrainDetail"
));
135
m_aSettingsBindings
.Insert(
new
SCR_SettingBindingEngine
(
"VideoUserSettings"
,
"Vsync"
,
"VSync"
));
136
137
m_aSettingsBindings
.Insert(
new
SCR_SettingBindingEngine
(
"GrassMaterialSettings"
,
"Lod"
,
"GrassLOD"
));
138
// We are using game settings to be able to override distance of grass
139
//m_aSettingsBindings.Insert(new SCR_SettingBindingEngine("GrassMaterialSettings", "Distance", "GrassDistance"));
140
m_aSettingsBindings
.Insert(
new
SCR_SettingBindingEngine
(
"TerrainGenMaterialSettings"
,
"Detail"
,
"TerrainSurfaceDetail"
));
141
m_aSettingsBindings
.Insert(
new
SCR_SettingBindingEngine
(
"MaterialSystemUserSettings"
,
"TextureFilter"
,
"TextureFiltering"
));
142
143
m_aSettingsBindings
.Insert(
new
SCR_SettingBindingEngine
(
"GraphicsQualitySettings"
,
"ObjectDrawDistanceScale"
,
"ObjectDrawDistance"
));
144
m_aSettingsBindings
.Insert(
new
SCR_SettingBindingEngine
(
"VideoUserSettings"
,
"Atoc"
,
"FoliageSmoothing"
));
145
m_aSettingsBindings
.Insert(
new
SCR_SettingBindingEngine
(
"VideoUserSettings"
,
"ResolutionScale"
,
"ResolutionScale"
));
146
m_aSettingsBindings
.Insert(
new
SCR_SettingBindingEngine
(
"VideoUserSettings"
,
"FsrEnabled"
,
"FSR"
));
147
m_aSettingsBindings
.Insert(
new
SCR_SettingBindingEngine
(
"VideoUserSettings"
,
"RenderFormat"
,
"RenderTargetFormat"
));
148
m_aSettingsBindings
.Insert(
new
SCR_SettingBindingEngine
(
"VideoUserSettings"
,
"DistantShadowsQuality"
,
"DistantShadows"
));
149
m_aSettingsBindings
.Insert(
new
SCR_SettingBindingEngine
(
"VideoUserSettings"
,
"EnvironmentQuality"
,
"EnvironmentQuality"
));
150
m_aSettingsBindings
.Insert(
new
SCR_SettingBindingEngine
(
"DisplayUserSettings"
,
"OverallQuality"
,
"QualityPreset"
));
151
152
// Post-process settings
153
m_aSettingsBindings
.Insert(
new
SCR_SettingBindingEngine
(
"DisplayUserSettings"
,
"PPAA"
,
"PostprocessAA"
,
"PPQuality"
));
154
m_aSettingsBindings
.Insert(
new
SCR_SettingBindingEngine
(
"DisplayUserSettings"
,
"HBAO"
,
"HBAO"
,
"PPQuality"
));
155
m_aSettingsBindings
.Insert(
new
SCR_SettingBindingEngine
(
"DisplayUserSettings"
,
"SSDO"
,
"SSDO"
,
"PPQuality"
));
156
m_aSettingsBindings
.Insert(
new
SCR_SettingBindingEngine
(
"DisplayUserSettings"
,
"SSR"
,
"SSR"
,
"PPQuality"
));
157
m_aSettingsBindings
.Insert(
new
SCR_SettingBindingGameplay
(
"SCR_VideoSettings"
,
"m_iDofType"
,
"DOF"
));
158
m_aSettingsBindings
.Insert(
new
SCR_SettingBindingGameplay
(
"SCR_VideoSettings"
,
"m_bNearDofEffect"
,
"NearDOF"
));
159
160
// Other settings
161
m_aSettingsBindings
.Insert(
new
SCR_SettingBindingGameplay
(
"SCR_GameplaySettings"
,
"m_b2DScopes"
,
"ScopeMode"
));
162
m_aSettingsBindings
.Insert(
new
SCR_SettingBindingEngine
(
"UserInterfaceSettings"
,
"UseSoftwareCursor"
,
"CursorMode"
));
163
164
LoadSettings
();
165
166
SetupQualityPreset
();
167
SetupViewDistance
();
168
SetupGrassDistance
();
169
SetupResolution
();
170
SetupResolutionScale
();
171
SetupShadowQuality
();
172
SetupHardwareAA
();
173
SetupTextureDetail
();
174
SetupMaxFPS
();
175
176
HandleDescription
();
177
178
RemoveQualityPresetFocus
();
179
180
// TODO: bind OnRenderResolutionChanged when Alt+Enter event (non-existing atm) is triggered
181
}
182
183
//------------------------------------------------------------------------------------------------
184
protected
void
SetupTextureDetail
(
bool
isInit =
true
)
185
{
186
if
(!
m_ResourceManager
)
187
return
;
188
189
SCR_SpinBoxComponent
textureDetail =
SCR_SpinBoxComponent
.
GetSpinBoxComponent
(
"TextureDetail"
,
m_wRoot
);
190
if
(!textureDetail)
191
return
;
192
193
const
float
item;
// TODO: check for good const usage
194
float
value, min, max, step;
195
m_ResourceManager
.Get(
"TextureDetail"
, value);
196
m_ResourceManager
.GetLimits(item, min, max, step);
197
198
int
current = (max - value);
199
textureDetail.
SetCurrentItem
(current);
200
201
if
(isInit)
202
textureDetail.m_OnChanged.Insert(
OnTextureDetailChanged
);
203
}
204
205
//------------------------------------------------------------------------------------------------
207
protected
void
OnMaxFPSChanged
(
SCR_SpinBoxComponent
comp,
int
i)
208
{
209
if
(!comp || !
m_MaxFPS
|| !
m_Video
)
210
return
;
211
212
bool
isEnabled =
m_MaxFPS
.GetCurrentIndex();
213
214
int
value = 0;
215
if
(isEnabled)
216
value =
m_MaxFPS
.GetCurrentItem().ToInt();
217
218
m_Video
.Set(
"MaxFps"
, value);
219
220
OnCustomMenuItemChanged
(
"MaxFPS"
);
221
}
222
223
//------------------------------------------------------------------------------------------------
225
protected
void
OnTextureDetailChanged
(
SCR_SpinBoxComponent
comp,
int
i)
226
{
227
if
(!
m_ResourceManager
)
228
return
;
229
230
const
float
item;
// TODO: check for good const usage
231
float
min, max, step;
232
m_ResourceManager
.GetLimits(item, min, max, step);
233
234
int
current = max - i;
235
m_ResourceManager
.Set(
"TextureDetail"
, current);
236
237
OnCustomMenuItemChanged
(
"TextureDetail"
);
238
}
239
240
//------------------------------------------------------------------------------------------------
241
protected
void
OnQualityPresetChanged
(
SCR_ComboBoxComponent
combobox,
int
itemIndex)
242
{
243
if
(
m_bLoadingSettings
)
244
return
;
245
246
if
(combobox.GetCurrentIndex() ==
CUSTOM_PRESET_INDEX
)
247
return
;
248
249
GetGame
().ApplySettingsPreset();
250
GetGame
().UserSettingsChanged();
251
LoadSettings
(
true
,
false
);
252
253
// all scripted widgets have to be manually done here
254
m_bLoadingSettings
=
true
;
255
256
SetupHardwareAA
(
false
);
257
SetupTextureDetail
(
false
);
258
SetupShadowQuality
(
false
);
259
260
m_bLoadingSettings
=
false
;
261
262
//SCR_AnalyticsApplication.GetInstance().SetQualityPresetSetting(itemIndex);
263
}
264
265
//------------------------------------------------------------------------------------------------
266
protected
void
SetupQualityPreset
()
267
{
268
SCR_ComboBoxComponent
qualityPreset =
SCR_ComboBoxComponent
.GetComboBoxComponent(
"QualityPreset"
,
m_wRoot
);
269
if
(!qualityPreset)
270
return
;
271
272
qualityPreset.m_OnChanged.Insert(
OnQualityPresetChanged
);
273
}
274
275
//------------------------------------------------------------------------------------------------
276
protected
void
SetupHardwareAA
(
bool
isInit =
true
)
277
{
278
if
(!
m_Video
)
279
return
;
280
281
SCR_SpinBoxComponent
antiAliasing =
SCR_SpinBoxComponent
.
GetSpinBoxComponent
(
"HardwareAA"
,
m_wRoot
);
282
if
(!antiAliasing)
283
return
;
284
285
//#ifdef PLATFORM_CONSOLE
286
// TODO: ifdefs are ugly and messy, make proper solution using menu configs and UI prefabs
287
//antiAliasing.GetRootWidget().SetVisible(false);
288
//return;
289
//#endif
290
291
int
value;
292
m_Video
.Get(
"Fsaa"
, value);
293
294
int
i =
m_aAAvalues
.Find(value);
295
if
(i > -1)
296
antiAliasing.
SetCurrentItem
(i);
297
298
if
(isInit)
299
antiAliasing.m_OnChanged.Insert(
OnHardwareAAChanged
);
300
301
SCR_SpinBoxComponent
foliageSmoothing =
SCR_SpinBoxComponent
.
GetSpinBoxComponent
(
"FoliageSmoothing"
,
m_wRoot
);
302
if
(foliageSmoothing && i == 0)
303
foliageSmoothing.SetEnabled(
false
);
304
}
305
306
//------------------------------------------------------------------------------------------------
308
protected
void
OnHardwareAAChanged
(
SCR_SpinBoxComponent
comp,
int
i)
309
{
310
if
(!
m_Video
|| i < 0 || i >=
m_aAAvalues
.Count())
311
return
;
312
313
m_Video
.Set(
"Fsaa"
,
m_aAAvalues
[i]);
314
315
SCR_SpinBoxComponent
foliageSmoothing =
SCR_SpinBoxComponent
.
GetSpinBoxComponent
(
"FoliageSmoothing"
,
m_wRoot
);
316
if
(foliageSmoothing)
317
foliageSmoothing.SetEnabled(i > 0);
318
319
OnCustomMenuItemChanged
(
"HardwareAA"
);
320
}
321
322
//------------------------------------------------------------------------------------------------
324
protected
void
OnResolutionScaleChanged
(
SCR_SliderComponent
comp,
float
value)
325
{
326
value =
Math
.Round(value * 100);
327
328
comp.
ShowCustomValue
(value.ToString());
329
330
OnRenderResolutionChanged
();
331
332
OnCustomMenuItemChanged
(
"ResolutionScale"
);
333
}
334
335
//------------------------------------------------------------------------------------------------
337
protected
void
OnRenderResolutionChanged
()
338
{
339
if
(!
m_ResolutionScale
|| !
m_sResolutionScaleLocalisation
)
340
return
;
341
342
TextWidget
labelWidget =
m_ResolutionScale
.GetLabel();
343
if
(!labelWidget)
344
return
;
345
346
float
uiResWidth, uiResHeight;
347
int
renderResWidth, renderResHeight;
348
GetGame
().GetWorkspace().GetScreenSize(uiResWidth, uiResHeight);
349
float
scale
=
m_ResolutionScale
.GetValue();
350
renderResWidth =
Math
.Round(uiResWidth *
scale
);
351
renderResHeight =
Math
.Round(uiResHeight *
scale
);
352
353
labelWidget.SetTextFormat(
m_sResolutionScaleLocalisation
, renderResWidth, renderResHeight);
354
}
355
356
//------------------------------------------------------------------------------------------------
358
protected
void
OnShadowDetailChanged
(
SCR_SpinBoxComponent
comp,
int
i)
359
{
360
if
(!
m_Pipeline
)
361
return
;
362
363
m_Pipeline
.Set(
"ShadowQuality"
, i + 1);
364
OnCustomMenuItemChanged
(
"ShadowQuality"
);
365
}
366
367
//------------------------------------------------------------------------------------------------
369
protected
void
OnViewDistanceChanged
(
SCR_SliderComponent
comp,
float
value)
370
{
371
GetGame
().SetViewDistance(value);
372
// Get desired type of DOF
373
BaseContainer
m_VideoSettings =
GetGame
().GetGameUserSettings().GetModule(
"SCR_VideoSettings"
);
374
if
(m_VideoSettings)
375
{
376
m_VideoSettings.Set(
"m_iViewDistance"
, value);
377
}
378
OnCustomMenuItemChanged
(
"DrawDistance"
);
379
}
380
381
//------------------------------------------------------------------------------------------------
382
protected
void
OnGrassDistanceChanged
(
SCR_SliderComponent
comp,
float
value)
383
{
384
GetGame
().SetGrassDistance(value);
385
OnCustomMenuItemChanged
(
"GrassDistance"
);
386
}
387
388
//------------------------------------------------------------------------------------------------
390
protected
void
OnWindowModeChanged
(
SCR_SpinBoxComponent
comp,
int
index
)
391
{
392
if
(!
m_Video
|| !
m_ResolutionCombo
|| !
m_ResolutionScale
)
393
return
;
394
395
bool
borderlessFullscreen = (
index
== 0);
396
397
m_ResolutionCombo
.GetRootWidget().SetVisible(!borderlessFullscreen);
398
m_ResolutionScale
.GetRootWidget().SetVisible(borderlessFullscreen);
399
400
int
nativeWidth, nativeHeight;
401
float
scale
;
402
403
if
(borderlessFullscreen)
404
{
405
// Set to borderless fulscreen
406
m_Video
.Set(
"WindowMode"
,
EWindowMode
.BORDERLESS);
407
408
SCR_ComboBoxComponent
combo =
SCR_ComboBoxComponent
.GetComboBoxComponent(
"Resolution"
,
m_wRoot
);
409
if
(!combo)
410
return
;
411
412
System
.GetNativeResolution(nativeWidth, nativeHeight);
413
int
i = combo.GetCurrentIndex();
414
scale
=
m_aWidths
[i] / nativeWidth;
415
m_Video
.Set(
"ResolutionScale"
,
scale
);
416
417
m_ResolutionScale
.SetValue(
scale
);
418
}
419
else
420
{
421
// Set to windowed mode
422
m_Video
.Set(
"WindowMode"
,
EWindowMode
.WINDOWED);
423
424
m_Video
.Get(
"ResolutionScale"
,
scale
);
425
System
.GetNativeResolution(nativeWidth, nativeHeight);
426
427
int
width = nativeWidth *
scale
;
428
int
bestDiff =
int
.MAX;
429
int
bestIdx = 0;
430
431
for
(
int
i, cnt =
m_aWidths
.Count(); i < cnt; i++)
432
{
433
int
diff =
Math
.AbsInt(
m_aWidths
[i] - width);
434
435
if
(diff < bestDiff)
436
{
437
bestDiff = diff;
438
bestIdx = i;
439
440
if
(diff == 0)
441
break
;
442
}
443
}
444
445
m_Video
.Set(
"ScreenWidth"
,
m_aWidths
[bestIdx]);
446
m_Video
.Set(
"ScreenHeight"
,
m_aHeights
[bestIdx]);
447
m_Video
.Set(
"ResolutionScale"
, 1.0);
448
449
SetResolutionCombo
(
m_ResolutionCombo
);
450
}
451
452
OnCustomMenuItemChanged
(
"WindowMode"
);
453
}
454
455
//------------------------------------------------------------------------------------------------
456
protected
void
SetResolutionCombo
(
SCR_ComboBoxComponent
combo)
457
{
458
if
(!
m_Video
)
459
return
;
460
461
int
scale
, nativeWidth, nativeHeight, width, height;
462
m_Video
.Get(
"ResolutionScale"
,
scale
);
463
m_Video
.Get(
"ScreenWidth"
, width);
464
m_Video
.Get(
"ScreenHeight"
, height);
465
System
.GetNativeResolution(nativeWidth, nativeHeight);
466
467
width = width *
scale
;
468
height = height *
scale
;
469
int
bestDiff =
int
.MAX;
470
int
bestIdx = 0;
471
472
for
(
int
i, cnt =
m_aWidths
.Count(); i < cnt; i++)
473
{
474
int
diff =
Math
.AbsInt(
m_aWidths
[i] - width);
475
476
if
(diff < bestDiff)
477
{
478
bestDiff = diff;
479
bestIdx = i;
480
if
(diff == 0)
481
break
;
482
}
483
}
484
485
int
bestDiffH =
int
.MAX;
486
int
bestIdxH = 0;
487
488
for
(
int
i, cnt =
m_aHeights
.Count(); i < cnt; i++)
489
{
490
int
diff =
Math
.AbsInt(
m_aHeights
[i] - height);
491
492
if
(diff < bestDiffH)
493
{
494
bestDiffH = diff;
495
bestIdxH = i;
496
if
(diff == 0)
497
break
;
498
}
499
}
500
501
string
resolutionStr =
string
.Format(
RESOLUTION_FORMAT
,
m_aWidths
[bestIdx],
m_aHeights
[bestIdxH]);
502
503
foreach
(
int
i,
string
elementName : combo.m_aElementNames)
504
{
505
if
(elementName != resolutionStr)
506
continue
;
507
508
combo.
SetCurrentItem
(i);
509
return
;
510
}
511
}
512
513
//------------------------------------------------------------------------------------------------
514
protected
void
SetupViewDistance
()
515
{
516
float
viewDistance;
517
SCR_SliderComponent
distance
=
SCR_SliderComponent
.
GetSliderComponent
(
"DrawDistance"
,
m_wRoot
);
518
if
(!
distance
)
519
return
;
520
521
float
min =
GetGame
().GetMinimumViewDistance();
522
float
max =
GetGame
().GetMaximumViewDistance();
523
524
// Get desired type of DOF
525
BaseContainer
m_VideoSettings =
GetGame
().GetGameUserSettings().GetModule(
"SCR_VideoSettings"
);
526
if
(m_VideoSettings)
527
{
528
m_VideoSettings.Get(
"m_iViewDistance"
, viewDistance);
529
GetGame
().SetViewDistance(viewDistance);
530
}
531
532
float
current =
GetGame
().GetViewDistance();
533
distance
.SetMin(min);
534
distance
.SetMax(max);
535
distance
.SetStep(50);
536
537
distance
.SetValue(current);
538
distance
.GetOnChangedFinal().Insert(
OnViewDistanceChanged
);
539
}
540
541
//------------------------------------------------------------------------------------------------
542
protected
void
SetupGrassDistance
()
543
{
544
SCR_SliderComponent
distance
=
SCR_SliderComponent
.
GetSliderComponent
(
"GrassDistance"
,
m_wRoot
);
545
if
(!
distance
)
546
return
;
547
548
int
min =
GetGame
().GetMinimumGrassDistance();
549
int
max =
GetGame
().GetMaximumGrassDistance();
550
int
current =
GetGame
().GetGrassDistance();
551
distance
.SetMin(min);
552
distance
.SetMax(max);
553
distance
.SetStep(1);
554
555
distance
.SetValue(current);
556
distance
.GetOnChangedFinal().Insert(
OnGrassDistanceChanged
);
557
}
558
559
//------------------------------------------------------------------------------------------------
560
protected
void
SetupShadowQuality
(
bool
isInit =
true
)
561
{
562
if
(!
m_Pipeline
)
563
return
;
564
// Shadow detail quality is little special, because we want to skip the lowest setting
565
SCR_SpinBoxComponent
shadowDetail =
SCR_SpinBoxComponent
.
GetSpinBoxComponent
(
"ShadowQuality"
,
m_wRoot
);
566
if
(!shadowDetail)
567
return
;
568
569
int
shadowQuality;
570
m_Pipeline
.Get(
"ShadowQuality"
, shadowQuality);
571
shadowDetail.
SetCurrentItem
(
Math
.ClampInt(shadowQuality - 1, 0, shadowDetail.GetNumItems() - 1));
572
573
if
(isInit)
574
shadowDetail.m_OnChanged.Insert(
OnShadowDetailChanged
);
575
}
576
577
//------------------------------------------------------------------------------------------------
578
protected
void
SetupResolution
()
579
{
580
if
(!
m_ResolutionCombo
|| !
m_ResolutionScale
|| !
m_WindowMode
|| !
m_Video
)
581
return
;
582
583
int
mode;
584
m_Video
.Get(
"WindowMode"
, mode);
585
586
// Hide resolutions if not in window mode
587
588
#ifdef PLATFORM_CONSOLE
589
bool
fullScreen =
true
;
590
bool
showWindowMode =
false
;
591
#else
592
bool
fullScreen = (mode !=
EWindowMode
.WINDOWED);
593
bool
showWindowMode =
true
;
594
#endif
595
596
#ifdef WORKBENCH
597
fullScreen =
true
;
598
showWindowMode =
false
;
599
#endif
600
601
if
(showWindowMode)
602
{
603
m_WindowMode
.SetCurrentItem(!fullScreen);
604
m_WindowMode
.m_OnChanged.Insert(
OnWindowModeChanged
);
605
}
606
607
m_WindowMode
.GetRootWidget().SetVisible(showWindowMode);
608
609
if
(
m_ResolutionScale
)
610
m_ResolutionScale
.GetRootWidget().SetVisible(fullScreen);
611
if
(
m_ResolutionCombo
)
612
m_ResolutionCombo
.GetRootWidget().SetVisible(!fullScreen);
613
614
System
.GetSupportedResolutions(
m_aWidths
,
m_aHeights
);
615
for
(
int
i = 0, cnt =
m_aWidths
.Count(); i < cnt; i++)
616
{
617
m_ResolutionCombo
.AddItem(
string
.Format(
RESOLUTION_FORMAT
,
m_aWidths
[i],
m_aHeights
[i]));
618
}
619
620
SetResolutionCombo
(
m_ResolutionCombo
);
621
m_ResolutionCombo
.m_OnChanged.Insert(
UpdateResolution
);
622
}
623
624
//------------------------------------------------------------------------------------------------
625
protected
void
SetupResolutionScale
()
626
{
627
if
(!
m_ResolutionScale
)
628
return
;
629
630
float
scale
=
m_ResolutionScale
.GetValue() * 100;
631
scale
=
Math
.Round(
scale
);
632
m_ResolutionScale
.ShowCustomValue(
scale
.ToString());
633
634
m_ResolutionScale
.m_OnChanged.Insert(
OnResolutionScaleChanged
);
635
OnRenderResolutionChanged
();
636
}
637
638
//------------------------------------------------------------------------------------------------
641
protected
void
RemoveQualityPresetFocus
()
642
{
643
ButtonWidget
qualityPreset =
ButtonWidget
.Cast(
m_wRoot
.FindAnyWidget(
"QualityPreset"
));
644
if
(!qualityPreset)
645
return
;
646
647
VerticalLayoutWidget
settingsEntries =
VerticalLayoutWidget
.Cast(
m_wScroll
.FindAnyWidget(
"SettingsEntries"
));
648
if
(!settingsEntries)
649
return
;
650
651
Widget
child = settingsEntries.GetChildren();
652
while
(child)
653
{
654
if
(
ButtonWidget
.Cast(child))
655
{
656
GetGame
().GetCallqueue().CallLater(
GetGame
().GetWorkspace().SetFocusedWidget, 0,
false
, child,
false
);
657
return
;
658
}
659
child = child.GetSibling();
660
}
661
}
662
663
//------------------------------------------------------------------------------------------------
665
protected
void
UpdateResolution
(
SCR_ComboBoxComponent
resolution,
int
current)
666
{
667
if
(!resolution || !
m_Video
)
668
return
;
669
670
m_Video
.Set(
"ScreenWidth"
,
m_aWidths
[current]);
671
m_Video
.Set(
"ScreenHeight"
,
m_aHeights
[current]);
672
673
OnRenderResolutionChanged
();
674
675
OnCustomMenuItemChanged
(
"Resolution"
);
676
}
677
678
//------------------------------------------------------------------------------------------------
679
protected
void
SetupMaxFPS
()
680
{
681
if
(!
m_Video
|| !
m_MaxFPS
)
682
return
;
683
684
int
maxFPS;
685
m_Video
.Get(
"MaxFps"
, maxFPS);
686
687
if
(maxFPS < 1)
688
{
689
m_MaxFPS
.SetCurrentItem(0);
690
}
691
else
692
{
693
for
(
int
i = 1, cnt =
m_MaxFPS
.GetNumItems(); i < cnt; i++)
694
{
695
if
(
m_MaxFPS
.GetItemName(i).ToInt() == maxFPS)
696
{
697
m_MaxFPS
.SetCurrentItem(i);
698
break
;
699
}
700
}
701
}
702
703
m_MaxFPS
.m_OnChanged.Insert(
OnMaxFPSChanged
);
704
}
705
706
protected
void
HandleDescription
()
707
{
708
ButtonWidget
drawDistance =
ButtonWidget
.Cast(
m_wRoot
.FindAnyWidget(
"DrawDistance"
));
709
if
(!drawDistance)
710
return
;
711
712
SCR_ModularButtonComponent buttonComp = SCR_ModularButtonComponent.Cast(drawDistance.FindHandler(SCR_ModularButtonComponent));
713
if
(!buttonComp)
714
return
;
715
716
buttonComp.m_OnFocus.Insert(
DescriptionOnFocus
);
717
buttonComp.m_OnFocusLost.Insert(
DescriptionOnFocusLost
);
718
}
719
720
protected
void
DescriptionOnFocus
()
721
{
722
RichTextWidget
title =
RichTextWidget
.Cast(
m_wRoot
.FindAnyWidget(
"DescriptionHeader"
));
723
RichTextWidget
body =
RichTextWidget
.Cast(
m_wRoot
.FindAnyWidget(
"DescriptionBody"
));
724
725
if
(!title || !body)
726
return
;
727
728
title.SetText(
"#AR-Settings_DrawDistance"
);
729
body.SetText(
"#AR-Settings_Description_DrawDistance"
);
730
}
731
732
protected
void
DescriptionOnFocusLost
()
733
{
734
RichTextWidget
title =
RichTextWidget
.Cast(
m_wRoot
.FindAnyWidget(
"DescriptionHeader"
));
735
RichTextWidget
body =
RichTextWidget
.Cast(
m_wRoot
.FindAnyWidget(
"DescriptionBody"
));
736
737
if
(!title || !body)
738
return
;
739
740
title.SetText(
string
.Empty);
741
body.SetText(
string
.Empty);
742
}
743
}
scale
vector scale
Definition
BlenderEndpoints.c:50
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
distance
float distance
Definition
SCR_DestructibleTreeV2.c:29
index
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
Definition
SCR_DestructionSynchronizationComponent.c:17
LoadSettings
void LoadSettings()
Definition
SCR_HintManagerComponent.c:455
FULLSCREEN
@ FULLSCREEN
Definition
SCR_MapConstants.c:30
EWindowMode
EWindowMode
Definition
SCR_VideoSettingsSubMenu.c:2
MAXIMIZED
@ MAXIMIZED
Definition
SCR_VideoSettingsSubMenu.c:5
WINDOWED
@ WINDOWED
Definition
SCR_VideoSettingsSubMenu.c:4
BORDERLESS
@ BORDERLESS
Definition
SCR_VideoSettingsSubMenu.c:6
BaseContainer
Definition
BaseContainer.c:13
ButtonWidget
Definition
ButtonWidget.c:16
Math
Definition
Math.c:13
ResourceName
Definition
ResourceName.c:13
RichTextWidget
Definition
RichTextWidget.c:13
SCR_ComboBoxComponent
Definition
SCR_ComboBoxComponent.c:2
SCR_ComboBoxComponent::SetCurrentItem
override bool SetCurrentItem(int i, bool playSound=false, bool animate=false)
Definition
SCR_ComboBoxComponent.c:242
SCR_ScriptedWidgetComponent::m_wRoot
Widget m_wRoot
Definition
SCR_ScriptedWidgetComponent.c:9
SCR_SettingBindingEngine
Definition
SCR_SettingBindingEngine.c:2
SCR_SettingBindingGameplay
Definition
SCR_SettingBindingGameplay.c:2
SCR_SettingsBindingBase
Definition
SCR_SettingsBindingBase.c:2
SCR_SettingsBindingBase::GetWidgetName
string GetWidgetName()
Definition
SCR_SettingsBindingBase.c:51
SCR_SettingsSubMenuBase
Definition
SCR_SettingsSubMenuBase.c:2
SCR_SettingsSubMenuBase::m_wScroll
ScrollLayoutWidget m_wScroll
Definition
SCR_SettingsSubMenuBase.c:4
SCR_SettingsSubMenuBase::m_aSettingsBindings
ref array< ref SCR_SettingsBindingBase > m_aSettingsBindings
Definition
SCR_SettingsSubMenuBase.c:3
SCR_SettingsSubMenuBase::m_bLoadingSettings
bool m_bLoadingSettings
Definition
SCR_SettingsSubMenuBase.c:5
SCR_SliderComponent
Definition
SCR_SliderComponent.c:3
SCR_SliderComponent::GetSliderComponent
static SCR_SliderComponent GetSliderComponent(string name, Widget parent, bool searchAllChildren=true)
Definition
SCR_SliderComponent.c:323
SCR_SliderComponent::ShowCustomValue
void ShowCustomValue(string value)
Definition
SCR_SliderComponent.c:235
SCR_SpinBoxComponent
Definition
SCR_SpinBoxComponent.c:2
SCR_SpinBoxComponent::GetSpinBoxComponent
static SCR_SpinBoxComponent GetSpinBoxComponent(string name, Widget parent, bool searchAllChildren=true)
Definition
SCR_SpinBoxComponent.c:389
SCR_SpinBoxComponent::SetCurrentItem
override bool SetCurrentItem(int i, bool playSound=false, bool animate=false)
Definition
SCR_SpinBoxComponent.c:142
SCR_VideoSettingsSubMenu
Definition
SCR_VideoSettingsSubMenu.c:23
SCR_VideoSettingsSubMenu::SetupResolutionScale
void SetupResolutionScale()
Definition
SCR_VideoSettingsSubMenu.c:625
SCR_VideoSettingsSubMenu::DescriptionOnFocus
void DescriptionOnFocus()
Definition
SCR_VideoSettingsSubMenu.c:720
SCR_VideoSettingsSubMenu::SetQualityPresetIndex
void SetQualityPresetIndex(string changedSetting)
Definition
SCR_VideoSettingsSubMenu.c:98
SCR_VideoSettingsSubMenu::SetupMaxFPS
void SetupMaxFPS()
Definition
SCR_VideoSettingsSubMenu.c:679
SCR_VideoSettingsSubMenu::OnHardwareAAChanged
void OnHardwareAAChanged(SCR_SpinBoxComponent comp, int i)
Event called when hardware AA spinbox changes.
Definition
SCR_VideoSettingsSubMenu.c:308
SCR_VideoSettingsSubMenu::OnRenderResolutionChanged
void OnRenderResolutionChanged()
method called when resolution or resolution scale changes
Definition
SCR_VideoSettingsSubMenu.c:337
SCR_VideoSettingsSubMenu::m_ResolutionScale
SCR_SliderComponent m_ResolutionScale
Definition
SCR_VideoSettingsSubMenu.c:29
SCR_VideoSettingsSubMenu::SetupQualityPreset
void SetupQualityPreset()
Definition
SCR_VideoSettingsSubMenu.c:266
SCR_VideoSettingsSubMenu::SetupTextureDetail
void SetupTextureDetail(bool isInit=true)
Definition
SCR_VideoSettingsSubMenu.c:184
SCR_VideoSettingsSubMenu::PRESET_SETTINGS
static const ref array< string > PRESET_SETTINGS
list of WIDGET names
Definition
SCR_VideoSettingsSubMenu.c:44
SCR_VideoSettingsSubMenu::SetResolutionCombo
void SetResolutionCombo(SCR_ComboBoxComponent combo)
Definition
SCR_VideoSettingsSubMenu.c:456
SCR_VideoSettingsSubMenu::OnQualityPresetChanged
void OnQualityPresetChanged(SCR_ComboBoxComponent combobox, int itemIndex)
Definition
SCR_VideoSettingsSubMenu.c:241
SCR_VideoSettingsSubMenu::SetupGrassDistance
void SetupGrassDistance()
Definition
SCR_VideoSettingsSubMenu.c:542
SCR_VideoSettingsSubMenu::OnViewDistanceChanged
void OnViewDistanceChanged(SCR_SliderComponent comp, float value)
Event called when shadow quality slider changes.
Definition
SCR_VideoSettingsSubMenu.c:369
SCR_VideoSettingsSubMenu::m_Pipeline
UserSettings m_Pipeline
Definition
SCR_VideoSettingsSubMenu.c:37
SCR_VideoSettingsSubMenu::OnGrassDistanceChanged
void OnGrassDistanceChanged(SCR_SliderComponent comp, float value)
Definition
SCR_VideoSettingsSubMenu.c:382
SCR_VideoSettingsSubMenu::m_aHeights
ref array< int > m_aHeights
Definition
SCR_VideoSettingsSubMenu.c:25
SCR_VideoSettingsSubMenu::OnTabCreate
override void OnTabCreate(Widget menuRoot, ResourceName buttonsLayout, int index)
Definition
SCR_VideoSettingsSubMenu.c:112
SCR_VideoSettingsSubMenu::m_ResolutionCombo
SCR_ComboBoxComponent m_ResolutionCombo
Definition
SCR_VideoSettingsSubMenu.c:28
SCR_VideoSettingsSubMenu::m_MaxFPS
SCR_SpinBoxComponent m_MaxFPS
Definition
SCR_VideoSettingsSubMenu.c:32
SCR_VideoSettingsSubMenu::SetupShadowQuality
void SetupShadowQuality(bool isInit=true)
Definition
SCR_VideoSettingsSubMenu.c:560
SCR_VideoSettingsSubMenu::SetupViewDistance
void SetupViewDistance()
Definition
SCR_VideoSettingsSubMenu.c:514
SCR_VideoSettingsSubMenu::m_Video
UserSettings m_Video
Definition
SCR_VideoSettingsSubMenu.c:36
SCR_VideoSettingsSubMenu::OnCustomMenuItemChanged
void OnCustomMenuItemChanged(string widgetName)
Definition
SCR_VideoSettingsSubMenu.c:91
SCR_VideoSettingsSubMenu::RESOLUTION_FORMAT
static const string RESOLUTION_FORMAT
Definition
SCR_VideoSettingsSubMenu.c:40
SCR_VideoSettingsSubMenu::m_sResolutionScaleLocalisation
string m_sResolutionScaleLocalisation
Definition
SCR_VideoSettingsSubMenu.c:34
SCR_VideoSettingsSubMenu::OnTextureDetailChanged
void OnTextureDetailChanged(SCR_SpinBoxComponent comp, int i)
Event called when texture detail spinbox changes.
Definition
SCR_VideoSettingsSubMenu.c:225
SCR_VideoSettingsSubMenu::m_ResourceManager
UserSettings m_ResourceManager
Definition
SCR_VideoSettingsSubMenu.c:38
SCR_VideoSettingsSubMenu::SetupHardwareAA
void SetupHardwareAA(bool isInit=true)
Definition
SCR_VideoSettingsSubMenu.c:276
SCR_VideoSettingsSubMenu::RemoveQualityPresetFocus
void RemoveQualityPresetFocus()
Definition
SCR_VideoSettingsSubMenu.c:641
SCR_VideoSettingsSubMenu::UpdateResolution
void UpdateResolution(SCR_ComboBoxComponent resolution, int current)
Event called when resolution combo box changes.
Definition
SCR_VideoSettingsSubMenu.c:665
SCR_VideoSettingsSubMenu::OnMaxFPSChanged
void OnMaxFPSChanged(SCR_SpinBoxComponent comp, int i)
Event called when max FPS is changed.
Definition
SCR_VideoSettingsSubMenu.c:207
SCR_VideoSettingsSubMenu::DescriptionOnFocusLost
void DescriptionOnFocusLost()
Definition
SCR_VideoSettingsSubMenu.c:732
SCR_VideoSettingsSubMenu::m_aAAvalues
ref array< int > m_aAAvalues
Definition
SCR_VideoSettingsSubMenu.c:26
SCR_VideoSettingsSubMenu::CUSTOM_PRESET_INDEX
static const int CUSTOM_PRESET_INDEX
Definition
SCR_VideoSettingsSubMenu.c:41
SCR_VideoSettingsSubMenu::HandleDescription
void HandleDescription()
Definition
SCR_VideoSettingsSubMenu.c:706
SCR_VideoSettingsSubMenu::OnWindowModeChanged
void OnWindowModeChanged(SCR_SpinBoxComponent comp, int index)
Event called when window mode combo box changes.
Definition
SCR_VideoSettingsSubMenu.c:390
SCR_VideoSettingsSubMenu::m_WindowMode
SCR_SpinBoxComponent m_WindowMode
Definition
SCR_VideoSettingsSubMenu.c:31
SCR_VideoSettingsSubMenu::SetupResolution
void SetupResolution()
Definition
SCR_VideoSettingsSubMenu.c:578
SCR_VideoSettingsSubMenu::OnShadowDetailChanged
void OnShadowDetailChanged(SCR_SpinBoxComponent comp, int i)
Event called when shadow quality spinbox changes.
Definition
SCR_VideoSettingsSubMenu.c:358
SCR_VideoSettingsSubMenu::OnResolutionScaleChanged
void OnResolutionScaleChanged(SCR_SliderComponent comp, float value)
Event called when resolution scale slider changes.
Definition
SCR_VideoSettingsSubMenu.c:324
SCR_VideoSettingsSubMenu::m_aWidths
ref array< int > m_aWidths
Definition
SCR_VideoSettingsSubMenu.c:24
SCR_VideoSettingsSubMenu::OnMenuItemChanged
override void OnMenuItemChanged(SCR_SettingsBindingBase binding)
Definition
SCR_VideoSettingsSubMenu.c:78
System
Definition
System.c:13
TextWidget
Definition
TextWidget.c:16
UserSettings
Definition
UserSettings.c:13
VerticalLayoutWidget
Definition
VerticalLayoutWidget.c:13
Widget
Definition
Widget.c:13
scripts
Game
UI
Menu
SettingsMenu
SCR_VideoSettingsSubMenu.c
Generated by
1.17.0