Add ZIP icon in games browser.

This one's from Gnome, license should be OK.
This commit is contained in:
Henrik Rydgård 2013-12-11 15:11:27 +01:00
parent 868a3d6dd5
commit 42f5bcb263
4 changed files with 29 additions and 20 deletions

View File

@ -360,7 +360,7 @@ void __IoSyncNotify(u64 userdata, int cyclesLate) {
if (ioManager.WaitResult(f->handle, managerResult)) {
result = managerResult;
} else {
ERROR_LOG(SCEIO, "Unable to complete IO operation.");
ERROR_LOG(SCEIO, "Unable to complete IO operation on %s", f->GetName());
}
HLEKernel::ResumeFromWait(threadID, WAITTYPE_IO, fd, result);

View File

@ -65,6 +65,12 @@ bool GameInfo::DeleteGame() {
g_Config.CleanRecent();
return true;
}
case FILETYPE_PSP_ELF:
{
const char *fileToRemove = fileInfo.fullName.c_str();
deleteFile(fileToRemove);
return true;
}
default:
return false;
@ -273,9 +279,7 @@ public:
lock_guard lock(info_->lock);
if (pbp.GetSubFileSize(PBP_ICON0_PNG) > 0) {
pbp.GetSubFileAsString(PBP_ICON0_PNG, &info_->iconTextureData);
printf("a %s\n", info_->path.c_str());
} else {
printf("b %s\n", info_->path.c_str());
// Read standard icon
size_t sz;
DEBUG_LOG(LOADER, "Loading unknown.png because a PBP was missing an icon");
@ -370,18 +374,30 @@ handleELF:
break;
}
case FILETYPE_NORMAL_DIRECTORY:
info_->title = gamePath_;
case FILETYPE_ARCHIVE_ZIP:
info_->title = getFilename(filename);
info_->paramSFOLoaded = true;
info_->wantBG = false;
{
// Read standard icon
size_t sz;
uint8_t *contents = VFSReadFile("zip.png", &sz);
if (contents) {
lock_guard lock(info_->lock);
info_->iconTextureData = std::string((const char *)contents, sz);
}
delete [] contents;
}
break;
case FILETYPE_ARCHIVE_RAR:
// TODO: Set archive icon
case FILETYPE_NORMAL_DIRECTORY:
default:
{
std::string fn, ext;
SplitPath(gamePath_, 0, &fn, &ext);
// ext includes the dot
info_->title = fn + ext;
}
break;
info_->title = getFilename(gamePath_);
info_->paramSFOLoaded = true;
info_->wantBG = false;
break;
}
// probably only want these when we ask for the background image...
// should maybe flip the flag to "onlyIcon"
@ -481,10 +497,6 @@ void GameInfoCache::FlushBGs() {
}
}
void GameInfoCache::Add(const std::string &key, GameInfo *info_) {
}
// This may run off-main-thread and we thus can't use the global
// pspFileSystem (well, we could with synchronization but there might not
// even be a game running).
@ -500,9 +512,8 @@ GameInfo *GameInfoCache::GetInfo(const std::string &gamePath, bool wantBG, bool
{
lock_guard lock(info->lock);
if (info->iconTextureData.size()) {
info->iconTexture = new Texture();
// TODO: We could actually do the PNG decoding as well on the async thread.
// We'd have to split up Texture->LoadPNG though, creating some intermediate Image class maybe.
info->iconTexture = new Texture();
if (info->iconTexture->LoadPNG((const u8 *)info->iconTextureData.data(), info->iconTextureData.size(), false)) {
info->timeIconWasLoaded = time_now_d();
} else {

View File

@ -123,8 +123,6 @@ public:
void Save();
void Load();
void Add(const std::string &key, GameInfo *info_);
private:
// Maps ISO path to info.
std::map<std::string, GameInfo *> info_;

BIN
assets/zip.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB