diff --git a/Volt/Sandbox/src/Sandbox/Window/LogPanel.cpp b/Volt/Sandbox/src/Sandbox/Window/LogPanel.cpp index 7662c0e62..53a82d4eb 100644 --- a/Volt/Sandbox/src/Sandbox/Window/LogPanel.cpp +++ b/Volt/Sandbox/src/Sandbox/Window/LogPanel.cpp @@ -65,7 +65,7 @@ void LogPanel::UpdateMainContent() { auto variable = Volt::ConsoleVariableRegistry::GetVariable(strings[0]); - std::string message = strings[0] + " = "; + std::string message = std::string(variable->GetName()) + " = "; if (strings.size() > 1) { diff --git a/Volt/Volt/src/Volt/Console/ConsoleVariableRegistry.h b/Volt/Volt/src/Volt/Console/ConsoleVariableRegistry.h index 669763d0a..9eb5f72da 100644 --- a/Volt/Volt/src/Volt/Console/ConsoleVariableRegistry.h +++ b/Volt/Volt/src/Volt/Console/ConsoleVariableRegistry.h @@ -2,6 +2,8 @@ #include "Volt/Core/Base.h" +#include "Volt/Utility/StringUtility.h" + #include #include @@ -28,7 +30,7 @@ namespace Volt class RegisteredConsoleVariable : public RegisteredConsoleVariableBase { public: - RegisteredConsoleVariable(std::string_view variableName, const T& defaultValue, std::string_view description); + RegisteredConsoleVariable(const std::string& variableName, const T& defaultValue, std::string_view description); [[nodiscard]] const void* Get() const override; void Set(const void* value) override; @@ -42,7 +44,7 @@ namespace Volt private: T m_value; - std::string_view m_variableName; + std::string m_variableName; std::string_view m_description; }; @@ -99,27 +101,28 @@ namespace Volt static Weak> RegisterVariable(std::string_view variableName, const T& defaultValue, std::string_view description); template - static Weak> FindVariable(std::string_view variableName); + static Weak> FindVariable(const std::string& variableName); - inline static Weak GetVariable(std::string_view variableName); + inline static Weak GetVariable(const std::string& variableName); inline static bool VariableExists(const std::string& variableName); - static std::unordered_map>& GetRegisteredVariables() { return s_registeredVariables; } + static std::unordered_map>& GetRegisteredVariables() { return s_registeredVariables; } private: ConsoleVariableRegistry() = delete; - inline static std::unordered_map> s_registeredVariables; + inline static std::unordered_map> s_registeredVariables; }; inline bool ConsoleVariableRegistry::VariableExists(const std::string& variableName) { - return s_registeredVariables.contains(std::string_view(variableName)); + std::string tempVarName = ::Utility::ToLower(std::string(variableName)); + return s_registeredVariables.contains(tempVarName); } template - inline RegisteredConsoleVariable::RegisteredConsoleVariable(std::string_view variableName, const T& defaultValue, std::string_view description) - : m_value(defaultValue) + inline RegisteredConsoleVariable::RegisteredConsoleVariable(const std::string& variableName, const T& defaultValue, std::string_view description) + : m_value(defaultValue), m_variableName(variableName), m_description(description) { } @@ -144,20 +147,24 @@ namespace Volt template inline Weak> ConsoleVariableRegistry::RegisterVariable(std::string_view variableName, const T& defaultValue, std::string_view description) { - Ref> consoleVariable = CreateRef>(variableName, defaultValue, description); + std::string tempVarName = ::Utility::ToLower(std::string(variableName)); + + Ref> consoleVariable = CreateRef>(tempVarName, defaultValue, description); - VT_CORE_ASSERT(!s_registeredVariables.contains(variableName), "Command variable with name already registered!"); - s_registeredVariables[variableName] = consoleVariable; + VT_CORE_ASSERT(!s_registeredVariables.contains(tempVarName), "Command variable with name already registered!"); + s_registeredVariables[tempVarName] = consoleVariable; return consoleVariable; } template - inline Weak> ConsoleVariableRegistry::FindVariable(std::string_view variableName) + inline Weak> ConsoleVariableRegistry::FindVariable(const std::string& variableName) { - if (s_registeredVariables.contains(variableName)) + const std::string tempVarName = ::Utility::ToLower(variableName); + + if (s_registeredVariables.contains(tempVarName)) { - return s_registeredVariables.at(variableName); + return s_registeredVariables.at(tempVarName); } return Weak>(); @@ -170,8 +177,9 @@ namespace Volt VT_CORE_ASSERT(m_variableReference, "Variable with name not found!"); } - inline Weak ConsoleVariableRegistry::GetVariable(std::string_view variableName) + inline Weak ConsoleVariableRegistry::GetVariable(const std::string& variableName) { - return s_registeredVariables.at(variableName); + const std::string tempVarName = ::Utility::ToLower(variableName); + return s_registeredVariables.at(tempVarName); } } diff --git a/Volt/Volt/src/Volt/Rendering/SceneRenderer.cpp b/Volt/Volt/src/Volt/Rendering/SceneRenderer.cpp index 2096df48c..dc61ffef0 100644 --- a/Volt/Volt/src/Volt/Rendering/SceneRenderer.cpp +++ b/Volt/Volt/src/Volt/Rendering/SceneRenderer.cpp @@ -78,8 +78,6 @@ #include "Volt/Utility/Noise.h" #include "Volt/Platform/ThreadUtility.h" -#include "Volt/Console/ConsoleVariableRegistry.h" - namespace Volt { namespace Utility