Skip to content

Commit 065f20e

Browse files
committed
setup testbuild
1 parent cc10a16 commit 065f20e

File tree

10 files changed

+614
-276
lines changed

10 files changed

+614
-276
lines changed

CMakeLists.txt

Lines changed: 55 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ cmake_minimum_required(VERSION 3.16)
22

33
project(TombRaiderLinuxLauncher)
44

5+
option(TEST "Enable building test" OFF)
6+
57
set(CMAKE_AUTOMOC ON)
68
set(CMAKE_AUTORCC ON)
79
set(CMAKE_AUTOUIC ON)
@@ -29,11 +31,10 @@ endif()
2931

3032
add_subdirectory(libs/miniz)
3133

32-
# suppress ZERO_CHECK dont think its needed
33-
#set(CMAKE_SUPPRESS_REGENERATION true)
34-
3534
set(SOURCES
3635
src/main.cpp
36+
src/binary.h
37+
src/gameTree.h
3738
src/staticData.h
3839
src/Network.h
3940
src/Network.cpp
@@ -45,14 +46,14 @@ set(SOURCES
4546
src/Model.cpp
4647
src/Data.h
4748
src/Data.cpp
48-
src/TombRaiderLinuxLauncher.h
49-
src/TombRaiderLinuxLauncher.cpp
50-
src/TombRaiderLinuxLauncher.ui
51-
src/resources.qrc
5249
)
5350

5451
set(TEST_SOURCES
55-
src/main.cpp
52+
test/main.cpp
53+
test/test.h
54+
src/binary.h
55+
src/gameTree.h
56+
src/staticData.h
5657
src/Network.h
5758
src/Network.cpp
5859
src/Controller.h
@@ -65,55 +66,61 @@ set(TEST_SOURCES
6566
src/Data.cpp
6667
)
6768

68-
add_executable(${PROJECT_NAME} ${SOURCES})
69-
70-
# create the test executable
71-
#enable_testing(false)
72-
#add_executable(${PROJECT_NAME}Test ${TEST_SOURCES})
73-
#add_test(NAME ${PROJECT_NAME}Test COMMAND ${PROJECT_NAME}Test)
74-
75-
# I think it should link to miniz here also
76-
target_link_libraries(${PROJECT_NAME} PUBLIC
77-
Qt5::Core
78-
Qt5::Gui
79-
Qt5::Widgets
80-
Qt5::WebEngineWidgets
81-
Qt5::Sql
82-
miniz
83-
${CURL_LIBRARY}
84-
OpenSSL::SSL
85-
Boost::system
86-
Boost::filesystem
87-
)
88-
# link to Qt5::Test
89-
# the test will be a console qt application
90-
#target_link_libraries(${PROJECT_NAME}Test PUBLIC
91-
# Qt5::Core
92-
# Qt5::Gui
93-
# Qt5::Test
94-
# Qt5::Widgets
95-
# Qt5::Sql
96-
# miniz
97-
# ${CURL_LIBRARY}
98-
#)
99-
100-
target_include_directories(${PROJECT_NAME} PRIVATE
69+
if(TEST)
70+
enable_testing()
71+
set(PROJECT_NAME_POST "${PROJECT_NAME}Test")
72+
add_executable(${PROJECT_NAME_POST} ${TEST_SOURCES})
73+
target_link_libraries(${PROJECT_NAME_POST} PUBLIC
74+
Qt5::Core
75+
Qt5::Gui
76+
Qt5::Test
77+
Qt5::Widgets
78+
Qt5::WebEngineWidgets
79+
Qt5::Sql
80+
miniz
81+
${CURL_LIBRARY}
82+
OpenSSL::SSL
83+
Boost::system
84+
Boost::filesystem
85+
)
86+
add_test(NAME ${PROJECT_NAME_POST} COMMAND ${PROJECT_NAME_POST})
87+
else()
88+
set(PROJECT_NAME_POST "${PROJECT_NAME}")
89+
add_executable(${PROJECT_NAME_POST} ${SOURCES})
90+
target_link_libraries(${PROJECT_NAME_POST} PUBLIC
91+
Qt5::Core
92+
Qt5::Gui
93+
Qt5::Widgets
94+
Qt5::WebEngineWidgets
95+
Qt5::Sql
96+
miniz
97+
${CURL_LIBRARY}
98+
OpenSSL::SSL
99+
Boost::system
100+
Boost::filesystem
101+
)
102+
endif()
103+
104+
target_include_directories(${PROJECT_NAME_POST} PRIVATE
101105
${CURL_INCLUDE_DIR}
102106
${Boost_INCLUDE_DIRS}
103107
libs/miniz
104108
src
109+
test
105110
)
106111

107-
set_target_properties(${PROJECT_NAME} PROPERTIES
112+
set_target_properties(${PROJECT_NAME_POST} PROPERTIES
108113
CXX_STANDARD 17
109114
CXX_STANDARD_REQUIRED ON
110115
)
111116

112-
install(TARGETS ${PROJECT_NAME}
113-
DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
114-
)
117+
if(NOT TEST)
118+
install(TARGETS ${PROJECT_NAME_POST}
119+
DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
120+
)
115121

116-
install(FILES ${CMAKE_SOURCE_DIR}/database/tombll.db
117-
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}
118-
)
122+
install(FILES ${CMAKE_SOURCE_DIR}/database/tombll.db
123+
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}
124+
)
125+
endif()
119126

setup_nvim_lsp.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ rm -fr build
2828
mkdir build
2929
cd build || exit 1
3030

31-
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DCMAKE_BUILD_TYPE=Debug ..
31+
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DCMAKE_BUILD_TYPE=Debug "$@" ..
3232
cd ..
3333
ln -s build/compile_commands.json compile_commands.json

src/FileManager.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <QtCore>
2424
#include <QByteArray>
2525
#include <QDataStream>
26+
#include "gameTree.h"
2627

2728
bool FileManager::setUpCamp(const QString& levelDir, const QString& gameDir) {
2829
QDir levelDirPath(levelDir);
@@ -212,6 +213,9 @@ int FileManager::checkFileInfo(const QString& file, bool lookGameDir) {
212213
bool FileManager::linkGameDir(const QString& levelDir, const QString& gameDir) {
213214
const QString& l = levelDir_m.absolutePath() + levelDir;
214215
const QString& g = gameDir_m.absolutePath() + gameDir;
216+
217+
test(l);
218+
215219
if (QFile::link(l, g)) {
216220
qDebug() << "Symbolic link created successfully.";
217221
return 0;

src/Model.cpp

Lines changed: 30 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,11 @@ bool Model::setDirectory(const QString& level, const QString& game) {
5959
return false;
6060
}
6161

62-
void Model::checkCommonFiles()
63-
{
62+
void Model::checkCommonFiles() {
6463
int index = checkCommonFilesIndex_m;
6564
assert(index >= 1 && index <= 5);
66-
for (int i = index; i <= 5; i++)
67-
{
68-
if (checkGameDirectory(i) == 2)
69-
{
65+
for (int i = index; i <= 5; i++) {
66+
if (checkGameDirectory(i) == 2) {
7067
checkCommonFilesIndex_m = i+1;
7168
emit askGameSignal(i);
7269
QCoreApplication::processEvents();
@@ -77,11 +74,9 @@ void Model::checkCommonFiles()
7774
QCoreApplication::processEvents();
7875
}
7976

80-
QString Model::getGameDirectory(int id)
81-
{
77+
QString Model::getGameDirectory(int id) {
8278
struct FolderNames folder;
83-
switch (id)
84-
{
79+
switch (id) {
8580
case 1:
8681
return folder.TR1;
8782
case 2:
@@ -98,25 +93,21 @@ QString Model::getGameDirectory(int id)
9893
}
9994
}
10095

101-
int Model::checkGameDirectory(int id)
102-
{
96+
int Model::checkGameDirectory(int id) {
10397
const QString s = getGameDirectory(id);
10498
if (s != "")
10599
return fileManager.checkFileInfo(s, true);
106100
return -1;
107101
}
108102

109-
void Model::getList(QVector<ListItemData>* list)
110-
{
103+
void Model::getList(QVector<ListItemData>* list) {
111104
*list = data.getListItems();
112105
}
113106

114-
int Model::getItemState(int id)
115-
{
116-
if (id < 0)
107+
int Model::getItemState(int id) {
108+
if (id < 0) {
117109
return 1;
118-
else if (id > 0)
119-
{
110+
} else if (id > 0) {
120111
QString map(QString::number(id) + ".TRLE");
121112
if (fileManager.checkDir(map, false))
122113
return 2;
@@ -126,17 +117,13 @@ int Model::getItemState(int id)
126117
return -1;
127118
}
128119

129-
bool Model::setLink(int id)
130-
{
131-
if (id < 0)
132-
{
120+
bool Model::setLink(int id) {
121+
if (id < 0) {
133122
id = -id;
134123
const QString s = "/Original.TR" + QString::number(id);
135124
if (fileManager.checkDir(s, false ))
136125
return fileManager.linkGameDir(s, getGameDirectory(id));
137-
}
138-
else if (id > 0)
139-
{
126+
} else if (id > 0) {
140127
const QString s = "/"+QString::number(id) + ".TRLE";
141128
const int t = data.getType(id);
142129

@@ -146,88 +133,70 @@ bool Model::setLink(int id)
146133
return false;
147134
}
148135

149-
void Model::setupGame(int id)
150-
{
136+
void Model::setupGame(int id) {
151137
std::array<QVector<QString>, 2> list = data.getFileList(id, false);
152138
const size_t s = list[0].size();
153139
const size_t sm = list[1].size();
154-
if (s != sm)
155-
{
140+
if (s != sm) {
156141
qDebug()
157142
<< "Corrupt list, there seems to bee"
158143
<< " more or less checksums for the files\n";
159144
assert(false);
160145
}
161146
const QString& sd = "/Original.TR" + QString::number(id) +"/";
162147
const QString& sg = getGameDirectory(id) + "/";
163-
for (size_t i = 0; i < s; i++)
164-
{
148+
for (size_t i = 0; i < s; i++) {
165149
const QString& fFile = list[0][i];
166150
const QString& fMd5sum = list[1][i];
167151
const QString& calculated = fileManager.calculateMD5(sg+fFile, true);
168-
if (fMd5sum == calculated)
169-
{
152+
if (fMd5sum == calculated) {
170153
fileManager.copyFile(sg+fFile, sd+fFile, true);
171-
}
172-
else
173-
{
154+
} else {
174155
qDebug() << "Original file was modified, had" << fMd5sum
175156
<< " got " << calculated << " for file "
176157
<< fFile << Qt::endl;
177158
fileManager.cleanWorkingDir(sd + fFile);
178159
break;
179160
}
180161
}
181-
if (fileManager.backupGameDir(sg))
182-
{
162+
if (fileManager.backupGameDir(sg)) {
183163
const QString& src = sd.chopped(1);
184164
const QString& des = sg.chopped(1);
185-
if (!fileManager.linkGameDir(src, des))
186-
{
165+
if (!fileManager.linkGameDir(src, des)) {
187166
checkCommonFiles();
188167
return;
189168
}
190169
}
191170
checkCommonFiles();
192171
}
193172

194-
bool Model::getGame(int id)
195-
{
173+
bool Model::getGame(int id) {
196174
assert(id > 0);
197-
if (id)
198-
{
175+
if (id) {
199176
int status = 0;
200177
ZipData zipData = data.getDownload(id);
201178
downloader.setUrl(zipData.url);
202179
downloader.setSaveFile(zipData.name);
203180

204-
if (fileManager.checkFile(zipData.name, false))
205-
{
181+
if (fileManager.checkFile(zipData.name, false)) {
206182
qDebug() << "File exists:" << zipData.name;
207183
const QString& sum = fileManager.calculateMD5(zipData.name, false);
208-
if (sum != zipData.md5sum)
209-
{
184+
if (sum != zipData.md5sum) {
210185
downloader.run();
211186
status = downloader.getStatus();
212-
}
213-
else
214-
{
187+
} else {
215188
// send 50% signal here
216-
for (int i=0; i < 50; i++)
217-
{
189+
for (int i=0; i < 50; i++) {
218190
emit this->modelTickSignal();
219191
QCoreApplication::processEvents();
220192
}
221193
}
222-
}
223-
else
224-
{
194+
} else {
225195
qWarning() << "File does not exist:" << zipData.name;
226196
downloader.run();
227197
status = downloader.getStatus();
228198
}
229-
if (status == 0)
230-
{
199+
if (status == 0) {
231200
fileManager.extractZip(zipData.name, QString::number(id)+".TRLE");
232201
instructionManager.executeInstruction(id);
233202
return true;
@@ -236,12 +205,10 @@ bool Model::getGame(int id)
236205
return false;
237206
}
238207

239-
const InfoData Model::getInfo(int id)
240-
{
208+
const InfoData Model::getInfo(int id) {
241209
return data.getInfo(id);
242210
}
243211

244-
const QString Model::getWalkthrough(int id)
245-
{
212+
const QString Model::getWalkthrough(int id) {
246213
return data.getWalkthrough(id);
247214
}

src/TombRaiderLinuxLauncher.ui

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1382,7 +1382,7 @@ p, li { white-space: pre-wrap; }
13821382
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans Serif'; font-size:12pt; font-weight:400; font-style:normal;&quot;&gt;
13831383
&lt;h3 style=&quot; margin-top:14px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:large; font-weight:600;&quot;&gt;About&lt;/span&gt;&lt;/h3&gt;
13841384
&lt;h4 style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:medium; font-weight:600;&quot;&gt;Tomb Raider Linux Launcher&lt;/span&gt;&lt;/h4&gt;
1385-
&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Welcome to the &lt;span style=&quot; font-weight:600;&quot;&gt;Tomb Raider Linux Launcher&lt;/span&gt;! This application is designed to provide a streamlined and convenient way to launch your favorite Tomb Raider games on Linux. Currently, the launcher supports Tomb Raider III and Tomb Raider: The Last Revelation (Tomb Raider IV).&lt;/p&gt;
1385+
&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Welcome to the &lt;span style=&quot; font-weight:600;&quot;&gt;Tomb Raider Linux Launcher&lt;/span&gt;! This application is designed to provide a streamlined and convenient way to launch your favorite Tomb Raider games on Linux. Currently, the launcher supports Tomb Raider 1-5 and trle.net but not TEN at the moment.&lt;/p&gt;
13861386
&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Our aim is to enhance your gaming experience by offering a user-friendly interface that simplifies game management and launching. The launcher is still a work in progress, and we are actively working on adding support for more games and improving functionality.&lt;/p&gt;
13871387
&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Stay tuned for updates and new features as we continue to develop and refine the Tomb Raider Linux Launcher. Your feedback and suggestions are always welcome to help us create the best possible tool for Tomb Raider fans.&lt;/p&gt;
13881388
&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Thank you for using the Tomb Raider Linux Launcher!&lt;/p&gt;

0 commit comments

Comments
 (0)