-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathhandlestuff.h
140 lines (121 loc) · 4.92 KB
/
handlestuff.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
/*
This file is part of the SaveState2snes software
Copyright (C) 2017 Sylvain "Skarsnik" Colinet <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef HANDLESTUFF_H
#define HANDLESTUFF_H
#include <QString>
#include <QStandardItem>
#include <QDir>
#define MyRolePath Qt::UserRole + 1
struct Category {
struct Category* parent;
QVector<Category*> children;
QString name;
QString path;
QIcon icon;
};
struct MemoryPreset {
QString gameName;
QString domain;
quint64 address;
quint8 size;
};
struct GameInfos
{
quint16 saveShortcut = 0;
quint16 loadShortcut = 0;
MemoryPreset memoryPreset;
QString name;
bool checkMemory;
};
class HandleStuff : public QObject
{
Q_OBJECT
public:
HandleStuff();
QStringList loadGames();
QVector<Category*> loadCategories(QString game);
QIcon getGameIcon(QString game);
bool addGame(QString newGame);
void setSaveStateDir(QString dir);
Category* addCategory(QString newCategory, QString parentPath);
QStringList loadSaveStates(QString categoryPath);
bool addSaveState(QString name, bool trigger = true);
bool removeCategory(QString categoryPath);
bool renameSaveState(int row, QString newName);
void changeStateOrder(int from, int to);
bool loadSaveState(QString name);
bool deleteSaveState(int row);
void setCategoryIcon(QString categoryPath, QString iconPath);
QPixmap getScreenshot(QString name);
QString getScreenshotPath(QString name);
QString getSavestatePath(QString name);
GameInfos gameInfos();
void setGameShortCut(quint16 save, quint16 load);
void setMemoryToWatch(MemoryPreset preset);
void saveMemoryCheck(bool);
virtual void savestateReady();
virtual void savestateUnready();
virtual QByteArray getScreenshotData() = 0;
virtual bool hasShortcutsEdit() = 0;
virtual bool hasScreenshots() = 0;
virtual void setShortcutSave(quint16 shortcut) = 0;
virtual void setShortcutLoad(quint16 shortcut) = 0;
virtual quint16 shortcutSave() = 0;
virtual quint16 shortcutLoad() = 0;
virtual bool hasMemoryWatch() = 0;
virtual void startMemoryWatch() = 0;
virtual void stopMemoryWatch() = 0;
virtual void controllerLoadState() = 0;
virtual void controllerSaveState() = 0;
// This is only for the subclass
signals:
void loadStateFinished(bool);
void saveStateFinished(bool);
void screenshotDone();
// The real public signals
signals:
void addSaveStateFinished(bool);
void loadSaveStateFinished(bool);
void controllerLoadStateFinished(bool);
void controllerSaveStateFinished(bool);
void gotMemoryValue(quint64 value);
void newGameLoaded();
protected:
virtual bool saveState(bool trigger) = 0;
virtual bool saveState(QString path) = 0;
virtual bool loadState(QString path) = 0;
virtual void loadState(QByteArray data) = 0;
virtual bool hasPostSaveScreenshot() = 0;
virtual bool doScreenshot() = 0;
virtual bool needByteData() = 0;
QByteArray saveStateData;
private:
QDir saveDirectory;
QStringList games;
QMap<QString, Category*> categoriesByPath;
QMap<QString, Category*> categories;
QMap<QString, QStringList> saveStates;
QString gameLoaded;
Category* catLoaded;
GameInfos m_gameInfo;
QFileInfo saveStateFileInfo;
void findCategory(Category *parent, QDir dir);
QStringList getCacheOrderList(QString file, QString dirPath);
void writeCacheOrderFile(QString file, QString dirPath);
void onSaveStateFinished(bool success);
void saveScreenshot();
void onScreenshotDone();
};
#endif // HANDLESTUFF_H