-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathConfig.cpp
More file actions
620 lines (549 loc) · 30.6 KB
/
Copy pathConfig.cpp
File metadata and controls
620 lines (549 loc) · 30.6 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
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
// ReSharper disable StringLiteralTypo
#include "Config.h"
#include <filesystem>
#include "common/CommonUtils.h"
#include "f4vr/F4VRUtils.h"
#include "vrcf/VRControllersManager.h"
using namespace common;
namespace frik
{
/**
* Load the FRIK.ini config, hide meshes, and weapon offsets.
* Handle creating the FRIK.ini file if it doesn't exist.
* Handle updating the FRIK.ini file if the version is old.
*/
void Config::load()
{
setupFolders();
migrateConfigFilesIfNeeded();
logger::info("Load ini config...");
loadIniConfig();
logger::info("Load hide meshes...");
loadHideMeshes();
logger::info("Load pipboy offsets...");
loadPipboyOffsets();
logger::info("Load weapon offsets...");
loadWeaponsOffsets();
}
/**
* Load only the FRIK.ini config from the file and override in-memory values.
*/
void Config::loadIniOnly()
{
logger::info("Load ini config only...");
loadIniConfig();
}
/**
* Reloads the config for Fallout London VR mod.
* Using different config file as the mod changes a lot of the game.
*/
void Config::reloadForFalloutLondonVR()
{
stopIniConfigFileWatch();
_iniFilePath = FRIK_FOLVR_INI_PATH;
loadIniOnly();
}
void Config::setFlashlightLocation(const FlashlightLocation location)
{
flashlightLocation = location;
saveIniConfigValue(INI_SECTION_MAIN, "iFlashlightLocation", static_cast<int>(flashlightLocation));
}
void Config::toggleIsHoloPipboy()
{
isHoloPipboy = !isHoloPipboy;
saveIniConfigValue(INI_SECTION_MAIN, "HoloPipBoyEnabled", isHoloPipboy);
}
void Config::toggleDampenPipboyScreen()
{
dampenPipboyScreenMode = static_cast<DampenPipboyScreenMode>((static_cast<uint8_t>(dampenPipboyScreenMode) + 1) % 3);
saveIniConfigValue(INI_SECTION_MAIN, "iDampenPipboyScreenMode", static_cast<int>(dampenPipboyScreenMode));
}
void Config::togglePipBoyOpenWhenLookAt()
{
pipboyOpenWhenLookAt = !pipboyOpenWhenLookAt;
saveIniConfigValue(INI_SECTION_MAIN, "PipBoyOpenWhenLookAt", pipboyOpenWhenLookAt);
}
void Config::togglePipBoyCloseWhenLookAway()
{
pipboyCloseWhenLookAway = !pipboyCloseWhenLookAway;
saveIniConfigValue(INI_SECTION_MAIN, "PipBoyCloseWhenLookAway", pipboyCloseWhenLookAway);
}
void Config::savePipboyScale(const float scale)
{
pipBoyScale = scale;
saveIniConfigValue(INI_SECTION_MAIN, "PipboyScale", pipBoyScale);
}
void Config::saveIsPlayingSeated(const bool iIsPlayingSeated)
{
this->isPlayingSeated = iIsPlayingSeated;
saveIniConfigValue(INI_SECTION_MAIN, "bIsPlayingSeated", iIsPlayingSeated);
}
void Config::saveHideHeadEquipment(const bool hide)
{
hideHeadEquipment = hide;
saveIniConfigValue(INI_SECTION_MAIN, "bHidePlayerHeadEquipment", hide);
}
void Config::saveDampenHands(const bool iDampenHands)
{
this->dampenHands = iDampenHands;
saveIniConfigValue(INI_SECTION_MAIN, "DampenHands", iDampenHands);
}
float Config::getPlayerBodyOffsetUp() const
{
if (isPlayingSeated) {
return f4vr::isInPowerArmor() ? playerBodyOffsetUpSittingInPA : playerBodyOffsetUpSitting;
}
return f4vr::isInPowerArmor() ? playerBodyOffsetUpStandingInPA : playerBodyOffsetUpStanding;
}
void Config::setPlayerBodyOffsetUp(const float value)
{
if (isPlayingSeated) {
if (f4vr::isInPowerArmor()) {
playerBodyOffsetUpSittingInPA = value;
} else {
playerBodyOffsetUpSitting = value;
}
} else {
if (f4vr::isInPowerArmor()) {
playerBodyOffsetUpStandingInPA = value;
} else {
playerBodyOffsetUpStanding = value;
}
}
}
float Config::getPlayerBodyOffsetForward() const
{
if (isPlayingSeated) {
return f4vr::isInPowerArmor() ? playerBodyOffsetForwardSittingInPA : playerBodyOffsetForwardSitting;
}
return f4vr::isInPowerArmor() ? playerBodyOffsetForwardStandingInPA : playerBodyOffsetForwardStanding;
}
void Config::setPlayerBodyOffsetForward(const float value)
{
if (isPlayingSeated) {
if (f4vr::isInPowerArmor()) {
playerBodyOffsetForwardSittingInPA = value;
} else {
playerBodyOffsetForwardSitting = value;
}
} else {
if (f4vr::isInPowerArmor()) {
playerBodyOffsetForwardStandingInPA = value;
} else {
playerBodyOffsetForwardStanding = value;
}
}
}
float Config::getPlayerHMDOffsetUp() const
{
if (isPlayingSeated) {
return f4vr::isInPowerArmor() ? playerHMDOffsetUpSittingInPA : playerHMDOffsetUpSitting;
}
return f4vr::isInPowerArmor() ? playerHMDOffsetUpStandingInPA : playerHMDOffsetUpStanding;
}
void Config::setPlayerHMDOffsetUp(const float value)
{
if (isPlayingSeated) {
if (f4vr::isInPowerArmor()) {
playerHMDOffsetUpSittingInPA = value;
} else {
playerHMDOffsetUpSitting = value;
}
} else {
if (f4vr::isInPowerArmor()) {
playerHMDOffsetUpStandingInPA = value;
} else {
playerHMDOffsetUpStanding = value;
}
}
}
float Config::getPlayerLegSlackAdjustOffset() const
{
if (isPlayingSeated) {
return f4vr::isInPowerArmor() ? playerLegSlackAdjustOffsetSittingInPA : playerLegSlackAdjustOffsetSitting;
}
return f4vr::isInPowerArmor() ? playerLegSlackAdjustOffsetStandingInPA : playerLegSlackAdjustOffsetStanding;
}
void Config::setPlayerLegSlackAdjustOffset(const float value)
{
if (isPlayingSeated) {
if (f4vr::isInPowerArmor()) {
playerLegSlackAdjustOffsetSittingInPA = value;
} else {
playerLegSlackAdjustOffsetSitting = value;
}
} else {
if (f4vr::isInPowerArmor()) {
playerLegSlackAdjustOffsetStandingInPA = value;
} else {
playerLegSlackAdjustOffsetStanding = value;
}
}
}
/**
* Open the FRIK.ini file in Notepad for editing.
*/
void Config::openInNotepad()
{
ShellExecuteA(nullptr, "open", "notepad.exe", FRIK_INI_PATH.c_str(), nullptr, SW_SHOWNORMAL);
}
/**
* Get the Pipboy offset of the currently used Pipboy type.
*/
RE::NiTransform Config::getPipboyOffset()
{
return _pipboyOffsets[getPipboyOffsetKey()];
}
/**
* Get the factory-default Pipboy offset for the currently used Pipboy type, read from the embedded resources.
*/
RE::NiTransform Config::getDefaultPipboyOffset()
{
auto defaults = loadEmbeddedOffsets(IDR_PIPBOY_HOLO_OFFSETS, IDR_PIPBOY_ATTABOY_OFFSETS);
return defaults[getPipboyOffsetKey()];
}
/**
* Save the Pipboy offset to the offsets map.
*/
bool Config::savePipboyOffset(const RE::NiTransform& transform)
{
const auto key = getPipboyOffsetKey();
_pipboyOffsets[key] = transform;
return saveOffsetsToJsonFile(key, transform, getPipboyOffsetPath());
}
/**
* Get weapon offsets for given weapon name and mode.
* Use non-PA mode if PA mode offsets not found.
*/
std::optional<RE::NiTransform> Config::getWeaponOffsets(const std::string& name, const WeaponOffsetsMode& mode, const bool inPA) const
{
const auto it = _weaponsOffsets.find(getWeaponNameWithMode(name, mode, inPA, f4vr::isLeftHandedMode()));
if (it != _weaponsOffsets.end()) {
return it->second;
}
// Check without PA (historic)
return inPA ? getWeaponOffsets(name, mode, false) : std::nullopt;
}
/**
* Save the weapon offset to config and filesystem.
*/
bool Config::saveWeaponOffsets(const std::string& name, const RE::NiTransform& transform, const WeaponOffsetsMode& mode, const bool inPA)
{
const auto fullName = getWeaponNameWithMode(name, mode, inPA, f4vr::isLeftHandedMode());
_weaponsOffsets[fullName] = transform;
const auto offsetFilePath = fs::path{ WEAPONS_OFFSETS_PATH } / (sanitizePathWindows(fullName) + ".json");
return saveOffsetsToJsonFile(fullName, transform, offsetFilePath.string());
}
/**
* Remove the weapon offset from the config and filesystem.
*/
void Config::removeWeaponOffsets(const std::string& name, const WeaponOffsetsMode& mode, const bool inPA, const bool replaceWithEmbedded)
{
const auto fullName = getWeaponNameWithMode(name, mode, inPA, f4vr::isLeftHandedMode());
_weaponsOffsets.erase(fullName);
if (replaceWithEmbedded && _weaponsEmbeddedOffsets.contains(fullName)) {
_weaponsOffsets[fullName] = _weaponsEmbeddedOffsets[fullName];
}
const auto path = WEAPONS_OFFSETS_PATH + "\\" + fullName + ".json";
logger::info("Removing weapon offsets '{}', file: '{}'", fullName.c_str(), path.c_str());
if (!std::filesystem::remove(WEAPONS_OFFSETS_PATH + "\\" + fullName + ".json")) {
logger::warn("Failed to remove weapon offset file: {}", fullName.c_str());
}
}
void Config::loadIniConfigInternal(const CSimpleIniA& ini)
{
// Player/Skeleton
setScale = ini.GetBoolValue(INI_SECTION_MAIN, "setScale", false);
fVrScale = static_cast<float>(ini.GetDoubleValue(INI_SECTION_MAIN, "fVrScale", 70.0));
playerHeight = static_cast<float>(ini.GetDoubleValue(INI_SECTION_MAIN, "PlayerHeight", 120.4828f));
armLength = static_cast<float>(ini.GetDoubleValue(INI_SECTION_MAIN, "armLength", 36.74f));
// Head Geometry Hide
hideHead = ini.GetBoolValue(INI_SECTION_MAIN, "bHidePlayerHead");
hideHeadEquipment = ini.GetBoolValue(INI_SECTION_MAIN, "bHidePlayerHeadEquipment");
hideSkin = ini.GetBoolValue(INI_SECTION_MAIN, "bHidePlayerSkin");
// is the player playing standing or sitting
isPlayingSeated = ini.GetBoolValue(INI_SECTION_MAIN, "bIsPlayingSeated", false);
// HMD, body, and leg slack adjust offsets
playerHMDOffsetUpStanding = static_cast<float>(ini.GetDoubleValue(INI_SECTION_MAIN, "fPlayerHMDOffsetUpStanding", 8.0f));
playerBodyOffsetUpStanding = static_cast<float>(ini.GetDoubleValue(INI_SECTION_MAIN, "fPlayerBodyOffsetUpStanding", -3.0f));
playerLegSlackAdjustOffsetStanding = static_cast<float>(ini.GetDoubleValue(INI_SECTION_MAIN, "fPlayerLegSlackAdjustOffsetStanding", 0.0f));
playerBodyOffsetForwardStanding = static_cast<float>(ini.GetDoubleValue(INI_SECTION_MAIN, "fPlayerBodyOffsetForwardStanding", -3.0f));
playerHMDOffsetUpSitting = static_cast<float>(ini.GetDoubleValue(INI_SECTION_MAIN, "fPlayerHMDOffsetUpSitting", 31.0f));
playerBodyOffsetUpSitting = static_cast<float>(ini.GetDoubleValue(INI_SECTION_MAIN, "fPlayerBodyOffsetUpSitting", -4.0f));
playerLegSlackAdjustOffsetSitting = static_cast<float>(ini.GetDoubleValue(INI_SECTION_MAIN, "fPlayerLegSlackAdjustOffsetSitting", 0.0f));
playerBodyOffsetForwardSitting = static_cast<float>(ini.GetDoubleValue(INI_SECTION_MAIN, "fPlayerBodyOffsetForwardSitting", 2.0f));
playerHMDOffsetUpStandingInPA = static_cast<float>(ini.GetDoubleValue(INI_SECTION_MAIN, "fPlayerHMDOffsetUpStandingInPA", 23.0f));
playerBodyOffsetUpStandingInPA = static_cast<float>(ini.GetDoubleValue(INI_SECTION_MAIN, "fPlayerBodyOffsetUpStandingInPA", -8.0f));
playerLegSlackAdjustOffsetStandingInPA = static_cast<float>(ini.GetDoubleValue(INI_SECTION_MAIN, "fPlayerLegSlackAdjustOffsetStandingInPA", 0.0f));
playerBodyOffsetForwardStandingInPA = static_cast<float>(ini.GetDoubleValue(INI_SECTION_MAIN, "fPlayerBodyOffsetForwardStandingInPA", -15.0f));
playerHMDOffsetUpSittingInPA = static_cast<float>(ini.GetDoubleValue(INI_SECTION_MAIN, "fPlayerHMDOffsetUpSittingInPA", 53.0f));
playerBodyOffsetUpSittingInPA = static_cast<float>(ini.GetDoubleValue(INI_SECTION_MAIN, "fPlayerBodyOffsetUpSittingInPA", -7.0f));
playerLegSlackAdjustOffsetSittingInPA = static_cast<float>(ini.GetDoubleValue(INI_SECTION_MAIN, "fPlayerLegSlackAdjustOffsetSittingInPA", 0.0f));
playerBodyOffsetForwardSittingInPA = static_cast<float>(ini.GetDoubleValue(INI_SECTION_MAIN, "fPlayerBodyOffsetForwardSittingInPA", -9.0f));
headBackPositionOffset = static_cast<float>(ini.GetDoubleValue(INI_SECTION_MAIN, "fHeadBackPositionOffset", 4));
skeletonLegSlackTarget = static_cast<float>(ini.GetDoubleValue(INI_SECTION_MAIN, "fSkeletonLegSlackTarget", 2.5f));
comfortSneakHackStaticBodyPitchAngle = static_cast<float>(ini.GetDoubleValue(INI_SECTION_MAIN, "fComfortSneakHackStaticBodyPitchAngle", 30.0f));
// Pipboy
pipBoyScale = static_cast<float>(ini.GetDoubleValue(INI_SECTION_MAIN, "PipboyScale", 1.0));
hidePipboy = ini.GetBoolValue(INI_SECTION_MAIN, "hidePipboy");
isHoloPipboy = ini.GetBoolValue(INI_SECTION_MAIN, "HoloPipBoyEnabled", true);
leftHandedPipBoy = ini.GetBoolValue(INI_SECTION_MAIN, "PipboyRightArmLeftHandedMode");
enablePrimaryControllerPipboyUse = ini.GetBoolValue(INI_SECTION_MAIN, "PipboyUIPrimaryController", true);
pipboyOpenWhenLookAt = ini.GetBoolValue(INI_SECTION_MAIN, "PipBoyOpenWhenLookAt", false);
pipboyCloseWhenLookAway = ini.GetBoolValue(INI_SECTION_MAIN, "PipBoyCloseWhenLookAway", false);
pipboyCloseWhenMovingWhileLookingAway = ini.GetBoolValue(INI_SECTION_MAIN, "AllowMovementWhenNotLookingAtPipboy", true);
pipboyHolsterWeaponForOperation = ini.GetBoolValue(INI_SECTION_MAIN, "bHolsterWeaponForOperation", false);
pipboyLookAtThreshold = static_cast<float>(ini.GetDoubleValue(INI_SECTION_MAIN, "PipBoyLookAtThreshold", 0.75f));
pipboyLookAwayThreshold = static_cast<float>(ini.GetDoubleValue(INI_SECTION_MAIN, "PipBoyLookAwayThreshold", 0.3f));
pipboyOperationFingerDetectionRange = static_cast<float>(ini.GetDoubleValue(INI_SECTION_MAIN, "fPipboyOperationFingerDetectionRange", 12.0));
pipBoyOnDelay = static_cast<int>(ini.GetLongValue(INI_SECTION_MAIN, "PipBoyOnDelay", 400));
pipBoyOffDelay = static_cast<int>(ini.GetLongValue(INI_SECTION_MAIN, "PipBoyOffDelay", 1000));
pipboyOpenBinding =
getInputBindingValue(ini, INI_SECTION_MAIN, "sPipboyOpenButton", vrcf::InputBinding{ vrcf::Hand::Offhand, vrcf::ActivationType::Tap, vr::k_EButton_SteamVR_Trigger });
pipboyCloseBinding =
getInputBindingValue(ini, INI_SECTION_MAIN, "sPipboyCloseButton", vrcf::InputBinding{ vrcf::Hand::Offhand, vrcf::ActivationType::Tap, vr::k_EButton_Grip });
holdPipboyScreenBinding = getInputBindingValue(ini,
INI_SECTION_MAIN,
"sHoldPipboyScreenButton",
vrcf::InputBinding{
.hand = vrcf::Hand::Offhand,
.type = vrcf::ActivationType::HoldDown,
.button = vr::k_EButton_Grip,
.duration = 0.3f,
});
enterPipboyConfigBinding = getInputBindingValue(ini,
INI_SECTION_MAIN,
"sEnterPipboyConfigButton",
vrcf::InputBinding{
.hand = vrcf::Hand::Primary,
.type = vrcf::ActivationType::LongPress,
.button = vr::k_EButton_SteamVR_Touchpad,
.duration = 2.0f,
});
// Torch/Flashlight
removeFlashlight = ini.GetBoolValue(INI_SECTION_MAIN, "bRemoveFlashlight", false);
flashlightLocation = static_cast<FlashlightLocation>(ini.GetLongValue(INI_SECTION_MAIN, "iFlashlightLocation", 0));
// change hand / head button (one binding per hand)
switchTorchLeftBinding =
getInputBindingValue(ini, INI_SECTION_MAIN, "sSwitchTorchLeftButton", vrcf::InputBinding{ vrcf::Hand::Left, vrcf::ActivationType::Tap, vr::k_EButton_Grip });
switchTorchRightBinding =
getInputBindingValue(ini, INI_SECTION_MAIN, "sSwitchTorchRightButton", vrcf::InputBinding{ vrcf::Hand::Right, vrcf::ActivationType::Tap, vr::k_EButton_Grip });
// Fallout London VR support
attaboyGrabBinding =
getInputBindingValue(ini, INI_SECTION_MAIN, "sAttaboyGrabButton", vrcf::InputBinding{ vrcf::Hand::Left, vrcf::ActivationType::Tap, vr::k_EButton_Grip });
attaboyGrabActivationDistance = static_cast<float>(ini.GetDoubleValue(INI_SECTION_MAIN, "fAttaboyGrabActivationDistance", 15.0));
// Two-handed gripping
enableOffHandGripping = ini.GetBoolValue(INI_SECTION_MAIN, "EnableOffHandGripping", true);
enableGripButtonToGrap = ini.GetBoolValue(INI_SECTION_MAIN, "EnableGripButton", true);
enableGripButtonToLetGo = ini.GetBoolValue(INI_SECTION_MAIN, "EnableGripButtonToLetGo", true);
onePressGripButton = ini.GetBoolValue(INI_SECTION_MAIN, "EnableGripButtonOnePress", true);
gripLetGoThreshold = static_cast<float>(ini.GetDoubleValue(INI_SECTION_MAIN, "GripLetGoThreshold", 15.0f));
offhandGripBinding = getInputBindingValue(ini, INI_SECTION_MAIN, "sGripButton", vrcf::InputBinding{ vrcf::Hand::Offhand, vrcf::ActivationType::Press, vr::k_EButton_Grip });
offhandGripHoldBinding =
getInputBindingValue(ini, INI_SECTION_MAIN, "sGripHoldButton", vrcf::InputBinding{ vrcf::Hand::Offhand, vrcf::ActivationType::HoldDown, vr::k_EButton_Grip });
// Dampen hands
dampenHands = ini.GetBoolValue(INI_SECTION_MAIN, "DampenHands", true);
dampenHandsInVanillaScope = ini.GetBoolValue(INI_SECTION_MAIN, "DampenHandsInVanillaScope", true);
dampenHandsRotation = static_cast<float>(ini.GetDoubleValue(INI_SECTION_MAIN, "DampenHandsRotation", 0.7f));
dampenHandsTranslation = static_cast<float>(ini.GetDoubleValue(INI_SECTION_MAIN, "DampenHandsTranslation", 0.7f));
dampenHandsRotationInVanillaScope = static_cast<float>(ini.GetDoubleValue(INI_SECTION_MAIN, "DampenHandsRotationInVanillaScope", 0.2f));
dampenHandsTranslationInVanillaScope = static_cast<float>(ini.GetDoubleValue(INI_SECTION_MAIN, "DampenHandsTranslationInVanillaScope", 0.2f));
// Dampen Pipboy
dampenPipboyScreenMode = static_cast<DampenPipboyScreenMode>(ini.GetLongValue(INI_SECTION_MAIN, "iDampenPipboyScreenMode", 1));
dampenPipboyThreshold = static_cast<float>(ini.GetDoubleValue(INI_SECTION_MAIN, "fDampenPipboyThreshold", 1.1f));
dampenPipboyMultiplier = static_cast<float>(ini.GetDoubleValue(INI_SECTION_MAIN, "fDampenPipboyMultiplier", 0.7f));
// Misc
showPAHUD = ini.GetBoolValue(INI_SECTION_MAIN, "showPAHUD");
selfieOutFrontDistance = static_cast<float>(ini.GetDoubleValue(INI_SECTION_MAIN, "selfieOutFrontDistance", 120.0));
selfieIgnoreHideFlags = ini.GetBoolValue(INI_SECTION_MAIN, "bSelfieIgnoreHideFlags", true);
toggleSelfieBinding =
getInputBindingValue(ini, INI_SECTION_MAIN, "sToggleSelfieButton", vrcf::InputBinding{ vrcf::Hand::Primary, vrcf::ActivationType::Tap, vr::k_EButton_A });
scopeAdjustDistance = static_cast<float>(ini.GetDoubleValue(INI_SECTION_MAIN, "ScopeAdjustDistance", 15.f));
openMainConfigBinding = getInputBindingValue(ini,
INI_SECTION_MAIN,
"sOpenConfigButton",
vrcf::InputBinding{
.hand = vrcf::Hand::Primary,
.type = vrcf::ActivationType::LongPress,
.button = vr::k_EButton_SteamVR_Touchpad,
.modifier = vrcf::InputModifier{ vr::k_EButton_SteamVR_Touchpad, vrcf::Hand::Offhand },
.duration = 1.5f,
});
// special disable of Fallout London so Pipboy can be used - a hacky hack for a specific player
ignoreFalloutLondonVR = ini.GetBoolValue(INI_SECTION_MAIN, "bIgnoreFalloutLondonVR", true);
//Smooth Movement
disableSmoothMovement = ini.GetBoolValue(INI_SECTION_SMOOTH_MOVEMENT, "DisableSmoothMovement");
smoothingAmount = static_cast<float>(ini.GetDoubleValue(INI_SECTION_SMOOTH_MOVEMENT, "SmoothAmount", 15.0));
smoothingAmountHorizontal = static_cast<float>(ini.GetDoubleValue(INI_SECTION_SMOOTH_MOVEMENT, "SmoothAmountHorizontal", 5.0));
dampingMultiplier = static_cast<float>(ini.GetDoubleValue(INI_SECTION_SMOOTH_MOVEMENT, "Damping", 1.0));
dampingMultiplierHorizontal = static_cast<float>(ini.GetDoubleValue(INI_SECTION_SMOOTH_MOVEMENT, "DampingHorizontal", 1.0));
stoppingMultiplier = static_cast<float>(ini.GetDoubleValue(INI_SECTION_SMOOTH_MOVEMENT, "StoppingMultiplier", 0.6f));
stoppingMultiplierHorizontal = static_cast<float>(ini.GetDoubleValue(INI_SECTION_SMOOTH_MOVEMENT, "StoppingMultiplierHorizontal", 0.6f));
disableInteriorSmoothing = ini.GetBoolValue(INI_SECTION_SMOOTH_MOVEMENT, "DisableInteriorSmoothing", true);
disableInteriorSmoothingHorizontal = ini.GetBoolValue(INI_SECTION_SMOOTH_MOVEMENT, "DisableInteriorSmoothingHorizontal", true);
}
void Config::saveIniConfigInternal(CSimpleIniA& ini)
{
ini.SetBoolValue(INI_SECTION_MAIN, "bIsPlayingSeated", isPlayingSeated);
ini.SetDoubleValue(INI_SECTION_MAIN, "fVrScale", fVrScale);
ini.SetBoolValue(INI_SECTION_MAIN, "bHidePlayerHead", hideHead);
ini.SetBoolValue(INI_SECTION_MAIN, "bHidePlayerHeadEquipment", hideHeadEquipment);
ini.SetDoubleValue(INI_SECTION_MAIN, "fPlayerBodyOffsetUpStanding", playerBodyOffsetUpStanding);
ini.SetDoubleValue(INI_SECTION_MAIN, "fPlayerBodyOffsetForwardStanding", playerBodyOffsetForwardStanding);
ini.SetDoubleValue(INI_SECTION_MAIN, "fPlayerHMDOffsetUpStanding", playerHMDOffsetUpStanding);
ini.SetDoubleValue(INI_SECTION_MAIN, "fPlayerLegSlackAdjustOffsetStanding", playerLegSlackAdjustOffsetStanding);
ini.SetDoubleValue(INI_SECTION_MAIN, "fPlayerBodyOffsetUpSitting", playerBodyOffsetUpSitting);
ini.SetDoubleValue(INI_SECTION_MAIN, "fPlayerBodyOffsetForwardSitting", playerBodyOffsetForwardSitting);
ini.SetDoubleValue(INI_SECTION_MAIN, "fPlayerHMDOffsetUpSitting", playerHMDOffsetUpSitting);
ini.SetDoubleValue(INI_SECTION_MAIN, "fPlayerLegSlackAdjustOffsetSitting", playerLegSlackAdjustOffsetSitting);
ini.SetDoubleValue(INI_SECTION_MAIN, "fPlayerBodyOffsetUpStandingInPA", playerBodyOffsetUpStandingInPA);
ini.SetDoubleValue(INI_SECTION_MAIN, "fPlayerBodyOffsetForwardStandingInPA", playerBodyOffsetForwardStandingInPA);
ini.SetDoubleValue(INI_SECTION_MAIN, "fPlayerHMDOffsetUpStandingInPA", playerHMDOffsetUpStandingInPA);
ini.SetDoubleValue(INI_SECTION_MAIN, "fPlayerLegSlackAdjustOffsetStandingInPA", playerLegSlackAdjustOffsetStandingInPA);
ini.SetDoubleValue(INI_SECTION_MAIN, "fPlayerBodyOffsetUpSittingInPA", playerBodyOffsetUpSittingInPA);
ini.SetDoubleValue(INI_SECTION_MAIN, "fPlayerBodyOffsetForwardSittingInPA", playerBodyOffsetForwardSittingInPA);
ini.SetDoubleValue(INI_SECTION_MAIN, "fPlayerHMDOffsetUpSittingInPA", playerHMDOffsetUpSittingInPA);
ini.SetDoubleValue(INI_SECTION_MAIN, "fPlayerLegSlackAdjustOffsetSittingInPA", playerLegSlackAdjustOffsetSittingInPA);
ini.SetDoubleValue(INI_SECTION_MAIN, "fSkeletonLegSlackTarget", skeletonLegSlackTarget);
ini.SetDoubleValue(INI_SECTION_MAIN, "armLength", armLength);
ini.SetBoolValue(INI_SECTION_MAIN, "hidePipboy", hidePipboy);
ini.SetDoubleValue(INI_SECTION_MAIN, "PipboyScale", pipBoyScale);
ini.SetBoolValue(INI_SECTION_MAIN, "HoloPipBoyEnabled", isHoloPipboy);
ini.SetLongValue(INI_SECTION_MAIN, "iFlashlightLocation", static_cast<int>(flashlightLocation));
ini.SetLongValue(INI_SECTION_MAIN, "iDampenPipboyScreenMode", static_cast<int>(dampenPipboyScreenMode));
ini.SetBoolValue(INI_SECTION_MAIN, "PipBoyOpenWhenLookAt", pipboyOpenWhenLookAt);
ini.SetBoolValue(INI_SECTION_MAIN, "DampenHands", dampenHands);
ini.SetBoolValue(INI_SECTION_MAIN, "EnableGripButton", enableGripButtonToGrap);
ini.SetBoolValue(INI_SECTION_MAIN, "EnableGripButtonToLetGo", enableGripButtonToLetGo);
ini.SetBoolValue(INI_SECTION_MAIN, "EnableGripButtonOnePress", onePressGripButton);
}
/**
* Load hide meshes from config ini files. Creating if it doesn't exist on the disk.
*/
void Config::loadHideMeshes()
{
createFileFromResourceIfNotExists(MESH_HIDE_FACE_INI_PATH, _module, IDR_MESH_HIDE_FACE, true);
_faceGeometry = loadListFromFile(MESH_HIDE_FACE_INI_PATH);
createFileFromResourceIfNotExists(MESH_HIDE_SKINS_INI_PATH, _module, IDR_MESH_HIDE_SKINS, true);
_skinGeometry = loadListFromFile(MESH_HIDE_SKINS_INI_PATH);
createFileFromResourceIfNotExists(MESH_HIDE_SLOTS_INI_PATH, _module, IDR_MESH_HIDE_SLOTS, true);
loadHideEquipmentSlots();
}
/**
* Slot Ids base on this link: https://falloutck.uesp.net/wiki/Biped_Slots
*/
void Config::loadHideEquipmentSlots()
{
const auto slotsGeometry = loadListFromFile(MESH_HIDE_SLOTS_INI_PATH);
std::unordered_map<std::string, int> slotToIndexMap = { { "hairtop", 0 }, // i.e. helmet
{ "hairlong", 1 },
{ "head", 2 },
{ "headband", 16 },
{ "eyes", 17 }, // i.e. glasses
{ "beard", 18 },
{ "mouth", 19 },
{ "neck", 20 },
{ "scalp", 22 } };
_hideEquipSlotIndexes.clear();
for (auto& geometry : slotsGeometry) {
if (slotToIndexMap.contains(geometry)) {
_hideEquipSlotIndexes.push_back(slotToIndexMap[geometry]);
}
}
}
/**
* Load the pipboy screen and holo screen offsets from json files.
*/
void Config::loadPipboyOffsets()
{
createFileFromResourceIfNotExists(PIPBOY_HOLO_OFFSETS_PATH, _module, IDR_PIPBOY_HOLO_OFFSETS, false);
createFileFromResourceIfNotExists(PIPBOY_SCREEN_OFFSETS_PATH, _module, IDR_PIPBOY_SCREEN_OFFSETS, false);
createFileFromResourceIfNotExists(PIPBOY_ATTABOY_OFFSETS_PATH, _module, IDR_PIPBOY_ATTABOY_OFFSETS, false);
_pipboyOffsets.clear();
loadOffsetJsonFile(PIPBOY_HOLO_OFFSETS_PATH, _pipboyOffsets);
loadOffsetJsonFile(PIPBOY_SCREEN_OFFSETS_PATH, _pipboyOffsets);
loadOffsetJsonFile(PIPBOY_ATTABOY_OFFSETS_PATH, _pipboyOffsets);
}
/**
* Load all the weapons offsets embedded in resource and override custom from filesystem.
*/
void Config::loadWeaponsOffsets()
{
_weaponsOffsets.clear();
_weaponsEmbeddedOffsets = loadEmbeddedOffsets(200, 600);
_weaponsOffsets.insert(_weaponsEmbeddedOffsets.begin(), _weaponsEmbeddedOffsets.end());
const auto weaponCustomOffsets = loadOffsetsFromFilesystem(WEAPONS_OFFSETS_PATH);
for (auto& [key, value] : weaponCustomOffsets) {
_weaponsOffsets.insert_or_assign(key, value);
}
logger::info("Loaded weapon offsets ; Total:{}, Embedded:{}, Custom:{}", _weaponsOffsets.size(), _weaponsEmbeddedOffsets.size(), weaponCustomOffsets.size());
}
/**
* Create all the folders needed for config to not handle later creating folders that don't exist.
*/
void Config::setupFolders()
{
createDirDeep(FRIK_INI_PATH);
createDirDeep(MESH_HIDE_FACE_INI_PATH);
createDirDeep(PIPBOY_HOLO_OFFSETS_PATH);
createDirDeep(WEAPONS_OFFSETS_PATH);
}
/**
* One time migration of config files (ini,json) to common location to handle MO2 overwrite.
* See https://github.com/rollingrock/Fallout-4-VR-Body/wiki/Development#frik-config-folder
* and https://github.com/rollingrock/Fallout-4-VR-Body/pull/80
* Always migrate config to handle custom weapon offsets at mod-list installation time.
*/
void Config::migrateConfigFilesIfNeeded()
{
// migrate pre v72 and v72 config files to v73 location
logger::info("Migrate configs if exists in old locations...");
moveFileSafe(R"(.\Data\F4SE\plugins\FRIK.ini)", FRIK_INI_PATH);
moveFileSafe(R"(.\Data\F4SE\plugins\FRIK_FOLVR.ini)", FRIK_FOLVR_INI_PATH);
moveFileSafe(R"(.\Data\F4SE\plugins\FRIK_Mesh_Hide\face.ini)", MESH_HIDE_FACE_INI_PATH);
moveFileSafe(R"(.\Data\F4SE\plugins\FRIK_Mesh_Hide\skins.ini)", MESH_HIDE_SKINS_INI_PATH);
moveFileSafe(R"(.\Data\F4SE\plugins\FRIK_Mesh_Hide\slots.ini)", MESH_HIDE_SLOTS_INI_PATH);
moveAllFilesInFolderSafe(R"(.\Data\F4SE\plugins\FRIK_weapon_offsets)", WEAPONS_OFFSETS_PATH);
}
/**
* Get the name for the weapon offset to use depending on the mode.
* Basically a hack to store multiple modes of the same weapon by adding suffix to the name.
*/
std::string Config::getWeaponNameWithMode(const std::string& name, const WeaponOffsetsMode& mode, const bool inPA, const bool leftHanded)
{
static const std::string POWER_ARMOR_SUFFIX{ "-PowerArmor" };
static const std::string PRIM_HAND_SUFFIX{ "-primHand" };
static const std::string OFF_HAND_SUFFIX{ "-offHand" };
static const std::string THROWABLE_SUFFIX{ "-throwable" };
static const std::string BACK_OF_HAND_SUFFIX{ "-backOfHand" };
static const std::string LEFT_HANDED_SUFFIX{ "-leftHanded" };
switch (mode) {
case WeaponOffsetsMode::Weapon:
return name + (inPA ? POWER_ARMOR_SUFFIX : "") + (leftHanded ? LEFT_HANDED_SUFFIX : "");
case WeaponOffsetsMode::PrimaryHand:
return name + PRIM_HAND_SUFFIX + (inPA ? POWER_ARMOR_SUFFIX : "") + (leftHanded ? LEFT_HANDED_SUFFIX : "");
case WeaponOffsetsMode::OffHand:
return name + OFF_HAND_SUFFIX + (inPA ? POWER_ARMOR_SUFFIX : "") + (leftHanded ? LEFT_HANDED_SUFFIX : "");
case WeaponOffsetsMode::Throwable:
return name + THROWABLE_SUFFIX + (inPA ? POWER_ARMOR_SUFFIX : "") + (leftHanded ? LEFT_HANDED_SUFFIX : "");
case WeaponOffsetsMode::BackOfHandUI:
return name + BACK_OF_HAND_SUFFIX + (inPA ? POWER_ARMOR_SUFFIX : "") + (leftHanded ? LEFT_HANDED_SUFFIX : "");
default:
throw std::invalid_argument("Invalid weapon offset mode");
}
}
std::string Config::getPipboyOffsetKey() const
{
if (isFalloutLondonVR) {
return "AttaboyPosition";
}
return isHoloPipboy ? "HoloPipboyPosition" : "PipboyPosition";
}
std::string Config::getPipboyOffsetPath() const
{
if (isFalloutLondonVR) {
return PIPBOY_ATTABOY_OFFSETS_PATH;
}
return isHoloPipboy ? PIPBOY_HOLO_OFFSETS_PATH : PIPBOY_SCREEN_OFFSETS_PATH;
}
}