From ba51197927ca0a3b86578808247ca5c786ffe196 Mon Sep 17 00:00:00 2001 From: Thomas Jentzsch Date: Fri, 15 Jul 2022 11:11:56 +0200 Subject: [PATCH] added if loading by ROM property name fails, try ROM file name (fixes #911) --- src/gui/RomInfoWidget.cxx | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/gui/RomInfoWidget.cxx b/src/gui/RomInfoWidget.cxx index 3ae305082..4ead37fb3 100644 --- a/src/gui/RomInfoWidget.cxx +++ b/src/gui/RomInfoWidget.cxx @@ -109,18 +109,22 @@ void RomInfoWidget::parseProperties(const FSNode& node) myRomInfo.clear(); #ifdef PNG_SUPPORT - // Get a valid filename representing a snapshot file for this rom - const string& filename = instance().snapshotLoadDir().getPath() + - myProperties.get(PropType::Cart_Name) + ".png"; + // Get a valid filename representing a snapshot file for this rom and load the snapshot + const string& path = instance().snapshotLoadDir().getPath(); - // Read the PNG file - mySurfaceIsValid = loadPng(filename); + // 1. Try to load snapshot by property name + mySurfaceIsValid = loadPng(path + myProperties.get(PropType::Cart_Name) + ".png"); - // Try to load a default image if not ROM image exists if(!mySurfaceIsValid) { - mySurfaceIsValid = loadPng(instance().snapshotLoadDir().getPath() + - "default_snapshot.png"); + // 2. If no snapshot with property name exists, try to load snapshot image by filename + mySurfaceIsValid = loadPng(path + node.getNameWithExt("") + ".png"); + + if(!mySurfaceIsValid) + { + // 3. If no ROM snapshot exists, try to load a default snapshot + mySurfaceIsValid = loadPng(path + "default_snapshot.png"); + } } #else mySurfaceErrorMsg = "PNG image loading not supported";