Skip to content

Commit 8d7bd6c

Browse files
committed
remove askGame dialog
Am not done with this but it better cus there was a crash in askGame dialog if it was Chronicles
1 parent 0c38e94 commit 8d7bd6c

File tree

10 files changed

+265
-216
lines changed

10 files changed

+265
-216
lines changed

.neovim.lua

Lines changed: 23 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ vim.api.nvim_set_keymap('n', 'ø', ":lua require'dapui'.toggle()<CR>", { noremap
2222
-- https://sourceware.org/gdb/current/onlinedocs/gdb.html/Interpreters.html
2323
-- https://sourceware.org/gdb/current/onlinedocs/gdb.html/Debugger-Adapter-Protocol.html
2424
-- Require DAP and DAP-Python
25+
-- Use qtcreator to debug c++ part
2526
local dap = require("dap")
2627
require("dap-python").setup("python")
2728

@@ -48,33 +49,6 @@ dap.configurations.python = {
4849
},
4950
}
5051

51-
-- C++ configuration with GDB
52-
dap.adapters.gdb = {
53-
type = "executable",
54-
command = "gdb", -- Ensure GDB is installed and available in your PATH
55-
args = { "-i", "dap" }
56-
}
57-
58-
dap.configurations.cpp = {
59-
{
60-
name = 'Launch executable (GDB)',
61-
type = 'gdb',
62-
request = 'launch',
63-
program = '~/TombRaiderLinuxLauncher/TombRaiderLinuxLauncher',
64-
stopOnEntry = false, -- or true if you want to stop at the beginning
65-
cwd = '${workspaceFolder}',
66-
setupCommands = {
67-
{
68-
text = '-enable-pretty-printing', -- Enable pretty-printing for gdb
69-
description = 'enable pretty printing',
70-
ignoreFailures = false
71-
},
72-
},
73-
args = {}, -- Pass arguments to the executable
74-
environment = {}, -- Set environment variables here
75-
}
76-
}
77-
7852
require("dapui").setup()
7953

8054
local nvim_lsp = require('lspconfig')
@@ -92,7 +66,6 @@ vim.api.nvim_create_autocmd("FileType", {
9266
end,
9367
})
9468

95-
9669
function ToggleShiftwidth()
9770
if vim.g.current_shiftwidth == 2 then
9871
vim.g.current_shiftwidth = 4
@@ -105,16 +78,14 @@ end
10578
-- The style is meant to keep the code narrow, never let it over 80-100
10679
-- With cpplint --filter=-whitespace/braces,-whitespace/newline
10780

108-
10981
require('lint').linters_by_ft = {
11082
sh = {'shellcheck'}, -- Ensure you have shellcheck installed
11183
python = {'pylint', 'bandit', 'ruff', 'pydocstyle', 'mypy', 'flake8'}, -- Ensure these are installed
11284
cmake = { 'cmakelint' },
11385
cpp = {'cppcheck', 'cpplint', 'flawfinder'},
11486
}
115-
-- add:
116-
-- --check-level=exhaustive
11787

88+
-- .local/share/nvim/plugged/nvim-lint/lua/lint/linters/cppcheck.lua
11889
-- cppcheck <= 1.84 doesn't support {column} so the start_col group is ambiguous
11990
local pattern = [[([^:]*):(%d*):([^:]*): %[([^%]\]*)%] ([^:]*): (.*)]]
12091
local groups = { "file", "lnum", "col", "code", "severity", "message" }
@@ -150,8 +121,29 @@ return {
150121
"--template={file}:{line}:{column}: [{id}] {severity}: {message}",
151122
"--check-level=exhaustive",
152123
"--library=qt",
124+
"--suppress=unmatchedSuppression",
125+
"--suppress=unusedStructMember",
153126
},
154127
stream = "stderr",
155128
parser = require("lint.parser").from_pattern(pattern, groups, severity_map, { ["source"] = "cppcheck" }),
156129
}
157130

131+
-- .local/share/nvim/plugged/nvim-lint/lua/lint/linters/cpplint.lua
132+
-- path/to/file:line: message [code] [code_id]
133+
local pattern = '([^:]+):(%d+): (.+) (.+)'
134+
local groups = { 'file', 'lnum', 'message', 'code'}
135+
136+
return {
137+
cmd = 'cpplint',
138+
stdin = false,
139+
args = {
140+
"--filter=-build/include_subdir",
141+
},
142+
ignore_exitcode = true,
143+
stream = 'stderr',
144+
parser = require('lint.parser').from_pattern(pattern, groups, nil, {
145+
['source'] = 'cpplint',
146+
['severity'] = vim.diagnostic.severity.WARN,
147+
}),
148+
}
149+

