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