diff --git a/src/config.c b/src/config.c index 9e606aef..f24bf732 100644 --- a/src/config.c +++ b/src/config.c @@ -2,45 +2,25 @@ #include "config_map.h" -#include -#include -#include +#include CONFIG g_Config = { 0 }; -#define DIR_CONFIG "cfg" +static const char *m_ConfigPath = "cfg/TR2X.json5"; -static const char *m_ConfigPath = DIR_CONFIG "/TR2X.json5"; - -static void M_Load(JSON_OBJECT *root_obj); -static void M_Dump(JSON_OBJECT *root_obj); - -static void M_Load(JSON_OBJECT *root_obj) +const char *Config_GetPath(void) { - ConfigFile_LoadOptions(root_obj, g_ConfigOptionMap); + return m_ConfigPath; } -static void M_Dump(JSON_OBJECT *root_obj) +void Config_LoadFromJSON(JSON_OBJECT *root_obj) { - ConfigFile_DumpOptions(root_obj, g_ConfigOptionMap); -} - -bool Config_Read(void) -{ - return ConfigFile_Read(m_ConfigPath, &M_Load); + ConfigFile_LoadOptions(root_obj, g_ConfigOptionMap); } -bool Config_Write(void) +void Config_DumpToJSON(JSON_OBJECT *root_obj) { - const EVENT event = { - .name = "change", - .sender = NULL, - .data = NULL, - }; - UI_Events_Fire(&event); - - File_CreateDirectory(DIR_CONFIG); - return ConfigFile_Write(m_ConfigPath, &M_Dump); + ConfigFile_DumpOptions(root_obj, g_ConfigOptionMap); } void Config_Sanitize(void) diff --git a/src/config.h b/src/config.h index 2e3a0731..afc16c82 100644 --- a/src/config.h +++ b/src/config.h @@ -1,6 +1,7 @@ #pragma once -#include +#include +#include #include diff --git a/src/config_map.c b/src/config_map.c index 3bdd2c04..a6e431fb 100644 --- a/src/config_map.c +++ b/src/config_map.c @@ -3,7 +3,7 @@ #include "config.h" // import order guard -#include +#include // import order guard #include "global/enum_str.h" diff --git a/src/config_map.h b/src/config_map.h index a4a1476d..177ea8d6 100644 --- a/src/config_map.h +++ b/src/config_map.h @@ -1,5 +1,5 @@ #pragma once -#include +#include extern const CONFIG_OPTION g_ConfigOptionMap[]; diff --git a/subprojects/libtrx b/subprojects/libtrx index 401454ac..463a76b8 160000 --- a/subprojects/libtrx +++ b/subprojects/libtrx @@ -1 +1 @@ -Subproject commit 401454ac9e5bc8e7085d32385db33ac565029568 +Subproject commit 463a76b81e7477cf62021a3af44208c41d2242bb