Skip to content

Commit

Permalink
fix create gamedir and gui display data
Browse files Browse the repository at this point in the history
  • Loading branch information
noisecode3 committed Dec 6, 2024
1 parent 515f440 commit cc10a16
Show file tree
Hide file tree
Showing 22 changed files with 546 additions and 628 deletions.
File renamed without changes.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ build
.gdb
.gdbinit
.vscode
.mypy_cache
77 changes: 76 additions & 1 deletion .neovim.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
-- I set those per project
-- This is an example of how you can use the kind of the same
-- Its not exact and you might do it differently, it's somewhat incomplete
-- debuging should be like qt-creator
Plug('neovim/nvim-lspconfig')
Plug('williamboman/mason.nvim')
Expand All @@ -6,6 +9,8 @@ Plug('mfussenegger/nvim-dap')
Plug('mfussenegger/nvim-dap-python')
Plug('nvim-neotest/nvim-nio')
Plug('rcarriga/nvim-dap-ui')
Plug('mfussenegger/nvim-lint')
Plug('Vimjas/vim-python-pep8-indent')

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

vim.g.current_shiftwidth = 4
vim.o.shiftwidth = 4
vim.api.nvim_create_autocmd("FileType", {
pattern = "python",
callback = function()
vim.opt_local.expandtab = true
vim.opt_local.shiftwidth = 4
vim.opt_local.softtabstop = 4
end,
})


function ToggleShiftwidth()
if vim.g.current_shiftwidth == 2 then
vim.g.current_shiftwidth = 4
else
vim.g.current_shiftwidth = 2
end
vim.cmd('set shiftwidth=' .. vim.g.current_shiftwidth)
print('Shiftwidth set to ' .. vim.g.current_shiftwidth)
end
-- The style is meant to keep the code narrow, never let it over 80-100
-- With cpplint --filter=-whitespace/braces,-whitespace/newline


require('lint').linters_by_ft = {
sh = {'shellcheck'}, -- Ensure you have shellcheck installed
python = {'pylint', 'bandit', 'ruff', 'pydocstyle', 'mypy', 'flake8'}, -- Ensure these are installed
cmake = { 'cmakelint' },
cpp = {'cppcheck', 'cpplint', 'flawfinder'},
}
-- add:
-- --check-level=exhaustive

-- cppcheck <= 1.84 doesn't support {column} so the start_col group is ambiguous
local pattern = [[([^:]*):(%d*):([^:]*): %[([^%]\]*)%] ([^:]*): (.*)]]
local groups = { "file", "lnum", "col", "code", "severity", "message" }
local severity_map = {
["error"] = vim.diagnostic.severity.ERROR,
["warning"] = vim.diagnostic.severity.WARN,
["performance"] = vim.diagnostic.severity.WARN,
["style"] = vim.diagnostic.severity.INFO,
["information"] = vim.diagnostic.severity.INFO,
}

return {
cmd = "cppcheck",
stdin = false,
args = {
"--enable=warning,style,performance,information",
function()
if vim.bo.filetype == "cpp" then
return "--language=c++"
else
return "--language=c"
end
end,
"--inline-suppr",
"--quiet",
function()
if vim.fn.isdirectory("build") == 1 then
return "--cppcheck-build-dir=build"
else
return nil
end
end,
"--template={file}:{line}:{column}: [{id}] {severity}: {message}",
"--check-level=exhaustive",
"--library=qt",
},
stream = "stderr",
parser = require("lint.parser").from_pattern(pattern, groups, severity_map, { ["source"] = "cppcheck" }),
}

File renamed without changes.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ add_subdirectory(libs/miniz)

