mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-02-22 23:22:25 +00:00
Some experimental (disabled) code to have images in gamelist. Too slow, needs work.
This commit is contained in:
parent
c1acc02560
commit
c23631a8fc
@ -24,10 +24,11 @@ extern "C"
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
|
||||
|
||||
BlockDevice *constructBlockDevice(const char *filename) {
|
||||
// Check for CISO
|
||||
FILE *f = fopen(filename, "rb");
|
||||
if (!f)
|
||||
return 0;
|
||||
char buffer[4];
|
||||
auto size = fread(buffer, 1, 4, f); //size_t
|
||||
fclose(f);
|
||||
|
@ -25,7 +25,6 @@
|
||||
#include "Core/FileSystems/ISOFileSystem.h"
|
||||
#include "Core/FileSystems/DirectoryFileSystem.h"
|
||||
|
||||
|
||||
GameInfoCache g_gameInfoCache;
|
||||
|
||||
GameInfoCache::~GameInfoCache()
|
||||
@ -82,14 +81,14 @@ GameInfo *GameInfoCache::GetInfo(const std::string &gamePath, bool wantBG) {
|
||||
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.
|
||||
if (info->iconTexture->LoadPNG((const u8 *)info->iconTextureData.data(), info->iconTextureData.size())) {
|
||||
if (info->iconTexture->LoadPNG((const u8 *)info->iconTextureData.data(), info->iconTextureData.size(), false)) {
|
||||
info->timeIconWasLoaded = time_now_d();
|
||||
}
|
||||
info->iconTextureData.clear();
|
||||
}
|
||||
if (info->bgTextureData.size()) {
|
||||
info->bgTexture = new Texture();
|
||||
if (info->bgTexture->LoadPNG((const u8 *)info->bgTextureData.data(), info->bgTextureData.size())) {
|
||||
if (info->bgTexture->LoadPNG((const u8 *)info->bgTextureData.data(), info->bgTextureData.size(), false)) {
|
||||
info->timeBgWasLoaded = time_now_d();
|
||||
}
|
||||
info->bgTextureData.clear();
|
||||
@ -98,8 +97,6 @@ GameInfo *GameInfoCache::GetInfo(const std::string &gamePath, bool wantBG) {
|
||||
return iter->second;
|
||||
}
|
||||
|
||||
GameInfo *info = new GameInfo();
|
||||
|
||||
// return info;
|
||||
|
||||
// TODO: Everything below here should be asynchronous and run on a thread,
|
||||
@ -109,12 +106,17 @@ GameInfo *GameInfoCache::GetInfo(const std::string &gamePath, bool wantBG) {
|
||||
if (startsWith(gamePath, "ms0:/PSP/GAME")) {
|
||||
return 0;
|
||||
} else {
|
||||
info_[gamePath] = info;
|
||||
SequentialHandleAllocator handles;
|
||||
// Let's assume it's an ISO.
|
||||
// TODO: This will currently read in the whole directory tree. Not really necessary for just a
|
||||
// few files.
|
||||
ISOFileSystem umd(&handles, constructBlockDevice(gamePath.c_str()));
|
||||
BlockDevice *bd = constructBlockDevice(gamePath.c_str());
|
||||
if (!bd)
|
||||
return 0; // nothing to do here..
|
||||
ISOFileSystem umd(&handles, bd);
|
||||
|
||||
GameInfo *info = new GameInfo();
|
||||
|
||||
|
||||
// Alright, let's fetch the PARAM.SFO.
|
||||
std::string paramSFOcontents;
|
||||
@ -128,7 +130,9 @@ GameInfo *GameInfoCache::GetInfo(const std::string &gamePath, bool wantBG) {
|
||||
if (wantBG) {
|
||||
ReadFileToString(&umd, "/PSP_GAME/PIC1.PNG", &info->bgTextureData);
|
||||
}
|
||||
info_[gamePath] = info;
|
||||
return info;
|
||||
}
|
||||
|
||||
return info;
|
||||
return 0;
|
||||
}
|
||||
|
@ -39,6 +39,7 @@ namespace MainWindow {
|
||||
#include "input/input_state.h"
|
||||
#include "math/curves.h"
|
||||
#include "ui/ui.h"
|
||||
#include "ui/ui_context.h"
|
||||
#include "ui_atlas.h"
|
||||
#include "util/random/rng.h"
|
||||
#include "util/text/utf8.h"
|
||||
@ -464,13 +465,15 @@ void DeveloperScreen::render() {
|
||||
|
||||
class FileListAdapter : public UIListAdapter {
|
||||
public:
|
||||
FileListAdapter(const FileSelectScreenOptions &options, const std::vector<FileInfo> *items) : options_(options), items_(items) {}
|
||||
FileListAdapter(const FileSelectScreenOptions &options, const std::vector<FileInfo> *items, UIContext *ctx)
|
||||
: options_(options), items_(items), ctx_(ctx) {}
|
||||
virtual size_t getCount() const { return items_->size(); }
|
||||
virtual void drawItem(int item, int x, int y, int w, int h, bool active) const;
|
||||
|
||||
private:
|
||||
const FileSelectScreenOptions &options_;
|
||||
const std::vector<FileInfo> *items_;
|
||||
const UIContext *ctx_;
|
||||
};
|
||||
|
||||
void FileListAdapter::drawItem(int item, int x, int y, int w, int h, bool selected) const
|
||||
@ -484,16 +487,40 @@ void FileListAdapter::drawItem(int item, int x, int y, int w, int h, bool select
|
||||
if (iter != options_.iconMapping.end())
|
||||
icon = iter->second;
|
||||
}
|
||||
|
||||
int iconSpace = this->itemHeight(item);
|
||||
ui_draw2d.DrawImage2GridH(selected ? I_BUTTON_SELECTED: I_BUTTON, x, y, x + w);
|
||||
ui_draw2d.DrawTextShadow(UBUNTU24, (*items_)[item].name.c_str(), x + UI_SPACE + iconSpace, y + 25, 0xFFFFFFFF, ALIGN_LEFT | ALIGN_VCENTER);
|
||||
|
||||
#if 0
|
||||
// This might create a texture so we must flush first.
|
||||
UIFlush();
|
||||
GameInfo *ginfo = 0;
|
||||
if (!(*items_)[item].isDirectory)
|
||||
ginfo = g_gameInfoCache.GetInfo((*items_)[item].fullName, false);
|
||||
if (ginfo && ginfo->iconTexture) {
|
||||
float scaled_w = h * (144.f / 80.f);
|
||||
UIFlush();
|
||||
ginfo->iconTexture->Bind(0);
|
||||
ui_draw2d.DrawTexRect(x + 10, y, x + 10 + scaled_w, y + h, 0, 0, 1, 1, 0xFFFFFFFF);
|
||||
ui_draw2d.Flush();
|
||||
ctx_->RebindTexture();
|
||||
} else {
|
||||
if (icon != -1)
|
||||
ui_draw2d.DrawImage(icon, x + UI_SPACE, y + 25, 1.0f, 0xFFFFFFFF, ALIGN_VCENTER | ALIGN_LEFT);
|
||||
}
|
||||
#else
|
||||
if (icon != -1)
|
||||
ui_draw2d.DrawImage(icon, x + UI_SPACE, y + 25, 1.0f, 0xFFFFFFFF, ALIGN_VCENTER | ALIGN_LEFT);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
FileSelectScreen::FileSelectScreen(const FileSelectScreenOptions &options) : options_(options) {
|
||||
currentDirectory_ = g_Config.currentDirectory;
|
||||
#ifdef _WIN32
|
||||
// HACK
|
||||
// currentDirectory_ = "E:/PSP ISO/";
|
||||
#endif
|
||||
updateListing();
|
||||
}
|
||||
|
||||
@ -512,7 +539,7 @@ void FileSelectScreen::update(InputState &input_state) {
|
||||
}
|
||||
|
||||
void FileSelectScreen::render() {
|
||||
FileListAdapter adapter(options_, &listing_);
|
||||
FileListAdapter adapter(options_, &listing_, screenManager()->getUIContext());
|
||||
|
||||
UIShader_Prepare();
|
||||
UIBegin(UIShader_Get());
|
||||
|
2
native
2
native
@ -1 +1 @@
|
||||
Subproject commit 7ec766a980dd9f77c407f482d8b570c43f35461c
|
||||
Subproject commit 5bdd4bd6631290d86b82fb99b26aefda6b73c64d
|
Loading…
x
Reference in New Issue
Block a user