This repository has been archived by the owner on Jul 2, 2023. It is now read-only.
Add anchoring points for HUD elements and various HUD refactorings #139
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.
This implements KronHUD's 9 point anchoring system to allow for greater flexibility with dynamic sized HUD elements. This implements it as pretty much set it and forget it. It handles updating bounds whenever height and width updates so there isn't any need to worry about that. It also converts x/y values into floats that represent the percentage that they are on the screen. This makes it so resizing does not mess up the HUD.
It may be worthwhile to enable anchoring everything if someone desires if they resize a lot. The anchoring would be useful to ensure stuff stays snapped to edges.
HudElement has a new inheritor called AbstractHudElement. This is meant to make it easier to create complex HUD elements without having to make them as a mod. This is useful in my bedwars mod and the discord mod in this client.
Currently on the HUD edit screen it displays the anchors when selected. I don't know if this is the best way, so feel free to change them.
This also should ™️ automatically migrate from old storage to new. It won't be perfect since it converts to percentages, and that's probably messed up.
(most likely) Closes #128.