Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
3382391
fix: menu segfault fix, windows build fixes
InfernalKn1ght Aug 5, 2025
e1cd1d5
test: add Qt tests for Ship class
InfernalKn1ght Aug 5, 2025
467fc22
Merge remote-tracking branch 'origin/windows-build' into qt-tests
InfernalKn1ght Aug 5, 2025
5c9a15f
fix: after merge fix
InfernalKn1ght Aug 5, 2025
a6cd629
fix: destroy qml components properly
InfernalKn1ght Aug 23, 2025
cb2df82
feat: add pop up menu in space view
InfernalKn1ght Aug 23, 2025
a577189
feat: add GUI testing with Spix, add code coverage with gcovr
InfernalKn1ght Aug 23, 2025
dec3124
feat: add test mode for running game without resources
InfernalKn1ght Aug 27, 2025
253d9f0
feat: add gen scripts for test mode
InfernalKn1ght Aug 28, 2025
305fd6a
feat: add more comprehensive GUI testing
InfernalKn1ght Aug 30, 2025
a140468
feat: add tests and coverage to CI
InfernalKn1ght Aug 30, 2025
3a66f48
fix(ci): install gtest in dependencies
InfernalKn1ght Aug 30, 2025
624c4eb
fix: install gcovr
InfernalKn1ght Aug 30, 2025
08fdb96
fix(ci): add virtual display support via xvbf
InfernalKn1ght Aug 30, 2025
9e9c483
fix(ci): xvbf and other fixes
InfernalKn1ght Aug 30, 2025
b0716ac
fix(ci): manually launch xvbf
InfernalKn1ght Aug 30, 2025
69118b8
fix(ci): code coverage workflow fix
InfernalKn1ght Sep 3, 2025
fecd2b4
docs: update readme
InfernalKn1ght Sep 3, 2025
e9f03f5
feat: replace Makefile.root with opensr_setup.sh
InfernalKn1ght Sep 7, 2025
c47cfeb
docs: edit readme
InfernalKn1ght Sep 7, 2025
7c11f9e
docs: final readme edits
InfernalKn1ght Sep 7, 2025
2755a35
fix: setup script fix
InfernalKn1ght Sep 7, 2025
53d7f52
fix(ci): enable tests building
InfernalKn1ght Sep 7, 2025
9dd43f5
fix: minor build fixes
InfernalKn1ght Sep 9, 2025
e351425
fix: remove unnecessary changes
InfernalKn1ght Sep 9, 2025
d6febb9
fix(build): include fixes
InfernalKn1ght Sep 11, 2025
eca6167
fix: increase GUI test wait time
InfernalKn1ght Sep 11, 2025
8a6c492
feat: linting improvement
InfernalKn1ght Sep 11, 2025
e77c6b2
feat: add path filter
InfernalKn1ght Sep 11, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 38 additions & 1 deletion .github/actions/install-dependencies-composite-action/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ runs:
shell: bash
run: sudo apt-get update -y && sudo apt-get install -y cmake

- name: Install Ninja
shell: bash
run: sudo apt-get install -y ninja-build

- name: Install Qt
uses: jurplel/install-qt-action@v4
with:
Expand All @@ -22,4 +26,37 @@ runs:

- name: Install OpenAL
shell: bash
run: sudo apt-get install -y libopenal-dev
run: sudo apt-get install -y libopenal-dev

- name: Install GTest
shell: bash
run: sudo apt-get install -y libgtest-dev

- name: Install gcovr
shell: bash
run: sudo apt-get install -y gcovr

- name: Install xvbf
shell: bash
run: sudo apt-get install -y xvfb libxcb-cursor0

- name: Install AnyRPC
shell: bash
run: |
git clone https://github.com/sgieseking/anyrpc.git
cd anyrpc
mkdir build
cd build
cmake -DBUILD_EXAMPLES=OFF -DBUILD_WITH_LOG4CPLUS=OFF -DBUILD_PROTOCOL_MESSAGEPACK=OFF ..
cmake --build .
sudo cmake --install .

