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