by Nash » Thu Mar 30, 2017 6:39 pm
Well, in /theory/ someone COULD write some sort of visual editor like the C# form editor, where you can place widgets, and edit code for each widget... things like that. Some sort of WYSIWYG editor thingy. And then it finally generates the ZScript code for you... but I don't think anyone is willing to do that.
Also, some generic menu advice, especially if you plan to design and code completely custom menus. The same advice could also be applied to making game menus in general, not just ZScript.
It's very important that you have some design worked out before you even type your first line of code. Do a mockup in Photoshop or something, get a feel for where your widgets are going to end up on the screen. This gives you a rough idea of what you actually need to program.
You will see LITTERED everywhere in the engine's menu code, where it tries to subtract 160 here, nudge something 8 pixels there... you'll see expressions with multiple layers of parentheses and subtractions and divisions and multiplications everywhere, and you'll start to get a headache. This looks to me like there was no design involved and were just kludges to compensate for something that wasn't thought of carefully in the beginning, and/or it could also be a relic to work around the fact that Doom's original menus were in 320x200. You don't want your user scripts to look like this because it would be painful to maintain and almost impossible to learn from, for newcomers.
What would have been a good way is to define constants. This is where the mockup design part would be very helpful. Make meaningful constants, like MENU_RESOLUTION_WIDTH, MENU_RESOLUTION_HEIGHT, BUTTON_X_OFFSET, SLIDER_POSITION_Y, things like that. This also means that you won't lock your menu to a specific resolution. If one day you decide to replace your art assets (let's say you started menus with a 320x200 design and suddenly you want crisp 1080p menus with high res art assets), you just change these constants once and your entire menu will (hopefully!) update to reflect the new art assets.
On the other hand, if you're just interested in plugging in widgets into the existing ZDoom menu design, then, perhaps not much design process is required beforehand. You just have to learn the programming conventions that the widgets use and adapt to that.
But for building new menus, careful design and preparation upfront will go a LONG way towards clean and maintainable code.