Is that even a reasonable idea in an IMGUI context? How will you deal with the logic introduced by the immediate result values?Maybe I find myself making lots of buttons with similar behavior/logic/etc... So I make a helper function to eliminate the boiler-plate parts of the API.
My impression is that if you try to do this, you will end up having to build an entire retained-mode wrapper around your IMGUI, and you'd be better off using an RMGUI in the first place.
I think so. Maybe I have a game-specific debug menu, with some XML (or, more likely, static table in code) configuration:
static DebugButtonData [] =
{
{ "GodMode", toggleGodMode },
{ "NoClip", toggleNoClip },
{ etc... }
} buttons;
for (int i = 0; i < numDebugButtons; ++i)
{
if (DoButton(buttons[i].label))
{
buttons[i].callback();
}
}
I just don't see why you wouldn't want to be able to write code like that... (Which still leads me back to the previous suggestion - pass in a string and use that (or hash it)).