Finer control of "draw"
speeder opened this issue ยท 3 comments
Since 1.05 update, the draw event became not much useful, due to CA abuse of rendertargets.
Also, overall the drawing code in SDV is not that good...
So I thought of doing something, that in a way is risky, but that also sounds a good idea: reimplement SDV draw function entirely, instead of calling the base SDV draw... then adding a finer control on how to draw stuff, maybe without even using events, for example SDV UI Drawing routine is just some crazy hacks, with UI objects having pointers to other UI objects in a long chain... it would be good if we could add to SMAPI something like: "addUI(someUIElement, layer)" and then SMAPI would figure how to draw it correctly every frame on its own (calling the element "draw" function in the proper place).
The idea is minimize mods need to call spritebatch begin/end on their own, allow them to insert content in the right place, and support CA hacky "zoomLevel" option properly in the mods.
I think I can write a prototype for this, but I honestly don't know, if we should do that or not.
What do you mean?
Also, how this allow us to insert drawing code in arbitrary places without each mod rewriting "draw" on their own?
What I want is avoid all mods needing to rewrite Game1.draw(), and ending with lots of incompatible mods.
Obvious examples: my health-bar mod, I wanted to render the healthbars BEFORE the monsters (right-after them would work too), so that lighting affected the health bars, currently there is no way to do that, except maybe editing the draw calls of each invidiual monster (leading to some big overhead).
My chest label mod, currently I have to render the label UI on top of the game, then render a new mouse cursor over it, and if you use zoom it breaks due to a bug in XNA (I found out XNA has a bug where rendering to a render target, something that is necessary to post-render stuff on SDV with zoom active, XNA clears the other buffers... even if you didn't wanted it to).
The correct way would be add to the game main draw() a call to render "extra" modded-in UI, after the game existing UI, but before everything else. (or even right before the existing modded-in UI, but after drawing the game elements, like map, characters, effects, etc...).