Move CVar* into Metaforce to begin removal of hecl's Dataspec

This commit is contained in:
Phillip Stephens 2022-02-20 18:28:07 -08:00
parent 64d4b0388c
commit 6c92f03664
Signed by: Antidote
GPG Key ID: F8BEE4C83DACA60D
45 changed files with 712 additions and 571 deletions

View File

@ -1,8 +1,16 @@
#pragma once #pragma once
#include <chrono>
#include <cstdint> #include <cstdint>
#include <cstdlib> #include <cstdlib>
#include <chrono> #ifndef _WIN32
#include <sys/stat.h>
#else
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#endif
#include "Runtime/GCNTypes.hpp" #include "Runtime/GCNTypes.hpp"
@ -26,6 +34,12 @@ struct OSCalendarTime {
class CBasics { class CBasics {
public: public:
#if _WIN32
using Sstat = struct ::_stat64;
#else
using Sstat = struct stat;
#endif
static void Initialize(); static void Initialize();
static const u64 SECONDS_TO_2000; static const u64 SECONDS_TO_2000;
@ -48,6 +62,9 @@ public:
static void Swap2Bytes(u8* v); static void Swap2Bytes(u8* v);
static void Swap4Bytes(u8* v); static void Swap4Bytes(u8* v);
static void Swap8Bytes(u8* v); static void Swap8Bytes(u8* v);
static int RecursiveMakeDir(const char* dir);
static void MakeDir(const char* dir);
static int Stat(const char* path, Sstat* statOut);
}; };
} // namespace metaforce } // namespace metaforce

View File

