[client] overlay: stabilize configuration ImGui IDs

This commit is contained in:
Geoffrey McRae
2026-07-30 09:12:55 +10:00
parent 9c24acc6f9
commit 510f6e8e14

View File

@@ -160,8 +160,6 @@ static int config_render(void * udata, bool interactive, struct Rect * windowRec
if (!interactive) if (!interactive)
return 0; return 0;
int id = 1000;
const ImGuiViewport * viewport = igGetMainViewport(); const ImGuiViewport * viewport = igGetMainViewport();
igSetNextWindowPos( igSetNextWindowPos(
(ImVec2){ (ImVec2){
@@ -176,12 +174,10 @@ static int config_render(void * udata, bool interactive, struct Rect * windowRec
(ImVec2){550, 680}, (ImVec2){550, 680},
ImGuiCond_FirstUseEver); ImGuiCond_FirstUseEver);
igPushID_Int(id++);
if (!igBegin("Configuration", NULL, 0)) if (!igBegin("Configuration", NULL, 0))
{ {
overlayGetImGuiRect(windowRects); overlayGetImGuiRect(windowRects);
igEnd(); igEnd();
igPopID();
return 1; return 1;
} }
@@ -200,11 +196,14 @@ static int config_render(void * udata, bool interactive, struct Rect * windowRec
ll_lock(cfg.callbacks); ll_lock(cfg.callbacks);
ll_forEachNL(cfg.callbacks, item, cb) ll_forEachNL(cfg.callbacks, item, cb)
{ {
if (!igCollapsingHeader_BoolPtr(cb->title, NULL, 0)) igPushID_Ptr(cb);
continue;
if (igCollapsingHeader_BoolPtr(cb->title, NULL, 0))
{
int id = 0;
cb->callback(cb->udata, &id);
}
igPushID_Int(id++);
cb->callback(cb->udata, &id);
igPopID(); igPopID();
} }
ll_unlock(cfg.callbacks); ll_unlock(cfg.callbacks);
@@ -214,13 +213,16 @@ static int config_render(void * udata, bool interactive, struct Rect * windowRec
ll_lock(cfg.tabCallbacks); ll_lock(cfg.tabCallbacks);
ll_forEachNL(cfg.tabCallbacks, item, cb) ll_forEachNL(cfg.tabCallbacks, item, cb)
{ {
if (!igBeginTabItem(cb->title, NULL, 0)) igPushID_Ptr(cb);
continue;
if (igBeginTabItem(cb->title, NULL, 0))
{
int id = 0;
cb->callback(cb->udata, &id);
igEndTabItem();
}
igPushID_Int(id++);
cb->callback(cb->udata, &id);
igPopID(); igPopID();
igEndTabItem();
} }
ll_unlock(cfg.tabCallbacks); ll_unlock(cfg.tabCallbacks);
@@ -234,7 +236,6 @@ static int config_render(void * udata, bool interactive, struct Rect * windowRec
overlayGetImGuiRect(windowRects); overlayGetImGuiRect(windowRects);
igEnd(); igEnd();
igPopID();
return 1; return 1;
} }