MehVahdJukaar / mapatlases-neoforge

GNU General Public License v3.0
21 stars 5 forks source link

Anchors don't work at greater GUI Scales #113

Closed Estecka closed 3 months ago

Estecka commented 3 months ago

Probably related to #105

The minimap anchor points only work properly when the vanilla GUI scale is set to 1. At any other GUI scale, the effective anchor point ends up being located farther outside of the screen, varying greatly depending on the GUI scale and the screen resolution.

I believe the faulty code is here. The correct version would look something like this:

double guiScale = MinecraftClient.getInstance().getWindow().getScaleFactor()

int x = anchorLocation.isLeft ? 0 : (int) (screenWidth  / (globalScale*guiScale) ) - BG_SIZE;
int y = anchorLocation.isUp   ? 0 : (int) (screenHeight / (globalScale*guiscale) ) - BG_SIZE;

I would have made a PR for this, but I was unable to test this code due to being unable to build the project.

Repro:

  1. Launch minecraft in windowed mod; do not change the default window's size. This should give you a vertical resolution of 480px.
  2. Use the following settings:   - Vanilla GUI Scale: 2   - Minimap Anchor: Lower Left   - Minimap offset: X:0 Y:-240   - Minimap Scale: 1
  3. Load a world and bring up the minimap. It should be located precisely into the bottom left corner of the screen.
  4. Open chat (to free the mouse cursor without obscuring the screen), grab the bottom of the window, and gradually increase the vertical resolution: The minimap will gradually slide off-screen through the bottom edge.

Versions:

MehVahdJukaar commented 3 months ago

thank you for looking into this. i was aware but it being a non curcial tiny issue never looked much into it since people could just use the other configs to tweak the attachment accordingly. Ill see if that code fixes

Estecka commented 3 months ago

Just realized you use Mojmap. The snippet I gave uses Yarn mappings.

Estecka commented 3 months ago

Confirmed that fix is working. This is its equivalent in mojmap.

double guiScale = Minecraft.getInstance().getWindow().getGuiScale();
MehVahdJukaar commented 3 months ago

so weirdly this is only needed on fabric version. even tho they use the same exact code and im not sure why

MehVahdJukaar commented 3 months ago

image this was actual fix. they were using getGuiWidth() instead