summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/classes/AcceptDialog.xml11
-rw-r--r--editor/plugins/node_3d_editor_plugin.cpp6
-rw-r--r--scene/gui/dialogs.cpp23
-rw-r--r--scene/gui/dialogs.h1
-rw-r--r--servers/physics_3d/collision_solver_3d_sat.cpp40
5 files changed, 58 insertions, 23 deletions
diff --git a/doc/classes/AcceptDialog.xml b/doc/classes/AcceptDialog.xml
index f644606040..fd1e2ba104 100644
--- a/doc/classes/AcceptDialog.xml
+++ b/doc/classes/AcceptDialog.xml
@@ -21,6 +21,7 @@
<description>
Adds a button with label [code]text[/code] and a custom [code]action[/code] to the dialog and returns the created button. [code]action[/code] will be passed to the [signal custom_action] signal when pressed.
If [code]true[/code], [code]right[/code] will place the button to the right of any sibling buttons.
+ You can use [method remove_button] method to remove a button created with this method from the dialog.
</description>
</method>
<method name="add_cancel_button">
@@ -30,6 +31,7 @@
</argument>
<description>
Adds a button with label [code]name[/code] and a cancel action to the dialog and returns the created button.
+ You can use [method remove_button] method to remove a button created with this method from the dialog.
</description>
</method>
<method name="get_label">
@@ -55,6 +57,15 @@
Registers a [LineEdit] in the dialog. When the enter key is pressed, the dialog will be accepted.
</description>
</method>
+ <method name="remove_button">
+ <return type="void">
+ </return>
+ <argument index="0" name="button" type="Control">
+ </argument>
+ <description>
+ Removes the [code]button[/code] from the dialog. Does NOT free the [code]button[/code]. The [code]button[/code] must be a [Button] added with [method add_button] or [method add_cancel_button] method. After removal, pressing the [code]button[/code] will no longer emit this dialog's [signal custom_action] or [signal cancelled] signals.
+ </description>
+ </method>
</methods>
<members>
<member name="dialog_autowrap" type="bool" setter="set_autowrap" getter="has_autowrap" default="false">
diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp
index 1d0bde0ad7..a7177faafa 100644
--- a/editor/plugins/node_3d_editor_plugin.cpp
+++ b/editor/plugins/node_3d_editor_plugin.cpp
@@ -2511,15 +2511,15 @@ void Node3DEditorViewport::_notification(int p_what) {
}
if (show_info) {
+ const String viewport_size = vformat(String::utf8("%d × %d"), viewport->get_size().x, viewport->get_size().y);
String text;
text += vformat(TTR("X: %s\n"), rtos(current_camera->get_position().x).pad_decimals(1));
text += vformat(TTR("Y: %s\n"), rtos(current_camera->get_position().y).pad_decimals(1));
text += vformat(TTR("Z: %s\n"), rtos(current_camera->get_position().z).pad_decimals(1));
text += "\n";
text += vformat(
- TTR("Size: %dx%d (%.1fMP)\n"),
- viewport->get_size().x,
- viewport->get_size().y,
+ TTR("Size: %s (%.1fMP)\n"),
+ viewport_size,
viewport->get_size().x * viewport->get_size().y * 0.000001);
text += "\n";
diff --git a/scene/gui/dialogs.cpp b/scene/gui/dialogs.cpp
index f63ae7569f..dceab00607 100644
--- a/scene/gui/dialogs.cpp
+++ b/scene/gui/dialogs.cpp
@@ -263,6 +263,28 @@ Button *AcceptDialog::add_cancel_button(const String &p_cancel) {
return b;
}
+void AcceptDialog::remove_button(Control *p_button) {
+ Button *button = Object::cast_to<Button>(p_button);
+ ERR_FAIL_NULL(button);
+ ERR_FAIL_COND_MSG(button->get_parent() != hbc, vformat("Cannot remove button %s as it does not belong to this dialog.", button->get_name()));
+ ERR_FAIL_COND_MSG(button == ok, "Cannot remove dialog's OK button.");
+
+ Node *right_spacer = hbc->get_child(button->get_index() + 1);
+ // Should always be valid but let's avoid crashing
+ if (right_spacer) {
+ hbc->remove_child(right_spacer);
+ memdelete(right_spacer);
+ }
+ hbc->remove_child(button);
+
+ if (button->is_connected("pressed", callable_mp(this, &AcceptDialog::_custom_action))) {
+ button->disconnect("pressed", callable_mp(this, &AcceptDialog::_custom_action));
+ }
+ if (button->is_connected("pressed", callable_mp(this, &AcceptDialog::_cancel_pressed))) {
+ button->disconnect("pressed", callable_mp(this, &AcceptDialog::_cancel_pressed));
+ }
+}
+
void AcceptDialog::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_ok_button"), &AcceptDialog::get_ok_button);
ClassDB::bind_method(D_METHOD("get_label"), &AcceptDialog::get_label);
@@ -270,6 +292,7 @@ void AcceptDialog::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_hide_on_ok"), &AcceptDialog::get_hide_on_ok);
ClassDB::bind_method(D_METHOD("add_button", "text", "right", "action"), &AcceptDialog::add_button, DEFVAL(false), DEFVAL(""));
ClassDB::bind_method(D_METHOD("add_cancel_button", "name"), &AcceptDialog::add_cancel_button);
+ ClassDB::bind_method(D_METHOD("remove_button", "button"), &AcceptDialog::remove_button);
ClassDB::bind_method(D_METHOD("register_text_enter", "line_edit"), &AcceptDialog::register_text_enter);
ClassDB::bind_method(D_METHOD("set_text", "text"), &AcceptDialog::set_text);
ClassDB::bind_method(D_METHOD("get_text"), &AcceptDialog::get_text);
diff --git a/scene/gui/dialogs.h b/scene/gui/dialogs.h
index d389806fff..8e803a2a7c 100644
--- a/scene/gui/dialogs.h
+++ b/scene/gui/dialogs.h
@@ -82,6 +82,7 @@ public:
Button *get_ok_button() { return ok; }
Button *add_button(const String &p_text, bool p_right = false, const String &p_action = "");
Button *add_cancel_button(const String &p_cancel = "");
+ void remove_button(Control *p_button);
void set_hide_on_ok(bool p_hide);
bool get_hide_on_ok() const;
diff --git a/servers/physics_3d/collision_solver_3d_sat.cpp b/servers/physics_3d/collision_solver_3d_sat.cpp
index b362f1ff17..1cfb9ba3ad 100644
--- a/servers/physics_3d/collision_solver_3d_sat.cpp
+++ b/servers/physics_3d/collision_solver_3d_sat.cpp
@@ -1024,7 +1024,7 @@ static void _collision_sphere_face(const Shape3DSW *p_a, const Transform3D &p_tr
n1 *= -1.0;
}
- if (!separator.test_axis(n1.normalized(), !face_B->backface_collision)) {
+ if (!separator.test_axis(n1.normalized())) {
return;
}
@@ -1035,7 +1035,7 @@ static void _collision_sphere_face(const Shape3DSW *p_a, const Transform3D &p_tr
axis *= -1.0;
}
- if (!separator.test_axis(axis, !face_B->backface_collision)) {
+ if (!separator.test_axis(axis)) {
return;
}
}
@@ -1493,7 +1493,7 @@ static void _collision_box_face(const Shape3DSW *p_a, const Transform3D &p_trans
axis *= -1.0;
}
- if (!separator.test_axis(axis, !face_B->backface_collision)) {
+ if (!separator.test_axis(axis)) {
return;
}
}
@@ -1509,7 +1509,7 @@ static void _collision_box_face(const Shape3DSW *p_a, const Transform3D &p_trans
axis *= -1.0;
}
- if (!separator.test_axis(axis, !face_B->backface_collision)) {
+ if (!separator.test_axis(axis)) {
return;
}
}
@@ -1533,7 +1533,7 @@ static void _collision_box_face(const Shape3DSW *p_a, const Transform3D &p_trans
axis_ab *= -1.0;
}
- if (!separator.test_axis(axis_ab.normalized(), !face_B->backface_collision)) {
+ if (!separator.test_axis(axis_ab.normalized())) {
return;
}
@@ -1548,7 +1548,7 @@ static void _collision_box_face(const Shape3DSW *p_a, const Transform3D &p_trans
axis *= -1.0;
}
- if (!separator.test_axis(axis, !face_B->backface_collision)) {
+ if (!separator.test_axis(axis)) {
return;
}
}
@@ -1578,7 +1578,7 @@ static void _collision_box_face(const Shape3DSW *p_a, const Transform3D &p_trans
axis *= -1.0;
}
- if (!separator.test_axis(axis, !face_B->backface_collision)) {
+ if (!separator.test_axis(axis)) {
return;
}
}
@@ -1812,7 +1812,7 @@ static void _collision_capsule_face(const Shape3DSW *p_a, const Transform3D &p_t
axis *= -1.0;
}
- if (!separator.test_axis(axis, !face_B->backface_collision)) {
+ if (!separator.test_axis(axis)) {
return;
}
@@ -1821,7 +1821,7 @@ static void _collision_capsule_face(const Shape3DSW *p_a, const Transform3D &p_t
dir_axis *= -1.0;
}
- if (!separator.test_axis(dir_axis, !face_B->backface_collision)) {
+ if (!separator.test_axis(dir_axis)) {
return;
}
@@ -1834,7 +1834,7 @@ static void _collision_capsule_face(const Shape3DSW *p_a, const Transform3D &p_t
n1 *= -1.0;
}
- if (!separator.test_axis(n1.normalized(), !face_B->backface_collision)) {
+ if (!separator.test_axis(n1.normalized())) {
return;
}
@@ -1845,7 +1845,7 @@ static void _collision_capsule_face(const Shape3DSW *p_a, const Transform3D &p_t
axis *= -1.0;
}
- if (!separator.test_axis(axis.normalized(), !face_B->backface_collision)) {
+ if (!separator.test_axis(axis.normalized())) {
return;
}
}
@@ -1955,7 +1955,7 @@ static void _collision_cylinder_face(const Shape3DSW *p_a, const Transform3D &p_
}
// Cylinder end caps.
- if (!separator.test_axis(cyl_axis, !face_B->backface_collision)) {
+ if (!separator.test_axis(cyl_axis)) {
return;
}
@@ -1971,7 +1971,7 @@ static void _collision_cylinder_face(const Shape3DSW *p_a, const Transform3D &p_
axis *= -1.0;
}
- if (!separator.test_axis(axis.normalized(), !face_B->backface_collision)) {
+ if (!separator.test_axis(axis.normalized())) {
return;
}
}
@@ -1984,7 +1984,7 @@ static void _collision_cylinder_face(const Shape3DSW *p_a, const Transform3D &p_
axis *= -1.0;
}
- if (!separator.test_axis(axis, !face_B->backface_collision)) {
+ if (!separator.test_axis(axis)) {
return;
}
}
@@ -2021,7 +2021,7 @@ static void _collision_cylinder_face(const Shape3DSW *p_a, const Transform3D &p_
axis *= -1.0;
}
- if (!separator.test_axis(axis.normalized(), !face_B->backface_collision)) {
+ if (!separator.test_axis(axis.normalized())) {
return;
}
}
@@ -2175,7 +2175,7 @@ static void _collision_convex_polygon_face(const Shape3DSW *p_a, const Transform
axis *= -1.0;
}
- if (!separator.test_axis(axis, !face_B->backface_collision)) {
+ if (!separator.test_axis(axis)) {
return;
}
}
@@ -2192,7 +2192,7 @@ static void _collision_convex_polygon_face(const Shape3DSW *p_a, const Transform
axis *= -1.0;
}
- if (!separator.test_axis(axis, !face_B->backface_collision)) {
+ if (!separator.test_axis(axis)) {
return;
}
}
@@ -2209,7 +2209,7 @@ static void _collision_convex_polygon_face(const Shape3DSW *p_a, const Transform
axis *= -1.0;
}
- if (!separator.test_axis(axis, !face_B->backface_collision)) {
+ if (!separator.test_axis(axis)) {
return;
}
}
@@ -2229,7 +2229,7 @@ static void _collision_convex_polygon_face(const Shape3DSW *p_a, const Transform
axis *= -1.0;
}
- if (!separator.test_axis(axis, !face_B->backface_collision)) {
+ if (!separator.test_axis(axis)) {
return;
}
}
@@ -2248,7 +2248,7 @@ static void _collision_convex_polygon_face(const Shape3DSW *p_a, const Transform
axis *= -1.0;
}
- if (!separator.test_axis(axis, !face_B->backface_collision)) {
+ if (!separator.test_axis(axis)) {
return;
}
}