From f798d9fe4bc0a1579eec5a5ab83d862ec9c59d17 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 7 Feb 2021 23:39:12 -0800 Subject: [PATCH] Savedata: Show save icons with proper aspect ratio. This mainly matters for Minis. --- Core/Dialog/PSPSaveDialog.cpp | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/Core/Dialog/PSPSaveDialog.cpp b/Core/Dialog/PSPSaveDialog.cpp index 3747927946..cda101b0d0 100755 --- a/Core/Dialog/PSPSaveDialog.cpp +++ b/Core/Dialog/PSPSaveDialog.cpp @@ -348,7 +348,7 @@ void PSPSaveDialog::DisplaySaveList(bool canMove) { imageStyle.color = CalcFadedColor(0xFF777777); // Calc save image position on screen - float w, h , x, b; + float w, h, x; float y = 97; if (displayCount != currentSelectedSave) { w = 81; @@ -358,11 +358,6 @@ void PSPSaveDialog::DisplaySaveList(bool canMove) { w = 144; h = 80; x = 27; - b = 1.2f; - PPGeDrawRect(x-b, y-b, x+w+b, y, CalcFadedColor(0xD0FFFFFF)); // top border - PPGeDrawRect(x-b, y, x, y+h, CalcFadedColor(0xD0FFFFFF)); // left border - PPGeDrawRect(x-b, y+h, x+w+b, y+h+b, CalcFadedColor(0xD0FFFFFF)); //bottom border - PPGeDrawRect(x+w, y, x+w+b, y+h, CalcFadedColor(0xD0FFFFFF)); //right border } if (displayCount < currentSelectedSave) y -= 13 + 45 * (currentSelectedSave - displayCount); @@ -373,16 +368,28 @@ void PSPSaveDialog::DisplaySaveList(bool canMove) { if (y > 472.0f || y < -200.0f) continue; - int tw = 256; - int th = 256; - if (fileInfo.texture != NULL) { + int pad = 0; + if (fileInfo.texture != nullptr) { fileInfo.texture->SetTexture(); - tw = fileInfo.texture->Width(); - th = fileInfo.texture->Height(); - PPGeDrawImage(x, y, w, h, 0, 0, 1, 1, tw, th, imageStyle); + int tw = fileInfo.texture->Width(); + int th = fileInfo.texture->Height(); + float scale = (float)h / (float)th; + int scaledW = (int)(tw * scale); + pad = (w - scaledW) / 2; + w = scaledW; + + PPGeDrawImage(x + pad, y, w, h, 0, 0, 1, 1, tw, th, imageStyle); } else { PPGeDrawRect(x, y, x + w, y + h, 0x88666666); } + if (displayCount == currentSelectedSave) { + float b = 1.2f; + uint32_t bc = CalcFadedColor(0xD0FFFFFF); + PPGeDrawRect(x + pad - b, y - b, x + pad + w + b, y, bc); // top border + PPGeDrawRect(x + pad - b, y, x + pad, y + h, bc); // left border + PPGeDrawRect(x + pad - b, y + h, x + pad + w + b, y + h + b, bc); //bottom border + PPGeDrawRect(x + pad + w, y, x + pad + w + b, y + h, bc); //right border + } PPGeSetDefaultTexture(); } @@ -416,6 +423,10 @@ void PSPSaveDialog::DisplaySaveIcon(bool checkExists) curSave.texture->SetTexture(); tw = curSave.texture->Width(); th = curSave.texture->Height(); + float scale = (float)h / (float)th; + int scaledW = (int)(tw * scale); + x += (w - scaledW) / 2; + w = scaledW; } else { PPGeDisableTexture(); }