Skip to content

Commit

Permalink
added error handling to string view
Browse files Browse the repository at this point in the history
added literal namespace to helper function to avoid collisions

added more tests
added string hashing

reworked dependency structure
all except tests are included now

reworked README.md

added back integradted tests
  • Loading branch information
gk646 committed May 12, 2024
1 parent 579d24b commit be9a08f
Show file tree
Hide file tree
Showing 231 changed files with 366,701 additions and 128 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/cmake-multi-platform.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: CMake on multiple platforms

on:
push:
branches:
- main

jobs:
build-and-test:
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
build_type: [Release]
include:
- os: windows-latest
c_compiler: cl
cpp_compiler: cl
- os: ubuntu-latest
c_compiler: gcc
cpp_compiler: g++

steps:
- uses: actions/checkout@v4

- name: Cache CMake builds
uses: actions/cache@v2
with:
path: ${{ github.workspace }}/build
key: ${{ runner.os }}-build-${{ hashFiles('**/CMakeLists.txt', '**/*.cpp', '**/*.h') }}
restore-keys: |
${{ runner.os }}-build-
- name: Configure CMake
run: |
cmake -B build \
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} \
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }} \
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-S .
working-directory: ${{ github.workspace }}

- name: Build
run: cmake --build build --config ${{ matrix.build_type }}
working-directory: ${{ github.workspace }}

- name: Run Tests
run: ctest -C ${{ matrix.build_type }} --output-on-failure
working-directory: ${{ github.workspace }}/build

- name: Upload Test Results
if: always()
uses: actions/upload-artifact@v2
with:
name: Test Results
path: ${{ github.workspace }}/build/Testing/**/*.xml
13 changes: 6 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,21 @@ set(CMAKE_CXX_STANDARD 23)

set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
set(BUILD_GAMES OFF CACHE BOOL "" FORCE)
set(OPENGL_VERSION "3.3" CACHE STRING "OpenGL Version to build raylib with")
set(OPENGL_VERSION "4.3" CACHE STRING "OpenGL Version to build raylib with")
set(BUILD_SHARED_LIBS ON CACHE BOOL "" FORCE) # Build as shared lib


set(ENABLE_SANITIZER OFF)
set(RUN_TESTS ON) # If it should build the test executable
set(RN_ENABLE_SANITIZER OFF) # If compiled with address sanitizer (MSVC)
set(RN_BUILD_TESTS OFF) # If it should build the test executable

# Compiler options for MSVC and GCC
include(cmake/CompilerOptions.cmake)

# Choose how the STL is linked
include(cmake/LinkSTL.cmake)

# Choose how to supply dependencies - currently only local libs supported
# include(cmake/FetchLibs.cmake)
include(cmake/LoadLocalLibs.cmake)
# Dependencies are included in the project - its only 14 mb
include(cmake/LoadInternalLibs.cmake)

# Add subdirectories for the main application components
add_subdirectory(src/raynodes)
Expand All @@ -33,7 +32,7 @@ add_subdirectory(src/import)
# Add all built targets here
add_dependencies(raynodes MQQS BuiltIns)

if (RUN_TESTS)
if (RN_BUILD_TESTS)
enable_testing()
add_subdirectory(test)
endif ()
29 changes: 11 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# raynodes

