aboutsummaryrefslogtreecommitdiff
path: root/extension/src/openvic-extension/classes/GUIMaskedFlagButton.cpp
diff options
context:
space:
mode:
author Hop311 <Hop3114@gmail.com>2024-08-30 23:30:12 +0200
committer GitHub <noreply@github.com>2024-08-30 23:30:12 +0200
commit2e0bc5b556b9c6df46a8cdd48d3f109e0ac76b63 (patch)
tree2c521b99fe6cd0a7fd5d6a29e55645b3415792b3 /extension/src/openvic-extension/classes/GUIMaskedFlagButton.cpp
parentf54e454afb90f8868e7c62529e2a388fdaadf20b (diff)
parentbdc2ba527bc02e7cdf977f6040f2ca85aa4f9a94 (diff)
Merge pull request #253 from OpenVicProject/tooltip
Tooltips
Diffstat (limited to 'extension/src/openvic-extension/classes/GUIMaskedFlagButton.cpp')
-rw-r--r--extension/src/openvic-extension/classes/GUIMaskedFlagButton.cpp88
1 files changed, 88 insertions, 0 deletions
diff --git a/extension/src/openvic-extension/classes/GUIMaskedFlagButton.cpp b/extension/src/openvic-extension/classes/GUIMaskedFlagButton.cpp
new file mode 100644
index 0000000..8c3c1f8
--- /dev/null
+++ b/extension/src/openvic-extension/classes/GUIMaskedFlagButton.cpp
@@ -0,0 +1,88 @@
+#include "GUIMaskedFlagButton.hpp"
+
+#include "openvic-extension/utility/ClassBindings.hpp"
+
+using namespace godot;
+using namespace OpenVic;
+
+void GUIMaskedFlagButton::_bind_methods() {
+ OV_BIND_METHOD(GUIMaskedFlagButton::get_gfx_masked_flag_texture);
+
+ OV_BIND_METHOD(GUIMaskedFlagButton::set_gfx_masked_flag_name, { "gfx_masked_flag_name" });
+ OV_BIND_METHOD(GUIMaskedFlagButton::get_gfx_masked_flag_name);
+
+ OV_BIND_METHOD(GUIMaskedFlagButton::set_flag_country_name_and_type, { "flag_country_name", "flag_type" });
+ OV_BIND_METHOD(GUIMaskedFlagButton::set_flag_country_name, { "flag_country_name" });
+ OV_BIND_METHOD(GUIMaskedFlagButton::get_flag_country_name);
+ OV_BIND_METHOD(GUIMaskedFlagButton::get_flag_type);
+}
+
+Error GUIMaskedFlagButton::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);
+ }
+
+ Error err = gfx_masked_flag_texture->set_gfx_masked_flag(gfx_masked_flag);
+
+ if (needs_setting && set_gfx_button_state_having_texture(gfx_masked_flag_texture) != OK) {
+ err = FAILED;
+ }
+
+ return err;
+}
+
+Ref<GFXMaskedFlagTexture> GUIMaskedFlagButton::get_gfx_masked_flag_texture() const {
+ ERR_FAIL_NULL_V(gfx_masked_flag_texture, nullptr);
+
+ return gfx_masked_flag_texture;
+}
+
+Error GUIMaskedFlagButton::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);
+ }
+
+ Error err = gfx_masked_flag_texture->set_gfx_masked_flag_name(gfx_masked_flag_name);
+
+ if (needs_setting && set_gfx_button_state_having_texture(gfx_masked_flag_texture) != OK) {
+ err = FAILED;
+ }
+
+ return err;
+}
+
+String GUIMaskedFlagButton::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 GUIMaskedFlagButton::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 GUIMaskedFlagButton::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 GUIMaskedFlagButton::get_flag_country_name() const {
+ ERR_FAIL_NULL_V(gfx_masked_flag_texture, {});
+
+ return gfx_masked_flag_texture->get_flag_country_name();
+}
+
+String GUIMaskedFlagButton::get_flag_type() const {
+ ERR_FAIL_NULL_V(gfx_masked_flag_texture, {});
+
+ return gfx_masked_flag_texture->get_flag_type();
+}