Skip to content

Commit

Permalink
Merge pull request #117 from ASM-Studios/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Mael-RABOT authored Nov 6, 2024
2 parents 6a61818 + 917a2d0 commit af7f4ff
Show file tree
Hide file tree
Showing 95 changed files with 17,084 additions and 783 deletions.
3 changes: 2 additions & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ Checks: "bugprone-*,cppcoreguidelines-*,clang-analyzer-*,readability-*,misc-*,mo
-readability-magic-numbers,
-unused-includes,
-bugprone-easily-swappable-parameters,
-readability-braces-around-statements
-readability-braces-around-statements,
-readability-convert-member-functions-to-static
"
87 changes: 46 additions & 41 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,12 @@ jobs:
./vcpkg/bootstrap-vcpkg.sh
fi
./vcpkg/vcpkg install
- name: Setup CMake
uses: jwlawson/actions-setup-cmake@v2
with:
cmake-version: '3.27.4'
- name: Compilation
run: |
./release.sh
- name: Create archive
run: |
zip -r linux_executables.zip r-type_client r-type_server
zip -r linux_executables.zip r-type_client r-type_server assets server/config.json client/config.json shared/Scenarios
- name: Upload Release Asset
id: upload-release-asset-linux
uses: actions/upload-release-asset@v1
Expand All @@ -72,39 +68,48 @@ jobs:
asset_name: linux_executables.zip
asset_content_type: application/zip

# build_and_deploy_windows:
# name: Build and deploy (Windows)
# runs-on: windows-latest
# needs: create_release
# steps:
# - name: Checkout repository
# uses: actions/checkout@v4
# - name: Cache vcpkg
# uses: actions/cache@v4
# with:
# path: C:\Users\runneradmin\AppData\Local\vcpkg\archives
# key: ${{ hashFiles('vcpkg.json') }}
# - name: Setup vcpkg
# run: |
# if (-not (Test-Path -Path "C:\vcpkg")) {
# git clone https://github.com/microsoft/vcpkg.git C:\vcpkg
# .\vcpkg\bootstrap-vcpkg.bat
# }
# C:\vcpkg\vcpkg install
# - name: Compilation # ne fonctionne pas encore
# run: |
# cmake -S . -B build -G "Ninja" -DCMAKE_TOOLCHAIN_FILE="C:\Program Files\Microsoft Visual Studio\2022\Community\VC\vcpkg\scripts\buildsystems\vcpkg.cmake" -DCMAKE_BUILD_TYPE=Release
# cmake --build .
# - name: Create archive
# run: |
# Compress-Archive -Path r-type_client.exe, r-type_server.exe -DestinationPath windows_executables.zip
# - name: Upload Release Asset
# id: upload-release-asset-windows
# uses: actions/upload-release-asset@v1
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# upload_url: ${{ needs.create_release.outputs.upload_url }}
# asset_path: ./windows_executables.zip
# asset_name: windows_executables.zip
# asset_content_type: application/zip
build_and_deploy_windows:
name: Build and deploy (Windows)
runs-on: windows-latest
needs: create_release
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Cache vcpkg
uses: actions/cache@v4
with:
path: C:\Users\runneradmin\AppData\Local\vcpkg\archives
key: ${{ hashFiles('vcpkg.json') }}
- name: Setup vcpkg
run: |
if (-not (Test-Path -Path "C:\vcpkg")) {
git clone https://github.com/microsoft/vcpkg.git C:\vcpkg
.\vcpkg\bootstrap-vcpkg.bat
}
C:\vcpkg\vcpkg install
- name: Setup Ninja
uses: seanmiddleditch/gha-setup-ninja@master
- name: Setup MSVC
uses: ilammy/[email protected]
- name: Compilation
run: |
mkdir cmake-build-windows
cd cmake-build-windows
cmake .. --preset=windows-from-windows -G "Ninja" -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake
cmake --build .
- name: Create archive
run: |
Get-ChildItem -Path .\server\* | Where-Object { $_.Name -ne 'config.json' } | Remove-Item -Recurse -Force
Get-ChildItem -Path .\client\* | Where-Object { $_.Name -ne 'config.json' } | Remove-Item -Recurse -Force
Get-ChildItem -Path .\shared\* | Where-Object { $_.Name -ne 'Scenarios' } | Remove-Item -Recurse -Force
Compress-Archive -Path r-type_client.exe, r-type_server.exe, *.dll, assets, server, client, shared -DestinationPath windows_executables.zip
- name: Upload Release Asset
id: upload-release-asset-windows
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_path: ./windows_executables.zip
asset_name: windows_executables.zip
asset_content_type: application/zip
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Executables
r-type_server
r-type_client
runner_client

