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/GUIListBox.cpp5
-rw-r--r--extension/src/openvic-extension/classes/GUINode.cpp34
-rw-r--r--extension/src/openvic-extension/classes/GUINode.hpp3
-rw-r--r--extension/src/openvic-extension/classes/GUIOverlappingElementsBox.cpp4
-rw-r--r--extension/src/openvic-extension/classes/MapMesh.cpp2
5 files changed, 44 insertions, 4 deletions
diff --git a/extension/src/openvic-extension/classes/GUIListBox.cpp b/extension/src/openvic-extension/classes/GUIListBox.cpp
index d04ab59..c153870 100644
--- a/extension/src/openvic-extension/classes/GUIListBox.cpp
+++ b/extension/src/openvic-extension/classes/GUIListBox.cpp
@@ -182,6 +182,7 @@ void GUIListBox::clear() {
clear_children();
if (scrollbar != nullptr) {
remove_child(scrollbar);
+ scrollbar->queue_free();
scrollbar = nullptr;
}
}
@@ -192,7 +193,9 @@ void GUIListBox::clear_children(int32_t remaining_child_count) {
int32_t child_index = get_child_count();
while (child_index > remaining_child_count) {
- remove_child(get_child(--child_index));
+ Node* child = get_child(--child_index);
+ remove_child(child);
+ child->queue_free();
}
if (scrollbar != nullptr) {
diff --git a/extension/src/openvic-extension/classes/GUINode.cpp b/extension/src/openvic-extension/classes/GUINode.cpp
index 674f162..d8ab6c1 100644
--- a/extension/src/openvic-extension/classes/GUINode.cpp
+++ b/extension/src/openvic-extension/classes/GUINode.cpp
@@ -83,6 +83,9 @@ void GUINode::_bind_methods() {
OV_BIND_METHOD(GUINode::hide_node, { "path" });
OV_BIND_METHOD(GUINode::hide_nodes, { "paths" });
+ OV_BIND_METHOD(GUINode::remove_node, { "path" });
+ OV_BIND_METHOD(GUINode::remove_nodes, { "paths" });
+
OV_BIND_SMETHOD(int_to_string_suffixed, { "val" });
OV_BIND_SMETHOD(float_to_string_suffixed, { "val" });
OV_BIND_SMETHOD(float_to_string_dp, { "val", "decimal_places" });
@@ -207,17 +210,46 @@ APPLY_TO_TEXTURE_TYPES(TEXTURE_GET_FUNCTIONS)
Error GUINode::hide_node(NodePath const& path) const {
CanvasItem* node = _cast_node<CanvasItem>(get_node_internal(path));
ERR_FAIL_NULL_V(node, FAILED);
+
node->hide();
+
return OK;
}
Error GUINode::hide_nodes(TypedArray<NodePath> const& paths) const {
Error ret = OK;
+
for (int32_t i = 0; i < paths.size(); ++i) {
if (hide_node(paths[i]) != OK) {
ret = FAILED;
}
}
+
+ return ret;
+}
+
+Error GUINode::remove_node(NodePath const& path) const {
+ Node* node = get_node_internal(path);
+ ERR_FAIL_NULL_V(node, FAILED);
+
+ Node* parent = node->get_parent();
+ ERR_FAIL_NULL_V(parent, FAILED);
+
+ parent->remove_child(node);
+ node->queue_free();
+
+ return OK;
+}
+
+Error GUINode::remove_nodes(TypedArray<NodePath> const& paths) const {
+ Error ret = OK;
+
+ for (int32_t i = 0; i < paths.size(); ++i) {
+ if (remove_node(paths[i]) != OK) {
+ ret = FAILED;
+ }
+ }
+
return ret;
}
@@ -331,7 +363,7 @@ void GUINode::set_click_mask_from_nodepaths(TypedArray<NodePath> const& paths) {
update_click_mask();
}
-bool GUINode::_has_point(godot::Vector2 const& p_point) const {
+bool GUINode::_has_point(Vector2 const& p_point) const {
if (!_click_mask.is_valid()) {
return Control::_has_point(p_point);
}
diff --git a/extension/src/openvic-extension/classes/GUINode.hpp b/extension/src/openvic-extension/classes/GUINode.hpp
index af1562e..27ce780 100644
--- a/extension/src/openvic-extension/classes/GUINode.hpp
+++ b/extension/src/openvic-extension/classes/GUINode.hpp
@@ -82,6 +82,9 @@ namespace OpenVic {
godot::Error hide_node(godot::NodePath const& path) const;
godot::Error hide_nodes(godot::TypedArray<godot::NodePath> const& paths) const;
+ godot::Error remove_node(godot::NodePath const& path) const;
+ godot::Error remove_nodes(godot::TypedArray<godot::NodePath> const& paths) const;
+
static godot::String int_to_string_suffixed(int64_t val);
static godot::String float_to_string_suffixed(float val);
static godot::String float_to_string_dp(float val, int32_t decimal_places);
diff --git a/extension/src/openvic-extension/classes/GUIOverlappingElementsBox.cpp b/extension/src/openvic-extension/classes/GUIOverlappingElementsBox.cpp
index 921f633..fe1f941 100644
--- a/extension/src/openvic-extension/classes/GUIOverlappingElementsBox.cpp
+++ b/extension/src/openvic-extension/classes/GUIOverlappingElementsBox.cpp
@@ -96,7 +96,9 @@ Error GUIOverlappingElementsBox::set_child_count(int32_t new_count) {
return OK;
} else if (child_count > new_count) {
do {
- remove_child(get_child(--child_count));
+ Node* child = get_child(--child_count);
+ remove_child(child);
+ child->queue_free();
} while (child_count > new_count);
return OK;
} else {
diff --git a/extension/src/openvic-extension/classes/MapMesh.cpp b/extension/src/openvic-extension/classes/MapMesh.cpp
index ba1b19f..d968f34 100644
--- a/extension/src/openvic-extension/classes/MapMesh.cpp
+++ b/extension/src/openvic-extension/classes/MapMesh.cpp
@@ -86,7 +86,7 @@ AABB MapMesh::get_core_aabb() const {
return AABB { size * -0.5f, size };
}
-bool MapMesh::is_valid_uv_coord(godot::Vector2 const& uv) const {
+bool MapMesh::is_valid_uv_coord(Vector2 const& uv) const {
return 0.0f <= uv.y && uv.y <= 1.0f;
}