Skip to content

Commit cc10a16

Browse files
committed
fix create gamedir and gui display data
1 parent 515f440 commit cc10a16

22 files changed

+546
-628
lines changed
File renamed without changes.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ build
1414
.gdb
1515
.gdbinit
1616
.vscode
17+
.mypy_cache

.neovim.lua

Lines changed: 76 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
-- I set those per project
2+
-- This is an example of how you can use the kind of the same
3+
-- Its not exact and you might do it differently, it's somewhat incomplete
14
-- debuging should be like qt-creator
25
Plug('neovim/nvim-lspconfig')
36
Plug('williamboman/mason.nvim')
@@ -6,6 +9,8 @@ Plug('mfussenegger/nvim-dap')
69
Plug('mfussenegger/nvim-dap-python')
710
Plug('nvim-neotest/nvim-nio')
811
Plug('rcarriga/nvim-dap-ui')
12+
Plug('mfussenegger/nvim-lint')
13+
Plug('Vimjas/vim-python-pep8-indent')
914

1015
vim.api.nvim_set_keymap('n', 'å', ":lua require'dap'.toggle_breakpoint()<CR>", { noremap = true, silent = true })
1116
vim.api.nvim_set_keymap('n', 'ä', ":lua require'dap'.step_into()<CR>", { noremap = true, silent = true })
@@ -77,6 +82,76 @@ nvim_lsp.clangd.setup{}
7782
require("mason").setup()
7883
require("mason-lspconfig").setup()
7984

80-
vim.g.current_shiftwidth = 4
85+
vim.o.shiftwidth = 4
86+
vim.api.nvim_create_autocmd("FileType", {
87+
pattern = "python",
88+
callback = function()
89+
vim.opt_local.expandtab = true
90+
vim.opt_local.shiftwidth = 4
91+
vim.opt_local.softtabstop = 4
92+
end,
93+
})
94+
95+
96+
function ToggleShiftwidth()
97+
if vim.g.current_shiftwidth == 2 then
98+
vim.g.current_shiftwidth = 4
99+
else
100+
vim.g.current_shiftwidth = 2
101+
end
102+
vim.cmd('set shiftwidth=' .. vim.g.current_shiftwidth)
103+
print('Shiftwidth set to ' .. vim.g.current_shiftwidth)
104+
end
81105
-- The style is meant to keep the code narrow, never let it over 80-100
82106
-- With cpplint --filter=-whitespace/braces,-whitespace/newline
107+
108+
109+
require('lint').linters_by_ft = {
110+
sh = {'shellcheck'}, -- Ensure you have shellcheck installed
111+
python = {'pylint', 'bandit', 'ruff', 'pydocstyle', 'mypy', 'flake8'}, -- Ensure these are installed
112+
cmake = { 'cmakelint' },
113+
cpp = {'cppcheck', 'cpplint', 'flawfinder'},
114+
}
115+
-- add:
116+
-- --check-level=exhaustive
117+
118+
-- cppcheck <= 1.84 doesn't support {column} so the start_col group is ambiguous
119+
local pattern = [[([^:]*):(%d*):([^:]*): %[([^%]\]*)%] ([^:]*): (.*)]]
120+
local groups = { "file", "lnum", "col", "code", "severity", "message" }
121+
local severity_map = {
122+
["error"] = vim.diagnostic.severity.ERROR,
123+
["warning"] = vim.diagnostic.severity.WARN,
124+
["performance"] = vim.diagnostic.severity.WARN,
125+
["style"] = vim.diagnostic.severity.INFO,
126+
["information"] = vim.diagnostic.severity.INFO,
127+
}
128+
129+
return {
130+
cmd = "cppcheck",
131+
stdin = false,
132+
args = {
133+
"--enable=warning,style,performance,information",
134+
function()
135+
if vim.bo.filetype == "cpp" then
136+
return "--language=c++"
137+
else
138+
return "--language=c"
139+
end
140+
end,
141+
"--inline-suppr",
142+
"--quiet",
143+
function()
144+
if vim.fn.isdirectory("build") == 1 then
145+
return "--cppcheck-build-dir=build"
146+
else
147+
return nil
148+
end
149+
end,
150+
"--template={file}:{line}:{column}: [{id}] {severity}: {message}",
151+
"--check-level=exhaustive",
152+
"--library=qt",
153+
},
154+
stream = "stderr",
155+
parser = require("lint.parser").from_pattern(pattern, groups, severity_map, { ["source"] = "cppcheck" }),
156+
}
157+
File renamed without changes.

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ add_subdirectory(libs/miniz)
3434

