More tweak CVars

This commit is contained in:
Phillip Stephens 2019-10-05 07:07:13 -07:00
parent b68acb06e1
commit 5f0f3ea45c
Signed by: Antidote
GPG Key ID: F8BEE4C83DACA60D
5 changed files with 185 additions and 17 deletions

View File

@ -3,16 +3,175 @@
#include <hecl/CVar.hpp>
#include <hecl/CVarManager.hpp>
#define PREFIX(v) std::string_view("tweak.automap." #v)
namespace DataSpec::DNAMP1 {
namespace {
}
namespace {
constexpr std::string_view skShowOneMiniMapArea = PREFIX(ShowOneMiniMapArea);
constexpr std::string_view skScaleMoveSpeedWithCamDist = PREFIX(ScaleMoveSpeedWithCamDist);
constexpr std::string_view skCamDist = PREFIX(CamDist);
constexpr std::string_view skMinCameraDist = PREFIX(MinCamDist);
constexpr std::string_view skMaxCamDist = PREFIX(MaxCamDist);
constexpr std::string_view skMinCamRotX = PREFIX(MinCamRotX);
constexpr std::string_view skMaxCamRotX = PREFIX(MaxCamRotX);
constexpr std::string_view skCamAngle = PREFIX(CamAngle);
constexpr std::string_view skWidgetColor = PREFIX(WidgetColor);
constexpr std::string_view skMiniCamDist = PREFIX(MiniCamDist);
constexpr std::string_view skMiniCamXAngle = PREFIX(MiniCamXAngle);
constexpr std::string_view skMiniCamAngle = PREFIX(MiniCamAngle);
constexpr std::string_view skVisitedSurfaceColor = PREFIX(VisitedSurfaceColor);
constexpr std::string_view skVisitedOutlineColor = PREFIX(VisitedOutlineColor);
constexpr std::string_view skUnvisitedSurfaceColor = PREFIX(UnvisitedSurfaceColor);
constexpr std::string_view skUnvisitedOutlineColor = PREFIX(UnvisitedOutlineColor);
constexpr std::string_view skSelectedVisitedSurfaceColor = PREFIX(SelectedVisitedSurfaceColor);
constexpr std::string_view skSelectedVisitedOutlineColor = PREFIX(SelectedVisitedOutlineColor);
constexpr std::string_view skMapSurfaceNormalColorLinear = PREFIX(MapSurfaceNormalColorLinear);
constexpr std::string_view skMapSurfaceNormalColorConstant = PREFIX(MapSurfaceNormalColorConstant);
hecl::CVar* tw_showOneMiniMapArea = nullptr;
hecl::CVar* tw_scaleMoveSpeedWithCamDist = nullptr;
hecl::CVar* tw_camDist = nullptr;
hecl::CVar* tw_minCamDist = nullptr;
hecl::CVar* tw_maxCamDist = nullptr;
hecl::CVar* tw_minCamRotX = nullptr;
hecl::CVar* tw_maxCamRotX = nullptr;
hecl::CVar* tw_camAngle = nullptr;
hecl::CVar* tw_widgetColor = nullptr;
hecl::CVar* tw_miniCamDist = nullptr;
hecl::CVar* tw_miniCamXAngle = nullptr;
hecl::CVar* tw_miniCamAngle = nullptr;
hecl::CVar* tw_visitedsurfaceColor = nullptr;
hecl::CVar* tw_visitedOutlineColor = nullptr;
hecl::CVar* tw_unvisitedSurfaceColor = nullptr;
hecl::CVar* tw_unvisitedOutlineColor = nullptr;
hecl::CVar* tw_selectedVisitedSurfaceColor = nullptr;
hecl::CVar* tw_selectedVisitedOutlineColor = nullptr;
hecl::CVar* tw_mapSurfaceNormColorLinear = nullptr;
hecl::CVar* tw_mapSurfaceNormColorConstant = nullptr;
} // namespace
void CTweakAutoMapper::_tweakListener(hecl::CVar* cv) {
if (cv == tw_showOneMiniMapArea) {
x4_24_showOneMiniMapArea = cv->toBoolean();
} else if (cv == tw_scaleMoveSpeedWithCamDist) {
x4_26_scaleMoveSpeedWithCamDist = cv->toBoolean();
} else if (cv == tw_camDist) {
x8_camDist = cv->toReal();
} else if (cv == tw_minCamDist) {
xc_minCamDist = cv->toReal();
} else if (cv == tw_maxCamDist) {
x10_maxCamDist = cv->toReal();
} else if (cv == tw_minCamRotX) {
x14_minCamRotateX = cv->toReal();
} else if (cv == tw_maxCamRotX) {
x18_maxCamRotateX = cv->toReal();
} else if (cv == tw_camAngle) {
x1c_camAngle = cv->toReal();
} else if (cv == tw_widgetColor) {
x24_automapperWidgetColor = zeus::CColor(cv->toVec4f());
} else if (cv == tw_miniCamDist) {
x28_miniCamDist = cv->toReal();
} else if (cv == tw_miniCamXAngle) {
x2c_miniCamXAngle = tw_miniCamXAngle->toReal();
} else if (cv == tw_miniCamAngle) {
x30_miniCamAngle = tw_miniCamAngle->toReal();
} else if (cv == tw_visitedsurfaceColor) {
x3c_surfColorVisited = zeus::CColor(tw_visitedsurfaceColor->toVec4f());
} else if (cv == tw_visitedOutlineColor) {
x40_outlineColorVisited = zeus::CColor(tw_visitedOutlineColor->toVec4f());
} else if (cv == tw_unvisitedSurfaceColor) {
x44_surfColorUnvisited = zeus::CColor(tw_unvisitedSurfaceColor->toVec4f());
} else if (cv == tw_unvisitedOutlineColor) {
x48_outlineColorUnvisited = zeus::CColor(tw_unvisitedOutlineColor->toVec4f());
} else if (cv == tw_selectedVisitedSurfaceColor) {
x4c_surfaceSelectColorVisited = zeus::CColor(tw_selectedVisitedSurfaceColor->toVec4f());
} else if (cv == tw_selectedVisitedOutlineColor) {
x50_outlineSelectColorVisited = zeus::CColor(tw_selectedVisitedOutlineColor->toVec4f());
} else if (cv == tw_mapSurfaceNormColorLinear) {
x54_mapSurfaceNormColorLinear = tw_mapSurfaceNormColorLinear->toReal();
} else if (cv == tw_mapSurfaceNormColorConstant) {
x58_mapSurfaceNormColorConstant = tw_mapSurfaceNormColorConstant->toReal();
}
}
void CTweakAutoMapper::initCVars(hecl::CVarManager* mgr) {
auto assignBool = [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) { _tweakListener(cv); });
return cv;
};
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 = cv->toReal();
cv->addListener([this](hecl::CVar* cv) { _tweakListener(cv); });
return cv;
};
auto assignColorValue = [this, mgr](std::string_view name, std::string_view desc, zeus::CColor& v,
hecl::CVar::EFlags flags) {
atVec4f vec{v.mSimd};
hecl::CVar* cv = mgr->findOrMakeCVar(name, desc, vec, flags | hecl::CVar::EFlags::Color);
// Check if the CVar was deserialized, this avoid an unnecessary conversion
if (cv->wasDeserialized())
v = zeus::CColor(cv->toVec4f());
cv->addListener([this](hecl::CVar* cv) { _tweakListener(cv); });
return cv;
};
tw_showOneMiniMapArea = assignBool(skShowOneMiniMapArea, "", x4_24_showOneMiniMapArea,
hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Gui | hecl::CVar::EFlags::Archive);
tw_scaleMoveSpeedWithCamDist =
assignBool(skScaleMoveSpeedWithCamDist, "", x4_26_scaleMoveSpeedWithCamDist,
hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Gui | hecl::CVar::EFlags::Archive);
tw_camDist = assignRealValue(skCamDist, "", x8_camDist,
hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Gui | hecl::CVar::EFlags::Archive);
tw_minCamDist = assignRealValue(skMinCameraDist, "", xc_minCamDist,
hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Gui | hecl::CVar::EFlags::Archive);
tw_maxCamDist = assignRealValue(skMaxCamDist, "", x10_maxCamDist,
hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Gui | hecl::CVar::EFlags::Archive);
tw_minCamRotX = assignRealValue(skMinCamRotX, "", x14_minCamRotateX,
hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Gui | hecl::CVar::EFlags::Archive);
tw_maxCamRotX = assignRealValue(skMaxCamRotX, "", x18_maxCamRotateX,
hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Gui | hecl::CVar::EFlags::Archive);
tw_camAngle = assignRealValue(skCamAngle, "", x1c_camAngle,
hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Gui | hecl::CVar::EFlags::Archive);
tw_widgetColor = assignColorValue(skWidgetColor, "", x24_automapperWidgetColor,
hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Gui | hecl::CVar::EFlags::Archive);
tw_miniCamDist = assignRealValue(skMiniCamDist, "", x28_miniCamDist,
hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Gui | hecl::CVar::EFlags::Archive);
tw_miniCamXAngle = assignRealValue(skMiniCamXAngle, "", x2c_miniCamXAngle,
hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Gui | hecl::CVar::EFlags::Archive);
tw_miniCamAngle = assignRealValue(skMiniCamAngle, "", x30_miniCamAngle,
hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Gui | hecl::CVar::EFlags::Archive);
tw_widgetColor = assignColorValue(skWidgetColor, "", x38_automapperWidgetMiniColor,
hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Gui | hecl::CVar::EFlags::Archive);
tw_visitedsurfaceColor =
assignColorValue(skVisitedSurfaceColor, "", x3c_surfColorVisited,
hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Gui | hecl::CVar::EFlags::Archive);
tw_visitedOutlineColor =
assignColorValue(skVisitedOutlineColor, "", x40_outlineColorVisited,
hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Gui | hecl::CVar::EFlags::Archive);
tw_unvisitedSurfaceColor =
assignColorValue(skUnvisitedSurfaceColor, "", x44_surfColorUnvisited,
hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Gui | hecl::CVar::EFlags::Archive);
tw_unvisitedOutlineColor =
assignColorValue(skUnvisitedOutlineColor, "", x48_outlineColorUnvisited,
hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Gui | hecl::CVar::EFlags::Archive);
tw_selectedVisitedSurfaceColor =
assignColorValue(skSelectedVisitedSurfaceColor, "", x4c_surfaceSelectColorVisited,
hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Gui | hecl::CVar::EFlags::Archive);
tw_selectedVisitedOutlineColor =
assignColorValue(skSelectedVisitedOutlineColor, "", x50_outlineSelectColorVisited,
hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Gui | hecl::CVar::EFlags::Archive);
tw_mapSurfaceNormColorLinear =
assignRealValue(skMapSurfaceNormalColorLinear, "", x54_mapSurfaceNormColorLinear,
hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Gui | hecl::CVar::EFlags::Archive);
tw_mapSurfaceNormColorConstant =
assignRealValue(skMapSurfaceNormalColorConstant, "", x58_mapSurfaceNormColorConstant,
hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Gui | hecl::CVar::EFlags::Archive);
}
}

