aboutsummaryrefslogtreecommitdiff
path: root/extension/src/openvic-extension/classes
diff options
context:
space:
mode:
Diffstat (limited to 'extension/src/openvic-extension/classes')
-rw-r--r--extension/src/openvic-extension/classes/GFXIconTexture.cpp2
-rw-r--r--extension/src/openvic-extension/classes/GFXPieChartTexture.cpp6
-rw-r--r--extension/src/openvic-extension/classes/GUINode.cpp26
-rw-r--r--extension/src/openvic-extension/classes/GUINode.hpp6
4 files changed, 21 insertions, 19 deletions
diff --git a/extension/src/openvic-extension/classes/GFXIconTexture.cpp b/extension/src/openvic-extension/classes/GFXIconTexture.cpp
index 5d29c07..99df7e4 100644
--- a/extension/src/openvic-extension/classes/GFXIconTexture.cpp
+++ b/extension/src/openvic-extension/classes/GFXIconTexture.cpp
@@ -3,7 +3,6 @@
#include <godot_cpp/variant/utility_functions.hpp>
#include "openvic-extension/singletons/AssetManager.hpp"
-#include "openvic-extension/singletons/GameSingleton.hpp"
#include "openvic-extension/utility/ClassBindings.hpp"
#include "openvic-extension/utility/UITools.hpp"
#include "openvic-extension/utility/Utilities.hpp"
@@ -11,7 +10,6 @@
using namespace godot;
using namespace OpenVic;
-using OpenVic::Utilities::godot_to_std_string;
using OpenVic::Utilities::std_view_to_godot_string;
using OpenVic::Utilities::std_view_to_godot_string_name;
diff --git a/extension/src/openvic-extension/classes/GFXPieChartTexture.cpp b/extension/src/openvic-extension/classes/GFXPieChartTexture.cpp
index c9a2a72..f4c7851 100644
--- a/extension/src/openvic-extension/classes/GFXPieChartTexture.cpp
+++ b/extension/src/openvic-extension/classes/GFXPieChartTexture.cpp
@@ -1,16 +1,14 @@
#include "GFXPieChartTexture.hpp"
-#include "openvic-extension/singletons/AssetManager.hpp"
-#include "openvic-extension/singletons/GameSingleton.hpp"
+#include <numbers>
+
#include "openvic-extension/utility/ClassBindings.hpp"
#include "openvic-extension/utility/UITools.hpp"
using namespace godot;
using namespace OpenVic;
-using OpenVic::Utilities::godot_to_std_string;
using OpenVic::Utilities::std_view_to_godot_string;
-using OpenVic::Utilities::std_view_to_godot_string_name;
StringName const& GFXPieChartTexture::_slice_identifier_key() {
static StringName const slice_identifier_key = "identifier";
diff --git a/extension/src/openvic-extension/classes/GUINode.cpp b/extension/src/openvic-extension/classes/GUINode.cpp
index 89701e0..f95e3cd 100644
--- a/extension/src/openvic-extension/classes/GUINode.cpp
+++ b/extension/src/openvic-extension/classes/GUINode.cpp
@@ -10,9 +10,6 @@
using namespace godot;
using namespace OpenVic;
-using OpenVic::Utilities::godot_to_std_string;
-using OpenVic::Utilities::std_view_to_godot_string;
-
#define APPLY_TO_CHILD_TYPES(F) \
F(Button, button) \
F(CheckBox, check_box) \
@@ -28,8 +25,9 @@ using OpenVic::Utilities::std_view_to_godot_string;
F(GFXPieChartTexture, gfx_pie_chart_texture)
void GUINode::_bind_methods() {
- OV_BIND_SMETHOD(generate_gui_element, { "gui_file", "gui_element", "name" }, DEFVAL(String {}));
- OV_BIND_METHOD(GUINode::add_gui_element, { "gui_file", "gui_element", "name" }, DEFVAL(String {}));
+ OV_BIND_SMETHOD(generate_gui_element, { "gui_scene", "gui_element", "name" }, DEFVAL(String {}));
+ OV_BIND_METHOD(GUINode::add_gui_element, { "gui_scene", "gui_element", "name" }, DEFVAL(String {}));
+ OV_BIND_SMETHOD(get_gui_position, { "gui_scene", "gui_position" });
#define GET_BINDINGS(type, name) \
OV_BIND_SMETHOD(get_##name##_from_node, { "node" }); \
@@ -55,19 +53,19 @@ GUINode::GUINode() {
set_mouse_filter(MOUSE_FILTER_IGNORE);
}
-Control* GUINode::generate_gui_element(String const& gui_file, String const& gui_element, String const& name) {
+Control* GUINode::generate_gui_element(String const& gui_scene, String const& gui_element, String const& name) {
Control* result = nullptr;
- if (!UITools::generate_gui_element(gui_file, gui_element, name, result)) {
- UtilityFunctions::push_error("Error generating GUI element ", gui_element, " from GUI file ", gui_file);
+ if (!UITools::generate_gui_element(gui_scene, gui_element, name, result)) {
+ UtilityFunctions::push_error("Error generating GUI element ", gui_element, " from GUI scene ", gui_scene);
}
return result;
}
-Error GUINode::add_gui_element(String const& gui_file, String const& gui_element, String const& name) {
+Error GUINode::add_gui_element(String const& gui_scene, String const& gui_element, String const& name) {
Error err = OK;
Control* result = nullptr;
- if (!UITools::generate_gui_element(gui_file, gui_element, name, result)) {
- UtilityFunctions::push_error("Error generating GUI element ", gui_element, " from GUI file ", gui_file);
+ if (!UITools::generate_gui_element(gui_scene, gui_element, name, result)) {
+ UtilityFunctions::push_error("Error generating GUI element ", gui_element, " from GUI scene ", gui_scene);
err = FAILED;
}
if (result != nullptr) {
@@ -76,6 +74,12 @@ Error GUINode::add_gui_element(String const& gui_file, String const& gui_element
return err;
}
+Vector2 GUINode::get_gui_position(String const& gui_scene, String const& gui_position) {
+ GUI::Position const* position = UITools::get_gui_position(gui_scene, gui_position);
+ ERR_FAIL_NULL_V(position, {});
+ return Utilities::to_godot_fvec2(position->get_position());
+}
+
template<std::derived_from<godot::Node> T>
static T* _cast_node(Node* node) {
ERR_FAIL_NULL_V(node, nullptr);
diff --git a/extension/src/openvic-extension/classes/GUINode.hpp b/extension/src/openvic-extension/classes/GUINode.hpp
index e38ed1f..0fbfc66 100644
--- a/extension/src/openvic-extension/classes/GUINode.hpp
+++ b/extension/src/openvic-extension/classes/GUINode.hpp
@@ -25,13 +25,15 @@ namespace OpenVic {
GUINode();
static godot::Control* generate_gui_element(
- godot::String const& gui_file, godot::String const& gui_element, godot::String const& name = ""
+ godot::String const& gui_scene, godot::String const& gui_element, godot::String const& name = ""
);
godot::Error add_gui_element(
- godot::String const& gui_file, godot::String const& gui_element, godot::String const& name = ""
+ godot::String const& gui_scene, godot::String const& gui_element, godot::String const& name = ""
);
+ static godot::Vector2 get_gui_position(godot::String const& gui_scene, godot::String const& gui_position);
+
static godot::Button* get_button_from_node(godot::Node* node);
static godot::CheckBox* get_check_box_from_node(godot::Node* node);
static godot::Label* get_label_from_node(godot::Node* node);