Closed GenericHeroGuy closed 8 months ago
Aaaaand 20 seconds after pushing the branch, I realized new drawing functions are waaaay overkill :rage1: Would be a much better idea to just return the patch to use, since that's ultimately what the drawing functions do.
On the other hand, the automatic colormaps are pretty convenient. Not sure which is better...
Why not both? 😎
patch, colormap = v.getColorHudPatch(item)
Returns the patch and colormap to use for the given HUD item. Different items may take different arguments.
Now that I've (hopefully) decided on the final set of functions, here's a sample script that shows everything in action: newhudtest.txt
Currently, supporting Saturn's HUD customization in Lua is kind of a pain. There's lots of cvars to deal with, like
colorizedhud
,colorizedhudcolor
,xoffset
,yoffset
, lots of hardcode to copy and paste... It's especially painful for the item box, which has its own pair of cvars:colorizeditembox
anddarkitembox
. And what if any of the above changes? Now you have to update your scripts to support it!This PR introduces a set of new Lua functions that greatly simplifies supporting HUD customization.
x, y = hud.getOffsets(item)
Returns the values of the given HUD item's offset cvars.Takes the same input asNow it does, and supports HUD items not inhud.enabled
. Returns nil if the item doesn't support offsets. (TODO: error out instead?)hud.enabled
.x, y, flags = v.getDrawInfo(item)
Returns the X, Y and flags where the given HUD item will be drawn. Currently supported areitem
,gametypeinfo
(laps) andminimap
. More can be added in the future. Some refactoring was done for this one; a newdrawinfo_t
has been introduced, so Lua and hardcode can share the same logic for positioning HUD items. This function might seem redundant, but it allows separating the offset cvars from the drawing logic. And I've got some plans for that 😛v.drawItemBox(x, y, flags, small, dark, colormap)
~~Draws an item box. The size and darkness of the item box can be controlled, as well as the color. If no colormap is provided, it uses the default HUD colormap. Colorization is automatically enabled depending on the player's settings.~~v.drawItemMul(x, y, flags, small, colormap)
Draws the multi sticker. It's not as complex as the item box, but it's closely related, so it's included for convenience. (doesn't flip automatically, btw)hudcolor = v.getHudColor()
Returns the skincolor used for HUD colorization. Useful for colorizing your own HUD stuff.colorized = v.useColorHud()
Returns true if HUD colorization is enabled.All in all, there's room for improvement, but the Lua side of things is pretty much done.
Some extras:
V_SPLITSCREEN
on OpenGL. It's about time, huh?stplyrnum
to simplify HUD code. Also moved it (andstplyr
) to st_stuff.h where it belongs.