aboutsummaryrefslogtreecommitdiff
path: root/extension/src/openvic-extension/classes/GUINode.cpp
diff options
context:
space:
mode:
author hop311 <hop3114@gmail.com>2024-02-02 21:19:21 +0100
committer hop311 <hop3114@gmail.com>2024-02-19 20:17:31 +0100
commit1455861632cd50f48f6e8ef8c50004087eff36f1 (patch)
tree5ce200d70f5f12d76dfd489ed06a6bb88204fd1c /extension/src/openvic-extension/classes/GUINode.cpp
parent576986af57db806af284bbc05a799e72f113f35c (diff)
Basic Nation Management Screen frameworknation-management-screens
Diffstat (limited to 'extension/src/openvic-extension/classes/GUINode.cpp')
-rw-r--r--extension/src/openvic-extension/classes/GUINode.cpp26
1 files changed, 15 insertions, 11 deletions
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);