openplanet-nl / issues

Issue tracker for Openplanet.
10 stars 0 forks source link

UI::PushID(const ?&in) doesn't work as expected #545

Closed AurisTFG closed 1 week ago

AurisTFG commented 2 weeks ago

When using UI::PushID with a non-string parameter, the function call compiles without errors but doesn't actually push the ID.

Happens on both pre-schoolmode and post-schoolmode versions of Openplanet.

Code example:

for (uint i = 0; i < arr.Length; i++)
{
    UI::PushID(i); // doesnt work, although compiles fine without errors
    UI::PushID(i + ""); // works

    // UI:Button etc..

    UI::PopID();
}
codecat commented 2 weeks ago

Not necessarily a bug; PushID() with any variable will use the address of that variable for the ID. In this case, it will use the address of i, which will never change. We could add a version of PushID that accepts an integer, just to support that.

AurisTFG commented 2 weeks ago

Ah, that makes sense then. Maybe it could be specified in the documentation by how exactly those two functions differ 🤔 I now see that I can even do PushID(arr[i]), which is pretty neat. A 3rd variant of PushID could be cool, although appending + "" or passing arr[i] isnt a hassle so it's fine the way it is right now.

codecat commented 2 weeks ago

It’s not a hassle, but it does add unnecessary overhead, so I would like to get this fixed.