2019-09-29 12:44:37 +00:00
|
|
|
#include "DataSpec/DNAMP1/Tweaks/CTweakGame.hpp"
|
2019-09-29 15:17:47 +00:00
|
|
|
#include "Runtime/Camera/CCameraManager.hpp"
|
2019-09-29 12:44:37 +00:00
|
|
|
|
|
|
|
#include <hecl/CVar.hpp>
|
|
|
|
#include <hecl/CVarManager.hpp>
|
2018-01-15 16:00:20 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
namespace DataSpec::DNAMP1 {
|
2019-09-29 15:17:47 +00:00
|
|
|
hecl::CVar* tw_fov = nullptr;
|
|
|
|
hecl::CVar* tw_hardmodeDMult = nullptr;
|
|
|
|
hecl::CVar* tw_hardmodeWMult = nullptr;
|
2020-04-18 21:37:02 +00:00
|
|
|
hecl::CVar* tw_splashScreensDisabled = nullptr;
|
2019-09-29 12:44:37 +00:00
|
|
|
namespace {
|
2019-10-05 14:07:13 +00:00
|
|
|
constexpr std::string_view skFov = "tweak.game.FieldOfView"sv;
|
|
|
|
constexpr std::string_view skHardModeDamageMultName = "tweak.game.HardModeDamageMult"sv;
|
|
|
|
constexpr std::string_view skHardModeWeaponMultName = "tweak.game.HardModeWeaponMult"sv;
|
2020-04-18 21:37:02 +00:00
|
|
|
constexpr std::string_view skSplashScreensDisabled = "tweak.game.SplashScreensDisabled"sv;
|
2019-09-29 15:17:47 +00:00
|
|
|
} // anonymous namespace
|
|
|
|
|
2019-09-29 12:44:37 +00:00
|
|
|
void CTweakGame::_tweakGameListener(hecl::CVar* cv) {
|
2019-09-29 15:17:47 +00:00
|
|
|
if (cv == tw_fov) {
|
2019-09-29 12:44:37 +00:00
|
|
|
x24_fov = cv->toReal();
|
2019-09-29 15:17:47 +00:00
|
|
|
} else if (cv == tw_hardmodeDMult) {
|
2019-09-29 12:44:37 +00:00
|
|
|
x60_hardmodeDamageMult = cv->toReal();
|
2019-09-29 15:17:47 +00:00
|
|
|
} else if (cv == tw_hardmodeWMult) {
|
2019-09-29 12:44:37 +00:00
|
|
|
x64_hardmodeWeaponMult = cv->toReal();
|
2020-04-18 21:37:02 +00:00
|
|
|
} else if (cv == tw_splashScreensDisabled) {
|
|
|
|
x2b_splashScreensDisabled = cv->toBoolean();
|
2019-09-29 12:44:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CTweakGame::initCVars(hecl::CVarManager* mgr) {
|
2019-09-29 12:44:37 +00:00
|
|
|
auto assignRealValue = [this, mgr](std::string_view name, std::string_view desc, float& v, hecl::CVar::EFlags flags) {
|
|
|
|
hecl::CVar* cv = mgr->findOrMakeCVar(name, desc, v, flags);
|
|
|
|
// Check if the CVar was deserialized, this avoid an unnecessary conversion
|
|
|
|
if (cv->wasDeserialized())
|
2019-10-05 14:07:13 +00:00
|
|
|
v = static_cast<float>(cv->toReal());
|
2019-09-29 12:44:37 +00:00
|
|
|
cv->addListener([this](hecl::CVar* cv) { _tweakGameListener(cv); });
|
2019-09-29 15:17:47 +00:00
|
|
|
return cv;
|
2019-09-29 12:44:37 +00:00
|
|
|
};
|
2020-04-18 21:37:02 +00:00
|
|
|
auto assignBoolValue = [this, mgr](std::string_view name, std::string_view desc, bool& v, hecl::CVar::EFlags flags) {
|
|
|
|
hecl::CVar* cv = mgr->findOrMakeCVar(name, desc, v, flags);
|
|
|
|
// Check if the CVar was deserialized, this avoid an unnecessary conversion
|
|
|
|
if (cv->wasDeserialized())
|
|
|
|
v = cv->toBoolean();
|
|
|
|
cv->addListener([this](hecl::CVar* cv) { _tweakGameListener(cv); });
|
|
|
|
return cv;
|
|
|
|
};
|
2019-09-29 12:44:37 +00:00
|
|
|
|
2020-04-18 21:37:02 +00:00
|
|
|
tw_fov = assignRealValue(skFov, "", x24_fov, hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Archive);
|
2019-09-29 15:17:47 +00:00
|
|
|
tw_hardmodeDMult =
|
|
|
|
assignRealValue(skHardModeDamageMultName, "", x60_hardmodeDamageMult,
|
|
|
|
hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Archive | hecl::CVar::EFlags::Cheat);
|
|
|
|
tw_hardmodeWMult =
|
|
|
|
assignRealValue(skHardModeWeaponMultName, "", x64_hardmodeWeaponMult,
|
|
|
|
hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Archive | hecl::CVar::EFlags::Cheat);
|
2020-04-18 21:37:02 +00:00
|
|
|
tw_splashScreensDisabled = assignBoolValue(skSplashScreensDisabled, "", x2b_splashScreensDisabled,
|
|
|
|
hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Archive);
|
2018-01-15 16:00:20 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
} // namespace DataSpec::DNAMP1
|