From 73c3af7bc04a189d4c05ce65d7e54ad361df8230 Mon Sep 17 00:00:00 2001 From: somewhatlurker <52014015+somewhatlurker@users.noreply.github.com> Date: Wed, 23 Oct 2019 12:28:29 +1100 Subject: [PATCH] pause: support all aspect ratios --- .../source/plugins/TLAC/Components/Drawing.h | 5 ++++- .../source/plugins/TLAC/Components/Pause.cpp | 15 +++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/source-code/source/plugins/TLAC/Components/Drawing.h b/source-code/source/plugins/TLAC/Components/Drawing.h index 1ef1242..0c5bd73 100644 --- a/source-code/source/plugins/TLAC/Components/Drawing.h +++ b/source-code/source/plugins/TLAC/Components/Drawing.h @@ -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, }; diff --git a/source-code/source/plugins/TLAC/Components/Pause.cpp b/source-code/source/plugins/TLAC/Components/Pause.cpp index a2ede51..db817a1 100644 --- a/source-code/source/plugins/TLAC/Components/Pause.cpp +++ b/source-code/source/plugins/TLAC/Components/Pause.cpp @@ -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;