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
QString RomPath(void) const
Definition: gamehandler.h:45
def scan(profile, smoonURL, gate)
Definition: scan.py:57
QString m_gametype
Definition: gamehandler.h:126
bool SpanDisks() const
Definition: gamehandler.h:100
void setRebuild(bool setrebuild)
Definition: gamehandler.h:96
QString m_romname
Definition: gamehandler.h:48
QString GameName(void) const
Definition: gamehandler.h:44
void setLoc(int lfoundloc)
Definition: gamehandler.h:43
Q_DECLARE_METATYPE(GrabberScript *)
int m_foundloc
Definition: gamehandler.h:52
GameFound
Definition: gamehandler.h:20
uint GamePlayerID() const
Definition: gamehandler.h:106
bool needRebuild(void) const
Definition: gamehandler.h:97
QString m_systemname
Definition: gamehandler.h:120
GameScanMap m_GameMap
Definition: gamehandler.h:130
QString SystemCmdLine() const
Definition: gamehandler.h:102
unsigned int uint
Definition: compat.h:140
QString m_commandline
Definition: gamehandler.h:122
#define CRC32(c, b)
CRC32 routine.
Definition: unzip.cpp:177
GameScan(QString lromname="", QString lromfullpath="", int lfoundloc=0, QString lgamename="", QString lrompath="")
Definition: gamehandler.h:31
QString m_gamename
Definition: gamehandler.h:50
QString GameType() const
Definition: gamehandler.h:107
QString RomFullPath(void) const
Definition: gamehandler.h:41
QStringList ValidExtensions() const
Definition: gamehandler.h:108
QString m_screenshots
Definition: gamehandler.h:124
QString m_rompath
Definition: gamehandler.h:121
QString SystemName() const
Definition: gamehandler.h:101
QMap< QString, RomData > RomDBMap
Definition: rom_metadata.h:47
int FoundLoc(void) const
Definition: gamehandler.h:42
static GameHandler * s_newInstance
Definition: gamehandler.h:137
QString m_workingpath
Definition: gamehandler.h:123
QString Rom(void) const
Definition: gamehandler.h:40
QString SystemWorkingPath() const
Definition: gamehandler.h:104
QMap< QString, GameScan > GameScanMap
Definition: gamehandler.h:57
RomDBMap m_romDB
Definition: gamehandler.h:129
QString m_rompath
Definition: gamehandler.h:51
QString SystemScreenShots() const
Definition: gamehandler.h:105
QStringList m_validextensions
Definition: gamehandler.h:127
QString SystemRomPath() const
Definition: gamehandler.h:103
QString m_romfullpath
Definition: gamehandler.h:49