- name: Install Spix
shell: bash
run: |
git clone https://github.com/faaxm/spix
cd spix
mkdir build && cd build
cmake -DSPIX_QT_MAJOR=6 -SPIX_BUILD_EXAMPLES=OFF ..
cmake --build .
sudo cmake --install .
41 changes: 38 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,39 @@
name: Build master
name: Build and test

on:
push:
branches: [ master ]
paths:
- 'data/**/*.js'
- 'Engine/**'
- 'ImagePlugin/**'
- 'include/**'
- 'QM/**'
- 'QML/**'
- 'Ranger/**'
- 'tests/**'
- 'tools/**'
- 'World/**'
- 'CMakeLists.txt'
- '**/CMakeLists.txt'
- 'opensr_setup.sh'

pull_request:
branches: [ master ]
paths:
- 'data/**/*.js'
- 'Engine/**'
- 'ImagePlugin/**'
- 'include/**'
- 'QM/**'
- 'QML/**'
- 'Ranger/**'
- 'tests/**'
- 'tools/**'
- 'World/**'
- 'CMakeLists.txt'
- '**/CMakeLists.txt'
- 'opensr_setup.sh'

env:
BUILD_TYPE: Debug
Expand All @@ -21,7 +50,13 @@ jobs:
uses: ./.github/actions/install-dependencies-composite-action

- name: Configure CMake
run: cmake -S . -B build -DBUILD_ALL_TOOLS=Yes -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }}
run: cmake -G Ninja -S . -B build -DBUILD_ALL_TOOLS=Yes -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} -DBUILD_TESTS=Yes

- name: Build
run: cmake --build build -j
run: cmake --build build --parallel $(nproc)

- name: Create symlinks to plugins
run: ./opensr_setup.sh -t demo

- name: Run tests
run: cd build/ && xvfb-run --auto-servernum --server-args="-screen 0 1280x1024x24" ctest -VV
66 changes: 66 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Code coverage

on:
push:
branches: [ master ]
paths:
- 'data/**/*.js'
- 'Engine/**'
- 'ImagePlugin/**'
- 'include/**'
- 'QM/**'
- 'QML/**'
- 'Ranger/**'
- 'tests/**'
- 'tools/**'
- 'World/**'
- 'CMakeLists.txt'
- '**/CMakeLists.txt'

pull_request:
branches: [ master ]
paths:
- 'data/**/*.js'
- 'Engine/**'
- 'ImagePlugin/**'
- 'include/**'
- 'QM/**'
- 'QML/**'
- 'Ranger/**'
- 'tests/**'
- 'tools/**'
- 'World/**'
- 'CMakeLists.txt'
- '**/CMakeLists.txt'

env:
BUILD_TYPE: Debug

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install dependencies
uses: ./.github/actions/install-dependencies-composite-action

- name: Configure CMake
run: cmake -G Ninja -S . -B build -DCMAKE_CXX_COMPILER=g++ -DBUILD_ALL_TOOLS=Yes -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} -DENABLE_COVERAGE=Yes

- name: Build
run: cmake --build build --parallel $(nproc)

- name: Create symlinks to plugins
run: ./opensr_setup.sh -t demo

- name: Make coverage report
run: xvfb-run --auto-servernum --server-args="-screen 0 1280x1024x24" cmake --build build --target global_coverage

- name: Coveralls
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
file: build/coverage/coverage.json
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
uses: ./.github/actions/install-dependencies-composite-action

- name: Configure CMake
run: cmake -S . -B build -DBUILD_ALL_TOOLS=Yes -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }}
run: cmake -G Ninja -S . -B build -DCMAKE_CXX_COMPILER=clang++ -DBUILD_ALL_TOOLS=Yes -DBUILD_TESTS=Yes -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }}