set(SOURCES
src/main.cpp
src/staticData.h
src/Network.h
src/Network.cpp
src/Controller.h
Expand Down Expand Up @@ -64,7 +65,7 @@ set(TEST_SOURCES
src/Data.cpp
)

add_executable(${PROJECT_NAME} ${SOURCES} )
add_executable(${PROJECT_NAME} ${SOURCES})

# create the test executable
#enable_testing(false)
Expand Down
3 changes: 0 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#!/bin/bash
cd "$(dirname "$0")" || exit 1
rm -fr build
mkdir build
cd build || exit 1
cmake -DCMAKE_BUILD_TYPE=Debug ..
make
2 changes: 2 additions & 0 deletions clean_nvim_lsp.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/bin/bash
cd "$(dirname "$0")" || exit 1
# clean up command
rm -fr build

rm -fr CMakeCache.txt CMakeFiles Makefile cmake_install.cmake \
compile_commands.json TombRaiderLinuxLauncher \
.cache TombRaiderLinuxLauncher_autogen \
Expand Down
22 changes: 10 additions & 12 deletions database/index_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import sys
import shutil
import gc
import ueberzug as ueberzug_root
import ueberzug.lib.v0 as ueberzug
import ueberzug as ueberzug_root # type: ignore
import ueberzug.lib.v0 as ueberzug # type: ignore

gc.collect()
os.chdir(os.path.dirname(os.path.abspath(__file__)))
Expand Down Expand Up @@ -159,12 +159,12 @@ def display_menu(items, image_paths):
row_offset = full_rows * max_columns
print_row(display_items, row_offset, last_row_items)

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

print("\033c", end="")
if awn == 'q':
#TODO clean upp files in tmp
# TODO clean upp files in tmp
sys.exit(0)

# Remove all previous images
Expand Down Expand Up @@ -203,27 +203,25 @@ def print_row(items, row_offset, columns):
print("")

for column in range(columns):
print( \
f"{' '*19}Author: " +\
print(
f"{' '*19}Author: " +
f"{', '.join(map(str, items[row_offset + column]['authors']))[:52]:<52}",
end=""
)
print("")

for column in range(columns):
print( \
f"{' '*19}Genre: " +\
print(
f"{' '*19}Genre: " +
f"{', '.join(map(str, items[row_offset + column]['genres']))[:53]:<53}",
end=""
)
print("")

for column in range(columns):
print(
f"{' '*19}Tag: " +\
f"{' '*19}Tag: " +
f"{', '.join(map(str, items[row_offset + column]['tags']))[:55]:<55}",
end=""
)
print("\n")


8 changes: 7 additions & 1 deletion setup_nvim_lsp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,10 @@ wget -O .gdb/qt5prettyprinters/helper.py \
wget -O .gdb/qt5prettyprinters/qt.py \
https://invent.kde.org/kdevelop/kdevelop/-/raw/master/plugins/gdb/printers/qt.py

cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DCMAKE_BUILD_TYPE=Debug .
rm -fr build
mkdir build
cd build || exit 1

cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DCMAKE_BUILD_TYPE=Debug ..
cd ..
ln -s build/compile_commands.json compile_commands.json
58 changes: 20 additions & 38 deletions src/Controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,34 +18,29 @@
#include <QDebug>

Controller::Controller(QObject *parent)
: QObject(parent), controllerThread(new QThread(this))
{
: QObject(parent), controllerThread(new QThread(this)) {
initializeThread();
}

Controller::~Controller()
{
Controller::~Controller() {
controllerThread->quit();
controllerThread->wait();
}

void Controller::initializeThread()
{
void Controller::initializeThread() {
this->moveToThread(controllerThread.data());
connect(controllerThread.data(), &QThread::finished,
controllerThread.data(), &QThread::deleteLater);
controllerThread->start();

// Using the controller thread to start model work
connect(this, &Controller::checkCommonFilesThreadSignal,
this, [this]()
{
this, [this]() {
model.checkCommonFiles();
});

connect(this, &Controller::setupThreadSignal,
this, [this](const QString& level, const QString& game)
{
this, [this](const QString& level, const QString& game) {
model.setup(level, game);
});

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

connect(this, &Controller::setupGameThreadSignal,
this, [this](int id)
{
this, [this](int id) {
model.setupGame(id);
});

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

connect(&downloader, &Downloader::networkWorkErrorSignal,
this, [this](int status)
{
this, [this](int status) {
emit controllerDownloadError(status);
}, Qt::QueuedConnection);

connect(&model, &Model::askGameSignal,
this, [this](int id)
{
this, [this](int id) {
emit controllerAskGame(id);
}, Qt::QueuedConnection);

connect(&model, &Model::generateListSignal,
this, [this]()
{
this, [this]() {
emit controllerGenerateList();
}, Qt::QueuedConnection);
}

void Controller::checkCommonFiles()
{
void Controller::checkCommonFiles() {
emit checkCommonFilesThreadSignal();
}

void Controller::setup(const QString& level, const QString& game)
{
void Controller::setup(const QString& level, const QString& game) {
emit setupThreadSignal(level, game);
}

void Controller::setupGame(int id)
{
void Controller::setupGame(int id) {
emit setupGameThreadSignal(id);
}

void Controller::setupLevel(int id)
{
void Controller::setupLevel(int id) {
emit setupLevelThreadSignal(id);
}

// GUI Threads
int Controller::checkGameDirectory(int id)
{
int Controller::checkGameDirectory(int id) {
return model.checkGameDirectory(id);
}

void Controller::getList(QVector<ListItemData>* list)
{
void Controller::getList(QVector<ListItemData>* list) {
model.getList(list);
}

const InfoData Controller::getInfo(int id)
{
const InfoData Controller::getInfo(int id) {
return model.getInfo(id);
}

const QString Controller::getWalkthrough(int id)
{
const QString Controller::getWalkthrough(int id) {
return model.getWalkthrough(id);
}

bool Controller::link(int id)
{
bool Controller::link(int id) {
return model.setLink(id);
}

int Controller::getItemState(int id)
{
int Controller::getItemState(int id) {
return model.getItemState(id);
}

6 changes: 2 additions & 4 deletions src/Controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,11 @@
* The controller activate UI thread work or light instant work on the model
*
*/
class Controller : public QObject
{
class Controller : public QObject {
Q_OBJECT

public:
static Controller& getInstance()
{
static Controller& getInstance() {
static Controller instance;
return instance;
}
Expand Down
Loading

0 comments on commit cc10a16

Please sign in to comment.