-
Notifications
You must be signed in to change notification settings - Fork 68
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
Text rendering redesign #216
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Preparing some utils functions to be used by TextBox and ListBox so they can be decoupled and better-designed.
Separated ListBox construction from initialization so it doesn't need to be in a unique_ptr anymore. Also started using "Rect + Properties" pattern for list box initialization arguments. ListBox is currently rendering a black box, probably need to call updateTexture().
Doesn't necessarily match the original game exactly but it's better now.
Added dirty boolean so the texture can be conditionally updated right before it's rendered.
Tried another way with updateTexture() being private but I like getTexture() being intuitive and not requiring any parameters.
Not the best solution but it works for now.
Still off by one pixel in the player inventory rendering when scrolled to the bottom but maybe that's just from float->int truncation somewhere.
Unable to test due to hundreds of compile errors.
This allows text to be drawn onto color buffers with existing background colors like tooltips.
A std::string&& would be more efficient but text shouldn't be changing frequently enough for it to matter.
Likely going to be used in UiView namespaces where the dimensions of a text box should be known at text box construction time.
Able to compile again.
It was a good convenience at the time but it has been superseded by better TextBox initialization patterns like InitInfo.
The text box might need to redraw itself in getTexture(), so it has to be non-const. Also added FontLibrary pointer for ease of redrawing the underlying texture. I guess it's okay to store a pointer to a singleton?
Also added TextRenderUtils::drawTextLines() for better code reuse.
Still just estimates but they should be plenty.
Still need to fix centering.
Wasn't able to make each font name a std::string due to global initialization order issues with all the UiView namespaces that reference them.
Only need them to stretch to the left and right edges of the screen in the worst case.
It always clamps either the foreground or shadow position non-negative so that the rendering starts at the dstX/Y position.
Need to add more text alignments so the trigger text is anchored to the bottom of its text box.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
TextRenderUtils adds several tools for determining texture size of a text box and drawing text to a buffer.
TextBox and ListBox are now much more convenient and versatile. They have been switched to a dirty boolean pattern so they only attempt to re-draw their underlying texture when it is about to be rendered on-screen. The limitation of having to allocate them on the heap has been removed as well.
Additional text alignment options were also added to support various cases like the orange trigger text in the game world being aligned to the bottom of its text box.
Future work would include changing the on-screen position to vector space and decoupling geometry dimensions from texture dimensions so that high-resolution fonts can be used.