diff options
author | BrickPi <49528459+BrickPi@users.noreply.github.com> | 2023-02-27 13:09:41 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-27 13:09:41 +0100 |
commit | e637c3afe2854488d1c2e755e0272f431105c404 (patch) | |
tree | 14d5cd52e699d5ebe8602dc3243b71689eec19c5 /extension/src | |
parent | 93c6b207c11fdaba484410eb53fc11b35fbbb3bd (diff) |
Add Main Menu Version and Checksum Labels (#44)
Diffstat (limited to 'extension/src')
-rw-r--r-- | extension/src/Checksum.hpp | 38 | ||||
-rw-r--r-- | extension/src/register_types.cpp | 9 |
2 files changed, 47 insertions, 0 deletions
diff --git a/extension/src/Checksum.hpp b/extension/src/Checksum.hpp new file mode 100644 index 0000000..ebdbd43 --- /dev/null +++ b/extension/src/Checksum.hpp @@ -0,0 +1,38 @@ +#pragma once + +#include <godot_cpp/classes/object.hpp> +#include <godot_cpp/core/class_db.hpp> +#include <godot_cpp/variant/utility_functions.hpp> + +namespace OpenVic2 { + class Checksum : public godot::Object { + GDCLASS(Checksum, godot::Object) + + //BEGIN BOILERPLATE + static Checksum* _checksum; + + protected: + static void _bind_methods() { + godot::ClassDB::bind_method(godot::D_METHOD("get_checksum_text"), &Checksum::get_checksum_text); + } + + public: + inline static Checksum* get_singleton() { return _checksum; } + + inline Checksum() { + ERR_FAIL_COND(_checksum != nullptr); + _checksum = this; + } + inline ~Checksum() { + ERR_FAIL_COND(_checksum != this); + _checksum = nullptr; + } + //END BOILERPLATE + + inline godot::String get_checksum_text() { + return godot::String("1234abcd"); + } + }; + + Checksum* Checksum::_checksum = nullptr; +}
\ No newline at end of file diff --git a/extension/src/register_types.cpp b/extension/src/register_types.cpp index 84e4dc4..aac38b9 100644 --- a/extension/src/register_types.cpp +++ b/extension/src/register_types.cpp @@ -7,12 +7,14 @@ #include "TestSingleton.hpp" #include "Simulation.hpp" +#include "Checksum.hpp" using namespace godot; using namespace OpenVic2; static TestSingleton* _test_singleton; static Simulation* _simulation; +static Checksum* _checksum; void initialize_openvic2_types(ModuleInitializationLevel p_level) { @@ -28,6 +30,10 @@ void initialize_openvic2_types(ModuleInitializationLevel p_level) _simulation = memnew(Simulation); Engine::get_singleton()->register_singleton("Simulation", Simulation::get_singleton()); + ClassDB::register_class<Checksum>(); + _checksum = memnew(Checksum); + Engine::get_singleton()->register_singleton("Checksum", Checksum::get_singleton()); + } void uninitialize_openvic2_types(ModuleInitializationLevel p_level) { @@ -40,6 +46,9 @@ void uninitialize_openvic2_types(ModuleInitializationLevel p_level) { Engine::get_singleton()->unregister_singleton("Simulation"); memdelete(_simulation); + + Engine::get_singleton()->unregister_singleton("Checksum"); + memdelete(_checksum); } extern "C" |