Skip to content

Commit 4e5a1d8

Browse files
committed
add default database download
1 parent aff6038 commit 4e5a1d8

File tree

9 files changed

+126
-32
lines changed

9 files changed

+126
-32
lines changed

CMakeLists.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ if(NOT EXISTS "${CMAKE_SOURCE_DIR}/libs/miniz/CMakeLists.txt")
3737
file(WRITE "${CMAKE_SOURCE_DIR}/libs/miniz/CMakeLists.txt" "${my_cmake}")
3838
endif()
3939

40+
if(NOT EXISTS "${CMAKE_SOURCE_DIR}/database/tombll.db")
41+
message(STATUS "Database not found, running get_trle.sh...")
42+
execute_process(
43+
COMMAND bash "${CMAKE_SOURCE_DIR}/database/get_trle.sh"
44+
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
45+
)
46+
endif()
47+
4048
add_subdirectory(libs/miniz)
4149

4250
# Add LIEF as a subdirectory
@@ -51,7 +59,7 @@ set(LIEF_MACHO OFF)
5159
set(LIEF_DEX OFF)
5260
set(LIEF_ART OFF)
5361

54-
if(NOT EXISTS "${CMAKE_SOURCE_DIR}/libs/LIEF/CMakeLists.txt")
62+
if(NOT EXISTS "${CMAKE_SOURCE_DIR}/libs/LIEF/CMakeLists.txt" AND NOT NO_DATABASE)
5563
message(STATUS "Submodule 'libs/LIEF' not found. Updating submodules...")
5664
execute_process(
5765
COMMAND git submodule update --init --recursive

database/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ trle
88
trle.sanitized.tar.gz
99
trle.sanitized
1010
.env
11+
tombll.db

database/get_trle.sh

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/bin/bash
2+
cd "$(dirname "$0")" || exit 1
23

34
# Check if megadl or mega-get is installed
45
if command -v megadl &> /dev/null; then
@@ -11,22 +12,27 @@ else
1112
exit 1
1213
fi
1314

15+
rm -f tombll.db
16+
1417
# Define the download link
15-
url1="https://mega.nz/file/xXkV3JqJ#1Ejtd9enidYYpV3FRLO5KSzcUg7-_Jg-vNi66RKo8aI"
16-
url2="https://mega.nz/file/kDlEVJiB#eRam4FXZBljrfHaurE3qz56VVi7RxPm-7IxG0aBq-uM"
18+
url1="https://mega.nz/file/2MESHZSa#9J6VF5FlOzc-FZLjdxi-4wB-fio8N3nEZK2Fp8Nn4z4"
1719

1820
# Download the file using the available tool
1921
echo "Using $downloader to download the file..."
2022
$downloader "$url1"
21-
$downloader "$url2"
2223

2324
# Verify the checksum (assuming you want to compare it to the expected checksum)
2425
echo "Verifying checksum..."
25-
echo "29e7e89bc11ebe77eafbd1c78ca3f1a7 trle.tar.gz" | md5sum -c -
26-
echo "7865bf73f09d531fb0ddc6b654d611f5 trle.sanitized.tar.gz" | md5sum -c -
26+
md5sum1="10da17189319c0b4ea73e30b54945101"
27+
md5sum1_dl=$(md5sum tombll.db | cut -d' ' -f1)
2728

28-
# Extract the tar.gz file
29-
echo "Extracting the archive..."
30-
tar xzf trle.tar.gz
29+
if [[ $md5sum1 == "$md5sum1_dl" ]]
30+
then
31+
echo "sbopkg download OK"
32+
else
33+
echo "sbopkg download faild"
34+
rm -f tombll.db
35+
exit 1
36+
fi
3137

3238
echo "Download and extraction complete."

database/tombll.db

28.4 MB
Binary file not shown.

setup_nvim_lsp.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ cmake \
1414
"$@" ..
1515

1616
cd ..
17-
ln -s build/compile_commands.json compile_commands.json
17+
# ln -s build/compile_commands.json compile_commands.json
1818

1919
git config submodule.libs/miniz.ignore all

src/Model.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,12 @@ void Model::getCoverList(QVector<ListItemData*>* items) {
111111
int Model::getItemState(int id) {
112112
int status = 0;
113113
if (id < 0) {
114-
status = 1;
114+
QString dir = QString("Original.TR%1").arg(id);
115+
if (fileManager.checkDir(dir, false)) {
116+
status = 2;
117+
} else {
118+
status = 1;
119+
}
115120
} else if (id > 0) {
116121
QString dir = QString("%1.TRLE").arg(id);
117122
if (fileManager.checkDir(dir, false)) {

src/TombRaiderLinuxLauncher.cpp

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,27 @@ TombRaiderLinuxLauncher::TombRaiderLinuxLauncher(QWidget *parent)
151151
}
152152

153153
void TombRaiderLinuxLauncher::generateList(const QList<int>& availableGames) {
154+
setInstalled();
154155
levelListModel->setLevels(availableGames);
155156
}
156157

158+
void TombRaiderLinuxLauncher::setInstalled() {
159+
QStringList keys = m_settings.allKeys();
160+
QHash<int, bool> installedLevel;
161+
QHash<int, bool> installedGame;
162+
for (const QString &key : keys) {
163+
if (key.startsWith("installed/game")) {
164+
qint64 id = key.mid(QString("installed/game").length()).toInt();
165+
installedGame.insert(id, m_settings.value(key).toBool());
166+
} else if (key.startsWith("installed/level")) {
167+
qint64 id = key.mid(QString("installed/level").length()).toInt();
168+
installedLevel.insert(id, m_settings.value(key).toBool());
169+
}
170+
}
171+
levelListModel->setInstalledListOriginal(installedGame);
172+
levelListModel->setInstalledList(installedLevel);
173+
}
174+
157175
void TombRaiderLinuxLauncher::sortByTitle() {
158176
levelListModel->sortItems(levelListModel->compareTitles);
159177
}
@@ -222,7 +240,7 @@ void TombRaiderLinuxLauncher::setup() {
222240
const QString homeDir =
223241
QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
224242
qDebug() << "Home Directory:" << homeDir;
225-
const QString s = "/.steam/root/steamapps/common/";
243+
const QString s = "/.steam/steam/steamapps/common/";
226244
const QString l = "/.local/share/TombRaiderLinuxLauncher";
227245
ui->gamePathEdit->setText(homeDir + s);
228246
ui->levelPathEdit->setText(homeDir + l);
@@ -231,8 +249,7 @@ void TombRaiderLinuxLauncher::setup() {
231249
void TombRaiderLinuxLauncher::originalSelected(qint64 id) {
232250
if (id != 0) {
233251
// the game directory was a symbolic link and it has a level directory
234-
if ((controller.checkGameDirectory(id) == 2)
235-
&& (controller.getItemState(id) == 1)) {
252+
if (levelListModel->getInstalled(id)) {
236253
ui->pushButtonLink->setEnabled(true);
237254
ui->pushButtonDownload->setEnabled(false);
238255
} else {
@@ -247,7 +264,7 @@ void TombRaiderLinuxLauncher::levelDirSelected(qint64 id) {
247264
if (id != 0) {
248265
int state = controller.getItemState(id);
249266
// Activate or deactivate pushbuttons based on the selected item
250-
qDebug() << id << Qt::endl;
267+
qDebug() << "Selected: " << id << Qt::endl;
251268
// if state == 1 then only activate link button
252269
// if state == 2 then only activate link and info button
253270
// if state == 0 then only activate download button
@@ -329,6 +346,9 @@ void TombRaiderLinuxLauncher::linkClicked() {
329346
if (m_settings.value(QString("level%1/RunnerType").arg(id)) == 2) {
330347
Model::getInstance().runWine(id);
331348
} else {
349+
if (levelListModel->getListType()) {
350+
id = (-1)*id;
351+
}
332352
if (!controller.link(id)) {
333353
qDebug() << "link error";
334354
}
@@ -343,7 +363,6 @@ void TombRaiderLinuxLauncher::downloadClicked() {
343363
if (current.isValid()) {
344364
qint64 id = levelListModel->getLid(current);
345365
if (levelListModel->getListType()) {
346-
qDebug() << "controller.setupGame(" << id << ")";
347366
ui->listViewLevels->setEnabled(false);
348367
ui->progressBar->setValue(0);
349368
ui->stackedWidgetBar->setCurrentWidget(
@@ -445,11 +464,18 @@ void TombRaiderLinuxLauncher::workTick() {
445464
QModelIndex current = ui->listViewLevels->currentIndex();
446465
if (current.isValid()) {
447466
qint64 id = levelListModel->getLid(current);
448-
if (id < 0) { // its the original game
467+
levelListModel->setInstalled(current);
468+
if (levelListModel->getListType()) { // its the original game
469+
m_settings.setValue(
470+
QString("installed/game%1").arg(id),
471+
"true");
449472
ui->pushButtonLink->setEnabled(true);
450473
ui->pushButtonInfo->setEnabled(false);
451474
ui->pushButtonDownload->setEnabled(false);
452-
} else if (id > 0) {
475+
} else {
476+
m_settings.setValue(
477+
QString("installed/level%1").arg(id),
478+
"true");
453479
ui->pushButtonLink->setEnabled(true);
454480
ui->pushButtonInfo->setEnabled(true);
455481
ui->pushButtonDownload->setEnabled(false);
@@ -497,6 +523,7 @@ void TombRaiderLinuxLauncher::GlobalSaveClicked() {
497523
controller.setup(newLevelPath, newGamePath);
498524
}
499525
}
526+
500527
void TombRaiderLinuxLauncher::GlobalResetClicked() {
501528
ui->tableWidgetSetup->item(0, 0)->setText(
502529
m_settings.value("gamePath").toString());

src/TombRaiderLinuxLauncher.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,22 +138,31 @@ class TombRaiderLinuxLauncher : public QMainWindow {
138138
void LevelResetClicked();
139139

140140
private:
141+
/**
142+
*
143+
*/
144+
void setInstalled();
145+
141146
/**
142147
*
143148
*/
144149
void originalSelected(qint64 id);
150+
145151
/**
146152
*
147153
*/
148154
void levelDirSelected(qint64 id);
155+
149156
/**
150157
* Configures game and level directories.
151158
*/
152159
void setup();
160+
153161
/**
154162
* Loads saved settings.
155163
*/
156164
void readSavedSettings();
165+
157166
/**
158167
* Executes the sorting algorithm.
159168
*/

src/levelViewList.hpp

Lines changed: 52 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ class LevelListModel : public QAbstractListModel {
112112
break;
113113
}
114114
}
115-
116115
} else {
117116
if ((index.isValid()) && (row < m_filterList.count())) {
118117
const ListItemData* item = m_filterList.at(row);
@@ -148,22 +147,9 @@ class LevelListModel : public QAbstractListModel {
148147
}
149148
}
150149

151-
152150
return result;
153151
}
154152

155-
int getLid(const QModelIndex &index) const {
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-
167153
bool getListType() const {
168154
return m_original;
169155
}
@@ -349,6 +335,56 @@ class LevelListModel : public QAbstractListModel {
349335
endResetModel();
350336
}
351337

338+
void setInstalledListOriginal(const QHash<int, bool> installed) {
339+
m_installedOriginal = installed;
340+
}
341+
void setInstalledList(const QHash<int, bool> installed) {
342+
m_installed = installed;
343+
}
344+
345+
int getLid(const QModelIndex &index) const {
346+
qint64 id = 0;
347+
if (m_original) {
348+
const OriginalGameData* item = &m_originalMainList.at(index.row());
349+
id = item->m_game_id;
350+
} else {
351+
const ListItemData* item = m_filterList.at(index.row());
352+
id = item->m_trle_id;
353+
}
354+
return id;
355+
}
356+
357+
void setInstalled(const QModelIndex &index) {
358+
int id = 0;
359+
if (m_original) {
360+
const OriginalGameData* item = &m_originalMainList.at(index.row());
361+
id = item->m_game_id;
362+
m_installedOriginal.insert(id, true);
363+
} else {
364+
const ListItemData* item = m_filterList.at(index.row());
365+
id = item->m_trle_id;
366+
m_installed.insert(id, true);
367+
}
368+
}
369+
370+
bool getInstalled(const qint64 id) {
371+
bool result;
372+
if (m_original) {
373+
if (m_installedOriginal.contains(id)) {
374+
result = m_installedOriginal.value(id);
375+
} else {
376+
result = false;
377+
}
378+
} else {
379+
if (m_installed.contains(id)) {
380+
result = m_installed.value(id);
381+
} else {
382+
result = false;
383+
}
384+
}
385+
return result;
386+
}
387+
352388
private:
353389
QVector<ListItemData> m_mainList;
354390
QVector<ListItemData*> m_sortList;
@@ -359,6 +395,8 @@ class LevelListModel : public QAbstractListModel {
359395
QString difficulty;
360396
QString duration;
361397
} m_filter;
398+
QHash<int, bool> m_installedOriginal;
399+
QHash<int, bool> m_installed;
362400
QString m_search;
363401
QVector<ListItemData*> m_cache;
364402
bool m_covers_loaded = false;

0 commit comments

Comments
 (0)