@ -1,21 +1,26 @@
#ifndef _WIN32 #ifndef _WIN32
#include <unistd.h>
#include <sys/time.h> #include <sys/time.h>
#include <unistd.h>
#if __APPLE__ #if __APPLE__
#include <mach/mach_time.h> #include <mach/mach_time.h>
#endif #endif
#else
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#endif #endif
#include <cstdio> #include <algorithm>
#include <cstdarg> #include <cstdarg>
#include <cstdio>
#include <cstring>
#include <ctime> #include <ctime>
#ifdef WIN32
#include <windows.h>
#ifndef _WIN32_IE
#define _WIN32_IE 0x0400
#endif
#include <shlobj.h>
#endif
#include "Runtime/CBasics.hpp" #include "Runtime/CBasics.hpp"
#include <logvisor/logvisor.hpp>
#if __APPLE__ #if __APPLE__
static u64 MachToDolphinNum; static u64 MachToDolphinNum;
@ -25,7 +30,7 @@ static LARGE_INTEGER PerfFrequency;
#endif #endif
namespace metaforce { namespace metaforce {
static logvisor::Module LogModule("metaforce::CBasics");
void CBasics::Initialize() { void CBasics::Initialize() {
#if __APPLE__ #if __APPLE__
mach_timebase_info_data_t timebase; mach_timebase_info_data_t timebase;
@ -195,4 +200,132 @@ void CBasics::Swap8Bytes(u8* v) {
#endif #endif
} }
int CBasics::Stat(const char* path, Sstat* statOut) {
#if _WIN32
size_t pos;
const nowide::wstackstring wpath(path);
const wchar_t* wpathP = wpath.get();
for (pos = 0; pos < 3 && wpathP[pos] != L'\0'; ++pos) {}
if (pos == 2 && wpathP[1] == L':') {
wchar_t fixPath[4] = {wpathP[0], L':', L'/', L'\0'};
return _wstat64(fixPath, statOut);
}
return _wstat64(wpath.get(), statOut);
#else
return stat(path, statOut);
#endif
}
/* recursive mkdir */
int CBasics::RecursiveMakeDir(const char* dir) {
#if _WIN32
char tmp[1024];
/* copy path */
std::strncpy(tmp, dir, std::size(tmp));
const size_t len = std::strlen(tmp);
if (len >= std::size(tmp)) {
return -1;
}
/* remove trailing slash */
if (tmp[len - 1] == '/' || tmp[len - 1] == '\\') {
tmp[len - 1] = 0;
}
/* recursive mkdir */
char* p = nullptr;
Sstat sb;
for (p = tmp + 1; *p; p++) {
if (*p == '/' || *p == '\\') {
*p = 0;
/* test path */
if (Stat(tmp, &sb) != 0) {
/* path does not exist - create directory */
const nowide::wstackstring wtmp(tmp);
if (!CreateDirectoryW(wtmp.get(), nullptr)) {
return -1;
}
} else if (!S_ISDIR(sb.st_mode)) {
/* not a directory */
return -1;
}
*p = '/';
}
}
/* test path */
if (Stat(tmp, &sb) != 0) {
/* path does not exist - create directory */
const nowide::wstackstring wtmp(tmp);
if (!CreateDirectoryW(wtmp.get(), nullptr)) {
return -1;
}
} else if (!S_ISDIR(sb.st_mode)) {
/* not a directory */
return -1;
}
return 0;
#else
char tmp[1024];
/* copy path */
std::memset(tmp, 0, std::size(tmp));
std::strncpy(tmp, dir, std::size(tmp) - 1);
const size_t len = std::strlen(tmp);
if (len >= std::size(tmp)) {
return -1;
}
/* remove trailing slash */
if (tmp[len - 1] == '/') {
tmp[len - 1] = 0;
}
/* recursive mkdir */
char* p = nullptr;
Sstat sb;
for (p = tmp + 1; *p; p++) {
if (*p == '/') {
*p = 0;
/* test path */
if (Stat(tmp, &sb) != 0) {
/* path does not exist - create directory */
if (mkdir(tmp, 0755) < 0) {
return -1;
}
} else if (!S_ISDIR(sb.st_mode)) {
/* not a directory */
return -1;
}
*p = '/';
}
}
/* test path */
if (Stat(tmp, &sb) != 0) {
/* path does not exist - create directory */
if (mkdir(tmp, 0755) < 0) {
return -1;
}
} else if (!S_ISDIR(sb.st_mode)) {
/* not a directory */
return -1;
}
return 0;
#endif
}
void CBasics::MakeDir(const char* dir) {
#if _WIN32
HRESULT err;
const nowide::wstackstring wdir(dir);
if (!CreateDirectoryW(wdir.get(), NULL))
if ((err = GetLastError()) != ERROR_ALREADY_EXISTS)
LogModule.report(logvisor::Fatal, FMT_STRING("MakeDir({})"), dir);
#else
if (mkdir(dir, 0755))
if (errno != EEXIST)
LogModule.report(logvisor::Fatal, FMT_STRING("MakeDir({}): {}"), dir, strerror(errno));
#endif
}
} // namespace metaforce } // namespace metaforce

View File

@ -14,7 +14,7 @@
#include "Runtime/Graphics/CMoviePlayer.hpp" #include "Runtime/Graphics/CMoviePlayer.hpp"
#include "Runtime/Input/CFinalInput.hpp" #include "Runtime/Input/CFinalInput.hpp"
#include <hecl/CVarManager.hpp> #include "ConsoleVariables/CVarManager.hpp"
namespace metaforce { namespace metaforce {

View File

@ -8,17 +8,19 @@
#include "ImGuiEngine.hpp" #include "ImGuiEngine.hpp"
#include "Runtime/Graphics/CGraphics.hpp" #include "Runtime/Graphics/CGraphics.hpp"
#include "Runtime/MP1/MP1.hpp" #include "Runtime/MP1/MP1.hpp"
#include "Runtime/ConsoleVariables/FileStoreManager.hpp"
#include "Runtime/ConsoleVariables/CVarManager.hpp"
#include "amuse/BooBackend.hpp" #include "amuse/BooBackend.hpp"
#include "../version.h" #include "../version.h"
//#include <fenv.h>
//#pragma STDC FENV_ACCESS ON
/* Static reference to dataspec additions /* Static reference to dataspec additions
* (used by MSVC to definitively link DataSpecs) */ * (used by MSVC to definitively link DataSpecs) */
#include "DataSpecRegistry.hpp" #include "DataSpecRegistry.hpp"
//#include <fenv.h>
//#pragma STDC FENV_ACCESS ON
#include <aurora/aurora.hpp> #include <aurora/aurora.hpp>
using namespace std::literals; using namespace std::literals;
@ -247,9 +249,9 @@ private:
struct Application : aurora::AppDelegate { struct Application : aurora::AppDelegate {
private: private:
hecl::Runtime::FileStoreManager& m_fileMgr; FileStoreManager& m_fileMgr;
hecl::CVarManager& m_cvarManager; CVarManager& m_cvarManager;
hecl::CVarCommons& m_cvarCommons; CVarCommons& m_cvarCommons;
ImGuiConsole m_imGuiConsole; ImGuiConsole m_imGuiConsole;
std::string m_errorString; std::string m_errorString;
@ -271,7 +273,7 @@ private:
// is built, i.e during initialization // is built, i.e during initialization
public: public:
Application(hecl::Runtime::FileStoreManager& fileMgr, hecl::CVarManager& cvarMgr, hecl::CVarCommons& cvarCmns) Application(FileStoreManager& fileMgr, CVarManager& cvarMgr, CVarCommons& cvarCmns)
: m_fileMgr(fileMgr), m_cvarManager(cvarMgr), m_cvarCommons(cvarCmns), m_imGuiConsole(cvarMgr, cvarCmns) {} : m_fileMgr(fileMgr), m_cvarManager(cvarMgr), m_cvarCommons(cvarCmns), m_imGuiConsole(cvarMgr, cvarCmns) {}
void onAppLaunched() override { void onAppLaunched() override {
@ -300,10 +302,6 @@ public:
for (const auto& str : aurora::get_args()) { for (const auto& str : aurora::get_args()) {
auto arg = static_cast<std::string>(str); auto arg = static_cast<std::string>(str);
if (arg.starts_with("--verbosity=") || arg.starts_with("-v=")) {
hecl::VerbosityLevel = atoi(arg.substr(arg.find_last_of('=') + 1).c_str());
hecl::LogModule.report(logvisor::Info, FMT_STRING("Set verbosity level to {}"), hecl::VerbosityLevel);
}
} }
const zeus::CPUInfo& cpuInf = zeus::cpuFeatures(); const zeus::CPUInfo& cpuInf = zeus::cpuFeatures();
@ -569,16 +567,18 @@ static void SetupBasics(bool logging) {
atSetExceptionHandler(AthenaExc); atSetExceptionHandler(AthenaExc);
#if SENTRY_ENABLED #if SENTRY_ENABLED
hecl::Runtime::FileStoreManager fileMgr{"sentry-native-metaforce"}; FileStoreManager fileMgr{"sentry-native-metaforce"};
std::string cacheDir{fileMgr.getStoreRoot()}; std::string cacheDir{fileMgr.getStoreRoot()};
logvisor::RegisterSentry("metaforce", METAFORCE_WC_DESCRIBE, cacheDir.c_str()); logvisor::RegisterSentry("metaforce", METAFORCE_WC_DESCRIBE, cacheDir.c_str());
#endif #endif
} }
static bool IsClientLoggingEnabled(int argc, char** argv) { static bool IsClientLoggingEnabled(int argc, char** argv) {
for (int i = 1; i < argc; ++i) for (int i = 1; i < argc; ++i) {
if (!hecl::StrNCmp(argv[i], "-l", 2)) if (!strncmp(argv[i], "-l", 2)) {
return true; return true;
}
}
return false; return false;
} }
@ -588,15 +588,15 @@ int main(int argc, char** argv) {
// but breaks animations, need to research why this is the case // but breaks animations, need to research why this is the case
// for now it's disabled // for now it's disabled
// fesetround(FE_TOWARDZERO); // fesetround(FE_TOWARDZERO);
if (argc > 1 && !hecl::StrCmp(argv[1], "--dlpackage")) { if (argc > 1 && !strcmp(argv[1], "--dlpackage")) {
fmt::print(FMT_STRING("{}\n"), METAFORCE_DLPACKAGE); fmt::print(FMT_STRING("{}\n"), METAFORCE_DLPACKAGE);
return 100; return 100;
} }
SetupBasics(IsClientLoggingEnabled(argc, argv)); SetupBasics(IsClientLoggingEnabled(argc, argv));
hecl::Runtime::FileStoreManager fileMgr{"metaforce"}; metaforce::FileStoreManager fileMgr{"metaforce"};
hecl::CVarManager cvarMgr{fileMgr}; metaforce::CVarManager cvarMgr{fileMgr};
hecl::CVarCommons cvarCmns{cvarMgr}; metaforce::CVarCommons cvarCmns{cvarMgr};
std::vector<std::string> args; std::vector<std::string> args;
for (int i = 1; i < argc; ++i) for (int i = 1; i < argc; ++i)

View File

@ -70,6 +70,10 @@ set(RUNTIME_SOURCES_B
${PARTICLE_SOURCES} ${PARTICLE_SOURCES}
${WORLD_SOURCES} ${WORLD_SOURCES}
${WEAPON_SOURCES} ${WEAPON_SOURCES}
ConsoleVariables/FileStoreManager.hpp ConsoleVariables/FileStoreManager.cpp
ConsoleVariables/CVar.hpp ConsoleVariables/CVar.cpp
ConsoleVariables/CVarManager.hpp ConsoleVariables/CVarManager.cpp
ConsoleVariables/CVarCommons.hpp ConsoleVariables/CVarCommons.cpp
Tweaks/ITweak.hpp Tweaks/ITweak.hpp
Tweaks/ITweakAutoMapper.hpp Tweaks/ITweakAutoMapper.hpp
Tweaks/ITweakBall.hpp Tweaks/ITweakBall.hpp

View File

@ -6,8 +6,8 @@
#include "Runtime/GameGlobalObjects.hpp" #include "Runtime/GameGlobalObjects.hpp"
#include "Runtime/Graphics/CTexture.hpp" #include "Runtime/Graphics/CTexture.hpp"
#include "Runtime/GuiSys/CStringTable.hpp" #include "Runtime/GuiSys/CStringTable.hpp"
#include <hecl/CVar.hpp> #include "ConsoleVariables/CVar.hpp"
#include <hecl/CVarManager.hpp> #include "ConsoleVariables/CVarManager.hpp"
namespace metaforce { namespace metaforce {
namespace { namespace {
@ -16,8 +16,8 @@ using ECardResult = kabufuda::ECardResult;
static std::string g_CardImagePaths[2] = {}; static std::string g_CardImagePaths[2] = {};
static kabufuda::Card g_CardStates[2] = {kabufuda::Card{"GM8E", "01"}, kabufuda::Card{"GM8E", "01"}}; static kabufuda::Card g_CardStates[2] = {kabufuda::Card{"GM8E", "01"}, kabufuda::Card{"GM8E", "01"}};
// static kabufuda::ECardResult g_OpResults[2] = {}; // static kabufuda::ECardResult g_OpResults[2] = {};
hecl::CVar* mc_dolphinAPath = nullptr; CVar* mc_dolphinAPath = nullptr;
hecl::CVar* mc_dolphinBPath = nullptr; CVar* mc_dolphinBPath = nullptr;
} // namespace } // namespace
CSaveWorldIntermediate::CSaveWorldIntermediate(CAssetId mlvl, CAssetId savw) : x0_mlvlId(mlvl), x8_savwId(savw) { CSaveWorldIntermediate::CSaveWorldIntermediate(CAssetId mlvl, CAssetId savw) : x0_mlvlId(mlvl), x8_savwId(savw) {
if (!savw.IsValid()) if (!savw.IsValid())
@ -71,12 +71,12 @@ const CSaveWorldMemory& CMemoryCardSys::GetSaveWorldMemory(CAssetId wldId) const
} }
CMemoryCardSys::CMemoryCardSys() { CMemoryCardSys::CMemoryCardSys() {
mc_dolphinAPath = hecl::CVarManager::instance()->findOrMakeCVar( mc_dolphinAPath = CVarManager::instance()->findOrMakeCVar(
"memcard.PathA"sv, "Path to the memory card image for SlotA"sv, ""sv, "memcard.PathA"sv, "Path to the memory card image for SlotA"sv, ""sv,
(hecl::CVar::EFlags::Archive | hecl::CVar::EFlags::System | hecl::CVar::EFlags::ModifyRestart)); (CVar::EFlags::Archive | CVar::EFlags::System | CVar::EFlags::ModifyRestart));
mc_dolphinBPath = hecl::CVarManager::instance()->findOrMakeCVar( mc_dolphinBPath = CVarManager::instance()->findOrMakeCVar(
"memcard.PathB"sv, "Path to the memory card image for SlotB"sv, ""sv, "memcard.PathB"sv, "Path to the memory card image for SlotB"sv, ""sv,
(hecl::CVar::EFlags::Archive | hecl::CVar::EFlags::System | hecl::CVar::EFlags::ModifyRestart)); (CVar::EFlags::Archive | CVar::EFlags::System | CVar::EFlags::ModifyRestart));
x0_hints = g_SimplePool->GetObj("HINT_Hints"); x0_hints = g_SimplePool->GetObj("HINT_Hints");
xc_memoryWorlds.reserve(16); xc_memoryWorlds.reserve(16);
x1c_worldInter.emplace(); x1c_worldInter.emplace();
@ -340,7 +340,7 @@ std::string CMemoryCardSys::_GetDolphinCardPath(kabufuda::ECardSlot slot) {
return g_CardImagePaths[static_cast<u32>(slot)]; return g_CardImagePaths[static_cast<u32>(slot)];
} }
void CMemoryCardSys::_ResolveDolphinCardPath(const hecl::CVar* cv, kabufuda::ECardSlot slot) { void CMemoryCardSys::_ResolveDolphinCardPath(const CVar* cv, kabufuda::ECardSlot slot) {
if (cv != nullptr && cv->toLiteral().empty()) { if (cv != nullptr && cv->toLiteral().empty()) {
g_CardImagePaths[int(slot)] = ResolveDolphinCardPath(slot); g_CardImagePaths[int(slot)] = ResolveDolphinCardPath(slot);
} else if (cv != nullptr) { } else if (cv != nullptr) {

View File

@ -69,7 +69,7 @@ class CMemoryCardSys {
public: public:
static void _ResetCVar(kabufuda::ECardSlot slot); static void _ResetCVar(kabufuda::ECardSlot slot);
static void _ResolveDolphinCardPath(const hecl::CVar* cv, kabufuda::ECardSlot slot); static void _ResolveDolphinCardPath(const CVar* cv, kabufuda::ECardSlot slot);
static std::string ResolveDolphinCardPath(kabufuda::ECardSlot slot); static std::string ResolveDolphinCardPath(kabufuda::ECardSlot slot);
static bool CreateDolphinCard(kabufuda::ECardSlot slot); static bool CreateDolphinCard(kabufuda::ECardSlot slot);
static std::string _GetDolphinCardPath(kabufuda::ECardSlot slot); static std::string _GetDolphinCardPath(kabufuda::ECardSlot slot);

View File

@ -47,19 +47,19 @@
#include "Runtime/World/CSnakeWeedSwarm.hpp" #include "Runtime/World/CSnakeWeedSwarm.hpp"
#include "Runtime/World/CWallCrawlerSwarm.hpp" #include "Runtime/World/CWallCrawlerSwarm.hpp"
#include "Runtime/World/CWorld.hpp" #include "Runtime/World/CWorld.hpp"
#include "TCastTo.hpp" // Generated file, do not modify include path #include "Runtime/ConsoleVariables/CVarManager.hpp"
#include <hecl/CVarManager.hpp> #include "TCastTo.hpp" // Generated file, do not modify include path
#include <zeus/CMRay.hpp> #include <zeus/CMRay.hpp>
namespace metaforce { namespace metaforce {
namespace { namespace {
hecl::CVar* debugToolDrawAiPath = nullptr; CVar* debugToolDrawAiPath = nullptr;
hecl::CVar* debugToolDrawLighting = nullptr; CVar* debugToolDrawLighting = nullptr;
hecl::CVar* debugToolDrawCollisionActors = nullptr; CVar* debugToolDrawCollisionActors = nullptr;
hecl::CVar* debugToolDrawMazePath = nullptr; CVar* debugToolDrawMazePath = nullptr;
hecl::CVar* debugToolDrawPlatformCollision = nullptr; CVar* debugToolDrawPlatformCollision = nullptr;
hecl::CVar* sm_logScripting = nullptr; CVar* sm_logScripting = nullptr;
} // namespace } // namespace
logvisor::Module LogModule("metaforce::CStateManager"); logvisor::Module LogModule("metaforce::CStateManager");
CStateManager::CStateManager(const std::weak_ptr<CScriptMailbox>& mailbox, const std::weak_ptr<CMapWorldInfo>& mwInfo, CStateManager::CStateManager(const std::weak_ptr<CScriptMailbox>& mailbox, const std::weak_ptr<CMapWorldInfo>& mwInfo,
@ -217,9 +217,9 @@ CStateManager::CStateManager(const std::weak_ptr<CScriptMailbox>& mailbox, const
g_StateManager = this; g_StateManager = this;
if (sm_logScripting == nullptr) { if (sm_logScripting == nullptr) {
sm_logScripting = hecl::CVarManager::instance()->findOrMakeCVar( sm_logScripting = CVarManager::instance()->findOrMakeCVar(
"stateManager.logScripting"sv, "Prints object communication to the console", false, "stateManager.logScripting"sv, "Prints object communication to the console", false,
hecl::CVar::EFlags::ReadOnly | hecl::CVar::EFlags::Archive | hecl::CVar::EFlags::Game); CVar::EFlags::ReadOnly | CVar::EFlags::Archive | CVar::EFlags::Game);
} }
m_logScriptingReference.emplace(&m_logScripting, sm_logScripting); m_logScriptingReference.emplace(&m_logScripting, sm_logScripting);
} }
@ -545,18 +545,18 @@ void CStateManager::BuildDynamicLightListForWorld() {
} }
} }
void CStateManager::DrawDebugStuff() const { void CStateManager::DrawDebugStuff() const {
if (hecl::com_developer != nullptr && !hecl::com_developer->toBoolean()) { if (com_developer != nullptr && !com_developer->toBoolean()) {
return; return;
} }
// FIXME: Add proper globals for CVars // FIXME: Add proper globals for CVars
if (debugToolDrawAiPath == nullptr || debugToolDrawCollisionActors == nullptr || debugToolDrawLighting == nullptr || if (debugToolDrawAiPath == nullptr || debugToolDrawCollisionActors == nullptr || debugToolDrawLighting == nullptr ||
debugToolDrawMazePath == nullptr || debugToolDrawPlatformCollision == nullptr) { debugToolDrawMazePath == nullptr || debugToolDrawPlatformCollision == nullptr) {
debugToolDrawAiPath = hecl::CVarManager::instance()->findCVar("debugTool.drawAiPath"); debugToolDrawAiPath = CVarManager::instance()->findCVar("debugTool.drawAiPath");
debugToolDrawMazePath = hecl::CVarManager::instance()->findCVar("debugTool.drawMazePath"); debugToolDrawMazePath = CVarManager::instance()->findCVar("debugTool.drawMazePath");
debugToolDrawCollisionActors = hecl::CVarManager::instance()->findCVar("debugTool.drawCollisionActors"); debugToolDrawCollisionActors = CVarManager::instance()->findCVar("debugTool.drawCollisionActors");
debugToolDrawLighting = hecl::CVarManager::instance()->findCVar("debugTool.drawLighting"); debugToolDrawLighting = CVarManager::instance()->findCVar("debugTool.drawLighting");
debugToolDrawPlatformCollision = hecl::CVarManager::instance()->findCVar("debugTool.drawPlatformCollision"); debugToolDrawPlatformCollision = CVarManager::instance()->findCVar("debugTool.drawPlatformCollision");
return; return;
} }

View File

@ -217,7 +217,7 @@ private:
std::map<TEditorId, std::set<SConnection>> m_incomingConnections; std::map<TEditorId, std::set<SConnection>> m_incomingConnections;
bool m_logScripting = false; bool m_logScripting = false;
std::optional<hecl::CVarValueReference<bool>> m_logScriptingReference; std::optional<CVarValueReference<bool>> m_logScriptingReference;
void UpdateThermalVisor(); void UpdateThermalVisor();
static void RendererDrawCallback(void*, void*, int); static void RendererDrawCallback(void*, void*, int);

View File

@ -16,7 +16,7 @@ CFirstPersonCamera::CFirstPersonCamera(TUniqueId uid, const zeus::CTransform& xf
nearz, farz, aspect, watchedObj, false, 0) nearz, farz, aspect, watchedObj, false, 0)
, x188_orbitCameraSpeed(orbitCameraSpeed) , x188_orbitCameraSpeed(orbitCameraSpeed)
, x190_gunFollowXf(xf) { , x190_gunFollowXf(xf) {
MP1::tw_FieldOfView->addListener([this](hecl::CVar* cv) { _fovListener(cv); }); MP1::tw_FieldOfView->addListener([this](CVar* cv) { _fovListener(cv); });
} }
void CFirstPersonCamera::Accept(IVisitor& visitor) { visitor.Visit(this); } void CFirstPersonCamera::Accept(IVisitor& visitor) { visitor.Visit(this); }
@ -328,7 +328,7 @@ void CFirstPersonCamera::UpdateElevation(CStateManager& mgr) {
} }
} }
void CFirstPersonCamera::_fovListener(hecl::CVar* cv) { void CFirstPersonCamera::_fovListener(CVar* cv) {
x15c_currentFov = x180_perspInterpStartFov = x184_perspInterpEndFov = cv->toReal(); x15c_currentFov = x180_perspInterpStartFov = x184_perspInterpEndFov = cv->toReal();
x170_24_perspDirty = true; x170_24_perspDirty = true;
} }

View File

@ -17,7 +17,7 @@ class CFirstPersonCamera : public CGameCamera {
bool x1c6_24_deferBallTransitionProcessing : 1 = false; bool x1c6_24_deferBallTransitionProcessing : 1 = false;
zeus::CVector3f x1c8_closeInVec; zeus::CVector3f x1c8_closeInVec;
float x1d4_closeInTimer = 0.f; float x1d4_closeInTimer = 0.f;
void _fovListener(hecl::CVar* cv); void _fovListener(CVar* cv);
public: public:
DEFINE_ENTITY DEFINE_ENTITY

View File

@ -1,13 +1,10 @@
#include "hecl/CVar.hpp" #include "Runtime/ConsoleVariables/CVar.hpp"
#include <sstream> #include <sstream>
#include "hecl/CVarManager.hpp" #include "Runtime/ConsoleVariables/CVarManager.hpp"
#include "hecl/hecl.hpp"
#include <athena/Utility.hpp> namespace metaforce {
namespace hecl {
extern CVar* com_developer; extern CVar* com_developer;
extern CVar* com_enableCheats; extern CVar* com_enableCheats;
@ -19,38 +16,38 @@ CVar::CVar(std::string_view name, std::string_view value, std::string_view help,
init(flags); init(flags);
} }
CVar::CVar(std::string_view name, const atVec2f& value, std::string_view help, EFlags flags) CVar::CVar(std::string_view name, const zeus::CVector2f& value, std::string_view help, EFlags flags)
: CVar(name, help, EType::Vec2f) { : CVar(name, help, EType::Vec2f) {
fromVec2f(value); fromVec2f(value);
init(flags); init(flags);
} }
CVar::CVar(std::string_view name, const atVec2d& value, std::string_view help, EFlags flags) CVar::CVar(std::string_view name, const zeus::CVector2d& value, std::string_view help, EFlags flags)
: CVar(name, help, EType::Vec2d) { : CVar(name, help, EType::Vec2d) {
fromVec2d(value); fromVec2d(value);
init(flags); init(flags);
} }
CVar::CVar(std::string_view name, const atVec3f& value, std::string_view help, EFlags flags) CVar::CVar(std::string_view name, const zeus::CVector3f& value, std::string_view help, EFlags flags)
: CVar(name, help, EType::Vec3f) { : CVar(name, help, EType::Vec3f) {
fromVec3f(value); fromVec3f(value);
init(flags, false); init(flags, false);
} }
CVar::CVar(std::string_view name, const atVec3d& value, std::string_view help, EFlags flags) CVar::CVar(std::string_view name, const zeus::CVector3d& value, std::string_view help, EFlags flags)
: CVar(name, help, EType::Vec3d) { : CVar(name, help, EType::Vec3d) {
fromVec3d(value); fromVec3d(value);
init(flags, false); init(flags, false);
} }
CVar::CVar(std::string_view name, const atVec4f& value, std::string_view help, EFlags flags) CVar::CVar(std::string_view name, const zeus::CVector4f& value, std::string_view help, EFlags flags)
: CVar(name, help, EType::Vec4f) { : CVar(name, help, EType::Vec4f) {
fromVec4f(value); fromVec4f(value);
init(flags, false); init(flags, false);
} }
CVar::CVar(std::string_view name, const atVec4d& value, std::string_view help, EFlags flags) CVar::CVar(std::string_view name, const zeus::CVector4d& value, std::string_view help, EFlags flags)
: CVar(name, help, EType::Vec4d) { : CVar(name, help, EType::Vec4d) {
fromVec4d(value); fromVec4d(value);
init(flags, false); init(flags, false);
@ -83,118 +80,100 @@ std::string CVar::help() const {
return m_help + (m_defaultValue.empty() ? "" : "\ndefault: " + m_defaultValue) + (isReadOnly() ? " [ReadOnly]" : ""); return m_help + (m_defaultValue.empty() ? "" : "\ndefault: " + m_defaultValue) + (isReadOnly() ? " [ReadOnly]" : "");
} }
atVec2f CVar::toVec2f(bool* isValid) const { zeus::CVector2f CVar::toVec2f(bool* isValid) const {
if (m_type != EType::Vec2f) { if (m_type != EType::Vec2f) {
if (isValid != nullptr) if (isValid != nullptr)
*isValid = false; *isValid = false;
return atVec2f{}; return {};
} }
if (isValid != nullptr) if (isValid != nullptr)
*isValid = true; *isValid = true;
atVec2f vec{}; std::array<float, 2> f;
athena::simd_floats f;
std::sscanf(m_value.c_str(), "%g %g", &f[0], &f[1]); std::sscanf(m_value.c_str(), "%g %g", &f[0], &f[1]);
vec.simd.copy_from(f); return {f[0], f[1]};
return vec;
} }
atVec2d CVar::toVec2d(bool* isValid) const { zeus::CVector2d CVar::toVec2d(bool* isValid) const {
if (m_type != EType::Vec2d) { if (m_type != EType::Vec2d) {
if (isValid != nullptr) if (isValid != nullptr)
*isValid = false; *isValid = false;
return atVec2d{}; return {};
} }
if (isValid != nullptr) if (isValid != nullptr)
*isValid = true; *isValid = true;
atVec2d vec{}; std::array<double, 2> f;
athena::simd_doubles f;
std::sscanf(m_value.c_str(), "%lg %lg", &f[0], &f[1]); std::sscanf(m_value.c_str(), "%lg %lg", &f[0], &f[1]);
vec.simd.copy_from(f); return {f[0], f[1]};
return vec;
} }
atVec3f CVar::toVec3f(bool* isValid) const { zeus::CVector3f CVar::toVec3f(bool* isValid) const {
if (m_type != EType::Vec3f) { if (m_type != EType::Vec3f) {
if (isValid != nullptr) if (isValid != nullptr)
*isValid = false; *isValid = false;
return atVec3f{}; return {};
} }
if (isValid != nullptr) if (isValid != nullptr)
*isValid = true; *isValid = true;
atVec3f vec{}; std::array<float, 3> f;
athena::simd_floats f;
std::sscanf(m_value.c_str(), "%g %g %g", &f[0], &f[1], &f[2]); std::sscanf(m_value.c_str(), "%g %g %g", &f[0], &f[1], &f[2]);
vec.simd.copy_from(f); return {f[0], f[1], f[2]};
return vec;
} }
atVec3d CVar::toVec3d(bool* isValid) const { zeus::CVector3d CVar::toVec3d(bool* isValid) const {
if (m_type != EType::Vec3d) { if (m_type != EType::Vec3d) {
if (isValid != nullptr) if (isValid != nullptr)
*isValid = false; *isValid = false;
return atVec3d{}; return {};
} }
if (isValid != nullptr) if (isValid != nullptr)
*isValid = true; *isValid = true;
atVec3d vec{}; std::array<double, 3> f;
athena::simd_doubles f;
std::sscanf(m_value.c_str(), "%lg %lg %lg", &f[0], &f[1], &f[2]); std::sscanf(m_value.c_str(), "%lg %lg %lg", &f[0], &f[1], &f[2]);
vec.simd.copy_from(f); return {f[0], f[1], f[2]};
return vec;
} }
atVec4f CVar::toVec4f(bool* isValid) const { zeus::CVector4f CVar::toVec4f(bool* isValid) const {
if (m_type != EType::Vec4f) { if (m_type != EType::Vec4f) {
if (isValid != nullptr) if (isValid != nullptr)
*isValid = false; *isValid = false;
return atVec4f{}; return {};
} }
if (isValid != nullptr) if (isValid != nullptr)
*isValid = true; *isValid = true;
atVec4f vec{}; std::array<float, 4> f;
athena::simd_floats f;
std::sscanf(m_value.c_str(), "%g %g %g %g", &f[0], &f[1], &f[2], &f[3]); std::sscanf(m_value.c_str(), "%g %g %g %g", &f[0], &f[1], &f[2], &f[3]);
vec.simd.copy_from(f); return {f[0], f[1], f[2], f[3]};
return vec;
} }
atVec4d CVar::toVec4d(bool* isValid) const { zeus::CVector4d CVar::toVec4d(bool* isValid) const {
if (m_type != EType::Vec4d) { if (m_type != EType::Vec4d) {
if (isValid != nullptr) if (isValid != nullptr)
*isValid = false; *isValid = false;
return atVec4d{}; return {};
} }
if (isValid != nullptr) if (isValid != nullptr)
*isValid = true; *isValid = true;
atVec4d vec{}; std::array<double, 4> f{};
athena::simd_doubles f;
std::sscanf(m_value.c_str(), "%lg %lg %lg %lg", &f[0], &f[1], &f[2], &f[3]); std::sscanf(m_value.c_str(), "%lg %lg %lg %lg", &f[0], &f[1], &f[2], &f[3]);
vec.simd.copy_from(f); return {f[0], f[1], f[2], f[3]};
return vec;
} }
double CVar::toReal(bool* isValid) const { double CVar::toReal(bool* isValid) const {
@ -259,62 +238,56 @@ std::string CVar::toLiteral(bool* isValid) const {
return m_value; return m_value;
} }
bool CVar::fromVec2f(const atVec2f& val) { bool CVar::fromVec2f(const zeus::CVector2f& val) {
if (!safeToModify(EType::Vec2f)) if (!safeToModify(EType::Vec2f))
return false; return false;
athena::simd_floats f(val.simd); m_value.assign(fmt::format(FMT_STRING("{} {}"), val.x(), val.y()));
m_value.assign(fmt::format(FMT_STRING("{} {}"), f[0], f[1]));
m_flags |= EFlags::Modified; m_flags |= EFlags::Modified;
return true; return true;
} }
bool CVar::fromVec2d(const atVec2d& val) { bool CVar::fromVec2d(const zeus::CVector2d& val) {
if (!safeToModify(EType::Vec2d)) if (!safeToModify(EType::Vec2d))
return false; return false;
athena::simd_doubles f(val.simd); m_value.assign(fmt::format(FMT_STRING("{} {}"), val.x(), val.y()));
m_value.assign(fmt::format(FMT_STRING("{} {}"), f[0], f[1]));
m_flags |= EFlags::Modified; m_flags |= EFlags::Modified;
return true; return true;
} }
bool CVar::fromVec3f(const atVec3f& val) { bool CVar::fromVec3f(const zeus::CVector3f& val) {
if (!safeToModify(EType::Vec3f)) if (!safeToModify(EType::Vec3f))
return false; return false;
athena::simd_floats f(val.simd); m_value.assign(fmt::format(FMT_STRING("{} {} {}"), val.x(), val.y(), val.z()));
m_value.assign(fmt::format(FMT_STRING("{} {} {}"), f[0], f[1], f[2]));
m_flags |= EFlags::Modified; m_flags |= EFlags::Modified;
return true; return true;
} }
bool CVar::fromVec3d(const atVec3d& val) { bool CVar::fromVec3d(const zeus::CVector3d& val) {
if (!safeToModify(EType::Vec3d)) if (!safeToModify(EType::Vec3d))
return false; return false;
athena::simd_doubles f(val.simd); m_value.assign(fmt::format(FMT_STRING("{} {} {}"), val.x(), val.y(), val.z()));
m_value.assign(fmt::format(FMT_STRING("{} {} {}"), f[0], f[1], f[2]));
m_flags |= EFlags::Modified; m_flags |= EFlags::Modified;
return true; return true;
} }
bool CVar::fromVec4f(const atVec4f& val) { bool CVar::fromVec4f(const zeus::CVector4f& val) {
if (!safeToModify(EType::Vec4f)) if (!safeToModify(EType::Vec4f))
return false; return false;
athena::simd_floats f(val.simd); m_value.assign(fmt::format(FMT_STRING("{} {} {} {}"), val.x(), val.y(), val.z(), val.w()));
m_value.assign(fmt::format(FMT_STRING("{} {} {} {}"), f[0], f[1], f[2], f[3]));
m_flags |= EFlags::Modified; m_flags |= EFlags::Modified;
return true; return true;
} }
bool CVar::fromVec4d(const atVec4d& val) { bool CVar::fromVec4d(const zeus::CVector4d& val) {
if (!safeToModify(EType::Vec4d)) if (!safeToModify(EType::Vec4d))
return false; return false;
athena::simd_doubles f(val.simd); m_value.assign(fmt::format(FMT_STRING("{} {} {} {}"), val.x(), val.y(), val.z(), val.w()));
m_value.assign(fmt::format(FMT_STRING("{} {} {} {}"), f[0], f[1], f[2], f[3]));
m_flags |= EFlags::Modified; m_flags |= EFlags::Modified;
return true; return true;
} }

View File

@ -1,16 +1,48 @@
#pragma once #pragma once
#include "Runtime/GCNTypes.hpp"
#include "zeus/zeus.hpp"
#include <functional> #include <functional>
#include <string> #include <string>
#include <vector> #include <vector>
#ifndef ENABLE_BITWISE_ENUM
#define ENABLE_BITWISE_ENUM(type) \
constexpr type operator|(type a, type b) noexcept { \
using T = std::underlying_type_t<type>; \
return type(static_cast<T>(a) | static_cast<T>(b)); \
} \
constexpr type operator&(type a, type b) noexcept { \
using T = std::underlying_type_t<type>; \
return type(static_cast<T>(a) & static_cast<T>(b)); \
} \
constexpr type& operator|=(type& a, type b) noexcept { \
using T = std::underlying_type_t<type>; \
a = type(static_cast<T>(a) | static_cast<T>(b)); \
return a; \
} \
constexpr type& operator&=(type& a, type b) noexcept { \
using T = std::underlying_type_t<type>; \
a = type(static_cast<T>(a) & static_cast<T>(b)); \
return a; \
} \
constexpr type operator~(type key) noexcept { \
using T = std::underlying_type_t<type>; \
return type(~static_cast<T>(key)); \
} \
constexpr bool True(type key) noexcept { \
using T = std::underlying_type_t<type>; \
return static_cast<T>(key) != 0; \
} \
constexpr bool False(type key) noexcept { \
using T = std::underlying_type_t<type>; \
return static_cast<T>(key) == 0; \
}
#endif
#include <athena/DNAYaml.hpp> namespace metaforce {
#include <athena/Global.hpp> namespace StoreCVar {
#include <athena/Types.hpp> enum class EType : uint32_t { Boolean, Signed, Unsigned, Real, Literal, Vec2f, Vec2d, Vec3f, Vec3d, Vec4f, Vec4d };
namespace hecl {
namespace DNACVAR {
enum class EType : atUint8 { Boolean, Signed, Unsigned, Real, Literal, Vec2f, Vec2d, Vec3f, Vec3d, Vec4f, Vec4d };
enum class EFlags { enum class EFlags {
None = 0, None = 0,
System = (1 << 0), System = (1 << 0),
@ -30,41 +62,37 @@ enum class EFlags {
}; };
ENABLE_BITWISE_ENUM(EFlags) ENABLE_BITWISE_ENUM(EFlags)
class CVar : public athena::io::DNA<athena::Endian::Big> { class CVar {
public: public:
AT_DECL_DNA std::string m_name;
String<-1> m_name; std::string m_value;
String<-1> m_value;
}; };
struct CVarContainer : public athena::io::DNA<athena::Endian::Big> { struct CVarContainer {
AT_DECL_DNA u32 magic = 'CVAR';
Value<atUint32> magic = 'CVAR'; std::vector<CVar> cvars;
Value<atUint32> cvarCount;
Vector<CVar, AT_DNA_COUNT(cvarCount)> cvars;
}; };
} // namespace DNACVAR } // namespace StoreCVar
class CVarManager; class CVarManager;
class ICVarValueReference; class ICVarValueReference;
class CVar : protected DNACVAR::CVar { class CVar : protected StoreCVar::CVar {
friend class CVarManager; friend class CVarManager;
Delete _d;
public: public:
typedef std::function<void(CVar*)> ListenerFunc; typedef std::function<void(CVar*)> ListenerFunc;
using EType = DNACVAR::EType; using EType = StoreCVar::EType;
using EFlags = DNACVAR::EFlags; using EFlags = StoreCVar::EFlags;
CVar(std::string_view name, std::string_view value, std::string_view help, EFlags flags); CVar(std::string_view name, std::string_view value, std::string_view help, EFlags flags);
CVar(std::string_view name, const atVec2f& value, std::string_view help, EFlags flags); CVar(std::string_view name, const zeus::CVector2f& value, std::string_view help, EFlags flags);
CVar(std::string_view name, const atVec2d& value, std::string_view help, EFlags flags); CVar(std::string_view name, const zeus::CVector2d& value, std::string_view help, EFlags flags);
CVar(std::string_view name, const atVec3f& value, std::string_view help, EFlags flags); CVar(std::string_view name, const zeus::CVector3f& value, std::string_view help, EFlags flags);
CVar(std::string_view name, const atVec3d& value, std::string_view help, EFlags flags); CVar(std::string_view name, const zeus::CVector3d& value, std::string_view help, EFlags flags);
CVar(std::string_view name, const atVec4f& value, std::string_view help, EFlags flags); CVar(std::string_view name, const zeus::CVector4f& value, std::string_view help, EFlags flags);
CVar(std::string_view name, const atVec4d& value, std::string_view help, EFlags flags); CVar(std::string_view name, const zeus::CVector4d& value, std::string_view help, EFlags flags);
CVar(std::string_view name, double value, std::string_view help, EFlags flags); CVar(std::string_view name, double value, std::string_view help, EFlags flags);
CVar(std::string_view name, bool value, std::string_view help, EFlags flags); CVar(std::string_view name, bool value, std::string_view help, EFlags flags);
CVar(std::string_view name, int32_t value, std::string_view help, EFlags flags); CVar(std::string_view name, int32_t value, std::string_view help, EFlags flags);
@ -78,12 +106,12 @@ public:
template <typename T> template <typename T>
inline bool toValue(T& value) const; inline bool toValue(T& value) const;
atVec2f toVec2f(bool* isValid = nullptr) const; zeus::CVector2f toVec2f(bool* isValid = nullptr) const;
atVec2d toVec2d(bool* isValid = nullptr) const; zeus::CVector2d toVec2d(bool* isValid = nullptr) const;
atVec3f toVec3f(bool* isValid = nullptr) const; zeus::CVector3f toVec3f(bool* isValid = nullptr) const;
atVec3d toVec3d(bool* isValid = nullptr) const; zeus::CVector3d toVec3d(bool* isValid = nullptr) const;
atVec4f toVec4f(bool* isValid = nullptr) const; zeus::CVector4f toVec4f(bool* isValid = nullptr) const;
atVec4d toVec4d(bool* isValid = nullptr) const; zeus::CVector4d toVec4d(bool* isValid = nullptr) const;
double toReal(bool* isValid = nullptr) const; double toReal(bool* isValid = nullptr) const;
bool toBoolean(bool* isValid = nullptr) const; bool toBoolean(bool* isValid = nullptr) const;
int32_t toSigned(bool* isValid = nullptr) const; int32_t toSigned(bool* isValid = nullptr) const;
@ -94,12 +122,12 @@ public:
inline bool fromValue(T value) { inline bool fromValue(T value) {
return false; return false;
} }
bool fromVec2f(const atVec2f& val); bool fromVec2f(const zeus::CVector2f& val);
bool fromVec2d(const atVec2d& val); bool fromVec2d(const zeus::CVector2d& val);
bool fromVec3f(const atVec3f& val); bool fromVec3f(const zeus::CVector3f& val);
bool fromVec3d(const atVec3d& val); bool fromVec3d(const zeus::CVector3d& val);
bool fromVec4f(const atVec4f& val); bool fromVec4f(const zeus::CVector4f& val);
bool fromVec4d(const atVec4d& val); bool fromVec4d(const zeus::CVector4d& val);
bool fromReal(double val); bool fromReal(double val);
bool fromBoolean(bool val); bool fromBoolean(bool val);
bool fromInteger(int32_t val); bool fromInteger(int32_t val);
@ -177,37 +205,37 @@ private:
}; };
template <> template <>
inline bool CVar::toValue(atVec2f& value) const { inline bool CVar::toValue(zeus::CVector2f& value) const {
bool isValid = false; bool isValid = false;
value = toVec2f(&isValid); value = toVec2f(&isValid);
return isValid; return isValid;
} }
template <> template <>
inline bool CVar::toValue(atVec2d& value) const { inline bool CVar::toValue(zeus::CVector2d& value) const {
bool isValid = false; bool isValid = false;
value = toVec2d(&isValid); value = toVec2d(&isValid);
return isValid; return isValid;
} }
template <> template <>
inline bool CVar::toValue(atVec3f& value) const { inline bool CVar::toValue(zeus::CVector3f& value) const {
bool isValid = false; bool isValid = false;
value = toVec3f(&isValid); value = toVec3f(&isValid);
return isValid; return isValid;
} }
template <> template <>
inline bool CVar::toValue(atVec3d& value) const { inline bool CVar::toValue(zeus::CVector3d& value) const {
bool isValid = false; bool isValid = false;
value = toVec3d(&isValid); value = toVec3d(&isValid);
return isValid; return isValid;
} }
template <> template <>
inline bool CVar::toValue(atVec4f& value) const { inline bool CVar::toValue(zeus::CVector4f& value) const {
bool isValid = false; bool isValid = false;
value = toVec4f(&isValid); value = toVec4f(&isValid);
return isValid; return isValid;
} }
template <> template <>
inline bool CVar::toValue(atVec4d& value) const { inline bool CVar::toValue(zeus::CVector4d& value) const {
bool isValid = false; bool isValid = false;
value = toVec4d(&isValid); value = toVec4d(&isValid);
return isValid; return isValid;
@ -250,27 +278,27 @@ inline bool CVar::toValue(std::string& value) const {
} }
template <> template <>
inline bool CVar::fromValue(const atVec2f& val) { inline bool CVar::fromValue(const zeus::CVector2f& val) {
return fromVec2f(val); return fromVec2f(val);
} }
template <> template <>
inline bool CVar::fromValue(const atVec2d& val) { inline bool CVar::fromValue(const zeus::CVector2d& val) {
return fromVec2d(val); return fromVec2d(val);
} }
template <> template <>
inline bool CVar::fromValue(const atVec3f& val) { inline bool CVar::fromValue(const zeus::CVector3f& val) {
return fromVec3f(val); return fromVec3f(val);
} }
template <> template <>
inline bool CVar::fromValue(const atVec3d& val) { inline bool CVar::fromValue(const zeus::CVector3d& val) {
return fromVec3d(val); return fromVec3d(val);
} }
template <> template <>
inline bool CVar::fromValue(const atVec4f& val) { inline bool CVar::fromValue(const zeus::CVector4f& val) {
return fromVec4f(val); return fromVec4f(val);
} }
template <> template <>
inline bool CVar::fromValue(const atVec4d& val) { inline bool CVar::fromValue(const zeus::CVector4d& val) {
return fromVec4d(val); return fromVec4d(val);
} }
template <> template <>
@ -350,4 +378,4 @@ public:
} }
} }
}; };
} // namespace hecl } // namespace metaforce

View File

@ -0,0 +1,78 @@
#include "Runtime/ConsoleVariables/CVarCommons.hpp"
namespace metaforce {
namespace {
CVarCommons* m_instance = nullptr;
}
CVarCommons::CVarCommons(CVarManager& manager) : m_mgr(manager) {
m_fullscreen = m_mgr.findOrMakeCVar("fullscreen"sv, "Start in fullscreen"sv, false,
CVar::EFlags::System | CVar::EFlags::Archive);
m_graphicsApi = m_mgr.findOrMakeCVar("graphicsApi"sv, "API to use for rendering graphics"sv, DEFAULT_GRAPHICS_API,
CVar::EFlags::System | CVar::EFlags::Archive | CVar::EFlags::ModifyRestart);
m_drawSamples = m_mgr.findOrMakeCVar("drawSamples"sv, "Number of MSAA samples to use for render targets"sv, 1,
CVar::EFlags::System | CVar::EFlags::Archive | CVar::EFlags::ModifyRestart);
m_texAnisotropy =
m_mgr.findOrMakeCVar("texAnisotropy"sv, "Number of anisotropic samples to use for sampling textures"sv, 1,
CVar::EFlags::System | CVar::EFlags::Archive | CVar::EFlags::ModifyRestart);
m_deepColor = m_mgr.findOrMakeCVar("deepColor"sv, "Allow framebuffer with color depth greater-then 24-bits"sv, false,
CVar::EFlags::System | CVar::EFlags::Archive | CVar::EFlags::ModifyRestart);
m_variableDt = m_mgr.findOrMakeCVar("variableDt", "Enable variable delta time (experimental)", false,
(CVar::EFlags::System | CVar::EFlags::Archive | CVar::EFlags::ModifyRestart));
m_lazyCommitResources = m_mgr.findOrMakeCVar("lazyCommitResources"sv, "Enable lazy commiting resources to GPU", true,
(CVar::EFlags::System | CVar::EFlags::Archive));
m_debugOverlayPlayerInfo = m_mgr.findOrMakeCVar(
"debugOverlay.playerInfo"sv, "Displays information about the player, such as location and orientation"sv, false,
CVar::EFlags::Game | CVar::EFlags::Archive | CVar::EFlags::ReadOnly);
m_debugOverlayWorldInfo = m_mgr.findOrMakeCVar(
"debugOverlay.worldInfo"sv, "Displays information about the current world, such as world asset ID, and areaId"sv,
false, CVar::EFlags::Game | CVar::EFlags::Archive | CVar::EFlags::ReadOnly);
m_debugOverlayAreaInfo = m_mgr.findOrMakeCVar(
"debugOverlay.areaInfo"sv,
"Displays information about the current area, such as asset ID, object/layer counts, and active layer bits"sv,
false, CVar::EFlags::Game | CVar::EFlags::Archive | CVar::EFlags::ReadOnly);
m_debugOverlayLayerInfo =
m_mgr.findOrMakeCVar("debugOverlay.layerInfo"sv, "Displays information about the currently active area layers"sv,
false, CVar::EFlags::Game | CVar::EFlags::Archive | CVar::EFlags::ReadOnly);
m_debugOverlayShowFrameCounter =
m_mgr.findOrMakeCVar("debugOverlay.showFrameCounter"sv, "Displays the current frame index"sv, false,
CVar::EFlags::Game | CVar::EFlags::Archive | CVar::EFlags::ReadOnly);
m_debugOverlayShowFramerate =
m_mgr.findOrMakeCVar("debugOverlay.showFramerate"sv, "Displays the current framerate"sv, false,
CVar::EFlags::Game | CVar::EFlags::Archive | CVar::EFlags::ReadOnly);
m_debugOverlayShowInGameTime =
m_mgr.findOrMakeCVar("debugOverlay.showInGameTime"sv, "Displays the current in game time"sv, false,
CVar::EFlags::Game | CVar::EFlags::Archive | CVar::EFlags::ReadOnly);
m_debugOverlayShowRoomTimer = m_mgr.findOrMakeCVar(
"debugOverlay.showRoomTimer", "Displays the current/last room timers in seconds and frames"sv, false,
CVar::EFlags::Game | CVar::EFlags::Archive | CVar::EFlags::ReadOnly);
m_debugOverlayShowResourceStats = m_mgr.findOrMakeCVar(
"debugOverlay.showResourceStats"sv, "Displays the current live resource object and token counts"sv, false,
CVar::EFlags::Game | CVar::EFlags::Archive | CVar::EFlags::ReadOnly);
m_debugOverlayShowRandomStats =
m_mgr.findOrMakeCVar("debugOverlay.showRandomStats", "Displays the current number of random calls per frame"sv,
false, CVar::EFlags::Game | CVar::EFlags::Archive | CVar::EFlags::ReadOnly);
m_debugOverlayShowInput = m_mgr.findOrMakeCVar("debugOverlay.showInput"sv, "Displays user input"sv, false,
CVar::EFlags::Game | CVar::EFlags::Archive | CVar::EFlags::ReadOnly);
m_debugToolDrawAiPath =
m_mgr.findOrMakeCVar("debugTool.drawAiPath", "Draws the selected paths of any AI in the room"sv, false,
CVar::EFlags::Game | CVar::EFlags::Archive | CVar::EFlags::ReadOnly);
m_debugToolDrawLighting = m_mgr.findOrMakeCVar("debugTool.drawLighting", "Draws the lighting setup in a room"sv,
false, CVar::EFlags::Game | CVar::EFlags::ReadOnly);
m_debugToolDrawCollisionActors =
m_mgr.findOrMakeCVar("debugTool.drawCollisionActors", "Draws the collision actors for enemies and objects"sv,
false, CVar::EFlags::Game | CVar::EFlags::ReadOnly);
m_debugToolDrawMazePath = m_mgr.findOrMakeCVar("debugTool.drawMazePath", "Draws the maze path in Dynamo"sv, false,
CVar::EFlags::Game | CVar::EFlags::Archive | CVar::EFlags::ReadOnly);
m_debugToolDrawPlatformCollision =
m_mgr.findOrMakeCVar("debugTool.drawPlatformCollision", "Draws the bounding boxes of platforms"sv, false,
CVar::EFlags::Game | CVar::EFlags::Archive | CVar::EFlags::ReadOnly);
m_logFile = m_mgr.findOrMakeCVar("logFile"sv, "Any log prints will be stored to this file upon exit"sv, "app.log"sv,
CVar::EFlags::System | CVar::EFlags::Archive | CVar::EFlags::ModifyRestart);
m_instance = this;
}
CVarCommons* CVarCommons::instance() { return m_instance; }
} // namespace metaforce

View File

@ -4,12 +4,12 @@
#include <cstdint> #include <cstdint>
#include <string> #include <string>
#include "hecl/CVarManager.hpp" #include "Runtime/ConsoleVariables/CVarManager.hpp"
#undef min #undef min
#undef max #undef max
namespace hecl { namespace metaforce {
using namespace std::literals; using namespace std::literals;

View File

@ -1,16 +1,13 @@
#include "hecl/CVarManager.hpp" #include "Runtime/ConsoleVariables/CVarManager.hpp"
#include "Runtime/ConsoleVariables/FileStoreManager.hpp"
#include <logvisor/logvisor.hpp>
#include <algorithm> #include <algorithm>
#include <memory> #include <memory>
#include <regex> #include <regex>
#include "hecl/hecl.hpp" namespace metaforce {
#include "hecl/Runtime.hpp"
#include <athena/FileWriter.hpp>
#include <athena/Utility.hpp>
namespace hecl {
CVar* com_developer = nullptr; CVar* com_developer = nullptr;
CVar* com_configfile = nullptr; CVar* com_configfile = nullptr;
@ -21,7 +18,7 @@ static const std::regex cmdLineRegex(R"(\+([\w\.]+)([=])?([\/\\\s\w\.\-]+)?)");
CVarManager* CVarManager::m_instance = nullptr; CVarManager* CVarManager::m_instance = nullptr;
static logvisor::Module CVarLog("CVarManager"); static logvisor::Module CVarLog("CVarManager");
CVarManager::CVarManager(hecl::Runtime::FileStoreManager& store, bool useBinary) CVarManager::CVarManager(FileStoreManager& store, bool useBinary)
: m_store(store), m_useBinary(useBinary) { : m_store(store), m_useBinary(useBinary) {
m_instance = this; m_instance = this;
com_configfile = com_configfile =
@ -108,16 +105,16 @@ void CVarManager::deserialize(CVar* cvar) {
if (!cvar->isArchive() && !cvar->isInternalArchivable()) { if (!cvar->isArchive() && !cvar->isInternalArchivable()) {
return; return;
} }
#if 0 // TODO: Reimplement this
/* We were either unable to find a deferred value or got an invalid value */ /* We were either unable to find a deferred value or got an invalid value */
std::string filename = std::string filename =
std::string(m_store.getStoreRoot()) + '/' + com_configfile->toLiteral(); std::string(m_store.getStoreRoot()) + '/' + com_configfile->toLiteral();
hecl::Sstat st; CBascis::Sstat st;
if (m_useBinary) { if (m_useBinary) {
CVarContainer container; CVarContainer container;
filename += ".bin"; filename += ".bin";
if (hecl::Stat(filename.c_str(), &st) || !S_ISREG(st.st_mode)) if (CBascis::Stat(filename.c_str(), &st) || !S_ISREG(st.st_mode))
return; return;
athena::io::FileReader reader(filename); athena::io::FileReader reader(filename);
if (reader.isOpen()) if (reader.isOpen())
@ -139,7 +136,7 @@ void CVarManager::deserialize(CVar* cvar) {
} }
} else { } else {
filename += ".yaml"; filename += ".yaml";
if (hecl::Stat(filename.c_str(), &st) || !S_ISREG(st.st_mode)) if (Stat(filename.c_str(), &st) || !S_ISREG(st.st_mode))
return; return;
athena::io::FileReader reader(filename); athena::io::FileReader reader(filename);
if (reader.isOpen()) { if (reader.isOpen()) {
@ -161,9 +158,11 @@ void CVarManager::deserialize(CVar* cvar) {
} }
} }
} }
#endif
} }
void CVarManager::serialize() { void CVarManager::serialize() {
#if 0 // TODO: reimplement this
std::string filename = std::string filename =
std::string(m_store.getStoreRoot()) + '/' + com_configfile->toLiteral(); std::string(m_store.getStoreRoot()) + '/' + com_configfile->toLiteral();
@ -202,6 +201,7 @@ void CVarManager::serialize() {
if (w.isOpen()) if (w.isOpen())
docWriter.finish(&w); docWriter.finish(&w);
} }
#endif
} }
CVarManager* CVarManager::instance() { return m_instance; } CVarManager* CVarManager::instance() { return m_instance; }

View File

@ -5,18 +5,16 @@
#include <unordered_map> #include <unordered_map>
#include <vector> #include <vector>
#include "hecl/CVar.hpp" #include "Runtime/ConsoleVariables/CVar.hpp"
namespace hecl { namespace metaforce {
namespace Runtime {
class FileStoreManager; class FileStoreManager;
}
extern CVar* com_developer; extern CVar* com_developer;
extern CVar* com_configfile; extern CVar* com_configfile;
extern CVar* com_enableCheats; extern CVar* com_enableCheats;
extern CVar* com_cubemaps; extern CVar* com_cubemaps;
class CVarManager final { class CVarManager final {
using CVarContainer = DNACVAR::CVarContainer; using CVarContainer = StoreCVar::CVarContainer;
template <typename T> template <typename T>
CVar* _newCVar(std::string_view name, std::string_view help, const T& value, CVar::EFlags flags) { CVar* _newCVar(std::string_view name, std::string_view help, const T& value, CVar::EFlags flags) {
if (CVar* ret = registerCVar(std::make_unique<CVar>(name, value, help, flags))) { if (CVar* ret = registerCVar(std::make_unique<CVar>(name, value, help, flags))) {
@ -26,7 +24,7 @@ class CVarManager final {
return nullptr; return nullptr;
} }
hecl::Runtime::FileStoreManager& m_store; FileStoreManager& m_store;
bool m_useBinary; bool m_useBinary;
static CVarManager* m_instance; static CVarManager* m_instance;
@ -35,26 +33,26 @@ public:
CVarManager(const CVarManager&) = delete; CVarManager(const CVarManager&) = delete;
CVarManager& operator=(const CVarManager&) = delete; CVarManager& operator=(const CVarManager&) = delete;
CVarManager& operator=(const CVarManager&&) = delete; CVarManager& operator=(const CVarManager&&) = delete;
CVarManager(hecl::Runtime::FileStoreManager& store, bool useBinary = false); CVarManager(FileStoreManager& store, bool useBinary = false);
~CVarManager(); ~CVarManager();
CVar* newCVar(std::string_view name, std::string_view help, const atVec2f& value, CVar::EFlags flags) { CVar* newCVar(std::string_view name, std::string_view help, const zeus::CVector2f& value, CVar::EFlags flags) {
return _newCVar<atVec2f>(name, help, value, flags); return _newCVar<const zeus::CVector2f>(name, help, value, flags);
} }
CVar* newCVar(std::string_view name, std::string_view help, const atVec2d& value, CVar::EFlags flags) { CVar* newCVar(std::string_view name, std::string_view help, const zeus::CVector2d& value, CVar::EFlags flags) {
return _newCVar<atVec2d>(name, help, value, flags); return _newCVar<const zeus::CVector2d>(name, help, value, flags);
} }
CVar* newCVar(std::string_view name, std::string_view help, const atVec3f& value, CVar::EFlags flags) { CVar* newCVar(std::string_view name, std::string_view help, const zeus::CVector3f& value, CVar::EFlags flags) {
return _newCVar<atVec3f>(name, help, value, flags); return _newCVar<const zeus::CVector3f>(name, help, value, flags);
} }
CVar* newCVar(std::string_view name, std::string_view help, const atVec3d& value, CVar::EFlags flags) { CVar* newCVar(std::string_view name, std::string_view help, const zeus::CVector3d& value, CVar::EFlags flags) {
return _newCVar<atVec3d>(name, help, value, flags); return _newCVar<const zeus::CVector3d>(name, help, value, flags);
} }
CVar* newCVar(std::string_view name, std::string_view help, const atVec4f& value, CVar::EFlags flags) { CVar* newCVar(std::string_view name, std::string_view help, const zeus::CVector4f& value, CVar::EFlags flags) {
return _newCVar<atVec4f>(name, help, value, flags); return _newCVar<const zeus::CVector4f>(name, help, value, flags);
} }
CVar* newCVar(std::string_view name, std::string_view help, const atVec4d& value, CVar::EFlags flags) { CVar* newCVar(std::string_view name, std::string_view help, const zeus::CVector4d& value, CVar::EFlags flags) {
return _newCVar<atVec4d>(name, help, value, flags); return _newCVar<const zeus::CVector4d>(name, help, value, flags);
} }
CVar* newCVar(std::string_view name, std::string_view help, std::string_view value, CVar::EFlags flags) { CVar* newCVar(std::string_view name, std::string_view help, std::string_view value, CVar::EFlags flags) {
return _newCVar<std::string_view>(name, help, value, flags); return _newCVar<std::string_view>(name, help, value, flags);

View File

@ -1,8 +1,8 @@
#include "hecl/Runtime.hpp" #include "Runtime/ConsoleVariables/FileStoreManager.hpp"
#include "hecl/hecl.hpp" #include "Runtime/CBasics.hpp"
#include <logvisor/logvisor.hpp> #include "logvisor/logvisor.hpp"
#if _WIN32 #if _WIN32
#include <ShlObj.h> #include <ShlObj.h>
@ -12,7 +12,7 @@
using namespace Windows::Storage; using namespace Windows::Storage;
#endif #endif
namespace hecl::Runtime { namespace metaforce {
static logvisor::Module Log("FileStoreManager"); static logvisor::Module Log("FileStoreManager");
FileStoreManager::FileStoreManager(std::string_view domain) : m_domain(domain) { FileStoreManager::FileStoreManager(std::string_view domain) : m_domain(domain) {
@ -29,11 +29,11 @@ FileStoreManager::FileStoreManager(std::string_view domain) : m_domain(domain) {
#endif #endif
path += "/.heclrun"; path += "/.heclrun";
hecl::MakeDir(path.c_str()); CBasics::MakeDir(path.c_str());
path += '/'; path += '/';
path += domain.data(); path += domain.data();
hecl::MakeDir(path.c_str()); CBasics::MakeDir(path.c_str());
m_storeRoot = path; m_storeRoot = path;
#else #else
const char* xdg_data_home = getenv("XDG_DATA_HOME"); const char* xdg_data_home = getenv("XDG_DATA_HOME");
@ -51,7 +51,7 @@ FileStoreManager::FileStoreManager(std::string_view domain) : m_domain(domain) {
} }
path += "/hecl/"; path += "/hecl/";
path += domain.data(); path += domain.data();
if (RecursiveMakeDir(path.c_str()) != 0) if (CBasics::RecursiveMakeDir(path.c_str()) != 0)
Log.report(logvisor::Fatal, FMT_STRING("unable to mkdir at {}"), path); Log.report(logvisor::Fatal, FMT_STRING("unable to mkdir at {}"), path);
m_storeRoot = path; m_storeRoot = path;
#endif #endif

View File

@ -0,0 +1,22 @@
#pragma once
#include <string>
#include <string_view>
namespace metaforce {
/**
* @brief Per-platform file store resolution
*/
class FileStoreManager {
std::string m_domain;
std::string m_storeRoot;
public:
FileStoreManager(std::string_view domain);
std::string_view getDomain() const { return m_domain; }
/**
* @brief Returns the full path to the file store, including domain
* @return Full path to store e.g /home/foo/.hecl/bar
*/
std::string_view getStoreRoot() const { return m_storeRoot; }
};
}

View File

@ -12,7 +12,7 @@
//#include <boo/graphicsdev/IGraphicsCommandQueue.hpp> //#include <boo/graphicsdev/IGraphicsCommandQueue.hpp>
//#include <boo/graphicsdev/IGraphicsDataFactory.hpp> //#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
#include <hecl/CVar.hpp> #include "ConsoleVariables/CVar.hpp"
#include <hecl/Runtime.hpp> #include <hecl/Runtime.hpp>
#include <zeus/CColor.hpp> #include <zeus/CColor.hpp>
@ -25,7 +25,7 @@
using frame_clock = std::chrono::high_resolution_clock; using frame_clock = std::chrono::high_resolution_clock;
namespace metaforce { namespace metaforce {
extern hecl::CVar* g_disableLighting; extern CVar* g_disableLighting;
class CLight; class CLight;
class CTimeProvider; class CTimeProvider;

View File

@ -12,7 +12,7 @@
#include <array> #include <array>
#include <hecl/CVarManager.hpp> #include "ConsoleVariables/CVarManager.hpp"
#include <hecl/HMDLMeta.hpp> #include <hecl/HMDLMeta.hpp>
#include <logvisor/logvisor.hpp> #include <logvisor/logvisor.hpp>
#include <utility> #include <utility>
@ -554,7 +554,7 @@ static EExtendedShader ResolveExtendedShader(const MaterialSet::Material& data,
/* Ensure cubemap extension shaders fall back to non-cubemap equivalents if necessary */ /* Ensure cubemap extension shaders fall back to non-cubemap equivalents if necessary */
EExtendedShader intermediateExtended = flags.m_extendedShader; EExtendedShader intermediateExtended = flags.m_extendedShader;
if (!hecl::com_cubemaps->toBoolean() || g_Renderer->IsThermalVisorHotPass() || g_Renderer->IsThermalVisorActive()) { if (!com_cubemaps->toBoolean() || g_Renderer->IsThermalVisorHotPass() || g_Renderer->IsThermalVisorActive()) {
if (intermediateExtended == EExtendedShader::LightingCubeReflection) if (intermediateExtended == EExtendedShader::LightingCubeReflection)
intermediateExtended = EExtendedShader::Lighting; intermediateExtended = EExtendedShader::Lighting;
else if (intermediateExtended == EExtendedShader::LightingCubeReflectionWorldShadow) else if (intermediateExtended == EExtendedShader::LightingCubeReflectionWorldShadow)

View File

@ -1,22 +1,30 @@
#pragma once #pragma once
#include "Runtime/RetroTypes.hpp" #include "Runtime/RetroTypes.hpp"
#include "DataSpec/DNACommon/MetaforceVersionInfo.hpp"
#include "Runtime/CMainFlowBase.hpp" #include "Runtime/CMainFlowBase.hpp"
#include "Runtime/ConsoleVariables/FileStoreManager.hpp"
#include <amuse/amuse.hpp> #include <amuse/amuse.hpp>
#include <boo/audiodev/IAudioVoiceEngine.hpp> #include <boo/audiodev/IAudioVoiceEngine.hpp>
#include <boo/boo.hpp> #include <boo/boo.hpp>
#include <hecl/Runtime.hpp>
namespace hecl {
class Console;
class CVarManager;
} // namespace hecl
namespace metaforce { namespace metaforce {
using ERegion = DataSpec::ERegion; class Console;
using EGame = DataSpec::EGame; class CVarManager;
enum class ERegion { Invalid = -1, NTSC_U = 'E', PAL = 'P', NTSC_J = 'J' };
enum class EGame {
Invalid = 0,
MetroidPrime1,
MetroidPrime2,
MetroidPrime3,
};
struct MetaforceVersionInfo {
std::string version;
ERegion region;
EGame game;
bool isTrilogy;
};
class CStopwatch; class CStopwatch;
enum class EGameplayResult { None, Win, Lose, Playing }; enum class EGameplayResult { None, Win, Lose, Playing };
@ -24,7 +32,7 @@ enum class EGameplayResult { None, Win, Lose, Playing };
class IMain { class IMain {
public: public:
virtual ~IMain() = default; virtual ~IMain() = default;
virtual void Init(const hecl::Runtime::FileStoreManager& storeMgr, hecl::CVarManager* cvarMgr, virtual void Init(const FileStoreManager& storeMgr, CVarManager* cvarMgr,
boo::IAudioVoiceEngine* voiceEngine, amuse::IBackendVoiceAllocator& backend) = 0; boo::IAudioVoiceEngine* voiceEngine, amuse::IBackendVoiceAllocator& backend) = 0;
virtual void Draw() = 0; virtual void Draw() = 0;
virtual bool Proc(float dt) = 0; virtual bool Proc(float dt) = 0;

View File

@ -379,14 +379,14 @@ void ImGuiConsole::ShowConsoleVariablesWindow() {
} }
ImGui::SameLine(); ImGui::SameLine();
ImGui::InputText("Filter", &m_cvarFiltersText); ImGui::InputText("Filter", &m_cvarFiltersText);
auto cvars = m_cvarMgr.cvars(hecl::CVar::EFlags::Any & ~hecl::CVar::EFlags::Hidden); auto cvars = m_cvarMgr.cvars(CVar::EFlags::Any & ~CVar::EFlags::Hidden);
if (ImGui::Button("Reset to defaults")) { if (ImGui::Button("Reset to defaults")) {
for (auto* cv : cvars) { for (auto* cv : cvars) {
if (cv->name() == "developer" || cv->name() == "cheats") { if (cv->name() == "developer" || cv->name() == "cheats") {
// don't reset developer or cheats to default // don't reset developer or cheats to default
continue; continue;
} }
hecl::CVarUnlocker l(cv); CVarUnlocker l(cv);
cv->fromLiteralToType(cv->defaultValue()); cv->fromLiteralToType(cv->defaultValue());
} }
} }
@ -405,7 +405,7 @@ void ImGuiConsole::ShowConsoleVariablesWindow() {
bool hasSortSpec = sortSpecs != nullptr && bool hasSortSpec = sortSpecs != nullptr &&
// no multi-sort // no multi-sort
sortSpecs->SpecsCount == 1; sortSpecs->SpecsCount == 1;
std::vector<hecl::CVar*> sortedList; std::vector<CVar*> sortedList;
sortedList.reserve(cvars.size()); sortedList.reserve(cvars.size());
for (auto* cvar : cvars) { for (auto* cvar : cvars) {
@ -422,12 +422,12 @@ void ImGuiConsole::ShowConsoleVariablesWindow() {
if (hasSortSpec) { if (hasSortSpec) {
const auto& spec = sortSpecs->Specs[0]; const auto& spec = sortSpecs->Specs[0];
if (spec.ColumnUserID == 'name') { if (spec.ColumnUserID == 'name') {
std::sort(sortedList.begin(), sortedList.end(), [&](hecl::CVar* a, hecl::CVar* b) { std::sort(sortedList.begin(), sortedList.end(), [&](CVar* a, CVar* b) {
int compare = a->name().compare(b->name()); int compare = a->name().compare(b->name());
return spec.SortDirection == ImGuiSortDirection_Ascending ? compare < 0 : compare > 0; return spec.SortDirection == ImGuiSortDirection_Ascending ? compare < 0 : compare > 0;
}); });
} else if (spec.ColumnUserID == 'val') { } else if (spec.ColumnUserID == 'val') {
std::sort(sortedList.begin(), sortedList.end(), [&](hecl::CVar* a, hecl::CVar* b) { std::sort(sortedList.begin(), sortedList.end(), [&](CVar* a, CVar* b) {
int compare = a->value().compare(b->value()); int compare = a->value().compare(b->value());
return spec.SortDirection == ImGuiSortDirection_Ascending ? compare < 0 : compare > 0; return spec.SortDirection == ImGuiSortDirection_Ascending ? compare < 0 : compare > 0;
}); });
@ -447,35 +447,35 @@ void ImGuiConsole::ShowConsoleVariablesWindow() {
// Value // Value
if (ImGui::TableNextColumn()) { if (ImGui::TableNextColumn()) {
switch (cv->type()) { switch (cv->type()) {
case hecl::CVar::EType::Boolean: { case CVar::EType::Boolean: {
bool b = cv->toBoolean(); bool b = cv->toBoolean();
if (ImGui::Checkbox("", &b)) { if (ImGui::Checkbox("", &b)) {
cv->fromBoolean(b); cv->fromBoolean(b);
} }
break; break;
} }
case hecl::CVar::EType::Real: { case CVar::EType::Real: {
float f = cv->toReal(); float f = cv->toReal();
if (ImGui::DragFloat("", &f)) { if (ImGui::DragFloat("", &f)) {
cv->fromReal(f); cv->fromReal(f);
} }
break; break;
} }
case hecl::CVar::EType::Signed: { case CVar::EType::Signed: {
std::array<s32, 1> i{cv->toSigned()}; std::array<s32, 1> i{cv->toSigned()};
if (ImGui::DragScalar("", ImGuiDataType_S32, i.data(), i.size())) { if (ImGui::DragScalar("", ImGuiDataType_S32, i.data(), i.size())) {
cv->fromInteger(i[0]); cv->fromInteger(i[0]);
} }
break; break;
} }
case hecl::CVar::EType::Unsigned: { case CVar::EType::Unsigned: {
std::array<u32, 1> i{cv->toUnsigned()}; std::array<u32, 1> i{cv->toUnsigned()};
if (ImGui::DragScalar("", ImGuiDataType_U32, i.data(), i.size())) { if (ImGui::DragScalar("", ImGuiDataType_U32, i.data(), i.size())) {
cv->fromInteger(i[0]); cv->fromInteger(i[0]);
} }
break; break;
} }
case hecl::CVar::EType::Literal: { case CVar::EType::Literal: {
char buf[4096]; char buf[4096];
strcpy(buf, cv->value().c_str()); strcpy(buf, cv->value().c_str());
if (ImGui::InputText("", buf, 4096, ImGuiInputTextFlags_EnterReturnsTrue)) { if (ImGui::InputText("", buf, 4096, ImGuiInputTextFlags_EnterReturnsTrue)) {
@ -483,102 +483,102 @@ void ImGuiConsole::ShowConsoleVariablesWindow() {
} }
break; break;
} }
case hecl::CVar::EType::Vec2f: { case CVar::EType::Vec2f: {
auto vec = cv->toVec2f(); auto vec = cv->toVec2f();
std::array<float, 2> scalars = {vec.simd[0], vec.simd[1]}; std::array<float, 2> scalars = {vec.x(), vec.y()};
if (ImGui::DragScalarN("", ImGuiDataType_Float, scalars.data(), scalars.size(), 0.1f)) { if (ImGui::DragScalarN("", ImGuiDataType_Float, scalars.data(), scalars.size(), 0.1f)) {
vec.simd[0] = scalars[0]; vec.x() = scalars[0];
vec.simd[1] = scalars[1]; vec.y() = scalars[1];
cv->fromVec2f(vec); cv->fromVec2f(vec);
} }
break; break;
} }
case hecl::CVar::EType::Vec2d: { case CVar::EType::Vec2d: {
auto vec = cv->toVec2d(); auto vec = cv->toVec2d();
std::array<double, 2> scalars = {vec.simd[0], vec.simd[1]}; std::array<double, 2> scalars = {vec.x(), vec.y()};
if (ImGui::DragScalarN("", ImGuiDataType_Double, scalars.data(), scalars.size(), 0.1f)) { if (ImGui::DragScalarN("", ImGuiDataType_Double, scalars.data(), scalars.size(), 0.1f)) {
vec.simd[0] = scalars[0]; vec.x() = scalars[0];
vec.simd[1] = scalars[1]; vec.y() = scalars[1];
cv->fromVec2d(vec); cv->fromVec2d(vec);
} }
break; break;
} }
case hecl::CVar::EType::Vec3f: { case CVar::EType::Vec3f: {
auto vec = cv->toVec3f(); auto vec = cv->toVec3f();
std::array<float, 3> scalars = {vec.simd[0], vec.simd[1]}; std::array<float, 3> scalars = {vec.x(), vec.y(), vec.z()};
if (cv->isColor()) { if (cv->isColor()) {
if (ImGui::ColorEdit3("", scalars.data())) { if (ImGui::ColorEdit3("", scalars.data())) {
vec.simd[0] = scalars[0]; vec.x() = scalars[0];
vec.simd[1] = scalars[1]; vec.y() = scalars[1];
vec.simd[2] = scalars[2]; vec.z() = scalars[2];
cv->fromVec3f(vec); cv->fromVec3f(vec);
} }
} else if (ImGui::DragScalarN("", ImGuiDataType_Float, scalars.data(), scalars.size(), 0.1f)) { } else if (ImGui::DragScalarN("", ImGuiDataType_Float, scalars.data(), scalars.size(), 0.1f)) {
vec.simd[0] = scalars[0]; vec.x() = scalars[0];
vec.simd[1] = scalars[1]; vec.y() = scalars[1];
vec.simd[2] = scalars[2]; vec.z() = scalars[2];
cv->fromVec3f(vec); cv->fromVec3f(vec);
} }
break; break;
} }
case hecl::CVar::EType::Vec3d: { case CVar::EType::Vec3d: {
auto vec = cv->toVec3d(); auto vec = cv->toVec3d();
std::array<double, 3> scalars = {vec.simd[0], vec.simd[1], vec.simd[2]}; std::array<double, 3> scalars = {vec.x(), vec.y(), vec.z()};
if (cv->isColor()) { if (cv->isColor()) {
std::array<float, 3> color{static_cast<float>(scalars[0]), static_cast<float>(scalars[1]), std::array<float, 3> color{static_cast<float>(scalars[0]), static_cast<float>(scalars[1]),
static_cast<float>(scalars[2])}; static_cast<float>(scalars[2])};
if (ImGui::ColorEdit3("", color.data())) { if (ImGui::ColorEdit3("", color.data())) {
vec.simd[0] = color[0]; vec.x() = scalars[0];
vec.simd[1] = color[1]; vec.y() = scalars[1];
vec.simd[2] = color[2]; vec.z() = scalars[2];
cv->fromVec3d(vec); cv->fromVec3d(vec);
} }
} else if (ImGui::DragScalarN("", ImGuiDataType_Double, scalars.data(), scalars.size(), 0.1f)) { } else if (ImGui::DragScalarN("", ImGuiDataType_Double, scalars.data(), scalars.size(), 0.1f)) {
vec.simd[0] = scalars[0]; vec.x() = scalars[0];
vec.simd[1] = scalars[1]; vec.y() = scalars[1];
vec.simd[2] = scalars[2]; vec.z() = scalars[2];
cv->fromVec3d(vec); cv->fromVec3d(vec);
} }
break; break;
} }
case hecl::CVar::EType::Vec4f: { case CVar::EType::Vec4f: {
auto vec = cv->toVec4f(); auto vec = cv->toVec4f();
std::array<float, 4> scalars = {vec.simd[0], vec.simd[1], vec.simd[2], vec.simd[3]}; std::array<float, 4> scalars = {vec.x(), vec.y(), vec.z(), vec.w()};
if (cv->isColor()) { if (cv->isColor()) {
if (ImGui::ColorEdit4("", scalars.data())) { if (ImGui::ColorEdit4("", scalars.data())) {
vec.simd[0] = scalars[0]; vec.x() = scalars[0];
vec.simd[1] = scalars[1]; vec.y() = scalars[1];
vec.simd[2] = scalars[2]; vec.z() = scalars[2];
vec.simd[3] = scalars[3]; vec.w() = scalars[2];
cv->fromVec4f(vec); cv->fromVec4f(vec);
} }
} else if (ImGui::DragScalarN("", ImGuiDataType_Float, scalars.data(), scalars.size(), 0.1f)) { } else if (ImGui::DragScalarN("", ImGuiDataType_Float, scalars.data(), scalars.size(), 0.1f)) {
vec.simd[0] = scalars[0]; vec.x() = scalars[0];
vec.simd[1] = scalars[1]; vec.y() = scalars[1];
vec.simd[2] = scalars[2]; vec.z() = scalars[2];
vec.simd[3] = scalars[3]; vec.w() = scalars[2];
cv->fromVec4f(vec); cv->fromVec4f(vec);
} }
break; break;
} }
case hecl::CVar::EType::Vec4d: { case CVar::EType::Vec4d: {
auto vec = cv->toVec4d(); auto vec = cv->toVec4d();
std::array<double, 4> scalars = {vec.simd[0], vec.simd[1], vec.simd[2], vec.simd[3]}; std::array<double, 4> scalars = {vec.x(), vec.y(), vec.z(), vec.w()};
if (cv->isColor()) { if (cv->isColor()) {
std::array<float, 4> color{static_cast<float>(scalars[0]), static_cast<float>(scalars[1]), std::array<float, 4> color{static_cast<float>(scalars[0]), static_cast<float>(scalars[1]),
static_cast<float>(scalars[2]), static_cast<float>(scalars[3])}; static_cast<float>(scalars[2]), static_cast<float>(scalars[3])};
if (ImGui::ColorEdit4("", color.data())) { if (ImGui::ColorEdit4("", color.data())) {
vec.simd[0] = color[0]; vec.x() = scalars[0];
vec.simd[1] = color[1]; vec.y() = scalars[1];
vec.simd[2] = color[2]; vec.z() = scalars[2];
vec.simd[3] = color[3]; vec.w() = scalars[2];
cv->fromVec4d(vec); cv->fromVec4d(vec);
} }
} else if (ImGui::DragScalarN("", ImGuiDataType_Double, scalars.data(), scalars.size(), 0.1f)) { } else if (ImGui::DragScalarN("", ImGuiDataType_Double, scalars.data(), scalars.size(), 0.1f)) {
vec.simd[0] = scalars[0]; vec.x() = scalars[0];
vec.simd[1] = scalars[1]; vec.y() = scalars[1];
vec.simd[2] = scalars[2]; vec.z() = scalars[2];
vec.simd[3] = scalars[3]; vec.w() = scalars[2];
cv->fromVec4d(vec); cv->fromVec4d(vec);
} }
break; break;
@ -1156,21 +1156,19 @@ void ImGuiConsole::PreUpdate() {
OPTICK_EVENT(); OPTICK_EVENT();
if (!m_isInitialized) { if (!m_isInitialized) {
m_isInitialized = true; m_isInitialized = true;
m_cvarCommons.m_debugOverlayShowFrameCounter->addListener( m_cvarCommons.m_debugOverlayShowFrameCounter->addListener([this](CVar* c) { m_frameCounter = c->toBoolean(); });
[this](hecl::CVar* c) { m_frameCounter = c->toBoolean(); }); m_cvarCommons.m_debugOverlayShowFramerate->addListener([this](CVar* c) { m_frameRate = c->toBoolean(); });
m_cvarCommons.m_debugOverlayShowFramerate->addListener([this](hecl::CVar* c) { m_frameRate = c->toBoolean(); }); m_cvarCommons.m_debugOverlayShowInGameTime->addListener([this](CVar* c) { m_inGameTime = c->toBoolean(); });
m_cvarCommons.m_debugOverlayShowInGameTime->addListener([this](hecl::CVar* c) { m_inGameTime = c->toBoolean(); }); m_cvarCommons.m_debugOverlayShowRoomTimer->addListener([this](CVar* c) { m_roomTimer = c->toBoolean(); });
m_cvarCommons.m_debugOverlayShowRoomTimer->addListener([this](hecl::CVar* c) { m_roomTimer = c->toBoolean(); }); m_cvarCommons.m_debugOverlayPlayerInfo->addListener([this](CVar* c) { m_playerInfo = c->toBoolean(); });
m_cvarCommons.m_debugOverlayPlayerInfo->addListener([this](hecl::CVar* c) { m_playerInfo = c->toBoolean(); }); m_cvarCommons.m_debugOverlayWorldInfo->addListener([this](CVar* c) { m_worldInfo = c->toBoolean(); });
m_cvarCommons.m_debugOverlayWorldInfo->addListener([this](hecl::CVar* c) { m_worldInfo = c->toBoolean(); }); m_cvarCommons.m_debugOverlayAreaInfo->addListener([this](CVar* c) { m_areaInfo = c->toBoolean(); });
m_cvarCommons.m_debugOverlayAreaInfo->addListener([this](hecl::CVar* c) { m_areaInfo = c->toBoolean(); }); m_cvarCommons.m_debugOverlayLayerInfo->addListener([this](CVar* c) { m_layerInfo = c->toBoolean(); });
m_cvarCommons.m_debugOverlayLayerInfo->addListener([this](hecl::CVar* c) { m_layerInfo = c->toBoolean(); }); m_cvarCommons.m_debugOverlayShowRandomStats->addListener([this](CVar* c) { m_randomStats = c->toBoolean(); });
m_cvarCommons.m_debugOverlayShowRandomStats->addListener([this](hecl::CVar* c) { m_randomStats = c->toBoolean(); }); m_cvarCommons.m_debugOverlayShowResourceStats->addListener([this](CVar* c) { m_resourceStats = c->toBoolean(); });
m_cvarCommons.m_debugOverlayShowResourceStats->addListener( m_cvarCommons.m_debugOverlayShowInput->addListener([this](CVar* c) { m_showInput = c->toBoolean(); });
[this](hecl::CVar* c) { m_resourceStats = c->toBoolean(); }); m_cvarMgr.findCVar("developer")->addListener([this](CVar* c) { m_developer = c->toBoolean(); });
m_cvarCommons.m_debugOverlayShowInput->addListener([this](hecl::CVar* c) { m_showInput = c->toBoolean(); }); m_cvarMgr.findCVar("cheats")->addListener([this](CVar* c) { m_cheats = c->toBoolean(); });
m_cvarMgr.findCVar("developer")->addListener([this](hecl::CVar* c) { m_developer = c->toBoolean(); });
m_cvarMgr.findCVar("cheats")->addListener([this](hecl::CVar* c) { m_cheats = c->toBoolean(); });
} }
// We ned to make sure we have a valid CRandom16 at all times, so lets do that here // We ned to make sure we have a valid CRandom16 at all times, so lets do that here
if (g_StateManager != nullptr && g_StateManager->GetActiveRandom() == nullptr) { if (g_StateManager != nullptr && g_StateManager->GetActiveRandom() == nullptr) {

View File

@ -3,13 +3,13 @@
#include <set> #include <set>
#include <string_view> #include <string_view>
#include "RetroTypes.hpp" #include "Runtime/RetroTypes.hpp"
#include "Runtime/World/CActor.hpp" #include "Runtime/World/CActor.hpp"
#include "Runtime/World/CEntity.hpp" #include "Runtime/World/CEntity.hpp"
#include "Runtime/ImGuiPlayerLoadouts.hpp" #include "Runtime/ImGuiPlayerLoadouts.hpp"
#include "hecl/CVarCommons.hpp" #include "Runtime/ConsoleVariables/CVarCommons.hpp"
#include "hecl/CVarManager.hpp" #include "Runtime/ConsoleVariables/CVarManager.hpp"
#include <zeus/CEulerAngles.hpp> #include <zeus/CEulerAngles.hpp>
@ -39,7 +39,7 @@ public:
static std::array<ImGuiEntityEntry, kMaxEntities> entities; static std::array<ImGuiEntityEntry, kMaxEntities> entities;
static ImGuiPlayerLoadouts loadouts; static ImGuiPlayerLoadouts loadouts;
ImGuiConsole(hecl::CVarManager& cvarMgr, hecl::CVarCommons& cvarCommons) ImGuiConsole(CVarManager& cvarMgr, CVarCommons& cvarCommons)
: m_cvarMgr(cvarMgr), m_cvarCommons(cvarCommons) {} : m_cvarMgr(cvarMgr), m_cvarCommons(cvarCommons) {}
void PreUpdate(); void PreUpdate();
void PostUpdate(); void PostUpdate();
@ -50,8 +50,8 @@ public:
static void EndEntityRow(const ImGuiEntityEntry& entry); static void EndEntityRow(const ImGuiEntityEntry& entry);
private: private:
hecl::CVarManager& m_cvarMgr; CVarManager& m_cvarMgr;
hecl::CVarCommons& m_cvarCommons; CVarCommons& m_cvarCommons;
bool m_showInspectWindow = false; bool m_showInspectWindow = false;
bool m_showDemoWindow = false; bool m_showDemoWindow = false;

View File

@ -25,7 +25,7 @@ namespace metaforce::MP1 {
static logvisor::Module Log("MP1::CTweaks"); static logvisor::Module Log("MP1::CTweaks");
void CTweaks::RegisterTweaks(hecl::CVarManager* cvarMgr) { void CTweaks::RegisterTweaks(CVarManager* cvarMgr) {
std::optional<CMemoryInStream> strm; std::optional<CMemoryInStream> strm;
const SObjectTag* tag; const SObjectTag* tag;
@ -121,7 +121,7 @@ void CTweaks::RegisterTweaks(hecl::CVarManager* cvarMgr) {
g_tweakSlideShow->initCVars(cvarMgr); g_tweakSlideShow->initCVars(cvarMgr);
} }
void CTweaks::RegisterResourceTweaks(hecl::CVarManager* cvarMgr) { void CTweaks::RegisterResourceTweaks(CVarManager* cvarMgr) {
std::optional<CMemoryInStream> strm; std::optional<CMemoryInStream> strm;
const SObjectTag* tag = g_ResFactory->GetResourceIdByName("GunRes"); const SObjectTag* tag = g_ResFactory->GetResourceIdByName("GunRes");

View File

@ -2,18 +2,15 @@
#include "Runtime/RetroTypes.hpp" #include "Runtime/RetroTypes.hpp"
namespace hecl {
class CVarManager;
}
namespace metaforce { namespace metaforce {
class CVarManager;
namespace MP1 { namespace MP1 {
class CTweaks { class CTweaks {
public: public:
void RegisterTweaks(hecl::CVarManager* cvarMgr); void RegisterTweaks(CVarManager* cvarMgr);
void RegisterResourceTweaks(hecl::CVarManager* cvarMgr); void RegisterResourceTweaks(CVarManager* cvarMgr);
}; };
} // namespace MP1 } // namespace MP1

View File

@ -551,11 +551,11 @@ void CMain::HandleDiscordErrored(int errorCode, const char* message) {
DiscordLog.report(logvisor::Error, FMT_STRING("Discord Error: {}"), message); DiscordLog.report(logvisor::Error, FMT_STRING("Discord Error: {}"), message);
} }
void CMain::Init(const hecl::Runtime::FileStoreManager& storeMgr, hecl::CVarManager* cvarMgr, void CMain::Init(const FileStoreManager& storeMgr, CVarManager* cvarMgr,
boo::IAudioVoiceEngine* voiceEngine, amuse::IBackendVoiceAllocator& backend) { boo::IAudioVoiceEngine* voiceEngine, amuse::IBackendVoiceAllocator& backend) {
InitializeDiscord(); InitializeDiscord();
m_cvarMgr = cvarMgr; m_cvarMgr = cvarMgr;
m_cvarCommons = std::make_unique<hecl::CVarCommons>(*m_cvarMgr); m_cvarCommons = std::make_unique<CVarCommons>(*m_cvarMgr);
bool loadedVersion = false; bool loadedVersion = false;
#if 0 #if 0
@ -582,10 +582,10 @@ void CMain::Init(const hecl::Runtime::FileStoreManager& storeMgr, hecl::CVarMana
static_cast<char*>(memmem(buf.get(), readLen, "MetroidBuildInfo", 16)) + 19; static_cast<char*>(memmem(buf.get(), readLen, "MetroidBuildInfo", 16)) + 19;
if (buildInfo != nullptr) { if (buildInfo != nullptr) {
// TODO // TODO
m_version = DataSpec::MetaforceVersionInfo{ m_version = MetaforceVersionInfo{
.version = std::string(buildInfo), .version = std::string(buildInfo),
.region = DataSpec::ERegion::NTSC_U, .region = ERegion::NTSC_U,
.game = DataSpec::EGame::MetroidPrime1, .game = EGame::MetroidPrime1,
.isTrilogy = false, .isTrilogy = false,
}; };
loadedVersion = true; loadedVersion = true;

View File

@ -36,9 +36,9 @@
#include "Runtime/CArchitectureQueue.hpp" #include "Runtime/CArchitectureQueue.hpp"
#include "Runtime/CTimeProvider.hpp" #include "Runtime/CTimeProvider.hpp"
#include "Runtime/GuiSys/CTextExecuteBuffer.hpp" #include "Runtime/GuiSys/CTextExecuteBuffer.hpp"
#include "DataSpec/DNAMP1/Tweaks/CTweakPlayer.hpp" #include "Runtime/MP1/Tweaks/CTweakPlayer.hpp"
#include "DataSpec/DNAMP1/Tweaks/CTweakGame.hpp" #include "Runtime/MP1/Tweaks/CTweakGame.hpp"
#include "hecl/CVarCommons.hpp" #include "Runtime/ConsoleVariables/CVarCommons.hpp"
struct DiscordUser; struct DiscordUser;
@ -243,9 +243,9 @@ private:
std::unique_ptr<CGameArchitectureSupport> x164_archSupport; std::unique_ptr<CGameArchitectureSupport> x164_archSupport;
// boo::IWindow* m_mainWindow = nullptr; // boo::IWindow* m_mainWindow = nullptr;
hecl::CVarManager* m_cvarMgr = nullptr; CVarManager* m_cvarMgr = nullptr;
std::unique_ptr<hecl::CVarCommons> m_cvarCommons; std::unique_ptr<CVarCommons> m_cvarCommons;
// std::unique_ptr<hecl::Console> m_console; // std::unique_ptr<Console> m_console;
// Warmup state // Warmup state
std::vector<SObjectTag> m_warmupTags; std::vector<SObjectTag> m_warmupTags;
std::vector<SObjectTag>::iterator m_warmupIt; std::vector<SObjectTag>::iterator m_warmupIt;
@ -253,7 +253,7 @@ private:
bool m_loadedPersistentResources = false; bool m_loadedPersistentResources = false;
bool m_doQuit = false; bool m_doQuit = false;
bool m_paused = false; bool m_paused = false;
DataSpec::MetaforceVersionInfo m_version; MetaforceVersionInfo m_version;
void InitializeSubsystems(); void InitializeSubsystems();
static void InitializeDiscord(); static void InitializeDiscord();
@ -279,7 +279,7 @@ public:
// int RsMain(int argc, char** argv, boo::IAudioVoiceEngine* voiceEngine, amuse::IBackendVoiceAllocator& // int RsMain(int argc, char** argv, boo::IAudioVoiceEngine* voiceEngine, amuse::IBackendVoiceAllocator&
// backend); // backend);
void Init(const hecl::Runtime::FileStoreManager& storeMgr, hecl::CVarManager* cvarManager, void Init(const FileStoreManager& storeMgr, CVarManager* cvarManager,
boo::IAudioVoiceEngine* voiceEngine, amuse::IBackendVoiceAllocator& backend) override; boo::IAudioVoiceEngine* voiceEngine, amuse::IBackendVoiceAllocator& backend) override;
void WarmupShaders() override; void WarmupShaders() override;
bool Proc(float dt) override; bool Proc(float dt) override;

View File

@ -1,8 +1,8 @@
#include "Runtime/MP1/Tweaks/CTweakAutoMapper.hpp" #include "Runtime/MP1/Tweaks/CTweakAutoMapper.hpp"
#include "Runtime/Streams/IOStreams.hpp" #include "Runtime/Streams/IOStreams.hpp"
#include <hecl/CVar.hpp> #include "Runtime/ConsoleVariables/CVar.hpp"
#include <hecl/CVarManager.hpp> #include "Runtime/ConsoleVariables/CVarManager.hpp"
#define PREFIX(v) std::string_view("tweak.automap." #v) #define PREFIX(v) std::string_view("tweak.automap." #v)
namespace metaforce::MP1 { namespace metaforce::MP1 {
@ -27,26 +27,26 @@ constexpr std::string_view skSelectedVisitedSurfaceColor = PREFIX(SelectedVisite
constexpr std::string_view skSelectedVisitedOutlineColor = PREFIX(SelectedVisitedOutlineColor); constexpr std::string_view skSelectedVisitedOutlineColor = PREFIX(SelectedVisitedOutlineColor);
constexpr std::string_view skMapSurfaceNormalColorLinear = PREFIX(MapSurfaceNormalColorLinear); constexpr std::string_view skMapSurfaceNormalColorLinear = PREFIX(MapSurfaceNormalColorLinear);
constexpr std::string_view skMapSurfaceNormalColorConstant = PREFIX(MapSurfaceNormalColorConstant); constexpr std::string_view skMapSurfaceNormalColorConstant = PREFIX(MapSurfaceNormalColorConstant);
hecl::CVar* tw_showOneMiniMapArea = nullptr; CVar* tw_showOneMiniMapArea = nullptr;
hecl::CVar* tw_scaleMoveSpeedWithCamDist = nullptr; CVar* tw_scaleMoveSpeedWithCamDist = nullptr;
hecl::CVar* tw_camDist = nullptr; CVar* tw_camDist = nullptr;
hecl::CVar* tw_minCamDist = nullptr; CVar* tw_minCamDist = nullptr;
hecl::CVar* tw_maxCamDist = nullptr; CVar* tw_maxCamDist = nullptr;
hecl::CVar* tw_minCamRotX = nullptr; CVar* tw_minCamRotX = nullptr;
hecl::CVar* tw_maxCamRotX = nullptr; CVar* tw_maxCamRotX = nullptr;
hecl::CVar* tw_camAngle = nullptr; CVar* tw_camAngle = nullptr;
hecl::CVar* tw_widgetColor = nullptr; CVar* tw_widgetColor = nullptr;
hecl::CVar* tw_miniCamDist = nullptr; CVar* tw_miniCamDist = nullptr;
hecl::CVar* tw_miniCamXAngle = nullptr; CVar* tw_miniCamXAngle = nullptr;
hecl::CVar* tw_miniCamAngle = nullptr; CVar* tw_miniCamAngle = nullptr;
hecl::CVar* tw_visitedsurfaceColor = nullptr; CVar* tw_visitedsurfaceColor = nullptr;
hecl::CVar* tw_visitedOutlineColor = nullptr; CVar* tw_visitedOutlineColor = nullptr;
hecl::CVar* tw_unvisitedSurfaceColor = nullptr; CVar* tw_unvisitedSurfaceColor = nullptr;
hecl::CVar* tw_unvisitedOutlineColor = nullptr; CVar* tw_unvisitedOutlineColor = nullptr;
hecl::CVar* tw_selectedVisitedSurfaceColor = nullptr; CVar* tw_selectedVisitedSurfaceColor = nullptr;
hecl::CVar* tw_selectedVisitedOutlineColor = nullptr; CVar* tw_selectedVisitedOutlineColor = nullptr;
hecl::CVar* tw_mapSurfaceNormColorLinear = nullptr; CVar* tw_mapSurfaceNormColorLinear = nullptr;
hecl::CVar* tw_mapSurfaceNormColorConstant = nullptr; CVar* tw_mapSurfaceNormColorConstant = nullptr;
} // namespace } // namespace
CTweakAutoMapper::CTweakAutoMapper(CInputStream& in) { CTweakAutoMapper::CTweakAutoMapper(CInputStream& in) {
@ -116,7 +116,7 @@ CTweakAutoMapper::CTweakAutoMapper(CInputStream& in) {
x118_doorBorderColor = in.Get<zeus::CColor>(); x118_doorBorderColor = in.Get<zeus::CColor>();
x11c_openDoorColor = in.Get<zeus::CColor>(); x11c_openDoorColor = in.Get<zeus::CColor>();
} }
void CTweakAutoMapper::_tweakListener(hecl::CVar* cv) { void CTweakAutoMapper::_tweakListener(CVar* cv) {
if (cv == tw_showOneMiniMapArea) { if (cv == tw_showOneMiniMapArea) {
x4_24_showOneMiniMapArea = cv->toBoolean(); x4_24_showOneMiniMapArea = cv->toBoolean();
} else if (cv == tw_scaleMoveSpeedWithCamDist) { } else if (cv == tw_scaleMoveSpeedWithCamDist) {
@ -160,86 +160,84 @@ void CTweakAutoMapper::_tweakListener(hecl::CVar* cv) {
} }
} }
void CTweakAutoMapper::initCVars(hecl::CVarManager* mgr) { void CTweakAutoMapper::initCVars(CVarManager* mgr) {
auto assignBool = [this, mgr](std::string_view name, std::string_view desc, bool& v, hecl::CVar::EFlags flags) { auto assignBool = [this, mgr](std::string_view name, std::string_view desc, bool& v, CVar::EFlags flags) {
hecl::CVar* cv = mgr->findOrMakeCVar(name, desc, v, flags); CVar* cv = mgr->findOrMakeCVar(name, desc, v, flags);
// Check if the CVar was deserialized, this avoid an unnecessary conversion // Check if the CVar was deserialized, this avoid an unnecessary conversion
if (cv->wasDeserialized()) if (cv->wasDeserialized())
v = cv->toBoolean(); v = cv->toBoolean();
cv->addListener([this](hecl::CVar* cv) { _tweakListener(cv); }); cv->addListener([this](CVar* cv) { _tweakListener(cv); });
return cv; return cv;
}; };
auto assignRealValue = [this, mgr](std::string_view name, std::string_view desc, float& v, hecl::CVar::EFlags flags) { auto assignRealValue = [this, mgr](std::string_view name, std::string_view desc, float& v, CVar::EFlags flags) {
hecl::CVar* cv = mgr->findOrMakeCVar(name, desc, v, flags); CVar* cv = mgr->findOrMakeCVar(name, desc, v, flags);
// Check if the CVar was deserialized, this avoid an unnecessary conversion // Check if the CVar was deserialized, this avoid an unnecessary conversion
if (cv->wasDeserialized()) if (cv->wasDeserialized())
v = cv->toReal(); v = cv->toReal();
cv->addListener([this](hecl::CVar* cv) { _tweakListener(cv); }); cv->addListener([this](CVar* cv) { _tweakListener(cv); });
return cv; return cv;
}; };
auto assignColorValue = [this, mgr](std::string_view name, std::string_view desc, zeus::CColor& v, auto assignColorValue = [this, mgr](std::string_view name, std::string_view desc, zeus::CColor& v,
hecl::CVar::EFlags flags) { CVar::EFlags flags) {
atVec4f vec{v.mSimd}; zeus::CVector4f vec = v;
hecl::CVar* cv = mgr->findOrMakeCVar(name, desc, vec, flags | hecl::CVar::EFlags::Color); CVar* cv = mgr->findOrMakeCVar(name, desc, vec, flags | CVar::EFlags::Color);
// Check if the CVar was deserialized, this avoid an unnecessary conversion // Check if the CVar was deserialized, this avoid an unnecessary conversion
if (cv->wasDeserialized()) if (cv->wasDeserialized())
v = zeus::CColor(cv->toVec4f()); v = zeus::CColor(cv->toVec4f());
cv->addListener([this](hecl::CVar* cv) { _tweakListener(cv); }); cv->addListener([this](CVar* cv) { _tweakListener(cv); });
return cv; return cv;
}; };
tw_showOneMiniMapArea = assignBool(skShowOneMiniMapArea, "", x4_24_showOneMiniMapArea, tw_showOneMiniMapArea = assignBool(skShowOneMiniMapArea, "", x4_24_showOneMiniMapArea,
hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Gui | hecl::CVar::EFlags::Archive); CVar::EFlags::Game | CVar::EFlags::Gui | CVar::EFlags::Archive);
tw_scaleMoveSpeedWithCamDist = tw_scaleMoveSpeedWithCamDist = assignBool(skScaleMoveSpeedWithCamDist, "", x4_26_scaleMoveSpeedWithCamDist,
assignBool(skScaleMoveSpeedWithCamDist, "", x4_26_scaleMoveSpeedWithCamDist, CVar::EFlags::Game | CVar::EFlags::Gui | CVar::EFlags::Archive);
hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Gui | hecl::CVar::EFlags::Archive); tw_camDist =
tw_camDist = assignRealValue(skCamDist, "", x8_camDist, assignRealValue(skCamDist, "", x8_camDist, CVar::EFlags::Game | CVar::EFlags::Gui | CVar::EFlags::Archive);
hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Gui | hecl::CVar::EFlags::Archive);
tw_minCamDist = assignRealValue(skMinCameraDist, "", xc_minCamDist, tw_minCamDist = assignRealValue(skMinCameraDist, "", xc_minCamDist,
hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Gui | hecl::CVar::EFlags::Archive); CVar::EFlags::Game | CVar::EFlags::Gui | CVar::EFlags::Archive);
tw_maxCamDist = assignRealValue(skMaxCamDist, "", x10_maxCamDist, tw_maxCamDist =
hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Gui | hecl::CVar::EFlags::Archive); assignRealValue(skMaxCamDist, "", x10_maxCamDist, CVar::EFlags::Game | CVar::EFlags::Gui | CVar::EFlags::Archive);
tw_minCamRotX = assignRealValue(skMinCamRotX, "", x14_minCamRotateX, tw_minCamRotX = assignRealValue(skMinCamRotX, "", x14_minCamRotateX,
hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Gui | hecl::CVar::EFlags::Archive); CVar::EFlags::Game | CVar::EFlags::Gui | CVar::EFlags::Archive);
tw_maxCamRotX = assignRealValue(skMaxCamRotX, "", x18_maxCamRotateX, tw_maxCamRotX = assignRealValue(skMaxCamRotX, "", x18_maxCamRotateX,
hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Gui | hecl::CVar::EFlags::Archive); CVar::EFlags::Game | CVar::EFlags::Gui | CVar::EFlags::Archive);
tw_camAngle = assignRealValue(skCamAngle, "", x1c_camAngle, tw_camAngle =
hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Gui | hecl::CVar::EFlags::Archive); assignRealValue(skCamAngle, "", x1c_camAngle, CVar::EFlags::Game | CVar::EFlags::Gui | CVar::EFlags::Archive);
tw_widgetColor = assignColorValue(skWidgetColor, "", x24_automapperWidgetColor, tw_widgetColor = assignColorValue(skWidgetColor, "", x24_automapperWidgetColor,
hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Gui | hecl::CVar::EFlags::Archive); CVar::EFlags::Game | CVar::EFlags::Gui | CVar::EFlags::Archive);
tw_miniCamDist = assignRealValue(skMiniCamDist, "", x28_miniCamDist, tw_miniCamDist = assignRealValue(skMiniCamDist, "", x28_miniCamDist,
hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Gui | hecl::CVar::EFlags::Archive); CVar::EFlags::Game | CVar::EFlags::Gui | CVar::EFlags::Archive);
tw_miniCamXAngle = assignRealValue(skMiniCamXAngle, "", x2c_miniCamXAngle, tw_miniCamXAngle = assignRealValue(skMiniCamXAngle, "", x2c_miniCamXAngle,
hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Gui | hecl::CVar::EFlags::Archive); CVar::EFlags::Game | CVar::EFlags::Gui | CVar::EFlags::Archive);
tw_miniCamAngle = assignRealValue(skMiniCamAngle, "", x30_miniCamAngle, tw_miniCamAngle = assignRealValue(skMiniCamAngle, "", x30_miniCamAngle,
hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Gui | hecl::CVar::EFlags::Archive); CVar::EFlags::Game | CVar::EFlags::Gui | CVar::EFlags::Archive);
tw_widgetColor = assignColorValue(skWidgetColor, "", x38_automapperWidgetMiniColor, tw_widgetColor = assignColorValue(skWidgetColor, "", x38_automapperWidgetMiniColor,
hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Gui | hecl::CVar::EFlags::Archive); CVar::EFlags::Game | CVar::EFlags::Gui | CVar::EFlags::Archive);
tw_visitedsurfaceColor = assignColorValue(skVisitedSurfaceColor, "", x3c_surfColorVisited, tw_visitedsurfaceColor =
hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Color | assignColorValue(skVisitedSurfaceColor, "", x3c_surfColorVisited,
hecl::CVar::EFlags::Gui | hecl::CVar::EFlags::Archive); CVar::EFlags::Game | CVar::EFlags::Color | CVar::EFlags::Gui | CVar::EFlags::Archive);
tw_visitedOutlineColor = assignColorValue(skVisitedOutlineColor, "", x40_outlineColorVisited, tw_visitedOutlineColor =
hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Color | assignColorValue(skVisitedOutlineColor, "", x40_outlineColorVisited,
hecl::CVar::EFlags::Gui | hecl::CVar::EFlags::Archive); CVar::EFlags::Game | CVar::EFlags::Color | CVar::EFlags::Gui | CVar::EFlags::Archive);
tw_unvisitedSurfaceColor = assignColorValue(skUnvisitedSurfaceColor, "", x44_surfColorUnvisited, tw_unvisitedSurfaceColor =
hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Color | assignColorValue(skUnvisitedSurfaceColor, "", x44_surfColorUnvisited,
hecl::CVar::EFlags::Gui | hecl::CVar::EFlags::Archive); CVar::EFlags::Game | CVar::EFlags::Color | CVar::EFlags::Gui | CVar::EFlags::Archive);
tw_unvisitedOutlineColor = tw_unvisitedOutlineColor = assignColorValue(skUnvisitedOutlineColor, "", x48_outlineColorUnvisited,
assignColorValue(skUnvisitedOutlineColor, "", x48_outlineColorUnvisited, CVar::EFlags::Game | CVar::EFlags::Gui | CVar::EFlags::Archive);
hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Gui | hecl::CVar::EFlags::Archive); tw_selectedVisitedSurfaceColor =
tw_selectedVisitedSurfaceColor = assignColorValue(skSelectedVisitedSurfaceColor, "", x4c_surfaceSelectColorVisited, assignColorValue(skSelectedVisitedSurfaceColor, "", x4c_surfaceSelectColorVisited,
hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Color | CVar::EFlags::Game | CVar::EFlags::Color | CVar::EFlags::Gui | CVar::EFlags::Archive);
hecl::CVar::EFlags::Gui | hecl::CVar::EFlags::Archive); tw_selectedVisitedOutlineColor =
tw_selectedVisitedOutlineColor = assignColorValue(skSelectedVisitedOutlineColor, "", x50_outlineSelectColorVisited, assignColorValue(skSelectedVisitedOutlineColor, "", x50_outlineSelectColorVisited,
hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Color | CVar::EFlags::Game | CVar::EFlags::Color | CVar::EFlags::Gui | CVar::EFlags::Archive);
hecl::CVar::EFlags::Gui | hecl::CVar::EFlags::Archive); tw_mapSurfaceNormColorLinear =
tw_mapSurfaceNormColorLinear = assignRealValue(skMapSurfaceNormalColorLinear, "", x54_mapSurfaceNormColorLinear, assignRealValue(skMapSurfaceNormalColorLinear, "", x54_mapSurfaceNormColorLinear,
hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Color | CVar::EFlags::Game | CVar::EFlags::Color | CVar::EFlags::Gui | CVar::EFlags::Archive);
hecl::CVar::EFlags::Gui | hecl::CVar::EFlags::Archive); tw_mapSurfaceNormColorConstant =
tw_mapSurfaceNormColorConstant = assignRealValue(skMapSurfaceNormalColorConstant, "", x58_mapSurfaceNormColorConstant, assignRealValue(skMapSurfaceNormalColorConstant, "", x58_mapSurfaceNormColorConstant,
hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Color | CVar::EFlags::Game | CVar::EFlags::Color | CVar::EFlags::Gui | CVar::EFlags::Archive);
hecl::CVar::EFlags::Gui | hecl::CVar::EFlags::Archive);
} }
} // namespace metaforce::MP1 } // namespace metaforce::MP1

View File

@ -4,17 +4,13 @@
#include "Runtime/rstl.hpp" #include "Runtime/rstl.hpp"
namespace hecl {
class CVar;
}
namespace metaforce::MP1 { namespace metaforce::MP1 {
struct CTweakAutoMapper final : public Tweaks::ITweakAutoMapper { struct CTweakAutoMapper final : public Tweaks::ITweakAutoMapper {
bool x4_24_showOneMiniMapArea;// : 1; bool x4_24_showOneMiniMapArea; // : 1;
bool x4_25_;// : 1; bool x4_25_; // : 1;
bool x4_26_scaleMoveSpeedWithCamDist;// : 1; bool x4_26_scaleMoveSpeedWithCamDist; // : 1;
float x8_camDist ; float x8_camDist;
float xc_minCamDist ; float xc_minCamDist;
float x10_maxCamDist; float x10_maxCamDist;
float x14_minCamRotateX; float x14_minCamRotateX;
float x18_maxCamRotateX; float x18_maxCamRotateX;
@ -135,9 +131,9 @@ struct CTweakAutoMapper final : public Tweaks::ITweakAutoMapper {
const zeus::CColor& GetAreaFlashPulseColor() const override { return xf4_areaFlashPulseColor; } const zeus::CColor& GetAreaFlashPulseColor() const override { return xf4_areaFlashPulseColor; }
const zeus::CColor& GetDoorColor(int idx) const override { return x100_doorColors[idx]; } const zeus::CColor& GetDoorColor(int idx) const override { return x100_doorColors[idx]; }
const zeus::CColor& GetOpenDoorColor() const override { return x11c_openDoorColor; } const zeus::CColor& GetOpenDoorColor() const override { return x11c_openDoorColor; }
void initCVars(hecl::CVarManager*) override; void initCVars(CVarManager*) override;
private: private:
void _tweakListener(hecl::CVar* cv); void _tweakListener(CVar* cv);
}; };
} // namespace DataSpec::DNAMP1 } // namespace metaforce::MP1

View File

@ -3,19 +3,19 @@
#include "Runtime/Streams/CInputStream.hpp" #include "Runtime/Streams/CInputStream.hpp"
#include <hecl/CVar.hpp> #include "ConsoleVariables/CVar.hpp"
#include <hecl/CVarManager.hpp> #include "ConsoleVariables/CVarManager.hpp"
#define DEFINE_CVAR_GLOBAL(name) \ #define DEFINE_CVAR_GLOBAL(name) \
constexpr std::string_view sk##name = std::string_view("tweak.game." #name); \ constexpr std::string_view sk##name = std::string_view("tweak.game." #name); \
hecl::CVar* tw_##name = nullptr; CVar* tw_##name = nullptr;
#define CREATE_CVAR(name, help, value, flags) \ #define CREATE_CVAR(name, help, value, flags) \
tw_##name = mgr->findOrMakeCVar(sk##name, help, value, flags); \ tw_##name = mgr->findOrMakeCVar(sk##name, help, value, flags); \
if (tw_##name->wasDeserialized()) { \ if (tw_##name->wasDeserialized()) { \
tw_##name->toValue(value); \ tw_##name->toValue(value); \
} \ } \
tw_##name->addListener([this](hecl::CVar* cv) { _tweakListener(cv); }); tw_##name->addListener([this](CVar* cv) { _tweakListener(cv); });
#define CREATE_CVAR_BITFIELD(name, help, value, flags) \ #define CREATE_CVAR_BITFIELD(name, help, value, flags) \
{ \ { \
@ -84,7 +84,7 @@ DEFINE_CVAR_GLOBAL(GravityWaterFogDistanceRange);
DEFINE_CVAR_GLOBAL(HardModeDamageMult); DEFINE_CVAR_GLOBAL(HardModeDamageMult);
DEFINE_CVAR_GLOBAL(HardModeWeaponMult); DEFINE_CVAR_GLOBAL(HardModeWeaponMult);
void CTweakGame::_tweakListener(hecl::CVar* cv) { void CTweakGame::_tweakListener(CVar* cv) {
UPDATE_CVAR(WorldPrefix, cv, x4_worldPrefix); UPDATE_CVAR(WorldPrefix, cv, x4_worldPrefix);
UPDATE_CVAR(FieldOfView, cv, x24_fov); UPDATE_CVAR(FieldOfView, cv, x24_fov);
UPDATE_CVAR(SplashScreensDisabled, cv, x2b_splashScreensDisabled); UPDATE_CVAR(SplashScreensDisabled, cv, x2b_splashScreensDisabled);
@ -104,8 +104,8 @@ void CTweakGame::_tweakListener(hecl::CVar* cv) {
UPDATE_CVAR(HardModeWeaponMult, cv, x64_hardmodeWeaponMult); UPDATE_CVAR(HardModeWeaponMult, cv, x64_hardmodeWeaponMult);
} }
void CTweakGame::initCVars(hecl::CVarManager* mgr) { void CTweakGame::initCVars(CVarManager* mgr) {
constexpr hecl::CVar::EFlags skDefaultFlags = hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Archive; constexpr CVar::EFlags skDefaultFlags = CVar::EFlags::Game | CVar::EFlags::Archive;
CREATE_CVAR(WorldPrefix, "", x4_worldPrefix, skDefaultFlags); CREATE_CVAR(WorldPrefix, "", x4_worldPrefix, skDefaultFlags);
CREATE_CVAR(FieldOfView, "", x24_fov, skDefaultFlags); CREATE_CVAR(FieldOfView, "", x24_fov, skDefaultFlags);
CREATE_CVAR(SplashScreensDisabled, "", x2b_splashScreensDisabled, skDefaultFlags); CREATE_CVAR(SplashScreensDisabled, "", x2b_splashScreensDisabled, skDefaultFlags);

View File

@ -10,7 +10,7 @@ namespace metaforce {
class CInputStream; class CInputStream;
namespace MP1 { namespace MP1 {
#define DEFINE_CVAR_GLOBAL(name) extern hecl::CVar* tw_##name; #define DEFINE_CVAR_GLOBAL(name) extern CVar* tw_##name;
DEFINE_CVAR_GLOBAL(WorldPrefix); DEFINE_CVAR_GLOBAL(WorldPrefix);
DEFINE_CVAR_GLOBAL(FieldOfView); DEFINE_CVAR_GLOBAL(FieldOfView);
@ -77,10 +77,10 @@ struct CTweakGame final : Tweaks::ITweakGame {
CTweakGame() = default; CTweakGame() = default;
CTweakGame(CInputStream& in); CTweakGame(CInputStream& in);
void initCVars(hecl::CVarManager* mgr) override; void initCVars(CVarManager* mgr) override;
private: private:
void _tweakListener(hecl::CVar* cv); void _tweakListener(CVar* cv);
}; };
} // namespace MP1 } // namespace MP1
} // namespace metaforce } // namespace metaforce

View File

@ -4,19 +4,19 @@
#include "zeus/Math.hpp" #include "zeus/Math.hpp"
#include <hecl/CVar.hpp> #include "Runtime/ConsoleVariables/CVar.hpp"
#include <hecl/CVarManager.hpp> #include "Runtime/ConsoleVariables/CVarManager.hpp"
#define DEFINE_CVAR_GLOBAL(name) \ #define DEFINE_CVAR_GLOBAL(name) \
constexpr std::string_view sk##name = std::string_view("tweak.player." #name); \ constexpr std::string_view sk##name = std::string_view("tweak.player." #name); \
hecl::CVar* tw_##name = nullptr; CVar* tw_##name = nullptr;
#define CREATE_CVAR(name, help, value, flags) \ #define CREATE_CVAR(name, help, value, flags) \
tw_##name = mgr->findOrMakeCVar(sk##name, help, value, flags); \ tw_##name = mgr->findOrMakeCVar(sk##name, help, value, flags); \
if (tw_##name->wasDeserialized()) { \ if (tw_##name->wasDeserialized()) { \
tw_##name->toValue(value); \ tw_##name->toValue(value); \
} \ } \
tw_##name->addListener([this](hecl::CVar* cv) { _tweakListener(cv); }); tw_##name->addListener([this](CVar* cv) { _tweakListener(cv); });
#define CREATE_CVAR_BITFIELD(name, help, value, flags) \ #define CREATE_CVAR_BITFIELD(name, help, value, flags) \
{ \ { \
@ -39,8 +39,7 @@
namespace metaforce::MP1 { namespace metaforce::MP1 {
namespace { namespace {
static constexpr hecl::CVar::EFlags skDefaultFlags = static constexpr CVar::EFlags skDefaultFlags = CVar::EFlags::Game | CVar::EFlags::Cheat | CVar::EFlags::Archive;
hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Cheat | hecl::CVar::EFlags::Archive;
DEFINE_CVAR_GLOBAL(MaxTranslationAccelerationNormal); DEFINE_CVAR_GLOBAL(MaxTranslationAccelerationNormal);
DEFINE_CVAR_GLOBAL(MaxTranslationAccelerationAir); DEFINE_CVAR_GLOBAL(MaxTranslationAccelerationAir);
DEFINE_CVAR_GLOBAL(MaxTranslationAccelerationIce); DEFINE_CVAR_GLOBAL(MaxTranslationAccelerationIce);
@ -1169,7 +1168,7 @@ void CTweakPlayer::FixupValues() {
x29c_fallCameraPitchDownAngle = zeus::degToRad(x29c_fallCameraPitchDownAngle); x29c_fallCameraPitchDownAngle = zeus::degToRad(x29c_fallCameraPitchDownAngle);
} }
void CTweakPlayer::_tweakListener(hecl::CVar* cv) { void CTweakPlayer::_tweakListener(CVar* cv) {
UPDATE_CVAR(MaxTranslationAccelerationNormal, cv, x4_maxTranslationalAcceleration[0]); UPDATE_CVAR(MaxTranslationAccelerationNormal, cv, x4_maxTranslationalAcceleration[0]);
UPDATE_CVAR(MaxTranslationAccelerationAir, cv, x4_maxTranslationalAcceleration[1]); UPDATE_CVAR(MaxTranslationAccelerationAir, cv, x4_maxTranslationalAcceleration[1]);
UPDATE_CVAR(MaxTranslationAccelerationIce, cv, x4_maxTranslationalAcceleration[2]); UPDATE_CVAR(MaxTranslationAccelerationIce, cv, x4_maxTranslationalAcceleration[2]);
@ -1386,7 +1385,7 @@ void CTweakPlayer::_tweakListener(hecl::CVar* cv) {
UPDATE_CVAR(PhazonDamageReduction, cv, x308_phazonDamageReduction); UPDATE_CVAR(PhazonDamageReduction, cv, x308_phazonDamageReduction);
} }
void CTweakPlayer::initCVars(hecl::CVarManager* mgr) { void CTweakPlayer::initCVars(CVarManager* mgr) {
CREATE_CVAR(MaxTranslationAccelerationNormal, CREATE_CVAR(MaxTranslationAccelerationNormal,
"Max translation acceleration allowed to the player under normal circumstances", "Max translation acceleration allowed to the player under normal circumstances",
x4_maxTranslationalAcceleration[0], skDefaultFlags); x4_maxTranslationalAcceleration[0], skDefaultFlags);
@ -1664,4 +1663,4 @@ void CTweakPlayer::initCVars(hecl::CVarManager* mgr) {
CREATE_CVAR(GravityDamageReduction, "", x304_gravityDamageReduction, skDefaultFlags); CREATE_CVAR(GravityDamageReduction, "", x304_gravityDamageReduction, skDefaultFlags);
CREATE_CVAR(PhazonDamageReduction, "", x308_phazonDamageReduction, skDefaultFlags); CREATE_CVAR(PhazonDamageReduction, "", x308_phazonDamageReduction, skDefaultFlags);
} }
} // namespace DataSpec::DNAMP1 } // namespace metaforce::MP1

View File

@ -2,10 +2,6 @@
#include "Runtime/Tweaks/ITweakPlayer.hpp" #include "Runtime/Tweaks/ITweakPlayer.hpp"
namespace hecl {
class CVar;
}
namespace metaforce::MP1 { namespace metaforce::MP1 {
struct CTweakPlayer final : Tweaks::ITweakPlayer { struct CTweakPlayer final : Tweaks::ITweakPlayer {
@ -310,8 +306,8 @@ struct CTweakPlayer final : Tweaks::ITweakPlayer {
CTweakPlayer(CInputStream& in); CTweakPlayer(CInputStream& in);
void PutTo(COutputStream& out); void PutTo(COutputStream& out);
void FixupValues(); void FixupValues();
void initCVars(hecl::CVarManager* mgr) override; void initCVars(CVarManager* mgr) override;
void _tweakListener(hecl::CVar* cv); void _tweakListener(CVar* cv);
}; };
} // namespace DataSpec::DNAMP1 } // namespace DataSpec::DNAMP1

View File

@ -1,19 +1,18 @@
#pragma once #pragma once
// Gonna need these in all the tweaks anyway, so we'll include them here // Gonna need these in all the tweaks anyway, so we'll include them here
#include "zeus/zeus.hpp"
#include "Runtime/GCNTypes.hpp" #include "Runtime/GCNTypes.hpp"
namespace hecl { #include "zeus/zeus.hpp"
class CVarManager;
}
namespace metaforce { namespace metaforce {
class CVar;
class CVarManager;
class CInputStream; class CInputStream;
class COutputStream; class COutputStream;
class ITweak { class ITweak {
public: public:
virtual ~ITweak() = default; virtual ~ITweak() = default;
virtual void initCVars(hecl::CVarManager*) {} virtual void initCVars(CVarManager*) {}
}; };
} // namespace metaforce } // namespace metaforce

View File

@ -16,7 +16,7 @@
#include "TCastTo.hpp" // Generated file, do not modify include path #include "TCastTo.hpp" // Generated file, do not modify include path
#include <hecl/CVarManager.hpp> #include "ConsoleVariables/CVarManager.hpp"
namespace metaforce { namespace metaforce {
static CMaterialList MakeActorMaterialList(const CMaterialList& materialList, const CActorParameters& params) { static CMaterialList MakeActorMaterialList(const CMaterialList& materialList, const CActorParameters& params) {

View File

@ -17,13 +17,13 @@
#include "Runtime/World/CScriptSpiderBallWaypoint.hpp" #include "Runtime/World/CScriptSpiderBallWaypoint.hpp"
#include "Runtime/World/CScriptWater.hpp" #include "Runtime/World/CScriptWater.hpp"
#include "Runtime/World/CWorld.hpp" #include "Runtime/World/CWorld.hpp"
#include <hecl/CVar.hpp> #include "Runtime/ConsoleVariables/CVar.hpp"
#include <hecl/CVarManager.hpp> #include "Runtime/ConsoleVariables/CVarManager.hpp"
#include "TCastTo.hpp" // Generated file, do not modify include path #include "TCastTo.hpp" // Generated file, do not modify include path
namespace metaforce { namespace metaforce {
namespace { namespace {
hecl::CVar* mb_spooderBall = nullptr; CVar* mb_spooderBall = nullptr;
bool mb_spooderBallCached = false; bool mb_spooderBallCached = false;
float kSpiderBallCollisionRadius; float kSpiderBallCollisionRadius;
@ -287,11 +287,11 @@ CMorphBall::CMorphBall(CPlayer& player, float radius)
LoadAnimationTokens("SamusBallANCS"); LoadAnimationTokens("SamusBallANCS");
InitializeWakeEffects(); InitializeWakeEffects();
if (mb_spooderBall == nullptr) { if (mb_spooderBall == nullptr) {
mb_spooderBall = hecl::CVarManager::instance()->findOrMakeCVar( mb_spooderBall = CVarManager::instance()->findOrMakeCVar(
"morphball.enableSpooderBall", "morphball.enableSpooderBall",
"Enables the ability to spiderball everywhere after touch a spiderball track with spiderball enabled", false, "Enables the ability to spiderball everywhere after touch a spiderball track with spiderball enabled", false,
hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Cheat); CVar::EFlags::Game | CVar::EFlags::Cheat);
mb_spooderBall->addListener([](hecl::CVar* cv) { mb_spooderBallCached = cv->toBoolean(); }); mb_spooderBall->addListener([](CVar* cv) { mb_spooderBallCached = cv->toBoolean(); });
} }
} }

View File

@ -19,14 +19,14 @@
#include "Runtime/World/CScriptWaypoint.hpp" #include "Runtime/World/CScriptWaypoint.hpp"
#include "Runtime/World/CStateMachine.hpp" #include "Runtime/World/CStateMachine.hpp"
#include <hecl/CVarManager.hpp> #include "Runtime/ConsoleVariables/CVarManager.hpp"
#include "TCastTo.hpp" // Generated file, do not modify include path #include "TCastTo.hpp" // Generated file, do not modify include path
#include <cmath> #include <cmath>
namespace metaforce { namespace metaforce {
namespace { namespace {
hecl::CVar* cv_disableAi = nullptr; CVar* cv_disableAi = nullptr;
} // namespace } // namespace
constexpr CMaterialList skPatternedGroundMaterialList(EMaterialTypes::Character, EMaterialTypes::Solid, constexpr CMaterialList skPatternedGroundMaterialList(EMaterialTypes::Character, EMaterialTypes::Solid,
@ -1830,8 +1830,8 @@ bool CPatterned::ApplyBoneTracking() const {
void CPatterned::Initialize() { void CPatterned::Initialize() {
if (cv_disableAi == nullptr) { if (cv_disableAi == nullptr) {
cv_disableAi = hecl::CVarManager::instance()->findOrMakeCVar("disableAi"sv, "Disables AI state machines", false, cv_disableAi = CVarManager::instance()->findOrMakeCVar("disableAi"sv, "Disables AI state machines", false,
hecl::CVar::EFlags::Cheat | hecl::CVar::EFlags::Game); CVar::EFlags::Cheat | CVar::EFlags::Game);
} }
} }

View File

@ -20,7 +20,7 @@
#include "TCastTo.hpp" // Generated file, do not modify include path #include "TCastTo.hpp" // Generated file, do not modify include path
#include <hecl/CVarManager.hpp> #include "ConsoleVariables/CVarManager.hpp"
namespace metaforce { namespace metaforce {
@ -969,7 +969,7 @@ void CScriptSpecialFunction::ThinkPlayerInArea(float dt, CStateManager& mgr) {
} }
bool CScriptSpecialFunction::ShouldSkipCinematic(CStateManager& stateMgr) const { bool CScriptSpecialFunction::ShouldSkipCinematic(CStateManager& stateMgr) const {
if (hecl::com_developer->toBoolean()) { if (com_developer->toBoolean()) {
return true; return true;
} }
return g_GameState->SystemOptions().GetCinematicState(stateMgr.GetWorld()->IGetWorldAssetId(), GetEditorId()); return g_GameState->SystemOptions().GetCinematicState(stateMgr.GetWorld()->IGetWorldAssetId(), GetEditorId());

View File

@ -3,7 +3,7 @@
#include "Runtime/CStateManager.hpp" #include "Runtime/CStateManager.hpp"
#include "Runtime/World/CAi.hpp" #include "Runtime/World/CAi.hpp"
#include <hecl/CVarManager.hpp> #include "ConsoleVariables/CVarManager.hpp"
namespace metaforce { namespace metaforce {
namespace { namespace {

View File

@ -16,7 +16,7 @@
#include "Runtime/GuiSys/CGuiTextSupport.hpp" #include "Runtime/GuiSys/CGuiTextSupport.hpp"
#include "Runtime/GuiSys/CStringTable.hpp" #include "Runtime/GuiSys/CStringTable.hpp"
#include <hecl/CVarManager.hpp> #include "ConsoleVariables/CVarManager.hpp"
namespace metaforce { namespace metaforce {

View File

@ -7,8 +7,6 @@ macro(hecl_add_list rel_path a_list)
endmacro(hecl_add_list) endmacro(hecl_add_list)
add_subdirectory(Blender) add_subdirectory(Blender)
add_subdirectory(Runtime)
if(WIN32) if(WIN32)
list(APPEND PLAT_SRCS ../include/hecl/winsupport.hpp) list(APPEND PLAT_SRCS ../include/hecl/winsupport.hpp)
endif() endif()
@ -18,10 +16,6 @@ if("${CMAKE_BUILD_TYPE}" STREQUAL "Release" OR "${CMAKE_BUILD_TYPE}" STREQUAL "R
endif() endif()
set(HECL_HEADERS set(HECL_HEADERS
../include/hecl/CVar.hpp
../include/hecl/CVarManager.hpp
# ../include/hecl/Console.hpp
../include/hecl/CVarCommons.hpp
../include/hecl/hecl.hpp ../include/hecl/hecl.hpp
../include/hecl/MultiProgressPrinter.hpp ../include/hecl/MultiProgressPrinter.hpp
../include/hecl/FourCC.hpp ../include/hecl/FourCC.hpp
@ -46,9 +40,6 @@ set(COMMON_SOURCES
Project.cpp Project.cpp
ProjectPath.cpp ProjectPath.cpp
HumanizeNumber.cpp HumanizeNumber.cpp
CVar.cpp
CVarCommons.cpp
CVarManager.cpp
# Console.cpp # Console.cpp
ClientProcess.cpp ClientProcess.cpp
SteamFinder.cpp SteamFinder.cpp
@ -60,7 +51,6 @@ endif()
add_library(hecl-full add_library(hecl-full
${FRONTEND_SOURCES} ${FRONTEND_SOURCES}
${RUNTIME_SOURCES}
${BLENDER_SOURCES} ${BLENDER_SOURCES}
${COMMON_SOURCES} ${COMMON_SOURCES}
${HECL_HEADERS} ${HECL_HEADERS}
@ -70,7 +60,6 @@ target_include_directories(hecl-full PUBLIC ../include)
target_link_libraries(hecl-full PUBLIC ${HECL_APPLICATION_REPS_TARGETS_LIST} target_link_libraries(hecl-full PUBLIC ${HECL_APPLICATION_REPS_TARGETS_LIST}
hecl-blender-addon boo athena-core logvisor xxhash) hecl-blender-addon boo athena-core logvisor xxhash)
target_atdna(hecl-full atdna_HMDLMeta_full.cpp ../include/hecl/HMDLMeta.hpp) target_atdna(hecl-full atdna_HMDLMeta_full.cpp ../include/hecl/HMDLMeta.hpp)
target_atdna(hecl-full atdna_CVar_full.cpp ../include/hecl/CVar.hpp)
target_atdna(hecl-full atdna_SDNARead_full.cpp ../include/hecl/Blender/SDNARead.hpp) target_atdna(hecl-full atdna_SDNARead_full.cpp ../include/hecl/Blender/SDNARead.hpp)
add_library(hecl-light add_library(hecl-light
@ -86,7 +75,6 @@ if (WIN32)
target_link_libraries(hecl-light PUBLIC Version) target_link_libraries(hecl-light PUBLIC Version)
endif () endif ()
target_atdna(hecl-light atdna_HMDLMeta_light.cpp ../include/hecl/HMDLMeta.hpp) target_atdna(hecl-light atdna_HMDLMeta_light.cpp ../include/hecl/HMDLMeta.hpp)
target_atdna(hecl-light atdna_CVar_light.cpp ../include/hecl/CVar.hpp)
if(COMMAND add_sanitizers) if(COMMAND add_sanitizers)
add_sanitizers(hecl-full) add_sanitizers(hecl-full)

View File

@ -1,87 +0,0 @@
#include "hecl/CVarCommons.hpp"
namespace hecl {
namespace {
CVarCommons* m_instance = nullptr;
}
CVarCommons::CVarCommons(CVarManager& manager) : m_mgr(manager) {
m_fullscreen = m_mgr.findOrMakeCVar("fullscreen"sv, "Start in fullscreen"sv, false,
hecl::CVar::EFlags::System | hecl::CVar::EFlags::Archive);
m_graphicsApi = m_mgr.findOrMakeCVar("graphicsApi"sv, "API to use for rendering graphics"sv, DEFAULT_GRAPHICS_API,
hecl::CVar::EFlags::System | hecl::CVar::EFlags::Archive |
hecl::CVar::EFlags::ModifyRestart);
m_drawSamples = m_mgr.findOrMakeCVar("drawSamples"sv, "Number of MSAA samples to use for render targets"sv, 1,
hecl::CVar::EFlags::System | hecl::CVar::EFlags::Archive |
hecl::CVar::EFlags::ModifyRestart);
m_texAnisotropy = m_mgr.findOrMakeCVar(
"texAnisotropy"sv, "Number of anisotropic samples to use for sampling textures"sv, 1,
hecl::CVar::EFlags::System | hecl::CVar::EFlags::Archive | hecl::CVar::EFlags::ModifyRestart);
m_deepColor = m_mgr.findOrMakeCVar("deepColor"sv, "Allow framebuffer with color depth greater-then 24-bits"sv, false,
hecl::CVar::EFlags::System | hecl::CVar::EFlags::Archive |
hecl::CVar::EFlags::ModifyRestart);
m_variableDt = m_mgr.findOrMakeCVar(
"variableDt", "Enable variable delta time (experimental)", false,
(hecl::CVar::EFlags::System | hecl::CVar::EFlags::Archive | hecl::CVar::EFlags::ModifyRestart));
m_lazyCommitResources = m_mgr.findOrMakeCVar(
"lazyCommitResources"sv, "Enable lazy commiting resources to GPU", true,
(hecl::CVar::EFlags::System | hecl::CVar::EFlags::Archive));
m_debugOverlayPlayerInfo = m_mgr.findOrMakeCVar(
"debugOverlay.playerInfo"sv, "Displays information about the player, such as location and orientation"sv, false,
hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Archive | hecl::CVar::EFlags::ReadOnly);
m_debugOverlayWorldInfo = m_mgr.findOrMakeCVar(
"debugOverlay.worldInfo"sv, "Displays information about the current world, such as world asset ID, and areaId"sv,
false, hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Archive | hecl::CVar::EFlags::ReadOnly);
m_debugOverlayAreaInfo = m_mgr.findOrMakeCVar(
"debugOverlay.areaInfo"sv,
"Displays information about the current area, such as asset ID, object/layer counts, and active layer bits"sv,
false, hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Archive | hecl::CVar::EFlags::ReadOnly);
m_debugOverlayLayerInfo = m_mgr.findOrMakeCVar(
"debugOverlay.layerInfo"sv, "Displays information about the currently active area layers"sv, false,
hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Archive | hecl::CVar::EFlags::ReadOnly);
m_debugOverlayShowFrameCounter =
m_mgr.findOrMakeCVar("debugOverlay.showFrameCounter"sv, "Displays the current frame index"sv, false,
hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Archive | hecl::CVar::EFlags::ReadOnly);
m_debugOverlayShowFramerate =
m_mgr.findOrMakeCVar("debugOverlay.showFramerate"sv, "Displays the current framerate"sv, false,
hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Archive | hecl::CVar::EFlags::ReadOnly);
m_debugOverlayShowInGameTime =
m_mgr.findOrMakeCVar("debugOverlay.showInGameTime"sv, "Displays the current in game time"sv, false,
hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Archive | hecl::CVar::EFlags::ReadOnly);
m_debugOverlayShowRoomTimer = m_mgr.findOrMakeCVar(
"debugOverlay.showRoomTimer", "Displays the current/last room timers in seconds and frames"sv, false,
hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Archive | hecl::CVar::EFlags::ReadOnly);
m_debugOverlayShowResourceStats = m_mgr.findOrMakeCVar(
"debugOverlay.showResourceStats"sv, "Displays the current live resource object and token counts"sv, false,
hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Archive | hecl::CVar::EFlags::ReadOnly);
m_debugOverlayShowRandomStats = m_mgr.findOrMakeCVar(
"debugOverlay.showRandomStats", "Displays the current number of random calls per frame"sv, false,
hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Archive | hecl::CVar::EFlags::ReadOnly);
m_debugOverlayShowInput =
m_mgr.findOrMakeCVar("debugOverlay.showInput"sv, "Displays user input"sv, false,
hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Archive | hecl::CVar::EFlags::ReadOnly);
m_debugToolDrawAiPath =
m_mgr.findOrMakeCVar("debugTool.drawAiPath", "Draws the selected paths of any AI in the room"sv, false,
hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Archive | hecl::CVar::EFlags::ReadOnly);
m_debugToolDrawLighting = m_mgr.findOrMakeCVar("debugTool.drawLighting", "Draws the lighting setup in a room"sv,
false, hecl::CVar::EFlags::Game | hecl::CVar::EFlags::ReadOnly);
m_debugToolDrawCollisionActors =
m_mgr.findOrMakeCVar("debugTool.drawCollisionActors", "Draws the collision actors for enemies and objects"sv,
false, hecl::CVar::EFlags::Game | hecl::CVar::EFlags::ReadOnly);
m_debugToolDrawMazePath =
m_mgr.findOrMakeCVar("debugTool.drawMazePath", "Draws the maze path in Dynamo"sv, false,
hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Archive | hecl::CVar::EFlags::ReadOnly);
m_debugToolDrawPlatformCollision =
m_mgr.findOrMakeCVar("debugTool.drawPlatformCollision", "Draws the bounding boxes of platforms"sv, false,
hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Archive | hecl::CVar::EFlags::ReadOnly);
m_logFile = m_mgr.findOrMakeCVar("logFile"sv, "Any log prints will be stored to this file upon exit"sv, "app.log"sv,
hecl::CVar::EFlags::System | hecl::CVar::EFlags::Archive |
hecl::CVar::EFlags::ModifyRestart);
m_instance = this;
}
CVarCommons* CVarCommons::instance() { return m_instance; }
} // namespace hecl

View File

@ -1,4 +0,0 @@
set(RUNTIME_SOURCES
FileStoreManager.cpp)
hecl_add_list(Runtime RUNTIME_SOURCES)

View File

@ -12,7 +12,7 @@
#include "Common.hpp" #include "Common.hpp"
#include "DownloadManager.hpp" #include "DownloadManager.hpp"
#include <hecl/CVarCommons.hpp> #include "ConsoleVariables/CVarCommons.hpp"
#include <hecl/Runtime.hpp> #include <hecl/Runtime.hpp>
class QPushButton; class QPushButton;