WIP
This commit is contained in:
@@ -5,7 +5,6 @@
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/tokenizer.hpp>
|
||||
#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>(configFile);
|
||||
m_ConfigFiles.push_back(config);
|
||||
auto config = ResourceManager::Load<ConfigFile>("Config.ini");
|
||||
LOG_DEBUG("Debug.LogLevel %i", config->Get<int>("Debug.LogLevel", -1));
|
||||
config->Set("Debug.LogLevel", 8);
|
||||
LOG_DEBUG("Debug.LogLevel %i", config->Get<int>("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<std::string>(key, value);
|
||||
};
|
||||
m_VariableBindingGetters[key] = [config, key]() {
|
||||
return config->Get<std::string>(key, "");
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@@ -83,9 +104,10 @@ public:
|
||||
private:
|
||||
typedef boost::tokenizer<boost::char_separator<char>> tokenizer;
|
||||
|
||||
static std::vector<ConfigFile*> m_ConfigFiles;
|
||||
static std::map<std::string, std::function<void(std::string)>> m_VariableBindingSetters;
|
||||
static std::map<std::string, std::function<std::string()>> m_VariableBindingGetters;
|
||||
static std::map<std::string, std::function<std::string()>> m_VariableBindingGetters;
|
||||
static std::map<std::string, std::function<void(std::string)>> m_VariableBindingSetters;
|
||||
static std::map<std::string, std::function<std::string(std::string)>> m_VariableBindingMappers;
|
||||
static std::map<std::string, std::string> 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<std::string>(key, "");
|
||||
}
|
||||
|
||||
if (!value.empty()) {
|
||||
std::cout << key << " = " << value << std::endl;
|
||||
} else {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#include "Core/DeveloperConsole.h"
|
||||
|
||||
std::vector<ConfigFile*> DeveloperConsole::m_ConfigFiles;
|
||||
std::map<std::string, std::function<void(std::string)>> DeveloperConsole::m_VariableBindingSetters;
|
||||
std::map<std::string, std::function<std::string()>> DeveloperConsole::m_VariableBindingGetters;
|
||||
|
||||
Regular → Executable
+9
@@ -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<ConfigFile>("Config.ini");
|
||||
LOG_LEVEL = static_cast<_LOG_LEVEL>(m_Config->Get<int>("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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user