# Secrets
note
Expand All @@ -22,10 +23,12 @@ docs/docs/html/*

# CMake

tags
.cache
build
cmake-build-debug
cmake-build-release
cmake-build-windows

### C ###

Expand Down Expand Up @@ -119,6 +122,7 @@ dkms.conf
*.app

### IDE ###
.gdbinit
.obsidian
compile_flags.txt
*.lock
Expand Down
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
cmake_minimum_required(VERSION 3.27.4)
project(rtype)

if (WIN32 OR MSVC)
add_definitions(-D_WIN32_WINNT=0x0601)
endif()

include_directories(shared/Singleton/include)
include_directories(shared/Clock/include)
include_directories(shared/network/include)
include_directories(shared/ECS/include)
include_directories(shared/ECS/src/Factories)
Expand Down
4 changes: 3 additions & 1 deletion CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"generator": "Ninja",
"binaryDir": "${sourceDir}/cmake-build-debug",
"cacheVariables": {
"VCPKG_MANIFEST_INSTALL": "ON",
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_CXX_COMPILER": "g++"
Expand Down Expand Up @@ -38,7 +39,8 @@
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
"CMAKE_BUILD_TYPE": "Release",
"CMAKE_CXX_COMPILER": "g++"
"CMAKE_CXX_COMPILER": "cl.exe",
"CMAKE_CXX_LINK_EXECUTABLE": "link.exe"
}
}
]
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ For developers, refer to the [Developers.md](docs/Developers.md) file.

This project is under the GNU General Public License v3.0.

All assets used in this project are under the Creative Commons License.

## Assets

All assets used in this project are under the Creative Commons License.
Expand All @@ -90,3 +92,4 @@ Here are the authors of some of the assets:
- [helianthus-games](https://helianthus-games.itch.io/)
- [kayillustrations](https://kayillustrations.itch.io/)
- [ansimuz](https://ansimuz.itch.io/)
- [foozlecc](https://foozlecc.itch.io/)
Binary file added assets/textures/backgrounds/scifi_labs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/textures/backgrounds/scifi_labs_back.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/textures/backgrounds/scifi_labs_front.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/textures/backgrounds/scifi_labs_mid.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/textures/platforms/platform_1x1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/textures/platforms/platform_1x3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/textures/player/runner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/textures/traps/electric_turret.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/textures/traps/laser_spikes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/textures/traps/saw.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
71 changes: 70 additions & 1 deletion assets/textures_config.cfg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# CurrentMaxId = 59 // Update this value when adding new textures
# CurrentMaxId = 70 // Update this value when adding new textures

backgrounds: {
main_menu: {
Expand Down Expand Up @@ -53,6 +53,30 @@ backgrounds: {
col = 1
scale = 1.0
};
scifi_labs: {
id = 60
row = 1
col = 1
scale = 1.0
};
scifi_labs_front: {
id = 67
row = 1
col = 1
scale = 1.0
};
scifi_labs_mid: {
id = 68
row = 1
col = 1
scale = 1.0
};
scifi_labs_back: {
id = 69
row = 1
col = 1
scale = 1.0
};
};

bar: {
Expand Down Expand Up @@ -337,3 +361,48 @@ buttons: {
scale = 5.0
};
};

player: {
runner: {
id = 61
row = 1
col = 8
scale = 1.0
};
};

traps: {
electric_turret: {
id = 62
row = 1
col = 25
scale = 5.0
};
laser_spikes: {
id = 63
row = 1
col = 10
scale = 5.0
};
saw: {
id = 64
row = 1
col = 6
scale = 5.0
};
};

platforms: {
platform_1x1: {
id = 65
row = 1
col = 1
scale = 5.0
};
platform_1x3: {
id = 66
row = 1
col = 3
scale = 5.0
};
};
1 change: 1 addition & 0 deletions clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ rm -rf cmake-build-release
rm -rf cmake-build-debug
rm -rf cmake-build-windows
rm -rf vgcore*
rm -rf tags
rm -rf $CLIENT
rm -rf $SERVER
25 changes: 15 additions & 10 deletions client/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,31 @@ include_directories(include)

find_package(SFML COMPONENTS system window graphics network audio CONFIG REQUIRED)
find_package(Boost COMPONENTS filesystem property_tree algorithm CONFIG REQUIRED)
find_package(libconfig CONFIG REQUIRED)

set(SOURCE_FILE
set(SOURCE_FILES
src/main.cpp
src/WindowManager.cpp
src/udpCallback.cpp
src/tcpCallback.cpp
src/SpriteManager.cpp
src/MusicManager.cpp
src/SystemMetrics.cpp
)

add_executable(r-type_client ${SOURCE_FILE})
add_executable(runner_client ${SOURCE_FILES})
target_compile_definitions(runner_client PRIVATE RUNNER)
target_link_libraries(
runner_client
sfml-system sfml-window sfml-graphics sfml-network sfml-audio
Boost::filesystem Boost::property_tree Boost::algorithm
Clock GameLogic ECS network Config Logger Texture
)

add_executable(r-type_client ${SOURCE_FILES})
target_compile_definitions(r-type_client PRIVATE RTYPE)
target_link_libraries(
r-type_client
sfml-system sfml-window sfml-graphics sfml-network sfml-audio
Boost::filesystem Boost::property_tree Boost::algorithm
network ECS GameLogic Config Logger Texture
Clock GameLogic ECS network Config Logger Texture
)

if (WIN32 OR MSVC)
target_link_libraries(r-type_client libconfig::libconfig libconfig::libconfig++)
elseif (UNIX)
target_link_libraries(r-type_client libconfig::config libconfig::config++)
endif()
4 changes: 3 additions & 1 deletion client/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@
"logLevel": "INFO",
"frameRateLimit": 60,
"hostname": "127.0.0.1",
"port": 8080
"udp_port": 8080,
"tcp_port": 8081,
"online": true
}
39 changes: 39 additions & 0 deletions client/include/SystemMetrics.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#pragma once

#include <string>
#include <SFML/Graphics.hpp>
#include <iostream>
#include "WindowManager.hpp"

#ifdef _WIN32
#include <windows.h>
#include <psapi.h>
#elif __linux__
#include <sys/resource.h>
#include <unistd.h>
#include <fstream>
#endif

extern int pingValue;

namespace GUI {class WindowManager;
class SystemMetrics {
public:
SystemMetrics() = delete;
explicit SystemMetrics(GUI::WindowManager& windowManager, const sf::RenderWindow *window);
~SystemMetrics();

void update();

private:
size_t memoryUsage;
float cpuUsage;
WindowManager& _windowManager;
float _timePerTick = 0;

size_t getMemoryUsage();
float getCPUUsage();
};

}

Loading

0 comments on commit af7f4ff

Please sign in to comment.