`raynodes` is a standalone 2D node editor made using [raylib](https://github.com/raysan5/raylib) with a focus
`raynodes` is a standalone 2D node editor made using [raylib](https://github.com/raysan5/raylib) and [raygui](https://github.com/raysan5/raygui) with a focus
extensibility. It aims to be an attractive tool for any node based task, and supports being integrated into
bigger projects like games, editors...
In many cases it comes close to being a node-editor SDK of sorts.
Expand All @@ -17,10 +17,10 @@ A small showcase of its major features:
- **Modern code base** using many C++20 and above
- **User created** nodes at runtime scripted in-editor in python (planned)

In a lot of places it uses my (header only) C++ helper library [cxstructs](https://github.com/gk646/cxstructs).
For more infos on the design choices go to [Software Design](#Software-Design)
For more information on how to use the editor look at the [raynodes-wiki](https://github.com/gk646/raynodes/wiki).
For more information on how to use the editor look at the [raynodes-wiki](https://github.com/gk646/raynodes/wiki).

The other dependencies are [cxstructs](https://github.com/gk646/cxstructs), [tinyfiledialogs](https://sourceforge.net/projects/tinyfiledialogs/) for file dialogs and [catch2](https://github.com/catchorg/Catch2) for testing.
![Image](.github/fullEditor.png)

**1.** [Installation](#Installation)
Expand All @@ -34,29 +34,22 @@ For more information on how to use the editor look at the [raynodes-wiki](https:

### For Users

Just download the .zip for your operating system from the most recent release in the [release page](https://github.com/gk646/raynodes/releases/tag/1.0.0).
Just download the .zip for your operating system from the most recent release in the [release page](https://github.com/gk646/raynodes/releases).
Unzip and start the executable! Have fun using `raynodes`.

### For Developers

This project uses CMake as buildsystem!

To build the project locally you just need to do 2 simple steps:
1. Clone this git repository
2. Supply the needed dependencies as specified inside the LoadLocalLibs.cmake

```cmake
set(DEPENDENCIES_PATH "C:/Users/gk646/Documents/Libraries") # Set to where your libraries are stored
To build the project locally you just need to do 4 simple steps:

include_directories(
"${DEPENDENCIES_PATH}/raylib-master/src" # Supply a clone of raylib.git
"${DEPENDENCIES_PATH}/raygui-master/src" # Supply a clone of raygui.git
"${DEPENDENCIES_PATH}/tinyfiledialogs" # Download from here https://sourceforge.net/projects/tinyfiledialogs/
"${DEPENDENCIES_PATH}/cxstructs-master/include" # Supply a clone of cxstructs.git
)
```
1. Clone this git repository
2. Create a new directory inside the clone repository (e.g. cmake-build-debug)
3. Configure the build from inside the build directory with `cmake ..`
4. Build the project from inside the build directory with `make ..`

At some point I will probably add an alternative version that automatically downloads the dependencies.
All external dependencies are included in the source!
This model is chose based on their combined low size (only **14mb**) and the provided simplicity for sharing and integrated testing.

## Editor Features:

Expand Down
12 changes: 0 additions & 12 deletions cmake/FetchLibs.cmake

This file was deleted.

14 changes: 14 additions & 0 deletions cmake/LoadInternalLibs.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

set(DEPENDENCIES_PATH "${CMAKE_SOURCE_DIR}/src/external") # Internal library storage

include_directories(
"${DEPENDENCIES_PATH}/raylib/src"
"${DEPENDENCIES_PATH}/raygui/src"
"${DEPENDENCIES_PATH}/tinyfiledialogs"
"${DEPENDENCIES_PATH}/cxstructs/include"
)

add_subdirectory("${DEPENDENCIES_PATH}/raylib" raylib)


add_library(nativefiledialogs STATIC "${DEPENDENCIES_PATH}/tinyfiledialogs/tinyfiledialogs.c")
14 changes: 0 additions & 14 deletions cmake/LoadLocalLibs.cmake

This file was deleted.

22 changes: 13 additions & 9 deletions include/RnImport.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,23 @@ using ComponentIndex = uint8_t; // Limits to 256 components per node
using TemplateID = uint8_t; // Limits to 256 unique nodes

// Dont wanna include raylib everywhere
struct Vec2 {
struct Vec2 final {
float x;
float y;
};

// This way we can return a unallocated string
struct StringView {
struct StringView final{
const char* start = nullptr;
uint16_t length = 0;
[[nodiscard]] std::string getString() const { return {start, length}; }
};

struct Vec3 {
[[nodiscard]] std::string getString() const {
if(start == nullptr || length == 0) [[unlikely]]{
return std::string() ;
}
return {start, length};
};

struct Vec3 final{
float x;
float y;
float z;
Expand All @@ -91,7 +95,7 @@ enum DataType : uint8_t {
STRING_VIEW, // Returns a StringView - unallocated string
};

struct Connection {
struct Connection final{
NodeID fromNode; // Value between 0 and nodeCnt-1 or ]0 - nodeCnt] or (0 - nodeCnt]
int8_t fromComponent; // -1 if its a node-to-node connection
uint8_t fromPin;
Expand All @@ -101,7 +105,7 @@ struct Connection {
[[nodiscard]] bool isValid() const { return fromNode != UINT16_MAX; }
};

struct NodeData {
struct NodeData final {
ByteIndex startByte = 0;
const NodeID id = 0;
const TemplateID tID = 0;
Expand All @@ -110,7 +114,7 @@ struct NodeData {
auto getData(char* fileData, ComponentIndex id, int index) const;
};

struct NodeTemplate {
struct NodeTemplate final{
const uint16_t startByte = 0;
ComponentIndex getCompIndex(char* fileData, const char* label) const;
StringView getName(const char* fileData) const;
Expand Down
27 changes: 26 additions & 1 deletion licenses.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,29 @@ raygui
2. Altered source versions must be plainly marked as such, and must not be misrepresented
as being the original software.

3. This notice may not be removed or altered from any source distribution.
3. This notice may not be removed or altered from any source distribution.

Catch2
Boost Software License - Version 1.0 - August 17th, 2003

Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:

The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
23 changes: 23 additions & 0 deletions src/external/catch2/LICENSE.txt.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Boost Software License - Version 1.0 - August 17th, 2003

Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:

The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
Loading

0 comments on commit be9a08f

Please sign in to comment.