Skip to content

Commit

Permalink
fix get_data.py, some lint, move to gpl3 and also add 2 maps
Browse files Browse the repository at this point in the history
  • Loading branch information
noisecode3 committed Aug 17, 2024
1 parent 496fe75 commit 0557ec7
Show file tree
Hide file tree
Showing 28 changed files with 1,371 additions and 475 deletions.
3 changes: 2 additions & 1 deletion .neovim.lua
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,6 @@ nvim_lsp.clangd.setup{}
require("mason").setup()
require("mason-lspconfig").setup()


vim.g.current_shiftwidth = 4
-- The style is meant to keep the code narrow, never let it over 80-100
-- With cpplint --filter=-whitespace/braces,-whitespace/newline
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@ target_link_libraries(${PROJECT_NAME} PUBLIC
# ${CURL_LIBRARY}
#)

target_include_directories(${PROJECT_NAME} PRIVATE ${CURL_INCLUDE_DIR} libs/miniz src )
target_include_directories(${PROJECT_NAME} PRIVATE
${CURL_INCLUDE_DIR}
libs/miniz
src
)

set_target_properties(${PROJECT_NAME} PROPERTIES
CXX_STANDARD 17
Expand Down
829 changes: 669 additions & 160 deletions LICENSE

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
cd "$(dirname "$0")"
cd "$(dirname "$0")" || exit 1
rm -fr build
mkdir build
cd build
cd build || exit 1
cmake -DCMAKE_BUILD_TYPE=Debug ..
make
2 changes: 1 addition & 1 deletion clean_nvim_lsp.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
cd "$(dirname "$0")"
cd "$(dirname "$0")" || exit 1
# clean up command
rm -fr CMakeCache.txt CMakeFiles Makefile cmake_install.cmake \
compile_commands.json TombRaiderLinuxLauncher \
Expand Down
4 changes: 4 additions & 0 deletions find.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
cd "$(dirname "$0")" || exit 1
FZF_DEFAULT_COMMAND="grep -Rn '' src" \
fzf --delimiter=: --bind 'enter:execute(less -N +{2} {1})'
2 changes: 1 addition & 1 deletion setup_nvim_lsp.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
cd "$(dirname "$0")"
cd "$(dirname "$0")" || exit 1
# don't forget that you need to build it one time
# and look at .neovim how to use debuger
mkdir -p .gdb/qt5prettyprinters/
Expand Down
20 changes: 18 additions & 2 deletions src/Controller.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/* TombRaiderLinuxLauncher
* Martin Bångens Copyright (C) 2024
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include "Controller.h"
#include <QDebug>

Expand Down Expand Up @@ -49,12 +65,12 @@ int Controller::checkGameDirectory(int id)

void Controller::setupCamp(const QString& level, const QString& game)
{
emit setupCampThreadSignal(level,game);
emit setupCampThreadSignal(level, game);
}

void Controller::setupCampThread(const QString& level, const QString& game)
{
bool status = model.setDirectory(level,game);
bool status = model.setDirectory(level, game);
emit setupCampDone(status);
}

Expand Down
33 changes: 24 additions & 9 deletions src/Controller.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
#ifndef CONTROLLER_H
#define CONTROLLER_H
/* TombRaiderLinuxLauncher
* Martin Bångens Copyright (C) 2024
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef SRC_CONTROLLER_H_
#define SRC_CONTROLLER_H_
#include <QObject>
#include <QThread>
#include "Model.h"
Expand All @@ -11,7 +27,7 @@
class Controller : public QObject
{
Q_OBJECT
public:
public:
static Controller& getInstance()
{
static Controller instance;
Expand All @@ -27,24 +43,23 @@ class Controller : public QObject
int getItemState(int id);
int checkGameDirectory(int id);

private:
private:
Model& model = Model::getInstance();

Controller(QObject *parent = nullptr);
explicit Controller(QObject *parent = nullptr);
~Controller();
QThread* ControllerThread;
Q_DISABLE_COPY(Controller)

public slots:
public slots:
void passTickSignal();
void setupCampThread(const QString& level, const QString& game);
void setupLevelThread(int id);
signals:
signals:
void controllerTickSignal();
void setupCampThreadSignal(const QString& level, const QString& game);
void setupCampDone(bool status);
void setupLevelThreadSignal(int id);
//void setupLevelDone(bool status);
};

#endif // CONTROLLER_H
#endif // SRC_CONTROLLER_H_
22 changes: 19 additions & 3 deletions src/Data.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/* TombRaiderLinuxLauncher
* Martin Bångens Copyright (C) 2024
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include "Data.h"

QVector<ListItemData> Data::getListItems()
Expand Down Expand Up @@ -27,7 +43,7 @@ QVector<ListItemData> Data::getListItems()
// Handle the case where no rows are returned
qDebug() << "No rows returned from the query";
}
for(int i=0; i<rowCount;i++)
for (int i=0; i < rowCount; i++)
{
QSqlQuery query(db);
query.prepare("SELECT Level.*, Info.*, Picture.* "
Expand All @@ -38,7 +54,7 @@ QVector<ListItemData> Data::getListItems()
"WHERE Level.LevelID = :id "
"GROUP BY Level.LevelID "
"ORDER BY MIN(Picture.PictureID) ASC");
query.bindValue(":id", i+1); // Set the ID autoincrament starts at 1
query.bindValue(":id", i+1); // Set the ID autoincrament starts at 1

if (query.exec())
{
Expand All @@ -54,7 +70,7 @@ QVector<ListItemData> Data::getListItems()
query.value("Info.class").toString(),
query.value("Picture.data").toByteArray()));
}
}
}
else
{
qDebug() << "Error executing query:" << query.lastError().text();
Expand Down
70 changes: 48 additions & 22 deletions src/Data.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,30 @@
#ifndef DATA_H
#define DATA_H
/* TombRaiderLinuxLauncher
* Martin Bångens Copyright (C) 2024
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef SRC_DATA_H_
#define SRC_DATA_H_

#include <QObject>
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QDebug>
#include <QSqlError>
#include "qicon.h"
#include "qpixmap.h"
#include <QIcon>
#include <QPixmap>

/**
* @struct FolderNames
* @brief Folder names game used on windows
Expand All @@ -31,12 +48,12 @@ struct ZipData
* @param
* @details
*/
ZipData() {};
ZipData( QString zipName, float zipSize, QString md5sum, QString url ):
ZipData() {}
ZipData(QString zipName, float zipSize, QString md5sum, QString url):
name(zipName),
megabyteSize(zipSize),
md5sum(md5sum),
url(url) {};
url(url) {}
QString name;
float megabyteSize;
QString md5sum;
Expand All @@ -51,31 +68,40 @@ struct ListItemData
* @param
* @details
*/
ListItemData() {};
ListItemData( QString title, QString author, QString type,
QString class_, QString releaseDate, QString difficulty,
QString duration, QByteArray imageData ):
ListItemData() {}
ListItemData(
QString title,
QString author,
QString type,
QString classIn,
QString releaseDate,
QString difficulty,
QString duration,
QByteArray imageData):
title(title),
author(author),
type(type),
class_(class_),
class_(classIn),
releaseDate(releaseDate),
difficulty(difficulty),
duration(duration)
{
QPixmap pixmap;
pixmap.loadFromData(imageData, "JPG");
picture.addPixmap(pixmap);
// Scale the pixmap to fit within a 640x480 rectangle while maintaining aspect ratio
// Scale the pixmap while maintaining aspect ratio
QSize newSize = pixmap.size().scaled(640, 480, Qt::KeepAspectRatio);
// Resize the pixmap to the scaled size
pixmap = pixmap.scaled(newSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
pixmap = pixmap.scaled(
newSize,
Qt::KeepAspectRatio,
Qt::SmoothTransformation);
// Create QIcon and add the scaled pixmap
picture.addPixmap(pixmap);
};
QString title;
QString author;
QString type; // like TR4
QString type;
QString class_;
QString releaseDate;
QString difficulty;
Expand All @@ -91,8 +117,8 @@ struct InfoData
* @param
* @details
*/
InfoData() {};
InfoData( QString body, QVector<QByteArray> imageList ) : body(body)
InfoData() {}
InfoData(QString body, QVector<QByteArray> imageList) : body(body)
{
for (const QByteArray &image : imageList)
{
Expand All @@ -110,7 +136,7 @@ struct InfoData
class Data : public QObject
{
Q_OBJECT
public:
public:
static Data& getInstance()
{
static Data instance;
Expand Down Expand Up @@ -147,17 +173,17 @@ class Data : public QObject
std::array<QVector<QString>, 2> getFileList(const int id, bool trleList);
ZipData getDownload(int id);

private:
Data(QObject *parent = nullptr) : QObject(parent)
private:
explicit Data(QObject *parent = nullptr) : QObject(parent)
{
}
~Data()
{
db.close();
}

Q_DISABLE_COPY(Data)
QSqlDatabase db;
Q_DISABLE_COPY(Data)
};

#endif // DATA_H
#endif // SRC_DATA_H_
Loading

0 comments on commit 0557ec7

Please sign in to comment.