mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Merge pull request #14079 from unknownbrackets/ppge-aspect
Savedata: Show save icons with proper aspect ratio
This commit is contained in:
commit
1c3c384289
4 changed files with 41 additions and 20 deletions
|
@ -352,7 +352,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;
|
||||
|
@ -362,11 +362,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);
|
||||
|
@ -377,13 +372,27 @@ 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();
|
||||
}
|
||||
|
@ -418,6 +427,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();
|
||||
}
|
||||
|
@ -467,11 +480,13 @@ static void FormatSaveDate(char *date, size_t sz, const tm &t) {
|
|||
void PSPSaveDialog::DisplaySaveDataInfo1() {
|
||||
std::lock_guard<std::mutex> guard(paramLock);
|
||||
const SaveFileInfo &saveInfo = param.GetFileInfo(currentSelectedSave);
|
||||
PPGeStyle saveTitleStyle = FadedStyle(PPGeAlign::BOX_LEFT, 0.55f);
|
||||
|
||||
if (saveInfo.broken) {
|
||||
auto di = GetI18NCategory("Dialog");
|
||||
PPGeStyle textStyle = FadedStyle(PPGeAlign::BOX_VCENTER, 0.6f);
|
||||
PPGeDrawText(di->T("Corrupted Data"), 180, 136, textStyle);
|
||||
PPGeDrawText(saveInfo.title, 175, 159, saveTitleStyle);
|
||||
} else if (saveInfo.size == 0) {
|
||||
auto di = GetI18NCategory("Dialog");
|
||||
PPGeStyle textStyle = FadedStyle(PPGeAlign::BOX_VCENTER, 0.6f);
|
||||
|
@ -492,7 +507,6 @@ void PSPSaveDialog::DisplaySaveDataInfo1() {
|
|||
std::string saveDetailTxt = saveInfo.saveDetail;
|
||||
|
||||
PPGeStyle titleStyle = FadedStyle(PPGeAlign::BOX_BOTTOM, 0.6f);
|
||||
PPGeStyle saveTitleStyle = FadedStyle(PPGeAlign::BOX_LEFT, 0.55f);
|
||||
titleStyle.color = CalcFadedColor(0xFFC0C0C0);
|
||||
PPGeStyle textStyle = FadedStyle(PPGeAlign::BOX_LEFT, 0.5f);
|
||||
|
||||
|
|
|
@ -1578,6 +1578,7 @@ void SavedataParam::SetFileInfo(SaveFileInfo &saveInfo, PSPFileInfo &info, std::
|
|||
}
|
||||
} else {
|
||||
saveInfo.broken = true;
|
||||
truncate_cpy(saveInfo.title, saveDir.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -199,9 +199,16 @@ static void EndVertexDataAndDraw(int prim) {
|
|||
|
||||
static u32 __PPGeDoAlloc(u32 &size, bool fromTop, const char *name) {
|
||||
u32 ptr = kernelMemory.Alloc(size, fromTop, name);
|
||||
// Didn't get it.
|
||||
if (ptr == (u32)-1)
|
||||
return 0;
|
||||
// Didn't get it, try again after decimating images.
|
||||
if (ptr == (u32)-1) {
|
||||
PPGeDecimateTextImages(4);
|
||||
PPGeImage::Decimate(4);
|
||||
|
||||
ptr = kernelMemory.Alloc(size, fromTop, name);
|
||||
if (ptr == (u32)-1) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return ptr;
|
||||
}
|
||||
|
||||
|
@ -1291,9 +1298,8 @@ void PPGeImage::CompatLoad(u32 texture, int width, int height) {
|
|||
height_ = height;
|
||||
}
|
||||
|
||||
void PPGeImage::Decimate() {
|
||||
static const int TOO_OLD_AGE = 30;
|
||||
int tooOldFrame = gpuStats.numFlips - TOO_OLD_AGE;
|
||||
void PPGeImage::Decimate(int age) {
|
||||
int tooOldFrame = gpuStats.numFlips - age;
|
||||
for (size_t i = 0; i < loadedTextures_.size(); ++i) {
|
||||
if (loadedTextures_[i]->lastFrame_ < tooOldFrame) {
|
||||
loadedTextures_[i]->Free();
|
||||
|
|
|
@ -133,7 +133,7 @@ public:
|
|||
return height_;
|
||||
}
|
||||
|
||||
static void Decimate();
|
||||
static void Decimate(int age = 30);
|
||||
|
||||
private:
|
||||
static std::vector<PPGeImage *> loadedTextures_;
|
||||
|
|
Loading…
Add table
Reference in a new issue