aboutsummaryrefslogtreecommitdiff
path: root/extension/src/openvic-extension/classes/GUINode.cpp
diff options
context:
space:
mode:
author Hop311 <Hop3114@gmail.com>2024-02-19 21:35:07 +0100
committer GitHub <noreply@github.com>2024-02-19 21:35:07 +0100
commit275cfbb62fe69828aeb9968110ad822447322a4e (patch)
tree15fe433ba9259623e2cb90a0ea7ae6a5c2f364b8 /extension/src/openvic-extension/classes/GUINode.cpp
parente4de451ce753dd8786546b9e2c94c579c8dab52e (diff)
parent1455861632cd50f48f6e8ef8c50004087eff36f1 (diff)
Merge pull request #202 from OpenVicProject/nation-management-screens
Basic Nation Management Screen framework
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);