aboutsummaryrefslogtreecommitdiff
path: root/extension/src/openvic-extension/classes/GUIMaskedFlag.cpp
diff options
context:
space:
mode:
author hop311 <hop3114@gmail.com>2024-08-28 19:46:30 +0200
committer hop311 <hop3114@gmail.com>2024-08-28 23:51:31 +0200
commit88acb31bd43f0e163522837bb1d0dd7da2977c4a (patch)
tree241cbf8cf21a7cdfe1c870469ac3b3ef3064bdb3 /extension/src/openvic-extension/classes/GUIMaskedFlag.cpp
parentd7672f406406eea46625bc725690651f28211e19 (diff)
Switch to using custom UI nodes
Diffstat (limited to 'extension/src/openvic-extension/classes/GUIMaskedFlag.cpp')
-rw-r--r--extension/src/openvic-extension/classes/GUIMaskedFlag.cpp88
1 files changed, 88 insertions, 0 deletions
diff --git a/extension/src/openvic-extension/classes/GUIMaskedFlag.cpp b/extension/src/openvic-extension/classes/GUIMaskedFlag.cpp
new file mode 100644
index 0000000..968cebb
--- /dev/null
+++ b/extension/src/openvic-extension/classes/GUIMaskedFlag.cpp
@@ -0,0 +1,88 @@
+#include "GUIMaskedFlag.hpp"
+
+#include "openvic-extension/utility/ClassBindings.hpp"
+
+using namespace godot;
+using namespace OpenVic;
+
+void GUIMaskedFlag::_bind_methods() {
+ OV_BIND_METHOD(GUIMaskedFlag::get_gfx_masked_flag_texture);
+
+ OV_BIND_METHOD(GUIMaskedFlag::set_gfx_masked_flag_name, { "gfx_masked_flag_name" });
+ OV_BIND_METHOD(GUIMaskedFlag::get_gfx_masked_flag_name);
+
+ OV_BIND_METHOD(GUIMaskedFlag::set_flag_country_name_and_type, { "flag_country_name", "flag_type" });
+ OV_BIND_METHOD(GUIMaskedFlag::set_flag_country_name, { "flag_country_name" });
+ OV_BIND_METHOD(GUIMaskedFlag::get_flag_country_name);
+ OV_BIND_METHOD(GUIMaskedFlag::get_flag_type);
+}
+
+Error GUIMaskedFlag::set_gfx_masked_flag(GFX::MaskedFlag const* gfx_masked_flag) {
+ const bool needs_setting = gfx_masked_flag_texture.is_null();
+
+ if (needs_setting) {
+ gfx_masked_flag_texture.instantiate();
+ ERR_FAIL_NULL_V(gfx_masked_flag_texture, FAILED);
+ }
+
+ const Error err = gfx_masked_flag_texture->set_gfx_masked_flag(gfx_masked_flag);
+
+ if (needs_setting) {
+ set_texture(gfx_masked_flag_texture);
+ }
+
+ return err;
+}
+
+Ref<GFXMaskedFlagTexture> GUIMaskedFlag::get_gfx_masked_flag_texture() const {
+ ERR_FAIL_NULL_V(gfx_masked_flag_texture, nullptr);
+
+ return gfx_masked_flag_texture;
+}
+
+Error GUIMaskedFlag::set_gfx_masked_flag_name(String const& gfx_masked_flag_name) {
+ const bool needs_setting = gfx_masked_flag_texture.is_null();
+
+ if (needs_setting) {
+ gfx_masked_flag_texture.instantiate();
+ ERR_FAIL_NULL_V(gfx_masked_flag_texture, FAILED);
+ }
+
+ const Error err = gfx_masked_flag_texture->set_gfx_masked_flag_name(gfx_masked_flag_name);
+
+ if (needs_setting) {
+ set_texture(gfx_masked_flag_texture);
+ }
+
+ return err;
+}
+
+String GUIMaskedFlag::get_gfx_masked_flag_name() const {
+ ERR_FAIL_NULL_V(gfx_masked_flag_texture, {});
+
+ return gfx_masked_flag_texture->get_gfx_masked_flag_name();
+}
+
+Error GUIMaskedFlag::set_flag_country_name_and_type(String const& flag_country_name, StringName const& flag_type) const {
+ ERR_FAIL_NULL_V(gfx_masked_flag_texture, FAILED);
+
+ return gfx_masked_flag_texture->set_flag_country_name_and_type(flag_country_name, flag_type);
+}
+
+Error GUIMaskedFlag::set_flag_country_name(String const& flag_country_name) const {
+ ERR_FAIL_NULL_V(gfx_masked_flag_texture, FAILED);
+
+ return gfx_masked_flag_texture->set_flag_country_name(flag_country_name);
+}
+
+String GUIMaskedFlag::get_flag_country_name() const {
+ ERR_FAIL_NULL_V(gfx_masked_flag_texture, {});
+
+ return gfx_masked_flag_texture->get_flag_country_name();
+}
+
+String GUIMaskedFlag::get_flag_type() const {
+ ERR_FAIL_NULL_V(gfx_masked_flag_texture, {});
+
+ return gfx_masked_flag_texture->get_flag_type();
+}