- uses: cpp-linter/cpp-linter-action@v2
id: linter
Expand All @@ -34,7 +34,7 @@ jobs:
with:
version: '19'
database: 'build'
ignore: 'QML|data|.github|build|Engine/3rdparty|Engine/shaders|tools'
ignore: 'QML|data|.github|build|Engine/3rdparty|Engine/shaders|anyrpc|spix'
style: 'file'
tidy-checks: ''
step-summary: true
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ Makefile
CMakeFiles
*.user
CMakeCache.txt
/.vscode
/.qt
# Root build dir
/build
/libworld.so
Expand Down
45 changes: 40 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
cmake_minimum_required(VERSION 3.16...3.27)
cmake_minimum_required(VERSION 3.10)

project(OpenSR
VERSION 0.1.1
LANGUAGES CXX
)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules")

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

set(CMAKE_CXX_STANDARD 20)
Expand All @@ -19,13 +17,45 @@ set(CMAKE_AUTOUIC ON)

set(API_VERSION 1)

find_package(Qt6 REQUIRED COMPONENTS Core Gui)

option(BUILD_ALL_TOOLS "Build all tools (overrides individual tool options)" OFF)
option(BUILD_RESOURCE_VIEWER "Build Resource Viewer tool" OFF)
option(BUILD_PLANET_VIEWER "Build Planet Viewer tool" OFF)
option(BUILD_QUEST_PLAYER "Build Quest Player tool" OFF)
option(BUILD_DAT_TOOLS "Build tools for DAT files" OFF)
option(BUILD_TESTS "Build project unit tests and tests for UI components" OFF)
option(ENABLE_COVERAGE "Enable code covereage (turns test building on)" OFF)

if(ENABLE_COVERAGE)
set(BUILD_TESTS ON)

add_compile_options(--coverage -g -O0 -fprofile-arcs)
add_link_options(--coverage -fprofile-arcs)

find_program(GCOVR gcovr REQUIRED)

file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/coverage)

add_custom_target(run_all_tests
COMMAND find ${CMAKE_BINARY_DIR} -name "*.gcda" -delete
COMMAND ${CMAKE_CTEST_COMMAND} -VV
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMENT "Running all tests for coverage"
)

add_custom_target(global_coverage
COMMAND ${GCOVR} -r ${CMAKE_SOURCE_DIR}
--exclude '.*/tests'
--exclude '.*/moc_.*'
--exclude '.*autogen.*'
--exclude '.*_autogen.*'
--exclude '.*/CMakeFiles/.*'
--exclude '.*/.qt'
--coveralls -o ${CMAKE_BINARY_DIR}/coverage/coverage.json
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMENT "Generating combined coverage report for all tests"
DEPENDS run_all_tests
)
endif()

if(BUILD_ALL_TOOLS)
set(BUILD_RESOURCE_VIEWER ON)
Expand All @@ -40,6 +70,11 @@ add_subdirectory(QM)
add_subdirectory(Engine)
add_subdirectory(World)

if (BUILD_TESTS)
include(CTest)
add_subdirectory(tests)
endif()

if(BUILD_RESOURCE_VIEWER OR BUILD_PLANET_VIEWER OR BUILD_QUEST_PLAYER OR BUILD_DAT_TOOLS)
add_subdirectory(tools)
endif()
2 changes: 1 addition & 1 deletion Engine/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
find_package(Qt6 REQUIRED COMPONENTS Widgets Quick ShaderTools)
find_package(Qt6 REQUIRED COMPONENTS Widgets Quick ShaderTools Gui)
find_package(OpenAL REQUIRED)

add_library(engine SHARED
Expand Down
20 changes: 18 additions & 2 deletions Engine/Engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class Engine::EnginePrivate
QUrl startupScript;
QUrl mainQML;
bool running = false;
bool testMode = false;
};

