ericoporto / agsimgui

Dear ImGui plugin for Adventure Game Studio
https://www.adventuregamestudio.co.uk/forums/index.php?topic=57699.0
Other
4 stars 1 forks source link

Enum values are hardcoded into builder #18

Open ocornut opened 4 years ago

ocornut commented 4 years ago

Hello,

Suggestion: it feels like the code generating the .ash file could emit the value using the value defined in imgui.h rather than hardcoded power of two:

" enum ImGuiInputTextFlags \r\n"
" { \r\n"
" eImGuiInputTextFlags_None                = 0, \r\n"
" eImGuiInputTextFlags_CharsDecimal        = 1,   // Allow 0123456789.+-*/ \r\n"
" eImGuiInputTextFlags_CharsHexadecimal    = 2,   // Allow 0123456789ABCDEFabcdef \r\n"
" eImGuiInputTextFlags_CharsUppercase      = 4,   // Turn a..z into A..Z \r\n"
" eImGuiInputTextFlags_CharsNoBlank        = 8,   // Filter out spaces, tabs \r\n"
" eImGuiInputTextFlags_AutoSelectAll       = 16,   // Select entire text when first taking mouse focus \r\n"
" eImGuiInputTextFlags_EnterReturnsTrue    = 32,   // Return 'true' when Enter is pressed (as opposed to every time the value was modified). \r\n"

etc.

This will make the generator code a little less readable. But please note that dear imgui provide no binary forward compatibility and those values are expected to change (and regularly are changing).

Regards.

ericoporto commented 4 years ago

First, thanks for ImGui, it's amazing piece of technology, I started using it for a little while and am having genuine fun with it, also repurposed one of it's examples in an in development tool here as agsconfig. ImGui is awesome!

I will update it to use non-hardcoded values. For now the .ash is not used, and instead I am relying on a big string in agsimgui.cpp. I am manually writing everything because AGS Script doesn't support the & feature (and, for now, AGS Script also doesn't have pointers for primitive types). I too wanted to rewrite some parts of the API - BeginListBox instead of ListBoxHeader for example.

When I get the API done I will proceed to try to automate it, but this is not trivial too, because parsing C++ code requires using Clang AST as parser. I am already learning Clang AST for a different project though, so eventually can be done. When this is done I can move the project to use git submodules or CMake instead of having a static version of ImGui stored in a directory in the git repository.

ocornut commented 4 years ago

Hello Eric,

You can and should use the cimgui metadata output (lua/json data) to get the enum and function data and then you can automate part of your output. While I believe cimgui is a little poorly written (it doesn't use Clang etc as you suggested) but the output works and so as a back-end creator that's the best thing to use today.

ListBoxHeader() will be refactored into BeginListBox() but api will change slightly so I would advise against doing that renaming yourself early because your version likely won't match how it will eventually appear in Dear ImGui's API. I realize I should have been working on this api for a while... maybe I can schedule it for the next version.

Cheers

ericoporto commented 4 years ago

OK, I read the cimgui repository and it seems doable, I will try later this month and report back. :smile: