Skip to content

Commit

Permalink
Fixed a bug where mod UI was offset when game is letterboxed
Browse files Browse the repository at this point in the history
  • Loading branch information
agersant committed Jul 8, 2024
1 parent 29ccbcf commit 9ba7f09
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion FrameMeter/src/mod/draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,19 @@ DrawContext::DrawContext(UObject *hud, Camera camera) : hud(hud), camera(camera)
int32_t height;
} viewport_size;
player_controller->ProcessEvent(get_viewport_size, &viewport_size);
scaling_factor = viewport_size.height / ui_height;

// 16:9 or theoretical widescreen
const float viewport_aspect_ratio = static_cast<float>(viewport_size.width) / viewport_size.height;
const float ui_aspect_ratio = ui_width / ui_height;
if (viewport_aspect_ratio >= ui_aspect_ratio)
{
scaling_factor = viewport_size.height / ui_height;
}
// Letterboxed tall-screen (eg. 4:3)
else
{
scaling_factor = viewport_size.width / ui_width;
}
}
}
}
Expand Down

0 comments on commit 9ba7f09

Please sign in to comment.