Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI draw call registration #220

Merged
merged 54 commits into from
Nov 8, 2021
Merged

UI draw call registration #220

merged 54 commits into from
Nov 8, 2021

Conversation

afritz1
Copy link
Owner

@afritz1 afritz1 commented Nov 8, 2021

Previously, all UI panels that wanted to draw something implemented a virtual render() or renderSecondary() function. Now all UI rendering is done with UI draw calls that are registered with various logic functions in the Panel's init() function. This makes each panel less hardcoded, more configurable, and more data-driven because the draw calls are put into a list and executed by the Game loop. Future work could involve certain panels being replaced with reusable UI collections of some kind, but right now I am pretty tired of refactoring.

This branch took three months because I've been busy with work lately, but I'm glad it is getting merged now.

Edit: this branch also includes all the UiTextureID work - all UI textures are referenced by an allocated UiTextureID handle. The UI texture can have its texels locked and written to for updating. Wish I would've known to do this a long time ago.

Not drawing anything yet but it will eventually become the primary way for panel draw calls to be processed.
Need to eventually move all UI texture code over to UiTextureID instead of relying on TextureAssetReference in the renderer.
Thinking it would be less work in the long run to start converting all the panel textures over to UiTextureID now instead of later.
Need to implement more PivotType cases in Game::render() and update TextBox and ListBox to use UiTextureID so the automap title can be drawn with the new way.
Also added lock/unlock texture functions for updating a UiTextureID's content.
Will probably need to do the 0.50 math at some point. Not sure if I'll ever use the SDL_RectF in later SDL versions; only will if it makes a difference.
Forgot that these functions were needed when working with integer resource handles.
Trying to reduce sword cursor boilerplate code.
Removed generate/select button tooltips since they weren't that important.
Also converted tooltip to help text at the bottom of the screen.
Can't test it visually since WorldMapPanel is still using legacy rendering, so the sub-panel gets covered currently.
Also split fast travel UI functions into their own namespace.
Need to re-add debug profiler and button tooltips. Commented out part of PauseMenuPanel since it depends on game world UI internals that changed. Added game world render callback since I'm considering it a special case and not something that can be handled by UI rendering.
Should be about ready to remove support for the old Panel render() functions.
All UI panels and sub-panels are registering their draw calls now. This makes the things they are drawing more like data to be manipulated instead of only being hardcoded functions.
@afritz1 afritz1 added this to the 0.14.0 milestone Nov 8, 2021
@afritz1
Copy link
Owner Author

afritz1 commented Nov 8, 2021

Works fine on Windows and Raspberry Pi.

@afritz1 afritz1 merged commit c52e540 into main Nov 8, 2021
@afritz1 afritz1 deleted the ui-draw-calls branch November 8, 2021 03:53
@Thunderforge
Copy link
Collaborator

Seems to work fine on macOS too!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants