forked from svn2github/mamepgui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gamelist.h
303 lines (254 loc) · 6.46 KB
/
gamelist.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
#ifndef _GAMELIST_H_
#define _GAMELIST_H_
#include <QtGui>
enum
{
GAME_MISSING = 0,
GAME_COMPLETE,
GAME_INCOMPLETE
};
enum
{
GAMELIST_INIT_FULL = 0,
GAMELIST_INIT_AUDIT,
GAMELIST_INIT_DIR,
GAMELIST_INIT_DRIVER
};
enum
{
RUNMAME_NORMAL = 0,
RUNMAME_EXTROM,
RUNMAME_CMD
};
enum
{
DOCK_SNAP,
DOCK_FLYER,
DOCK_CABINET,
DOCK_MARQUEE,
DOCK_TITLE,
DOCK_CPANEL,
DOCK_PCB,
DOCK_HISTORY,
DOCK_MAMEINFO,
DOCK_DRIVERINFO,
DOCK_STORY,
DOCK_COMMAND,
DOCK_LAST
};
enum
{
FOLDER_ALLGAME = 0,
FOLDER_ALLARC,
FOLDER_AVAILABLE,
FOLDER_UNAVAILABLE,
FOLDER_CONSOLE,
FOLDER_MANUFACTURER,
FOLDER_YEAR,
FOLDER_SOURCE,
FOLDER_BIOS,
FOLDER_CPU,
FOLDER_SND,
FOLDER_HARDDISK,
FOLDER_SAMPLES,
FOLDER_DUMPING,
FOLDER_WORKING,
FOLDER_NONWORKING,
FOLDER_ORIGINALS,
FOLDER_CLONES,
FOLDER_RESOLUTION,
FOLDER_PALETTESIZE,
FOLDER_REFRESH,
FOLDER_DISPLAY,
FOLDER_CONTROLS,
FOLDER_CHANNELS,
FOLDER_SAVESTATE,
FOLDER_MECHANICAL,
FOLDER_NONMECHANICAL,
/*
FOLDER_DEFICIENCY,
FOLDER_ARTWORK,
*/
FOLDER_EXT,
MAX_FOLDERS,
SORT_STR
};
class UpdateSelectionThread : public QThread
{
Q_OBJECT
public:
QString historyText;
QString mameinfoText;
QString driverinfoText;
QString storyText;
QString commandText;
QByteArray pmSnapData[DOCK_LAST];
UpdateSelectionThread(QObject *parent = 0);
~UpdateSelectionThread();
void update();
signals:
void snapUpdated(int);
protected:
void run();
private:
QMutex mutex;
QString gameName;
bool abort;
QString getHistory(const QString &, const QString &, int);
void convertHistory(QString &, const QString &);
void convertMameInfo(QString &, const QString &);
void convertCommand(QString &);
QByteArray getScreenshot(const QString &, const QString &, int);
};
class TreeItem
{
public:
TreeItem(const QList<QVariant> &data, TreeItem *parent = 0);
~TreeItem();
void appendChild(TreeItem *child);
TreeItem *child(int row);
int childCount() const;
int columnCount() const;
QVariant data(int column) const;
int row() const;
TreeItem *parent();
private:
QList<TreeItem*> childItems;
QList<QVariant> itemData;
TreeItem *parentItem;
};
class GameInfo;
class TreeModel : public QAbstractItemModel
{
Q_OBJECT
public:
TreeModel(QObject *parent = 0);
~TreeModel();
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
QModelIndex index(int column, TreeItem *childItem) const;
QModelIndex parent(const QModelIndex &index) const;
QVariant displayData(GameInfo *gameInfo, int col) const;
QVariant data(const QModelIndex &index, int role) const;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
int rowCount(const QModelIndex &parent = QModelIndex()) const;
int columnCount(const QModelIndex &parent = QModelIndex()) const;
void updateRow(const QModelIndex &index);
private:
TreeItem *rootItem;
TreeItem *getItem(const QModelIndex &index) const;
TreeItem *setupModelData(TreeItem *, QString);
};
class GameListTreeView : public QTreeView
{
Q_OBJECT
public:
GameListTreeView(QWidget * = 0);
void paintEvent(QPaintEvent *);
QModelIndex moveCursor(QAbstractItemView::CursorAction, Qt::KeyboardModifiers);
void keyPressEvent(QKeyEvent *);
};
class GameListDelegate : public QItemDelegate
{
Q_OBJECT
public:
GameListDelegate(QObject * = 0);
QSize sizeHint(const QStyleOptionViewItem &, const QModelIndex &) const;
void paint(QPainter *, const QStyleOptionViewItem &, const QModelIndex &) const;
};
class Gamelist : public QObject
{
Q_OBJECT
public:
QProcess *loadProc;
QStringList xmlLines;
QMenu *menuContext;
QMenu *headerMenu;
QString listMode;
QStringList intFolderNames0, intFolderNames;
QPixmap pmDeco;
QRect rectDeco;
quint16 filterFlags;
bool autoAudit;
Gamelist(QObject *parent = 0);
~Gamelist();
void loadIcon();
void disableCtrls();
void restoreFolderSelection(bool = false);
void centerGameSelection(QModelIndex);
bool isAuditConsoleFolder(const QString&);
bool isConsoleFolder();
QString getResolution(GameInfo *, int);
public slots:
void init(bool = true, int = GAMELIST_INIT_AUDIT); //the default init value is a hack, for connect slots
void update(int = GAMELIST_INIT_FULL);
void restoreGameSelection();
void runMame(int = RUNMAME_NORMAL, QStringList = QStringList());
QString getViewString(const QModelIndex &index, int column) const;
GameInfo* getGameInfo (const QModelIndex &, QString&);
void updateProgress(int progress);
void switchProgress(int max, QString title);
void updateSelection();
void updateSelection(const QModelIndex & current, const QModelIndex & previous);
// external process management
void runMameFinished(int, QProcess::ExitStatus);
void runMergedFinished(int, QProcess::ExitStatus);
void filterFlagsChanged(bool);
void filterSearchCleared();
void filterSearchChanged();
void filterFolderChanged(QTreeWidgetItem * = NULL, QTreeWidgetItem * = NULL);
private:
bool hasInitd;
QString currentTempROM;
QFutureWatcher<void> loadIconWatcher;
QAbstractItemDelegate *defaultGameListDelegate;
// interactive threads used by the game list
UpdateSelectionThread selectionThread;
QList<QTreeWidgetItem *> intFolderItems;
QStringList extFolderNames;
QTimer timerJoy;
QTime timeJoyRepeatDelay;
void initFolders();
int parseExtFolders(const QString &);
void initExtFolders(const QString &, const QString &);
void saveExtFolders(const QString &);
void initMenus();
void updateDynamicMenu(QMenu *);
void updateDeleteCfgMenu(const QString &);
void addDeleteCfgMenu(const QString &, const QString &);
void loadMMO(int);
void loadIconWorkder();
void openJoysticks();
void closeJoysticks();
private slots:
void setupSnap(int);
void showContextMenu(const QPoint &);
void updateContextMenu();
void mountDevice();
void unmountDevice();
void toggleFolder();
void showHeaderContextMenu(const QPoint &);
void updateHeaderContextMenu();
void deleteCfg();
void addToExtFolder();
void removeFromExtFolder();
void postLoadIcon();
void processJoyEvents();
};
class GameListSortFilterProxyModel : public QSortFilterProxyModel
{
Q_OBJECT
public:
QString searchText, filterText;
QStringList filterList;
GameListSortFilterProxyModel(QObject *parent = 0);
protected:
bool filterAcceptsRow(int, const QModelIndex &) const;
bool lessThan(const QModelIndex &, const QModelIndex &) const;
};
extern Gamelist *gameList;
extern QString currentGame, currentFolder;
extern QStringList hiddenFolders;
extern QMap<QString, QString> consoleMap;
extern QActionGroup *colSortActionGroup;
extern QList<QAction *> colToggleActions;
#endif