UI: Display save state screenshots as icons.

This way the list is not just a bunch of words, if you have a lot of save
states.  Like me.
This commit is contained in:
Unknown W. Brackets 2016-01-23 11:27:41 -08:00
parent 43218ea953
commit 21a15e4728
2 changed files with 15 additions and 2 deletions

View File

@ -443,6 +443,14 @@ handleELF:
case FILETYPE_PPSSPP_SAVESTATE:
{
// Let's use the screenshot as an icon, too.
std::string screenshotPath = ReplaceAll(gamePath_, ".ppst", ".jpg");
lock_guard guard(info_->lock);
if (File::Exists(screenshotPath)) {
if (readFileToString(false, screenshotPath.c_str(), info_->iconTextureData)) {
info_->iconDataLoaded = true;
}
}
break;
}
@ -709,7 +717,7 @@ again:
void GameInfoCache::SetupTexture(GameInfo *info, std::string &textureData, Thin3DContext *thin3d, Thin3DTexture *&tex, double &loadTime) {
if (textureData.size()) {
if (!tex) {
tex = thin3d->CreateTextureFromFileData((const uint8_t *)textureData.data(), (int)textureData.size(), T3DImageType::PNG);
tex = thin3d->CreateTextureFromFileData((const uint8_t *)textureData.data(), (int)textureData.size(), T3DImageType::DETECT);
if (tex) {
loadTime = time_now_d();
}

View File

@ -84,7 +84,7 @@ public:
root->Add(new TextView(savedata_detail, 0, true, new LinearLayoutParams(Margins(10, 0))));
root->Add(new Spacer(3.0));
} else {
std::string image_path = ReplaceAll(savePath_, "ppst", "jpg");
std::string image_path = ReplaceAll(savePath_, ".ppst", ".jpg");
if (File::Exists(image_path)) {
PrioritizedWorkQueue *wq = g_gameInfoCache.WorkQueue();
toprow->Add(new AsyncImageFileView(image_path, IS_DEFAULT, wq, new UI::LayoutParams(500, 500/16*9)));
@ -182,6 +182,11 @@ void SavedataButton::Draw(UIContext &dc) {
float nw = h * tw / th;
x += (w - nw) / 2.0f;
w = nw;
if (texture->Width() >= w * 2 || texture->Height() >= h * 2) {
// Better to use mipmaps, then. This is probably a large savestate screenshot.
texture->AutoGenMipmaps();
}
}
int txOffset = down_ ? 4 : 0;