forked from myst6re/hyne
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSavecardData.h
More file actions
115 lines (105 loc) · 3.65 KB
/
SavecardData.h
File metadata and controls
115 lines (105 loc) · 3.65 KB
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
/****************************************************************************
** Hyne Final Fantasy VIII Save Editor
** Copyright (C) 2009-2013 Arzel Jérôme <myst6re@gmail.com>
**
** 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 DEF_SAVECARDDATA
#define DEF_SAVECARDDATA
#include <QtCore>
#include "SaveData.h"
#include "UserDirectory.h"
#include "FF8Installation.h"
class SavecardData
{
public:
enum Type {
Pc, Ps, Vgs, Gme, Vmp, Psv, PcSlot, Unknown, Undefined
};
explicit SavecardData(const QString &path, quint8 slot=0, const FF8Installation &ff8Installation=FF8Installation());
explicit SavecardData(int saveCount);
virtual ~SavecardData();
bool open(const QString &path, quint8 slot=0);
const QFileSystemWatcher *watcher() const;
inline const QString &errorString() const {
return _lastError;
}
QString description() const;
void setDescription(const QString &desc);
void setIsTheLastEdited(int saveID);
inline const QList<SaveData *> &getSaves() const {
return saves;
}
void moveSave(int sourceID, int targetID);
SaveData *getSave(int id) const;
int saveCount() const;
bool save2PC(const quint8 id, const QString &saveAs);
bool save2PSV(const quint8 id, const QString &saveAs, const QByteArray &MCHeader);
bool save2PS(const QList<int> &ids, const QString &path, const Type newType, const QByteArray &MCHeader);
bool saveDirectory();
QString dirname() const;
QString name() const;
QString extension() const;
inline const QString &path() const {
return _path;
}
void setName(const QString &name);
inline bool isOpen() const {
return _ok;
}
inline Type type() const {
return _type;
}
inline quint8 slotNumber() const {
return _slot;
}
bool hasPath() const;
bool isModified() const;
void setModified(bool modified);
inline const FF8Installation &ff8Installation() const {
return _ff8Installation;
}
void compare(quint8 idLeft, quint8 idRight) const;
static void compare(const QByteArray &oldData, const QByteArray &newData);
bool getFormatFromRaw();
bool save(const QString &saveAs=QString(), Type newType=Pc);
private:
inline void setPath(const QString &path) {
_path = path;
}
void setType(Type type);
bool ps();
bool ps3();
bool pc(const QString &path = QString());
bool sstate_ePSXe();
bool sstate_pSX();
bool sstate(const QByteArray &fdata, const QByteArray &MCHeader);
void directory(const QString &filePattern);
void addSave(const QByteArray &data=QByteArray(), const QByteArray &header=QByteArray(), bool occupied=false);
QByteArray header(QFile *srcFile, Type newType, bool saveAs);
inline void setErrorString(const QString &errorString) {
_lastError = errorString;
}
QString _path, _lastError;
bool _ok;
Type _type;
quint16 start; // Start of save data
QFileSystemWatcher fileWatcher;
QList<SaveData *> saves;
bool _isModified;
QByteArray _description;
quint8 _slot;
const FF8Installation _ff8Installation;
};
#endif