Index: mythtv/themes/Terra/game-ui.xml
===================================================================
--- mythtv/themes/Terra/game-ui.xml (revision 0)
+++ mythtv/themes/Terra/game-ui.xml (revision 0)
@@ -0,0 +1,109 @@
+
+
+
+
+
+
+
+
+
+
+ 8,52,1264,375
+ 3
+ 10
+
+ 0,0,1264,375
+ vertical
+ 0,0,100%,97%
+
+
+ 0,0,100%,30
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 880,448,300,196
+
+
+
+ 25,448,300,196
+ true
+
+
+
+
+
Index: mythplugins/mythgame/theme/default/game-ui.xml
===================================================================
--- mythplugins/mythgame/theme/default/game-ui.xml (revision 20745)
+++ mythplugins/mythgame/theme/default/game-ui.xml (working copy)
@@ -1,25 +1,11 @@
-
+
-
- #ffffff
- 18
- yes
-
+
+ 0,0,800,600
+
-
- #9999cc
- 18
- yes
-
-
-
- #8cdeff
- 18
- yes
-
-
#ffffff
#000000
@@ -33,111 +19,305 @@
20
yes
-
-
-
- background.png
- 0,10
-
-
- trans-titles.png
- 0,10
-
-
- pf-top.png
- 26,350
-
-
-
-
+
+
0,10,800,310
-
- 40,10,720,270
-
-
-
-
-
-
- 30,16,190,250
-
-
-
-
-
-
- 235,10,535,270
-
-
-
-
-
-
+ 2
+ 10
+
+
-
- showings.png
- 0,0
-
-
-
-
- 25,355,750,220
-
-
-
-
- 153,75,500,35
+
+ 178,430,500,35
infofont
-
+
-
- 13,110,150,35
+
+ 38,465,150,35
infofont
Year:
-
+
-
- 153,110,500,35
+
+ 178,465,500,35
infofont
-
+
-
- 13,140,150,35
+
+ 38,495,150,35
infofont
Genre:
-
+
-
- 153,140,500,35
+
+ 178,495,500,35
infofont
-
+
-
- 13,170,150,35
+
+ 38,525,150,35
infofont
Favorite:
-
+
-
- 153,170,500,35
+
+ 178,525,500,35
infofont
-
+
-
- 535,25
- 180,150
-
-
-
+
+ 600,420,180,150
+
+
+
+ 410,420,180,150
+ true
+
+
+
+
+
+ 10,50,1260,50
+ Edit Game Information
+ hcenter,vcenter
+ baselarge
+
+
+
+
+
+ 250,110,250,40
+ Game Name:
+ right,top
+
+
+
+ 250,155,250,40
+ Genre:
+ right,top
+
+
+
+ 250,200,250,40
+ Year:
+ right,top
+
+
+
+ 250,245,250,40
+ Country:
+ right,top
+
+
+
+ 250,290,250,40
+ Publisher:
+ right,top
+
+
+
+ 250,335,250,40
+ Favorite:
+ right,top
+
+
+
+ 250,380,250,40
+ Fanart:
+ right,top
+
+
+
+ 250,425,250,40
+ Boxart:
+ right,top
+
+
+
+
+
+ 510,100
+
+
+
+ 510,145
+
+
+
+ 510,190
+
+
+
+ 510,235
+
+
+
+ 510,280
+
+
+
+ 510,330
+
+
+
+
+
+ 550,375,250,40
+ /path/to/the/thing.jpg
+
+
+
+
+
+ 550,420,250,40
+ /path/to/the/thing.jpg
+
+
+
+
+
+
+
+
+
+ 0,0,800,600
+
+
+
+ 40,60,140,40
+ Game:
+ right
+
+
+
+ 190,60,570,40
+
+
+
+ 40,100,140,40
+ Type:
+ right
+
+
+
+ 190,100,570,40
+
+
+
+ 40,140,140,40
+ Filename:
+ right
+
+
+
+ 190,140,570,40
+
+
+
+ 40,180,140,40
+ Rompath:
+ right
+
+
+
+ 190,180,570,40
+
+
+
+ 40,220,140,40
+ System(s):
+ right
+
+
+
+ 190,220,570,40
+
+
+
+ 40,260,140,40
+ Genre:
+ right
+
+
+
+ 190,260,570,40
+
+
+
+ 40,300,140,40
+ Year:
+ right
+
+
+
+ 190,300,400,40
+
+
+
+ 40,340,140,40
+ Country:
+ right
+
+
+
+ 190,340,400,40
+
+
+
+ 40,380,140,40
+ Publisher:
+ right
+
+
+
+ 190,380,400,40
+
+
+
+ 40,420,140,40
+ CRC:
+ right
+
+
+
+ 190,420,400,40
+
+
+
+ 600,300,180,150
+ true
+
+
+
+
+
+
+
+
Index: mythplugins/mythgame/theme/default-wide/game-ui.xml
===================================================================
--- mythplugins/mythgame/theme/default-wide/game-ui.xml (revision 20745)
+++ mythplugins/mythgame/theme/default-wide/game-ui.xml (working copy)
@@ -1,25 +1,11 @@
-
+
-
- #ffffff
- 18
- yes
-
+
+ 0,0,1280,720
+
-
- #9999cc
- 18
- yes
-
-
-
- #8cdeff
- 18
- yes
-
-
#ffffff
#000000
@@ -34,112 +20,311 @@
yes
-
-
- background.png
- 0,48
-
-
- trans-titles.png
- 0,50
- 280,315
-
-
- pf-top.png
- 64,412
-
-
-
-
+
8,52,1264,310
-
- 32,0,1200,296
-
-
-
-
-
-
- 56,28,288,271
-
-
-
-
-
-
- 384,0,816,296
-
-
-
-
-
-
+ 3
+ 10
+
+
-
- showings.png
- 20,10
- 1200,310
-
-
-
-
- 64,412,1152,260
-
-
- 32,28,752,60
+
+ 96,440,752,60
largetitle
-
+
-
- 32,98,140,35
+
+ 96,510,140,35
infofont
System:
-
+
-
- 172,98,580,35
+
+ 236,510,580,35
infofont
-
+
-
- 32,133,140,35
+
+ 96,545,140,35
infofont
Year:
-
+
-
- 172,133,580,35
+
+ 236,545,580,35
infofont
-
+
-
- 32,168,140,35
+
+ 96,580,140,35
infofont
Genre:
-
+
-
- 172,168,580,35
+
+ 236,580,580,35
infofont
-
+
-
- 32,203,140,35
+
+ 96,615,140,35
infofont
Favorite:
-
+
-
- 172,203,580,35
+
+ 236,615,580,35
infofont
-
+
-
- 816,36
- 300,196
-
-
-
+
+ 610,500,180,150
+ true
+
+
+
+ 880,500,300,196
+
+
+
+
+
+ 0,0,1280,720
+
+
+
+ 10,50,1260,50
+ Game Information
+ hcenter,vcenter
+ baselarge
+
+
+
+ 40,160,140,40
+ Game:
+ right
+
+
+
+ 190,160,570,40
+
+
+
+ 40,200,140,40
+ Type:
+ right
+
+
+
+ 190,200,570,40
+
+
+
+ 40,240,140,40
+ Filename:
+ right
+
+
+
+ 190,240,570,40
+
+
+
+ 40,280,140,40
+ Rompath:
+ right
+
+
+
+ 190,280,570,40
+
+
+
+ 40,320,140,40
+ System(s):
+ right
+
+
+
+ 190,320,570,40
+
+
+
+ 40,360,140,40
+ Genre:
+ right
+
+
+
+ 190,360,570,40
+
+
+
+ 40,400,140,40
+ Year:
+ right
+
+
+
+ 190,400,400,40
+
+
+
+ 40,440,140,40
+ Country:
+ right
+
+
+
+ 190,440,400,40
+
+
+
+ 40,480,140,40
+ Publisher:
+ right
+
+
+
+ 190,480,400,40
+
+
+
+ 40,520,140,40
+ CRC:
+ right
+
+
+
+ 190,520,400,40
+
+
+
+ 800,200,415,320
+ true
+
+
+
+
+
+
+
+
+
+
+
+ 10,50,1260,50
+ Edit Game Information
+ hcenter,vcenter
+ baselarge
+
+
+
+
+
+ 250,110,250,40
+ Game Name:
+ right,top
+
+
+
+ 250,155,250,40
+ Genre:
+ right,top
+
+
+
+ 250,200,250,40
+ Year:
+ right,top
+
+
+
+ 250,245,250,40
+ Country:
+ right,top
+
+
+
+ 250,290,250,40
+ Publisher:
+ right,top
+
+
+
+ 250,335,250,40
+ Favorite:
+ right,top
+
+
+
+ 250,380,250,40
+ Fanart:
+ right,top
+
+
+
+ 250,425,250,40
+ Boxart:
+ right,top
+
+
+
+
+
+ 510,100
+
+
+
+ 510,145
+
+
+
+ 510,190
+
+
+
+ 510,235
+
+
+
+ 510,280
+
+
+
+ 510,330
+
+
+
+
+
+ 550,375,750,40
+ /path/to/the/thing.jpg
+
+
+
+
+
+ 550,420,750,40
+ /path/to/the/thing.jpg
+
+
+
+
+
+
Index: mythplugins/mythgame/mythgame/romedit.cpp
===================================================================
--- mythplugins/mythgame/mythgame/romedit.cpp (revision 20745)
+++ mythplugins/mythgame/mythgame/romedit.cpp (working copy)
@@ -1,99 +1,234 @@
-#include
+#include
+#include
#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
#include "romedit.h"
+#include "rominfo.h"
-class Gamename : public LineEditSetting, public GenericDBStorage
+EditRomInfoDialog::EditRomInfoDialog(MythScreenStack *parent,
+ QString name, RomInfo *romInfo) : MythScreenType(parent, name),
+ m_id(""), m_retObject(0), m_gamenameEdit(0), m_genreEdit(0),
+ m_yearEdit(0), m_countryEdit(0), m_publisherEdit(0), m_favoriteCheck(0),
+ m_fanartButton(0), m_fanartText(0), m_boxartButton(0), m_boxartText(0),
+ m_doneButton(0)
{
- public:
- Gamename(const QString &romname) :
- LineEditSetting(this), GenericDBStorage(
- this, "gamemetadata", "gamename", "romname", romname)
- {
- setLabel(QObject::tr("Game Name"));
- setHelpText(QObject::tr("Friendly name of this Game."));
- }
-};
+ m_workingRomInfo = new RomInfo(*romInfo);
+}
-class Genre : public LineEditSetting, public GenericDBStorage
+EditRomInfoDialog::~EditRomInfoDialog()
{
- public:
- Genre(const QString &romname) :
- LineEditSetting(this), GenericDBStorage(
- this, "gamemetadata", "genre", "romname", romname)
+ delete m_workingRomInfo;
+}
+
+bool EditRomInfoDialog::Create()
+{
+ if (!LoadWindowFromXML("game-ui.xml", "edit_metadata", this))
+ return false;
+
+ bool err = false;
+ UIUtilE::Assign(this, m_gamenameEdit, "gamename_edit", &err);
+ UIUtilE::Assign(this, m_genreEdit, "genre_edit", &err);
+ UIUtilE::Assign(this, m_yearEdit, "year_edit", &err);
+ UIUtilE::Assign(this, m_countryEdit, "country_edit", &err);
+ UIUtilE::Assign(this, m_publisherEdit, "publisher_edit", &err);
+
+ UIUtilE::Assign(this, m_favoriteCheck, "favorite_check", &err);
+
+ UIUtilE::Assign(this, m_fanartButton, "fanart_button", &err);
+ UIUtilE::Assign(this, m_fanartText, "fanart_text", &err);
+ UIUtilE::Assign(this, m_boxartButton, "boxart_button", &err);
+ UIUtilE::Assign(this, m_boxartText, "boxart_text", &err);
+
+ UIUtilE::Assign(this, m_doneButton, "done_button", &err);
+
+ if (err)
{
- setLabel(QObject::tr("Genre"));
- setHelpText(QObject::tr("Genre/Category this game falls under."));
+ VERBOSE(VB_IMPORTANT, "Cannot load screen 'edit_metadata'");
+ return false;
}
-};
-class Year : public LineEditSetting, public GenericDBStorage
+ fillWidgets();
+
+ if (!BuildFocusList())
+ VERBOSE(VB_IMPORTANT, "Failed to build a focuslist.");
+
+ connect(m_gamenameEdit, SIGNAL(valueChanged()), SLOT(SetGamename()));
+ connect(m_genreEdit, SIGNAL(valueChanged()), SLOT(SetGenre()));
+ connect(m_yearEdit, SIGNAL(valueChanged()), SLOT(SetYear()));
+ connect(m_countryEdit, SIGNAL(valueChanged()), SLOT(SetCountry()));
+ connect(m_publisherEdit, SIGNAL(valueChanged()), SLOT(SetPublisher()));
+
+ connect(m_favoriteCheck, SIGNAL(valueChanged()), SLOT(ToggleFavorite()));
+
+ connect(m_fanartButton, SIGNAL(Clicked()), SLOT(FindFanart()));
+ connect(m_boxartButton, SIGNAL(Clicked()), SLOT(FindBoxart()));
+
+ connect(m_doneButton, SIGNAL(Clicked()), SLOT(SaveAndExit()));
+
+ return true;
+}
+
+namespace
{
- public:
- Year(const QString &romname) :
- LineEditSetting(this), GenericDBStorage(
- this, "gamemetadata", "year", "romname", romname)
+ QStringList GetSupportedImageExtensionFilter()
{
- setLabel(QObject::tr("Year"));
- setHelpText(QObject::tr("The Year the game was released."));
+ QStringList ret;
+
+ QList exts = QImageReader::supportedImageFormats();
+ for (QList::iterator p = exts.begin(); p != exts.end(); ++p)
+ {
+ ret.append(QString("*.").append(*p));
+ }
+
+ return ret;
}
-};
-class Country : public LineEditSetting, public GenericDBStorage
-{
- public:
- Country(const QString &romname) :
- LineEditSetting(this), GenericDBStorage(
- this, "gamemetadata", "country", "romname", romname)
+ void FindImagePopup(const QString &prefix, const QString &prefixAlt,
+ QObject &inst, const QString &returnEvent)
{
- setLabel(QObject::tr("Country"));
- setHelpText(QObject::tr("The Country this game was "
- "originally distributed in."));
+ QString fp = prefix.isEmpty() ? prefixAlt : prefix;
+
+ MythScreenStack *popupStack =
+ GetMythMainWindow()->GetStack("popup stack");
+
+ MythUIFileBrowser *fb = new MythUIFileBrowser(popupStack, fp);
+ fb->SetNameFilter(GetSupportedImageExtensionFilter());
+ if (fb->Create())
+ {
+ fb->SetReturnEvent(&inst, returnEvent);
+ popupStack->AddScreen(fb);
+ }
+ else
+ delete fb;
}
-};
-class Publisher : public LineEditSetting, public GenericDBStorage
+ const QString CEID_FANARTFILE = "fanartfile";
+ const QString CEID_BOXARTFILE = "boxartfile";
+}
+
+void EditRomInfoDialog::customEvent(QEvent *event)
{
- public:
- Publisher(const QString &romname) :
- LineEditSetting(this), GenericDBStorage(
- this, "gamemetadata", "publisher", "romname", romname)
+ if (event->type() == kMythDialogBoxCompletionEventType)
{
- setLabel(QObject::tr("Publisher"));
- setHelpText(QObject::tr("The Company that made and "
- "published this game."));
+ DialogCompletionEvent *dce =
+ dynamic_cast(event);
+
+ if (!dce)
+ return;
+
+ const QString resultid = dce->GetId();
+
+ if (resultid == CEID_FANARTFILE)
+ SetFanart(dce->GetResultText());
+ else if (resultid == CEID_BOXARTFILE)
+ SetBoxart(dce->GetResultText());
}
-};
+}
+void EditRomInfoDialog::fillWidgets()
+{
+ m_gamenameEdit->SetText(m_workingRomInfo->Gamename());
+ m_genreEdit->SetText(m_workingRomInfo->Genre());
+ m_yearEdit->SetText(m_workingRomInfo->Year());
+ m_countryEdit->SetText(m_workingRomInfo->Country());
+ m_publisherEdit->SetText(m_workingRomInfo->Publisher());
-class Favourite : public CheckBoxSetting, public GenericDBStorage
+ if (m_workingRomInfo->Favorite())
+ m_favoriteCheck->SetCheckState(MythUIStateType::Full);
+
+ m_fanartText->SetText(m_workingRomInfo->Fanart());
+ m_boxartText->SetText(m_workingRomInfo->Boxart());
+}
+
+void EditRomInfoDialog::SetReturnEvent(QObject *retobject,
+ const QString &resultid)
{
- public:
- Favourite(const QString &romname) :
- CheckBoxSetting(this), GenericDBStorage(
- this, "gamemetadata", "favorite", "romname", romname)
+ m_retObject = retobject;
+ m_id = resultid;
+}
+
+void EditRomInfoDialog::SaveAndExit()
+{
+ if (m_retObject)
{
- setLabel(QObject::tr("Favorite"));
- setHelpText(QObject::tr("ROM status as a Favorite"));
+ RomInfo *romInfo = new RomInfo(*m_workingRomInfo);
+ DialogCompletionEvent *dce =
+ new DialogCompletionEvent(m_id, 0, "",
+ qVariantFromValue(romInfo));
+
+ QApplication::postEvent(m_retObject, dce);
}
-};
+ Close();
+}
-GameEditDialog::GameEditDialog(const QString &romname)
+void EditRomInfoDialog::SetGamename()
{
- QString title = QObject::tr("Editing Metadata - ") + romname;
+ m_workingRomInfo->setGamename(m_gamenameEdit->GetText());
+}
- VerticalConfigurationGroup *group =
- new VerticalConfigurationGroup(false);
+void EditRomInfoDialog::SetGenre()
+{
+ m_workingRomInfo->setGenre(m_genreEdit->GetText());
+}
- group->setLabel(title);
- group->addChild(new Gamename(romname));
- group->addChild(new Genre(romname));
- group->addChild(new Year(romname));
- group->addChild(new Country(romname));
- group->addChild(new Publisher(romname));
- group->addChild(new Favourite(romname));
- addChild(group);
+void EditRomInfoDialog::SetYear()
+{
+ m_workingRomInfo->setYear(m_yearEdit->GetText());
}
+void EditRomInfoDialog::SetCountry()
+{
+ m_workingRomInfo->setCountry(m_countryEdit->GetText());
+}
+void EditRomInfoDialog::SetPublisher()
+{
+ m_workingRomInfo->setPublisher(m_publisherEdit->GetText());
+}
+
+void EditRomInfoDialog::ToggleFavorite()
+{
+ m_workingRomInfo->setFavorite();
+}
+
+void EditRomInfoDialog::FindFanart()
+{
+ FindImagePopup(gContext->GetSetting("mythgame.fanartDir"),
+ GetConfDir() + "/MythGame/Fanart",
+ *this, CEID_FANARTFILE);
+}
+
+void EditRomInfoDialog::FindBoxart()
+{
+ FindImagePopup(gContext->GetSetting("mythgame.boxartDir"),
+ GetConfDir() + "/MythGame/Boxart",
+ *this, CEID_BOXARTFILE);
+}
+
+void EditRomInfoDialog::SetFanart(QString file)
+{
+ if (file.isEmpty())
+ return;
+
+ m_workingRomInfo->setFanart(file);
+ m_fanartText->SetText(file);
+}
+
+void EditRomInfoDialog::SetBoxart(QString file)
+{
+ if (file.isEmpty())
+ return;
+
+ m_workingRomInfo->setBoxart(file);
+ m_boxartText->SetText(file);
+}
Index: mythplugins/mythgame/mythgame/gamehandler.cpp
===================================================================
--- mythplugins/mythgame/mythgame/gamehandler.cpp (revision 20745)
+++ mythplugins/mythgame/mythgame/gamehandler.cpp (working copy)
@@ -149,7 +149,8 @@
void GameHandler::GetMetadata(GameHandler *handler, QString rom, QString* Genre, QString* Year,
QString* Country, QString* CRC32, QString* GameName,
- QString *Publisher, QString *Version)
+ QString *Publisher, QString *Version, QString* Fanart,
+ QString* Boxart)
{
QString key;
QString tmpcrc;
@@ -165,6 +166,8 @@
*Genre = QObject::tr("Unknown");
*Publisher = QObject::tr("Unknown");
*Version = QObject::tr("0");
+ *Fanart = QObject::tr("");
+ *Boxart = QObject::tr("");
if (*CRC32 != "")
{
@@ -411,6 +414,8 @@
QString Year;
QString Publisher;
QString Version;
+ QString Fanart;
+ QString Boxart;
int removalprompt = gContext->GetSetting("GameRemovalPrompt").toInt();
int indepth = gContext->GetSetting("GameDeepScan").toInt();
@@ -423,7 +428,7 @@
if (indepth)
{
GetMetadata(handler, iter.data().RomFullPath(), &Genre, &Year, &Country, &CRC32, &GameName,
- &Publisher, &Version);
+ &Publisher, &Version, &Fanart, &Boxart);
}
else
{
@@ -434,6 +439,8 @@
GameName = QObject::tr("Unknown");
Publisher = QObject::tr("Unknown");
Version = QObject::tr("0");
+ Fanart = QObject::tr("");
+ Boxart = QObject::tr("");
}
if (GameName == QObject::tr("Unknown"))
@@ -446,9 +453,10 @@
query.prepare("INSERT INTO gamemetadata "
"(system, romname, gamename, genre, year, gametype, "
"rompath, country, crc_value, diskcount, display, "
- "publisher, version) "
+ "publisher, version, fanart, boxart) "
"VALUES (:SYSTEM, :ROMNAME, :GAMENAME, :GENRE, :YEAR, "
- ":GAMETYPE, :ROMPATH, :COUNTRY, :CRC32, '1', '1', :PUBLISHER, :VERSION)");
+ ":GAMETYPE, :ROMPATH, :COUNTRY, :CRC32, '1', '1', :PUBLISHER, :VERSION, "
+ ":FANART, BOXART)");
@@ -463,7 +471,9 @@
query.bindValue(":CRC32", CRC32);
query.bindValue(":PUBLISHER", Publisher);
query.bindValue(":VERSION", Version);
-
+ query.bindValue(":FANART", Fanart);
+ query.bindValue(":BOXART", Boxart);
+
query.exec();
}
else if ((iter.data().FoundLoc() == inDatabase) && (removalprompt))
Index: mythplugins/mythgame/mythgame/gameui.cpp
===================================================================
--- mythplugins/mythgame/mythgame/gameui.cpp (revision 0)
+++ mythplugins/mythgame/mythgame/gameui.cpp (revision 0)
@@ -0,0 +1,734 @@
+#include
+#include
+#include
+#include
+
+// MythGame headers
+#include "gameui.h"
+#include "gamehandler.h"
+#include "rominfo.h"
+#include "gamedetails.h"
+#include "romedit.h"
+
+class GameTreeInfo
+{
+ public:
+ GameTreeInfo(const QString& levels, const QString& filter)
+ : m_levels(QStringList::split(" ", levels))
+ , m_filter(filter)
+ {
+ }
+
+ int getDepth() const { return m_levels.size(); }
+ const QString& getLevel(unsigned i) const { return m_levels[i]; }
+ const QString& getFilter() const { return m_filter; }
+
+ private:
+ QStringList m_levels;
+ QString m_filter;
+};
+
+Q_DECLARE_METATYPE(GameTreeInfo *)
+
+GameUI::GameUI(MythScreenStack *parent)
+ : MythScreenType(parent, "GameUI")
+{
+ gContext->addCurrentLocation("mythgame");
+}
+
+GameUI::~GameUI()
+{
+ gContext->removeCurrentLocation();
+}
+
+bool GameUI::Create()
+{
+ if (!LoadWindowFromXML("game-ui.xml", "gameui", this))
+ return false;
+
+ bool err = false;
+ UIUtilE::Assign(this, m_gameTreeUI, "gametreelist", &err);
+ UIUtilE::Assign(this, m_gameTitle, "gametitle", &err);
+ UIUtilE::Assign(this, m_gameSystem, "systemname", &err);
+ UIUtilE::Assign(this, m_gameYear, "yearname", &err);
+ UIUtilE::Assign(this, m_gameGenre, "genrename", &err);
+ UIUtilE::Assign(this, m_gameFavourite, "showfavorite", &err);
+ UIUtilE::Assign(this, m_gameImage, "gameimage", &err);
+ UIUtilE::Assign(this, m_fanartImage, "fanart", &err);
+ UIUtilE::Assign(this, m_boxImage, "boxart", &err);
+
+ if (err)
+ {
+ VERBOSE(VB_IMPORTANT, "Cannot load screen 'gameui'");
+ return false;
+ }
+
+ connect(m_gameTreeUI, SIGNAL(itemClicked(MythUIButtonListItem*)),
+ this, SLOT(itemClicked(MythUIButtonListItem*)));
+
+ connect(m_gameTreeUI, SIGNAL(nodeChanged(MythGenericTree*)),
+ this, SLOT(nodeChanged(MythGenericTree*)));
+
+ m_gameShowFileName = gContext->GetSetting("GameShowFileNames").toInt();
+
+ m_gameTree = new MythGenericTree("game root", 0, false);
+
+ timer = new QTimer(this);
+ connect(timer, SIGNAL(timeout()), SLOT(showImageTimeout()));
+
+ // create system filter to only select games where handlers are present
+ QString systemFilter;
+
+ // The call to GameHandler::count() fills the handler list for us
+ // to move through.
+ unsigned handlercount = GameHandler::count();
+
+ for (unsigned i = 0; i < handlercount; ++i)
+ {
+ QString system = GameHandler::getHandler(i)->SystemName();
+ if (i == 0)
+ systemFilter = "system in ('" + system + "'";
+ else
+ systemFilter += ",'" + system + "'";
+ }
+ if (systemFilter.isEmpty())
+ {
+ systemFilter = "1=0";
+ VERBOSE(VB_GENERAL, QString("Couldn't find any game handlers!"));
+ }
+ else
+ systemFilter += ")";
+
+ m_showHashed = gContext->GetSetting("GameTreeView").toInt();
+
+ // create a few top level nodes - this could be moved to a config based
+ // approach with multiple roots if/when someone has the time to create
+ // the relevant dialog screens
+
+ QString levels = gContext->GetSetting("GameFavTreeLevels");
+
+ MythGenericTree *new_node = new MythGenericTree("Favourites", 1, true);
+ new_node->SetData(qVariantFromValue(
+ new GameTreeInfo(levels, systemFilter + " and favorite=1")));
+ m_favouriteNode = m_gameTree->addNode(new_node);
+
+ levels = gContext->GetSetting("GameAllTreeLevels");
+
+ if (m_showHashed)
+ {
+ int pos = levels.find("gamename",0);
+ if (pos >= 0)
+ levels.insert(pos, " hash ");
+ }
+
+ new_node = new MythGenericTree(tr("All Games"), 1, true);
+ new_node->SetData(qVariantFromValue(
+ new GameTreeInfo(levels, systemFilter)));
+ m_gameTree->addNode(new_node);
+
+ new_node = new MythGenericTree(tr("- By Genre"), 1, true);
+ new_node->SetData(qVariantFromValue(
+ new GameTreeInfo("genre gamename", systemFilter)));
+ m_gameTree->addNode(new_node);
+
+ new_node = new MythGenericTree(tr("- By Year"), 1, true);
+ new_node->SetData(qVariantFromValue(
+ new GameTreeInfo("year gamename", systemFilter)));
+ m_gameTree->addNode(new_node);
+
+ new_node = new MythGenericTree(tr("- By Name"), 1, true);
+ new_node->SetData(qVariantFromValue(
+ new GameTreeInfo("gamename", systemFilter)));
+ m_gameTree->addNode(new_node);
+
+ new_node = new MythGenericTree(tr("- By Publisher"), 1, true);
+ new_node->SetData(qVariantFromValue(
+ new GameTreeInfo("publisher gamename", systemFilter)));
+ m_gameTree->addNode(new_node);
+
+ m_gameTreeUI->AssignTree(m_gameTree);
+
+ BuildFocusList();
+
+ return true;
+}
+
+bool GameUI::keyPressEvent(QKeyEvent *event)
+{
+ if (GetFocusWidget()->keyPressEvent(event))
+ return true;
+
+ bool handled = false;
+ QStringList actions;
+ gContext->GetMainWindow()->TranslateKeyPress("Game", event, actions);
+
+ for (int i = 0; i < actions.size() && !handled; i++)
+ {
+ QString action = actions[i];
+ handled = true;
+
+ if (action == "MENU")
+ showMenu();
+ else if (action == "INFO")
+ showInfo();
+ else if (action == "TOGGLEFAV")
+ toggleFavorite();
+ else if (action == "INCSEARCH")
+ searchStart();
+ else if (action == "INCSEARCHNEXT")
+ searchStart();
+ else
+ handled = false;
+ }
+ if (!handled && MythScreenType::keyPressEvent(event))
+ handled = true;
+
+ return handled;
+}
+
+void GameUI::nodeChanged(MythGenericTree* node)
+{
+ if (!isLeaf(node))
+ {
+ if (node->childCount() == 0 || node == m_favouriteNode)
+ {
+ node->deleteAllChildren();
+ fillNode(node);
+ }
+ if (timer->isActive())
+ timer->stop();
+ clearRomInfo();
+ }
+ else
+ {
+ RomInfo *romInfo = qVariantValue(node->GetData());
+ if (romInfo->Romname().isEmpty())
+ romInfo->fillData();
+ updateRomInfo(romInfo);
+ if (!romInfo->ImagePath().isEmpty() || !romInfo->Fanart().isEmpty() ||
+ !romInfo->Boxart().isEmpty())
+ {
+ if (timer->isActive())
+ timer->changeInterval(330);
+ else
+ timer->start(330, true);
+ }
+ else
+ {
+ if (m_gameImage->IsVisible())
+ m_gameImage->Hide();
+ if (m_fanartImage->IsVisible())
+ m_fanartImage->Hide();
+ if (m_boxImage->IsVisible())
+ m_boxImage->Hide();
+ }
+ }
+}
+
+void GameUI::itemClicked(MythUIButtonListItem*)
+{
+ MythGenericTree *node = m_gameTreeUI->GetCurrentNode();
+ if (isLeaf(node))
+ {
+ RomInfo *romInfo = qVariantValue(node->GetData());
+ if (romInfo->RomCount() == 1)
+ {
+ GameHandler::Launchgame(romInfo, NULL);
+ }
+ else
+ {
+ QString msg = QObject::tr("Choose System for") +
+ ":\n" + node->getString();
+ MythScreenStack *popupStack = GetMythMainWindow()->
+ GetStack("popup stack");
+ MythDialogBox *chooseSystemPopup = new MythDialogBox(
+ msg, popupStack, "chooseSystemPopup");
+
+ if (chooseSystemPopup->Create())
+ {
+ chooseSystemPopup->SetReturnEvent(this, "chooseSystemPopup");
+ QString all_systems = romInfo->AllSystems();
+ QStringList players = QStringList::split(",", all_systems);
+ for (QStringList::Iterator it = players.begin();
+ it != players.end(); ++it)
+ {
+ chooseSystemPopup->AddButton(*it);
+ }
+ chooseSystemPopup->AddButton(tr("Cancel"));
+ popupStack->AddScreen(chooseSystemPopup);
+ }
+ else
+ delete chooseSystemPopup;
+ }
+ }
+}
+
+void GameUI::showImageTimeout(void)
+{
+ m_gameImage->Load();
+ if (!m_gameImage->IsVisible())
+ m_gameImage->Show();
+ m_fanartImage->Load();
+ if (!m_fanartImage->IsVisible())
+ m_fanartImage->Show();
+ m_boxImage->Load();
+ if (!m_boxImage->IsVisible())
+ m_boxImage->Show();
+}
+
+void GameUI::searchComplete(QString string)
+{
+ MythGenericTree *parent = m_gameTreeUI->GetCurrentNode()->getParent();
+ MythGenericTree *new_node = parent->getChildByName(string);
+ if (new_node)
+ {
+ m_gameTreeUI->SetCurrentNode(new_node);
+ // SetActive updates the buttonlist but SetCurrentNode doesn't.
+ m_gameTreeUI->SetActive(true);
+ }
+}
+
+void GameUI::updateRomInfo(RomInfo *rom)
+{
+ m_gameTitle->SetText(rom->Gamename());
+ m_gameSystem->SetText(rom->System());
+ m_gameYear->SetText(rom->Year());
+ m_gameGenre->SetText(rom->Genre());
+
+ if (rom->Favorite())
+ m_gameFavourite->SetText("Yes");
+ else
+ m_gameFavourite->SetText("No");
+
+ m_gameImage->SetFilename(rom->ImagePath());
+ m_fanartImage->SetFilename(rom->Fanart());
+ m_boxImage->SetFilename(rom->Boxart());
+}
+
+void GameUI::clearRomInfo(void) {
+ m_gameTitle->SetText("");
+ m_gameSystem->SetText("");
+ m_gameYear->SetText("");
+ m_gameGenre->SetText("");
+ m_gameFavourite->SetText("");
+
+ if (m_gameImage->IsVisible())
+ m_gameImage->Hide();
+
+ if (m_fanartImage->IsVisible())
+ m_fanartImage->Hide();
+
+ if (m_boxImage->IsVisible())
+ m_boxImage->Hide();
+}
+
+void GameUI::edit(void)
+{
+ MythGenericTree *node = m_gameTreeUI->GetCurrentNode();
+ if (isLeaf(node))
+ {
+ RomInfo *romInfo = qVariantValue(node->GetData());
+
+ MythScreenStack *screenStack = GetScreenStack();
+
+ EditRomInfoDialog *md_editor = new EditRomInfoDialog(screenStack,
+ "mythgameeditmetadata", romInfo);
+
+ if (md_editor->Create())
+ {
+ screenStack->AddScreen(md_editor);
+ md_editor->SetReturnEvent(this, "editMetadata");
+ }
+ else
+ delete md_editor;
+ }
+}
+
+void GameUI::showInfo()
+{
+ MythGenericTree *node = m_gameTreeUI->GetCurrentNode();
+ if (isLeaf(node))
+ {
+ RomInfo *romInfo = qVariantValue(node->GetData());
+ MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack();
+ GameDetailsPopup *details_dialog =
+ new GameDetailsPopup(mainStack, romInfo);
+
+ if (details_dialog->Create())
+ {
+ mainStack->AddScreen(details_dialog);
+ details_dialog->SetReturnEvent(this, "detailsPopup");
+ }
+ else
+ delete details_dialog;
+ }
+}
+
+void GameUI::showMenu()
+{
+ MythGenericTree *node = m_gameTreeUI->GetCurrentNode();
+ if (isLeaf(node))
+ {
+ RomInfo *romInfo = qVariantValue(node->GetData());
+ MythScreenStack *popupStack = GetMythMainWindow()->
+ GetStack("popup stack");
+ MythDialogBox *showMenuPopup =
+ new MythDialogBox(node->getString(), popupStack, "showMenuPopup");
+
+ if (showMenuPopup->Create())
+ {
+ showMenuPopup->SetReturnEvent(this, "showMenuPopup");
+ showMenuPopup->AddButton(tr("Show Information"));
+ if (romInfo->Favorite())
+ showMenuPopup->AddButton(tr("Remove Favorite"));
+ else
+ showMenuPopup->AddButton(tr("Make Favorite"));
+ showMenuPopup->AddButton(tr("Edit"));
+ popupStack->AddScreen(showMenuPopup);
+ }
+ else
+ delete showMenuPopup;
+ }
+}
+
+void GameUI::searchStart(void)
+{
+ MythGenericTree *parent = m_gameTreeUI->GetCurrentNode()->getParent();
+
+ if (parent != NULL)
+ {
+ QStringList childList;
+ QList::iterator it;
+ QList *children = parent->getAllChildren();
+
+ for (it = children->begin(); it != children->end(); ++it)
+ {
+ MythGenericTree *child = *it;
+ childList << child->getString();
+ }
+
+ MythScreenStack *popupStack =
+ GetMythMainWindow()->GetStack("popup stack");
+ MythUISearchDialog *searchDialog = new MythUISearchDialog(popupStack,
+ tr("Game Search"), childList, true, "");
+
+ if (searchDialog->Create())
+ {
+ connect(searchDialog, SIGNAL(haveResult(QString)),
+ SLOT(searchComplete(QString)));
+
+ popupStack->AddScreen(searchDialog);
+ }
+ else
+ delete searchDialog;
+ }
+}
+
+void GameUI::toggleFavorite(void)
+{
+ MythGenericTree *node = m_gameTreeUI->GetCurrentNode();
+ if (isLeaf(node))
+ {
+ RomInfo *romInfo = qVariantValue(node->GetData());
+ romInfo->setFavorite(true);
+ updateChangedNode(node, romInfo);
+ }
+}
+
+void GameUI::customEvent(QEvent *event)
+{
+ if (event->type() == kMythDialogBoxCompletionEventType)
+ {
+ DialogCompletionEvent *dce =
+ dynamic_cast(event);
+
+ QString resultid = dce->GetId();
+ QString resulttext = dce->GetResultText();
+
+ if (resultid == "showMenuPopup")
+ {
+ if (resulttext == tr("Edit")) {
+ edit();
+ }
+ else if (resulttext == tr("Show Information"))
+ {
+ showInfo();
+ }
+ else if (resulttext == tr("Make Favorite") ||
+ resulttext == tr("Remove Favorite"))
+ {
+ toggleFavorite();
+ }
+ }
+ else if (resultid == "chooseSystemPopup")
+ {
+ if (resulttext != "" && resulttext != tr("Cancel")) {
+ MythGenericTree *node = m_gameTreeUI->GetCurrentNode();
+ RomInfo *romInfo = qVariantValue(node->GetData());
+ GameHandler::Launchgame(romInfo, resulttext);
+ }
+ }
+ else if (resultid == "editMetadata")
+ {
+ MythGenericTree *node = m_gameTreeUI->GetCurrentNode();
+ RomInfo *oldRomInfo = qVariantValue(node->GetData());
+ delete oldRomInfo;
+
+ RomInfo *romInfo = qVariantValue(dce->GetData());
+ node->SetData(qVariantFromValue(romInfo));
+ node->setString(romInfo->Gamename());
+
+ romInfo->UpdateDatabase();
+ updateChangedNode(node, romInfo);
+ }
+ else if (resultid == "detailsPopup")
+ {
+ // Play button pushed
+ itemClicked(0);
+ }
+ }
+}
+
+QString GameUI::getFillSql(MythGenericTree *node) const
+{
+ QString layer = node->getString();
+ int childDepth = node->getInt() + 1;
+ QString childLevel = getChildLevelString(node);
+ QString filter = getFilter(node);
+ bool childIsLeaf = childDepth == getLevelsOnThisBranch(node) + 1;
+ RomInfo *romInfo = qVariantValue(node->GetData());
+
+ QString columns;
+ QString conj = "where ";
+
+ if (!filter.isEmpty())
+ {
+ filter = conj + filter;
+ conj = " and ";
+ }
+ if ((childLevel == "gamename") && (m_gameShowFileName))
+ {
+ columns = childIsLeaf
+ ? "romname,system,year,genre,gamename"
+ : "romname";
+
+ if (m_showHashed)
+ filter += " and romname like '" + layer + "%'";
+
+ }
+ else if ((childLevel == "gamename") && (layer.length() == 1)) {
+ columns = childIsLeaf
+ ? childLevel + ",system,year,genre,gamename"
+ : childLevel;
+
+ if (m_showHashed)
+ filter += " and gamename like '" + layer + "%'";
+
+ }
+ else if (childLevel == "hash") {
+ columns = "left(gamename,1)";
+ }
+ else {
+
+ columns = childIsLeaf
+ ? childLevel + ",system,year,genre,gamename"
+ : childLevel;
+ }
+
+ // this whole section ought to be in rominfo.cpp really, but I've put it
+ // in here for now to minimise the number of files changed by this mod
+ if (romInfo) {
+ if (!romInfo->System().isEmpty())
+ {
+ filter += conj + "trim(system)=:SYSTEM";
+ conj = " and ";
+ }
+ if (!romInfo->Year().isEmpty())
+ {
+ filter += conj + "year=:YEAR";
+ conj = " and ";
+ }
+ if (!romInfo->Genre().isEmpty())
+ {
+ filter += conj + "trim(genre)=:GENRE";
+ conj = " and ";
+ }
+ if (!romInfo->Publisher().isEmpty())
+ {
+ filter += conj + "publisher=:PUBLISHER";
+ conj = " and ";
+ }
+
+ if (!romInfo->Gamename().isEmpty())
+ {
+ filter += conj + "trim(gamename)=:GAMENAME";
+ }
+
+ }
+
+ filter += conj + " display = 1 ";
+
+ QString sql;
+
+ if ((childLevel == "gamename") && (m_gameShowFileName))
+ {
+ sql = "select distinct "
+ + columns
+ + " from gamemetadata "
+ + filter
+ + " order by romname"
+ + ";";
+ }
+ else if (childLevel == "hash") {
+ sql = "select distinct "
+ + columns
+ + " from gamemetadata "
+ + filter
+ + " order by gamename,romname"
+ + ";";
+ }
+ else
+ {
+ sql = "select distinct "
+ + columns
+ + " from gamemetadata "
+ + filter
+ + " order by "
+ + childLevel
+ + ";";
+ }
+
+ return sql;
+}
+
+QString GameUI::getChildLevelString(MythGenericTree *node) const
+{
+ unsigned this_level = node->getInt();
+ while (node->getInt() != 1)
+ node = node->getParent();
+
+ GameTreeInfo *gi = qVariantValue(node->GetData());
+ return gi->getLevel(this_level - 1);
+}
+
+QString GameUI::getFilter(MythGenericTree *node) const
+{
+ while (node->getInt() != 1)
+ node = node->getParent();
+ GameTreeInfo *gi = qVariantValue(node->GetData());
+ return gi->getFilter();
+}
+
+int GameUI::getLevelsOnThisBranch(MythGenericTree *node) const
+{
+ while (node->getInt() != 1)
+ node = node->getParent();
+
+ GameTreeInfo *gi = qVariantValue(node->GetData());
+ return gi->getDepth();
+}
+
+bool GameUI::isLeaf(MythGenericTree *node) const
+{
+ return (node->getInt() - 1) == getLevelsOnThisBranch(node);
+}
+
+void GameUI::fillNode(MythGenericTree *node)
+{
+ QString layername = node->getString();
+ RomInfo *romInfo = qVariantValue(node->GetData());
+
+ MSqlQuery query(MSqlQuery::InitCon());
+
+ query.prepare(getFillSql(node));
+
+ if (romInfo)
+ {
+ if (!romInfo->System().isEmpty())
+ query.bindValue(":SYSTEM", romInfo->System());
+ if (!romInfo->Year().isEmpty())
+ query.bindValue(":YEAR", romInfo->Year());
+ if (!romInfo->Genre().isEmpty())
+ query.bindValue(":GENRE", romInfo->Genre());
+ if (!romInfo->Publisher().isEmpty())
+ query.bindValue(":PUBLISHER", romInfo->Publisher());
+ if (!romInfo->Gamename().isEmpty())
+ query.bindValue(":GAMENAME", romInfo->Gamename());
+ }
+
+ bool IsLeaf = node->getInt() == getLevelsOnThisBranch(node);
+ if (query.exec() && query.size() > 0)
+ {
+ while (query.next())
+ {
+ QString current = query.value(0).toString().stripWhiteSpace();
+ MythGenericTree *new_node =
+ new MythGenericTree(current, node->getInt() + 1, false);
+ if (IsLeaf)
+ {
+ RomInfo *temp = new RomInfo();
+ temp->setSystem(query.value(1).toString().stripWhiteSpace());
+ temp->setYear(query.value(2).toString());
+ temp->setGenre(query.value(3).toString().stripWhiteSpace());
+ temp->setGamename(query.value(4).toString().stripWhiteSpace());
+ new_node->SetData(qVariantFromValue(temp));
+ node->addNode(new_node);
+ }
+ else
+ {
+ RomInfo *newRomInfo;
+ if (node->getInt() > 1)
+ {
+ RomInfo *currentRomInfo;
+ currentRomInfo = qVariantValue(node->GetData());
+ newRomInfo = new RomInfo(*currentRomInfo);
+ }
+ else
+ {
+ newRomInfo = new RomInfo();
+ }
+ new_node->SetData(qVariantFromValue(newRomInfo));
+ node->addNode(new_node);
+ if (getChildLevelString(node) != "hash")
+ newRomInfo->setField(getChildLevelString(node), current);
+ }
+ }
+ }
+}
+
+void GameUI::resetOtherTrees(MythGenericTree *node)
+{
+ MythGenericTree *top_level = node;
+ while (top_level->getParent() != m_gameTree)
+ {
+ top_level = top_level->getParent();
+ }
+
+ QList::iterator it;
+ QList *children = m_gameTree->getAllChildren();
+
+ for (it = children->begin(); it != children->end(); ++it)
+ {
+ MythGenericTree *child = *it;
+ if (child != top_level)
+ {
+ child->deleteAllChildren();
+ }
+ }
+}
+
+void GameUI::updateChangedNode(MythGenericTree *node, RomInfo *romInfo)
+{
+ resetOtherTrees(node);
+
+ if (node->getParent() == m_favouriteNode && romInfo->Favorite() == 0) {
+ // node is being removed
+ m_gameTreeUI->SetCurrentNode(m_favouriteNode);
+ }
+ else
+ {
+ nodeChanged(node);
+ }
+ // SetActive to update the buttonlist text
+ m_gameTreeUI->SetActive(true);
+}
Index: mythplugins/mythgame/mythgame/romedit.h
===================================================================
--- mythplugins/mythgame/mythgame/romedit.h (revision 20745)
+++ mythplugins/mythgame/mythgame/romedit.h (working copy)
@@ -1,15 +1,57 @@
#ifndef ROMEDITDLG_H_
#define ROMEDITDLG_H_
-#include
+#include
-#include
-#include
+class RomInfo;
-class GameEditDialog : public ConfigurationWizard
+class EditRomInfoDialog : public MythScreenType
{
+ Q_OBJECT
+
public:
- GameEditDialog(const QString &romname);
+ EditRomInfoDialog(MythScreenStack *parent,
+ QString name,
+ RomInfo *romInfo);
+
+ ~EditRomInfoDialog();
+
+ bool Create();
+ void customEvent(QEvent *levent);
+ void SetReturnEvent(QObject *retobject, const QString &resultid);
+
+ public slots:
+ void SetGamename();
+ void SetGenre();
+ void SetYear();
+ void SetCountry();
+ void SetPublisher();
+ void ToggleFavorite();
+ void FindFanart();
+ void FindBoxart();
+ void SaveAndExit();
+
+ private:
+ void fillWidgets();
+ void SetFanart(QString file);
+ void SetBoxart(QString file);
+
+ private:
+ RomInfo *m_workingRomInfo;
+ QString m_id;
+ QObject *m_retObject;
+
+ MythUITextEdit *m_gamenameEdit;
+ MythUITextEdit *m_genreEdit;
+ MythUITextEdit *m_yearEdit;
+ MythUITextEdit *m_countryEdit;
+ MythUITextEdit *m_publisherEdit;
+ MythUICheckBox *m_favoriteCheck;
+ MythUIButton *m_fanartButton;
+ MythUIText *m_fanartText;
+ MythUIButton *m_boxartButton;
+ MythUIText *m_boxartText;
+ MythUIButton *m_doneButton;
};
#endif // ROMEDITDLG_H_
Index: mythplugins/mythgame/mythgame/rominfo.cpp
===================================================================
--- mythplugins/mythgame/mythgame/rominfo.cpp (revision 20745)
+++ mythplugins/mythgame/mythgame/rominfo.cpp (working copy)
@@ -1,6 +1,7 @@
#include
#include
+#include
#include "rominfo.h"
#include "romedit.h"
@@ -15,63 +16,70 @@
return false;
}
-
-void RomInfo::edit_rominfo()
+void RomInfo::UpdateDatabase()
{
- QString rom_ver = Version();
+ MSqlQuery query(MSqlQuery::InitCon());
+ query.prepare("SELECT gamename,genre,year,country,publisher,favorite,"
+ "fanart,boxart "
+ "FROM gamemetadata "
+ "WHERE gametype = :GAMETYPE "
+ "AND romname = :ROMNAME");
- GameEditDialog romeditdlg(Romname());
+ query.bindValue(":GAMETYPE", GameType());
+ query.bindValue(":ROMNAME", Romname());
- DialogCode res = romeditdlg.exec();
+ if (!query.exec())
+ {
+ MythDB::DBError("RomInfo::UpdateDatabase", query);
+ return;
+ }
- if (kDialogCodeRejected == res)
+ if (!query.next())
return;
- if (res)
+ QString t_gamename = query.value(0).toString();
+ QString t_genre = query.value(1).toString();
+ QString t_year = query.value(2).toString();
+ QString t_country = query.value(3).toString();
+ QString t_publisher = query.value(4).toString();
+ bool t_favourite = query.value(5).toBool();
+ QString t_fanart = query.value(6).toString();
+ QString t_boxart = query.value(7).toString();
+
+ if ((t_gamename != Gamename()) || (t_genre != Genre()) ||
+ (t_year != Year()) || (t_country != Country()) ||
+ (t_publisher != Publisher()) || (t_favourite != Favorite()) ||
+ (t_fanart != Fanart()) || (t_boxart != Boxart()))
{
- MSqlQuery query(MSqlQuery::InitCon());
- query.prepare("SELECT gamename,genre,year,country,publisher,favorite "
- "FROM gamemetadata "
- "WHERE gametype = :GAMETYPE "
- "AND romname = :ROMNAME");
-
+ query.prepare("UPDATE gamemetadata "
+ "SET version = 'CUSTOM', "
+ " gamename = :GAMENAME,"
+ " genre = :GENRE,"
+ " year = :YEAR,"
+ " country = :COUNTRY,"
+ " publisher = :PUBLISHER,"
+ " favorite = :FAVORITE,"
+ " fanart = :FANART,"
+ " boxart = :BOXART "
+ "WHERE gametype = :GAMETYPE AND "
+ " romname = :ROMNAME");
+ query.bindValue(":GAMENAME", Gamename());
+ query.bindValue(":GENRE", Genre());
+ query.bindValue(":YEAR", Year());
+ query.bindValue(":COUNTRY", Country());
+ query.bindValue(":PUBLISHER", Publisher());
+ query.bindValue(":FAVORITE", Favorite());
+ query.bindValue(":FANART", Fanart());
+ query.bindValue(":BOXART", Boxart());
query.bindValue(":GAMETYPE", GameType());
query.bindValue(":ROMNAME", Romname());
if (!query.exec())
{
- MythDB::DBError("RomInfo::edit_rominfo", query);
+ MythDB::DBError("RomInfo::UpdateDatabase", query);
return;
}
-
- if (!query.next())
- return;
-
- QString t_gamename = query.value(0).toString();
- QString t_genre = query.value(1).toString();
- QString t_year = query.value(2).toString();
- QString t_country = query.value(3).toString();
- QString t_publisher = query.value(4).toString();
- bool t_favourite = query.value(5).toBool();
-
- if ((t_gamename != Gamename()) || (t_genre != Genre()) ||
- (t_year != Year()) || (t_country != Country()) ||
- (t_publisher != Publisher()) || (t_favourite != Favorite()))
- {
- query.prepare("UPDATE gamemetadata "
- "SET version = 'CUSTOM' "
- "WHERE gametype = :GAMETYPE AND "
- " romname = :ROMNAME");
- query.bindValue(":GAMETYPE", GameType());
- query.bindValue(":ROMNAME", Romname());
-
- if (!query.exec())
- {
- MythDB::DBError("RomInfo::edit_rominfo", query);
- return;
- }
- }
- }
+ }
}
// Return the count of how many times this appears in the db already
@@ -147,6 +155,10 @@
favorite = data.toInt();
else if (field == "rompath")
rompath = data;
+ else if (field == "fanart")
+ fanart = data;
+ else if (field == "boxart")
+ boxart = data;
else if (field == "country")
country = data;
else if (field == "publisher")
@@ -164,21 +176,24 @@
}
-void RomInfo::setFavorite()
+void RomInfo::setFavorite(bool updateDatabase)
{
favorite = 1 - favorite;
- MSqlQuery query(MSqlQuery::InitCon());
+ if (updateDatabase)
+ {
+ MSqlQuery query(MSqlQuery::InitCon());
- query.prepare("UPDATE gamemetadata SET favorite = :FAV "
- "WHERE romname = :ROMNAME");
+ query.prepare("UPDATE gamemetadata SET favorite = :FAV "
+ "WHERE romname = :ROMNAME");
- query.bindValue(":FAV", favorite);
- query.bindValue(":ROMNAME",romname);
+ query.bindValue(":FAV", favorite);
+ query.bindValue(":ROMNAME",romname);
- if (!query.exec())
- {
- MythDB::DBError("RomInfo::setFavorite", query);
+ if (!query.exec())
+ {
+ MythDB::DBError("RomInfo::setFavorite", query);
+ }
}
}
@@ -211,7 +226,7 @@
QString thequery = "SELECT system,gamename,genre,year,romname,favorite,"
"rompath,country,crc_value,diskcount,gametype,publisher,"
- "version FROM gamemetadata WHERE gamename = :GAMENAME "
+ "version,fanart,boxart FROM gamemetadata WHERE gamename = :GAMENAME "
+ systemtype + " ORDER BY diskcount DESC";
query.prepare(thequery);
@@ -234,6 +249,8 @@
setGameType(query.value(10).toString());
setPublisher(query.value(11).toString());
setVersion(query.value(12).toString());
+ setFanart(query.value(13).toString());
+ setBoxart(query.value(14).toString());
}
query.prepare("SELECT screenshots FROM gameplayers "
Index: mythplugins/mythgame/mythgame/gameui.h
===================================================================
--- mythplugins/mythgame/mythgame/gameui.h (revision 0)
+++ mythplugins/mythgame/mythgame/gameui.h (revision 0)
@@ -0,0 +1,68 @@
+#ifndef GAMEUI_H_
+#define GAMEUI_H_
+
+#include
+
+// myth
+#include
+
+class MythUIButtonTree;
+class MythGenericTree;
+class RomInfo;
+
+class GameUI : public MythScreenType
+{
+ Q_OBJECT
+
+ public:
+ GameUI(MythScreenStack *parentStack);
+ ~GameUI();
+
+ bool Create();
+ bool keyPressEvent(QKeyEvent *event);
+
+ public slots:
+ void nodeChanged(MythGenericTree* node);
+ void itemClicked(MythUIButtonListItem* item);
+ void showImageTimeout(void);
+ void searchComplete(QString);
+
+ private:
+ void updateRomInfo(RomInfo *rom);
+ void clearRomInfo(void);
+ void edit(void);
+ void showInfo(void);
+ void showMenu(void);
+ void searchStart(void);
+ void toggleFavorite(void);
+ void customEvent(QEvent *event);
+
+ QString getFillSql(MythGenericTree* node) const;
+ QString getChildLevelString(MythGenericTree *node) const;
+ QString getFilter(MythGenericTree *node) const;
+ int getLevelsOnThisBranch(MythGenericTree *node) const;
+ bool isLeaf(MythGenericTree *node) const;
+ void fillNode(MythGenericTree *node);
+ void resetOtherTrees(MythGenericTree *node);
+ void updateChangedNode(MythGenericTree *node, RomInfo *romInfo);
+
+ private:
+ bool m_showHashed;
+ int m_gameShowFileName;
+ QTimer *timer;
+
+ MythGenericTree *m_gameTree;
+ MythGenericTree *m_favouriteNode;
+
+ MythUIButtonTree *m_gameTreeUI;
+ MythUIText *m_gameTitle;
+ MythUIText *m_gameSystem;
+ MythUIText *m_gameYear;
+ MythUIText *m_gameGenre;
+ MythUIText *m_gameFavourite;
+ MythUIImage *m_gameImage;
+ MythUIImage *m_fanartImage;
+ MythUIImage *m_boxImage;
+};
+
+#endif
Index: mythplugins/mythgame/mythgame/gamehandler.h
===================================================================
--- mythplugins/mythgame/mythgame/gamehandler.h (revision 20745)
+++ mythplugins/mythgame/mythgame/gamehandler.h (working copy)
@@ -67,7 +67,8 @@
void GetMetadata(GameHandler *handler, QString rom,
QString* Genre, QString* Year, QString* Country,
QString* CRC32, QString* GameName,
- QString* Publisher, QString* Version);
+ QString* Publisher, QString* Version,
+ QString* Fanart, QString* Boxart);
void promptForRemoval(QString filename, QString RomPath );
void UpdateGameDB(GameHandler *handler);
Index: mythplugins/mythgame/mythgame/rominfo.h
===================================================================
--- mythplugins/mythgame/mythgame/rominfo.h (revision 20745)
+++ mythplugins/mythgame/mythgame/rominfo.h (working copy)
@@ -12,7 +12,8 @@
QString lgenre = "", QString lyear = "", bool lfavorite = FALSE,
QString lrompath = "", QString lcountry ="", QString lcrc_value = "",
int ldiskcount = 0, QString lgametype = "", int lromcount = 0,
- QString lallsystems = "", QString lpublisher = "", QString lversion = "")
+ QString lallsystems = "", QString lpublisher = "", QString lversion = "",
+ QString lfanart = "", QString lboxart = "")
{
romname = lromname;
system = lsystem;
@@ -21,6 +22,8 @@
year = lyear;
favorite = lfavorite;
rompath = lrompath;
+ fanart = lfanart;
+ boxart = lboxart;
country = lcountry;
crc_value = lcrc_value;
diskcount = ldiskcount;
@@ -37,9 +40,12 @@
system = lhs.system;
gamename = lhs.gamename;
genre = lhs.genre;
+ imagepath = lhs.imagepath;
year = lhs.year;
favorite = lhs.favorite;
rompath = lhs.rompath;
+ fanart = lhs.fanart;
+ boxart = lhs.boxart;
country = lhs.country;
crc_value = lhs.crc_value;
diskcount = lhs.diskcount;
@@ -50,64 +56,69 @@
version = lhs.version;
}
- virtual ~RomInfo() {}
+ ~RomInfo() {}
bool FindImage(QString BaseFileName, QString *result);
QString Rompath() const { return rompath; }
void setRompath(const QString &lrompath) { rompath = lrompath; }
+ QString Fanart() const { return fanart; }
+ void setFanart(const QString &lfanart) { fanart = lfanart; }
+
+ QString Boxart() const { return boxart; }
+ void setBoxart(const QString &lboxart) { boxart = lboxart; }
+
QString Romname() const { return romname; }
void setRomname(const QString &lromname) { romname = lromname; }
- QString System() { return system; }
+ QString System() const { return system; }
void setSystem(const QString &lsystem) { system = lsystem; }
- QString Gamename() { return gamename; }
+ QString Gamename() const { return gamename; }
void setGamename(const QString &lgamename) { gamename = lgamename; }
- QString Genre() { return genre; }
+ QString Genre() const { return genre; }
void setGenre(const QString &lgenre) { genre = lgenre; }
- QString Country() { return country; }
+ QString Country() const { return country; }
void setCountry(const QString &lcountry) { country = lcountry; }
- QString GameType() { return gametype; }
+ QString GameType() const { return gametype; }
void setGameType(const QString &lgametype) { gametype = lgametype; }
- int RomCount() { return romcount; }
+ int RomCount() const { return romcount; }
void setRomCount(const int &lromcount) { romcount = lromcount; }
- QString AllSystems() { return allsystems; }
+ QString AllSystems() const { return allsystems; }
void setAllSystems(const QString &lallsystems) { allsystems = lallsystems; }
- int DiskCount() { return diskcount; }
+ int DiskCount() const { return diskcount; }
void setDiskCount(const int &ldiskcount) { diskcount = ldiskcount; }
- QString CRC_VALUE() { return crc_value; }
+ QString CRC_VALUE() const { return crc_value; }
void setCRC_VALUE(const QString &lcrc_value) { crc_value = lcrc_value; }
- QString ImagePath() { return imagepath; }
+ QString ImagePath() const { return imagepath; }
void setImagePath(const QString &limagepath) { imagepath = limagepath; }
- QString Publisher() { return publisher; }
+ QString Publisher() const { return publisher; }
void setPublisher(const QString &lpublisher) { publisher = lpublisher; }
- QString Version() { return version; }
+ QString Version() const { return version; }
void setVersion(const QString &lversion) { version = lversion; }
-
- QString Year() { return year; }
+ QString Year() const { return year; }
void setYear(const QString &lyear) { year = lyear; }
- int Favorite() { return favorite; }
- virtual void setFavorite();
+ int Favorite() const { return favorite; }
+ void setFavorite(bool updateDatabase = false);
QString getExtension();
- virtual void setField(QString field, QString data);
- virtual void fillData();
- virtual void edit_rominfo();
+ void setField(QString field, QString data);
+ void fillData();
+ void UpdateDatabase();
protected:
QString romname;
@@ -126,8 +137,12 @@
QString year;
bool favorite;
QString rompath;
+ QString fanart;
+ QString boxart;
};
bool operator==(const RomInfo& a, const RomInfo& b);
+Q_DECLARE_METATYPE(RomInfo *)
+
#endif
Index: mythplugins/mythgame/mythgame/gamedetails.cpp
===================================================================
--- mythplugins/mythgame/mythgame/gamedetails.cpp (revision 0)
+++ mythplugins/mythgame/mythgame/gamedetails.cpp (revision 0)
@@ -0,0 +1,101 @@
+#include
+#include
+
+#include "mythcontext.h"
+#include "mythuihelper.h"
+#include "mythuitext.h"
+#include "mythuiimage.h"
+#include "mythuibutton.h"
+#include "mythdialogbox.h"
+
+#include "gamedetails.h"
+
+GameDetailsPopup::GameDetailsPopup(MythScreenStack *parent,
+ const RomInfo *romInfo)
+ : MythScreenType (parent, "gamedetailspopup")
+{
+ m_romInfo = romInfo;
+}
+
+GameDetailsPopup::~GameDetailsPopup(void)
+{
+}
+
+void GameDetailsPopup::handleText(const QString &name, const QString &value)
+{
+ MythUIText *textarea;
+ UIUtilE::Assign(this, textarea, name);
+ if (textarea)
+ {
+ textarea->SetText(value);
+ }
+}
+
+void GameDetailsPopup::handleImage(const QString &name, const QString &filename)
+{
+ MythUIImage *image;
+ UIUtilW::Assign(this, image, name);
+ if (image)
+ {
+ if (filename.size())
+ {
+ image->SetFilename(filename);
+ image->Load();
+ }
+ else
+ image->Reset();
+ }
+}
+
+bool GameDetailsPopup::Create(void)
+{
+ if (!LoadWindowFromXML("game-ui.xml", "gamedetailspopup", this))
+ return false;
+
+ UIUtilW::Assign(this, m_playButton, "play_button");
+ UIUtilW::Assign(this, m_doneButton, "done_button");
+
+ if (m_playButton)
+ connect(m_playButton, SIGNAL(Clicked()), SLOT(Play()));
+
+ if (m_doneButton)
+ connect(m_doneButton, SIGNAL(Clicked()), SLOT(Close()));
+
+ BuildFocusList();
+
+ if (m_playButton || m_doneButton)
+ SetFocusWidget(m_playButton ? m_playButton : m_doneButton);
+
+ handleText("gamename", m_romInfo->Gamename());
+ handleText("gametype", m_romInfo->GameType());
+ handleText("romname", m_romInfo->Romname());
+ handleText("crc", m_romInfo->CRC_VALUE());
+ handleText("rompath", m_romInfo->Rompath());
+ handleText("genre", m_romInfo->Genre());
+ handleText("year", m_romInfo->Year());
+ handleText("country", m_romInfo->Country());
+ handleText("publisher", m_romInfo->Publisher());
+ handleText("allsystems", m_romInfo->AllSystems());
+ handleImage("fanart", m_romInfo->Fanart());
+ handleImage("boxart", m_romInfo->Boxart());
+
+ return true;
+}
+
+void GameDetailsPopup::Play()
+{
+ if (m_retObject)
+ {
+ DialogCompletionEvent *dce =
+ new DialogCompletionEvent(m_id, 0, "", "");
+ QApplication::postEvent(m_retObject, dce);
+ Close();
+ }
+}
+
+void GameDetailsPopup::SetReturnEvent(QObject *retobject,
+ const QString &resultid)
+{
+ m_retObject = retobject;
+ m_id = resultid;
+}
Index: mythplugins/mythgame/mythgame/dbcheck.cpp
===================================================================
--- mythplugins/mythgame/mythgame/dbcheck.cpp (revision 20745)
+++ mythplugins/mythgame/mythgame/dbcheck.cpp (working copy)
@@ -12,7 +12,7 @@
#include "gamesettings.h"
-const QString currentDatabaseVersion = "1014";
+const QString currentDatabaseVersion = "1015";
static bool UpdateDBVersionNumber(const QString &newnumber)
{
@@ -384,6 +384,18 @@
return false;
}
+ if (dbver == "1014")
+ {
+ const QString updates[] = {
+"ALTER TABLE gamemetadata ADD fanart VARCHAR(255) NOT NULL AFTER rompath,"
+"ADD boxart VARCHAR( 255 ) NOT NULL AFTER fanart;",
+""
+};
+
+ if (!performActualUpdate(updates, "1015", dbver))
+ return false;
+ }
+
return true;
}
Index: mythplugins/mythgame/mythgame/main.cpp
===================================================================
--- mythplugins/mythgame/mythgame/main.cpp (revision 20745)
+++ mythplugins/mythgame/mythgame/main.cpp (working copy)
@@ -6,10 +6,10 @@
#include
#include
+#include "gameui.h"
#include "gamehandler.h"
#include "rominfo.h"
#include "gamesettings.h"
-#include "gametree.h"
#include "dbcheck.h"
#include
@@ -60,33 +60,33 @@
{
QString themedir = GetMythUI()->GetThemeDir();
- MythThemedMenu *diag = new MythThemedMenu(
+ MythThemedMenu *menu = new MythThemedMenu(
themedir, which_menu, GetMythMainWindow()->GetMainStack(), "game menu");
GameData data;
- diag->setCallback(GameCallback, &data);
- diag->setKillable();
+ menu->setCallback(GameCallback, &data);
+ menu->setKillable();
- if (diag->foundTheme())
+ if (menu->foundTheme())
{
- if (class LCD * lcd = LCD::Get())
- {
+ if (LCD * lcd = LCD::Get())
lcd->switchToTime();
- }
- GetMythMainWindow()->GetMainStack()->AddScreen(diag);
+
+ GetMythMainWindow()->GetMainStack()->AddScreen(menu);
return 0;
}
else
{
VERBOSE(VB_IMPORTANT, QString("Couldn't find menu %1 or theme %2")
.arg(which_menu).arg(themedir));
- delete diag;
+ delete menu;
return -1;
}
}
void runGames(void);
+int RunGames(void);
void setupKeys(void)
{
@@ -105,9 +105,12 @@
{
if (!gContext->TestPopupVersion("mythgame", libversion,
MYTH_BINARY_VERSION))
+ {
+ VERBOSE(VB_IMPORTANT,
+ QString("libmythgame.so/main.o: binary version mismatch"));
return -1;
+ }
-
gContext->ActivateSettingsCache(false);
if (!UpgradeGameDatabaseSchema())
{
@@ -126,18 +129,31 @@
return 0;
}
-void runGames(void)
+void runGames()
{
- gContext->addCurrentLocation("mythgame");
- GameTree gametree(gContext->GetMainWindow(), "gametree", "game-");
- gametree.exec();
- gContext->removeCurrentLocation();
+ RunGames();
}
+int RunGames(void)
+{
+ MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack();
+ GameUI *game = new GameUI(mainStack);
+
+ if (game->Create())
+ {
+ mainStack->AddScreen(game);
+ return 0;
+ }
+ else
+ {
+ delete game;
+ return -1;
+ }
+}
+
int mythplugin_run(void)
{
- runGames();
- return 0;
+ return RunGames();
}
int mythplugin_config(void)
Index: mythplugins/mythgame/mythgame/gamedetails.h
===================================================================
--- mythplugins/mythgame/mythgame/gamedetails.h (revision 0)
+++ mythplugins/mythgame/mythgame/gamedetails.h (revision 0)
@@ -0,0 +1,48 @@
+#ifndef GAMEDETAILS_H_
+#define GAMEDETAILS_H_
+
+#include
+
+#include "mythscreentype.h"
+#include "rominfo.h"
+
+class GameDetailsPopup : public MythScreenType
+{
+ Q_OBJECT
+
+ public:
+ GameDetailsPopup(MythScreenStack *parent, const RomInfo *romInfo);
+ ~GameDetailsPopup();
+
+ bool Create(void);
+ void SetReturnEvent(QObject *retobject, const QString &resultid);
+
+ private slots:
+ void Play(void);
+
+ private:
+ void handleText(const QString &name, const QString &value);
+ void handleImage(const QString &name, const QString &filename);
+
+ const RomInfo *m_romInfo;
+ QString m_id;
+ QObject *m_retObject;
+
+ MythUIText *m_gameName;
+ MythUIText *m_gameType;
+ MythUIText *m_romName;
+ MythUIText *m_crc;
+ MythUIText *m_romPath;
+ MythUIText *m_genre;
+ MythUIText *m_year;
+ MythUIText *m_country;
+ MythUIText *m_publisher;
+ MythUIText *m_allSystems;
+ MythUIImage *m_fanartImage;
+ MythUIImage *m_boxImage;
+
+ MythUIButton *m_playButton;
+ MythUIButton *m_doneButton;
+};
+
+#endif
Index: mythplugins/mythgame/mythgame/mythgame.pro
===================================================================
--- mythplugins/mythgame/mythgame/mythgame.pro (revision 20745)
+++ mythplugins/mythgame/mythgame/mythgame.pro (working copy)
@@ -9,11 +9,12 @@
INSTALLS += target
# Input
-HEADERS += gamehandler.h rominfo.h unzip.h gamesettings.h gametree.h
-HEADERS += rom_metadata.h romedit.h
+HEADERS += gamehandler.h rominfo.h unzip.h gamesettings.h gameui.h
+HEADERS += rom_metadata.h romedit.h gamedetails.h
-SOURCES += main.cpp gamehandler.cpp rominfo.cpp gametree.cpp unzip.c
+SOURCES += main.cpp gamehandler.cpp rominfo.cpp gameui.cpp unzip.c
SOURCES += gamesettings.cpp dbcheck.cpp rom_metadata.cpp romedit.cpp
+SOURCES += gamedetails.cpp
use_hidesyms {
QMAKE_CXXFLAGS += -fvisibility=hidden