[mythtv] [PATCH] NES Screenshots change
Jason Gabriele
jason.gabriele at gmail.com
Thu Feb 10 16:40:49 UTC 2005
I had trouble getting nes screenshots to show up before I made these
changes. I moved the check for the nes rom name to first, followed by
the check for gamename. Afterwards, if the file isnt found it checks the
database. Most screenshot packs I have seen are labeled by rom name with
the rom name being the one given by goodtools.
I was tempted to remove the database code altogether and make it work
like the other screenshot loaders which try several extensions. However,
with 4 different file names, running through all the extensions would
mean about 32 checks per rom, which I felt was too many. Is anyone using
the database names?
I'm rather new with this so I apoligize for any mistakes made in the
patch. Also I'm getting this error (unrelated to the patch) everytime I
select a different rom.
MythThemedDialog.o: something is requesting a screen update of zero
size. A widget probably has not done a calculateScreeArea(). Will redraw
the whole screen (inefficient!).
--
Jason Gabriele
jason.gabriele at gmail dot com
-------------- next part --------------
Index: nesrominfo.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythgame/mythgame/nesrominfo.cpp,v
retrieving revision 1.2
diff -u -r1.2 nesrominfo.cpp
--- nesrominfo.cpp 14 Oct 2004 04:44:28 -0000 1.2
+++ nesrominfo.cpp 10 Feb 2005 16:28:02 -0000
@@ -5,18 +5,26 @@
bool NesRomInfo::FindImage(QString type, QString* result)
{
- bool retval = false;
-
if (type != "screenshot")
return false;
-
+
+ QString screenLocation = gContext->GetSetting("NesScreensLocation");
+
+ // First, before looking at the DB, just try and see if a screenshot matches the rom name
+ *result = screenLocation + "/" + Romname() + ".gif";
+ if(QFile::exists(*result)) return true;
+
+ // Now just try to match the game name
+ *result = screenLocation + "/" + Gamename() + ".gif";
+ if(QFile::exists(*result)) return true;
+
// Try to match the GoodNES name against the title table in order to get an image
// index that hopefully matches up with the game.
-
- QString thequery;
+
+ QString thequery;
thequery = QString("SELECT screenshot, description FROM nestitle WHERE "
"MATCH(description) AGAINST ('%1');").arg(Gamename());
-
+
QSqlDatabase* db = QSqlDatabase::database();
QSqlQuery query = db->exec(thequery);
if (query.isActive() && query.numRowsAffected() > 0)
@@ -24,28 +32,15 @@
// Take first entry since that will be the most relevant match.
query.first();
QString current = query.value(0).toString();
- *result = gContext->GetSetting("NesScreensLocation") + "/" + current + ".gif";
- retval = QFile::exists(*result);
- if (!retval)
- {
- // Look for file with the same name as the Game
- current = query.value(1).toString();
- *result = gContext->GetSetting("NesScreensLocation") + "/" + current + ".gif";
- retval = QFile::exists(*result);
- }
- else if (!retval)
- {
- // Now just try to match the game name
- *result = gContext->GetSetting("NesScreensLocation") + "/" + Gamename() + ".gif";
- retval = QFile::exists(*result);
- }
- else if (!retval)
- {
- // Now just try to match the game name
- *result = gContext->GetSetting("NesScreensLocation") + "/" + Romname() + ".gif";
- retval = QFile::exists(*result);
- }
+ *result = screenLocation + "/" + current + ".gif";
+ if(QFile::exists(*result)) return true;
+
+ // Look for file with the same name as the Game
+ current = query.value(1).toString();
+ *result = screenLocation + "/" + current + ".gif";
+ if(QFile::exists(*result)) return true;
+
}
- return retval;
+ return false;
}
More information about the mythtv-dev
mailing list