[Scummvm-git-logs] scummvm master -> 95f8fc121817721ac4298295009453279010bd66

SupSuper noreply at scummvm.org
Fri Apr 1 07:11:28 UTC 2022


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
95f8fc1218 GUI: Handle grid fallback icons more gracefully


Commit: 95f8fc121817721ac4298295009453279010bd66
    https://github.com/scummvm/scummvm/commit/95f8fc121817721ac4298295009453279010bd66
Author: SupSuper (supsuper at gmail.com)
Date: 2022-04-01T08:11:03+01:00

Commit Message:
GUI: Handle grid fallback icons more gracefully

Always use the full ID as thumbPath

Changed paths:
    gui/widgets/grid.cpp
    gui/widgets/grid.h


diff --git a/gui/widgets/grid.cpp b/gui/widgets/grid.cpp
index 01b94dc6c43..bb26d878045 100644
--- a/gui/widgets/grid.cpp
+++ b/gui/widgets/grid.cpp
@@ -572,28 +572,26 @@ void GridWidget::setGroupHeaderFormat(const Common::U32String &prefix, const Com
 void GridWidget::reloadThumbnails() {
 	for (Common::Array<GridItemInfo *>::iterator iter = _visibleEntryList.begin(); iter != _visibleEntryList.end(); ++iter) {
 		GridItemInfo *entry = *iter;
-		if (entry->isHeader)
+		if (entry->thumbPath.empty())
 			continue;
-		Graphics::ManagedSurface *surf = nullptr;
-		Common::String path = Common::String::format("icons/%s-%s.png", entry->engineid.c_str(), entry->gameid.c_str());
-		if (!_loadedSurfaces.contains(path)) {
-			surf = loadSurfaceFromFile(path);
-			_loadedSurfaces[path] = surf;
+
+		if (!_loadedSurfaces.contains(entry->thumbPath)) {
+			Common::String path = Common::String::format("icons/%s-%s.png", entry->engineid.c_str(), entry->gameid.c_str());
+			Graphics::ManagedSurface *surf = loadSurfaceFromFile(path);
 			if (!surf) {
 				path = Common::String::format("icons/%s.png", entry->engineid.c_str());
-				if (!_loadedSurfaces.contains(path)) {
-					surf = loadSurfaceFromFile(path);
-					_loadedSurfaces[path] = surf;
-				}
+				surf = loadSurfaceFromFile(path);
 			}
-		}
-		entry->thumbPath = path;
-		if (surf) {
-			const Graphics::ManagedSurface *scSurf(scaleGfx(surf, _thumbnailWidth, 512, true));
-			_loadedSurfaces[path] = scSurf;
-			if (surf != scSurf) {
-				surf->free();
-				delete surf;
+
+			if (surf) {
+				const Graphics::ManagedSurface *scSurf(scaleGfx(surf, _thumbnailWidth, 512, true));
+				_loadedSurfaces[entry->thumbPath] = scSurf;
+				if (surf != scSurf) {
+					surf->free();
+					delete surf;
+				}
+			} else {
+				_loadedSurfaces[entry->thumbPath] = nullptr;
 			}
 		}
 	}
diff --git a/gui/widgets/grid.h b/gui/widgets/grid.h
index f597670a6eb..ba9da46a212 100644
--- a/gui/widgets/grid.h
+++ b/gui/widgets/grid.h
@@ -63,10 +63,12 @@ struct GridItemInfo {
 	GridItemInfo(int id, const Common::String &eid, const Common::String &gid
 		,const Common::String &t, Common::Language l, Common::Platform p)
 		: entryID(id), gameid(gid), engineid(eid), title(t), language(l), platform(p), isHeader(false) {
+		thumbPath = Common::String::format("icons/%s-%s.png", engineid.c_str(), gameid.c_str());
 	}
 
 	GridItemInfo(const Common::String &groupHeader, int groupID) : title(groupHeader), isHeader(true),
 		entryID(groupID), language(Common::UNK_LANG), platform(Common::kPlatformUnknown) {
+		thumbPath = Common::String("");
 	}
 };
 




More information about the Scummvm-git-logs mailing list