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
#include <chrono>
#include <cstdint>
#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"
@ -26,6 +34,12 @@ struct OSCalendarTime {
class CBasics {
public:
#if _WIN32
using Sstat = struct ::_stat64;
#else
using Sstat = struct stat;
#endif
static void Initialize();
static const u64 SECONDS_TO_2000;
@ -48,6 +62,9 @@ public:
static void Swap2Bytes(u8* v);
static void Swap4Bytes(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

View File

@ -1,21 +1,26 @@
#ifndef _WIN32
#include <unistd.h>
#include <sys/time.h>
#include <unistd.h>
#if __APPLE__
#include <mach/mach_time.h>
#endif
#else
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#endif
#include <cstdio>
#include <algorithm>
#include <cstdarg>
#include <cstdio>
#include <cstring>
#include <ctime>
#ifdef WIN32
#include <windows.h>
#ifndef _WIN32_IE
#define _WIN32_IE 0x0400
#endif
#include <shlobj.h>
#endif
#include "Runtime/CBasics.hpp"
#include <logvisor/logvisor.hpp>
#if __APPLE__
static u64 MachToDolphinNum;
@ -25,7 +30,7 @@ static LARGE_INTEGER PerfFrequency;
#endif
namespace metaforce {
static logvisor::Module LogModule("metaforce::CBasics");
void CBasics::Initialize() {
#if __APPLE__
mach_timebase_info_data_t timebase;
@ -195,4 +200,132 @@ void CBasics::Swap8Bytes(u8* v) {
#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

View File

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

View File

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

View File

@ -70,6 +70,10 @@ set(RUNTIME_SOURCES_B
${PARTICLE_SOURCES}
${WORLD_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/ITweakAutoMapper.hpp
Tweaks/ITweakBall.hpp

View File

@ -6,8 +6,8 @@
#include "Runtime/GameGlobalObjects.hpp"
#include "Runtime/Graphics/CTexture.hpp"
#include "Runtime/GuiSys/CStringTable.hpp"
#include <hecl/CVar.hpp>
#include <hecl/CVarManager.hpp>
#include "ConsoleVariables/CVar.hpp"
#include "ConsoleVariables/CVarManager.hpp"
namespace metaforce {
namespace {
@ -16,8 +16,8 @@ using ECardResult = kabufuda::ECardResult;
static std::string g_CardImagePaths[2] = {};
static kabufuda::Card g_CardStates[2] = {kabufuda::Card{"GM8E", "01"}, kabufuda::Card{"GM8E", "01"}};
// static kabufuda::ECardResult g_OpResults[2] = {};
hecl::CVar* mc_dolphinAPath = nullptr;
hecl::CVar* mc_dolphinBPath = nullptr;
CVar* mc_dolphinAPath = nullptr;
CVar* mc_dolphinBPath = nullptr;
} // namespace
CSaveWorldIntermediate::CSaveWorldIntermediate(CAssetId mlvl, CAssetId savw) : x0_mlvlId(mlvl), x8_savwId(savw) {
if (!savw.IsValid())
@ -71,12 +71,12 @@ const CSaveWorldMemory& CMemoryCardSys::GetSaveWorldMemory(CAssetId wldId) const
}
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,
(hecl::CVar::EFlags::Archive | hecl::CVar::EFlags::System | hecl::CVar::EFlags::ModifyRestart));
mc_dolphinBPath = hecl::CVarManager::instance()->findOrMakeCVar(
(CVar::EFlags::Archive | CVar::EFlags::System | CVar::EFlags::ModifyRestart));
mc_dolphinBPath = CVarManager::instance()->findOrMakeCVar(
"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");
xc_memoryWorlds.reserve(16);
x1c_worldInter.emplace();
@ -340,7 +340,7 @@ std::string CMemoryCardSys::_GetDolphinCardPath(kabufuda::ECardSlot 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()) {
g_CardImagePaths[int(slot)] = ResolveDolphinCardPath(slot);
} else if (cv != nullptr) {

View File

@ -69,7 +69,7 @@ class CMemoryCardSys {
public:
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 bool CreateDolphinCard(kabufuda::ECardSlot slot);
static std::string _GetDolphinCardPath(kabufuda::ECardSlot slot);

View File

@ -47,19 +47,19 @@
#include "Runtime/World/CSnakeWeedSwarm.hpp"
#include "Runtime/World/CWallCrawlerSwarm.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>
namespace metaforce {
namespace {
hecl::CVar* debugToolDrawAiPath = nullptr;
hecl::CVar* debugToolDrawLighting = nullptr;
hecl::CVar* debugToolDrawCollisionActors = nullptr;
hecl::CVar* debugToolDrawMazePath = nullptr;
hecl::CVar* debugToolDrawPlatformCollision = nullptr;
hecl::CVar* sm_logScripting = nullptr;
CVar* debugToolDrawAiPath = nullptr;
CVar* debugToolDrawLighting = nullptr;
CVar* debugToolDrawCollisionActors = nullptr;
CVar* debugToolDrawMazePath = nullptr;
CVar* debugToolDrawPlatformCollision = nullptr;
CVar* sm_logScripting = nullptr;
} // namespace
logvisor::Module LogModule("metaforce::CStateManager");
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;
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,
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);
}
@ -545,18 +545,18 @@ void CStateManager::BuildDynamicLightListForWorld() {
}
}
void CStateManager::DrawDebugStuff() const {
if (hecl::com_developer != nullptr && !hecl::com_developer->toBoolean()) {
if (com_developer != nullptr && !com_developer->toBoolean()) {
return;
}
// FIXME: Add proper globals for CVars
if (debugToolDrawAiPath == nullptr || debugToolDrawCollisionActors == nullptr || debugToolDrawLighting == nullptr ||
debugToolDrawMazePath == nullptr || debugToolDrawPlatformCollision == nullptr) {
debugToolDrawAiPath = hecl::CVarManager::instance()->findCVar("debugTool.drawAiPath");
debugToolDrawMazePath = hecl::CVarManager::instance()->findCVar("debugTool.drawMazePath");
debugToolDrawCollisionActors = hecl::CVarManager::instance()->findCVar("debugTool.drawCollisionActors");
debugToolDrawLighting = hecl::CVarManager::instance()->findCVar("debugTool.drawLighting");
debugToolDrawPlatformCollision = hecl::CVarManager::instance()->findCVar("debugTool.drawPlatformCollision");
debugToolDrawAiPath = CVarManager::instance()->findCVar("debugTool.drawAiPath");
debugToolDrawMazePath = CVarManager::instance()->findCVar("debugTool.drawMazePath");
debugToolDrawCollisionActors = CVarManager::instance()->findCVar("debugTool.drawCollisionActors");
debugToolDrawLighting = CVarManager::instance()->findCVar("debugTool.drawLighting");
debugToolDrawPlatformCollision = CVarManager::instance()->findCVar("debugTool.drawPlatformCollision");
return;
}

View File

@ -217,7 +217,7 @@ private:
std::map<TEditorId, std::set<SConnection>> m_incomingConnections;
bool m_logScripting = false;
std::optional<hecl::CVarValueReference<bool>> m_logScriptingReference;
std::optional<CVarValueReference<bool>> m_logScriptingReference;
void UpdateThermalVisor();
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)
, x188_orbitCameraSpeed(orbitCameraSpeed)
, 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); }
@ -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();
x170_24_perspDirty = true;
}

View File

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

View File

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

View File

@ -1,16 +1,48 @@
#pragma once
#include "Runtime/GCNTypes.hpp"
#include "zeus/zeus.hpp"
#include <functional>
#include <string>
#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>
#include <athena/Global.hpp>
#include <athena/Types.hpp>
namespace hecl {
namespace DNACVAR {
enum class EType : atUint8 { Boolean, Signed, Unsigned, Real, Literal, Vec2f, Vec2d, Vec3f, Vec3d, Vec4f, Vec4d };
namespace metaforce {
namespace StoreCVar {
enum class EType : uint32_t { Boolean, Signed, Unsigned, Real, Literal, Vec2f, Vec2d, Vec3f, Vec3d, Vec4f, Vec4d };
enum class EFlags {
None = 0,
System = (1 << 0),
@ -30,41 +62,37 @@ enum class EFlags {
};
ENABLE_BITWISE_ENUM(EFlags)
class CVar : public athena::io::DNA<athena::Endian::Big> {
class CVar {
public:
AT_DECL_DNA
String<-1> m_name;
String<-1> m_value;
std::string m_name;
std::string m_value;
};
struct CVarContainer : public athena::io::DNA<athena::Endian::Big> {
AT_DECL_DNA
Value<atUint32> magic = 'CVAR';
Value<atUint32> cvarCount;
Vector<CVar, AT_DNA_COUNT(cvarCount)> cvars;
struct CVarContainer {
u32 magic = 'CVAR';
std::vector<CVar> cvars;
};
} // namespace DNACVAR
} // namespace StoreCVar
class CVarManager;
class ICVarValueReference;
class CVar : protected DNACVAR::CVar {
class CVar : protected StoreCVar::CVar {
friend class CVarManager;
Delete _d;
public:
typedef std::function<void(CVar*)> ListenerFunc;
using EType = DNACVAR::EType;
using EFlags = DNACVAR::EFlags;
using EType = StoreCVar::EType;
using EFlags = StoreCVar::EFlags;
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 atVec2d& 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 atVec3d& 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 atVec4d& 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 zeus::CVector2d& 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 zeus::CVector3d& 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 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, bool 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>
inline bool toValue(T& value) const;
atVec2f toVec2f(bool* isValid = nullptr) const;
atVec2d toVec2d(bool* isValid = nullptr) const;
atVec3f toVec3f(bool* isValid = nullptr) const;
atVec3d toVec3d(bool* isValid = nullptr) const;
atVec4f toVec4f(bool* isValid = nullptr) const;
atVec4d toVec4d(bool* isValid = nullptr) const;
zeus::CVector2f toVec2f(bool* isValid = nullptr) const;
zeus::CVector2d toVec2d(bool* isValid = nullptr) const;
zeus::CVector3f toVec3f(bool* isValid = nullptr) const;
zeus::CVector3d toVec3d(bool* isValid = nullptr) const;
zeus::CVector4f toVec4f(bool* isValid = nullptr) const;
zeus::CVector4d toVec4d(bool* isValid = nullptr) const;
double toReal(bool* isValid = nullptr) const;
bool toBoolean(bool* isValid = nullptr) const;
int32_t toSigned(bool* isValid = nullptr) const;
@ -94,12 +122,12 @@ public:
inline bool fromValue(T value) {
return false;
}
bool fromVec2f(const atVec2f& val);
bool fromVec2d(const atVec2d& val);
bool fromVec3f(const atVec3f& val);
bool fromVec3d(const atVec3d& val);
bool fromVec4f(const atVec4f& val);
bool fromVec4d(const atVec4d& val);
bool fromVec2f(const zeus::CVector2f& val);
bool fromVec2d(const zeus::CVector2d& val);
bool fromVec3f(const zeus::CVector3f& val);
bool fromVec3d(const zeus::CVector3d& val);
bool fromVec4f(const zeus::CVector4f& val);
bool fromVec4d(const zeus::CVector4d& val);
bool fromReal(double val);
bool fromBoolean(bool val);
bool fromInteger(int32_t val);
@ -177,37 +205,37 @@ private:
};
template <>
inline bool CVar::toValue(atVec2f& value) const {
inline bool CVar::toValue(zeus::CVector2f& value) const {
bool isValid = false;
value = toVec2f(&isValid);
return isValid;
}
template <>
inline bool CVar::toValue(atVec2d& value) const {
inline bool CVar::toValue(zeus::CVector2d& value) const {
bool isValid = false;
value = toVec2d(&isValid);
return isValid;
}
template <>
inline bool CVar::toValue(atVec3f& value) const {
inline bool CVar::toValue(zeus::CVector3f& value) const {
bool isValid = false;
value = toVec3f(&isValid);
return isValid;
}
template <>
inline bool CVar::toValue(atVec3d& value) const {
inline bool CVar::toValue(zeus::CVector3d& value) const {
bool isValid = false;
value = toVec3d(&isValid);
return isValid;
}
template <>
inline bool CVar::toValue(atVec4f& value) const {
inline bool CVar::toValue(zeus::CVector4f& value) const {
bool isValid = false;
value = toVec4f(&isValid);
return isValid;
}
template <>
inline bool CVar::toValue(atVec4d& value) const {
inline bool CVar::toValue(zeus::CVector4d& value) const {
bool isValid = false;
value = toVec4d(&isValid);
return isValid;
@ -250,27 +278,27 @@ inline bool CVar::toValue(std::string& value) const {
}
template <>
inline bool CVar::fromValue(const atVec2f& val) {
inline bool CVar::fromValue(const zeus::CVector2f& val) {
return fromVec2f(val);
}
template <>
inline bool CVar::fromValue(const atVec2d& val) {
inline bool CVar::fromValue(const zeus::CVector2d& val) {
return fromVec2d(val);
}
template <>
inline bool CVar::fromValue(const atVec3f& val) {
inline bool CVar::fromValue(const zeus::CVector3f& val) {
return fromVec3f(val);
}
template <>
inline bool CVar::fromValue(const atVec3d& val) {
inline bool CVar::fromValue(const zeus::CVector3d& val) {
return fromVec3d(val);
}
template <>
inline bool CVar::fromValue(const atVec4f& val) {
inline bool CVar::fromValue(const zeus::CVector4f& val) {
return fromVec4f(val);
}
template <>
inline bool CVar::fromValue(const atVec4d& val) {
inline bool CVar::fromValue(const zeus::CVector4d& val) {
return fromVec4d(val);
}
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 <string>
#include "hecl/CVarManager.hpp"
#include "Runtime/ConsoleVariables/CVarManager.hpp"
#undef min
#undef max
namespace hecl {
namespace metaforce {
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 <memory>
#include <regex>
#include "hecl/hecl.hpp"
#include "hecl/Runtime.hpp"
#include <athena/FileWriter.hpp>
#include <athena/Utility.hpp>
namespace hecl {
namespace metaforce {
CVar* com_developer = nullptr;
CVar* com_configfile = nullptr;
@ -21,7 +18,7 @@ static const std::regex cmdLineRegex(R"(\+([\w\.]+)([=])?([\/\\\s\w\.\-]+)?)");
CVarManager* CVarManager::m_instance = nullptr;
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_instance = this;
com_configfile =
@ -108,16 +105,16 @@ void CVarManager::deserialize(CVar* cvar) {
if (!cvar->isArchive() && !cvar->isInternalArchivable()) {
return;
}
#if 0 // TODO: Reimplement this
/* We were either unable to find a deferred value or got an invalid value */
std::string filename =
std::string(m_store.getStoreRoot()) + '/' + com_configfile->toLiteral();
hecl::Sstat st;
CBascis::Sstat st;
if (m_useBinary) {
CVarContainer container;
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;
athena::io::FileReader reader(filename);
if (reader.isOpen())
@ -139,7 +136,7 @@ void CVarManager::deserialize(CVar* cvar) {
}
} else {
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;
athena::io::FileReader reader(filename);
if (reader.isOpen()) {
@ -161,9 +158,11 @@ void CVarManager::deserialize(CVar* cvar) {
}
}
}
#endif
}
void CVarManager::serialize() {
#if 0 // TODO: reimplement this
std::string filename =
std::string(m_store.getStoreRoot()) + '/' + com_configfile->toLiteral();
@ -202,6 +201,7 @@ void CVarManager::serialize() {
if (w.isOpen())
docWriter.finish(&w);
}
#endif
}
CVarManager* CVarManager::instance() { return m_instance; }

View File

@ -5,18 +5,16 @@
#include <unordered_map>
#include <vector>
#include "hecl/CVar.hpp"
#include "Runtime/ConsoleVariables/CVar.hpp"
namespace hecl {
namespace Runtime {
namespace metaforce {
class FileStoreManager;
}
extern CVar* com_developer;
extern CVar* com_configfile;
extern CVar* com_enableCheats;
extern CVar* com_cubemaps;
class CVarManager final {
using CVarContainer = DNACVAR::CVarContainer;
using CVarContainer = StoreCVar::CVarContainer;
template <typename T>
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))) {
@ -26,7 +24,7 @@ class CVarManager final {
return nullptr;
}
hecl::Runtime::FileStoreManager& m_store;
FileStoreManager& m_store;
bool m_useBinary;
static CVarManager* m_instance;
@ -35,26 +33,26 @@ public:
CVarManager(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();
CVar* newCVar(std::string_view name, std::string_view help, const atVec2f& value, CVar::EFlags flags) {
return _newCVar<atVec2f>(name, help, value, flags);
CVar* newCVar(std::string_view name, std::string_view help, const zeus::CVector2f& value, CVar::EFlags 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) {
return _newCVar<atVec2d>(name, help, value, flags);
CVar* newCVar(std::string_view name, std::string_view help, const zeus::CVector2d& value, CVar::EFlags 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) {
return _newCVar<atVec3f>(name, help, value, flags);
CVar* newCVar(std::string_view name, std::string_view help, const zeus::CVector3f& value, CVar::EFlags 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) {
return _newCVar<atVec3d>(name, help, value, flags);
CVar* newCVar(std::string_view name, std::string_view help, const zeus::CVector3d& value, CVar::EFlags 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) {
return _newCVar<atVec4f>(name, help, value, flags);
CVar* newCVar(std::string_view name, std::string_view help, const zeus::CVector4f& value, CVar::EFlags 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) {
return _newCVar<atVec4d>(name, help, value, flags);
CVar* newCVar(std::string_view name, std::string_view help, const zeus::CVector4d& value, CVar::EFlags 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) {
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
#include <ShlObj.h>
@ -12,7 +12,7 @@
using namespace Windows::Storage;
#endif
namespace hecl::Runtime {
namespace metaforce {
static logvisor::Module Log("FileStoreManager");
FileStoreManager::FileStoreManager(std::string_view domain) : m_domain(domain) {
@ -29,11 +29,11 @@ FileStoreManager::FileStoreManager(std::string_view domain) : m_domain(domain) {
#endif
path += "/.heclrun";
hecl::MakeDir(path.c_str());
CBasics::MakeDir(path.c_str());
path += '/';
path += domain.data();
hecl::MakeDir(path.c_str());
CBasics::MakeDir(path.c_str());
m_storeRoot = path;
#else
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 += 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);
m_storeRoot = path;
#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/IGraphicsDataFactory.hpp>
#include <hecl/CVar.hpp>
#include "ConsoleVariables/CVar.hpp"
#include <hecl/Runtime.hpp>
#include <zeus/CColor.hpp>
@ -25,7 +25,7 @@
using frame_clock = std::chrono::high_resolution_clock;
namespace metaforce {
extern hecl::CVar* g_disableLighting;
extern CVar* g_disableLighting;
class CLight;
class CTimeProvider;

View File

@ -12,7 +12,7 @@
#include <array>
#include <hecl/CVarManager.hpp>
#include "ConsoleVariables/CVarManager.hpp"
#include <hecl/HMDLMeta.hpp>
#include <logvisor/logvisor.hpp>
#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 */
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)
intermediateExtended = EExtendedShader::Lighting;
else if (intermediateExtended == EExtendedShader::LightingCubeReflectionWorldShadow)

View File

@ -1,22 +1,30 @@
#pragma once
#include "Runtime/RetroTypes.hpp"
#include "DataSpec/DNACommon/MetaforceVersionInfo.hpp"
#include "Runtime/CMainFlowBase.hpp"
#include "Runtime/ConsoleVariables/FileStoreManager.hpp"
#include <amuse/amuse.hpp>
#include <boo/audiodev/IAudioVoiceEngine.hpp>
#include <boo/boo.hpp>
#include <hecl/Runtime.hpp>
namespace hecl {
class Console;
class CVarManager;
} // namespace hecl
namespace metaforce {
using ERegion = DataSpec::ERegion;
using EGame = DataSpec::EGame;
class Console;
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;
enum class EGameplayResult { None, Win, Lose, Playing };
@ -24,7 +32,7 @@ enum class EGameplayResult { None, Win, Lose, Playing };
class IMain {
public:
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;
virtual void Draw() = 0;
virtual bool Proc(float dt) = 0;

View File

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

View File

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

View File

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

View File

@ -2,18 +2,15 @@
#include "Runtime/RetroTypes.hpp"
namespace hecl {
class CVarManager;
}
namespace metaforce {
class CVarManager;
namespace MP1 {
class CTweaks {
public:
void RegisterTweaks(hecl::CVarManager* cvarMgr);
void RegisterResourceTweaks(hecl::CVarManager* cvarMgr);
void RegisterTweaks(CVarManager* cvarMgr);
void RegisterResourceTweaks(CVarManager* cvarMgr);
};
} // 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);
}
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) {
InitializeDiscord();
m_cvarMgr = cvarMgr;
m_cvarCommons = std::make_unique<hecl::CVarCommons>(*m_cvarMgr);
m_cvarCommons = std::make_unique<CVarCommons>(*m_cvarMgr);
bool loadedVersion = false;
#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;
if (buildInfo != nullptr) {
// TODO
m_version = DataSpec::MetaforceVersionInfo{
m_version = MetaforceVersionInfo{
.version = std::string(buildInfo),
.region = DataSpec::ERegion::NTSC_U,
.game = DataSpec::EGame::MetroidPrime1,
.region = ERegion::NTSC_U,
.game = EGame::MetroidPrime1,
.isTrilogy = false,
};
loadedVersion = true;

View File

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

View File

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

View File

@ -4,10 +4,6 @@
#include "Runtime/rstl.hpp"
namespace hecl {
class CVar;
}
namespace metaforce::MP1 {
struct CTweakAutoMapper final : public Tweaks::ITweakAutoMapper {
bool x4_24_showOneMiniMapArea; // : 1;
@ -135,9 +131,9 @@ struct CTweakAutoMapper final : public Tweaks::ITweakAutoMapper {
const zeus::CColor& GetAreaFlashPulseColor() const override { return xf4_areaFlashPulseColor; }
const zeus::CColor& GetDoorColor(int idx) const override { return x100_doorColors[idx]; }
const zeus::CColor& GetOpenDoorColor() const override { return x11c_openDoorColor; }
void initCVars(hecl::CVarManager*) override;
void initCVars(CVarManager*) override;
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 <hecl/CVar.hpp>
#include <hecl/CVarManager.hpp>
#include "ConsoleVariables/CVar.hpp"
#include "ConsoleVariables/CVarManager.hpp"
#define DEFINE_CVAR_GLOBAL(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) \
tw_##name = mgr->findOrMakeCVar(sk##name, help, value, flags); \
if (tw_##name->wasDeserialized()) { \
tw_##name->toValue(value); \
} \
tw_##name->addListener([this](hecl::CVar* cv) { _tweakListener(cv); });
tw_##name->addListener([this](CVar* cv) { _tweakListener(cv); });
#define CREATE_CVAR_BITFIELD(name, help, value, flags) \
{ \
@ -84,7 +84,7 @@ DEFINE_CVAR_GLOBAL(GravityWaterFogDistanceRange);
DEFINE_CVAR_GLOBAL(HardModeDamageMult);
DEFINE_CVAR_GLOBAL(HardModeWeaponMult);
void CTweakGame::_tweakListener(hecl::CVar* cv) {
void CTweakGame::_tweakListener(CVar* cv) {
UPDATE_CVAR(WorldPrefix, cv, x4_worldPrefix);
UPDATE_CVAR(FieldOfView, cv, x24_fov);
UPDATE_CVAR(SplashScreensDisabled, cv, x2b_splashScreensDisabled);
@ -104,8 +104,8 @@ void CTweakGame::_tweakListener(hecl::CVar* cv) {
UPDATE_CVAR(HardModeWeaponMult, cv, x64_hardmodeWeaponMult);
}
void CTweakGame::initCVars(hecl::CVarManager* mgr) {
constexpr hecl::CVar::EFlags skDefaultFlags = hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Archive;
void CTweakGame::initCVars(CVarManager* mgr) {
constexpr CVar::EFlags skDefaultFlags = CVar::EFlags::Game | CVar::EFlags::Archive;
CREATE_CVAR(WorldPrefix, "", x4_worldPrefix, skDefaultFlags);
CREATE_CVAR(FieldOfView, "", x24_fov, skDefaultFlags);
CREATE_CVAR(SplashScreensDisabled, "", x2b_splashScreensDisabled, skDefaultFlags);

View File

@ -10,7 +10,7 @@ namespace metaforce {
class CInputStream;
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(FieldOfView);
@ -77,10 +77,10 @@ struct CTweakGame final : Tweaks::ITweakGame {
CTweakGame() = default;
CTweakGame(CInputStream& in);
void initCVars(hecl::CVarManager* mgr) override;
void initCVars(CVarManager* mgr) override;
private:
void _tweakListener(hecl::CVar* cv);
void _tweakListener(CVar* cv);
};
} // namespace MP1
} // namespace metaforce

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -7,8 +7,6 @@ macro(hecl_add_list rel_path a_list)
endmacro(hecl_add_list)
add_subdirectory(Blender)
add_subdirectory(Runtime)
if(WIN32)
list(APPEND PLAT_SRCS ../include/hecl/winsupport.hpp)
endif()
@ -18,10 +16,6 @@ if("${CMAKE_BUILD_TYPE}" STREQUAL "Release" OR "${CMAKE_BUILD_TYPE}" STREQUAL "R
endif()
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/MultiProgressPrinter.hpp
../include/hecl/FourCC.hpp
@ -46,9 +40,6 @@ set(COMMON_SOURCES
Project.cpp
ProjectPath.cpp
HumanizeNumber.cpp
CVar.cpp
CVarCommons.cpp
CVarManager.cpp
# Console.cpp
ClientProcess.cpp
SteamFinder.cpp
@ -60,7 +51,6 @@ endif()
add_library(hecl-full
${FRONTEND_SOURCES}
${RUNTIME_SOURCES}
${BLENDER_SOURCES}
${COMMON_SOURCES}
${HECL_HEADERS}
@ -70,7 +60,6 @@ target_include_directories(hecl-full PUBLIC ../include)
target_link_libraries(hecl-full PUBLIC ${HECL_APPLICATION_REPS_TARGETS_LIST}
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_CVar_full.cpp ../include/hecl/CVar.hpp)
target_atdna(hecl-full atdna_SDNARead_full.cpp ../include/hecl/Blender/SDNARead.hpp)
add_library(hecl-light
@ -86,7 +75,6 @@ if (WIN32)
target_link_libraries(hecl-light PUBLIC Version)
endif ()
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)
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 "DownloadManager.hpp"
#include <hecl/CVarCommons.hpp>
#include "ConsoleVariables/CVarCommons.hpp"
#include <hecl/Runtime.hpp>
class QPushButton;