Skip to content

Commit aff6038

Browse files
committed
update game list handeling
1 parent 9ab4cd4 commit aff6038

File tree

5 files changed

+148
-83
lines changed

5 files changed

+148
-83
lines changed

src/Data.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -218,14 +218,13 @@ ZipData Data::getDownload(const int id) {
218218
if (status) {
219219
if (query.exec() == true) {
220220
if (query.next() == true) {
221-
result = ZipData(
222-
query.value("Zip.name").toString(),
223-
query.value("Zip.size").toFloat(),
224-
query.value("Zip.md5sum").toString(),
225-
query.value("Zip.url").toString(),
226-
query.value("Zip.version").toInt(),
227-
query.value("Info.type").toInt(),
228-
query.value("Zip.release").toString());
221+
result.setFileName(query.value("Zip.name").toString());
222+
result.setMebibyteSize(query.value("Zip.size").toFloat());
223+
result.setMD5sum(query.value("Zip.md5sum").toString());
224+
result.setURL(query.value("Zip.url").toString());
225+
result.setVersion(query.value("Zip.version").toInt());
226+
result.setType(query.value("Info.type").toInt());
227+
result.setRelease(query.value("Zip.release").toString());
229228
} else {
230229
qDebug() << "No results found for Level ID:" << id;
231230
}

src/Data.hpp

Lines changed: 106 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,42 @@ struct File {
4141
* @brief Folder names game used on Windows.
4242
*
4343
* These names are used by steam and installed in the common folder on Linux.
44-
* Except for `TombEngine (TEN)` I made that one up.
44+
* 1-6 first folder name are used by steam
45+
*
4546
*/
4647
struct FolderNames {
47-
QMap<int, QString> data = {
48-
{0, "null"},
49-
{1, "Tomb Raider (I)"},
50-
{2, "Tomb Raider (II)"},
51-
{3, "TombRaider (III)"},
52-
{4, "Tomb Raider (IV) The Last Revelation"},
53-
{5, "Tomb Raider (V) Chronicles"},
54-
{6, "TombEngine (TEN)"},
48+
QMap<int, QStringList> data = {
49+
{0, {"null"}},
50+
{1, {
51+
"Tomb Raider (I)",
52+
"Tomb Raider 1",
53+
"Tomb Raider I"
54+
}},
55+
{2, {
56+
"Tomb Raider (II)",
57+
"Tomb Raider 2",
58+
"Tomb Raider II"
59+
}},
60+
{3, {
61+
"TombRaider (III)",
62+
"Tomb Raider 3",
63+
"Tomb Raider III"
64+
}},
65+
{4, {
66+
"Tomb Raider (IV) The Last Revelation",
67+
"Tomb Raider 4",
68+
"Tomb Raider - The Last Revelation"
69+
}},
70+
{5, {
71+
"Tomb Raider (V) Chronicles",
72+
"Tomb Raider 5",
73+
"Tomb Raider - Chronicles"
74+
}},
75+
{6, {"Tomb Raider (VI) The Angel of Darkness"}},
76+
{7, {"Tomb Raider I Unfinished Business"}},
77+
{8, {"Tomb Raider II Gold"}},
78+
{9, {"Tomb Raider - The Lost Artifact"}},
79+
{10, {"The Times - Exclusive Tomb Raider Level"}},
5580
};
5681
};
5782

@@ -65,12 +90,59 @@ struct FolderNames {
6590
struct ExecutableNames {
6691
QMap<int, QString> data = {
6792
{0, "null"},
68-
{1, "tomb.exe"},
93+
{1, "dosbox.exe"},
6994
{2, "Tomb2.exe"},
7095
{3, "tomb3.exe"},
7196
{4, "tomb4.exe"},
7297
{5, "PCTOMB5.EXE"},
73-
{6, "TombEngine.exe"},
98+
{6, "Launcher.exe"},
99+
{7, "tombub.exe"},
100+
{8, "tomb2.EXE"},
101+
{9, "tr3gold.exe"},
102+
{10, "tomb4.exe"},
103+
};
104+
};
105+
106+
struct GameRelease {
107+
QMap<int, QString> data = {
108+
{0, "null"},
109+
{1, "1996-11-14"},
110+
{2, "1997-11-21"},
111+
{3, "1998-11-20"},
112+
{4, "1999-11-24"},
113+
{5, "2000-11-17"},
114+
{6, "2003-07-01"},
115+
{7, "1998-12-31"},
116+
{8, "1999-06-04"},
117+
{9, "2000-03-00"},
118+
{10, "1999-12"},
119+
};
120+
};
121+
122+
/**
123+
* @struct MoodFolderNames
124+
* @brief Folder names moods used on Windows.
125+
*
126+
* These made up names that are used installed in the common folder on Linux.
127+
*/
128+
struct MoodFolderNames {
129+
QMap<int, QString> data = {
130+
{0, "null"},
131+
{1, "TombEngine (TEN)"}
132+
};
133+
};
134+
135+
/**
136+
* @struct MoodExecutableNames
137+
* @brief Executable game file names used by unofficial moods.
138+
*
139+
* These are used as a default starter by using a symbolic link to the executable
140+
* It can help simplify running it from steam or lutris.
141+
*/
142+
struct MoodExecutableNames {
143+
QMap<int, QString> data = {
144+
{0, "null"},
145+
{1, "TombEngine.exe"},
74146
};
75147
};
76148

@@ -87,93 +159,75 @@ struct ZipData {
87159
*
88160
* Initializes an empty instance of `ZipData`.
89161
*/
90-
ZipData() {}
162+
ZipData() {
163+
m_mebibyteSize = 0.0;
164+
m_version = 0;
165+
m_type = 0;
166+
}
91167

92168
/**
93169
* @brief This sets the file name metadata.
94170
* @param fileName TRLE level zip file name.
95171
*/
96172
inline void setFileName(const QString& fileName) {
173+
m_fileName = fileName;
97174
}
98175

99176
/**
100177
* @brief This sets the file size metadata.
101178
* @param size Size in MiB.
102179
*/
103-
inline void setZise(const float size) {
180+
inline void setMebibyteSize(const float size) {
181+
m_mebibyteSize = size;
104182
}
105183

106184
/**
107185
* @brief This sets the file md5sum metadata.
108186
* @param md5sum Checksum of the archive.
109187
*/
110-
inline void setMd5sum(const QString& md5sum) {
188+
inline void setMD5sum(const QString& MD5sum) {
189+
m_MD5sum = MD5sum;
111190
}
112191

113192
/**
114193
* @brief This sets the URL for the file.
115194
* @param url String of download address.
116195
*/
117-
inline void setURL(const QString& url) {
196+
inline void setURL(const QString& URL) {
197+
m_URL = URL;
118198
}
119199

120200
/**
121201
* @brief This sets the zip file name metadata.
122202
* @param version File version from trcustoms.org
123203
*/
124204
inline void setVersion(const qint64 version) {
205+
m_version = version;
125206
}
126207

127208
/**
128209
* @brief This sets the zip file name metadata.
129210
* @param type Level type.
130211
*/
131212
inline void setType(const qint64 type) {
213+
m_type = type;
132214
}
133215

134216
/**
135217
* @brief This sets the zip file name metadata.
136218
* @param release date of file release.
137219
*/
138220
inline void setRelease(const QString& release) {
221+
m_release = m_release;
139222
}
140223

141-
/**
142-
* @brief Parameterized constructor for `ZipData`.
143-
*
144-
* This constructor initializes a `ZipData` object with metadata.
145-
*
146-
* @param zipName TRLE level zip file name.
147-
* @param zipSize Size of the file form TRLE in MiB.
148-
* @param md5sum checksum of the archive.
149-
* @param url String of download address.
150-
* @param version File version from trcustoms.org
151-
* @param type Level type.
152-
* @param release date of file release.
153-
*/
154-
ZipData(
155-
const QString& zipName,
156-
float zipSize,
157-
const QString& md5sum,
158-
const QString& url,
159-
int version,
160-
int type,
161-
const QString& release) :
162-
name(zipName),
163-
mebibyteSize(zipSize),
164-
md5sum(md5sum),
165-
url(url),
166-
version(version),
167-
type(type),
168-
release(release) {}
169-
170-
QString name; ///< The archive file name.
171-
float mebibyteSize; ///< The archive file size in MiB.
172-
QString md5sum; ///< The archive md5sum.
173-
QString url; ///< The URL of the TRLE level download.
174-
int version; ///< The Version of trcustoms archive file.
175-
int type; ///< The TRLE type used to identify a executable.
176-
QString release; ///< The The date of file release from trcustoms.
224+
QString m_fileName; ///< The archive file name.
225+
float m_mebibyteSize; ///< The archive file size in MiB.
226+
QString m_MD5sum; ///< The archive md5sum.
227+
QString m_URL; ///< The URL of the TRLE level download.
228+
int m_version; ///< The Version of trcustoms archive file.
229+
int m_type; ///< The TRLE type used to identify a executable.
230+
QString m_release; ///< The The date of file release from trcustoms.
177231
};
178232

179233
/**
@@ -196,7 +250,7 @@ struct OriginalGameData {
196250
*
197251
* This constructor initializes a `OriginalGameData` object with game metadata.
198252
*
199-
* @param id The numeric game datbase ID.
253+
* @param id The numeric game database ID.
200254
* @param title The TRLE title. Expected to contain a single name.
201255
* @param shortBody some short game info text.
202256
* @param type The TRLE type, represented by a numeric ID.

src/Model.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ QString Model::getGameDirectory(int id) {
7171
QString value;
7272
FolderNames folder;
7373
if (folder.data.contains(id)) {
74-
value = folder.data[id];
74+
value = folder.data[id][0];
7575
} else {
7676
qDebug() << "Id number:" << id << " is not a game.";
7777
}
@@ -255,21 +255,22 @@ void Model::getLevel(int id) {
255255
if (id > 0) {
256256
bool status = false;
257257
ZipData zipData = data.getDownload(id);
258-
downloader.setUrl(zipData.url);
259-
downloader.setSaveFile(zipData.name);
258+
downloader.setUrl(zipData.m_URL);
259+
downloader.setSaveFile(zipData.m_fileName);
260260
// this if just slips up execution but has nothing to do with the error
261-
if (fileManager.checkFile(zipData.name, false)) {
262-
qWarning() << "File exists:" << zipData.name;
263-
status = getLevelHaveFile(id, zipData.md5sum, zipData.name);
261+
if (fileManager.checkFile(zipData.m_fileName, false)) {
262+
qWarning() << "File exists:" << zipData.m_fileName;
263+
status = getLevelHaveFile(id, zipData.m_MD5sum, zipData.m_fileName);
264264
} else {
265-
qDebug() << "File does not exist:" << zipData.name;
266-
status = getLevelDontHaveFile(id, zipData.md5sum, zipData.name);
265+
qDebug() << "File does not exist:" << zipData.m_fileName;
266+
status = getLevelDontHaveFile(
267+
id, zipData.m_MD5sum, zipData.m_fileName);
267268
}
268269
if (status == true) {
269270
if (!unpackLevel(
270271
id,
271-
zipData.name,
272-
getExecutableName(zipData.type))) {
272+
zipData.m_fileName,
273+
getExecutableName(zipData.m_type))) {
273274
qDebug() << "unpackLevel failed";
274275
}
275276
}

src/TombRaiderLinuxLauncher.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ void TombRaiderLinuxLauncher::onCurrentItemChanged(
277277
const QModelIndex &current, const QModelIndex &previous) {
278278
if (current.isValid()) {
279279
qint64 id = levelListModel->getLid(current);
280-
if (id < 0) { // its the original game
280+
if (levelListModel->getListType()) { // its the original game
281281
originalSelected(id);
282282
} else {
283283
levelDirSelected(id);
@@ -342,14 +342,14 @@ void TombRaiderLinuxLauncher::downloadClicked() {
342342
QModelIndex current = ui->listViewLevels->currentIndex();
343343
if (current.isValid()) {
344344
qint64 id = levelListModel->getLid(current);
345-
if (id < 0) {
345+
if (levelListModel->getListType()) {
346+
qDebug() << "controller.setupGame(" << id << ")";
346347
ui->listViewLevels->setEnabled(false);
347348
ui->progressBar->setValue(0);
348349
ui->stackedWidgetBar->setCurrentWidget(
349350
ui->stackedWidgetBar->findChild<QWidget*>("progress"));
350-
// debugStop(QString("%1").arg(id*(-1)));
351-
controller.setupGame(id*(-1));
352-
} else if (id > 0) {
351+
controller.setupGame(id);
352+
} else {
353353
ui->listViewLevels->setEnabled(false);
354354
ui->progressBar->setValue(0);
355355
ui->stackedWidgetBar->setCurrentWidget(

src/levelViewList.hpp

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,22 +90,22 @@ class LevelListModel : public QAbstractListModel {
9090

9191
if (m_original == true) {
9292
if ((index.isValid()) && (row < m_originalMainList.count())) {
93-
const OriginalGameData item = m_originalMainList.at(row);
93+
const OriginalGameData* item = &m_originalMainList.at(row);
9494
switch (role) {
9595
case Qt::DisplayRole:
96-
result = item.m_title;
96+
result = item->m_title;
9797
break;
9898
case Qt::UserRole + 1:
99-
result = item.m_shortBody;
99+
result = item->m_shortBody;
100100
break;
101101
case Qt::UserRole + 2:
102-
result = item.m_type;
102+
result = item->m_type;
103103
break;
104104
case Qt::UserRole + 5:
105-
result = item.m_releaseDate;
105+
result = item->m_releaseDate;
106106
break;
107107
case Qt::UserRole + 7:
108-
result = item.m_cover;
108+
result = item->m_cover;
109109
break;
110110
case Qt::UserRole + 10:
111111
result = true;
@@ -153,8 +153,19 @@ class LevelListModel : public QAbstractListModel {
153153
}
154154

155155
int getLid(const QModelIndex &index) const {
156-
const ListItemData* item = m_filterList.at(index.row());
157-
return item->m_trle_id;
156+
qint64 id = 0;
157+
if (m_original) {
158+
const OriginalGameData* item = &m_originalMainList.at(index.row());
159+
id = item->m_game_id;
160+
} else {
161+
const ListItemData* item = m_filterList.at(index.row());
162+
id = item->m_trle_id;
163+
}
164+
return id;
165+
}
166+
167+
bool getListType() const {
168+
return m_original;
158169
}
159170

160171
void getMoreCovers() {

0 commit comments

Comments
 (0)