View File

@ -9,9 +9,9 @@ hecl::CVar* tw_fov = nullptr;
hecl::CVar* tw_hardmodeDMult = nullptr;
hecl::CVar* tw_hardmodeWMult = nullptr;
namespace {
constexpr std::string_view skFov = "tweaks.game.FieldOfView"sv;
constexpr std::string_view skHardModeDamageMultName = "tweaks.game.HardModeDamageMult"sv;
constexpr std::string_view skHardModeWeaponMultName = "tweaks.game.HardModeWeaponMult"sv;
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;
} // anonymous namespace
void CTweakGame::_tweakGameListener(hecl::CVar* cv) {
@ -29,7 +29,7 @@ void CTweakGame::initCVars(hecl::CVarManager* mgr) {
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->toReal();
v = static_cast<float>(cv->toReal());
cv->addListener([this](hecl::CVar* cv) { _tweakGameListener(cv); });
return cv;
};

View File

@ -7,7 +7,7 @@ CPakFile::CPakFile(std::string_view filename, bool buildDepList, bool worldPak)
if (!CDvdFile::operator bool())
Log.report(logvisor::Fatal, fmt("{}: Unable to open"), GetPath());
x28_24_buildDepList = buildDepList;
x28_24_buildDepList = true; // Always do this so URDE can rapidly pre-warm shaders
//x28_24_buildDepList = true; // Always do this so URDE can rapidly pre-warm shaders
x28_26_worldPak = worldPak;
x28_27_stashedInARAM = false;
}