3535
set(SOURCES
3636
src/main.cpp
37+
src/staticData.h
3738
src/Network.h
3839
src/Network.cpp
3940
src/Controller.h
@@ -64,7 +65,7 @@ set(TEST_SOURCES
6465
src/Data.cpp
6566
)
6667

67-
add_executable(${PROJECT_NAME} ${SOURCES} )
68+
add_executable(${PROJECT_NAME} ${SOURCES})
6869

6970
# create the test executable
7071
#enable_testing(false)

build.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
#!/bin/bash
22
cd "$(dirname "$0")" || exit 1
3-
rm -fr build
4-
mkdir build
53
cd build || exit 1
6-
cmake -DCMAKE_BUILD_TYPE=Debug ..
74
make

clean_nvim_lsp.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/bin/bash
22
cd "$(dirname "$0")" || exit 1
33
# clean up command
4+
rm -fr build
5+
46
rm -fr CMakeCache.txt CMakeFiles Makefile cmake_install.cmake \
57
compile_commands.json TombRaiderLinuxLauncher \
68
.cache TombRaiderLinuxLauncher_autogen \

database/index_view.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import sys
44
import shutil
55
import gc
6-
import ueberzug as ueberzug_root
7-
import ueberzug.lib.v0 as ueberzug
6+
import ueberzug as ueberzug_root # type: ignore
7+
import ueberzug.lib.v0 as ueberzug # type: ignore
88

99
gc.collect()
1010
os.chdir(os.path.dirname(os.path.abspath(__file__)))
@@ -159,12 +159,12 @@ def display_menu(items, image_paths):
159159
row_offset = full_rows * max_columns
160160
print_row(display_items, row_offset, last_row_items)
161161

162-
awn = input(f" {len(display_items)} of {len(items)} results, " +\
163-
"Press 'q' and Enter to exit, else press Enter for next page...")
162+
awn = input(f" {len(display_items)} of {len(items)} results, " +
163+
"Press 'q' and Enter to exit, else press Enter for next page...")
164164

165165
print("\033c", end="")
166166
if awn == 'q':
167-
#TODO clean upp files in tmp
167+
# TODO clean upp files in tmp
168168
sys.exit(0)
169169

170170
# Remove all previous images
@@ -203,27 +203,25 @@ def print_row(items, row_offset, columns):
203203
print("")
204204

205205
for column in range(columns):
206-
print( \
207-
f"{' '*19}Author: " +\
206+
print(
207+
f"{' '*19}Author: " +
208208
f"{', '.join(map(str, items[row_offset + column]['authors']))[:52]:<52}",
209209
end=""
210210
)
211211
print("")
212212

213213
for column in range(columns):
214-
print( \
215-
f"{' '*19}Genre: " +\
214+
print(
215+
f"{' '*19}Genre: " +
216216
f"{', '.join(map(str, items[row_offset + column]['genres']))[:53]:<53}",
217217
end=""
218218
)
219219
print("")
220220

221221
for column in range(columns):
222222
print(
223-
f"{' '*19}Tag: " +\
223+
f"{' '*19}Tag: " +
224224
f"{', '.join(map(str, items[row_offset + column]['tags']))[:55]:<55}",
225225
end=""
226226
)
227227
print("\n")
228-
229-

setup_nvim_lsp.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,10 @@ wget -O .gdb/qt5prettyprinters/helper.py \
2424
wget -O .gdb/qt5prettyprinters/qt.py \
2525
https://invent.kde.org/kdevelop/kdevelop/-/raw/master/plugins/gdb/printers/qt.py
2626

27-
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DCMAKE_BUILD_TYPE=Debug .
27+
rm -fr build
28+
mkdir build
29+
cd build || exit 1
30+
31+
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DCMAKE_BUILD_TYPE=Debug ..
32+
cd ..
33+
ln -s build/compile_commands.json compile_commands.json

src/Controller.cpp

Lines changed: 20 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -18,34 +18,29 @@
1818
#include <QDebug>
1919

2020
Controller::Controller(QObject *parent)
21-
: QObject(parent), controllerThread(new QThread(this))
22-
{
21+
: QObject(parent), controllerThread(new QThread(this)) {
2322
initializeThread();
2423
}
2524

26-
Controller::~Controller()
27-
{
25+
Controller::~Controller() {
2826
controllerThread->quit();
2927
controllerThread->wait();
3028
}
3129

32-
void Controller::initializeThread()
33-
{
30+
void Controller::initializeThread() {
3431
this->moveToThread(controllerThread.data());
3532
connect(controllerThread.data(), &QThread::finished,
3633
controllerThread.data(), &QThread::deleteLater);
3734
controllerThread->start();
3835

3936
// Using the controller thread to start model work
4037
connect(this, &Controller::checkCommonFilesThreadSignal,
41-
this, [this]()
42-
{
38+
this, [this]() {
4339
model.checkCommonFiles();
4440
});
4541

4642
connect(this, &Controller::setupThreadSignal,
47-
this, [this](const QString& level, const QString& game)
48-
{
43+
this, [this](const QString& level, const QString& game) {
4944
model.setup(level, game);
5045
});
5146

@@ -55,8 +50,7 @@ void Controller::initializeThread()
5550
});
5651

5752
connect(this, &Controller::setupGameThreadSignal,
58-
this, [this](int id)
59-
{
53+
this, [this](int id) {
6054
model.setupGame(id);
6155
});
6256

@@ -72,71 +66,59 @@ void Controller::initializeThread()
7266
this, tickSignal, Qt::QueuedConnection);
7367

7468
connect(&downloader, &Downloader::networkWorkErrorSignal,
75-
this, [this](int status)
76-
{
69+
this, [this](int status) {
7770
emit controllerDownloadError(status);
7871
}, Qt::QueuedConnection);
7972

8073
connect(&model, &Model::askGameSignal,
81-
this, [this](int id)
82-
{
74+
this, [this](int id) {
8375
emit controllerAskGame(id);
8476
}, Qt::QueuedConnection);
8577

8678
connect(&model, &Model::generateListSignal,
87-
this, [this]()
88-
{
79+
this, [this]() {
8980
emit controllerGenerateList();
9081
}, Qt::QueuedConnection);
9182
}
9283

93-
void Controller::checkCommonFiles()
94-
{
84+
void Controller::checkCommonFiles() {
9585
emit checkCommonFilesThreadSignal();
9686
}
9787

98-
void Controller::setup(const QString& level, const QString& game)
99-
{
88+
void Controller::setup(const QString& level, const QString& game) {
10089
emit setupThreadSignal(level, game);
10190
}
10291

103-
void Controller::setupGame(int id)
104-
{
92+
void Controller::setupGame(int id) {
10593
emit setupGameThreadSignal(id);
10694
}
10795

108-
void Controller::setupLevel(int id)
109-
{
96+
void Controller::setupLevel(int id) {
11097
emit setupLevelThreadSignal(id);
11198
}
11299

113100
// GUI Threads
114-
int Controller::checkGameDirectory(int id)
115-
{
101+
int Controller::checkGameDirectory(int id) {
116102
return model.checkGameDirectory(id);
117103
}
118104

119-
void Controller::getList(QVector<ListItemData>* list)
120-
{
105+
void Controller::getList(QVector<ListItemData>* list) {
121106
model.getList(list);
122107
}
123108

124-
const InfoData Controller::getInfo(int id)
125-
{
109+
const InfoData Controller::getInfo(int id) {
126110
return model.getInfo(id);
127111
}
128112

129-
const QString Controller::getWalkthrough(int id)
130-
{
113+
const QString Controller::getWalkthrough(int id) {
131114
return model.getWalkthrough(id);
132115
}
133116

134-
bool Controller::link(int id)
135-
{
117+
bool Controller::link(int id) {
136118
return model.setLink(id);
137119
}
138120

139-
int Controller::getItemState(int id)
140-
{
121+
int Controller::getItemState(int id) {
141122
return model.getItemState(id);
142123
}
124+

0 commit comments

Comments
 (0)