HUD: support float values for text size property#16731
HUD: support float values for text size property#16731SmallJoker merged 11 commits intoluanti-org:masterfrom
size property#16731Conversation
|
Works for me. I also tested Please note the So I can can get behind the case for adding a But either way, I don't care that much as long it works; the problems with a float size are mostly of theoretical nature. Also, I noticed this: if I use Finally, should the documentation mention that floats are accepted now? (In general, I think the documentation would improve if data types (esp. float vs int) and size bounds (min/max value) are mentioned everywhere, but this is off-topic …) |
I wanted
I didn't want to add a new field. However, if core devs think this is the way to go, just tell me and I'll go with this approach instead |
|
Actually, this can be considered "UI improvements". Relabelled, if core devs don't agree, feel free to close it as not adhering to the roadmap. |
There was a problem hiding this comment.
I was initially a bit skeptical of this (I would have preferred a separate font_size). I've now approached this again with a fresh mind and I figure it's okay, for the following reasons:
- We do currently use
sizefor font size, so the natural way to extend that is by just allowing floats. - Adding
font_sizewould introduce redundancy and/or require a deprecation ofsizefor font size, creating work for modders (as Zughy noted).- This will be slightly dirty either way. It's not clear to me that
font_sizewould be meaningfully cleaner.
- This will be slightly dirty either way. It's not clear to me that
- It also introduces further HUD element non-uniformity (custom logic for a specific element type).
- "Upgrading"
s32tof32is fine; we can pretend thatf32is a supertype ofs32, current code keeps working. Nobody needs more than 8388608 pixels. - As far as the Lua API user is concerned, not much changes either. I believe our current
v2s32reading logic silently casts already. Now the cast just moves to a different place deeper inside the code (network level and/or HUD drawing). - From a Lua perspective, where everything is
f64,f32is a more natural type even.
If we want to be extra careful, the other HUD elements that currently use size and expect it to be integer can get explicit casts to v2s32 in their drawing logic.
The review mostly consists of suggestions to use the appropriate vector2d<T>::from cast helpers.
|
Rebased and review addressed |
appgurueu
left a comment
There was a problem hiding this comment.
Took the liberty to commit your test code as a unit test under your name. Works as expected in singleplayer 👍
I believe the protocol version check needs to be updated to 52 however, as 51 is now used by the released 5.15.0. The protocol version then also needs to be bumped in networkprotocol.cpp, with an appropriate note in the comment.
One small detail I missed initially, could you explicitly state in the docs the client version requirement for this feature (5.16.0+), and note that older clients only support integer sizes so modders can adjust accordingly?
@appgurueu I would suggest to prepare the 5.16.0 notice and not bump yet - especially in regard to another feature that would benefit from a bump: #17020. The PR can be tested manually by changing the supported proto version locally. |
Co-authored-by: SmallJoker <SmallJoker@users.noreply.github.com>
| Only send first frame of animated item/wield images to older client | ||
| [scheduled bump for 5.15.0] | ||
| PROTOCOL VERSION 52 | ||
| Add TOCLIENT_WIELD_ITEM |
There was a problem hiding this comment.
for reviewers: this avoids a rebase conflict with #17020 , as it sounds like both this PR and the other are being merged within 5.16
Co-authored-by: SmallJoker <SmallJoker@users.noreply.github.com>
SmallJoker
left a comment
There was a problem hiding this comment.
LGTM. Thank you for the adjustments.
appgurueu
left a comment
There was a problem hiding this comment.
sure, as long as the state in master is consistent when this is merged it's good
What conflicts? Anyway. I assume this needs the label ... |
|
@SmallJoker I don't see it, it tells me there are no conflicts |
Fixes #16603
size.mp4
⬅️ master
➡️ PR
(code below)
It's my first time really messing with the networking part, as I wanted to learn a bit how the engine works. So... heh.
I didn't want to add another property (e.g.
font_size), as I'd like to avoid any additional work to game devs. So I've convertedsizeinto av2f. I've tested both with new server - old client (as in video) and vice versa.To do
This PR is Ready for Review.
How to test