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
Move hard coded minimap to builtin #14071
Conversation
It's rebased and ready for review, so it would be nice if someone could review it. |
Rebased again. |
This PR probably also solves #8431 if it wasn't already solved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested, works. I have a few questions, but the code looks fine as-is. Thanks for the PR.
Fix the automatic resizing, if it is important. This may need a new feature for all HUD elements.Automatic resizing is bad since it would be the only builtin element that does this.
I am fine with your rationale for not fixing this. (Additionally, if needed, modders should be able to implement automatic resizing by querying screen size.)
You could also add a feature for screen-size relative size (similar to how images support percentages via negative values).
Thanks for the review and testing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Backwards compatibility is missing in both directions. Both cases must be fixed.
5.8.0 on the client, this PR on the server: minimap shown twice
The compatibility to older versions is not completely contained, since multiple builtin minimaps may be shown, but it is not a breaking change, and I don't think it is a big problem.
Having two mipmaps on top of each other, each with a different size, is ugly enough to be a concern. It's also easy enough to fix by checking the protocol version.
this PR on the client, 5.8.0 on the server: no minimap at all
always shows "Minimap currently disabled by game or mod"
It is now backwards compatible. (At first, I thought it wouldn't be a big problem for the builtin minimap to behave incorrectly when using different versions, since it is a rather dispensable feature.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regardless of any potential future refactoring, you can reduce code duplication a lot by moving the minimap code to statbars.lua
. (And in that case, it would make sense to rename statbars.lua
to hud.lua
or similar.)
Ok, moved it into Edit: |
Goal of the PR
(I will probably soon make a PR to add HUD new elements for the hotbar and crosshair).
How does the PR work?
The compatibility to older versions is not completely contained, since multiple builtin minimaps may be shown, but it is not a breaking change, and I don't think it is a big problem.It is now backwards compatible in both directions (server/client).
Unittest info
I completely removed
testFlagSetters
sinceshowMinimap
was the only function in theGameUI
class which could change a Hud flag. (The flag is now only managed in builtin likehealthbar
orbreathbar
)To do
This PR is Ready for Review
Fix the automatic resizing, if it is important. This may need a new feature for all HUD elements.Automatic resizing is bad since it would be the only builtin element that does this.
Now it has a fixed size like all other HUD elements. The size is similar to the previous one, only people which use a window height far away from 1080 pixels may notice a difference.
minetest.hud_replace_builtin(name, hud_definition)
work with the minimap.How to test
Use this and press the mimimap key:
(If you are unsure how the HUD flag should behave execute it also on a previous version.)
Maybe also test if the
enable_minimap
setting still works.