Skip to content

Commit

Permalink
Savedata: Show save icons with proper aspect ratio.
Browse files Browse the repository at this point in the history
This mainly matters for Minis.
  • Loading branch information
unknownbrackets committed Feb 8, 2021
1 parent c2415d7 commit f798d9f
Showing 1 changed file with 23 additions and 12 deletions.
35 changes: 23 additions & 12 deletions Core/Dialog/PSPSaveDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -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();
}

Expand Down Expand Up @@ -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();
}
Expand Down

0 comments on commit f798d9f

Please sign in to comment.