MythTV  master
gamehandler.h
Go to the documentation of this file.
1 // -*- Mode: c++ -*-
2 #ifndef GAMEHANDLER_H_
3 #define GAMEHANDLER_H_
4 
5 // C++
6 #include <utility>
7 
8 // Qt
9 #include <QEvent>
10 #include <QMap>
11 #include <QObject>
12 #include <QStringList>
13 
14 // MythTV
15 #include <libmythbase/mythdbcon.h>
16 
17 // MythGame
18 #include "rom_metadata.h"
19 #include "rominfo.h"
20 
21 class MythMainWindow;
22 class GameHandler;
23 
25 {
30 };
31 
32 class GameScan
33 {
34  public:
35  explicit GameScan(QString lromname = "", QString lromfullpath = "",
36  int lfoundloc = 0, QString lgamename = "",
37  QString lrompath = "") :
38  m_romname(std::move(lromname)),
39  m_romfullpath(std::move(lromfullpath)),
40  m_gamename(std::move(lgamename)),
41  m_rompath(std::move(lrompath)),
42  m_foundloc(lfoundloc) {}
43 
44  QString Rom(void) const { return m_romname; }
45  QString RomFullPath(void) const { return m_romfullpath; }
46  int FoundLoc(void) const { return m_foundloc; }
47  void setLoc(int lfoundloc) { m_foundloc = lfoundloc; }
48  QString GameName(void) const { return m_gamename; }
49  QString RomPath(void) const { return m_rompath; }
50 
51  private:
52  QString m_romname;
53  QString m_romfullpath;
54  QString m_gamename;
55  QString m_rompath;
57 };
58 
60 
61 using GameScanMap = QMap<QString, GameScan>;
62 
64 class GameHandler : public QObject
65 {
66  Q_OBJECT
67 
68  public:
69  GameHandler() = default;
70 
71  static void updateSettings(GameHandler *handler);
72  static GameHandler *getHandler(uint i);
73  static GameHandler *newHandler(QString name);
74  static uint count(void);
75  void InitMetaDataMap(const QString& GameType);
76  void GetMetadata(GameHandler *handler, const QString& rom,
77  QString* Genre, QString* Year, QString* Country,
78  QString* CRC32, QString* GameName,
79  QString* Plot, QString* Publisher, QString* Version,
80  QString* Fanart, QString* Boxart);
81 
82  void promptForRemoval(const GameScan& scan);
83  void UpdateGameDB(GameHandler *handler);
84  void VerifyGameDB(GameHandler *handler);
85 
86  void clearAllGameData(void);
87 
88  static int buildFileCount(const QString& directory, GameHandler *handler);
89  void buildFileList(const QString& directory, GameHandler *handler,
90  int* filecount);
91 
92  void processGames(GameHandler *handler);
93  static void processAllGames(void);
94  static void registerHandler(GameHandler *handler);
95  static void Launchgame(RomInfo *romdata, const QString& systemname);
96  static void EditSettings(RomInfo *romdata);
97  static void EditSystemSettings(RomInfo *romdata);
98  static RomInfo* CreateRomInfo(RomInfo* parent);
99 
100  void setRebuild(bool setrebuild) { m_rebuild = setrebuild; }
101  bool needRebuild(void) const { return m_rebuild; }
102 
103  static RomInfo* create_rominfo(RomInfo* parent);
104  bool SpanDisks() const { return m_spandisks; }
105  QString SystemName() const { return m_systemname; }
106  QString SystemCmdLine() const { return m_commandline; }
107  QString SystemRomPath() const { return m_rompath; }
108  QString SystemWorkingPath() const { return m_workingpath; }
109  QString SystemScreenShots() const { return m_screenshots; }
110  uint GamePlayerID() const { return m_gameplayerid; }
111  QString GameType() const { return m_gametype; }
112  QStringList ValidExtensions() const { return m_validextensions; }
113 
114  static void clearAllMetadata(void);
115 
116  static GameHandler* GetHandler(RomInfo *rominfo);
117  static GameHandler* GetHandlerByName(const QString& systemname);
118 
119  protected:
120  void customEvent(QEvent *event) override; // QObject
121 
122  bool m_rebuild {false};
123  bool m_spandisks {false};
124  QString m_systemname;
125  QString m_rompath;
126  QString m_commandline;
127  QString m_workingpath;
128  QString m_screenshots;
129  uint m_gameplayerid {0};
130  QString m_gametype;
131  QStringList m_validextensions;
132 
135 
136  bool m_removeAll {false};
137  bool m_keepAll {false};
138 
139  private:
140  void CreateProgress(const QString& message);
142 
143  MythUIProgressDialog *m_progressDlg {nullptr};
144 };
145 
146 #endif
inBoth
@ inBoth
Definition: gamehandler.h:29
GameHandler::setRebuild
void setRebuild(bool setrebuild)
Definition: gamehandler.h:100
GameHandler
Definition: gamehandler.h:64
GameHandler::SpanDisks
bool SpanDisks() const
Definition: gamehandler.h:104
mythdbcon.h
GameHandler::needRebuild
bool needRebuild(void) const
Definition: gamehandler.h:101
GameScan::GameScan
GameScan(QString lromname="", QString lromfullpath="", int lfoundloc=0, QString lgamename="", QString lrompath="")
Definition: gamehandler.h:35
GameScan::m_romfullpath
QString m_romfullpath
Definition: gamehandler.h:53
hardwareprofile.scan.scan
def scan(profile, smoonURL, gate)
Definition: scan.py:57
GameScan::m_rompath
QString m_rompath
Definition: gamehandler.h:55
Q_DECLARE_METATYPE
Q_DECLARE_METATYPE(StandardSetting *)
GameHandler::GamePlayerID
uint GamePlayerID() const
Definition: gamehandler.h:110
GameScan::m_romname
QString m_romname
Definition: gamehandler.h:52
GameScan::RomPath
QString RomPath(void) const
Definition: gamehandler.h:49
MythUIProgressDialog
Definition: mythprogressdialog.h:59
GameScan
Definition: gamehandler.h:32
GameScan::m_foundloc
int m_foundloc
Definition: gamehandler.h:56
GameHandler::GameType
QString GameType() const
Definition: gamehandler.h:111
rominfo.h
GameScan::RomFullPath
QString RomFullPath(void) const
Definition: gamehandler.h:45
GameScan::m_gamename
QString m_gamename
Definition: gamehandler.h:54
GameHandler::m_systemname
QString m_systemname
Definition: gamehandler.h:124
uint
unsigned int uint
Definition: compat.h:79
inFileSystem
@ inFileSystem
Definition: gamehandler.h:27
inDatabase
@ inDatabase
Definition: gamehandler.h:28
GameScan::GameName
QString GameName(void) const
Definition: gamehandler.h:48
GameHandler::m_screenshots
QString m_screenshots
Definition: gamehandler.h:128
RomInfo
Definition: rominfo.h:14
GameHandler::SystemCmdLine
QString SystemCmdLine() const
Definition: gamehandler.h:106
GameScan::FoundLoc
int FoundLoc(void) const
Definition: gamehandler.h:46
GameFound
GameFound
Definition: gamehandler.h:24
GameHandler::ValidExtensions
QStringList ValidExtensions() const
Definition: gamehandler.h:112
GameHandler::SystemName
QString SystemName() const
Definition: gamehandler.h:105
GameHandler::m_commandline
QString m_commandline
Definition: gamehandler.h:126
std
Definition: mythchrono.h:23
RomDBMap
QMap< QString, RomData > RomDBMap
Definition: rom_metadata.h:49
GameScan::Rom
QString Rom(void) const
Definition: gamehandler.h:44
GameScanMap
QMap< QString, GameScan > GameScanMap
Definition: gamehandler.h:61
GameHandler::SystemScreenShots
QString SystemScreenShots() const
Definition: gamehandler.h:109
inNone
@ inNone
Definition: gamehandler.h:26
GameHandler::m_gameMap
GameScanMap m_gameMap
Definition: gamehandler.h:134
GameHandler::s_newInstance
static GameHandler * s_newInstance
Definition: gamehandler.h:141
GameType
Definition: gamesettings.cpp:246
rom_metadata.h
GameHandler::m_rompath
QString m_rompath
Definition: gamehandler.h:125
GameHandler::m_romDB
RomDBMap m_romDB
Definition: gamehandler.h:133
GameScan::setLoc
void setLoc(int lfoundloc)
Definition: gamehandler.h:47
GameHandler::m_validextensions
QStringList m_validextensions
Definition: gamehandler.h:131
GameHandler::SystemRomPath
QString SystemRomPath() const
Definition: gamehandler.h:107
GameHandler::m_gametype
QString m_gametype
Definition: gamehandler.h:130
MythMainWindow
Definition: mythmainwindow.h:28
GameHandler::m_workingpath
QString m_workingpath
Definition: gamehandler.h:127
GameHandler::SystemWorkingPath
QString SystemWorkingPath() const
Definition: gamehandler.h:108