mirror of
https://github.com/ocornut/imgui.git
synced 2026-07-10 19:39:40 +00:00
Settings: added a type name filter to CleanupIniSettings() / ImGuiSettingsCleanupArgs. (#9460)
This commit is contained in:
@@ -15713,10 +15713,12 @@ void ImGui::CleanupIniSettings(ImGuiSettingsCleanupArgs* args)
|
|||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
if (g.PlatformIO.Platform_SessionDate == 0)
|
if (g.PlatformIO.Platform_SessionDate == 0)
|
||||||
return;
|
return;
|
||||||
|
ImGuiID type_hash_filter = args->TypeName ? ImHashStr(args->TypeName) : 0;
|
||||||
ImGuiPackedDate discard_older_than_date_p = g.PlatformIO.Platform_SessionDate;
|
ImGuiPackedDate discard_older_than_date_p = g.PlatformIO.Platform_SessionDate;
|
||||||
discard_older_than_date_p.SubtractMonths(args->DiscardOlderThanMonths);
|
discard_older_than_date_p.SubtractMonths(args->DiscardOlderThanMonths);
|
||||||
args->_DiscardOlderThanDate = discard_older_than_date_p.Unpack();
|
args->_DiscardOlderThanDate = discard_older_than_date_p.Unpack();
|
||||||
for (ImGuiSettingsHandler& handler : g.SettingsHandlers)
|
for (ImGuiSettingsHandler& handler : g.SettingsHandlers)
|
||||||
|
if (type_hash_filter == 0 || handler.TypeHash == type_hash_filter)
|
||||||
if (handler.CleanupFn != NULL)
|
if (handler.CleanupFn != NULL)
|
||||||
handler.CleanupFn(&g, &handler, args);
|
handler.CleanupFn(&g, &handler, args);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2048,6 +2048,7 @@ struct ImGuiWindowSettings
|
|||||||
|
|
||||||
struct ImGuiSettingsCleanupArgs
|
struct ImGuiSettingsCleanupArgs
|
||||||
{
|
{
|
||||||
|
const char* TypeName = NULL; // Set to restrict cleanup to a given .ini type, e.g. "Window", "Table". Otherwise every types supporting Cleanup are supported.
|
||||||
int DiscardOlderThanMonths = 0; // Enable to discard entries older than XX months.
|
int DiscardOlderThanMonths = 0; // Enable to discard entries older than XX months.
|
||||||
bool DiscardWhenMissingDate = false; // Enable to discard entries missing a date.
|
bool DiscardWhenMissingDate = false; // Enable to discard entries missing a date.
|
||||||
bool SetCurrentSessionDateToAll = false; // Enable to write current SessionDate to all supporting entries. // Let us know in #9460 if you use this.
|
bool SetCurrentSessionDateToAll = false; // Enable to write current SessionDate to all supporting entries. // Let us know in #9460 if you use this.
|
||||||
|
|||||||
Reference in New Issue
Block a user