mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-22 20:07:01 +00:00
Settings: Internals: Added FindSettingsHandler()
This commit is contained in:
parent
35eb5c5c99
commit
7ae71e4984
14
imgui.cpp
14
imgui.cpp
@ -2639,6 +2639,15 @@ static void LoadIniSettingsFromDisk(const char* ini_filename)
|
|||||||
ImGui::MemFree(file_data);
|
ImGui::MemFree(file_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImGuiSettingsHandler* ImGui::FindSettingsHandler(ImGuiID type_hash)
|
||||||
|
{
|
||||||
|
ImGuiContext& g = *GImGui;
|
||||||
|
for (int handler_n = 0; handler_n < g.SettingsHandlers.Size; handler_n++)
|
||||||
|
if (g.SettingsHandlers[handler_n].TypeHash == type_hash)
|
||||||
|
return &g.SettingsHandlers[handler_n];
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
// Zero-tolerance, no error reporting, cheap .ini parsing
|
// Zero-tolerance, no error reporting, cheap .ini parsing
|
||||||
static void LoadIniSettingsFromMemory(const char* buf_readonly)
|
static void LoadIniSettingsFromMemory(const char* buf_readonly)
|
||||||
{
|
{
|
||||||
@ -2680,10 +2689,7 @@ static void LoadIniSettingsFromMemory(const char* buf_readonly)
|
|||||||
name_start++; // Skip second '['
|
name_start++; // Skip second '['
|
||||||
}
|
}
|
||||||
const ImGuiID type_hash = ImHash(type_start, 0, 0);
|
const ImGuiID type_hash = ImHash(type_start, 0, 0);
|
||||||
entry_handler = NULL;
|
entry_handler = ImGui::FindSettingsHandler(type_hash);
|
||||||
for (int handler_n = 0; handler_n < g.SettingsHandlers.Size && entry_handler == NULL; handler_n++)
|
|
||||||
if (g.SettingsHandlers[handler_n].TypeHash == type_hash)
|
|
||||||
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)
|
||||||
|
@ -803,8 +803,9 @@ namespace ImGui
|
|||||||
|
|
||||||
IMGUI_API void Initialize();
|
IMGUI_API void Initialize();
|
||||||
|
|
||||||
IMGUI_API void MarkIniSettingsDirty();
|
IMGUI_API void MarkIniSettingsDirty();
|
||||||
IMGUI_API ImGuiWindowSettings* FindWindowSettings(ImGuiID id);
|
IMGUI_API ImGuiSettingsHandler* FindSettingsHandler(ImGuiID type_id);
|
||||||
|
IMGUI_API ImGuiWindowSettings* FindWindowSettings(ImGuiID id);
|
||||||
|
|
||||||
IMGUI_API void SetActiveID(ImGuiID id, ImGuiWindow* window);
|
IMGUI_API void SetActiveID(ImGuiID id, ImGuiWindow* window);
|
||||||
IMGUI_API void ClearActiveID();
|
IMGUI_API void ClearActiveID();
|
||||||
|
Loading…
Reference in New Issue
Block a user