GUI: Create subdirs for flags and platforms in icon dir

This commit is contained in:
av-dx 2021-07-13 20:26:07 +05:30 committed by Eugene Sandulenko
parent ffef874a96
commit 752e4414c8

View file

@ -258,10 +258,11 @@ void GridItemTray::handleMouseMoved(int x, int y, int button) {
Graphics::ManagedSurface *loadSurfaceFromFile(const Common::String &name) { Graphics::ManagedSurface *loadSurfaceFromFile(const Common::String &name) {
Graphics::ManagedSurface *surf = nullptr; Graphics::ManagedSurface *surf = nullptr;
const Graphics::Surface *srcSurface = nullptr; const Graphics::Surface *srcSurface = nullptr;
const String path = String::format("%s/%s", ConfMan.get("iconpath").c_str(), name.c_str());
if (name.hasSuffix(".png")) { if (name.hasSuffix(".png")) {
#ifdef USE_PNG #ifdef USE_PNG
Image::PNGDecoder decoder; Image::PNGDecoder decoder;
Common::FSNode fileNode(name); Common::FSNode fileNode(path);
Common::SeekableReadStream *stream = fileNode.createReadStream(); Common::SeekableReadStream *stream = fileNode.createReadStream();
if (stream) { if (stream) {
if (!decoder.loadStream(*stream)) if (!decoder.loadStream(*stream))
@ -282,7 +283,7 @@ Graphics::ManagedSurface *loadSurfaceFromFile(const Common::String &name) {
#endif #endif
} else if (name.hasSuffix(".svg")) { } else if (name.hasSuffix(".svg")) {
Graphics::SVGBitmap *image = nullptr; Graphics::SVGBitmap *image = nullptr;
Common::FSNode fileNode(name); Common::FSNode fileNode(path);
Common::SeekableReadStream *stream = fileNode.createReadStream(); Common::SeekableReadStream *stream = fileNode.createReadStream();
if (stream) { if (stream) {
image = new Graphics::SVGBitmap(stream); image = new Graphics::SVGBitmap(stream);
@ -352,11 +353,9 @@ GridWidget::~GridWidget() {
} }
const Graphics::ManagedSurface *GridWidget::filenameToSurface(const String &name) { const Graphics::ManagedSurface *GridWidget::filenameToSurface(const String &name) {
String path = String::format("%s/%s", _iconDir.c_str(), name.c_str());
for (Common::Array<GridItemInfo>::iterator l = _visibleEntries.begin(); l!=_visibleEntries.end(); ++l) { for (Common::Array<GridItemInfo>::iterator l = _visibleEntries.begin(); l!=_visibleEntries.end(); ++l) {
if (l->thumbPath == name) { if (l->thumbPath == name) {
return _loadedSurfaces[path]; return _loadedSurfaces[name];
} }
} }
return nullptr; return nullptr;
@ -418,19 +417,17 @@ void GridWidget::reloadThumbnails() {
Graphics::ManagedSurface *surf = nullptr; Graphics::ManagedSurface *surf = nullptr;
String gameid; String gameid;
String engineid; String engineid;
String path;
for (Common::Array<GridItemInfo>::iterator iter = _visibleEntries.begin(); iter != _visibleEntries.end(); ++iter) { for (Common::Array<GridItemInfo>::iterator iter = _visibleEntries.begin(); iter != _visibleEntries.end(); ++iter) {
path = String::format("%s/%s", _iconDir.c_str(), iter->thumbPath.c_str()); if (!_loadedSurfaces.contains(iter->thumbPath)) {
if (!_loadedSurfaces.contains(path)) { surf = loadSurfaceFromFile(iter->thumbPath);
surf = loadSurfaceFromFile(path);
if (surf) { if (surf) {
const Graphics::ManagedSurface *scSurf(scaleGfx(surf, _thumbnailWidth, 512)); const Graphics::ManagedSurface *scSurf(scaleGfx(surf, _thumbnailWidth, 512));
_loadedSurfaces[path] = scSurf; _loadedSurfaces[iter->thumbPath] = scSurf;
surf->free(); surf->free();
delete surf; delete surf;
} else { } else {
_loadedSurfaces[path] = nullptr; _loadedSurfaces[iter->thumbPath] = nullptr;
} }
} }
} }
@ -439,7 +436,7 @@ void GridWidget::reloadThumbnails() {
void GridWidget::loadFlagIcons() { void GridWidget::loadFlagIcons() {
const Common::LanguageDescription *l = Common::g_languages; const Common::LanguageDescription *l = Common::g_languages;
for (; l->code; ++l) { for (; l->code; ++l) {
String path = String::format("%s/%s.svg", _iconDir.c_str(), l->code); String path = String::format("flags/%s.svg", l->code);
Graphics::ManagedSurface *gfx = loadSurfaceFromFile(path); Graphics::ManagedSurface *gfx = loadSurfaceFromFile(path);
if (gfx) { if (gfx) {
const Graphics::ManagedSurface *scGfx = scaleGfx(gfx, 32, 32); const Graphics::ManagedSurface *scGfx = scaleGfx(gfx, 32, 32);
@ -455,7 +452,7 @@ void GridWidget::loadFlagIcons() {
void GridWidget::loadPlatformIcons() { void GridWidget::loadPlatformIcons() {
const Common::PlatformDescription *l = Common::g_platforms; const Common::PlatformDescription *l = Common::g_platforms;
for (; l->abbrev; ++l) { for (; l->abbrev; ++l) {
String path = String::format("%s/%s.png", _iconDir.c_str(), l->abbrev); String path = String::format("platforms/%s.png", l->abbrev);
Graphics::ManagedSurface *gfx = loadSurfaceFromFile(path); Graphics::ManagedSurface *gfx = loadSurfaceFromFile(path);
if (gfx) { if (gfx) {
const Graphics::ManagedSurface *scGfx = scaleGfx(gfx, 32, 32); const Graphics::ManagedSurface *scGfx = scaleGfx(gfx, 32, 32);