aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitattributes2
-rw-r--r--.github/workflows/builds.yml106
-rw-r--r--.gitignore24
-rw-r--r--.gitmodules6
-rw-r--r--README.md7
-rw-r--r--SConstruct32
m---------extension/deps/OV2-compiler0
-rw-r--r--extension/src/TestSingleton.cpp36
-rw-r--r--extension/src/TestSingleton.hpp24
-rw-r--r--extension/src/register_types.cpp51
-rw-r--r--extension/src/register_types.h6
-rw-r--r--game/icon.svg1
-rw-r--r--game/icon.svg.import37
-rw-r--r--game/project.godot20
-rw-r--r--game/src/StartNode.gd5
-rw-r--r--game/src/StartNode.tscn6
m---------godot-cpp0
17 files changed, 363 insertions, 0 deletions
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..8ad74f7
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,2 @@
+# Normalize EOL for all files that Git considers text files.
+* text=auto eol=lf
diff --git a/.github/workflows/builds.yml b/.github/workflows/builds.yml
new file mode 100644
index 0000000..bd8ca20
--- /dev/null
+++ b/.github/workflows/builds.yml
@@ -0,0 +1,106 @@
+name: Builds
+
+#on: [pull_request]
+
+concurrency:
+ group: ci-${{github.actor}}-${{github.head_ref || github.run_number}}-${{github.ref}}-macos
+ cancel-in-progress: true
+
+jobs:
+ build:
+ runs-on: ${{matrix.os}}
+ name: ${{matrix.name}}
+ strategy:
+ fail-fast: false
+ matrix:
+ include:
+ - identifier: windows-debug
+ os: windows-2019
+ name: 🏁 Windows Debug
+ target: template_debug
+ platform: windows
+ arch: x86_64
+ - identifier: windows-release
+ os: windows-2019
+ name: 🏁 Windows Release
+ target: template_release
+ platform: windows
+ arch: x86_64
+ - identifier: macos-debug
+ os: macos-latest
+ name: 🍎 macOS (universal) Debug
+ target: template_debug
+ platform: macos
+ arch: universal
+ - identifier: macos-release
+ os: macos-latest
+ name: 🍎 macOS (universal) Release
+ target: template_release
+ platform: macos
+ arch: universal
+ - identifier: linux-debug
+ os: ubuntu-18.04
+ name: 🐧 Linux Debug
+ runner: ubuntu-20.04
+ target: template_debug
+ platform: linux
+ arch: x86_64
+ - identifier: linux-release
+ os: ubuntu-18.04
+ name: 🐧 Linux Release
+ runner: ubuntu-20.04
+ target: template_release
+ platform: linux
+ arch: x86_64
+
+ steps:
+
+ - name: Checkout project
+ uses: actions/checkout@v3
+ with:
+ submodules: recursive
+
+ - name: Set up Python
+ uses: actions/setup-python@v4
+ with:
+ python-version: '3.x'
+
+ - name: Set up SCons
+ shell: bash
+ run: |
+ python -c "import sys; print(sys.version)"
+ python -m pip install scons
+ scons --version
+
+ - name: Linux dependencies
+ if: ${{ matrix.platform == 'linux' }}
+ run: |
+ sudo apt-get update -qq
+ sudo apt-get install -qqq build-essential pkg-config
+
+ - name: Setup MinGW for Windows/MinGW build
+ if: ${{ matrix.platform == 'windows' }}
+ uses: egor-tensin/setup-mingw@v2
+
+ - name: Compile godot-cpp
+ shell: sh
+ run: |
+ scons target='${{ matrix.target }}' platform='${{ matrix.platform }}' arch='${{ matrix.arch }}'
+ working-directory: godot-cpp
+
+ - name: Compile Extension
+ shell: sh
+ run: |
+ scons target='${{ matrix.target }}' platform='${{ matrix.platform }}' arch='${{ matrix.arch }}'
+
+ - name: Delete compilation files
+ if: ${{ matrix.platform == 'windows' }}
+ run: |
+ Remove-Item game/bin/openvic2/* -Include *.exp,*.lib,*.pdb -Force
+
+ - name: Upload artifact
+ uses: actions/upload-artifact@v3
+ with:
+ name: ${{ github.event.repository.name }}
+ path: |
+ ${{ github.workspace }}/game/bin/openvic2/*
diff --git a/.gitignore b/.gitignore
index 259148f..94bcd32 100644
--- a/.gitignore
+++ b/.gitignore
@@ -30,3 +30,27 @@
*.exe
*.out
*.app
+
+# Godot 4+ specific ignores
+.godot/
+game/bin/openvic2/*
+.sconsign*.dblite
+
+# Binaries
+*.o
+*.os
+*.so
+*.obj
+*.bc
+*.pyc
+*.dblite
+*.pdb
+*.lib
+bin
+*.config
+*.creator
+*.creator.user
+*.files
+*.includes
+*.idb
+*.exp \ No newline at end of file
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..10d14d2
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,6 @@
+[submodule "godot-cpp"]
+ path = godot-cpp
+ url = https://github.com/godotengine/godot-cpp
+[submodule "extension/deps/OV2-compiler"]
+ path = extension/deps/OV2-compiler
+ url = https://github.com/OpenVic2Project/OV2-compiler
diff --git a/README.md b/README.md
index 3aefcaa..cb5570b 100644
--- a/README.md
+++ b/README.md
@@ -1,2 +1,9 @@
# OpenVic2
Main Repo for the OpenVic2 Project
+
+# Instructions
+1. Ensure you have [scons](https://scons.org/) installed.
+2. Run `scons` here, when finished a libopenvic2 file will appear in `game/bin/openvic2`
+3. Open with Godot 4 beta 14, click import and navigate to the game directory
+4. Import and edit
+5. Once loaded, click the play button at the top right, if you see `Hello GDExtension Singleton!` in the output at the bottom then it is working. \ No newline at end of file
diff --git a/SConstruct b/SConstruct
new file mode 100644
index 0000000..50fa747
--- /dev/null
+++ b/SConstruct
@@ -0,0 +1,32 @@
+#!/usr/bin/env python
+import os
+import sys
+
+env = SConscript("godot-cpp/SConstruct")
+
+# For the reference:
+# - CCFLAGS are compilation flags shared between C and C++
+# - CFLAGS are for C-specific compilation flags
+# - CXXFLAGS are for C++-specific compilation flags
+# - CPPFLAGS are for pre-processor flags
+# - CPPDEFINES are for pre-processor defines
+# - LINKFLAGS are for linking flags
+
+# tweak this if you want to use different folders, or more folders, to store your source code in.
+env.Append(CPPPATH=["extension/src/"])
+sources = Glob("extension/src/*.cpp")
+
+if env["platform"] == "macos":
+ library = env.SharedLibrary(
+ "game/bin/openvic2/libopenvic2.{}.{}.framework/libgdsummator.{}.{}".format(
+ env["platform"], env["target"], env["platform"], env["target"]
+ ),
+ source=sources,
+ )
+else:
+ library = env.SharedLibrary(
+ "game/bin/openvic2/libopenvic2{}{}".format(env["suffix"], env["SHLIBSUFFIX"]),
+ source=sources,
+ )
+
+Default(library)
diff --git a/extension/deps/OV2-compiler b/extension/deps/OV2-compiler
new file mode 160000
+Subproject 267d38aab922fa929c0ce649fad699a6468b6c3
diff --git a/extension/src/TestSingleton.cpp b/extension/src/TestSingleton.cpp
new file mode 100644
index 0000000..0855a30
--- /dev/null
+++ b/extension/src/TestSingleton.cpp
@@ -0,0 +1,36 @@
+#include "TestSingleton.hpp"
+
+#include <godot_cpp/core/class_db.hpp>
+#include <godot_cpp/variant/utility_functions.hpp>
+
+using namespace godot;
+using namespace OpenVic2;
+
+TestSingleton *TestSingleton::singleton = nullptr;
+
+void TestSingleton::_bind_methods()
+{
+ ClassDB::bind_method(D_METHOD("hello_singleton"), &TestSingleton::hello_singleton);
+}
+
+TestSingleton *TestSingleton::get_singleton()
+{
+ return singleton;
+}
+
+TestSingleton::TestSingleton()
+{
+ ERR_FAIL_COND(singleton != nullptr);
+ singleton = this;
+}
+
+TestSingleton::~TestSingleton()
+{
+ ERR_FAIL_COND(singleton != this);
+ singleton = nullptr;
+}
+
+void TestSingleton::hello_singleton()
+{
+ UtilityFunctions::print("Hello GDExtension Singleton!");
+} \ No newline at end of file
diff --git a/extension/src/TestSingleton.hpp b/extension/src/TestSingleton.hpp
new file mode 100644
index 0000000..0a591ac
--- /dev/null
+++ b/extension/src/TestSingleton.hpp
@@ -0,0 +1,24 @@
+#pragma once
+
+#include <godot_cpp/classes/object.hpp>
+#include <godot_cpp/core/class_db.hpp>
+
+namespace OpenVic2 {
+ class TestSingleton : public godot::Object
+ {
+ GDCLASS(TestSingleton, godot::Object);
+
+ static TestSingleton *singleton;
+
+ protected:
+ static void _bind_methods();
+
+ public:
+ static TestSingleton *get_singleton();
+
+ TestSingleton();
+ ~TestSingleton();
+
+ void hello_singleton();
+ };
+} \ No newline at end of file
diff --git a/extension/src/register_types.cpp b/extension/src/register_types.cpp
new file mode 100644
index 0000000..775e6c3
--- /dev/null
+++ b/extension/src/register_types.cpp
@@ -0,0 +1,51 @@
+#include "register_types.h"
+#include <gdextension_interface.h>
+#include <godot_cpp/core/class_db.hpp>
+#include <godot_cpp/core/defs.hpp>
+#include <godot_cpp/godot.hpp>
+#include <godot_cpp/classes/engine.hpp>
+
+#include "TestSingleton.hpp"
+
+using namespace godot;
+using namespace OpenVic2;
+
+static TestSingleton *_test_singleton;
+
+void initialize_openvic2_types(ModuleInitializationLevel p_level)
+{
+ if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) {
+ return;
+ }
+
+ ClassDB::register_class<TestSingleton>();
+
+ _test_singleton = memnew(TestSingleton);
+ Engine::get_singleton()->register_singleton("TestSingleton", TestSingleton::get_singleton());
+}
+
+void uninitialize_openvic2_types(ModuleInitializationLevel p_level) {
+ if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) {
+ return;
+ }
+
+ Engine::get_singleton()->unregister_singleton("TestSingleton");
+ memdelete(_test_singleton);
+}
+
+extern "C"
+{
+
+ // Initialization.
+
+ GDExtensionBool GDE_EXPORT openvic2_library_init(const GDExtensionInterface *p_interface, const GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization)
+ {
+ GDExtensionBinding::InitObject init_obj(p_interface, p_library, r_initialization);
+
+ init_obj.register_initializer(initialize_openvic2_types);
+ init_obj.register_terminator(uninitialize_openvic2_types);
+ init_obj.set_minimum_library_initialization_level(MODULE_INITIALIZATION_LEVEL_SCENE);
+
+ return init_obj.init();
+ }
+} \ No newline at end of file
diff --git a/extension/src/register_types.h b/extension/src/register_types.h
new file mode 100644
index 0000000..860359f
--- /dev/null
+++ b/extension/src/register_types.h
@@ -0,0 +1,6 @@
+#pragma once
+
+#include <godot_cpp/core/class_db.hpp>
+
+void initialize_openvic2_types(godot::ModuleInitializationLevel);
+void uninitialize_openvic2_types(godot::ModuleInitializationLevel); \ No newline at end of file
diff --git a/game/icon.svg b/game/icon.svg
new file mode 100644
index 0000000..adc26df
--- /dev/null
+++ b/game/icon.svg
@@ -0,0 +1 @@
+<svg height="128" width="128" xmlns="http://www.w3.org/2000/svg"><g transform="translate(32 32)"><path d="m-16-32c-8.86 0-16 7.13-16 15.99v95.98c0 8.86 7.13 15.99 16 15.99h96c8.86 0 16-7.13 16-15.99v-95.98c0-8.85-7.14-15.99-16-15.99z" fill="#363d52"/><path d="m-16-32c-8.86 0-16 7.13-16 15.99v95.98c0 8.86 7.13 15.99 16 15.99h96c8.86 0 16-7.13 16-15.99v-95.98c0-8.85-7.14-15.99-16-15.99zm0 4h96c6.64 0 12 5.35 12 11.99v95.98c0 6.64-5.35 11.99-12 11.99h-96c-6.64 0-12-5.35-12-11.99v-95.98c0-6.64 5.36-11.99 12-11.99z" fill-opacity=".4"/></g><g stroke-width="9.92746" transform="matrix(.10073078 0 0 .10073078 12.425923 2.256365)"><path d="m0 0s-.325 1.994-.515 1.976l-36.182-3.491c-2.879-.278-5.115-2.574-5.317-5.459l-.994-14.247-27.992-1.997-1.904 12.912c-.424 2.872-2.932 5.037-5.835 5.037h-38.188c-2.902 0-5.41-2.165-5.834-5.037l-1.905-12.912-27.992 1.997-.994 14.247c-.202 2.886-2.438 5.182-5.317 5.46l-36.2 3.49c-.187.018-.324-1.978-.511-1.978l-.049-7.83 30.658-4.944 1.004-14.374c.203-2.91 2.551-5.263 5.463-5.472l38.551-2.75c.146-.01.29-.016.434-.016 2.897 0 5.401 2.166 5.825 5.038l1.959 13.286h28.005l1.959-13.286c.423-2.871 2.93-5.037 5.831-5.037.142 0 .284.005.423.015l38.556 2.75c2.911.209 5.26 2.562 5.463 5.472l1.003 14.374 30.645 4.966z" fill="#fff" transform="matrix(4.162611 0 0 -4.162611 919.24059 771.67186)"/><path d="m0 0v-47.514-6.035-5.492c.108-.001.216-.005.323-.015l36.196-3.49c1.896-.183 3.382-1.709 3.514-3.609l1.116-15.978 31.574-2.253 2.175 14.747c.282 1.912 1.922 3.329 3.856 3.329h38.188c1.933 0 3.573-1.417 3.855-3.329l2.175-14.747 31.575 2.253 1.115 15.978c.133 1.9 1.618 3.425 3.514 3.609l36.182 3.49c.107.01.214.014.322.015v4.711l.015.005v54.325c5.09692 6.4164715 9.92323 13.494208 13.621 19.449-5.651 9.62-12.575 18.217-19.976 26.182-6.864-3.455-13.531-7.369-19.828-11.534-3.151 3.132-6.7 5.694-10.186 8.372-3.425 2.751-7.285 4.768-10.946 7.118 1.09 8.117 1.629 16.108 1.846 24.448-9.446 4.754-19.519 7.906-29.708 10.17-4.068-6.837-7.788-14.241-11.028-21.479-3.842.642-7.702.88-11.567.926v.006c-.027 0-.052-.006-.075-.006-.024 0-.049.006-.073.006v-.006c-3.872-.046-7.729-.284-11.572-.926-3.238 7.238-6.956 14.642-11.03 21.479-10.184-2.264-20.258-5.416-29.703-10.17.216-8.34.755-16.331 1.848-24.448-3.668-2.35-7.523-4.367-10.949-7.118-3.481-2.678-7.036-5.24-10.188-8.372-6.297 4.165-12.962 8.079-19.828 11.534-7.401-7.965-14.321-16.562-19.974-26.182 4.4426579-6.973692 9.2079702-13.9828876 13.621-19.449z" fill="#478cbf" transform="matrix(4.162611 0 0 -4.162611 104.69892 525.90697)"/><path d="m0 0-1.121-16.063c-.135-1.936-1.675-3.477-3.611-3.616l-38.555-2.751c-.094-.007-.188-.01-.281-.01-1.916 0-3.569 1.406-3.852 3.33l-2.211 14.994h-31.459l-2.211-14.994c-.297-2.018-2.101-3.469-4.133-3.32l-38.555 2.751c-1.936.139-3.476 1.68-3.611 3.616l-1.121 16.063-32.547 3.138c.015-3.498.06-7.33.06-8.093 0-34.374 43.605-50.896 97.781-51.086h.066.067c54.176.19 97.766 16.712 97.766 51.086 0 .777.047 4.593.063 8.093z" fill="#478cbf" transform="matrix(4.162611 0 0 -4.162611 784.07144 817.24284)"/><path d="m0 0c0-12.052-9.765-21.815-21.813-21.815-12.042 0-21.81 9.763-21.81 21.815 0 12.044 9.768 21.802 21.81 21.802 12.048 0 21.813-9.758 21.813-21.802" fill="#fff" transform="matrix(4.162611 0 0 -4.162611 389.21484 625.67104)"/><path d="m0 0c0-7.994-6.479-14.473-14.479-14.473-7.996 0-14.479 6.479-14.479 14.473s6.483 14.479 14.479 14.479c8 0 14.479-6.485 14.479-14.479" fill="#414042" transform="matrix(4.162611 0 0 -4.162611 367.36686 631.05679)"/><path d="m0 0c-3.878 0-7.021 2.858-7.021 6.381v20.081c0 3.52 3.143 6.381 7.021 6.381s7.028-2.861 7.028-6.381v-20.081c0-3.523-3.15-6.381-7.028-6.381" fill="#fff" transform="matrix(4.162611 0 0 -4.162611 511.99336 724.73954)"/><path d="m0 0c0-12.052 9.765-21.815 21.815-21.815 12.041 0 21.808 9.763 21.808 21.815 0 12.044-9.767 21.802-21.808 21.802-12.05 0-21.815-9.758-21.815-21.802" fill="#fff" transform="matrix(4.162611 0 0 -4.162611 634.78706 625.67104)"/><path d="m0 0c0-7.994 6.477-14.473 14.471-14.473 8.002 0 14.479 6.479 14.479 14.473s-6.477 14.479-14.479 14.479c-7.994 0-14.471-6.485-14.471-14.479" fill="#414042" transform="matrix(4.162611 0 0 -4.162611 656.64056 631.05679)"/></g></svg>
diff --git a/game/icon.svg.import b/game/icon.svg.import
new file mode 100644
index 0000000..b124f12
--- /dev/null
+++ b/game/icon.svg.import
@@ -0,0 +1,37 @@
+[remap]
+
+importer="texture"
+type="CompressedTexture2D"
+uid="uid://bgxnxy7o5x7bq"
+path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"
+metadata={
+"vram_texture": false
+}
+
+[deps]
+
+source_file="res://icon.svg"
+dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"]
+
+[params]
+
+compress/mode=0
+compress/lossy_quality=0.7
+compress/hdr_compression=1
+compress/bptc_ldr=0
+compress/normal_map=0
+compress/channel_pack=0
+mipmaps/generate=false
+mipmaps/limit=-1
+roughness/mode=0
+roughness/src_normal=""
+process/fix_alpha_border=true
+process/premult_alpha=false
+process/normal_map_invert_y=false
+process/hdr_as_srgb=false
+process/hdr_clamp_exposure=false
+process/size_limit=0
+detect_3d/compress_to=1
+svg/scale=1.0
+editor/scale_with_editor_scale=false
+editor/convert_colors_with_editor_theme=false
diff --git a/game/project.godot b/game/project.godot
new file mode 100644
index 0000000..fadb09f
--- /dev/null
+++ b/game/project.godot
@@ -0,0 +1,20 @@
+; Engine configuration file.
+; It's best edited using the editor UI and not directly,
+; since the parameters that go here are not all obvious.
+;
+; Format:
+; [section] ; section goes between []
+; param=value ; assign values to parameters
+
+config_version=5
+
+[application]
+
+config/name="Game"
+run/main_scene="res://src/StartNode.tscn"
+config/features=PackedStringArray("4.0", "Forward Plus")
+config/icon="res://icon.svg"
+
+[editor]
+
+export/convert_text_resources_to_binary=true
diff --git a/game/src/StartNode.gd b/game/src/StartNode.gd
new file mode 100644
index 0000000..131dc40
--- /dev/null
+++ b/game/src/StartNode.gd
@@ -0,0 +1,5 @@
+extends Node
+
+func _ready():
+ print("From GDScript")
+ TestSingleton.hello_singleton()
diff --git a/game/src/StartNode.tscn b/game/src/StartNode.tscn
new file mode 100644
index 0000000..f992b6c
--- /dev/null
+++ b/game/src/StartNode.tscn
@@ -0,0 +1,6 @@
+[gd_scene load_steps=2 format=3 uid="uid://b5hk77pbyfd2j"]
+
+[ext_resource type="Script" path="res://src/StartNode.gd" id="1_6ch7h"]
+
+[node name="StartNode" type="Node"]
+script = ExtResource("1_6ch7h")
diff --git a/godot-cpp b/godot-cpp
new file mode 160000
+Subproject 19091138895d35e1ce69742889b8bfd82be57f1