mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-15 01:17:00 +00:00
Settings: Import old style .ini file
This commit is contained in:
parent
c8b5b569da
commit
1a8a7c9d17
13
imgui.cpp
13
imgui.cpp
@ -2676,16 +2676,23 @@ static void LoadIniSettingsFromMemory(const char* buf_readonly)
|
|||||||
char* type_start = line + 1;
|
char* type_start = line + 1;
|
||||||
char* type_end = ImStrchrRange(type_start, name_end, ']');
|
char* type_end = ImStrchrRange(type_start, name_end, ']');
|
||||||
char* name_start = type_end ? ImStrchrRange(type_end + 1, name_end, '[') : NULL;
|
char* name_start = type_end ? ImStrchrRange(type_end + 1, name_end, '[') : NULL;
|
||||||
if (type_start && type_end && name_start++ && name_end)
|
if (!type_end || !name_start)
|
||||||
{
|
{
|
||||||
const ImGuiID type_hash = ImHash(type_start, type_end - type_start, 0);
|
name_start = type_start; // Import legacy entries that have no type
|
||||||
|
type_start = "Window";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*type_end = 0; // Overwrite first ']'
|
||||||
|
name_start++; // Skip second '['
|
||||||
|
}
|
||||||
|
const ImGuiID type_hash = ImHash(type_start, 0, 0);
|
||||||
entry_handler = NULL;
|
entry_handler = NULL;
|
||||||
for (int handler_n = 0; handler_n < g.SettingsHandlers.Size && entry_handler == NULL; handler_n++)
|
for (int handler_n = 0; handler_n < g.SettingsHandlers.Size && entry_handler == NULL; handler_n++)
|
||||||
if (g.SettingsHandlers[handler_n].TypeHash == type_hash)
|
if (g.SettingsHandlers[handler_n].TypeHash == type_hash)
|
||||||
entry_handler = &g.SettingsHandlers[handler_n];
|
entry_handler = &g.SettingsHandlers[handler_n];
|
||||||
entry_data = entry_handler ? entry_handler->ReadOpenEntryFn(g, name_start) : NULL;
|
entry_data = entry_handler ? entry_handler->ReadOpenEntryFn(g, name_start) : NULL;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if (entry_handler != NULL && entry_data != NULL)
|
else if (entry_handler != NULL && entry_data != NULL)
|
||||||
{
|
{
|
||||||
// Let type handler parse the line
|
// Let type handler parse the line
|
||||||
|
Loading…
Reference in New Issue
Block a user