diff --git a/Minecraft.Client/Gui.cpp b/Minecraft.Client/Gui.cpp index 839d0423..8836a6b2 100644 --- a/Minecraft.Client/Gui.cpp +++ b/Minecraft.Client/Gui.cpp @@ -697,8 +697,8 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) glEnable(GL_COLOR_MATERIAL); // 4J - TomK now using safe zone values directly instead of the magic number calculation that lived here before (which only worked for medium scale, the other two were off!) - int xo = iSafezoneXHalf + 10; - int yo = iSafezoneTopYHalf + 10; + int xo = iSafezoneXHalf + 10; // TODO: fix relative scaling for atrocious aspect ratios + int yo = iSafezoneTopYHalf + 10; // TODO: fix relative scaling for atrocious aspect ratios #ifdef __PSVITA__ // align directly with corners, there are no safe zones on vita @@ -708,8 +708,35 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) glPushMatrix(); glTranslatef(static_cast(xo), static_cast(yo), 50); + + // correct paper doll aspect ratio float ss = 12; - glScalef(-ss, ss, ss); + float aspectScaleX = 1.0f; + float aspectScaleY = 1.0f; + + extern int g_rScreenWidth; + extern int g_rScreenHeight; + float screenAspect = (float)g_rScreenWidth / (float)g_rScreenHeight; + float targetAspect = 16.0f / 9.0f; + + // apply correction if window is not already at a 16:9 aspect ratio + float correction = 1.0f; + + if (fabs(screenAspect - targetAspect) > 0.01f) { + if (g_rScreenHeight > 0) { + correction = 1080.0f / (float)g_rScreenHeight; + correction = std::clamp(correction, 0.5f, 2.0f); + + if (screenAspect > targetAspect) + aspectScaleX = targetAspect / screenAspect; + else + aspectScaleY = screenAspect / targetAspect; + } + } + + glTranslatef((float)xo, (float)yo, 50.0f); + + glScalef(-ss * aspectScaleX, ss * aspectScaleY, ss); glRotatef(180, 0, 0, 1); float oyr = minecraft->player->yRot;