Fix to GUI/Overlay Scaling Issue - Custom Anchoring Positions w/ Example/Math Formula

Started by Rikurob on

Topic category: Feature requests and ideas for MCreator

Joined Feb 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Fix to GUI/Overlay Scaling Issue - Custom Anchoring Positions w/ Example/Math Formula

I recently made a tutorial about how to help fix the scaling on GUI's. By adding the ability to change the anchoring position when creating a GUI, GUI's created with core mcreator code would be much better, as even if the GUI isn't centered, you could easily get it to scale properly by setting the GUI anchor position. This wouldn't work PERFECTLY, but it is a really good change and big step up from the current system, and would fix MOST of MCreator's user's issues when creating a GUI. It also doesn't seem like it would be too difficult to do, and I really think this is a feature that should be included/something similar to this.

Idea:

  • Add an anchor element to the GUI creator screen for MCreator .
  • This would be placed similar to an image, but by it's center. In MCreator's GUI creator screen it would look like an image of an anchor, but it wouldn't render in the actual GUI, it is just a tool. You could also toggle the visibility of it after placing it. If you place a second one, only the first one would be called (In order to fix the issue of limiting the element to one per GUI)
  • (Optional)Alternatively, you could set the coordinates of it manually in the element editor by clicking the Anchor on the side where you would edit a GUi's element, and setting the centering positions of the element in respect to GUI editor screen, and the changes would appear.(I think this should be a new feature for all GUI elements honestly.)
  • This element then marks the coordinates it is placed at in respect to w and h(screen sizes) and saves them as "xPositionFromElement", and "yPositionFromElement" respectively for when the GUI is created, and replaces them in the code.
  • The math and setup for the positioning would be as follows: Using "posX=w/2" and "posY=h/2" as the center of the screen, and  "posX=w" and "posY=h" as the bottom right as examples, we can derive a nice formula here. Lets replace that with  "posX=w*wAnchor" and "posY=h*hAnchor", and just before this, declare       "wAnchor=(xPositionFromElement/w)" and "yAnchor=(yPositionFromElement/h)". Pos (0,0) returns posX=0, posY=0 as the anchor point, Pos(x,y) returns posX=w, posY=h as the anchor point, Pos(x/2,y/2) returns posX=w/2 posY=h/2 as the anchor point.

 

I really hope this gets added, it would in my opinion make a dramatic increase to how good GUI's with MCreator can be.