mirror of https://github.com/AxioDL/metaforce.git
Wire up the rest of CTweakGame to CVars
This commit is contained in:
parent
424ad7a103
commit
9a0d51ad05
|
@ -4,56 +4,96 @@
|
|||
#include <hecl/CVar.hpp>
|
||||
#include <hecl/CVarManager.hpp>
|
||||
|
||||
#define DEFINE_CVAR_GLOBAL(name) \
|
||||
constexpr std::string_view sk##name = std::string_view("tweak.game." #name); \
|
||||
hecl::CVar* tw_##name = nullptr;
|
||||
|
||||
#define CREATE_CVAR(name, help, value, flags) \
|
||||
tw_##name = mgr->findOrMakeCVar(sk##name, help, value, flags); \
|
||||
if (tw_##name->wasDeserialized()) { \
|
||||
tw_##name->toValue(value); \
|
||||
} \
|
||||
tw_##name->addListener([this](hecl::CVar* cv) { _tweakListener(cv); });
|
||||
|
||||
#define CREATE_CVAR_BITFIELD(name, help, value, flags) \
|
||||
{ \
|
||||
bool tmp = value; \
|
||||
CREATE_CVAR(name, help, tmp, flags) \
|
||||
}
|
||||
|
||||
#define UPDATE_CVAR(name, cv, value) \
|
||||
if ((cv) == tw_##name) { \
|
||||
(cv)->toValue(value); \
|
||||
return; \
|
||||
}
|
||||
|
||||
#define UPDATE_CVAR_BITFIELD(name, cv, value) \
|
||||
{ \
|
||||
bool tmp = value; \
|
||||
UPDATE_CVAR(name, cv, tmp) \
|
||||
(value) = tmp; \
|
||||
}
|
||||
|
||||
namespace DataSpec::DNAMP1 {
|
||||
hecl::CVar* tw_fov = nullptr;
|
||||
hecl::CVar* tw_hardmodeDMult = nullptr;
|
||||
hecl::CVar* tw_hardmodeWMult = nullptr;
|
||||
hecl::CVar* tw_splashScreensDisabled = nullptr;
|
||||
namespace {
|
||||
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;
|
||||
constexpr std::string_view skSplashScreensDisabled = "tweak.game.SplashScreensDisabled"sv;
|
||||
constexpr hecl::CVar::EFlags skDefaultFlags = hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Archive;
|
||||
DEFINE_CVAR_GLOBAL(WorldPrefix);
|
||||
DEFINE_CVAR_GLOBAL(FieldOfView);
|
||||
DEFINE_CVAR_GLOBAL(SplashScreensDisabled);
|
||||
DEFINE_CVAR_GLOBAL(PressStartDelay);
|
||||
DEFINE_CVAR_GLOBAL(WavecapIntensityNormal);
|
||||
DEFINE_CVAR_GLOBAL(WavecapIntensityPoison);
|
||||
DEFINE_CVAR_GLOBAL(WavecapIntensityLava);
|
||||
DEFINE_CVAR_GLOBAL(RippleIntensityNormal);
|
||||
DEFINE_CVAR_GLOBAL(RippleIntensityPoison);
|
||||
DEFINE_CVAR_GLOBAL(RippleIntensityLava);
|
||||
DEFINE_CVAR_GLOBAL(FluidEnvBumpScale);
|
||||
DEFINE_CVAR_GLOBAL(WaterFogDistanceBase);
|
||||
DEFINE_CVAR_GLOBAL(WaterFogDistanceRange);
|
||||
DEFINE_CVAR_GLOBAL(GravityWaterFogDistanceBase);
|
||||
DEFINE_CVAR_GLOBAL(GravityWaterFogDistanceRange);
|
||||
DEFINE_CVAR_GLOBAL(HardModeDamageMult);
|
||||
DEFINE_CVAR_GLOBAL(HardModeWeaponMult);
|
||||
} // anonymous namespace
|
||||
|
||||
void CTweakGame::_tweakGameListener(hecl::CVar* cv) {
|
||||
if (cv == tw_fov) {
|
||||
x24_fov = cv->toReal();
|
||||
} else if (cv == tw_hardmodeDMult) {
|
||||
x60_hardmodeDamageMult = cv->toReal();
|
||||
} else if (cv == tw_hardmodeWMult) {
|
||||
x64_hardmodeWeaponMult = cv->toReal();
|
||||
} else if (cv == tw_splashScreensDisabled) {
|
||||
x2b_splashScreensDisabled = cv->toBoolean();
|
||||
}
|
||||
void CTweakGame::_tweakListener(hecl::CVar* cv) {
|
||||
UPDATE_CVAR(WorldPrefix, cv, x4_worldPrefix);
|
||||
UPDATE_CVAR(FieldOfView, cv, x24_fov);
|
||||
UPDATE_CVAR(SplashScreensDisabled, cv, x2b_splashScreensDisabled);
|
||||
UPDATE_CVAR(PressStartDelay, cv, x30_pressStartDelay);
|
||||
UPDATE_CVAR(WavecapIntensityNormal, cv, x34_wavecapIntensityNormal);
|
||||
UPDATE_CVAR(WavecapIntensityPoison, cv, x38_wavecapIntensityPoison);
|
||||
UPDATE_CVAR(WavecapIntensityLava, cv, x3c_wavecapIntensityLava);
|
||||
UPDATE_CVAR(RippleIntensityNormal, cv, x40_rippleIntensityNormal);
|
||||
UPDATE_CVAR(RippleIntensityPoison, cv, x44_rippleIntensityPoison);
|
||||
UPDATE_CVAR(RippleIntensityLava, cv, x48_rippleIntensityLava);
|
||||
UPDATE_CVAR(FluidEnvBumpScale, cv, x4c_fluidEnvBumpScale);
|
||||
UPDATE_CVAR(WaterFogDistanceBase, cv, x50_waterFogDistanceBase);
|
||||
UPDATE_CVAR(WaterFogDistanceRange, cv, x54_waterFogDistanceRange);
|
||||
UPDATE_CVAR(GravityWaterFogDistanceBase, cv, x58_gravityWaterFogDistanceBase);
|
||||
UPDATE_CVAR(GravityWaterFogDistanceRange, cv, x5c_gravityWaterFogDistanceRange);
|
||||
UPDATE_CVAR(HardModeDamageMult, cv, x60_hardmodeDamageMult);
|
||||
UPDATE_CVAR(HardModeWeaponMult, cv, x64_hardmodeWeaponMult);
|
||||
}
|
||||
|
||||
void CTweakGame::initCVars(hecl::CVarManager* mgr) {
|
||||
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())
|
||||
v = static_cast<float>(cv->toReal());
|
||||
cv->addListener([this](hecl::CVar* cv) { _tweakGameListener(cv); });
|
||||
return cv;
|
||||
};
|
||||
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;
|
||||
};
|
||||
|
||||
tw_fov = assignRealValue(skFov, "", x24_fov, hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Archive);
|
||||
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);
|
||||
tw_splashScreensDisabled = assignBoolValue(skSplashScreensDisabled, "", x2b_splashScreensDisabled,
|
||||
CREATE_CVAR(WorldPrefix, "", x4_worldPrefix, skDefaultFlags);
|
||||
CREATE_CVAR(FieldOfView, "", x24_fov, skDefaultFlags);
|
||||
CREATE_CVAR(SplashScreensDisabled, "", x2b_splashScreensDisabled,
|
||||
hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Archive);
|
||||
CREATE_CVAR(PressStartDelay, "", x30_pressStartDelay, , skDefaultFlags);
|
||||
CREATE_CVAR(WavecapIntensityNormal, "", x34_wavecapIntensityNormal, skDefaultFlags);
|
||||
CREATE_CVAR(WavecapIntensityPoison, "", x38_wavecapIntensityPoison, skDefaultFlags);
|
||||
CREATE_CVAR(WavecapIntensityLava, "", x3c_wavecapIntensityLava, skDefaultFlags);
|
||||
CREATE_CVAR(RippleIntensityNormal, "", x40_rippleIntensityNormal, skDefaultFlags);
|
||||
CREATE_CVAR(RippleIntensityPoison, "", x44_rippleIntensityPoison, skDefaultFlags);
|
||||
CREATE_CVAR(RippleIntensityLava, "", x48_rippleIntensityLava, skDefaultFlags);
|
||||
CREATE_CVAR(FluidEnvBumpScale, "", x4c_fluidEnvBumpScale, skDefaultFlags);
|
||||
CREATE_CVAR(WaterFogDistanceBase, "", x50_waterFogDistanceBase, skDefaultFlags);
|
||||
CREATE_CVAR(WaterFogDistanceRange, "", x54_waterFogDistanceRange, skDefaultFlags);
|
||||
CREATE_CVAR(GravityWaterFogDistanceBase, "", x58_gravityWaterFogDistanceBase, skDefaultFlags);
|
||||
CREATE_CVAR(GravityWaterFogDistanceRange, "", x5c_gravityWaterFogDistanceRange, skDefaultFlags);
|
||||
CREATE_CVAR(HardModeDamageMult, "", x60_hardmodeDamageMult, skDefaultFlags);
|
||||
CREATE_CVAR(HardModeWeaponMult, "", x64_hardmodeWeaponMult, skDefaultFlags);
|
||||
}
|
||||
} // namespace DataSpec::DNAMP1
|
||||
|
|
|
@ -23,7 +23,7 @@ struct CTweakGame final : ITweakGame {
|
|||
Value<float> x38_wavecapIntensityPoison;
|
||||
Value<float> x3c_wavecapIntensityLava;
|
||||
Value<float> x40_rippleIntensityNormal;
|
||||
Value<float> x44_rippleIntentityPoison;
|
||||
Value<float> x44_rippleIntensityPoison;
|
||||
Value<float> x48_rippleIntensityLava;
|
||||
Value<float> x4c_fluidEnvBumpScale;
|
||||
Value<float> x50_waterFogDistanceBase;
|
||||
|
@ -42,7 +42,7 @@ struct CTweakGame final : ITweakGame {
|
|||
float GetWavecapIntensityPoison() const override { return x38_wavecapIntensityPoison; }
|
||||
float GetWavecapIntensityLava() const override { return x3c_wavecapIntensityLava; }
|
||||
float GetRippleIntensityNormal() const override { return x40_rippleIntensityNormal; }
|
||||
float GetRippleIntensityPoison() const override { return x44_rippleIntentityPoison; }
|
||||
float GetRippleIntensityPoison() const override { return x44_rippleIntensityPoison; }
|
||||
float GetRippleIntensityLava() const override { return x48_rippleIntensityLava; }
|
||||
float GetFluidEnvBumpScale() const override { return x4c_fluidEnvBumpScale; }
|
||||
float GetWaterFogDistanceBase() const override { return x50_waterFogDistanceBase; }
|
||||
|
@ -61,6 +61,6 @@ struct CTweakGame final : ITweakGame {
|
|||
|
||||
void initCVars(hecl::CVarManager* mgr) override;
|
||||
private:
|
||||
void _tweakGameListener(hecl::CVar* cv);
|
||||
void _tweakListener(hecl::CVar* cv);
|
||||
};
|
||||
} // namespace DataSpec::DNAMP1
|
||||
|
|
|
@ -76,52 +76,38 @@ bool CCharAnimTime::operator>(const CCharAnimTime& other) const { return (!(*thi
|
|||
|
||||
bool CCharAnimTime::operator<(const CCharAnimTime& other) const {
|
||||
if (x4_type == EType::NonZero) {
|
||||
if (other.x4_type == EType::NonZero)
|
||||
if (other.x4_type == EType::NonZero) {
|
||||
return x0_time < other.x0_time;
|
||||
if (other.EqualsZero())
|
||||
}
|
||||
|
||||
return other.EqualsZero() ? x0_time < 0.f : other.x0_time > 0;
|
||||
}
|
||||
|
||||
if (!EqualsZero()) {
|
||||
if (other.x4_type == EType::Infinity) {
|
||||
return x0_time >= 0 || other.x0_time <= 0.f;
|
||||
}
|
||||
|
||||
return x0_time < 0.f;
|
||||
else
|
||||
}
|
||||
|
||||
if (!other.EqualsZero()) {
|
||||
if (other.x4_type == EType::NonZero) {
|
||||
return other.x0_time > 0.f;
|
||||
}
|
||||
|
||||
if (EqualsZero()) {
|
||||
if (other.EqualsZero()) {
|
||||
int type = -1;
|
||||
if (x4_type != EType::ZeroDecreasing) {
|
||||
if (x4_type != EType::ZeroSteady)
|
||||
type = 1;
|
||||
else
|
||||
type = 0;
|
||||
return other.x0_time > 0.f;
|
||||
}
|
||||
|
||||
int otherType = -1;
|
||||
if (other.x4_type != EType::ZeroDecreasing) {
|
||||
if (other.x4_type != EType::ZeroSteady)
|
||||
otherType = 1;
|
||||
else
|
||||
otherType = 0;
|
||||
}
|
||||
int type = x4_type == EType::ZeroDecreasing ? -1 : x4_type == EType::ZeroSteady ? 0 : 1;
|
||||
int otherType = other.x4_type == EType::ZeroDecreasing ? -1 : other.x4_type == EType::ZeroSteady ? 0 : 1;
|
||||
|
||||
return type < otherType;
|
||||
}
|
||||
|
||||
if (other.x4_type == EType::NonZero)
|
||||
return other.x0_time > 0.f;
|
||||
return other.x0_time > 0.f; // ?
|
||||
}
|
||||
CCharAnimTime& CCharAnimTime::operator*=(const CCharAnimTime& other) { return *this = *this * other; }
|
||||
|
||||
if (other.x4_type == EType::Infinity)
|
||||
return x0_time < 0.f && other.x0_time > 0.f;
|
||||
return x0_time < 0.f;
|
||||
}
|
||||
|
||||
CCharAnimTime& CCharAnimTime::operator*=(const CCharAnimTime& other) {
|
||||
return *this = *this * other;
|
||||
}
|
||||
|
||||
CCharAnimTime& CCharAnimTime::operator+=(const CCharAnimTime& other) {
|
||||
return *this = *this + other;
|
||||
}
|
||||
CCharAnimTime& CCharAnimTime::operator+=(const CCharAnimTime& other) { return *this = *this + other; }
|
||||
|
||||
CCharAnimTime CCharAnimTime::operator+(const CCharAnimTime& other) const {
|
||||
if (x4_type == EType::Infinity && other.x4_type == EType::Infinity) {
|
||||
|
@ -157,9 +143,7 @@ CCharAnimTime CCharAnimTime::operator+(const CCharAnimTime& other) const {
|
|||
return {EType::ZeroIncreasing, 0.f};
|
||||
}
|
||||
|
||||
CCharAnimTime& CCharAnimTime::operator-=(const CCharAnimTime& other) {
|
||||
return *this = *this - other;
|
||||
}
|
||||
CCharAnimTime& CCharAnimTime::operator-=(const CCharAnimTime& other) { return *this = *this - other; }
|
||||
|
||||
CCharAnimTime CCharAnimTime::operator-(const CCharAnimTime& other) const {
|
||||
if (x4_type == EType::Infinity && other.x4_type == EType::Infinity) {
|
||||
|
|
Loading…
Reference in New Issue