I’ve got a plan for the UI, and am now in the process of writing all the C++ funcitons to display and manipulate the separate elements. Then I’ll finalize the file format for storing the data, then I’ll hook LUA in to it all to feed the C++ code the actual data that the UI will display. So it will go something like this:
C++ recognizes a possible UI event (like, landing on a planet, or pressing ESC).
C++ sends the UI event type, along with possible extra data (like the ID number of the star and planet being landed on), to LUA. There is a highly flexible stack kept for calls between C++ and LUA, so it’s pretty good about sticking optional extra data in the calls.
Then LUA will make a call back to C++ for every individual UI element required by the UI screen for that event, feeding in the screen-space coordinates for each individual button, the size of the sliders, that sort of thing. Also, it will have to talk to C++ to find out the values for all of the stuff the elements represent.
All of those new elements will be put in a queue back on the C++ side, where it manages the frame-by-frame stuff like mouse motion and clicks. This is the part I’m building now. When certain things happen, like a button is pressed, it talks to LUA to figure out what to do about it.
LUA responds by calling C++ functions to change data, or whatever is required. Writing the code for this part will be pretty tedious on both the LUA and C++ side.
And that’s it. A giant mess of calls back and forth from C++ and LUA, at least one line of LUA to write for every single button, slider, or whatever; and a large number of tiny little functions to write in probably every class in the game in C++ to let LUA get and set any value that might be modified by the UI, since LUA can only call very particular functions. All to have some buttons to click on.
This is the first major system that isn’t at all based on files you can modify without recompiling. This is because LUA itself can be modified without recompiling- it’s all interpreted.