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/CVar.hpp>
|
||||||
#include <hecl/CVarManager.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 {
|
namespace DataSpec::DNAMP1 {
|
||||||
hecl::CVar* tw_fov = nullptr;
|
|
||||||
hecl::CVar* tw_hardmodeDMult = nullptr;
|
|
||||||
hecl::CVar* tw_hardmodeWMult = nullptr;
|
|
||||||
hecl::CVar* tw_splashScreensDisabled = nullptr;
|
|
||||||
namespace {
|
namespace {
|
||||||
constexpr std::string_view skFov = "tweak.game.FieldOfView"sv;
|
constexpr hecl::CVar::EFlags skDefaultFlags = hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Archive;
|
||||||
constexpr std::string_view skHardModeDamageMultName = "tweak.game.HardModeDamageMult"sv;
|
DEFINE_CVAR_GLOBAL(WorldPrefix);
|
||||||
constexpr std::string_view skHardModeWeaponMultName = "tweak.game.HardModeWeaponMult"sv;
|
DEFINE_CVAR_GLOBAL(FieldOfView);
|
||||||
constexpr std::string_view skSplashScreensDisabled = "tweak.game.SplashScreensDisabled"sv;
|
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
|
} // anonymous namespace
|
||||||
|
|
||||||
void CTweakGame::_tweakGameListener(hecl::CVar* cv) {
|
void CTweakGame::_tweakListener(hecl::CVar* cv) {
|
||||||
if (cv == tw_fov) {
|
UPDATE_CVAR(WorldPrefix, cv, x4_worldPrefix);
|
||||||
x24_fov = cv->toReal();
|
UPDATE_CVAR(FieldOfView, cv, x24_fov);
|
||||||
} else if (cv == tw_hardmodeDMult) {
|
UPDATE_CVAR(SplashScreensDisabled, cv, x2b_splashScreensDisabled);
|
||||||
x60_hardmodeDamageMult = cv->toReal();
|
UPDATE_CVAR(PressStartDelay, cv, x30_pressStartDelay);
|
||||||
} else if (cv == tw_hardmodeWMult) {
|
UPDATE_CVAR(WavecapIntensityNormal, cv, x34_wavecapIntensityNormal);
|
||||||
x64_hardmodeWeaponMult = cv->toReal();
|
UPDATE_CVAR(WavecapIntensityPoison, cv, x38_wavecapIntensityPoison);
|
||||||
} else if (cv == tw_splashScreensDisabled) {
|
UPDATE_CVAR(WavecapIntensityLava, cv, x3c_wavecapIntensityLava);
|
||||||
x2b_splashScreensDisabled = cv->toBoolean();
|
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) {
|
void CTweakGame::initCVars(hecl::CVarManager* mgr) {
|
||||||
auto assignRealValue = [this, mgr](std::string_view name, std::string_view desc, float& v, hecl::CVar::EFlags flags) {
|
CREATE_CVAR(WorldPrefix, "", x4_worldPrefix, skDefaultFlags);
|
||||||
hecl::CVar* cv = mgr->findOrMakeCVar(name, desc, v, flags);
|
CREATE_CVAR(FieldOfView, "", x24_fov, skDefaultFlags);
|
||||||
// Check if the CVar was deserialized, this avoid an unnecessary conversion
|
CREATE_CVAR(SplashScreensDisabled, "", x2b_splashScreensDisabled,
|
||||||
if (cv->wasDeserialized())
|
hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Archive);
|
||||||
v = static_cast<float>(cv->toReal());
|
CREATE_CVAR(PressStartDelay, "", x30_pressStartDelay, , skDefaultFlags);
|
||||||
cv->addListener([this](hecl::CVar* cv) { _tweakGameListener(cv); });
|
CREATE_CVAR(WavecapIntensityNormal, "", x34_wavecapIntensityNormal, skDefaultFlags);
|
||||||
return cv;
|
CREATE_CVAR(WavecapIntensityPoison, "", x38_wavecapIntensityPoison, skDefaultFlags);
|
||||||
};
|
CREATE_CVAR(WavecapIntensityLava, "", x3c_wavecapIntensityLava, skDefaultFlags);
|
||||||
auto assignBoolValue = [this, mgr](std::string_view name, std::string_view desc, bool& v, hecl::CVar::EFlags flags) {
|
CREATE_CVAR(RippleIntensityNormal, "", x40_rippleIntensityNormal, skDefaultFlags);
|
||||||
hecl::CVar* cv = mgr->findOrMakeCVar(name, desc, v, flags);
|
CREATE_CVAR(RippleIntensityPoison, "", x44_rippleIntensityPoison, skDefaultFlags);
|
||||||
// Check if the CVar was deserialized, this avoid an unnecessary conversion
|
CREATE_CVAR(RippleIntensityLava, "", x48_rippleIntensityLava, skDefaultFlags);
|
||||||
if (cv->wasDeserialized())
|
CREATE_CVAR(FluidEnvBumpScale, "", x4c_fluidEnvBumpScale, skDefaultFlags);
|
||||||
v = cv->toBoolean();
|
CREATE_CVAR(WaterFogDistanceBase, "", x50_waterFogDistanceBase, skDefaultFlags);
|
||||||
cv->addListener([this](hecl::CVar* cv) { _tweakGameListener(cv); });
|
CREATE_CVAR(WaterFogDistanceRange, "", x54_waterFogDistanceRange, skDefaultFlags);
|
||||||
return cv;
|
CREATE_CVAR(GravityWaterFogDistanceBase, "", x58_gravityWaterFogDistanceBase, skDefaultFlags);
|
||||||
};
|
CREATE_CVAR(GravityWaterFogDistanceRange, "", x5c_gravityWaterFogDistanceRange, skDefaultFlags);
|
||||||
|
CREATE_CVAR(HardModeDamageMult, "", x60_hardmodeDamageMult, skDefaultFlags);
|
||||||
tw_fov = assignRealValue(skFov, "", x24_fov, hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Archive);
|
CREATE_CVAR(HardModeWeaponMult, "", x64_hardmodeWeaponMult, skDefaultFlags);
|
||||||
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,
|
|
||||||
hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Archive);
|
|
||||||
}
|
}
|
||||||
} // namespace DataSpec::DNAMP1
|
} // namespace DataSpec::DNAMP1
|
||||||
|
|
|
@ -23,7 +23,7 @@ struct CTweakGame final : ITweakGame {
|
||||||
Value<float> x38_wavecapIntensityPoison;
|
Value<float> x38_wavecapIntensityPoison;
|
||||||
Value<float> x3c_wavecapIntensityLava;
|
Value<float> x3c_wavecapIntensityLava;
|
||||||
Value<float> x40_rippleIntensityNormal;
|
Value<float> x40_rippleIntensityNormal;
|
||||||
Value<float> x44_rippleIntentityPoison;
|
Value<float> x44_rippleIntensityPoison;
|
||||||
Value<float> x48_rippleIntensityLava;
|
Value<float> x48_rippleIntensityLava;
|
||||||
Value<float> x4c_fluidEnvBumpScale;
|
Value<float> x4c_fluidEnvBumpScale;
|
||||||
Value<float> x50_waterFogDistanceBase;
|
Value<float> x50_waterFogDistanceBase;
|
||||||
|
@ -42,7 +42,7 @@ struct CTweakGame final : ITweakGame {
|
||||||
float GetWavecapIntensityPoison() const override { return x38_wavecapIntensityPoison; }
|
float GetWavecapIntensityPoison() const override { return x38_wavecapIntensityPoison; }
|
||||||
float GetWavecapIntensityLava() const override { return x3c_wavecapIntensityLava; }
|
float GetWavecapIntensityLava() const override { return x3c_wavecapIntensityLava; }
|
||||||
float GetRippleIntensityNormal() const override { return x40_rippleIntensityNormal; }
|
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 GetRippleIntensityLava() const override { return x48_rippleIntensityLava; }
|
||||||
float GetFluidEnvBumpScale() const override { return x4c_fluidEnvBumpScale; }
|
float GetFluidEnvBumpScale() const override { return x4c_fluidEnvBumpScale; }
|
||||||
float GetWaterFogDistanceBase() const override { return x50_waterFogDistanceBase; }
|
float GetWaterFogDistanceBase() const override { return x50_waterFogDistanceBase; }
|
||||||
|
@ -61,6 +61,6 @@ struct CTweakGame final : ITweakGame {
|
||||||
|
|
||||||
void initCVars(hecl::CVarManager* mgr) override;
|
void initCVars(hecl::CVarManager* mgr) override;
|
||||||
private:
|
private:
|
||||||
void _tweakGameListener(hecl::CVar* cv);
|
void _tweakListener(hecl::CVar* cv);
|
||||||
};
|
};
|
||||||
} // namespace DataSpec::DNAMP1
|
} // namespace DataSpec::DNAMP1
|
||||||
|
|
|
@ -76,52 +76,38 @@ bool CCharAnimTime::operator>(const CCharAnimTime& other) const { return (!(*thi
|
||||||
|
|
||||||
bool CCharAnimTime::operator<(const CCharAnimTime& other) const {
|
bool CCharAnimTime::operator<(const CCharAnimTime& other) const {
|
||||||
if (x4_type == EType::NonZero) {
|
if (x4_type == EType::NonZero) {
|
||||||
if (other.x4_type == EType::NonZero)
|
if (other.x4_type == EType::NonZero) {
|
||||||
return x0_time < other.x0_time;
|
return x0_time < other.x0_time;
|
||||||
if (other.EqualsZero())
|
|
||||||
return x0_time < 0.f;
|
|
||||||
else
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
int otherType = -1;
|
|
||||||
if (other.x4_type != EType::ZeroDecreasing) {
|
|
||||||
if (other.x4_type != EType::ZeroSteady)
|
|
||||||
otherType = 1;
|
|
||||||
else
|
|
||||||
otherType = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return type < otherType;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (other.x4_type == EType::NonZero)
|
return other.EqualsZero() ? x0_time < 0.f : other.x0_time > 0;
|
||||||
return other.x0_time > 0.f;
|
|
||||||
return other.x0_time > 0.f; // ?
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (other.x4_type == EType::Infinity)
|
if (!EqualsZero()) {
|
||||||
return x0_time < 0.f && other.x0_time > 0.f;
|
if (other.x4_type == EType::Infinity) {
|
||||||
return x0_time < 0.f;
|
return x0_time >= 0 || other.x0_time <= 0.f;
|
||||||
|
}
|
||||||
|
|
||||||
|
return x0_time < 0.f;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!other.EqualsZero()) {
|
||||||
|
if (other.x4_type == EType::NonZero) {
|
||||||
|
return other.x0_time > 0.f;
|
||||||
|
}
|
||||||
|
|
||||||
|
return other.x0_time > 0.f;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
CCharAnimTime& CCharAnimTime::operator*=(const CCharAnimTime& other) {
|
CCharAnimTime& CCharAnimTime::operator*=(const CCharAnimTime& other) { return *this = *this * other; }
|
||||||
return *this = *this * other;
|
|
||||||
}
|
|
||||||
|
|
||||||
CCharAnimTime& CCharAnimTime::operator+=(const CCharAnimTime& other) {
|
CCharAnimTime& CCharAnimTime::operator+=(const CCharAnimTime& other) { return *this = *this + other; }
|
||||||
return *this = *this + other;
|
|
||||||
}
|
|
||||||
|
|
||||||
CCharAnimTime CCharAnimTime::operator+(const CCharAnimTime& other) const {
|
CCharAnimTime CCharAnimTime::operator+(const CCharAnimTime& other) const {
|
||||||
if (x4_type == EType::Infinity && other.x4_type == EType::Infinity) {
|
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};
|
return {EType::ZeroIncreasing, 0.f};
|
||||||
}
|
}
|
||||||
|
|
||||||
CCharAnimTime& CCharAnimTime::operator-=(const CCharAnimTime& other) {
|
CCharAnimTime& CCharAnimTime::operator-=(const CCharAnimTime& other) { return *this = *this - other; }
|
||||||
return *this = *this - other;
|
|
||||||
}
|
|
||||||
|
|
||||||
CCharAnimTime CCharAnimTime::operator-(const CCharAnimTime& other) const {
|
CCharAnimTime CCharAnimTime::operator-(const CCharAnimTime& other) const {
|
||||||
if (x4_type == EType::Infinity && other.x4_type == EType::Infinity) {
|
if (x4_type == EType::Infinity && other.x4_type == EType::Infinity) {
|
||||||
|
|
Loading…
Reference in New Issue