Engine::Engine(int &argc, char **argv) : QApplication(argc, argv), d_osr_ptr(new EnginePrivate())
Expand All @@ -95,6 +96,14 @@ Engine::Engine(int &argc, char **argv) : QApplication(argc, argv), d_osr_ptr(new

d->qmlEngine->globalObject().setProperty("Engine", d->qmlEngine->newQObject(this));
d->qmlEngine->setObjectOwnership(this, QQmlEngine::CppOwnership);
d->qmlEngine->rootContext()->setContextProperty("isTestMode", false);

d->testMode = arguments().contains("--test-mode");

if (d->testMode)
{
d->qmlEngine->rootContext()->setContextProperty("isTestMode", true);
}
}

Engine::~Engine()
Expand Down Expand Up @@ -146,7 +155,13 @@ int Engine::run()

auto scriptExec = [this] {
Q_D(Engine);
if (!d->startupScript.isEmpty())

if (d->testMode)
{
execScript(QUrl("res:/opensrTestMode.js"));
return;
}
if (!d->startupScript.isEmpty() && !d->testMode)
{
execScript(d->startupScript);
}
Expand Down Expand Up @@ -178,7 +193,8 @@ void Engine::showQMLComponent(const QString &url)

for (auto root : d->qmlEngine->rootObjects())
{
QMetaObject::invokeMethod(root, "destroyAndChangeScreen", Q_ARG(QVariant, QUrl(url)), Q_ARG(QVariant, QVariantMap()));
QMetaObject::invokeMethod(root, "destroyAndChangeScreen", Q_ARG(QVariant, QUrl(url)),
Q_ARG(QVariant, QVariantMap()));
}
}

Expand Down
4 changes: 2 additions & 2 deletions Engine/GAIAnimatedImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class GAIAnimatedImage::GAIAnimatedImagePrivate
QList<QVector<QPoint>> m_gaiOffsets;
QTimer m_timer;

std::vector<std::unique_ptr<GAITexture>> m_textures;
std::vector<std::shared_ptr<GAITexture>> m_textures;
long long m_currentFile = 0;
bool m_fileChanged = false;
bool m_playing = true;
Expand Down Expand Up @@ -168,7 +168,7 @@ QSGNode *GAIAnimatedImage::updatePaintNode(QSGNode *oldNode, QQuickItem::UpdateP

if (d->m_fileChanged)
{
material->setTexture(d->m_textures[d->m_currentFile].get());
material->setTexture(d->m_textures[d->m_currentFile]);
node->markDirty(QSGNode::DirtyMaterial);
d->m_fileChanged = false;
}
Expand Down
5 changes: 3 additions & 2 deletions Engine/GAIMaterial.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "GAIMaterial.h"
#include "GAIShader.h"
#include <memory>

namespace OpenSR
{
Expand All @@ -21,10 +22,10 @@ QSGMaterialShader *GAIMaterial::createShader(QSGRendererInterface::RenderMode) c

GAITexture *GAIMaterial::texture() const
{
return m_texture;
return m_texture.get();
}

void GAIMaterial::setTexture(GAITexture *texture)
void GAIMaterial::setTexture(std::shared_ptr<GAITexture> texture)
{
m_texture = texture;
}
Expand Down
4 changes: 2 additions & 2 deletions Engine/GAIMaterial.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ class GAIMaterial : public QSGMaterial
QSGMaterialType *type() const override;
QSGMaterialShader *createShader(QSGRendererInterface::RenderMode) const override;
GAITexture *texture() const;
void setTexture(GAITexture *texture);
void setTexture(std::shared_ptr<GAITexture> texture);

private:
GAITexture *m_texture;
std::shared_ptr<GAITexture> m_texture;
};
} // namespace OpenSR
1 change: 1 addition & 0 deletions Engine/ResourceManager_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "OpenSR/ResourceManager.h"

#include <OpenSR/libRangerQt.h>
#include <QDir>
#include <QNetworkReply>

class QFile;
Expand Down
Loading
Loading