pause: support all aspect ratios

This commit is contained in:
somewhatlurker
2019-10-23 12:28:29 +11:00
parent b5b0af0e15
commit 73c3af7bc0
2 changed files with 17 additions and 3 deletions
@@ -75,7 +75,7 @@ namespace TLAC::Components
{
uint32_t colour; // RGBA byte array?, so set as 0xAABBGGRR
uint32_t fillColour; // ?? RGBA byte array?, so set as 0xAABBGGRR
uint8_t unk08;
uint8_t unk08; // seems to enable DRAWTEXT_MEASURE
uint8_t unk09[0x3];
uint32_t unk0c;
uint32_t unk10;
@@ -188,6 +188,9 @@ namespace TLAC::Components
DRAWTEXT_ENABLE_XADVANCE = 1,
DRAWTEXT_ALIGN_RIGHT = 2,
DRAWTEXT_ALIGN_CENTRE = 8,
DRAWTEXT_MEASURE = 0x200,
DRAWTEXT_SCALING_OPTIMISED = 0x400, // ? -- seems to be set if the requested font size doesn't match the original font, and the internal width/height 1 and 2 match
// maybe it's just required for any scaling though
DRAWTEXT_STROKE = 0x10000,
};
@@ -251,10 +251,15 @@ namespace TLAC::Components
DrawParams dtParams(&fontInfo);
dtParams.layer = bgLayer;
// get aspect ratio
float aspect = *(float*)UI_ASPECT_RATIO;
// bg rect
float bgWidth = aspect * 720 + 2; // add a couple of pixels to protect against rounding errors
float bgLeft = -(bgWidth - 1280) / 2; // 0,0 is in the corner of a 720p view.. half of the extra over 1280 wide is the horizontal offset to centre the bg
RectangleBounds rect;
rect = { 0, 0, 1280, 720 };
rect = { bgLeft, 0, bgWidth, 720 };
dtParams.colour = 0xa0000000;
dtParams.fillColour = 0xa0000000;
fillRectangle(&dtParams, &rect);
@@ -330,8 +335,14 @@ namespace TLAC::Components
destroyAetLayer(crossAet);
destroyAetLayer(circleAet);
float textLeft;
if (aspect > 16.0f / 9.0f)
textLeft = 32;
else
textLeft = (1280 - bgWidth) / 2 + 32; // 0,0 is in the corner of a 720p view.. half of the difference to 1280 wide is the horizontal offset to the window corner
fontInfo.setSize(18, 18);
dtParams.textCurrentLoc = { 32, 720 - 40 };
dtParams.textCurrentLoc = { textLeft, 720 - 40 };
dtParams.lineOriginLoc = dtParams.textCurrentLoc;
const float spriteSize = 18;
const float halfSpriteSize = spriteSize / 2;