diff --git a/include/Engine/Core/DeveloperConsole.h b/include/Engine/Core/DeveloperConsole.h index a761c2c4..322596ba 100644 --- a/include/Engine/Core/DeveloperConsole.h +++ b/include/Engine/Core/DeveloperConsole.h @@ -5,7 +5,6 @@ #include #include #include "../Common.h" -#include "ResourceManager.h" #include "ConfigFile.h" class DeveloperConsole @@ -15,8 +14,30 @@ public: static void MergeConfig(std::string configFile) { - auto config = ResourceManager::Load(configFile); - m_ConfigFiles.push_back(config); + auto config = ResourceManager::Load("Config.ini"); + LOG_DEBUG("Debug.LogLevel %i", config->Get("Debug.LogLevel", -1)); + config->Set("Debug.LogLevel", 8); + LOG_DEBUG("Debug.LogLevel %i", config->Get("Debug.LogLevel", -1)); + config->Set("Test.TesTest.Testies", "Hello"); + config->SaveToDisk(); + for (auto& section : config->GetSections()) { + for (auto& param : *section.second) { + std::cout << "// " << param.second->get_comment() << std::endl; + std::cout << section.first << "." << param.first << " " << param.second->get_value() << std::endl; + } + } + + for (auto& section : config->GetSections()) { + for (auto& param : *section.second) { + std::string key = section.first + "." + param.first; + m_VariableBindingSetters[key] = [config, key](std::string value) { + config->Set(key, value); + }; + m_VariableBindingGetters[key] = [config, key]() { + return config->Get(key, ""); + }; + } + } } template @@ -83,9 +104,10 @@ public: private: typedef boost::tokenizer> tokenizer; - static std::vector m_ConfigFiles; - static std::map> m_VariableBindingSetters; - static std::map> m_VariableBindingGetters; + static std::map> m_VariableBindingGetters; + static std::map> m_VariableBindingSetters; + static std::map> m_VariableBindingMappers; + static std::map m_VariableDocumentation; static void consumeToken(tokenizer::iterator& token, const tokenizer::iterator end) { @@ -112,10 +134,6 @@ private: return; - for (auto& config : m_ConfigFiles) { - value = config->Get(key, ""); - } - if (!value.empty()) { std::cout << key << " = " << value << std::endl; } else { diff --git a/src/Engine/Core/DeveloperConsole.cpp b/src/Engine/Core/DeveloperConsole.cpp index 0677ad6f..3dc51e4f 100644 --- a/src/Engine/Core/DeveloperConsole.cpp +++ b/src/Engine/Core/DeveloperConsole.cpp @@ -1,5 +1,4 @@ #include "Core/DeveloperConsole.h" -std::vector DeveloperConsole::m_ConfigFiles; std::map> DeveloperConsole::m_VariableBindingSetters; std::map> DeveloperConsole::m_VariableBindingGetters; diff --git a/src/Game/Game.cpp b/src/Game/Game.cpp old mode 100644 new mode 100755 index c66d2641..368684c9 --- a/src/Game/Game.cpp +++ b/src/Game/Game.cpp @@ -2,6 +2,7 @@ #include "Collision/TriggerSystem.h" #include "Collision/CollisionSystem.h" #include "Game/HealthSystem.h" +#include "Core/DeveloperConsole.h" #include "Core/EntityFileWriter.h" Game::Game(int argc, char* argv[]) @@ -15,6 +16,14 @@ Game::Game(int argc, char* argv[]) m_Config = ResourceManager::Load("Config.ini"); LOG_LEVEL = static_cast<_LOG_LEVEL>(m_Config->Get("Debug.LogLevel", 1)); + DeveloperConsole::MergeConfig("Config.ini"); + DeveloperConsole::BindVariable("Debug.LogLevel", LOG_LEVEL); + std::string testBind = "Carlito"; + DeveloperConsole::BindVariable("Test", testBind); + while (true) { + DeveloperConsole::Consume(std::cin); + } + // Create the core event broker m_EventBroker = new EventBroker();