Valheim-Modding/Jotunn

[BUG] GUI panels cannot be anchored anywhere but the center of the screen

joeyparrish opened this issue · 4 comments

Details:
Jotunn Version: 2.3.9
Jotunn Submodule(if applicable): GUIManager
Repeatability(Consistent(100%), Inconsistent(50%), Rare(1%), Unknown(==1)): 100%

Problem Description:
It seems that panels parented by CustomGUIFront can only be anchored to the center of the screen. Setting anchor to the left edge (new Vector2(0, 0.5f)) has no effect, and the panel ends up in the center anyway.

I can set a relative offset from center using the position, but this isn't the same. It won't scale fluidly with varying screen sizes.

Expected Behaviour:
I would expect anchoring to the left edge to allow my custom GUI to sit on the left side of the screen.

Actual Behaviour:
No matter where I try to anchor it, the panel is in the center.

Link to your server's and client's LogOutput.log
N/A AFAICT, but let me know if you need it anyway

Other
I expect that this has to do with CustomGUIFront having a size of 0x0, such that all positions within that space are the center of the screen.

I thought about modifying the source of GUIManager to give it the size of the game root, so that children could be anchored to the left of the screen, but I realized that this could also change at runtime if the user resizes the window. I don't know how to track size changes of the game root, so I gave up on doing this myself.

Any advice? I'm happy to tinker and send a PR, but I'm out of ideas.

I tried getting the parent of CustomGUIFront and setting that as the parent of my panel instead, but that didn't work for me.

CustomGUIFront and CustomGUIBack should get their Anchors min and max set to (0, 0) and (1, 1) respectively so they stretch over the whole screen. Settings childs anchors should work as expected after that.

fixed in current dev branch

Thank you!