From 1455861632cd50f48f6e8ef8c50004087eff36f1 Mon Sep 17 00:00:00 2001 From: hop311 Date: Fri, 2 Feb 2024 20:19:21 +0000 Subject: Basic Nation Management Screen framework --- .../src/openvic-extension/classes/GUINode.cpp | 26 +++++++++++++--------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'extension/src/openvic-extension/classes/GUINode.cpp') 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 T> static T* _cast_node(Node* node) { ERR_FAIL_NULL_V(node, nullptr); -- cgit v1.2.3-56-ga3b1