aboutsummaryrefslogtreecommitdiff
path: root/extension/src/openvic-extension/classes/GUIPieChart.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/GUIPieChart.cpp
parentd7672f406406eea46625bc725690651f28211e19 (diff)
Switch to using custom UI nodes
Diffstat (limited to 'extension/src/openvic-extension/classes/GUIPieChart.cpp')
-rw-r--r--extension/src/openvic-extension/classes/GUIPieChart.cpp66
1 files changed, 66 insertions, 0 deletions
diff --git a/extension/src/openvic-extension/classes/GUIPieChart.cpp b/extension/src/openvic-extension/classes/GUIPieChart.cpp
new file mode 100644
index 0000000..a8ed087
--- /dev/null
+++ b/extension/src/openvic-extension/classes/GUIPieChart.cpp
@@ -0,0 +1,66 @@
+#include "GUIPieChart.hpp"
+
+#include "openvic-extension/utility/ClassBindings.hpp"
+
+using namespace godot;
+using namespace OpenVic;
+using namespace OpenVic::Utilities::literals;
+
+void GUIPieChart::_bind_methods() {
+ OV_BIND_METHOD(GUIPieChart::get_gfx_pie_chart_texture);
+ OV_BIND_METHOD(GUIPieChart::set_gfx_pie_chart_name, { "gfx_pie_chart_name" });
+ OV_BIND_METHOD(GUIPieChart::get_gfx_pie_chart_name);
+ OV_BIND_METHOD(GUIPieChart::set_slices_array, { "new_slices" });
+}
+
+Error GUIPieChart::set_gfx_pie_chart(GFX::PieChart const* gfx_pie_chart) {
+ const bool needs_setting = gfx_pie_chart_texture.is_null();
+
+ if (needs_setting) {
+ gfx_pie_chart_texture.instantiate();
+ ERR_FAIL_NULL_V(gfx_pie_chart_texture, FAILED);
+ }
+
+ const Error err = gfx_pie_chart_texture->set_gfx_pie_chart(gfx_pie_chart);
+
+ if (needs_setting) {
+ set_texture(gfx_pie_chart_texture);
+ }
+
+ return err;
+}
+
+Ref<GFXPieChartTexture> GUIPieChart::get_gfx_pie_chart_texture() const {
+ ERR_FAIL_NULL_V(gfx_pie_chart_texture, nullptr);
+
+ return gfx_pie_chart_texture;
+}
+
+Error GUIPieChart::set_gfx_pie_chart_name(String const& gfx_pie_chart_name) {
+ const bool needs_setting = gfx_pie_chart_texture.is_null();
+
+ if (needs_setting) {
+ gfx_pie_chart_texture.instantiate();
+ ERR_FAIL_NULL_V(gfx_pie_chart_texture, FAILED);
+ }
+
+ const Error err = gfx_pie_chart_texture->set_gfx_pie_chart_name(gfx_pie_chart_name);
+
+ if (needs_setting) {
+ set_texture(gfx_pie_chart_texture);
+ }
+
+ return err;
+}
+
+String GUIPieChart::get_gfx_pie_chart_name() const {
+ ERR_FAIL_NULL_V(gfx_pie_chart_texture, {});
+
+ return gfx_pie_chart_texture->get_gfx_pie_chart_name();
+}
+
+Error GUIPieChart::set_slices_array(GFXPieChartTexture::godot_pie_chart_data_t const& new_slices) const {
+ ERR_FAIL_NULL_V(gfx_pie_chart_texture, FAILED);
+
+ return gfx_pie_chart_texture->set_slices_array(new_slices);
+}