summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/io/marshalls.cpp10
-rw-r--r--doc/classes/EncodedObjectAsID.xml22
-rw-r--r--doc/classes/Object.xml1
-rw-r--r--editor/editor_help_search.cpp6
-rw-r--r--modules/gridmap/grid_map_editor_plugin.cpp4
-rw-r--r--scene/gui/popup.cpp17
-rw-r--r--scene/gui/popup.h3
7 files changed, 39 insertions, 24 deletions
diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp
index 7494603462..3c9c5bc2bb 100644
--- a/core/io/marshalls.cpp
+++ b/core/io/marshalls.cpp
@@ -37,13 +37,11 @@
#include <limits.h>
#include <stdio.h>
-#define _S(a) ((int32_t)a)
-#define ERR_FAIL_ADD_OF(a, b, err) ERR_FAIL_COND_V(_S(b) < 0 || _S(a) < 0 || _S(a) > INT_MAX - _S(b), err)
-#define ERR_FAIL_MUL_OF(a, b, err) ERR_FAIL_COND_V(_S(a) < 0 || _S(b) <= 0 || _S(a) > INT_MAX / _S(b), err)
-
void EncodedObjectAsID::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_object_id", "id"), &EncodedObjectAsID::set_object_id);
ClassDB::bind_method(D_METHOD("get_object_id"), &EncodedObjectAsID::get_object_id);
+
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "object_id"), "set_object_id", "get_object_id");
}
void EncodedObjectAsID::set_object_id(ObjectID p_id) {
@@ -59,6 +57,10 @@ EncodedObjectAsID::EncodedObjectAsID() :
id(0) {
}
+#define _S(a) ((int32_t)a)
+#define ERR_FAIL_ADD_OF(a, b, err) ERR_FAIL_COND_V(_S(b) < 0 || _S(a) < 0 || _S(a) > INT_MAX - _S(b), err)
+#define ERR_FAIL_MUL_OF(a, b, err) ERR_FAIL_COND_V(_S(a) < 0 || _S(b) <= 0 || _S(a) > INT_MAX / _S(b), err)
+
#define ENCODE_MASK 0xFF
#define ENCODE_FLAG_64 1 << 16
#define ENCODE_FLAG_OBJECT_AS_ID 1 << 16
diff --git a/doc/classes/EncodedObjectAsID.xml b/doc/classes/EncodedObjectAsID.xml
index 1822f6c199..6efdda48ef 100644
--- a/doc/classes/EncodedObjectAsID.xml
+++ b/doc/classes/EncodedObjectAsID.xml
@@ -1,27 +1,21 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="EncodedObjectAsID" inherits="Reference" category="Core" version="3.2">
<brief_description>
+ Holds a reference to an [Object]'s instance ID.
</brief_description>
<description>
+ Utility class which holds a reference to the internal identifier of an [Object] instance, as given by [method Object.get_instance_id]. This ID can then be used to retrieve the object instance with [method @GDScript.instance_from_id].
+ This class is used internally by the editor inspector and script debugger, but can also be used in plugins to pass and display objects as their IDs.
</description>
<tutorials>
</tutorials>
<methods>
- <method name="get_object_id" qualifiers="const">
- <return type="int">
- </return>
- <description>
- </description>
- </method>
- <method name="set_object_id">
- <return type="void">
- </return>
- <argument index="0" name="id" type="int">
- </argument>
- <description>
- </description>
- </method>
</methods>
+ <members>
+ <member name="object_id" type="int" setter="set_object_id" getter="get_object_id">
+ The [Object] identifier stored in this [EncodedObjectAsID] instance. The object instance can be retrieved with [method @GDScript.instance_from_id].
+ </member>
+ </members>
<constants>
</constants>
</class>
diff --git a/doc/classes/Object.xml b/doc/classes/Object.xml
index 548a0c18bb..a1fba1ac8d 100644
--- a/doc/classes/Object.xml
+++ b/doc/classes/Object.xml
@@ -203,6 +203,7 @@
</return>
<description>
Returns the object's unique instance ID.
+ This ID can be saved in [EncodedObjectAsID], and can be used to retrieve the object instance with [method @GDScript.instance_from_id].
</description>
</method>
<method name="get_meta" qualifiers="const">
diff --git a/editor/editor_help_search.cpp b/editor/editor_help_search.cpp
index 55ab38ba6c..4ec24c76f2 100644
--- a/editor/editor_help_search.cpp
+++ b/editor/editor_help_search.cpp
@@ -260,7 +260,11 @@ bool EditorHelpSearch::Runner::_is_class_disabled_by_feature_profile(const Strin
StringName class_name = p_class;
while (class_name != StringName()) {
- if (!ClassDB::class_exists(class_name) || profile->is_class_disabled(class_name)) {
+ if (!ClassDB::class_exists(class_name)) {
+ return false;
+ }
+
+ if (profile->is_class_disabled(class_name)) {
return true;
}
class_name = ClassDB::get_parent_class(class_name);
diff --git a/modules/gridmap/grid_map_editor_plugin.cpp b/modules/gridmap/grid_map_editor_plugin.cpp
index 6b9a97efb4..03619aa0bd 100644
--- a/modules/gridmap/grid_map_editor_plugin.cpp
+++ b/modules/gridmap/grid_map_editor_plugin.cpp
@@ -279,7 +279,7 @@ void GridMapEditor::_update_cursor_transform() {
cursor_transform = Transform();
cursor_transform.origin = cursor_origin;
cursor_transform.basis.set_orthogonal_index(cursor_rot);
- cursor_transform = node->get_transform() * cursor_transform;
+ cursor_transform = node->get_global_transform() * cursor_transform;
if (cursor_instance.is_valid()) {
VisualServer::get_singleton()->instance_set_transform(cursor_instance, cursor_transform);
@@ -420,7 +420,7 @@ bool GridMapEditor::do_input_action(Camera *p_camera, const Point2 &p_point, boo
}
last_mouseover = Vector3(cell[0], cell[1], cell[2]);
- VS::get_singleton()->instance_set_transform(grid_instance[edit_axis], Transform(Basis(), grid_ofs));
+ VS::get_singleton()->instance_set_transform(grid_instance[edit_axis], node->get_global_transform() * edit_grid_xform);
if (cursor_instance.is_valid()) {
diff --git a/scene/gui/popup.cpp b/scene/gui/popup.cpp
index fdb1b65f77..492e379440 100644
--- a/scene/gui/popup.cpp
+++ b/scene/gui/popup.cpp
@@ -141,7 +141,7 @@ void Popup::popup_centered(const Size2 &p_size) {
rect.size = p_size == Size2() ? get_size() : p_size;
rect.position = ((window_size - rect.size) / 2.0).floor();
- popup(rect);
+ _popup(rect, true);
}
void Popup::popup_centered_ratio(float p_screen_ratio) {
@@ -151,18 +151,29 @@ void Popup::popup_centered_ratio(float p_screen_ratio) {
rect.size = (window_size * p_screen_ratio).floor();
rect.position = ((window_size - rect.size) / 2.0).floor();
- popup(rect);
+ _popup(rect, true);
}
void Popup::popup(const Rect2 &p_bounds) {
+ _popup(p_bounds);
+}
+
+void Popup::_popup(const Rect2 &p_bounds, const bool p_centered) {
+
emit_signal("about_to_show");
show_modal(exclusive);
// Fit the popup into the optionally provided bounds.
if (!p_bounds.has_no_area()) {
- set_position(p_bounds.position);
set_size(p_bounds.size);
+
+ // check if p_bounds.size was using an outdated cached values
+ if (p_centered && p_bounds.size != get_size()) {
+ set_position(p_bounds.position - ((get_size() - p_bounds.size) / 2.0).floor());
+ } else {
+ set_position(p_bounds.position);
+ }
}
_fix_size();
diff --git a/scene/gui/popup.h b/scene/gui/popup.h
index 6615c51ec5..d6d96dfe64 100644
--- a/scene/gui/popup.h
+++ b/scene/gui/popup.h
@@ -43,6 +43,9 @@ class Popup : public Control {
bool exclusive;
bool popped_up;
+private:
+ void _popup(const Rect2 &p_bounds = Rect2(), const bool p_centered = false);
+
protected:
virtual void _post_popup() {}