Move Editor cvars to CVarCommons

This commit is contained in:
Luke Street 2020-04-14 15:20:00 -04:00
parent aba42eba52
commit 89a1cedba1
3 changed files with 32 additions and 14 deletions

View File

@ -27,6 +27,14 @@ struct CVarCommons {
CVar* m_drawSamples = nullptr;
CVar* m_texAnisotropy = nullptr;
CVar* m_deepColor = nullptr;
CVar* m_variableDt = nullptr;
CVar* m_debugOverlayPlayerInfo = nullptr;
CVar* m_debugOverlayWorldInfo = nullptr;
CVar* m_debugOverlayAreaInfo = nullptr;
CVar* m_debugOverlayShowFrameCounter = nullptr;
CVar* m_debugOverlayShowInGameTime = nullptr;
CVar* m_debugOverlayShowResourceStats = nullptr;
CVarCommons(CVarManager& manager) : m_mgr(manager) {
m_graphicsApi = m_mgr.findOrMakeCVar("graphicsApi"sv, "API to use for rendering graphics"sv, DEFAULT_GRAPHICS_API,
@ -41,6 +49,30 @@ struct CVarCommons {
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,
(CVar::EFlags::Game | CVar::EFlags::ReadOnly | CVar::EFlags::InternalArchivable));
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_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_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_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);
}
std::string getGraphicsApi() const { return m_graphicsApi->toLiteral(); }

View File

@ -16,7 +16,6 @@ extern CVar* com_developer;
extern CVar* com_configfile;
extern CVar* com_enableCheats;
extern CVar* com_cubemaps;
extern CVar* com_variableDt;
class CVarManager final {
using CVarContainer = DNACVAR::CVarContainer;
template <typename T>
@ -106,7 +105,6 @@ public:
void setDeveloperMode(bool v, bool setDeserialized = false);
void setCheatsEnabled(bool v, bool setDeserialized = false);
void setVariableDtEnabled(bool v, bool setDeserialized = false);
bool restartRequired() const;
void parseCommandLine(const std::vector<SystemString>& args);

View File

@ -17,7 +17,6 @@ CVar* com_developer = nullptr;
CVar* com_configfile = nullptr;
CVar* com_enableCheats = nullptr;
CVar* com_cubemaps = nullptr;
CVar* com_variableDt = nullptr;
static const std::regex cmdLineRegex("\\+([\\w\\.]+)=([\\w\\.\\-]+)");
CVarManager* CVarManager::m_instance = nullptr;
@ -36,8 +35,6 @@ CVarManager::CVarManager(hecl::Runtime::FileStoreManager& store, bool useBinary)
(CVar::EFlags::System | CVar::EFlags::ReadOnly | CVar::EFlags::Hidden | CVar::EFlags::InternalArchivable));
com_cubemaps = newCVar("cubemaps", "Enable cubemaps", false,
(CVar::EFlags::Game | CVar::EFlags::ReadOnly | CVar::EFlags::InternalArchivable));
com_variableDt = newCVar("variableDt", "Enable variable delta time (experimental)", false,
(CVar::EFlags::Game | CVar::EFlags::ReadOnly | CVar::EFlags::InternalArchivable));
}
CVarManager::~CVarManager() {}
@ -279,15 +276,6 @@ void CVarManager::setCheatsEnabled(bool v, bool setDeserialized) {
com_enableCheats->setModified();
}
void CVarManager::setVariableDtEnabled(bool v, bool setDeserialized) {
com_variableDt->unlock();
com_variableDt->fromBoolean(v);
if (setDeserialized)
com_variableDt->m_wasDeserialized = true;
com_variableDt->lock();
com_variableDt->setModified();
}
bool CVarManager::restartRequired() const {
return std::any_of(m_cvars.cbegin(), m_cvars.cend(), [](const auto& entry) {
return entry.second->isModified() && entry.second->modificationRequiresRestart();