-
Notifications
You must be signed in to change notification settings - Fork 17
/
LumberJackSettings.lua
641 lines (530 loc) · 19 KB
/
LumberJackSettings.lua
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
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
LumberJack.SETTINGS = {}
LumberJack.CONTROLS = {}
LumberJack.menuItems = {
'cutAnywhere',
'createWoodchips',
'maxWoodchips',
'superStrengthValue',
'normalStrengthValue',
'superDistanceValue',
'normalDistanceValue',
'maxCutDistance',
'defaultCutDuration',
'destroyFoliageSize',
'longHoldThreshold',
'doubleTapThreshold',
'showDebug'
}
LumberJack.multiplayerPermissions = {
'superSpeed',
'superStrength',
'chainsawSettings'
}
Farm.PERMISSION['SUPER_SPEED'] = "superSpeed"
Farm.PERMISSION['SUPER_STRENGTH'] = "superStrength"
Farm.PERMISSION['CHAINSAW_SETTINGS'] = "chainsawSettings"
table.insert(Farm.PERMISSIONS, Farm.PERMISSION.SUPER_SPEED)
table.insert(Farm.PERMISSIONS, Farm.PERMISSION.SUPER_STRENGTH)
table.insert(Farm.PERMISSIONS, Farm.PERMISSION.CHAINSAW_SETTINGS)
-- table.insert(g_inGameMenu.permissionsBox.elements, "superSpeedPermissionCheckbox")
-- table.insert(g_inGameMenu.permissionsBox.elements, "superStrengthPermissionCheckbox")
-- table.insert(g_inGameMenu.permissionsBox.elements, "chainsawSettingsPermissionCheckbox")
--DEV
LumberJack.SETTINGS.showDebug = {
-- LumberJack.showDebug = false
['default'] = 1,
['values'] = {false, true},
['strings'] = {
g_i18n:getText("ui_off"),
g_i18n:getText("ui_on")
}
}
--SERVER
LumberJack.SETTINGS.createWoodchips = {
-- LumberJack.createWoodchips = false
['default'] = 1,
['serverOnly'] = true,
['values'] = {false, true},
['strings'] = {
g_i18n:getText("ui_off"),
g_i18n:getText("ui_on")
}
}
LumberJack.SETTINGS.maxWoodchips = {
-- LumberJack.maxWoodchips = 2000
['default'] = 2,
['serverOnly'] = true,
['values'] = {1000, 2000, 3000, 4000, 5000},
['strings'] = {
"1000 "..g_i18n:getText("unit_liter"),
"2000 "..g_i18n:getText("unit_liter"),
"3000 "..g_i18n:getText("unit_liter"),
"4000 "..g_i18n:getText("unit_liter"),
"5000 "..g_i18n:getText("unit_liter"),
}
}
LumberJack.SETTINGS.destroyFoliageSize = {
-- LumberJack.destroyFoliageSize = 2
['default'] = 1,
['serverOnly'] = true,
['values'] = {0,1,1.5,2,2.5,3,4,5},
['strings'] = {
g_i18n:getText("ui_off"),
"1m",
"1.5m",
"2m",
"2.5m",
"3m",
"4m",
"5m",
}
}
--PLAYER
LumberJack.SETTINGS.cutAnywhere = {
-- LumberJack.cutAnywhere = true
['default'] = 2,
['permission'] = 'chainsawSettings',
['values'] = {false, true},
['strings'] = {
g_i18n:getText("ui_off"),
g_i18n:getText("ui_on")
}
}
LumberJack.SETTINGS.superStrengthValue = {
-- LumberJack.superStrengthValue = 1000
['default'] = 13,
['permission'] = 'superStrength',
['values'] = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 20.0, 50.0, 100.0, 200.0, 500.0, 1000.0, 100000000},
['strings'] = {
"1 " .. g_i18n:getText("text_TONNE"),
"2 " .. g_i18n:getText("text_TONNE"),
"3 " .. g_i18n:getText("text_TONNE"),
"4 " .. g_i18n:getText("text_TONNE"),
"5 " .. g_i18n:getText("text_TONNE"),
"6 " .. g_i18n:getText("text_TONNE"),
"7 " .. g_i18n:getText("text_TONNE"),
"8 " .. g_i18n:getText("text_TONNE"),
"9 " .. g_i18n:getText("text_TONNE"),
"10 " .. g_i18n:getText("text_TONNE"),
"20 " .. g_i18n:getText("text_TONNE"),
"50 " .. g_i18n:getText("text_TONNE"),
"100 " .. g_i18n:getText("text_TONNE"),
"200 " .. g_i18n:getText("text_TONNE"),
"500 " .. g_i18n:getText("text_TONNE"),
"1000 " .. g_i18n:getText("text_TONNE"),
g_i18n:getText("text_INFINITE").."!"
}
}
LumberJack.SETTINGS.normalStrengthValue = {
-- LumberJack.normalStrengthValue = 0.2
['default'] = 2,
['permission'] = 'superStrength',
['values'] = {0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0},
['strings'] = {
"100 "..g_i18n:getText("text_KG"),
"200 "..g_i18n:getText("text_KG"),
"300 "..g_i18n:getText("text_KG"),
"400 "..g_i18n:getText("text_KG"),
"500 "..g_i18n:getText("text_KG"),
"600 "..g_i18n:getText("text_KG"),
"700 "..g_i18n:getText("text_KG"),
"800 "..g_i18n:getText("text_KG"),
"900 "..g_i18n:getText("text_KG"),
"1,000 "..g_i18n:getText("text_KG"),
}
}
LumberJack.SETTINGS.superDistanceValue = {
-- LumberJack.superDistanceValue = 12
['default'] = 2,
['permission'] = 'superStrength',
['values'] = {10, 12, 15, 20, 25, 30, 35, 40, 50},
['strings'] = {
"10 "..g_i18n:getText("text_METRE"),
"12 "..g_i18n:getText("text_METRE"),
"15 "..g_i18n:getText("text_METRE"),
"20 "..g_i18n:getText("text_METRE"),
"25 "..g_i18n:getText("text_METRE"),
"30 "..g_i18n:getText("text_METRE"),
"35 "..g_i18n:getText("text_METRE"),
"40 "..g_i18n:getText("text_METRE"),
"50 "..g_i18n:getText("text_METRE"),
}
}
LumberJack.SETTINGS.normalDistanceValue = {
-- LumberJack.normalDistanceValue = 3
['default'] = 1,
['permission'] = 'superStrength',
['values'] = {3, 4, 5, 6, 7, 8, 9, 10},
['strings'] = {
"3 "..g_i18n:getText("text_METRE"),
"4 "..g_i18n:getText("text_METRE"),
"5 "..g_i18n:getText("text_METRE"),
"6 "..g_i18n:getText("text_METRE"),
"7 "..g_i18n:getText("text_METRE"),
"8 "..g_i18n:getText("text_METRE"),
"9 "..g_i18n:getText("text_METRE"),
"10 "..g_i18n:getText("text_METRE"),
}
}
LumberJack.SETTINGS.maxCutDistance = {
-- LumberJack.maxCutDistance = 4.0
['default'] = 4,
['permission'] = 'chainsawSettings',
['values'] = {1, 2, 3, 4, 5, 7, 10, 12, 15, 20},
['strings'] = {
"1 "..g_i18n:getText("text_METRE"),
"2 "..g_i18n:getText("text_METRE"),
"3 "..g_i18n:getText("text_METRE"),
"4 "..g_i18n:getText("text_METRE"),
"5 "..g_i18n:getText("text_METRE"),
"7 "..g_i18n:getText("text_METRE"),
"10 "..g_i18n:getText("text_METRE"),
"12 "..g_i18n:getText("text_METRE"),
"15 "..g_i18n:getText("text_METRE"),
"20 "..g_i18n:getText("text_METRE")
}
}
LumberJack.SETTINGS.defaultCutDuration = {
-- LumberJack.defaultCutDuration = 4
['default'] = 4,
['permission'] = 'chainsawSettings',
['values'] = {0.5,1.0,1.5,2.0,2.5,3.0,3.5,4.0,4.5,5.0,5.5,6.0},
['strings'] = {
"0.5 "..g_i18n:getText("text_SECOND"),
"1.0 "..g_i18n:getText("text_SECOND"),
"1.5 "..g_i18n:getText("text_SECOND"),
"2.0 "..g_i18n:getText("text_SECOND"),
"2.5 "..g_i18n:getText("text_SECOND"),
"3.0 "..g_i18n:getText("text_SECOND"),
"3.5 "..g_i18n:getText("text_SECOND"),
"4.0 "..g_i18n:getText("text_SECOND"),
"4.5 "..g_i18n:getText("text_SECOND"),
"5.0 "..g_i18n:getText("text_SECOND"),
"5.5 "..g_i18n:getText("text_SECOND"),
"6.0 "..g_i18n:getText("text_SECOND")
}
}
LumberJack.SETTINGS.longHoldThreshold = {
-- LumberJack.longHoldThreshold = 1000
['default'] = 1,
['permission'] = 'superStrength',
['values'] = {500, 1000, 1500, 2000, 2500},
['strings'] = {
"0.5 "..g_i18n:getText("text_SECOND"),
"1.0 "..g_i18n:getText("text_SECOND"),
"1.5 "..g_i18n:getText("text_SECOND"),
"2.0 "..g_i18n:getText("text_SECOND"),
"2.5 "..g_i18n:getText("text_SECOND"),
}
}
LumberJack.SETTINGS.doubleTapThreshold = {
-- LumberJack.doubleTapThreshold = 500
['default'] = 3,
['permission'] = 'superStrength',
['values'] = {100, 200, 300, 400, 500, 600, 700, 800, 900, 1000},
['strings'] = {
"0.1 "..g_i18n:getText("text_SECOND"),
"0.2 "..g_i18n:getText("text_SECOND"),
"0.3 "..g_i18n:getText("text_SECOND"),
"0.4 "..g_i18n:getText("text_SECOND"),
"0.5 "..g_i18n:getText("text_SECOND"),
"0.6 "..g_i18n:getText("text_SECOND"),
"0.7 "..g_i18n:getText("text_SECOND"),
"0.8 "..g_i18n:getText("text_SECOND"),
"0.9 "..g_i18n:getText("text_SECOND"),
"1.0 "..g_i18n:getText("text_SECOND"),
}
}
-- HELPER FUNCTIONS
function LumberJack.setValue(id, value)
LumberJack[id] = value
end
function LumberJack.getValue(id)
return LumberJack[id]
end
function LumberJack.getStateIndex(id, value)
local value = value or LumberJack.getValue(id)
local values = LumberJack.SETTINGS[id].values
if type(value) == 'number' then
local index = LumberJack.SETTINGS[id].default
local initialdiff = math.huge
for i, v in pairs(values) do
local currentdiff = math.abs(v - value)
if currentdiff < initialdiff then
initialdiff = currentdiff
index = i
end
end
return index
else
for i, v in pairs(values) do
if value == v then
return i
end
end
end
print(id .. " USING DEFAULT")
return LumberJack.SETTINGS[id].default
end
-- READ/WRITE SETTINGS
function LumberJack.writeSettings()
local key = "lumberjack"
local userSettingsFile = Utils.getFilename("modSettings/LumberJack.xml", getUserProfileAppPath())
local xmlFile = createXMLFile("settings", userSettingsFile, key)
if xmlFile ~= 0 then
local function setXmlValue(id)
if not id or not LumberJack.SETTINGS[id] then
return
end
if LumberJack.SETTINGS[id].serverOnly and g_server == nil then
return
end
local xmlValueKey = "lumberjack." .. id .. "#value"
local value = LumberJack.getValue(id)
if type(value) == 'number' then
setXMLFloat(xmlFile, xmlValueKey, value)
elseif type(value) == 'boolean' then
setXMLBool(xmlFile, xmlValueKey, value)
end
end
for _, id in pairs(LumberJack.menuItems) do
setXmlValue(id)
end
saveXMLFile(xmlFile)
delete(xmlFile)
end
end
function LumberJack.readSettings()
local userSettingsFile = Utils.getFilename("modSettings/LumberJack.xml", getUserProfileAppPath())
if not fileExists(userSettingsFile) then
print("CREATING user settings file: "..userSettingsFile)
LumberJack.writeSettings()
return
end
local xmlFile = loadXMLFile("lumberjack", userSettingsFile)
if xmlFile ~= 0 then
local function getXmlValue(id)
local setting = LumberJack.SETTINGS[id]
if setting then
local xmlValueKey = "lumberjack." .. id .. "#value"
local value = LumberJack.getValue(id)
local value_string = tostring(value)
if hasXMLProperty(xmlFile, xmlValueKey) then
if type(value) == 'number' then
value = getXMLFloat(xmlFile, xmlValueKey) or value
if value == math.floor(value) then
value_string = tostring(value)
else
value_string = string.format("%.3f", value)
end
elseif type(value) == 'boolean' then
value = getXMLBool(xmlFile, xmlValueKey) or false
value_string = tostring(value)
end
if g_server == nil and type(value) == 'number' then
-- print("CLIENT - restrict to closest value")
value = setting.values[LumberJack.getStateIndex(id, value)]
end
LumberJack.setValue(id, value)
return value_string
end
end
return "MISSING"
end
print("LUMBERJACK SETTINGS")
for _, id in pairs(LumberJack.menuItems) do
local valueString = getXmlValue(id)
print(" " .. id .. ": " .. valueString)
end
delete(xmlFile)
end
end
LumberJackControls = {}
function LumberJackControls.onMenuOptionChanged(self, state, menuOption)
local id = menuOption.id
local setting = LumberJack.SETTINGS
local value = setting[id].values[state]
if value ~= nil then
LumberJack.setValue(id, value)
end
if LumberJack.SETTINGS[id].serverOnly and type(LumberJack.SETTINGS[id].values[1]) == "boolean" then
ToggleServerSettingEvent.sendEvent(id)
end
if id == 'superStrengthValue' or id == 'normalStrengthValue' or
id == 'superDistanceValue' or id == 'normalDistanceValue' then
SuperStrengthEvent.sendEvent(LumberJack.superStrength)
end
LumberJack.writeSettings()
end
local function updateFocusIds(element)
if not element then
return
end
element.focusId = FocusManager:serveAutoFocusId()
for _, child in pairs(element.elements) do
updateFocusIds(child)
end
end
function LumberJack.injectMenu()
--print("LumberJack - INJECT MENU")
--print("IN GAME MENU")
local inGameMenu = g_gui.screenControllers[InGameMenu]
local settingsPage = inGameMenu.pageSettings
-- The name is required as otherwise the focus manager would ignore any control which has LumberJack as a callback target, believing it belonged to a different UI
LumberJackControls.name = settingsPage.name
-- print("GAME SETTINGS")
-- local gameSettings = g_gui.frames["ingameMenuSettings"]
-- local gameSettingsLayout = g_inGameMenu["gameSettingsLayout"]
function LumberJack.addBinaryMenuOption(id)
local callback = "onMenuOptionChanged"
local i18n_title = "setting_lumberJack_" .. id
local i18n_tooltip = "toolTip_lumberJack_" .. id
local options = LumberJack.SETTINGS[id].strings
local originalBox = settingsPage.checkWoodHarvesterAutoCutBox
local menuOptionBox = originalBox:clone(settingsPage.generalSettingsLayout)
menuOptionBox.id = id .. "box"
local menuBinaryOption = menuOptionBox.elements[1]
menuBinaryOption.id = id
menuBinaryOption.target = LumberJackControls
menuBinaryOption:setCallback("onClickCallback", callback)
menuBinaryOption:setDisabled(false)
local toolTip = menuBinaryOption.elements[1]
toolTip:setText(g_i18n:getText(i18n_tooltip))
--menuOption.elements[1].text = g_i18n:getText(i18n_title)
local setting = menuOptionBox.elements[2]
setting:setText(g_i18n:getText(i18n_title))
menuBinaryOption:setTexts({unpack(options)})
menuBinaryOption:setState(LumberJack.getStateIndex(id))
LumberJack.CONTROLS[id] = menuBinaryOption
-- Assign new focus IDs to the controls as clone() copies the existing ones which are supposed to be unique
updateFocusIds(menuOptionBox)
table.insert(settingsPage.controlsList, menuOptionBox)
print(" added " .. id)
-- DebugUtil.printTableRecursively(menuOption.elements, "--", 0, 1)
return menuOptionBox
end
function LumberJack.addMultiMenuOption(id)
local callback = "onMenuOptionChanged"
local i18n_title = "setting_lumberJack_" .. id
local i18n_tooltip = "toolTip_lumberJack_" .. id
local options = LumberJack.SETTINGS[id].strings
local originalBox = settingsPage.multiVolumeVoiceBox
local menuOptionBox = originalBox:clone(settingsPage.generalSettingsLayout)
menuOptionBox.id = id .. "box"
local menuMultiOption = menuOptionBox.elements[1]
menuMultiOption.id = id
menuMultiOption.target = LumberJackControls
menuMultiOption:setCallback("onClickCallback", callback)
menuMultiOption:setDisabled(false)
local toolTip = menuMultiOption.elements[1]
toolTip:setText(g_i18n:getText(i18n_tooltip))
--menuOption.elements[1].text = g_i18n:getText(i18n_title)
local setting = menuOptionBox.elements[2]
setting:setText(g_i18n:getText(i18n_title))
menuMultiOption:setTexts({unpack(options)})
menuMultiOption:setState(LumberJack.getStateIndex(id))
LumberJack.CONTROLS[id] = menuMultiOption
-- Assign new focus IDs to the controls as clone() copies the existing ones which are supposed to be unique
updateFocusIds(menuOptionBox)
table.insert(settingsPage.controlsList, menuOptionBox)
print(" added " .. id)
-- DebugUtil.printTableRecursively(menuOption.elements, "--", 0, 1)
return menuOptionBox
end
-- Add section
local sectionTitle = nil
for idx, elem in ipairs(settingsPage.generalSettingsLayout.elements) do
if elem.name == "sectionHeader" then
sectionTitle = elem:clone(settingsPage.generalSettingsLayout)
break
end
end
if sectionTitle then
sectionTitle:setText(g_i18n:getText("menu_LUMBERJACK_TITLE"))
else
sectionTitle = TextElement.new()
sectionTitle:applyProfile("fs25_settingsSectionHeader", true)
sectionTitle:setText(g_i18n:getText("menu_LUMBERJACK_TITLE"))
sectionTitle.name = "sectionHeader"
settingsPage.generalSettingsLayout:addElement(sectionTitle)
end
-- Apply a new focus ID in either case - either the element doesn't have one right now, or it has an already used one
-- This is required for proper keyboard/controller navigation in the menu
sectionTitle.focusId = FocusManager:serveAutoFocusId()
table.insert(settingsPage.controlsList, sectionTitle)
-- The title needs to be passed to the focus manager later on, otherwise skipping over the section title with up/down keys will fail
LumberJack.CONTROLS[sectionTitle.name] = sectionTitle
for _, id in pairs(LumberJack.menuItems) do
if #LumberJack.SETTINGS[id].values == 2 then
LumberJack.addBinaryMenuOption(id)
else
LumberJack.addMultiMenuOption(id)
end
end
settingsPage.generalSettingsLayout:invalidateLayout()
-- MULTIPLAYER PERMISSIONS
local multiplayerPage = inGameMenu.pageMultiplayer
function LumberJack.addMultiplayerPermission(id)
local newPermissionName = id..'PermissionCheckbox'
local i18n_title = "permission_lumberJack_" .. id
--registerControls seems to not exist anymore
--multiplayerPage:registerControls({newPermissionName})
local original = multiplayerPage.cutTreesPermissionCheckbox.parent
local newPermissionRow = original:clone(multiplayerPage.permissionsBox)
local newPermissionCheckbox = newPermissionRow.elements[1]
newPermissionCheckbox.id = newPermissionName
local newPermissionLabel = newPermissionRow.elements[2]
newPermissionLabel:setText(g_i18n:getText(i18n_title))
table.insert(multiplayerPage.permissionRow, newPermissionRow)
multiplayerPage.controlIDs[newPermissionName] = true
multiplayerPage.permissionCheckboxes[id] = newPermissionCheckbox
multiplayerPage.checkboxPermissions[newPermissionCheckbox] = id
end
for _, id in pairs(LumberJack.multiplayerPermissions) do
LumberJack.addMultiplayerPermission(id)
end
-- ENABLE/DISABLE OPTIONS FOR CLIENTS
InGameMenuSettingsFrame.onFrameOpen = Utils.appendedFunction(InGameMenuSettingsFrame.onFrameOpen, function()
local isAdmin = g_currentMission:getIsServer() or g_currentMission.isMasterUser
for _, id in pairs(LumberJack.menuItems) do
local menuOption = LumberJack.CONTROLS[id]
menuOption:setState(LumberJack.getStateIndex(id))
if LumberJack.SETTINGS[id].disabled then
menuOption:setDisabled(true)
elseif LumberJack.SETTINGS[id].serverOnly and g_server == nil then
menuOption:setDisabled(not isAdmin)
else
local permission = LumberJack.SETTINGS[id].permission
local hasPermission = g_currentMission:getHasPlayerPermission(permission)
-- debugPrint(string.format("Player has permission \"%s\"?: ", permission or "any") .. tostring(hasPermission))
local canChange = isAdmin or hasPermission or false
menuOption:setDisabled(not canChange)
end
end
end)
end
-- Allow keyboard navigation of menu options
FocusManager.setGui = Utils.appendedFunction(FocusManager.setGui, function(_, gui)
if gui == "ingameMenuSettings" then
-- Let the focus manager know about our custom controls now (earlier than this point seems to fail)
for _, control in pairs(LumberJack.CONTROLS) do
if not control.focusId or not FocusManager.currentFocusData.idToElementMapping[control.focusId] then
if not FocusManager:loadElementFromCustomValues(control, nil, nil, false, false) then
Logging.warning("Could not register control %s with the focus manager. Selecting the control might be bugged", control.id or control.name or control.focusId)
end
end
end
-- Invalidate the layout so the up/down connections are analyzed again by the focus manager
local settingsPage = g_gui.screenControllers[InGameMenu].pageSettings
settingsPage.generalSettingsLayout:invalidateLayout()
end
end)
--SEND SETTINGS TO CLIENT:
FSBaseMission.sendInitialClientState = Utils.appendedFunction(FSBaseMission.sendInitialClientState,
function(self, connection, user, farm)
for _, id in pairs(LumberJack.menuItems) do
if LumberJack.SETTINGS[id].serverOnly and type(LumberJack.SETTINGS[id].values[1]) == "boolean" then
ToggleServerSettingEvent.sendEvent(id)
end
end
end)