View File

@ -82,7 +82,7 @@ void CTweaks::RegisterTweaks(hecl::CVarManager* cvarMgr) {
strm.emplace(g_ResFactory->LoadResourceSync(*tag).release(), g_ResFactory->ResourceSize(*tag), true);
g_tweakAutoMapper = new DataSpec::DNAMP1::CTweakAutoMapper(*strm);
CMappableObject::ReadAutoMapperTweaks(*g_tweakAutoMapper);
g_tweakPlayerGun->initCVars(cvarMgr);
g_tweakAutoMapper->initCVars(cvarMgr);
/* Gui */
tag = g_ResFactory->GetResourceIdByName("Gui");

View File

@ -387,7 +387,8 @@ bool CMain::LoadAudio() {
void CMain::EnsureWorldPaksReady() {}
void CMain::EnsureWorldPakReady(CAssetId mlvl) { /* TODO: Schedule resource list load for World Pak containing mlvl */ }
void CMain::EnsureWorldPakReady(CAssetId mlvl) { /* TODO: Schedule resource list load for World Pak containing mlvl */
}
void CMain::Give(hecl::Console* console, const std::vector<std::string>& args) {
if (args.size() < 1 || (!g_GameState || !g_GameState->GetPlayerState()))
@ -404,6 +405,8 @@ void CMain::Give(hecl::Console* console, const std::vector<std::string>& args) {
CPlayerState::GetPowerUpMaxValue(CPlayerState::EItemType(item)));
}
pState->IncrPickup(CPlayerState::EItemType::HealthRefill, 99999);
} else if (type == "map") {
g_GameState->CurrentWorldState().MapWorldInfo()->SetMapStationUsed(true);
} else {
CPlayerState::EItemType eType = CPlayerState::ItemNameToType(type);
if (eType == CPlayerState::EItemType::Invalid) {
@ -444,7 +447,7 @@ void CMain::Give(hecl::Console* console, const std::vector<std::string>& args) {
if (g_StateManager)
g_StateManager->Player()->AsyncLoadSuit(*g_StateManager);
console->report(hecl::Console::Level::Info, fmt("Cheater....., Greatly increasing Metroid encounters, have fun!"));
}
} // namespace MP1
void CMain::Remove(hecl::Console*, const std::vector<std::string>& args) {
if (args.size() < 1 || (!g_GameState || !g_GameState->GetPlayerState()))
@ -453,11 +456,17 @@ void CMain::Remove(hecl::Console*, const std::vector<std::string>& args) {
std::string type = args[0];
athena::utility::tolower(type);
std::shared_ptr<CPlayerState> pState = g_GameState->GetPlayerState();
CPlayerState::EItemType eType = CPlayerState::ItemNameToType(type);
if (eType != CPlayerState::EItemType::Invalid) {
pState->ReInitalizePowerUp(eType, 0);
if (g_StateManager)
g_StateManager->Player()->AsyncLoadSuit(*g_StateManager);
if (type == "all") {
} else if (type == "map") {
g_GameState->CurrentWorldState().MapWorldInfo()->SetMapStationUsed(false);
} else {
CPlayerState::EItemType eType = CPlayerState::ItemNameToType(type);
if (eType != CPlayerState::EItemType::Invalid) {
pState->ReInitalizePowerUp(eType, 0);
if (g_StateManager)
g_StateManager->Player()->AsyncLoadSuit(*g_StateManager);
}
}
}