-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSystemConsoleCommands.lua
More file actions
566 lines (488 loc) · 15.3 KB
/
SystemConsoleCommands.lua
File metadata and controls
566 lines (488 loc) · 15.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
SystemConsoleCommands = {
init = function ()
addConsoleCommand("gsGuiDrawHelper", "", "drawGuiHelper", SystemConsoleCommands)
addConsoleCommand("gsI3DCacheClean", "Removes all cached i3d files to ensure the latest versions are loaded from disk", "cleanI3DCache", SystemConsoleCommands)
addConsoleCommand("gsSetHighQuality", "Incease draw and LOD distances of foliage, terrain and objects", "setHighQuality", SystemConsoleCommands)
addConsoleCommand("gsGuiSafeFrameShow", "", "showSafeFrame", SystemConsoleCommands)
addConsoleCommand("gsGuiDebug", "", "toggleUiDebug", SystemConsoleCommands)
addConsoleCommand("gsGuiFocusDebug", "", "toggleUiFocusDebug", SystemConsoleCommands)
addConsoleCommand("gsRenderColorAndDepthScreenShot", "", "renderColorAndDepthScreenShot", SystemConsoleCommands)
if g_addCheatCommands then
addConsoleCommand("gsRenderingDebugMode", "", "setDebugRenderingMode", SystemConsoleCommands)
addConsoleCommand("gsInputDrawRaw", "", "drawRawInput", SystemConsoleCommands)
addConsoleCommand("gsTestForceFeedback", "", "testForceFeedback", SystemConsoleCommands)
addConsoleCommand("gsTextureStreamingSetBudget", "", "setTextureStreamingBudget", SystemConsoleCommands)
end
if g_addTestCommands then
addConsoleCommand("gsLanguageSet", "Set active language", "changeLanguage", SystemConsoleCommands)
addConsoleCommand("gsGuiReloadCurrent", "", "reloadCurrentGui", SystemConsoleCommands)
if not GS_IS_CONSOLE_VERSION and not GS_IS_MOBILE_VERSION then
addConsoleCommand("gsSuspendApp", "", "suspendApp", SystemConsoleCommands)
end
addConsoleCommand("gsInputFuzz", "", "fuzzInput", SystemConsoleCommands)
addConsoleCommand("gsUpdateDownloadFinished", "", "updateDownloadFinished", SystemConsoleCommands)
addConsoleCommand("gsRenderingFidelityFxSRSet", "", "setFidelityFxSR", SystemConsoleCommands)
addConsoleCommand("gsSoftRestart", "", "softRestart", SystemConsoleCommands)
end
end,
delete = function ()
removeConsoleCommand("gsGuiDrawHelper")
removeConsoleCommand("gsI3DCacheClean")
removeConsoleCommand("gsSetHighQuality")
removeConsoleCommand("gsGuiSafeFrameShow")
removeConsoleCommand("gsGuiDebug")
removeConsoleCommand("gsGuiFocusDebug")
removeConsoleCommand("gsRenderColorAndDepthScreenShot")
removeConsoleCommand("gsRenderingDebugMode")
removeConsoleCommand("gsInputDrawRaw")
removeConsoleCommand("gsTestForceFeedback")
removeConsoleCommand("gsTextureStreamingSetBudget")
removeConsoleCommand("gsLanguageSet")
removeConsoleCommand("gsGuiReloadCurrent")
removeConsoleCommand("gsSuspendApp")
removeConsoleCommand("gsInputFuzz")
removeConsoleCommand("gsUpdateDownloadFinished")
removeConsoleCommand("gsRenderingFidelityFxSRSet")
removeConsoleCommand("gsSoftRestart")
end,
drawGuiHelper = function (self, steps)
steps = tonumber(steps)
if steps ~= nil then
g_guiHelperSteps = math.max(steps, 0.001)
g_drawGuiHelper = true
else
g_guiHelperSteps = 0.1
g_drawGuiHelper = false
end
if g_drawGuiHelper then
return "DrawGuiHelper = true (step = " .. g_guiHelperSteps .. ")"
else
return "DrawGuiHelper = false"
end
end,
showSafeFrame = function (self)
g_showSafeFrame = not g_showSafeFrame
return string.format("showSafeFrame = %s", g_showSafeFrame)
end,
drawRawInput = function (self)
g_showRawInput = not g_showRawInput
return string.format("showRawInput = %s", g_showRawInput)
end,
testForceFeedback = function (self)
if getHasGamepadAxisForceFeedback(0, 0) then
co = coroutine.create(function ()
for i = 1, 0, -0.2 do
setGamepadAxisForceFeedback(0, 0, 0.8, i)
print(string.format("TestForceFeedback %1.2f", i))
usleep(500000)
setGamepadAxisForceFeedback(0, 0, 0.8, -i)
usleep(500000)
end
setGamepadAxisForceFeedback(0, 0, 0, 0)
end)
coroutine.resume(co)
else
print("Force feedback not available")
end
end,
setTextureStreamingBudget = function (self, sizeInMB)
sizeInMB = tonumber(sizeInMB)
if sizeInMB == nil then
setTextureStreamingMemoryBudget(0)
return "Reset Texture Streaming Memory Budget to default"
else
setTextureStreamingMemoryBudget(sizeInMB)
return "Set Texture Streaming Memory Budget to " .. sizeInMB .. " MB"
end
end,
cleanI3DCache = function (self, verbose)
verbose = Utils.stringToBoolean(verbose)
g_i3DManager:clearEntireSharedI3DFileCache(verbose)
local ret = "I3D cache cleaned."
if not verbose then
ret = ret .. " Use 'true' parameter for verbose output"
end
return ret
end,
setHighQuality = function (self, coeffOverride)
local minValue = 1e-06
local maxValue = 10
local default = 5
local usage = string.format("Usage 'gsSetHighQuality <factor (default=%d)>'", default)
local coeff = MathUtil.clamp(tonumber(coeffOverride) or default, minValue, maxValue)
setViewDistanceCoeff(coeff)
setLODDistanceCoeff(coeff)
setTerrainLODDistanceCoeff(coeff)
setFoliageViewDistanceCoeff(math.max(1, coeff * 0.5))
return string.format("High quality activated, used factor=%s.%s", MathUtil.round(coeff, 8), coeffOverride == nil and " " .. usage or "")
end,
renderColorAndDepthScreenShot = function (self, inWidth, inHeight)
local width, height = nil
if inWidth == nil or inHeight == nil then
local curScrMode = getScreenMode()
width, height = getScreenModeInfo(curScrMode)
else
width = tonumber(inWidth)
height = tonumber(inHeight)
end
setDebugRenderingMode(DebugRendering.NONE)
local strDate = getDate("%Y_%m_%d_%H_%M_%S") .. ".hdr"
local colorScreenShot = g_screenshotsDirectory .. "fsScreen_color_" .. strDate
print("Saving color screenshot: " .. colorScreenShot)
renderScreenshot(colorScreenShot, width, height, width / height, "raw_hdr", 1, 0, 0, 0, 0, 0, 15, false, 4)
setDebugRenderingMode(DebugRendering.DEPTH)
local depthScreenShot = g_screenshotsDirectory .. "fsScreen_depth_" .. strDate
print("Saving depth screenshot: " .. depthScreenShot)
renderScreenshot(depthScreenShot, width, height, width / height, "raw_hdr", 1, 0, 0, 0, 0, 0, 15, false, 0)
setDebugRenderingMode(DebugRendering.NONE)
end,
setDebugRenderingMode = function (self, newMode)
if newMode == nil or newMode == "" then
setDebugRenderingMode(DebugRendering.NONE)
return "Possible modes: alpha, parallax, albedo, normals, smoothness, metalness, ambientOcclusion (ao), bakedAmbientOcclusion (bakedAO), screenSpaceAmbientOcclusion(ssao), specularOcclusion, diffuseLighting, specularLighting, indirectLighting, lightGrid, shadowSplits, depth, mipLevels, triangleDensity, terrainSlopes, motionVectors, vrs"
end
newMode = newMode:lower()
local modeDescs = {
alpha = {
DebugRendering.ALPHA,
"alpha"
},
parallax = {
DebugRendering.PARALLAX,
"parallax"
},
albedo = {
DebugRendering.ALBEDO,
"albedo"
},
normals = {
DebugRendering.NORMALS,
"normals"
},
tangent_space_normals = {
DebugRendering.TANGENT_SPACE_NORMALS,
"tangentSpaceNormals"
},
smoothness = {
DebugRendering.SMOOTHNESS,
"smoothness"
},
metalness = {
DebugRendering.METALNESS,
"metalness"
},
ambient_occlusion = {
DebugRendering.AMBIENT_OCCLUSION,
"ambientOcclusion"
},
ambientocclusion = {
DebugRendering.AMBIENT_OCCLUSION,
"ambientOcclusion"
},
ao = {
DebugRendering.AMBIENT_OCCLUSION,
"ambientOcclusion"
},
baked_ambient_occlusion = {
DebugRendering.BAKED_AMBIENT_OCCLUSION,
"bakedAmbientOcclusion"
},
bakedambientocclusion = {
DebugRendering.BAKED_AMBIENT_OCCLUSION,
"bakedAmbientOcclusion"
},
bakedao = {
DebugRendering.BAKED_AMBIENT_OCCLUSION,
"bakedAmbientOcclusion"
},
screenspaceambientocclusion = {
DebugRendering.SCREEN_SPACE_AMBIENT_OCCLUSION,
"screenSpaceAmbientOcclusion"
},
screen_space_ambient_occlusion = {
DebugRendering.SCREEN_SPACE_AMBIENT_OCCLUSION,
"screenSpaceAmbientOcclusion"
},
ssao = {
DebugRendering.SCREEN_SPACE_AMBIENT_OCCLUSION,
"screenSpaceAmbientOcclusion"
},
specular_occlusion = {
DebugRendering.SPECULAR_OCCLUSION,
"specularOcclusion"
},
specularocclusion = {
DebugRendering.SPECULAR_OCCLUSION,
"specularOcclusion"
},
diffuse_lighting = {
DebugRendering.DIFFUSE_LIGHTING,
"diffuseLighting"
},
diffuselighting = {
DebugRendering.DIFFUSE_LIGHTING,
"diffuseLighting"
},
diffuse = {
DebugRendering.DIFFUSE_LIGHTING,
"diffuseLighting"
},
specular_lighting = {
DebugRendering.SPECULAR_LIGHTING,
"specularLighting"
},
specularlighting = {
DebugRendering.SPECULAR_LIGHTING,
"specularLighting"
},
specular = {
DebugRendering.SPECULAR_LIGHTING,
"specularLighting"
},
indirect_lighting = {
DebugRendering.INDIRECT_LIGHTING,
"indirectLighting"
},
indirectlighting = {
DebugRendering.INDIRECT_LIGHTING,
"indirectLighting"
},
indirect = {
DebugRendering.INDIRECT_LIGHTING,
"indirectLighting"
},
light_grid = {
DebugRendering.LIGHT_GRID,
"lightGrid"
},
lightgrid = {
DebugRendering.LIGHT_GRID,
"lightGrid"
},
shadow_splits = {
DebugRendering.SHADOW_SPLITS,
"shadowSplits"
},
shadowsplits = {
DebugRendering.SHADOW_SPLITS,
"shadowSplits"
},
depth = {
DebugRendering.DEPTH_SCALED,
"depth"
},
miplevels = {
DebugRendering.MIP_LEVELS,
"mipLevels"
},
mips = {
DebugRendering.MIP_LEVELS,
"mipLevels"
},
triangledensity = {
DebugRendering.TRIANGLE_DENSITY,
"triangleDensity"
},
terrainslopes = {
DebugRendering.TERRAIN_SLOPES,
"terrainSlopes"
},
motionvectors = {
DebugRendering.MOTION_VECTORS,
"motionVectors"
},
vrs = {
DebugRendering.SHADING_RATE,
"vrs"
},
custom1 = {
DebugRendering.CUSTOM1,
"custom1"
},
custom2 = {
DebugRendering.CUSTOM2,
"custom2"
}
}
local modeDesc = modeDescs[newMode]
local modeName = "none"
local mode = DebugRendering.NONE
if modeDesc ~= nil then
mode = modeDesc[1]
modeName = modeDesc[2]
end
setDebugRenderingMode(mode)
return "Changed debug rendering to " .. modeName
end,
changeLanguage = function (self, newCode)
local numLanguages = getNumOfLanguages()
local newLang = -1
if newCode == nil then
local newIndex = g_settingsLanguageGUI + 1
if table.getn(g_availableLanguagesTable) <= newIndex then
newIndex = 0
end
newLang = g_availableLanguagesTable[newIndex + 1]
else
for i = 0, numLanguages - 1 do
if getLanguageCode(i) == newCode then
newLang = i
break
end
end
if newLang < 0 then
return "Invalid language parameter " .. tostring(newCode)
end
end
if setLanguage(newLang) then
local xmlFile = XMLFile.load("SettingsFile", "dataS/settings.xml")
loadLanguageSettings(xmlFile)
xmlFile:delete()
g_i18n:load()
return string.format("Changed language to '%s'. Note that many texts are loaded on game start and need a reboot to be updated.", getLanguageCode(newLang))
end
return "Invalid language parameter " .. tostring(newCode)
end,
reloadCurrentGui = function (self)
if g_gui.currentGuiName ~= nil and g_gui.currentGuiName ~= "" then
local guiName = g_gui.currentGuiName
local guiController = g_gui.currentGui.target
g_gui:showGui("")
g_i18n:load()
g_gui.profiles = {}
g_gui.traits = {}
local success = g_gui:loadProfiles("dataS/guiProfiles.xml")
if not success then
return "Failed to reload profiles"
end
local class = ClassUtil.getClassObject(guiName)
if class == nil then
for customEnv, _ in pairs(g_modIsLoaded) do
for k, v in pairs(_G[customEnv]) do
if k == guiName then
class = v
end
end
end
end
if class == nil then
return "Given GUI class not found"
end
g_dummyGui = nil
if class.createFromExistingGui ~= nil then
g_dummyGui = class.createFromExistingGui(guiController, guiName)
else
g_dummyGui = class.new()
g_gui.guis[guiName]:delete()
g_gui.guis[guiName].target:delete()
g_gui:loadGui(guiController.xmlFilename, guiName, g_dummyGui)
end
g_gui:showGui(guiName)
return "Reloaded gui " .. tostring(guiName)
end
return "No GUI active!"
end,
reloadCurrentDialog = function (self)
if g_gui.currentDialogName ~= nil and g_gui.currentDialogName ~= "" then
g_gui.currentlyReloading = true
local guiName = g_gui.currentDialogName
local guiController = g_gui.currentListener.target
g_gui:closeDialog(g_gui.currentListener)
g_i18n:delete()
g_i18n:load()
local success = g_gui:loadProfiles("dataS/guiProfiles.xml")
if not success then
g_gui.currentlyReloading = false
return "Failed to reload profiles"
end
local class = ClassUtil.getClassObject(guiName)
if class == nil then
for customEnv, _ in pairs(g_modIsLoaded) do
for k, v in pairs(_G[customEnv]) do
if k == guiName then
class = v
end
end
end
end
if class == nil then
return "Given GUI Dialog class not found"
end
g_dummyGui = nil
if class.createFromExistingGui ~= nil then
g_dummyGui = class.createFromExistingGui(guiController, guiName)
else
g_dummyGui = class.new()
g_gui.guis[guiName]:delete()
g_gui.guis[guiName].target:delete()
g_gui:loadGui(guiController.xmlFilename, guiName, g_dummyGui)
end
g_gui.currentlyReloading = false
return "Reloaded dialog " .. tostring(guiName)
end
return "No Dialog active!"
end,
toggleUiDebug = function (self)
if g_uiDebugEnabled then
g_uiDebugEnabled = false
return "UI Debug disabled"
else
g_uiDebugEnabled = true
return "UI Debug enabled"
end
end,
toggleUiFocusDebug = function (self)
if g_uiFocusDebugEnabled then
g_uiFocusDebugEnabled = false
return "UI Focus Debug disabled"
else
g_uiFocusDebugEnabled = true
return "UI Focus Debug enabled"
end
end,
suspendApp = function (self)
if g_appIsSuspended then
notifyAppResumed()
else
notifyAppSuspended()
end
return "App Suspended: " .. tostring(g_appIsSuspended)
end,
fuzzInput = function (self)
beginInputFuzzing()
end,
softRestart = function (self)
if g_currentMission ~= nil then
OnInGameMenuMenu()
return
end
RestartManager:setStartScreen(RestartManager.START_SCREEN_MAIN)
doRestart(false, "")
end,
updateDownloadFinished = function (self)
g_updateDownloadFinished = true
log("g_updateDownloadFinished = true")
end,
setFidelityFxSR = function (self, newQuality)
local usage = "Usage: gsRenderingFidelityFxSRSet <qualityNumber>"
newQuality = tonumber(newQuality)
local currentQuality = getFidelityFxSRQuality()
print(string.format("current setting: %s (%d)", getFidelityFxSRQualityName(currentQuality), currentQuality))
print("Available settings:")
for i = 0, FidelityFxSRQuality.NUM - 1 do
local name = getFidelityFxSRQualityName(i)
print(string.format(" %d | %s | supported=%s", i, name, getSupportsFidelityFxSRQuality(i)))
end
if newQuality ~= nil then
if newQuality >= 0 and newQuality < FidelityFxSRQuality.NUM and getSupportsFidelityFxSRQuality(newQuality) then
setFidelityFxSRQuality(newQuality)
else
return string.format("Error: Given quality '%d' not supported\n%s", newQuality, usage)
end
local effectiveQuality = getFidelityFxSRQuality()
return string.format("new setting: %s (%d)", getFidelityFxSRQualityName(effectiveQuality), effectiveQuality)
else
return usage
end
end
}