setup_nvim_lsp.sh

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,6 @@
11
#!/bin/bash
22
cd "$(dirname "$0")" || exit 1
33
# don't forget that you need to build it one time
4-
# and look at .neovim how to use debuger
5-
mkdir -p .gdb/qt5prettyprinters/
6-
7-
gdbinit=$(cat <<'EOINS'
8-
python
9-
import sys, os
10-
11-
sys.path.insert(0, "./.gdb/qt5prettyprinters")
12-
13-
from qt import register_qt_printers
14-
register_qt_printers (None)
15-
16-
end
17-
EOINS
18-
)
19-
echo "$gdbinit" > .gdbinit
20-
chmod 0644 .gdbinit
21-
22-
wget -O .gdb/qt5prettyprinters/helper.py \
23-
https://invent.kde.org/kdevelop/kdevelop/-/raw/master/plugins/gdb/printers/helper.py
24-
wget -O .gdb/qt5prettyprinters/qt.py \
25-
https://invent.kde.org/kdevelop/kdevelop/-/raw/master/plugins/gdb/printers/qt.py
264

275
rm -fr build
286
mkdir build

src/Controller.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,12 @@ void Controller::initializeThread() {
3131
controllerThread->start();
3232

3333
// Using the controller thread to start model work
34+
/*
3435
connect(this, &Controller::checkCommonFilesThreadSignal,
3536
this, [this]() {
3637
model.checkCommonFiles();
3738
});
39+
*/
3840

3941
connect(this, &Controller::setupThreadSignal,
4042
this, [this](const QString& level, const QString& game) {
@@ -43,7 +45,7 @@ void Controller::initializeThread() {
4345

4446
connect(this, &Controller::setupLevelThreadSignal,
4547
this, [this](int id) {
46-
model.getGame(id);
48+
model.getLevel(id);
4749
});
4850

4951
connect(this, &Controller::setupGameThreadSignal,
@@ -67,14 +69,9 @@ void Controller::initializeThread() {
6769
emit controllerDownloadError(status);
6870
}, Qt::QueuedConnection);
6971

70-
connect(&model, &Model::askGameSignal,
71-
this, [this](int id) {
72-
emit controllerAskGame(id);
73-
}, Qt::QueuedConnection);
74-
7572
connect(&model, &Model::generateListSignal,
76-
this, [this]() {
77-
emit controllerGenerateList();
73+
this, [this](const QList<int>& availableGames) {
74+
emit controllerGenerateList(availableGames);
7875
}, Qt::QueuedConnection);
7976
}
8077

@@ -94,7 +91,7 @@ void Controller::setupLevel(int id) {
9491
emit setupLevelThreadSignal(id);
9592
}
9693

97-
// GUI Threads
94+
// Using the GUI Threads
9895
int Controller::checkGameDirectory(int id) {
9996
return model.checkGameDirectory(id);
10097
}

src/Controller.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ class Controller : public QObject {
4444
int getItemState(int id);
4545

4646
signals:
47-
void controllerAskGame(int id);
48-
void controllerGenerateList();
47+
void controllerGenerateList(const QList<int>& availableGames);
4948
void controllerTickSignal();
5049
void controllerDownloadError(int status);
5150

src/FileManager.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -222,14 +222,14 @@ bool FileManager::linkGameDir(const QString& levelDir, const QString& gameDir) {
222222

223223
test(levelPath); // here we just output the directory tree for now..
224224

225-
if (QFile::link(levelPath, gamePath)) {
225+
if (QFile::link(levelPath, gamePath) == true) {
226226
qDebug() << "Symbolic link created successfully.";
227-
return 0;
227+
status = true;
228228
} else {
229229
QFileInfo fileInfo(gamePath);
230230
if (fileInfo.isSymLink() == true) {
231231
QFile::remove(gamePath);
232-
if (QFile::link(levelPath, gamePath)) {
232+
if (QFile::link(levelPath, gamePath) == true) {
233233
qDebug() << "Symbolic link created successfully.";
234234
status = true;
235235
} else {
@@ -256,14 +256,14 @@ bool FileManager::makeRelativeLink(
256256
const QString toPath = QString("%1%2")
257257
.arg(levelPath, to);
258258

259-
if (QFile::link(fromPath, toPath)) {
259+
if (QFile::link(fromPath, toPath) == true) {
260260
qDebug() << "Symbolic link created successfully.";
261261
status = true;
262262
} else {
263263
QFileInfo i(toPath);
264-
if (i.isSymLink()) {
264+
if (i.isSymLink() == true) {
265265
QFile::remove(toPath);
266-
if (QFile::link(fromPath, toPath)) {
266+
if (QFile::link(fromPath, toPath) == true) {
267267
qDebug() << "Symbolic link created successfully.";
268268
status = true;
269269
} else {

src/Model.cpp

Lines changed: 45 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
// Those lambda should be in another header file
1717
// I hate this and it should be able to recognize both the directory
1818
// when linking and the game exe to make a symbolic link to automatically
19-
Model::Model(QObject *parent) : QObject(parent), checkCommonFilesIndex_m(1) {
19+
Model::Model(QObject *parent) : QObject(parent) {
2020
instructionManager.addInstruction(4, [this](int id) {
2121
qDebug() << "Perform Operation A";
2222
const QString s = "/"+QString::number(id) + ".TRLE";
@@ -32,54 +32,41 @@ Model::Model(QObject *parent) : QObject(parent), checkCommonFilesIndex_m(1) {
3232
const QString s = QString::number(id) + ".TRLE/TRBiohazard";
3333
fileManager.moveFilesToParentDirectory(s, 1);
3434
});
35-
/*
36-
instructionManager.addInstruction(12, [this](int id) {
37-
qDebug() << "Perform Operation C";
38-
const QString s = QString::number(id) + ".TRLE/Delca-KittenAdventureDemo/Engine";
39-
fileManager.moveFilesToParentDirectory(s, 2);
40-
});
41-
*/
4235
}
4336

4437
Model::~Model() {}
4538

4639
bool Model::setup(const QString& level, const QString& game) {
4740
bool status = false;
48-
if (setDirectory(level, game)) {
41+
if (setDirectory(level, game) == true) {
4942
status = true;
50-
checkCommonFiles();
43+
emit generateListSignal(checkCommonFiles());
44+
QCoreApplication::processEvents();
5145
}
5246
return status;
5347
}
5448

5549
bool Model::setDirectory(const QString& level, const QString& game) {
50+
bool status = false;
5651
if (fileManager.setUpCamp(level, game) &&
57-
downloader.setUpCamp(level) &&
58-
data.initializeDatabase(level)
59-
)
60-
return true;
61-
else
62-
return false;
52+
downloader.setUpCamp(level) &&
53+
data.initializeDatabase(level)) {
54+
status = true;
55+
}
56+
return status;
6357
}
6458

65-
// true if there was new original game
66-
// false if there was no new original games
67-
bool Model::checkCommonFiles() {
68-
int index = checkCommonFilesIndex_m;
69-
assert(index >= 1 && index <= 5);
70-
for (int i = index; i <= 5; i++) {
71-
if (checkGameDirectory(i) == 2) {
72-
// checkCommonFilesIndex_m this is becouse it should start here
73-
// becouse we use a return, we should only use 1 return...
74-
checkCommonFilesIndex_m = i+1;
75-
emit askGameSignal(i);
76-
QCoreApplication::processEvents();
77-
return true;
59+
const QList<int>& Model::checkCommonFiles() {
60+
m_availableGames.clear();
61+
for (int i = 1; i <= 5; i++) {
62+
int dirStatus = checkGameDirectory(i);
63+
if (dirStatus == 1) { // symbolic link
64+
m_availableGames.append(i);
65+
} else if (dirStatus == 2) { // directory
66+
m_availableGames.append(-i);
7867
}
7968
}
80-
emit generateListSignal();
81-
QCoreApplication::processEvents();
82-
return false;
69+
return m_availableGames;
8370
}
8471

8572
QString Model::getGameDirectory(int id) {
@@ -95,39 +82,48 @@ QString Model::getGameDirectory(int id) {
9582
return folder.TR4;
9683
case 5:
9784
return folder.TR5;
85+
case 10:
86+
return folder.TEN;
9887
default:
9988
qDebug() << "Id number:" << id << " is not a game.";
10089
return "";
10190
}
10291
}
10392

10493
int Model::checkGameDirectory(int id) {
94+
int status = -1;
10595
const QString s = getGameDirectory(id);
106-
if (s != "")
107-
return fileManager.checkFileInfo(s, true);
108-
return -1;
96+
qDebug() << s;
97+
if (s != "") {
98+
status = fileManager.checkFileInfo(s, true);
99+
}
100+
return status;
109101
}
110102

111103
void Model::getList(QVector<ListItemData>* list) {
112104
*list = data.getListItems();
113105
}
114106

115107
int Model::getItemState(int id) {
108+
int status = 0;
116109
if (id < 0) {
117-
return 1;
110+
status = 1;
118111
} else if (id > 0) {
119-
QString map(QString::number(id) + ".TRLE");
120-
if (fileManager.checkDir(map, false))
121-
return 2;
122-
else
123-
return 0;
112+
QString dir(QString::number(id) + ".TRLE");
113+
if (fileManager.checkDir(dir, false)) {
114+
status = 2;
115+
} else {
116+
status = 0;
117+
}
118+
} else {
119+
status = -1;
124120
}
125-
return -1;
121+
return status;
126122
}
127123

128124
bool Model::setLink(int id) {
129125
bool status = false;
130-
if (id < 0) {
126+
if (id < 0) { // we use original game id as negative number
131127
id = -id;
132128
const QString s = "/Original.TR" + QString::number(id);
133129
if (fileManager.checkDir(s, false ))
@@ -171,14 +167,16 @@ void Model::setupGame(int id) {
171167
const QString src = levelPath.chopped(1);
172168
const QString des = gamePath.chopped(1);
173169
if (!fileManager.linkGameDir(src, des)) {
174-
checkCommonFiles(); // TODO(noisecode3): Remove this
175-
return;
170+
qDebug() << "Faild to create the link to the new game directory";
176171
}
177172
}
178-
checkCommonFiles(); // TODO(noisecode3): Remove this
173+
for (int i=0; i < 100; i++) {
174+
emit this->modelTickSignal();
175+
QCoreApplication::processEvents();
176+
}
179177
}
180178

181-
bool Model::getGame(int id) {
179+
bool Model::getLevel(int id) {
182180
assert(id > 0);
183181
if (id) {
184182
int status = 0;

0 commit comments

Comments
 (0)