summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/variant_call.cpp4
-rw-r--r--doc/classes/ConfigFile.xml10
-rw-r--r--doc/classes/PopupMenu.xml2
-rw-r--r--doc/classes/ScriptCreateDialog.xml6
-rw-r--r--doc/classes/Skeleton2D.xml2
-rw-r--r--doc/classes/TreeItem.xml18
-rw-r--r--doc/classes/VisualShaderNodeCubeMapUniform.xml3
-rw-r--r--editor/editor_inspector.cpp4
-rw-r--r--editor/output_strings.cpp208
-rw-r--r--editor/output_strings.h87
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp86
-rw-r--r--editor/plugins/canvas_item_editor_plugin.h11
-rw-r--r--editor/plugins/script_editor_plugin.cpp37
-rw-r--r--editor/plugins/script_editor_plugin.h1
-rw-r--r--modules/gdscript/language_server/gdscript_language_server.cpp3
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/BuildManager.cs13
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs22
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/Ides/GodotIdeManager.cs3
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/Internals/Internal.cs6
-rw-r--r--modules/mono/editor/csharp_project.cpp2
-rw-r--r--modules/mono/editor/editor_internal_calls.cpp51
-rw-r--r--modules/mono/editor/godotsharp_export.cpp14
-rw-r--r--modules/mono/editor/godotsharp_export.h3
-rw-r--r--modules/mono/godotsharp_dirs.cpp18
-rw-r--r--modules/mono/mono_gd/gd_mono.cpp288
-rw-r--r--modules/mono/mono_gd/gd_mono.h66
-rw-r--r--modules/mono/mono_gd/gd_mono_utils.cpp2
-rw-r--r--modules/websocket/doc_classes/WebSocketClient.xml20
-rw-r--r--modules/websocket/doc_classes/WebSocketServer.xml11
-rw-r--r--modules/websocket/emws_client.cpp15
-rw-r--r--modules/websocket/emws_client.h2
-rw-r--r--modules/websocket/websocket_client.cpp24
-rw-r--r--modules/websocket/websocket_client.h8
-rw-r--r--modules/websocket/websocket_server.cpp41
-rw-r--r--modules/websocket/websocket_server.h16
-rw-r--r--modules/websocket/wsl_client.cpp19
-rw-r--r--modules/websocket/wsl_client.h4
-rw-r--r--modules/websocket/wsl_peer.cpp11
-rw-r--r--modules/websocket/wsl_peer.h3
-rw-r--r--modules/websocket/wsl_server.cpp34
-rw-r--r--modules/websocket/wsl_server.h11
-rw-r--r--platform/android/export/export.cpp6
-rw-r--r--scene/gui/text_edit.cpp1
43 files changed, 596 insertions, 600 deletions
diff --git a/core/variant_call.cpp b/core/variant_call.cpp
index a1b75266ff..683c6882bf 100644
--- a/core/variant_call.cpp
+++ b/core/variant_call.cpp
@@ -599,9 +599,9 @@ struct _VariantCall {
int buffer_size = (int)(*p_args[0]);
- if (buffer_size < 0) {
+ if (buffer_size <= 0) {
r_ret = decompressed;
- ERR_FAIL_MSG("Decompression buffer size is less than zero.");
+ ERR_FAIL_MSG("Decompression buffer size must be greater than zero.");
}
decompressed.resize(buffer_size);
diff --git a/doc/classes/ConfigFile.xml b/doc/classes/ConfigFile.xml
index 775ad4c922..56f54e4434 100644
--- a/doc/classes/ConfigFile.xml
+++ b/doc/classes/ConfigFile.xml
@@ -39,6 +39,16 @@
Deletes the specified section along with all the key-value pairs inside.
</description>
</method>
+ <method name="erase_section_key">
+ <return type="void">
+ </return>
+ <argument index="0" name="section" type="String">
+ </argument>
+ <argument index="1" name="key" type="String">
+ </argument>
+ <description>
+ </description>
+ </method>
<method name="get_section_keys" qualifiers="const">
<return type="PoolStringArray">
</return>
diff --git a/doc/classes/PopupMenu.xml b/doc/classes/PopupMenu.xml
index 50b300d216..691aec2eb1 100644
--- a/doc/classes/PopupMenu.xml
+++ b/doc/classes/PopupMenu.xml
@@ -156,7 +156,7 @@
</argument>
<argument index="1" name="max_states" type="int">
</argument>
- <argument index="2" name="default_state" type="int">
+ <argument index="2" name="default_state" type="int" default="0">
</argument>
<argument index="3" name="id" type="int" default="-1">
</argument>
diff --git a/doc/classes/ScriptCreateDialog.xml b/doc/classes/ScriptCreateDialog.xml
index 30d67d47f3..3d0fa9a0d5 100644
--- a/doc/classes/ScriptCreateDialog.xml
+++ b/doc/classes/ScriptCreateDialog.xml
@@ -31,9 +31,9 @@
</methods>
<members>
<member name="dialog_hide_on_ok" type="bool" setter="set_hide_on_ok" getter="get_hide_on_ok" override="true" default="false" />
- <member name="margin_bottom" type="float" setter="set_margin" getter="get_margin" override="true" default="76.0" />
- <member name="margin_right" type="float" setter="set_margin" getter="get_margin" override="true" default="200.0" />
- <member name="rect_size" type="Vector2" setter="_set_size" getter="get_size" override="true" default="Vector2( 200, 76 )" />
+ <member name="margin_bottom" type="float" setter="set_margin" getter="get_margin" override="true" default="232.0" />
+ <member name="margin_right" type="float" setter="set_margin" getter="get_margin" override="true" default="361.0" />
+ <member name="rect_size" type="Vector2" setter="_set_size" getter="get_size" override="true" default="Vector2( 361, 232 )" />
<member name="window_title" type="String" setter="set_title" getter="get_title" override="true" default="&quot;Attach Node Script&quot;" />
</members>
<signals>
diff --git a/doc/classes/Skeleton2D.xml b/doc/classes/Skeleton2D.xml
index 064a7266bd..886e8244a2 100644
--- a/doc/classes/Skeleton2D.xml
+++ b/doc/classes/Skeleton2D.xml
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="Skeleton2D" inherits="Node2D" category="Core" version="3.2">
<brief_description>
+ Skeleton for 2D characters and animated objects.
</brief_description>
<description>
</description>
@@ -20,6 +21,7 @@
<return type="int">
</return>
<description>
+ Returns the amount of bones in the skeleton.
</description>
</method>
<method name="get_skeleton" qualifiers="const">
diff --git a/doc/classes/TreeItem.xml b/doc/classes/TreeItem.xml
index a4c976591f..c77388e5f4 100644
--- a/doc/classes/TreeItem.xml
+++ b/doc/classes/TreeItem.xml
@@ -26,6 +26,15 @@
Adds a button with [Texture] [code]button[/code] at column [code]column[/code]. The [code]button_idx[/code] index is used to identify the button when calling other methods. If not specified, the next available index is used, which may be retrieved by calling [method get_button_count] immediately after this method. Optionally, the button can be [code]disabled[/code] and have a [code]tooltip[/code].
</description>
</method>
+ <method name="call_recursive" qualifiers="vararg">
+ <return type="Variant">
+ </return>
+ <argument index="0" name="method" type="String">
+ </argument>
+ <description>
+ Calls the [code]method[/code] on the actual TreeItem and its children recursively. Pass parameters as a comma separated list.
+ </description>
+ </method>
<method name="clear_custom_bg_color">
<return type="void">
</return>
@@ -594,15 +603,6 @@
Sets the given column's tooltip text.
</description>
</method>
- <method name="call_recursive" qualifiers="vararg">
- <return type="Variant">
- </return>
- <argument index="0" name="method" type="String">
- </argument>
- <description>
- Calls the [code]method[/code] on the actual TreeItem and its children recursively. Pass parameters as a comma separated list.
- </description>
- </method>
</methods>
<members>
<member name="collapsed" type="bool" setter="set_collapsed" getter="is_collapsed">
diff --git a/doc/classes/VisualShaderNodeCubeMapUniform.xml b/doc/classes/VisualShaderNodeCubeMapUniform.xml
index 453af81009..c6b3db5a9d 100644
--- a/doc/classes/VisualShaderNodeCubeMapUniform.xml
+++ b/doc/classes/VisualShaderNodeCubeMapUniform.xml
@@ -8,9 +8,6 @@
</tutorials>
<methods>
</methods>
- <members>
- <member name="default_input_values" type="Array" setter="_set_default_input_values" getter="_get_default_input_values" override="true" default="[ ]" />
- </members>
<constants>
</constants>
</class>
diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp
index b29417b4c3..78e058eeaa 100644
--- a/editor/editor_inspector.cpp
+++ b/editor/editor_inspector.cpp
@@ -1566,11 +1566,11 @@ void EditorInspector::update_tree() {
if (dot != -1) {
String ov = name.right(dot);
name = name.substr(0, dot);
- name = name.camelcase_to_underscore().capitalize();
+ name = name.capitalize();
name += ov;
} else {
- name = name.camelcase_to_underscore().capitalize();
+ name = name.capitalize();
}
}
diff --git a/editor/output_strings.cpp b/editor/output_strings.cpp
deleted file mode 100644
index baabaff9a8..0000000000
--- a/editor/output_strings.cpp
+++ /dev/null
@@ -1,208 +0,0 @@
-/*************************************************************************/
-/* output_strings.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#include "output_strings.h"
-
-void OutputStrings::update_scrollbars() {
-
- Size2 hmin = h_scroll->get_combined_minimum_size();
- Size2 vmin = v_scroll->get_combined_minimum_size();
-
- v_scroll->set_anchor(MARGIN_LEFT, ANCHOR_END);
- v_scroll->set_anchor(MARGIN_RIGHT, ANCHOR_END);
- v_scroll->set_anchor(MARGIN_BOTTOM, ANCHOR_END);
-
- v_scroll->set_begin(Point2(-vmin.width, 0));
- v_scroll->set_end(Point2(0, 0));
-
- h_scroll->set_anchor(MARGIN_RIGHT, ANCHOR_END);
- h_scroll->set_anchor(MARGIN_TOP, ANCHOR_END);
- h_scroll->set_anchor(MARGIN_BOTTOM, ANCHOR_END);
-
- h_scroll->set_begin(Point2(0, -hmin.y));
- h_scroll->set_end(Point2(-vmin.x, 0));
-
- margin.y = hmin.y;
- margin.x = vmin.x;
-
- Ref<StyleBox> tree_st = get_stylebox("bg", "Tree");
- int page = ((size_height - (int)margin.y - tree_st->get_margin(MARGIN_TOP)) / font_height);
- v_scroll->set_page(page);
-}
-
-void OutputStrings::_notification(int p_what) {
-
- switch (p_what) {
-
- case NOTIFICATION_DRAW: {
-
- if (following) {
-
- updating = true;
- v_scroll->set_value(v_scroll->get_max() - v_scroll->get_page());
- updating = false;
- }
-
- RID ci = get_canvas_item();
- Size2 size = get_size();
-
- Ref<Font> font = get_font("font", "Tree");
- Ref<StyleBox> tree_st = get_stylebox("bg", "Tree");
- tree_st->draw(ci, Rect2(Point2(), size));
- Color color = get_color("font_color", "Tree");
- Ref<Texture> icon_error = get_icon("Error", "EditorIcons");
- Ref<Texture> icon_warning = get_icon("Warning", "EditorIcons");
-
- //int lines = (size_height-(int)margin.y) / font_height;
- Point2 ofs = tree_st->get_offset();
-
- LineMap::Element *E = line_map.find(v_scroll->get_value());
- float h_ofs = (int)h_scroll->get_value();
- Point2 icon_ofs = Point2(0, (font_height - (int)icon_error->get_height()) / 2);
-
- FontDrawer drawer(font, Color(1, 1, 1));
- while (E && ofs.y < (size_height - (int)margin.y)) {
-
- String str = E->get().text;
- Point2 line_ofs = ofs;
-
- switch (E->get().type) {
-
- case LINE_WARNING: {
- icon_warning->draw(ci, line_ofs + icon_ofs);
-
- } break;
- case LINE_ERROR: {
- icon_error->draw(ci, line_ofs + icon_ofs);
- } break;
- case LINE_LINK: {
-
- } break;
- default: {
- }
- }
-
- line_ofs.y += font->get_ascent();
- line_ofs.x += icon_error->get_width() + 4;
-
- for (int i = 0; i < str.length(); i++) {
- if (line_ofs.x - h_ofs < 0) {
- line_ofs.x += font->get_char_size(str[i], str[i + 1]).width;
- } else if (line_ofs.x - h_ofs > size.width - margin.width) {
- break;
- } else {
- line_ofs.x += font->draw_char(ci, Point2(line_ofs.x - h_ofs, line_ofs.y), str[i], str[i + 1], color);
- }
- }
-
- ofs.y += font_height;
- E = E->next();
- }
-
- } break;
-
- case NOTIFICATION_ENTER_TREE:
- case NOTIFICATION_RESIZED: {
-
- font_height = get_font("font", "Tree")->get_height();
- size_height = get_size().height;
- update_scrollbars();
- } break;
- }
-}
-
-void OutputStrings::_hscroll_changed(float p_value) {
-
- if (updating)
- return;
-
- update();
-}
-void OutputStrings::_vscroll_changed(float p_value) {
-
- if (updating)
- return;
- //user changed scroll
- following = (p_value + v_scroll->get_page()) >= v_scroll->get_max();
- update();
-}
-
-void OutputStrings::add_line(const String &p_text, const Variant &p_meta, const LineType p_type) {
-
- Vector<String> strings = p_text.split("\n");
-
- for (int i = 0; i < strings.size(); i++) {
-
- if (strings[i].length() == 0)
- continue;
-
- int last = line_map.empty() ? 0 : (line_map.back()->key() + 1);
-
- Line l;
- l.text = strings[i];
- l.meta = p_meta;
- l.type = p_type;
- line_map.insert(last, l);
-
- updating = true;
- v_scroll->set_max(last + 1);
- v_scroll->set_min(line_map.front()->key());
- updating = false;
- }
-
- while (line_map.size() > line_max_count) {
-
- line_map.erase(line_map.front());
- }
-
- update();
-}
-
-void OutputStrings::_bind_methods() {
-
- ClassDB::bind_method("_vscroll_changed", &OutputStrings::_vscroll_changed);
- ClassDB::bind_method("_hscroll_changed", &OutputStrings::_hscroll_changed);
-}
-
-OutputStrings::OutputStrings() {
-
- following = true;
- updating = false;
- line_max_count = 4096;
- h_scroll = memnew(HScrollBar);
- v_scroll = memnew(VScrollBar);
- add_child(h_scroll);
- add_child(v_scroll);
- size_height = 1;
- font_height = 1;
- update_scrollbars();
- h_scroll->connect("value_changed", this, "_hscroll_changed");
- v_scroll->connect("value_changed", this, "_vscroll_changed");
-}
diff --git a/editor/output_strings.h b/editor/output_strings.h
deleted file mode 100644
index 4fd3f7d836..0000000000
--- a/editor/output_strings.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/*************************************************************************/
-/* output_strings.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#ifndef OUTPUT_STRINGS_H
-#define OUTPUT_STRINGS_H
-
-#include "core/map.h"
-#include "scene/gui/control.h"
-#include "scene/gui/scroll_bar.h"
-
-class OutputStrings : public Control {
-
- GDCLASS(OutputStrings, Control);
-
-public:
- enum LineType {
-
- LINE_NORMAL,
- LINE_WARNING,
- LINE_ERROR,
- LINE_LINK
- };
-
-private:
- struct Line {
-
- LineType type;
- Variant meta;
- String text;
- };
-
- int font_height;
- int size_height;
-
- Size2 margin;
- typedef Map<int, Line> LineMap;
- Map<int, Line> line_map;
-
- VScrollBar *v_scroll;
- HScrollBar *h_scroll;
-
- bool following;
- int line_max_count;
- bool updating;
-
- void _vscroll_changed(float p_value);
- void _hscroll_changed(float p_value);
- void update_scrollbars();
-
-protected:
- static void _bind_methods();
- void _notification(int p_what);
-
-public:
- void add_line(const String &p_text, const Variant &p_meta = Variant(), const LineType p_type = LINE_NORMAL);
-
- OutputStrings();
-};
-
-#endif // OUTPUT_STRINGS_H
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index f54411c72b..117b88bc7e 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -284,7 +284,7 @@ Point2 CanvasItemEditor::snap_point(Point2 p_target, unsigned int p_modes, unsig
snap_target[0] = SNAP_TARGET_NONE;
snap_target[1] = SNAP_TARGET_NONE;
- bool is_snap_active = snap_active ^ Input::get_singleton()->is_key_pressed(KEY_CONTROL);
+ bool is_snap_active = smart_snap_active ^ Input::get_singleton()->is_key_pressed(KEY_CONTROL);
// Smart snap using the canvas position
Vector2 output = p_target;
@@ -384,7 +384,7 @@ Point2 CanvasItemEditor::snap_point(Point2 p_target, unsigned int p_modes, unsig
}
}
- if (((is_snap_active && snap_grid && (p_modes & SNAP_GRID)) || (p_forced_modes & SNAP_GRID)) && fmod(rotation, (real_t)360.0) == 0.0) {
+ if (((grid_snap_active && (p_modes & SNAP_GRID)) || (p_forced_modes & SNAP_GRID)) && fmod(rotation, (real_t)360.0) == 0.0) {
// Grid
Point2 offset = grid_offset;
if (snap_relative) {
@@ -412,7 +412,7 @@ Point2 CanvasItemEditor::snap_point(Point2 p_target, unsigned int p_modes, unsig
}
float CanvasItemEditor::snap_angle(float p_target, float p_start) const {
- return (((snap_active || snap_rotation) ^ Input::get_singleton()->is_key_pressed(KEY_CONTROL)) && snap_rotation_step != 0) ? Math::stepify(p_target - snap_rotation_offset, snap_rotation_step) + snap_rotation_offset : p_target;
+ return (((smart_snap_active || snap_rotation) ^ Input::get_singleton()->is_key_pressed(KEY_CONTROL)) && snap_rotation_step != 0) ? Math::stepify(p_target - snap_rotation_offset, snap_rotation_step) + snap_rotation_offset : p_target;
}
void CanvasItemEditor::_unhandled_key_input(const Ref<InputEvent> &p_ev) {
@@ -427,11 +427,11 @@ void CanvasItemEditor::_unhandled_key_input(const Ref<InputEvent> &p_ev) {
}
if (k->is_pressed() && !k->get_control() && !k->is_echo()) {
- if ((snap_grid || show_grid) && multiply_grid_step_shortcut.is_valid() && multiply_grid_step_shortcut->is_shortcut(p_ev)) {
+ if ((grid_snap_active || show_grid) && multiply_grid_step_shortcut.is_valid() && multiply_grid_step_shortcut->is_shortcut(p_ev)) {
// Multiply the grid size
grid_step_multiplier = MIN(grid_step_multiplier + 1, 12);
viewport->update();
- } else if ((snap_grid || show_grid) && divide_grid_step_shortcut.is_valid() && divide_grid_step_shortcut->is_shortcut(p_ev)) {
+ } else if ((grid_snap_active || show_grid) && divide_grid_step_shortcut.is_valid() && divide_grid_step_shortcut->is_shortcut(p_ev)) {
// Divide the grid size
Point2 new_grid_step = grid_step * Math::pow(2.0, grid_step_multiplier - 1);
if (new_grid_step.x >= 1.0 && new_grid_step.y >= 1.0)
@@ -2287,7 +2287,7 @@ bool CanvasItemEditor::_gui_input_ruler_tool(const Ref<InputEvent> &p_event) {
return true;
}
- bool is_snap_active = snap_active ^ Input::get_singleton()->is_key_pressed(KEY_CONTROL);
+ bool is_snap_active = smart_snap_active ^ Input::get_singleton()->is_key_pressed(KEY_CONTROL);
if (m.is_valid() && (ruler_tool_active || (is_snap_active && previous_origin != ruler_tool_origin))) {
@@ -2558,11 +2558,10 @@ void CanvasItemEditor::_draw_rulers() {
Color font_color = get_color("font_color", "Editor");
font_color.a = 0.8;
Ref<Font> font = get_font("rulers", "EditorFonts");
- bool is_snap_active = snap_active ^ Input::get_singleton()->is_key_pressed(KEY_CONTROL);
// The rule transform
Transform2D ruler_transform = Transform2D();
- if (show_grid || (is_snap_active && snap_grid)) {
+ if (show_grid || grid_snap_active) {
List<CanvasItem *> selection = _get_edited_canvas_items();
if (snap_relative && selection.size() > 0) {
ruler_transform.translate(_get_encompassing_rect_from_list(selection).position);
@@ -2642,7 +2641,7 @@ void CanvasItemEditor::_draw_rulers() {
}
void CanvasItemEditor::_draw_grid() {
- if (show_grid) {
+ if (show_grid || grid_snap_active) {
//Draw the grid
Size2 s = viewport->get_size();
int last_cell = 0;
@@ -2688,7 +2687,7 @@ void CanvasItemEditor::_draw_ruler_tool() {
if (tool != TOOL_RULER)
return;
- bool is_snap_active = snap_active ^ Input::get_singleton()->is_key_pressed(KEY_CONTROL);
+ bool is_snap_active = smart_snap_active ^ Input::get_singleton()->is_key_pressed(KEY_CONTROL);
if (ruler_tool_active) {
Color ruler_primary_color = get_color("accent_color", "Editor");
@@ -3697,7 +3696,8 @@ void CanvasItemEditor::_notification(int p_what) {
move_button->set_icon(get_icon("ToolMove", "EditorIcons"));
scale_button->set_icon(get_icon("ToolScale", "EditorIcons"));
rotate_button->set_icon(get_icon("ToolRotate", "EditorIcons"));
- snap_button->set_icon(get_icon("Snap", "EditorIcons"));
+ smart_snap_button->set_icon(get_icon("Snap", "EditorIcons"));
+ grid_snap_button->set_icon(get_icon("SnapGrid", "EditorIcons"));
snap_config_menu->set_icon(get_icon("GuiTabMenu", "EditorIcons"));
skeleton_menu->set_icon(get_icon("Bone", "EditorIcons"));
pan_button->set_icon(get_icon("ToolPan", "EditorIcons"));
@@ -4101,8 +4101,13 @@ void CanvasItemEditor::_button_zoom_plus() {
_zoom_on_position(zoom * Math_SQRT2, viewport_scrollable->get_size() / 2.0);
}
-void CanvasItemEditor::_button_toggle_snap(bool p_status) {
- snap_active = p_status;
+void CanvasItemEditor::_button_toggle_smart_snap(bool p_status) {
+ smart_snap_active = p_status;
+ viewport->update();
+}
+
+void CanvasItemEditor::_button_toggle_grid_snap(bool p_status) {
+ grid_snap_active = p_status;
viewport->update();
}
@@ -4261,11 +4266,6 @@ void CanvasItemEditor::_popup_callback(int p_op) {
int idx = smartsnap_config_popup->get_item_index(SNAP_USE_GUIDES);
smartsnap_config_popup->set_item_checked(idx, snap_guides);
} break;
- case SNAP_USE_GRID: {
- snap_grid = !snap_grid;
- int idx = snap_config_menu->get_popup()->get_item_index(SNAP_USE_GRID);
- snap_config_menu->get_popup()->set_item_checked(idx, snap_grid);
- } break;
case SNAP_USE_ROTATION: {
snap_rotation = !snap_rotation;
int idx = snap_config_menu->get_popup()->get_item_index(SNAP_USE_ROTATION);
@@ -4797,7 +4797,8 @@ void CanvasItemEditor::_bind_methods() {
ClassDB::bind_method("_button_zoom_minus", &CanvasItemEditor::_button_zoom_minus);
ClassDB::bind_method("_button_zoom_reset", &CanvasItemEditor::_button_zoom_reset);
ClassDB::bind_method("_button_zoom_plus", &CanvasItemEditor::_button_zoom_plus);
- ClassDB::bind_method("_button_toggle_snap", &CanvasItemEditor::_button_toggle_snap);
+ ClassDB::bind_method("_button_toggle_smart_snap", &CanvasItemEditor::_button_toggle_smart_snap);
+ ClassDB::bind_method("_button_toggle_grid_snap", &CanvasItemEditor::_button_toggle_grid_snap);
ClassDB::bind_method("_button_toggle_anchor_mode", &CanvasItemEditor::_button_toggle_anchor_mode);
ClassDB::bind_method("_update_scroll", &CanvasItemEditor::_update_scroll);
ClassDB::bind_method("_update_scrollbars", &CanvasItemEditor::_update_scrollbars);
@@ -4832,13 +4833,13 @@ Dictionary CanvasItemEditor::get_state() const {
state["grid_step"] = grid_step;
state["snap_rotation_offset"] = snap_rotation_offset;
state["snap_rotation_step"] = snap_rotation_step;
- state["snap_active"] = snap_active;
+ state["smart_snap_active"] = smart_snap_active;
+ state["grid_snap_active"] = grid_snap_active;
state["snap_node_parent"] = snap_node_parent;
state["snap_node_anchors"] = snap_node_anchors;
state["snap_node_sides"] = snap_node_sides;
state["snap_node_center"] = snap_node_center;
state["snap_other_nodes"] = snap_other_nodes;
- state["snap_grid"] = snap_grid;
state["snap_guides"] = snap_guides;
state["show_grid"] = show_grid;
state["show_origin"] = show_origin;
@@ -4886,9 +4887,14 @@ void CanvasItemEditor::set_state(const Dictionary &p_state) {
snap_rotation_offset = state["snap_rotation_offset"];
}
- if (state.has("snap_active")) {
- snap_active = state["snap_active"];
- snap_button->set_pressed(snap_active);
+ if (state.has("smart_snap_active")) {
+ smart_snap_active = state["smart_snap_active"];
+ smart_snap_button->set_pressed(smart_snap_active);
+ }
+
+ if (state.has("grid_snap_active")) {
+ grid_snap_active = state["grid_snap_active"];
+ grid_snap_button->set_pressed(smart_snap_active);
}
if (state.has("snap_node_parent")) {
@@ -4927,12 +4933,6 @@ void CanvasItemEditor::set_state(const Dictionary &p_state) {
smartsnap_config_popup->set_item_checked(idx, snap_guides);
}
- if (state.has("snap_grid")) {
- snap_grid = state["snap_grid"];
- int idx = snap_config_menu->get_popup()->get_item_index(SNAP_USE_GRID);
- snap_config_menu->get_popup()->set_item_checked(idx, snap_grid);
- }
-
if (state.has("show_grid")) {
show_grid = state["show_grid"];
int idx = view_menu->get_popup()->get_item_index(SHOW_GRID);
@@ -5071,13 +5071,13 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
grid_step_multiplier = 0;
snap_rotation_offset = 0;
snap_rotation_step = 15 / (180 / Math_PI);
- snap_active = false;
+ smart_snap_active = false;
+ grid_snap_active = false;
snap_node_parent = true;
snap_node_anchors = true;
snap_node_sides = true;
snap_node_center = true;
snap_other_nodes = true;
- snap_grid = true;
snap_guides = true;
snap_rotation = false;
snap_relative = false;
@@ -5269,12 +5269,19 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
hb->add_child(memnew(VSeparator));
- snap_button = memnew(ToolButton);
- hb->add_child(snap_button);
- snap_button->set_toggle_mode(true);
- snap_button->connect("toggled", this, "_button_toggle_snap");
- snap_button->set_tooltip(TTR("Toggle snapping."));
- snap_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/use_snap", TTR("Use Snap"), KEY_MASK_SHIFT | KEY_S));
+ smart_snap_button = memnew(ToolButton);
+ hb->add_child(smart_snap_button);
+ smart_snap_button->set_toggle_mode(true);
+ smart_snap_button->connect("toggled", this, "_button_toggle_smart_snap");
+ smart_snap_button->set_tooltip(TTR("Toggle smart snapping."));
+ smart_snap_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/use_smart_snap", TTR("Use Smart Snap"), KEY_MASK_SHIFT | KEY_S));
+
+ grid_snap_button = memnew(ToolButton);
+ hb->add_child(grid_snap_button);
+ grid_snap_button->set_toggle_mode(true);
+ grid_snap_button->connect("toggled", this, "_button_toggle_grid_snap");
+ grid_snap_button->set_tooltip(TTR("Toggle grid snapping."));
+ grid_snap_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/use_grid_snap", TTR("Use Grid Snap"), KEY_MASK_SHIFT | KEY_G));
snap_config_menu = memnew(MenuButton);
hb->add_child(snap_config_menu);
@@ -5285,7 +5292,6 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
PopupMenu *p = snap_config_menu->get_popup();
p->connect("id_pressed", this, "_popup_callback");
p->set_hide_on_checkable_item_selection(false);
- p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/snap_grid", TTR("Snap to Grid")), SNAP_USE_GRID);
p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/use_rotation_snap", TTR("Use Rotation Snap")), SNAP_USE_ROTATION);
p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/snap_relative", TTR("Snap Relative")), SNAP_RELATIVE);
p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/use_pixel_snap", TTR("Use Pixel Snap")), SNAP_USE_PIXEL);
@@ -5357,7 +5363,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
p = view_menu->get_popup();
p->set_hide_on_checkable_item_selection(false);
- p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/show_grid", TTR("Show Grid"), KEY_G), SHOW_GRID);
+ p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/show_grid", TTR("Always Show Grid"), KEY_G), SHOW_GRID);
p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/show_helpers", TTR("Show Helpers"), KEY_H), SHOW_HELPERS);
p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/show_rulers", TTR("Show Rulers")), SHOW_RULERS);
p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/show_guides", TTR("Show Guides"), KEY_Y), SHOW_GUIDES);
diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h
index 6cce1ca10e..480fb89621 100644
--- a/editor/plugins/canvas_item_editor_plugin.h
+++ b/editor/plugins/canvas_item_editor_plugin.h
@@ -259,13 +259,14 @@ private:
float snap_rotation_step;
float snap_rotation_offset;
- bool snap_active;
+ bool smart_snap_active;
+ bool grid_snap_active;
+
bool snap_node_parent;
bool snap_node_anchors;
bool snap_node_sides;
bool snap_node_center;
bool snap_other_nodes;
- bool snap_grid;
bool snap_guides;
bool snap_rotation;
bool snap_relative;
@@ -347,7 +348,8 @@ private:
ToolButton *ruler_button;
- ToolButton *snap_button;
+ ToolButton *smart_snap_button;
+ ToolButton *grid_snap_button;
MenuButton *snap_config_menu;
PopupMenu *smartsnap_config_popup;
@@ -529,7 +531,8 @@ private:
void _button_zoom_minus();
void _button_zoom_reset();
void _button_zoom_plus();
- void _button_toggle_snap(bool p_status);
+ void _button_toggle_smart_snap(bool p_status);
+ void _button_toggle_grid_snap(bool p_status);
void _button_tool_select(int p_index);
HSplitContainer *palette_split;
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index 132a491fb3..f7e997a269 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -43,6 +43,7 @@
#include "editor/plugins/shader_editor_plugin.h"
#include "editor/script_editor_debugger.h"
#include "scene/main/viewport.h"
+#include "scene/scene_string_names.h"
#include "script_text_editor.h"
#include "text_editor.h"
@@ -1420,16 +1421,6 @@ void ScriptEditor::_notification(int p_what) {
members_overview->connect("item_selected", this, "_members_overview_selected");
help_overview->connect("item_selected", this, "_help_overview_selected");
script_split->connect("dragged", this, "_script_split_dragged");
- autosave_timer->connect("timeout", this, "_autosave_scripts");
- {
- float autosave_time = EditorSettings::get_singleton()->get("text_editor/files/autosave_interval_secs");
- if (autosave_time > 0) {
- autosave_timer->set_wait_time(autosave_time);
- autosave_timer->start();
- } else {
- autosave_timer->stop();
- }
- }
EditorSettings::get_singleton()->connect("settings_changed", this, "_editor_settings_changed");
FALLTHROUGH;
@@ -2335,13 +2326,7 @@ void ScriptEditor::_editor_settings_changed() {
_update_members_overview_visibility();
_update_help_overview_visibility();
- float autosave_time = EditorSettings::get_singleton()->get("text_editor/files/autosave_interval_secs");
- if (autosave_time > 0) {
- autosave_timer->set_wait_time(autosave_time);
- autosave_timer->start();
- } else {
- autosave_timer->stop();
- }
+ _update_autosave_timer();
if (current_theme == "") {
current_theme = EditorSettings::get_singleton()->get("text_editor/theme/color_theme");
@@ -2369,6 +2354,21 @@ void ScriptEditor::_autosave_scripts() {
save_all_scripts();
}
+void ScriptEditor::_update_autosave_timer() {
+
+ if (!autosave_timer->is_inside_tree()) {
+ return;
+ }
+
+ float autosave_time = EditorSettings::get_singleton()->get("text_editor/files/autosave_interval_secs");
+ if (autosave_time > 0) {
+ autosave_timer->set_wait_time(autosave_time);
+ autosave_timer->start();
+ } else {
+ autosave_timer->stop();
+ }
+}
+
void ScriptEditor::_tree_changed() {
if (waiting_update_names)
@@ -3092,6 +3092,7 @@ void ScriptEditor::_bind_methods() {
ClassDB::bind_method("_show_debugger", &ScriptEditor::_show_debugger);
ClassDB::bind_method("_get_debug_tooltip", &ScriptEditor::_get_debug_tooltip);
ClassDB::bind_method("_autosave_scripts", &ScriptEditor::_autosave_scripts);
+ ClassDB::bind_method("_update_autosave_timer", &ScriptEditor::_update_autosave_timer);
ClassDB::bind_method("_editor_settings_changed", &ScriptEditor::_editor_settings_changed);
ClassDB::bind_method("_update_script_names", &ScriptEditor::_update_script_names);
ClassDB::bind_method("_update_script_connections", &ScriptEditor::_update_script_connections);
@@ -3428,6 +3429,8 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
autosave_timer = memnew(Timer);
autosave_timer->set_one_shot(false);
+ autosave_timer->connect(SceneStringNames::get_singleton()->tree_entered, this, "_update_autosave_timer");
+ autosave_timer->connect("timeout", this, "_autosave_scripts");
add_child(autosave_timer);
grab_focus_block = false;
diff --git a/editor/plugins/script_editor_plugin.h b/editor/plugins/script_editor_plugin.h
index 8ff7a2222d..294294fc56 100644
--- a/editor/plugins/script_editor_plugin.h
+++ b/editor/plugins/script_editor_plugin.h
@@ -343,6 +343,7 @@ class ScriptEditor : public PanelContainer {
void _save_layout();
void _editor_settings_changed();
void _autosave_scripts();
+ void _update_autosave_timer();
void _update_members_overview_visibility();
void _update_members_overview();
diff --git a/modules/gdscript/language_server/gdscript_language_server.cpp b/modules/gdscript/language_server/gdscript_language_server.cpp
index 62c212a2bd..8d58b99e02 100644
--- a/modules/gdscript/language_server/gdscript_language_server.cpp
+++ b/modules/gdscript/language_server/gdscript_language_server.cpp
@@ -56,8 +56,9 @@ void GDScriptLanguageServer::_notification(int p_what) {
void GDScriptLanguageServer::thread_main(void *p_userdata) {
GDScriptLanguageServer *self = static_cast<GDScriptLanguageServer *>(p_userdata);
while (!self->thread_exit) {
+ // Poll 20 times per second
self->protocol.poll();
- OS::get_singleton()->delay_usec(10);
+ OS::get_singleton()->delay_usec(50000);
}
}
diff --git a/modules/mono/editor/GodotTools/GodotTools/BuildManager.cs b/modules/mono/editor/GodotTools/GodotTools/BuildManager.cs
index 417032da54..ab37d89955 100644
--- a/modules/mono/editor/GodotTools/GodotTools/BuildManager.cs
+++ b/modules/mono/editor/GodotTools/GodotTools/BuildManager.cs
@@ -160,9 +160,16 @@ namespace GodotTools
if (!File.Exists(GodotSharpDirs.ProjectSlnPath))
return true; // No solution to build
- // Make sure to update the API assemblies if they happen to be missing. Just in
- // case the user decided to delete them at some point after they were loaded.
- Internal.UpdateApiAssembliesFromPrebuilt();
+ // Make sure the API assemblies are up to date before building the project.
+ // We may not have had the chance to update the release API assemblies, and the debug ones
+ // may have been deleted by the user at some point after they were loaded by the Godot editor.
+ string apiAssembliesUpdateError = Internal.UpdateApiAssembliesFromPrebuilt(config == "Release" ? "Release" : "Debug");
+
+ if (!string.IsNullOrEmpty(apiAssembliesUpdateError))
+ {
+ ShowBuildErrorDialog("Failed to update the Godot API assemblies");
+ return false;
+ }
var editorSettings = GodotSharpEditor.Instance.GetEditorInterface().GetEditorSettings();
var buildTool = (BuildTool) editorSettings.GetSetting("mono/builds/build_tool");
diff --git a/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs b/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs
index 7da7cff933..12edd651df 100644
--- a/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs
+++ b/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs
@@ -34,7 +34,7 @@ namespace GodotTools
private bool CreateProjectSolution()
{
- using (var pr = new EditorProgress("create_csharp_solution", "Generating solution...".TTR(), 2))
+ using (var pr = new EditorProgress("create_csharp_solution", "Generating solution...".TTR(), 3))
{
pr.Step("Generating C# project...".TTR());
@@ -73,9 +73,23 @@ namespace GodotTools
return false;
}
- // Make sure to update the API assemblies if they happen to be missing. Just in
- // case the user decided to delete them at some point after they were loaded.
- Internal.UpdateApiAssembliesFromPrebuilt();
+ pr.Step("Updating Godot API assemblies...".TTR());
+
+ string debugApiAssembliesError = Internal.UpdateApiAssembliesFromPrebuilt("Debug");
+
+ if (!string.IsNullOrEmpty(debugApiAssembliesError))
+ {
+ ShowErrorDialog("Failed to update the Godot API assemblies: " + debugApiAssembliesError);
+ return false;
+ }
+
+ string releaseApiAssembliesError = Internal.UpdateApiAssembliesFromPrebuilt("Release");
+
+ if (!string.IsNullOrEmpty(releaseApiAssembliesError))
+ {
+ ShowErrorDialog("Failed to update the Godot API assemblies: " + releaseApiAssembliesError);
+ return false;
+ }
pr.Step("Done".TTR());
diff --git a/modules/mono/editor/GodotTools/GodotTools/Ides/GodotIdeManager.cs b/modules/mono/editor/GodotTools/GodotTools/Ides/GodotIdeManager.cs
index 9e24138143..01aa0d0ab1 100644
--- a/modules/mono/editor/GodotTools/GodotTools/Ides/GodotIdeManager.cs
+++ b/modules/mono/editor/GodotTools/GodotTools/Ides/GodotIdeManager.cs
@@ -40,8 +40,7 @@ namespace GodotTools.Ides
protected ILogger Logger
{
- get => logger ?? (logger = new ConsoleLogger());
- set => logger = value;
+ get => logger ?? (logger = new GodotLogger());
}
private void StartServer()
diff --git a/modules/mono/editor/GodotTools/GodotTools/Internals/Internal.cs b/modules/mono/editor/GodotTools/GodotTools/Internals/Internal.cs
index 7783576910..836c9c11e4 100644
--- a/modules/mono/editor/GodotTools/GodotTools/Internals/Internal.cs
+++ b/modules/mono/editor/GodotTools/GodotTools/Internals/Internal.cs
@@ -10,8 +10,8 @@ namespace GodotTools.Internals
public const string CSharpLanguageType = "CSharpScript";
public const string CSharpLanguageExtension = "cs";
- public static string UpdateApiAssembliesFromPrebuilt() =>
- internal_UpdateApiAssembliesFromPrebuilt();
+ public static string UpdateApiAssembliesFromPrebuilt(string config) =>
+ internal_UpdateApiAssembliesFromPrebuilt(config);
public static string FullTemplatesDir =>
internal_FullTemplatesDir();
@@ -55,7 +55,7 @@ namespace GodotTools.Internals
// Internal Calls
[MethodImpl(MethodImplOptions.InternalCall)]
- private static extern string internal_UpdateApiAssembliesFromPrebuilt();
+ private static extern string internal_UpdateApiAssembliesFromPrebuilt(string config);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern string internal_FullTemplatesDir();
diff --git a/modules/mono/editor/csharp_project.cpp b/modules/mono/editor/csharp_project.cpp
index 0e6c58c9d7..748447005f 100644
--- a/modules/mono/editor/csharp_project.cpp
+++ b/modules/mono/editor/csharp_project.cpp
@@ -75,7 +75,7 @@ bool generate_api_solution(const String &p_solution_dir, const String &p_core_pr
p_editor_proj_dir, p_editor_compile_items,
GDMono::get_singleton()->get_tools_project_editor_assembly());
} else {
- MonoDomain *temp_domain = GDMonoUtils::create_domain("GodotEngine.ApiSolutionGenerationDomain");
+ MonoDomain *temp_domain = GDMonoUtils::create_domain("GodotEngine.Domain.ApiSolutionGeneration");
CRASH_COND(temp_domain == NULL);
_GDMONO_SCOPE_EXIT_DOMAIN_UNLOAD_(temp_domain);
diff --git a/modules/mono/editor/editor_internal_calls.cpp b/modules/mono/editor/editor_internal_calls.cpp
index 5a84d9e3b8..1564d73c2a 100644
--- a/modules/mono/editor/editor_internal_calls.cpp
+++ b/modules/mono/editor/editor_internal_calls.cpp
@@ -230,31 +230,9 @@ uint32_t godot_icall_GodotSharpExport_GetExportedAssemblyDependencies(MonoString
return GodotSharpExport::get_exported_assembly_dependencies(project_dll_name, project_dll_src_path, build_config, custom_lib_dir, dependencies);
}
-float godot_icall_Globals_EditorScale() {
- return EDSCALE;
-}
-
-MonoObject *godot_icall_Globals_GlobalDef(MonoString *p_setting, MonoObject *p_default_value, MonoBoolean p_restart_if_changed) {
- String setting = GDMonoMarshal::mono_string_to_godot(p_setting);
- Variant default_value = GDMonoMarshal::mono_object_to_variant(p_default_value);
- Variant result = _GLOBAL_DEF(setting, default_value, (bool)p_restart_if_changed);
- return GDMonoMarshal::variant_to_mono_object(result);
-}
-
-MonoObject *godot_icall_Globals_EditorDef(MonoString *p_setting, MonoObject *p_default_value, MonoBoolean p_restart_if_changed) {
- String setting = GDMonoMarshal::mono_string_to_godot(p_setting);
- Variant default_value = GDMonoMarshal::mono_object_to_variant(p_default_value);
- Variant result = _EDITOR_DEF(setting, default_value, (bool)p_restart_if_changed);
- return GDMonoMarshal::variant_to_mono_object(result);
-}
-
-MonoString *godot_icall_Globals_TTR(MonoString *p_text) {
- String text = GDMonoMarshal::mono_string_to_godot(p_text);
- return GDMonoMarshal::mono_string_from_godot(TTR(text));
-}
-
-MonoString *godot_icall_Internal_UpdateApiAssembliesFromPrebuilt() {
- String error_str = GDMono::get_singleton()->update_api_assemblies_from_prebuilt();
+MonoString *godot_icall_Internal_UpdateApiAssembliesFromPrebuilt(MonoString *p_config) {
+ String config = GDMonoMarshal::mono_string_to_godot(p_config);
+ String error_str = GDMono::get_singleton()->update_api_assemblies_from_prebuilt(config);
return GDMonoMarshal::mono_string_from_godot(error_str);
}
@@ -365,6 +343,29 @@ void godot_icall_Internal_ScriptEditorDebugger_ReloadScripts() {
}
}
+float godot_icall_Globals_EditorScale() {
+ return EDSCALE;
+}
+
+MonoObject *godot_icall_Globals_GlobalDef(MonoString *p_setting, MonoObject *p_default_value, MonoBoolean p_restart_if_changed) {
+ String setting = GDMonoMarshal::mono_string_to_godot(p_setting);
+ Variant default_value = GDMonoMarshal::mono_object_to_variant(p_default_value);
+ Variant result = _GLOBAL_DEF(setting, default_value, (bool)p_restart_if_changed);
+ return GDMonoMarshal::variant_to_mono_object(result);
+}
+
+MonoObject *godot_icall_Globals_EditorDef(MonoString *p_setting, MonoObject *p_default_value, MonoBoolean p_restart_if_changed) {
+ String setting = GDMonoMarshal::mono_string_to_godot(p_setting);
+ Variant default_value = GDMonoMarshal::mono_object_to_variant(p_default_value);
+ Variant result = _EDITOR_DEF(setting, default_value, (bool)p_restart_if_changed);
+ return GDMonoMarshal::variant_to_mono_object(result);
+}
+
+MonoString *godot_icall_Globals_TTR(MonoString *p_text) {
+ String text = GDMonoMarshal::mono_string_to_godot(p_text);
+ return GDMonoMarshal::mono_string_from_godot(TTR(text));
+}
+
MonoString *godot_icall_Utils_OS_GetPlatformName() {
String os_name = OS::get_singleton()->get_name();
return GDMonoMarshal::mono_string_from_godot(os_name);
diff --git a/modules/mono/editor/godotsharp_export.cpp b/modules/mono/editor/godotsharp_export.cpp
index 80a7335b1d..e83152d668 100644
--- a/modules/mono/editor/godotsharp_export.cpp
+++ b/modules/mono/editor/godotsharp_export.cpp
@@ -32,9 +32,13 @@
#include <mono/metadata/image.h>
+#include "core/os/os.h"
+
#include "../mono_gd/gd_mono.h"
#include "../mono_gd/gd_mono_assembly.h"
+namespace GodotSharpExport {
+
String get_assemblyref_name(MonoImage *p_image, int index) {
const MonoTableInfo *table_info = mono_image_get_table_info(p_image, MONO_TABLE_ASSEMBLYREF);
@@ -45,7 +49,7 @@ String get_assemblyref_name(MonoImage *p_image, int index) {
return String::utf8(mono_metadata_string_heap(p_image, cols[MONO_ASSEMBLYREF_NAME]));
}
-Error GodotSharpExport::get_assembly_dependencies(GDMonoAssembly *p_assembly, const Vector<String> &p_search_dirs, Dictionary &r_dependencies) {
+Error get_assembly_dependencies(GDMonoAssembly *p_assembly, const Vector<String> &p_search_dirs, Dictionary &r_dependencies) {
MonoImage *image = p_assembly->get_image();
for (int i = 0; i < mono_image_get_table_rows(image, MONO_TABLE_ASSEMBLYREF); i++) {
@@ -96,8 +100,8 @@ Error GodotSharpExport::get_assembly_dependencies(GDMonoAssembly *p_assembly, co
return OK;
}
-Error GodotSharpExport::get_exported_assembly_dependencies(const String &p_project_dll_name, const String &p_project_dll_src_path, const String &p_build_config, const String &p_custom_lib_dir, Dictionary &r_dependencies) {
- MonoDomain *export_domain = GDMonoUtils::create_domain("GodotEngine.ProjectExportDomain");
+Error get_exported_assembly_dependencies(const String &p_project_dll_name, const String &p_project_dll_src_path, const String &p_build_config, const String &p_custom_bcl_dir, Dictionary &r_dependencies) {
+ MonoDomain *export_domain = GDMonoUtils::create_domain("GodotEngine.Domain.ProjectExport");
ERR_FAIL_NULL_V(export_domain, FAILED);
_GDMONO_SCOPE_EXIT_DOMAIN_UNLOAD_(export_domain);
@@ -110,7 +114,9 @@ Error GodotSharpExport::get_exported_assembly_dependencies(const String &p_proje
ERR_FAIL_COND_V_MSG(!load_success, ERR_CANT_RESOLVE, "Cannot load assembly (refonly): '" + p_project_dll_name + "'.");
Vector<String> search_dirs;
- GDMonoAssembly::fill_search_dirs(search_dirs, p_build_config, p_custom_lib_dir);
+ GDMonoAssembly::fill_search_dirs(search_dirs, p_build_config, p_custom_bcl_dir);
return get_assembly_dependencies(scripts_assembly, search_dirs, r_dependencies);
}
+
+} // namespace GodotSharpExport
diff --git a/modules/mono/editor/godotsharp_export.h b/modules/mono/editor/godotsharp_export.h
index 8d121a6bc3..58e46e2f2d 100644
--- a/modules/mono/editor/godotsharp_export.h
+++ b/modules/mono/editor/godotsharp_export.h
@@ -39,10 +39,11 @@
namespace GodotSharpExport {
+Error get_assembly_dependencies(GDMonoAssembly *p_assembly, const Vector<String> &p_search_dirs, Dictionary &r_dependencies);
+
Error get_exported_assembly_dependencies(const String &p_project_dll_name,
const String &p_project_dll_src_path, const String &p_build_config,
const String &p_custom_lib_dir, Dictionary &r_dependencies);
-Error get_assembly_dependencies(GDMonoAssembly *p_assembly, const Vector<String> &p_search_dirs, Dictionary &r_dependencies);
} // namespace GodotSharpExport
diff --git a/modules/mono/godotsharp_dirs.cpp b/modules/mono/godotsharp_dirs.cpp
index 4b2525c692..5fa8aed5a9 100644
--- a/modules/mono/godotsharp_dirs.cpp
+++ b/modules/mono/godotsharp_dirs.cpp
@@ -43,6 +43,8 @@
#include "utils/android_utils.h"
#endif
+#include "mono_gd/gd_mono.h"
+
namespace GodotSharpDirs {
String _get_expected_build_config() {
@@ -59,20 +61,6 @@ String _get_expected_build_config() {
#endif
}
-String _get_expected_api_build_config() {
-#ifdef TOOLS_ENABLED
- return "Debug";
-#else
-
-#ifdef DEBUG_ENABLED
- return "Debug";
-#else
- return "Release";
-#endif
-
-#endif
-}
-
String _get_mono_user_dir() {
#ifdef TOOLS_ENABLED
if (EditorSettings::get_singleton()) {
@@ -134,7 +122,7 @@ private:
res_data_dir = "res://.mono";
res_metadata_dir = res_data_dir.plus_file("metadata");
res_assemblies_base_dir = res_data_dir.plus_file("assemblies");
- res_assemblies_dir = res_assemblies_base_dir.plus_file(_get_expected_api_build_config());
+ res_assemblies_dir = res_assemblies_base_dir.plus_file(GDMono::get_expected_api_build_config());
res_config_dir = res_data_dir.plus_file("etc").plus_file("mono");
// TODO use paths from csproj
diff --git a/modules/mono/mono_gd/gd_mono.cpp b/modules/mono/mono_gd/gd_mono.cpp
index 544bfc4615..0a34404154 100644
--- a/modules/mono/mono_gd/gd_mono.cpp
+++ b/modules/mono/mono_gd/gd_mono.cpp
@@ -381,10 +381,10 @@ void GDMono::initialize_load_assemblies() {
}
bool GDMono::_are_api_assemblies_out_of_sync() {
- bool out_of_sync = core_api_assembly && (core_api_assembly_out_of_sync || !GDMonoUtils::mono_cache.godot_api_cache_updated);
+ bool out_of_sync = core_api_assembly.assembly && (core_api_assembly.out_of_sync || !GDMonoUtils::mono_cache.godot_api_cache_updated);
#ifdef TOOLS_ENABLED
if (!out_of_sync)
- out_of_sync = editor_api_assembly && editor_api_assembly_out_of_sync;
+ out_of_sync = editor_api_assembly.assembly && editor_api_assembly.out_of_sync;
#endif
return out_of_sync;
}
@@ -523,10 +523,10 @@ bool GDMono::load_assembly_from(const String &p_name, const String &p_path, GDMo
return true;
}
-APIAssembly::Version APIAssembly::Version::get_from_loaded_assembly(GDMonoAssembly *p_api_assembly, APIAssembly::Type p_api_type) {
- APIAssembly::Version api_assembly_version;
+ApiAssemblyInfo::Version ApiAssemblyInfo::Version::get_from_loaded_assembly(GDMonoAssembly *p_api_assembly, ApiAssemblyInfo::Type p_api_type) {
+ ApiAssemblyInfo::Version api_assembly_version;
- const char *nativecalls_name = p_api_type == APIAssembly::API_CORE ?
+ const char *nativecalls_name = p_api_type == ApiAssemblyInfo::API_CORE ?
BINDINGS_CLASS_NATIVECALLS :
BINDINGS_CLASS_NATIVECALLS_EDITOR;
@@ -549,8 +549,8 @@ APIAssembly::Version APIAssembly::Version::get_from_loaded_assembly(GDMonoAssemb
return api_assembly_version;
}
-String APIAssembly::to_string(APIAssembly::Type p_type) {
- return p_type == APIAssembly::API_CORE ? "API_CORE" : "API_EDITOR";
+String ApiAssemblyInfo::to_string(ApiAssemblyInfo::Type p_type) {
+ return p_type == ApiAssemblyInfo::API_CORE ? "API_CORE" : "API_EDITOR";
}
bool GDMono::_load_corlib_assembly() {
@@ -567,16 +567,12 @@ bool GDMono::_load_corlib_assembly() {
}
#ifdef TOOLS_ENABLED
-bool GDMono::copy_prebuilt_api_assembly(APIAssembly::Type p_api_type, const String &p_config) {
-
- bool &api_assembly_out_of_sync = (p_api_type == APIAssembly::API_CORE) ?
- GDMono::get_singleton()->core_api_assembly_out_of_sync :
- GDMono::get_singleton()->editor_api_assembly_out_of_sync;
+bool GDMono::copy_prebuilt_api_assembly(ApiAssemblyInfo::Type p_api_type, const String &p_config) {
String src_dir = GodotSharpDirs::get_data_editor_prebuilt_api_dir().plus_file(p_config);
String dst_dir = GodotSharpDirs::get_res_assemblies_base_dir().plus_file(p_config);
- String assembly_name = p_api_type == APIAssembly::API_CORE ? CORE_API_ASSEMBLY_NAME : EDITOR_API_ASSEMBLY_NAME;
+ String assembly_name = p_api_type == ApiAssemblyInfo::API_CORE ? CORE_API_ASSEMBLY_NAME : EDITOR_API_ASSEMBLY_NAME;
// Create destination directory if needed
if (!DirAccess::exists(dst_dir)) {
@@ -590,35 +586,102 @@ bool GDMono::copy_prebuilt_api_assembly(APIAssembly::Type p_api_type, const Stri
}
}
+ DirAccessRef da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
+
+ String xml_file = assembly_name + ".xml";
+ if (da->copy(src_dir.plus_file(xml_file), dst_dir.plus_file(xml_file)) != OK)
+ WARN_PRINTS("Failed to copy '" + xml_file + "'.");
+
+ String pdb_file = assembly_name + ".pdb";
+ if (da->copy(src_dir.plus_file(pdb_file), dst_dir.plus_file(pdb_file)) != OK)
+ WARN_PRINTS("Failed to copy '" + pdb_file + "'.");
+
String assembly_file = assembly_name + ".dll";
- String assembly_src = src_dir.plus_file(assembly_file);
- String assembly_dst = dst_dir.plus_file(assembly_file);
+ if (da->copy(src_dir.plus_file(assembly_file), dst_dir.plus_file(assembly_file)) != OK) {
+ ERR_PRINTS("Failed to copy '" + assembly_file + "'.");
+ return false;
+ }
- if (!FileAccess::exists(assembly_dst) || api_assembly_out_of_sync) {
- DirAccessRef da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
+ return true;
+}
- String xml_file = assembly_name + ".xml";
- if (da->copy(src_dir.plus_file(xml_file), dst_dir.plus_file(xml_file)) != OK)
- WARN_PRINTS("Failed to copy '" + xml_file + "'.");
+static bool try_get_cached_api_hash_for(const String &p_api_assemblies_dir, bool &r_out_of_sync) {
+ String core_api_assembly_path = p_api_assemblies_dir.plus_file(CORE_API_ASSEMBLY_NAME ".dll");
+ String editor_api_assembly_path = p_api_assemblies_dir.plus_file(EDITOR_API_ASSEMBLY_NAME ".dll");
- String pdb_file = assembly_name + ".pdb";
- if (da->copy(src_dir.plus_file(pdb_file), dst_dir.plus_file(pdb_file)) != OK)
- WARN_PRINTS("Failed to copy '" + pdb_file + "'.");
+ if (!FileAccess::exists(core_api_assembly_path) || !FileAccess::exists(editor_api_assembly_path))
+ return false;
- Error err = da->copy(assembly_src, assembly_dst);
+ String cached_api_hash_path = p_api_assemblies_dir.plus_file("api_hash_cache.cfg");
- if (err != OK) {
- ERR_PRINTS("Failed to copy '" + assembly_file + "'.");
- return false;
- }
+ if (!FileAccess::exists(cached_api_hash_path))
+ return false;
+
+ Ref<ConfigFile> cfg;
+ cfg.instance();
+ Error cfg_err = cfg->load(cached_api_hash_path);
+ ERR_FAIL_COND_V(cfg_err != OK, false);
- api_assembly_out_of_sync = false;
+ // Checking the modified time is good enough
+ if (FileAccess::get_modified_time(core_api_assembly_path) != (uint64_t)cfg->get_value("core", "modified_time") ||
+ FileAccess::get_modified_time(editor_api_assembly_path) != (uint64_t)cfg->get_value("editor", "modified_time")) {
+ return false;
}
+ r_out_of_sync = GodotSharpBindings::get_bindings_version() != (uint32_t)cfg->get_value("core", "bindings_version") ||
+ GodotSharpBindings::get_cs_glue_version() != (uint32_t)cfg->get_value("core", "cs_glue_version") ||
+ GodotSharpBindings::get_bindings_version() != (uint32_t)cfg->get_value("editor", "bindings_version") ||
+ GodotSharpBindings::get_cs_glue_version() != (uint32_t)cfg->get_value("editor", "cs_glue_version") ||
+ GodotSharpBindings::get_core_api_hash() != (uint64_t)cfg->get_value("core", "api_hash") ||
+ GodotSharpBindings::get_editor_api_hash() != (uint64_t)cfg->get_value("editor", "api_hash");
+
return true;
}
-String GDMono::update_api_assemblies_from_prebuilt() {
+static void create_cached_api_hash_for(const String &p_api_assemblies_dir) {
+
+ String core_api_assembly_path = p_api_assemblies_dir.plus_file(CORE_API_ASSEMBLY_NAME ".dll");
+ String editor_api_assembly_path = p_api_assemblies_dir.plus_file(EDITOR_API_ASSEMBLY_NAME ".dll");
+ String cached_api_hash_path = p_api_assemblies_dir.plus_file("api_hash_cache.cfg");
+
+ Ref<ConfigFile> cfg;
+ cfg.instance();
+
+ cfg->set_value("core", "modified_time", FileAccess::get_modified_time(core_api_assembly_path));
+ cfg->set_value("editor", "modified_time", FileAccess::get_modified_time(editor_api_assembly_path));
+
+ cfg->set_value("core", "bindings_version", GodotSharpBindings::get_bindings_version());
+ cfg->set_value("core", "cs_glue_version", GodotSharpBindings::get_cs_glue_version());
+ cfg->set_value("editor", "bindings_version", GodotSharpBindings::get_bindings_version());
+ cfg->set_value("editor", "cs_glue_version", GodotSharpBindings::get_cs_glue_version());
+
+ // This assumes the prebuilt api assemblies we copied to the project are not out of sync
+ cfg->set_value("core", "api_hash", GodotSharpBindings::get_core_api_hash());
+ cfg->set_value("editor", "api_hash", GodotSharpBindings::get_editor_api_hash());
+
+ Error err = cfg->save(cached_api_hash_path);
+ ERR_FAIL_COND(err != OK);
+}
+
+bool GDMono::_temp_domain_load_are_assemblies_out_of_sync(const String &p_config) {
+ MonoDomain *temp_domain = GDMonoUtils::create_domain("GodotEngine.Domain.CheckApiAssemblies");
+ ERR_FAIL_NULL_V(temp_domain, "Failed to create temporary domain to check API assemblies");
+ _GDMONO_SCOPE_EXIT_DOMAIN_UNLOAD_(temp_domain);
+
+ _GDMONO_SCOPE_DOMAIN_(temp_domain);
+
+ GDMono::LoadedApiAssembly temp_core_api_assembly;
+ GDMono::LoadedApiAssembly temp_editor_api_assembly;
+
+ if (!_try_load_api_assemblies(temp_core_api_assembly, temp_editor_api_assembly,
+ p_config, /* refonly: */ true, /* loaded_callback: */ NULL)) {
+ return temp_core_api_assembly.out_of_sync || temp_editor_api_assembly.out_of_sync;
+ }
+
+ return true; // Failed to load, assume they're outdated assemblies
+}
+
+String GDMono::update_api_assemblies_from_prebuilt(const String &p_config, const bool *p_core_api_out_of_sync, const bool *p_editor_api_out_of_sync) {
#define FAIL_REASON(m_out_of_sync, m_prebuilt_exists) \
( \
@@ -629,46 +692,55 @@ String GDMono::update_api_assemblies_from_prebuilt() {
String("and the prebuilt assemblies are missing.") : \
String("and we failed to copy the prebuilt assemblies.")))
- bool api_assembly_out_of_sync = core_api_assembly_out_of_sync || editor_api_assembly_out_of_sync;
+ String dst_assemblies_dir = GodotSharpDirs::get_res_assemblies_base_dir().plus_file(p_config);
- String core_assembly_path = GodotSharpDirs::get_res_assemblies_dir().plus_file(CORE_API_ASSEMBLY_NAME ".dll");
- String editor_assembly_path = GodotSharpDirs::get_res_assemblies_dir().plus_file(EDITOR_API_ASSEMBLY_NAME ".dll");
+ String core_assembly_path = dst_assemblies_dir.plus_file(CORE_API_ASSEMBLY_NAME ".dll");
+ String editor_assembly_path = dst_assemblies_dir.plus_file(EDITOR_API_ASSEMBLY_NAME ".dll");
- if (!api_assembly_out_of_sync && FileAccess::exists(core_assembly_path) && FileAccess::exists(editor_assembly_path))
- return String(); // No update needed
+ bool api_assemblies_out_of_sync = false;
- const int CONFIGS_LEN = 2;
- String configs[CONFIGS_LEN] = { String("Debug"), String("Release") };
+ if (p_core_api_out_of_sync && p_editor_api_out_of_sync) {
+ api_assemblies_out_of_sync = p_core_api_out_of_sync || p_editor_api_out_of_sync;
+ } else if (FileAccess::exists(core_assembly_path) && FileAccess::exists(editor_assembly_path)) {
+ // Determine if they're out of sync
+ if (!try_get_cached_api_hash_for(dst_assemblies_dir, api_assemblies_out_of_sync)) {
+ api_assemblies_out_of_sync = _temp_domain_load_are_assemblies_out_of_sync(p_config);
+ }
+ }
- for (int i = 0; i < CONFIGS_LEN; i++) {
- String config = configs[i];
+ // Note: Even if only one of the assemblies if missing or out of sync, we update both
- print_verbose("Updating '" + config + "' API assemblies");
+ if (!api_assemblies_out_of_sync && FileAccess::exists(core_assembly_path) && FileAccess::exists(editor_assembly_path))
+ return String(); // No update needed
- String prebuilt_api_dir = GodotSharpDirs::get_data_editor_prebuilt_api_dir().plus_file(config);
- String prebuilt_core_dll_path = prebuilt_api_dir.plus_file(CORE_API_ASSEMBLY_NAME ".dll");
- String prebuilt_editor_dll_path = prebuilt_api_dir.plus_file(EDITOR_API_ASSEMBLY_NAME ".dll");
+ print_verbose("Updating '" + p_config + "' API assemblies");
- if (!FileAccess::exists(prebuilt_core_dll_path) || !FileAccess::exists(prebuilt_editor_dll_path)) {
- return FAIL_REASON(api_assembly_out_of_sync, /* prebuilt_exists: */ false);
- }
+ String prebuilt_api_dir = GodotSharpDirs::get_data_editor_prebuilt_api_dir().plus_file(p_config);
+ String prebuilt_core_dll_path = prebuilt_api_dir.plus_file(CORE_API_ASSEMBLY_NAME ".dll");
+ String prebuilt_editor_dll_path = prebuilt_api_dir.plus_file(EDITOR_API_ASSEMBLY_NAME ".dll");
- // Copy the prebuilt Api
- if (!copy_prebuilt_api_assembly(APIAssembly::API_CORE, config) ||
- !copy_prebuilt_api_assembly(APIAssembly::API_EDITOR, config)) {
- return FAIL_REASON(api_assembly_out_of_sync, /* prebuilt_exists: */ true);
- }
+ if (!FileAccess::exists(prebuilt_core_dll_path) || !FileAccess::exists(prebuilt_editor_dll_path)) {
+ return FAIL_REASON(api_assemblies_out_of_sync, /* prebuilt_exists: */ false);
}
+ // Copy the prebuilt Api
+ if (!copy_prebuilt_api_assembly(ApiAssemblyInfo::API_CORE, p_config) ||
+ !copy_prebuilt_api_assembly(ApiAssemblyInfo::API_EDITOR, p_config)) {
+ return FAIL_REASON(api_assemblies_out_of_sync, /* prebuilt_exists: */ true);
+ }
+
+ // Cache the api hash of the assemblies we just copied
+ create_cached_api_hash_for(dst_assemblies_dir);
+
return String(); // Updated successfully
#undef FAIL_REASON
}
#endif
-bool GDMono::_load_core_api_assembly() {
+bool GDMono::_load_core_api_assembly(LoadedApiAssembly &r_loaded_api_assembly, const String &p_config, bool p_refonly) {
- if (core_api_assembly)
+ if (r_loaded_api_assembly.assembly)
return true;
#ifdef TOOLS_ENABLED
@@ -676,101 +748,115 @@ bool GDMono::_load_core_api_assembly() {
// If running the project manager, load it from the prebuilt API directory
String assembly_dir = !Main::is_project_manager() ?
- GodotSharpDirs::get_res_assemblies_dir() :
- GodotSharpDirs::get_data_editor_prebuilt_api_dir().plus_file("Debug");
+ GodotSharpDirs::get_res_assemblies_base_dir().plus_file(p_config) :
+ GodotSharpDirs::get_data_editor_prebuilt_api_dir().plus_file(p_config);
String assembly_path = assembly_dir.plus_file(CORE_API_ASSEMBLY_NAME ".dll");
bool success = FileAccess::exists(assembly_path) &&
- load_assembly_from(CORE_API_ASSEMBLY_NAME, assembly_path, &core_api_assembly);
+ load_assembly_from(CORE_API_ASSEMBLY_NAME, assembly_path, &r_loaded_api_assembly.assembly, p_refonly);
#else
- bool success = load_assembly(CORE_API_ASSEMBLY_NAME, &core_api_assembly);
+ bool success = load_assembly(CORE_API_ASSEMBLY_NAME, &core_api_assembly, p_refonly);
#endif
if (success) {
- APIAssembly::Version api_assembly_ver = APIAssembly::Version::get_from_loaded_assembly(core_api_assembly, APIAssembly::API_CORE);
- core_api_assembly_out_of_sync = GodotSharpBindings::get_core_api_hash() != api_assembly_ver.godot_api_hash ||
- GodotSharpBindings::get_bindings_version() != api_assembly_ver.bindings_version ||
- GodotSharpBindings::get_cs_glue_version() != api_assembly_ver.cs_glue_version;
- if (!core_api_assembly_out_of_sync) {
- GDMonoUtils::update_godot_api_cache();
-
- _install_trace_listener();
- }
+ ApiAssemblyInfo::Version api_assembly_ver = ApiAssemblyInfo::Version::get_from_loaded_assembly(r_loaded_api_assembly.assembly, ApiAssemblyInfo::API_CORE);
+ r_loaded_api_assembly.out_of_sync = GodotSharpBindings::get_core_api_hash() != api_assembly_ver.godot_api_hash ||
+ GodotSharpBindings::get_bindings_version() != api_assembly_ver.bindings_version ||
+ GodotSharpBindings::get_cs_glue_version() != api_assembly_ver.cs_glue_version;
} else {
- core_api_assembly_out_of_sync = false;
+ r_loaded_api_assembly.out_of_sync = false;
}
return success;
}
#ifdef TOOLS_ENABLED
-bool GDMono::_load_editor_api_assembly() {
+bool GDMono::_load_editor_api_assembly(LoadedApiAssembly &r_loaded_api_assembly, const String &p_config, bool p_refonly) {
- if (editor_api_assembly)
+ if (r_loaded_api_assembly.assembly)
return true;
// For the editor and the editor player we want to load it from a specific path to make sure we can keep it up to date
// If running the project manager, load it from the prebuilt API directory
String assembly_dir = !Main::is_project_manager() ?
- GodotSharpDirs::get_res_assemblies_dir() :
- GodotSharpDirs::get_data_editor_prebuilt_api_dir().plus_file("Debug");
+ GodotSharpDirs::get_res_assemblies_base_dir().plus_file(p_config) :
+ GodotSharpDirs::get_data_editor_prebuilt_api_dir().plus_file(p_config);
String assembly_path = assembly_dir.plus_file(EDITOR_API_ASSEMBLY_NAME ".dll");
bool success = FileAccess::exists(assembly_path) &&
- load_assembly_from(EDITOR_API_ASSEMBLY_NAME, assembly_path, &editor_api_assembly);
+ load_assembly_from(EDITOR_API_ASSEMBLY_NAME, assembly_path, &r_loaded_api_assembly.assembly, p_refonly);
if (success) {
- APIAssembly::Version api_assembly_ver = APIAssembly::Version::get_from_loaded_assembly(editor_api_assembly, APIAssembly::API_EDITOR);
- editor_api_assembly_out_of_sync = GodotSharpBindings::get_editor_api_hash() != api_assembly_ver.godot_api_hash ||
- GodotSharpBindings::get_bindings_version() != api_assembly_ver.bindings_version ||
- GodotSharpBindings::get_cs_glue_version() != api_assembly_ver.cs_glue_version;
+ ApiAssemblyInfo::Version api_assembly_ver = ApiAssemblyInfo::Version::get_from_loaded_assembly(r_loaded_api_assembly.assembly, ApiAssemblyInfo::API_EDITOR);
+ r_loaded_api_assembly.out_of_sync = GodotSharpBindings::get_editor_api_hash() != api_assembly_ver.godot_api_hash ||
+ GodotSharpBindings::get_bindings_version() != api_assembly_ver.bindings_version ||
+ GodotSharpBindings::get_cs_glue_version() != api_assembly_ver.cs_glue_version;
} else {
- editor_api_assembly_out_of_sync = false;
+ r_loaded_api_assembly.out_of_sync = false;
}
return success;
}
#endif
-bool GDMono::_try_load_api_assemblies() {
-
- if (!_load_core_api_assembly()) {
+bool GDMono::_try_load_api_assemblies(LoadedApiAssembly &r_core_api_assembly, LoadedApiAssembly &r_editor_api_assembly,
+ const String &p_config, bool p_refonly, CoreApiAssemblyLoadedCallback p_callback) {
+ if (!_load_core_api_assembly(r_core_api_assembly, p_config, p_refonly)) {
if (OS::get_singleton()->is_stdout_verbose())
print_error("Mono: Failed to load Core API assembly");
return false;
}
#ifdef TOOLS_ENABLED
- if (!_load_editor_api_assembly()) {
+ if (!_load_editor_api_assembly(r_editor_api_assembly, p_config, p_refonly)) {
if (OS::get_singleton()->is_stdout_verbose())
print_error("Mono: Failed to load Editor API assembly");
return false;
}
- if (editor_api_assembly_out_of_sync)
+ if (r_editor_api_assembly.out_of_sync)
return false;
#endif
// Check if the core API assembly is out of sync only after trying to load the
// editor API assembly. Otherwise, if both assemblies are out of sync, we would
// only update the former as we won't know the latter also needs to be updated.
- if (core_api_assembly_out_of_sync || !GDMonoUtils::mono_cache.godot_api_cache_updated)
+ if (r_core_api_assembly.out_of_sync)
return false;
+ if (p_callback)
+ return p_callback();
+
return true;
}
+bool GDMono::_on_core_api_assembly_loaded() {
+ GDMonoUtils::update_godot_api_cache();
+
+ if (!GDMonoUtils::mono_cache.godot_api_cache_updated)
+ return false;
+
+ get_singleton()->_install_trace_listener();
+
+ return true;
+}
+
+bool GDMono::_try_load_api_assemblies_preset() {
+ return _try_load_api_assemblies(core_api_assembly, editor_api_assembly,
+ get_expected_api_build_config(), /* refonly: */ false, _on_core_api_assembly_loaded);
+}
+
void GDMono::_load_api_assemblies() {
- bool api_assemblies_loaded = _try_load_api_assemblies();
+ bool api_assemblies_loaded = _try_load_api_assemblies_preset();
if (!api_assemblies_loaded) {
#ifdef TOOLS_ENABLED
- // The API assemblies are out of sync. Fine, try one more time, but this time
- // update them from the prebuilt assemblies directory before trying to load them.
+ // The API assemblies are out of sync or some other error happened. Fine, try one more time, but
+ // this time update them from the prebuilt assemblies directory before trying to load them again.
// Shouldn't happen. The project manager loads the prebuilt API assemblies
CRASH_COND_MSG(Main::is_project_manager(), "Failed to load one of the prebuilt API assemblies.");
@@ -780,7 +866,7 @@ void GDMono::_load_api_assemblies() {
CRASH_COND_MSG(domain_unload_err != OK, "Mono: Failed to unload scripts domain.");
// 2. Update the API assemblies
- String update_error = update_api_assemblies_from_prebuilt();
+ String update_error = update_api_assemblies_from_prebuilt("Debug", &core_api_assembly.out_of_sync, &editor_api_assembly.out_of_sync);
CRASH_COND_MSG(!update_error.empty(), update_error);
// 3. Load the scripts domain again
@@ -788,7 +874,7 @@ void GDMono::_load_api_assemblies() {
CRASH_COND_MSG(domain_load_err != OK, "Mono: Failed to load scripts domain.");
// 4. Try loading the updated assemblies
- api_assemblies_loaded = _try_load_api_assemblies();
+ api_assemblies_loaded = _try_load_api_assemblies_preset();
#endif
}
@@ -796,14 +882,14 @@ void GDMono::_load_api_assemblies() {
// welp... too bad
if (_are_api_assemblies_out_of_sync()) {
- if (core_api_assembly_out_of_sync) {
+ if (core_api_assembly.out_of_sync) {
ERR_PRINT("The assembly '" CORE_API_ASSEMBLY_NAME "' is out of sync.");
} else if (!GDMonoUtils::mono_cache.godot_api_cache_updated) {
ERR_PRINT("The loaded assembly '" CORE_API_ASSEMBLY_NAME "' is in sync, but the cache update failed.");
}
#ifdef TOOLS_ENABLED
- if (editor_api_assembly_out_of_sync) {
+ if (editor_api_assembly.out_of_sync) {
ERR_PRINT("The assembly '" EDITOR_API_ASSEMBLY_NAME "' is out of sync.");
}
#endif
@@ -852,15 +938,14 @@ void GDMono::_install_trace_listener() {
#ifdef DEBUG_ENABLED
// Install the trace listener now before the project assembly is loaded
- typedef void (*DebuggingUtils_InstallTraceListener)(MonoObject **);
+ GDMonoClass *debug_utils = get_core_api_assembly()->get_class(BINDINGS_NAMESPACE, "DebuggingUtils");
+ GDMonoMethod *install_func = debug_utils->get_method("InstallTraceListener");
+
MonoException *exc = NULL;
- GDMonoClass *debug_utils = core_api_assembly->get_class(BINDINGS_NAMESPACE, "DebuggingUtils");
- DebuggingUtils_InstallTraceListener install_func =
- (DebuggingUtils_InstallTraceListener)debug_utils->get_method_thunk("InstallTraceListener");
- install_func((MonoObject **)&exc);
+ install_func->invoke_raw(NULL, NULL, &exc);
if (exc) {
- ERR_PRINT("Failed to install 'System.Diagnostics.Trace' listener.");
GDMonoUtils::debug_print_unhandled_exception(exc);
+ ERR_PRINT("Failed to install 'System.Diagnostics.Trace' listener.");
}
#endif
}
@@ -871,7 +956,7 @@ Error GDMono::_load_scripts_domain() {
print_verbose("Mono: Loading scripts domain...");
- scripts_domain = GDMonoUtils::create_domain("GodotEngine.ScriptsDomain");
+ scripts_domain = GDMonoUtils::create_domain("GodotEngine.Domain.Scripts");
ERR_FAIL_NULL_V_MSG(scripts_domain, ERR_CANT_CREATE, "Mono: Could not create scripts app domain.");
@@ -903,10 +988,8 @@ Error GDMono::_unload_scripts_domain() {
_domain_assemblies_cleanup(mono_domain_get_id(scripts_domain));
- core_api_assembly = NULL;
project_assembly = NULL;
#ifdef TOOLS_ENABLED
- editor_api_assembly = NULL;
tools_assembly = NULL;
tools_project_editor_assembly = NULL;
#endif
@@ -1076,16 +1159,9 @@ GDMono::GDMono() {
root_domain = NULL;
scripts_domain = NULL;
- core_api_assembly_out_of_sync = false;
-#ifdef TOOLS_ENABLED
- editor_api_assembly_out_of_sync = false;
-#endif
-
corlib_assembly = NULL;
- core_api_assembly = NULL;
project_assembly = NULL;
#ifdef TOOLS_ENABLED
- editor_api_assembly = NULL;
tools_assembly = NULL;
tools_project_editor_assembly = NULL;
#endif
diff --git a/modules/mono/mono_gd/gd_mono.h b/modules/mono/mono_gd/gd_mono.h
index 343d68bc2d..e14a0d8409 100644
--- a/modules/mono/mono_gd/gd_mono.h
+++ b/modules/mono/mono_gd/gd_mono.h
@@ -41,7 +41,7 @@
#include "../utils/mono_reg_utils.h"
#endif
-namespace APIAssembly {
+namespace ApiAssemblyInfo {
enum Type {
API_CORE,
API_EDITOR
@@ -76,7 +76,7 @@ struct Version {
};
String to_string(Type p_type);
-} // namespace APIAssembly
+} // namespace ApiAssemblyInfo
class GDMono {
@@ -86,44 +86,58 @@ public:
POLICY_LOG_ERROR
};
+ struct LoadedApiAssembly {
+ GDMonoAssembly *assembly;
+ bool out_of_sync;
+
+ LoadedApiAssembly() :
+ assembly(NULL),
+ out_of_sync(false) {
+ }
+ };
+
private:
bool runtime_initialized;
bool finalizing_scripts_domain;
+ UnhandledExceptionPolicy unhandled_exception_policy;
+
MonoDomain *root_domain;
MonoDomain *scripts_domain;
- bool core_api_assembly_out_of_sync;
-#ifdef TOOLS_ENABLED
- bool editor_api_assembly_out_of_sync;
-#endif
+ HashMap<uint32_t, HashMap<String, GDMonoAssembly *> > assemblies;
GDMonoAssembly *corlib_assembly;
- GDMonoAssembly *core_api_assembly;
GDMonoAssembly *project_assembly;
#ifdef TOOLS_ENABLED
- GDMonoAssembly *editor_api_assembly;
GDMonoAssembly *tools_assembly;
GDMonoAssembly *tools_project_editor_assembly;
#endif
- HashMap<uint32_t, HashMap<String, GDMonoAssembly *> > assemblies;
-
- UnhandledExceptionPolicy unhandled_exception_policy;
+ LoadedApiAssembly core_api_assembly;
+ LoadedApiAssembly editor_api_assembly;
- void _domain_assemblies_cleanup(uint32_t p_domain_id);
+ typedef bool (*CoreApiAssemblyLoadedCallback)();
bool _are_api_assemblies_out_of_sync();
+ bool _temp_domain_load_are_assemblies_out_of_sync(const String &p_config);
+
+ bool _load_core_api_assembly(LoadedApiAssembly &r_loaded_api_assembly, const String &p_config, bool p_refonly);
+#ifdef TOOLS_ENABLED
+ bool _load_editor_api_assembly(LoadedApiAssembly &r_loaded_api_assembly, const String &p_config, bool p_refonly);
+#endif
+
+ static bool _on_core_api_assembly_loaded();
bool _load_corlib_assembly();
- bool _load_core_api_assembly();
#ifdef TOOLS_ENABLED
- bool _load_editor_api_assembly();
bool _load_tools_assemblies();
#endif
bool _load_project_assembly();
- bool _try_load_api_assemblies();
+ bool _try_load_api_assemblies(LoadedApiAssembly &r_core_api_assembly, LoadedApiAssembly &r_editor_api_assembly,
+ const String &p_config, bool p_refonly, CoreApiAssemblyLoadedCallback p_callback);
+ bool _try_load_api_assemblies_preset();
void _load_api_assemblies();
void _install_trace_listener();
@@ -133,6 +147,8 @@ private:
Error _load_scripts_domain();
Error _unload_scripts_domain();
+ void _domain_assemblies_cleanup(uint32_t p_domain_id);
+
uint64_t api_core_hash;
#ifdef TOOLS_ENABLED
uint64_t api_editor_hash;
@@ -166,9 +182,21 @@ public:
#endif // TOOLS_ENABLED
#endif // DEBUG_METHODS_ENABLED
+ _FORCE_INLINE_ static String get_expected_api_build_config() {
+#ifdef TOOLS_ENABLED
+ return "Debug";
+#else
+#ifdef DEBUG_ENABLED
+ return "Debug";
+#else
+ return "Release";
+#endif
+#endif
+ }
+
#ifdef TOOLS_ENABLED
- bool copy_prebuilt_api_assembly(APIAssembly::Type p_api_type, const String &p_config);
- String update_api_assemblies_from_prebuilt();
+ bool copy_prebuilt_api_assembly(ApiAssemblyInfo::Type p_api_type, const String &p_config);
+ String update_api_assemblies_from_prebuilt(const String &p_config, const bool *p_core_api_out_of_sync = NULL, const bool *p_editor_api_out_of_sync = NULL);
#endif
static GDMono *get_singleton() { return singleton; }
@@ -188,10 +216,10 @@ public:
_FORCE_INLINE_ MonoDomain *get_scripts_domain() { return scripts_domain; }
_FORCE_INLINE_ GDMonoAssembly *get_corlib_assembly() const { return corlib_assembly; }
- _FORCE_INLINE_ GDMonoAssembly *get_core_api_assembly() const { return core_api_assembly; }
+ _FORCE_INLINE_ GDMonoAssembly *get_core_api_assembly() const { return core_api_assembly.assembly; }
_FORCE_INLINE_ GDMonoAssembly *get_project_assembly() const { return project_assembly; }
#ifdef TOOLS_ENABLED
- _FORCE_INLINE_ GDMonoAssembly *get_editor_api_assembly() const { return editor_api_assembly; }
+ _FORCE_INLINE_ GDMonoAssembly *get_editor_api_assembly() const { return editor_api_assembly.assembly; }
_FORCE_INLINE_ GDMonoAssembly *get_tools_assembly() const { return tools_assembly; }
_FORCE_INLINE_ GDMonoAssembly *get_tools_project_editor_assembly() const { return tools_project_editor_assembly; }
#endif
diff --git a/modules/mono/mono_gd/gd_mono_utils.cpp b/modules/mono/mono_gd/gd_mono_utils.cpp
index e385f4c601..6504fbe423 100644
--- a/modules/mono/mono_gd/gd_mono_utils.cpp
+++ b/modules/mono/mono_gd/gd_mono_utils.cpp
@@ -550,6 +550,8 @@ MonoObject *create_managed_from(const Dictionary &p_from, GDMonoClass *p_class)
}
MonoDomain *create_domain(const String &p_friendly_name) {
+ print_verbose("Mono: Creating domain '" + p_friendly_name + "'...");
+
MonoDomain *domain = mono_domain_create_appdomain((char *)p_friendly_name.utf8().get_data(), NULL);
if (domain) {
diff --git a/modules/websocket/doc_classes/WebSocketClient.xml b/modules/websocket/doc_classes/WebSocketClient.xml
index c3baf9de83..705e3485f5 100644
--- a/modules/websocket/doc_classes/WebSocketClient.xml
+++ b/modules/websocket/doc_classes/WebSocketClient.xml
@@ -21,10 +21,13 @@
</argument>
<argument index="2" name="gd_mp_api" type="bool" default="false">
</argument>
+ <argument index="3" name="custom_headers" type="PoolStringArray" default="PoolStringArray( )">
+ </argument>
<description>
Connects to the given URL requesting one of the given [code]protocols[/code] as sub-protocol. If the list empty (default), no sub-protocol will be requested.
If [code]true[/code] is passed as [code]gd_mp_api[/code], the client will behave like a network peer for the [MultiplayerAPI], connections to non-Godot servers will not work, and [signal data_received] will not be emitted.
If [code]false[/code] is passed instead (default), you must call [PacketPeer] functions ([code]put_packet[/code], [code]get_packet[/code], etc.) on the [WebSocketPeer] returned via [code]get_peer(1)[/code] and not on this object directly (e.g. [code]get_peer(1).put_packet(data)[/code]).
+ You can optionally pass a list of [code]custom_headers[/code] to be added to the handshake HTTP request (not supported in HTML5 platform).
</description>
</method>
<method name="disconnect_from_host">
@@ -38,8 +41,25 @@
Disconnects this client from the connected host. See [method WebSocketPeer.close] for more information.
</description>
</method>
+ <method name="get_connected_host" qualifiers="const">
+ <return type="String">
+ </return>
+ <description>
+ Return the IP address of the currently connected host.
+ </description>
+ </method>
+ <method name="get_connected_port" qualifiers="const">
+ <return type="int">
+ </return>
+ <description>
+ Return the IP port of the currently connected host.
+ </description>
+ </method>
</methods>
<members>
+ <member name="trusted_ssl_certificate" type="X509Certificate" setter="set_trusted_ssl_certificate" getter="get_trusted_ssl_certificate">
+ If specified, this [X509Certificate] will be the only one accepted when connecting to an SSL host. Any other certificate provided by the server will be regarded as invalid.
+ </member>
<member name="verify_ssl" type="bool" setter="set_verify_ssl_enabled" getter="is_verify_ssl_enabled">
If [code]true[/code], SSL certificate verification is enabled.
[b]Note:[/b] You must specify the certificates to be used in the Project Settings for it to work when exported.
diff --git a/modules/websocket/doc_classes/WebSocketServer.xml b/modules/websocket/doc_classes/WebSocketServer.xml
index 63318e5874..86f2dae64f 100644
--- a/modules/websocket/doc_classes/WebSocketServer.xml
+++ b/modules/websocket/doc_classes/WebSocketServer.xml
@@ -82,6 +82,17 @@
</description>
</method>
</methods>
+ <members>
+ <member name="ca_chain" type="X509Certificate" setter="set_ca_chain" getter="get_ca_chain">
+ When using SSL (see [member private_key] and [member ssl_certificate]), you can set this to a valid [X509Certificate] to be provided as additional CA chain information during the SSL handshake.
+ </member>
+ <member name="private_key" type="CryptoKey" setter="set_private_key" getter="get_private_key">
+ When set to a valid [CryptoKey] (along with [member ssl_certificate]) will cause the server to require SSL instead of regular TCP (i.e. the [code]wss://[/code] protocol).
+ </member>
+ <member name="ssl_certificate" type="X509Certificate" setter="set_ssl_certificate" getter="get_ssl_certificate">
+ When set to a valid [X509Certificate] (along with [member private_key]) will cause the server to require SSL instead of regular TCP (i.e. the [code]wss://[/code] protocol).
+ </member>
+ </members>
<signals>
<signal name="client_close_request">
<argument index="0" name="id" type="int">
diff --git a/modules/websocket/emws_client.cpp b/modules/websocket/emws_client.cpp
index 409cc9f699..fad766ea5d 100644
--- a/modules/websocket/emws_client.cpp
+++ b/modules/websocket/emws_client.cpp
@@ -64,13 +64,20 @@ EMSCRIPTEN_KEEPALIVE void _esws_on_close(void *obj, int code, char *reason, int
}
}
-Error EMWSClient::connect_to_host(String p_host, String p_path, uint16_t p_port, bool p_ssl, PoolVector<String> p_protocols) {
+Error EMWSClient::connect_to_host(String p_host, String p_path, uint16_t p_port, bool p_ssl, const PoolVector<String> p_protocols, const Vector<String> p_custom_headers) {
String proto_string = p_protocols.join(",");
String str = "ws://";
- if (p_ssl)
+ if (p_custom_headers.size()) {
+ WARN_PRINT_ONCE("Custom headers are not supported in in HTML5 platform.");
+ }
+ if (p_ssl) {
str = "wss://";
+ if (ssl_cert.is_valid()) {
+ WARN_PRINT_ONCE("Custom SSL certificate is not supported in HTML5 platform.");
+ }
+ }
str += p_host + ":" + itos(p_port) + p_path;
_is_connecting = true;
@@ -193,12 +200,12 @@ void EMWSClient::disconnect_from_host(int p_code, String p_reason) {
IP_Address EMWSClient::get_connected_host() const {
- return IP_Address();
+ ERR_FAIL_V_MSG(IP_Address(), "Not supported in HTML5 export.");
};
uint16_t EMWSClient::get_connected_port() const {
- return 1025;
+ ERR_FAIL_V_MSG(0, "Not supported in HTML5 export.");
};
int EMWSClient::get_max_packet_size() const {
diff --git a/modules/websocket/emws_client.h b/modules/websocket/emws_client.h
index 1811d05eea..2d35f7f0f6 100644
--- a/modules/websocket/emws_client.h
+++ b/modules/websocket/emws_client.h
@@ -50,7 +50,7 @@ public:
bool _is_connecting;
Error set_buffers(int p_in_buffer, int p_in_packets, int p_out_buffer, int p_out_packets);
- Error connect_to_host(String p_host, String p_path, uint16_t p_port, bool p_ssl, PoolVector<String> p_protocol = PoolVector<String>());
+ Error connect_to_host(String p_host, String p_path, uint16_t p_port, bool p_ssl, const PoolVector<String> p_protocol = PoolVector<String>(), const Dictionary p_custom_headers = Dictionary());
Ref<WebSocketPeer> get_peer(int p_peer_id) const;
void disconnect_from_host(int p_code = 1000, String p_reason = "");
IP_Address get_connected_host() const;
diff --git a/modules/websocket/websocket_client.cpp b/modules/websocket/websocket_client.cpp
index 4ff5404c61..8bbd5aa37f 100644
--- a/modules/websocket/websocket_client.cpp
+++ b/modules/websocket/websocket_client.cpp
@@ -40,7 +40,7 @@ WebSocketClient::WebSocketClient() {
WebSocketClient::~WebSocketClient() {
}
-Error WebSocketClient::connect_to_url(String p_url, PoolVector<String> p_protocols, bool gd_mp_api) {
+Error WebSocketClient::connect_to_url(String p_url, const Vector<String> p_protocols, bool gd_mp_api, const Vector<String> p_custom_headers) {
_is_multiplayer = gd_mp_api;
String host = p_url;
@@ -72,7 +72,7 @@ Error WebSocketClient::connect_to_url(String p_url, PoolVector<String> p_protoco
host = host.substr(0, p_len);
}
- return connect_to_host(host, path, port, ssl, p_protocols);
+ return connect_to_host(host, path, port, ssl, p_protocols, p_custom_headers);
}
void WebSocketClient::set_verify_ssl_enabled(bool p_verify_ssl) {
@@ -85,6 +85,17 @@ bool WebSocketClient::is_verify_ssl_enabled() const {
return verify_ssl;
}
+Ref<X509Certificate> WebSocketClient::get_trusted_ssl_certificate() const {
+
+ return ssl_cert;
+}
+
+void WebSocketClient::set_trusted_ssl_certificate(Ref<X509Certificate> p_cert) {
+
+ ERR_FAIL_COND(get_connection_status() != CONNECTION_DISCONNECTED);
+ ssl_cert = p_cert;
+}
+
bool WebSocketClient::is_server() const {
return false;
@@ -132,13 +143,20 @@ void WebSocketClient::_on_error() {
}
void WebSocketClient::_bind_methods() {
- ClassDB::bind_method(D_METHOD("connect_to_url", "url", "protocols", "gd_mp_api"), &WebSocketClient::connect_to_url, DEFVAL(PoolVector<String>()), DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("connect_to_url", "url", "protocols", "gd_mp_api", "custom_headers"), &WebSocketClient::connect_to_url, DEFVAL(Vector<String>()), DEFVAL(false), DEFVAL(Vector<String>()));
ClassDB::bind_method(D_METHOD("disconnect_from_host", "code", "reason"), &WebSocketClient::disconnect_from_host, DEFVAL(1000), DEFVAL(""));
+ ClassDB::bind_method(D_METHOD("get_connected_host"), &WebSocketClient::get_connected_host);
+ ClassDB::bind_method(D_METHOD("get_connected_port"), &WebSocketClient::get_connected_port);
ClassDB::bind_method(D_METHOD("set_verify_ssl_enabled", "enabled"), &WebSocketClient::set_verify_ssl_enabled);
ClassDB::bind_method(D_METHOD("is_verify_ssl_enabled"), &WebSocketClient::is_verify_ssl_enabled);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "verify_ssl", PROPERTY_HINT_NONE, "", 0), "set_verify_ssl_enabled", "is_verify_ssl_enabled");
+ ClassDB::bind_method(D_METHOD("get_trusted_ssl_certificate"), &WebSocketClient::get_trusted_ssl_certificate);
+ ClassDB::bind_method(D_METHOD("set_trusted_ssl_certificate"), &WebSocketClient::set_trusted_ssl_certificate);
+
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "trusted_ssl_certificate", PROPERTY_HINT_RESOURCE_TYPE, "X509Certificate", 0), "set_trusted_ssl_certificate", "get_trusted_ssl_certificate");
+
ADD_SIGNAL(MethodInfo("data_received"));
ADD_SIGNAL(MethodInfo("connection_established", PropertyInfo(Variant::STRING, "protocol")));
ADD_SIGNAL(MethodInfo("server_close_request", PropertyInfo(Variant::INT, "code"), PropertyInfo(Variant::STRING, "reason")));
diff --git a/modules/websocket/websocket_client.h b/modules/websocket/websocket_client.h
index 7ddb9468a5..08fd6798fe 100644
--- a/modules/websocket/websocket_client.h
+++ b/modules/websocket/websocket_client.h
@@ -31,6 +31,7 @@
#ifndef WEBSOCKET_CLIENT_H
#define WEBSOCKET_CLIENT_H
+#include "core/crypto/crypto.h"
#include "core/error_list.h"
#include "websocket_multiplayer_peer.h"
#include "websocket_peer.h"
@@ -43,17 +44,20 @@ class WebSocketClient : public WebSocketMultiplayerPeer {
protected:
Ref<WebSocketPeer> _peer;
bool verify_ssl;
+ Ref<X509Certificate> ssl_cert;
static void _bind_methods();
public:
- Error connect_to_url(String p_url, PoolVector<String> p_protocols = PoolVector<String>(), bool gd_mp_api = false);
+ Error connect_to_url(String p_url, const Vector<String> p_protocols = Vector<String>(), bool gd_mp_api = false, const Vector<String> p_custom_headers = Vector<String>());
void set_verify_ssl_enabled(bool p_verify_ssl);
bool is_verify_ssl_enabled() const;
+ Ref<X509Certificate> get_trusted_ssl_certificate() const;
+ void set_trusted_ssl_certificate(Ref<X509Certificate> p_cert);
virtual void poll() = 0;
- virtual Error connect_to_host(String p_host, String p_path, uint16_t p_port, bool p_ssl, PoolVector<String> p_protocol = PoolVector<String>()) = 0;
+ virtual Error connect_to_host(String p_host, String p_path, uint16_t p_port, bool p_ssl, const Vector<String> p_protocol = Vector<String>(), const Vector<String> p_custom_headers = Vector<String>()) = 0;
virtual void disconnect_from_host(int p_code = 1000, String p_reason = "") = 0;
virtual IP_Address get_connected_host() const = 0;
virtual uint16_t get_connected_port() const = 0;
diff --git a/modules/websocket/websocket_server.cpp b/modules/websocket/websocket_server.cpp
index ef5f6f5c20..c7414075ed 100644
--- a/modules/websocket/websocket_server.cpp
+++ b/modules/websocket/websocket_server.cpp
@@ -42,19 +42,58 @@ WebSocketServer::~WebSocketServer() {
void WebSocketServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("is_listening"), &WebSocketServer::is_listening);
- ClassDB::bind_method(D_METHOD("listen", "port", "protocols", "gd_mp_api"), &WebSocketServer::listen, DEFVAL(PoolVector<String>()), DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("listen", "port", "protocols", "gd_mp_api"), &WebSocketServer::listen, DEFVAL(Vector<String>()), DEFVAL(false));
ClassDB::bind_method(D_METHOD("stop"), &WebSocketServer::stop);
ClassDB::bind_method(D_METHOD("has_peer", "id"), &WebSocketServer::has_peer);
ClassDB::bind_method(D_METHOD("get_peer_address", "id"), &WebSocketServer::get_peer_address);
ClassDB::bind_method(D_METHOD("get_peer_port", "id"), &WebSocketServer::get_peer_port);
ClassDB::bind_method(D_METHOD("disconnect_peer", "id", "code", "reason"), &WebSocketServer::disconnect_peer, DEFVAL(1000), DEFVAL(""));
+ ClassDB::bind_method(D_METHOD("get_private_key"), &WebSocketServer::get_private_key);
+ ClassDB::bind_method(D_METHOD("set_private_key"), &WebSocketServer::set_private_key);
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "private_key", PROPERTY_HINT_RESOURCE_TYPE, "CryptoKey", 0), "set_private_key", "get_private_key");
+
+ ClassDB::bind_method(D_METHOD("get_ssl_certificate"), &WebSocketServer::get_ssl_certificate);
+ ClassDB::bind_method(D_METHOD("set_ssl_certificate"), &WebSocketServer::set_ssl_certificate);
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "ssl_certificate", PROPERTY_HINT_RESOURCE_TYPE, "X509Certificate", 0), "set_ssl_certificate", "get_ssl_certificate");
+
+ ClassDB::bind_method(D_METHOD("get_ca_chain"), &WebSocketServer::get_ca_chain);
+ ClassDB::bind_method(D_METHOD("set_ca_chain"), &WebSocketServer::set_ca_chain);
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "ca_chain", PROPERTY_HINT_RESOURCE_TYPE, "X509Certificate", 0), "set_ca_chain", "get_ca_chain");
+
ADD_SIGNAL(MethodInfo("client_close_request", PropertyInfo(Variant::INT, "id"), PropertyInfo(Variant::INT, "code"), PropertyInfo(Variant::STRING, "reason")));
ADD_SIGNAL(MethodInfo("client_disconnected", PropertyInfo(Variant::INT, "id"), PropertyInfo(Variant::BOOL, "was_clean_close")));
ADD_SIGNAL(MethodInfo("client_connected", PropertyInfo(Variant::INT, "id"), PropertyInfo(Variant::STRING, "protocol")));
ADD_SIGNAL(MethodInfo("data_received", PropertyInfo(Variant::INT, "id")));
}
+Ref<CryptoKey> WebSocketServer::get_private_key() const {
+ return private_key;
+}
+
+void WebSocketServer::set_private_key(Ref<CryptoKey> p_key) {
+ ERR_FAIL_COND(is_listening());
+ private_key = p_key;
+}
+
+Ref<X509Certificate> WebSocketServer::get_ssl_certificate() const {
+ return ssl_cert;
+}
+
+void WebSocketServer::set_ssl_certificate(Ref<X509Certificate> p_cert) {
+ ERR_FAIL_COND(is_listening());
+ ssl_cert = p_cert;
+}
+
+Ref<X509Certificate> WebSocketServer::get_ca_chain() const {
+ return ca_chain;
+}
+
+void WebSocketServer::set_ca_chain(Ref<X509Certificate> p_ca_chain) {
+ ERR_FAIL_COND(is_listening());
+ ca_chain = p_ca_chain;
+}
+
NetworkedMultiplayerPeer::ConnectionStatus WebSocketServer::get_connection_status() const {
if (is_listening())
return CONNECTION_CONNECTED;
diff --git a/modules/websocket/websocket_server.h b/modules/websocket/websocket_server.h
index 83c0c10419..0b39f94473 100644
--- a/modules/websocket/websocket_server.h
+++ b/modules/websocket/websocket_server.h
@@ -31,6 +31,7 @@
#ifndef WEBSOCKET_H
#define WEBSOCKET_H
+#include "core/crypto/crypto.h"
#include "core/reference.h"
#include "websocket_multiplayer_peer.h"
#include "websocket_peer.h"
@@ -43,9 +44,13 @@ class WebSocketServer : public WebSocketMultiplayerPeer {
protected:
static void _bind_methods();
+ Ref<CryptoKey> private_key;
+ Ref<X509Certificate> ssl_cert;
+ Ref<X509Certificate> ca_chain;
+
public:
virtual void poll() = 0;
- virtual Error listen(int p_port, PoolVector<String> p_protocols = PoolVector<String>(), bool gd_mp_api = false) = 0;
+ virtual Error listen(int p_port, const Vector<String> p_protocols = Vector<String>(), bool gd_mp_api = false) = 0;
virtual void stop() = 0;
virtual bool is_listening() const = 0;
virtual bool has_peer(int p_id) const = 0;
@@ -62,6 +67,15 @@ public:
void _on_disconnect(int32_t p_peer_id, bool p_was_clean);
void _on_close_request(int32_t p_peer_id, int p_code, String p_reason);
+ Ref<CryptoKey> get_private_key() const;
+ void set_private_key(Ref<CryptoKey> p_key);
+
+ Ref<X509Certificate> get_ssl_certificate() const;
+ void set_ssl_certificate(Ref<X509Certificate> p_cert);
+
+ Ref<X509Certificate> get_ca_chain() const;
+ void set_ca_chain(Ref<X509Certificate> p_ca_chain);
+
virtual Error set_buffers(int p_in_buffer, int p_in_packets, int p_out_buffer, int p_out_packets) = 0;
WebSocketServer();
diff --git a/modules/websocket/wsl_client.cpp b/modules/websocket/wsl_client.cpp
index 0006a057e0..a422f65cfc 100644
--- a/modules/websocket/wsl_client.cpp
+++ b/modules/websocket/wsl_client.cpp
@@ -86,6 +86,7 @@ void WSLClient::_do_handshake() {
WSLPeer::PeerData *data = memnew(struct WSLPeer::PeerData);
data->obj = this;
data->conn = _connection;
+ data->tcp = _tcp;
data->is_server = false;
data->id = 1;
_peer->make_context(data, _in_buf_size, _in_pkt_size, _out_buf_size, _out_pkt_size);
@@ -151,7 +152,7 @@ bool WSLClient::_verify_headers(String &r_protocol) {
return true;
}
-Error WSLClient::connect_to_host(String p_host, String p_path, uint16_t p_port, bool p_ssl, PoolVector<String> p_protocols) {
+Error WSLClient::connect_to_host(String p_host, String p_path, uint16_t p_port, bool p_ssl, const Vector<String> p_protocols, const Vector<String> p_custom_headers) {
ERR_FAIL_COND_V(_connection.is_valid(), ERR_ALREADY_IN_USE);
@@ -180,7 +181,8 @@ Error WSLClient::connect_to_host(String p_host, String p_path, uint16_t p_port,
_connection = _tcp;
_use_ssl = p_ssl;
_host = p_host;
- _protocols = p_protocols;
+ _protocols.clear();
+ _protocols.append_array(p_protocols);
_key = WSLPeer::generate_key();
// TODO custom extra headers (allow overriding this too?)
@@ -199,6 +201,9 @@ Error WSLClient::connect_to_host(String p_host, String p_path, uint16_t p_port,
}
request += "\r\n";
}
+ for (int i = 0; i < p_custom_headers.size(); i++) {
+ request += p_custom_headers[i] + "\r\n";
+ }
request += "\r\n";
_request = request.utf8();
@@ -236,7 +241,7 @@ void WSLClient::poll() {
ssl = Ref<StreamPeerSSL>(StreamPeerSSL::create());
ERR_FAIL_COND_MSG(ssl.is_null(), "SSL is not available in this build.");
ssl->set_blocking_handshake_enabled(false);
- if (ssl->connect_to_stream(_tcp, verify_ssl, _host) != OK) {
+ if (ssl->connect_to_stream(_tcp, verify_ssl, _host, ssl_cert) != OK) {
disconnect_from_host();
_on_error();
return;
@@ -293,7 +298,7 @@ void WSLClient::disconnect_from_host(int p_code, String p_reason) {
_key = "";
_host = "";
- _protocols.resize(0);
+ _protocols.clear();
_use_ssl = false;
_request = "";
@@ -305,12 +310,14 @@ void WSLClient::disconnect_from_host(int p_code, String p_reason) {
IP_Address WSLClient::get_connected_host() const {
- return IP_Address();
+ ERR_FAIL_COND_V(!_peer->is_connected_to_host(), IP_Address());
+ return _peer->get_connected_host();
}
uint16_t WSLClient::get_connected_port() const {
- return 1025;
+ ERR_FAIL_COND_V(!_peer->is_connected_to_host(), 0);
+ return _peer->get_connected_port();
}
Error WSLClient::set_buffers(int p_in_buffer, int p_in_packets, int p_out_buffer, int p_out_packets) {
diff --git a/modules/websocket/wsl_client.h b/modules/websocket/wsl_client.h
index 57dfd635b7..870be94a87 100644
--- a/modules/websocket/wsl_client.h
+++ b/modules/websocket/wsl_client.h
@@ -64,7 +64,7 @@ private:
String _key;
String _host;
- PoolVector<String> _protocols;
+ Vector<String> _protocols;
bool _use_ssl;
void _do_handshake();
@@ -72,7 +72,7 @@ private:
public:
Error set_buffers(int p_in_buffer, int p_in_packets, int p_out_buffer, int p_out_packets);
- Error connect_to_host(String p_host, String p_path, uint16_t p_port, bool p_ssl, PoolVector<String> p_protocol = PoolVector<String>());
+ Error connect_to_host(String p_host, String p_path, uint16_t p_port, bool p_ssl, const Vector<String> p_protocol = Vector<String>(), const Vector<String> p_custom_headers = Vector<String>());
int get_max_packet_size() const;
Ref<WebSocketPeer> get_peer(int p_peer_id) const;
void disconnect_from_host(int p_code = 1000, String p_reason = "");
diff --git a/modules/websocket/wsl_peer.cpp b/modules/websocket/wsl_peer.cpp
index 74fb901232..32beccde5d 100644
--- a/modules/websocket/wsl_peer.cpp
+++ b/modules/websocket/wsl_peer.cpp
@@ -208,7 +208,6 @@ void WSLPeer::make_context(PeerData *p_data, unsigned int p_in_buf_size, unsigne
_data = p_data;
_data->peer = this;
_data->valid = true;
- _connection = Ref<StreamPeer>(_data->conn);
if (_data->is_server)
wslay_event_context_server_init(&(_data->ctx), &wsl_callbacks, _data);
@@ -302,18 +301,16 @@ void WSLPeer::close(int p_code, String p_reason) {
IP_Address WSLPeer::get_connected_host() const {
- ERR_FAIL_COND_V(!is_connected_to_host(), IP_Address());
+ ERR_FAIL_COND_V(!is_connected_to_host() || _data->tcp.is_null(), IP_Address());
- IP_Address ip;
- return ip;
+ return _data->tcp->get_connected_host();
}
uint16_t WSLPeer::get_connected_port() const {
- ERR_FAIL_COND_V(!is_connected_to_host(), 0);
+ ERR_FAIL_COND_V(!is_connected_to_host() || _data->tcp.is_null(), 0);
- uint16_t port = 0;
- return port;
+ return _data->tcp->get_connected_port();
}
void WSLPeer::invalidate() {
diff --git a/modules/websocket/wsl_peer.h b/modules/websocket/wsl_peer.h
index d51b304fe1..01ad250468 100644
--- a/modules/websocket/wsl_peer.h
+++ b/modules/websocket/wsl_peer.h
@@ -35,6 +35,7 @@
#include "core/error_list.h"
#include "core/io/packet_peer.h"
+#include "core/io/stream_peer_tcp.h"
#include "core/ring_buffer.h"
#include "packet_buffer.h"
#include "websocket_peer.h"
@@ -55,6 +56,7 @@ public:
void *obj;
void *peer;
Ref<StreamPeer> conn;
+ Ref<StreamPeerTCP> tcp;
int id;
wslay_event_context_ptr ctx;
@@ -77,7 +79,6 @@ private:
static bool _wsl_poll(struct PeerData *p_data);
static void _wsl_destroy(struct PeerData **p_data);
- Ref<StreamPeer> _connection;
struct PeerData *_data;
uint8_t _is_string;
// Our packet info is just a boolean (is_string), using uint8_t for it.
diff --git a/modules/websocket/wsl_server.cpp b/modules/websocket/wsl_server.cpp
index efb526eed1..993dceafb9 100644
--- a/modules/websocket/wsl_server.cpp
+++ b/modules/websocket/wsl_server.cpp
@@ -35,6 +35,7 @@
#include "core/project_settings.h"
WSLServer::PendingPeer::PendingPeer() {
+ use_ssl = false;
time = 0;
has_request = false;
response_sent = 0;
@@ -42,7 +43,7 @@ WSLServer::PendingPeer::PendingPeer() {
memset(req_buf, 0, sizeof(req_buf));
}
-bool WSLServer::PendingPeer::_parse_request(const PoolStringArray p_protocols) {
+bool WSLServer::PendingPeer::_parse_request(const Vector<String> p_protocols) {
Vector<String> psa = String((char *)req_buf).split("\r\n");
int len = psa.size();
ERR_FAIL_COND_V_MSG(len < 4, false, "Not enough response headers, got: " + itos(len) + ", expected >= 4.");
@@ -97,9 +98,19 @@ bool WSLServer::PendingPeer::_parse_request(const PoolStringArray p_protocols) {
return true;
}
-Error WSLServer::PendingPeer::do_handshake(PoolStringArray p_protocols) {
+Error WSLServer::PendingPeer::do_handshake(const Vector<String> p_protocols) {
if (OS::get_singleton()->get_ticks_msec() - time > WSL_SERVER_TIMEOUT)
return ERR_TIMEOUT;
+ if (use_ssl) {
+ Ref<StreamPeerSSL> ssl = static_cast<Ref<StreamPeerSSL> >(connection);
+ if (ssl.is_null())
+ return FAILED;
+ ssl->poll();
+ if (ssl->get_status() == StreamPeerSSL::STATUS_HANDSHAKING)
+ return ERR_BUSY;
+ else if (ssl->get_status() != StreamPeerSSL::STATUS_CONNECTED)
+ return FAILED;
+ }
if (!has_request) {
int read = 0;
while (true) {
@@ -143,11 +154,11 @@ Error WSLServer::PendingPeer::do_handshake(PoolStringArray p_protocols) {
return OK;
}
-Error WSLServer::listen(int p_port, PoolVector<String> p_protocols, bool gd_mp_api) {
+Error WSLServer::listen(int p_port, const Vector<String> p_protocols, bool gd_mp_api) {
ERR_FAIL_COND_V(is_listening(), ERR_ALREADY_IN_USE);
_is_multiplayer = gd_mp_api;
- _protocols = p_protocols;
+ _protocols.append_array(p_protocols);
_server->listen(p_port);
return OK;
@@ -185,6 +196,7 @@ void WSLServer::poll() {
WSLPeer::PeerData *data = memnew(struct WSLPeer::PeerData);
data->obj = this;
data->conn = ppeer->connection;
+ data->tcp = ppeer->tcp;
data->is_server = true;
data->id = id;
@@ -204,12 +216,21 @@ void WSLServer::poll() {
return;
while (_server->is_connection_available()) {
- Ref<StreamPeer> conn = _server->take_connection();
+ Ref<StreamPeerTCP> conn = _server->take_connection();
if (is_refusing_new_connections())
continue; // Conn will go out-of-scope and be closed.
Ref<PendingPeer> peer = memnew(PendingPeer);
- peer->connection = conn;
+ if (private_key.is_valid() && ssl_cert.is_valid()) {
+ Ref<StreamPeerSSL> ssl = Ref<StreamPeerSSL>(StreamPeerSSL::create());
+ ssl->set_blocking_handshake_enabled(false);
+ ssl->accept_stream(conn, private_key, ssl_cert, ca_chain);
+ peer->connection = ssl;
+ peer->use_ssl = true;
+ } else {
+ peer->connection = conn;
+ }
+ peer->tcp = conn;
peer->time = OS::get_singleton()->get_ticks_msec();
_pending.push_back(peer);
}
@@ -231,6 +252,7 @@ void WSLServer::stop() {
}
_pending.clear();
_peer_map.clear();
+ _protocols.clear();
}
bool WSLServer::has_peer(int p_id) const {
diff --git a/modules/websocket/wsl_server.h b/modules/websocket/wsl_server.h
index 2ceb941073..aae563355e 100644
--- a/modules/websocket/wsl_server.h
+++ b/modules/websocket/wsl_server.h
@@ -36,6 +36,7 @@
#include "websocket_server.h"
#include "wsl_peer.h"
+#include "core/io/stream_peer_ssl.h"
#include "core/io/stream_peer_tcp.h"
#include "core/io/tcp_server.h"
@@ -49,10 +50,12 @@ private:
class PendingPeer : public Reference {
private:
- bool _parse_request(const PoolStringArray p_protocols);
+ bool _parse_request(const Vector<String> p_protocols);
public:
+ Ref<StreamPeerTCP> tcp;
Ref<StreamPeer> connection;
+ bool use_ssl;
int time;
uint8_t req_buf[WSL_MAX_HEADER_SIZE];
@@ -65,7 +68,7 @@ private:
PendingPeer();
- Error do_handshake(const PoolStringArray p_protocols);
+ Error do_handshake(const Vector<String> p_protocols);
};
int _in_buf_size;
@@ -75,11 +78,11 @@ private:
List<Ref<PendingPeer> > _pending;
Ref<TCP_Server> _server;
- PoolStringArray _protocols;
+ Vector<String> _protocols;
public:
Error set_buffers(int p_in_buffer, int p_in_packets, int p_out_buffer, int p_out_packets);
- Error listen(int p_port, PoolVector<String> p_protocols = PoolVector<String>(), bool gd_mp_api = false);
+ Error listen(int p_port, const Vector<String> p_protocols = Vector<String>(), bool gd_mp_api = false);
void stop();
bool is_listening() const;
int get_max_packet_size() const;
diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp
index b61575e2aa..ab5cba04a2 100644
--- a/platform/android/export/export.cpp
+++ b/platform/android/export/export.cpp
@@ -828,14 +828,16 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
encode_uint32(min_gles3 ? 0x00030000 : 0x00020000, &p_manifest.write[iofs + 16]);
}
- if (tname == "meta-data" && attrname == "name" && string_table[attr_value] == "xr_mode_metadata_name") {
+ // FIXME: `attr_value != 0xFFFFFFFF` below added as a stopgap measure for GH-32553,
+ // but the issue should be debugged further and properly addressed.
+ if (tname == "meta-data" && attrname == "name" && attr_value != 0xFFFFFFFF && string_table[attr_value] == "xr_mode_metadata_name") {
// Update the meta-data 'android:name' attribute based on the selected XR mode.
if (xr_mode_index == 1 /* XRMode.OVR */) {
string_table.write[attr_value] = "com.samsung.android.vr.application.mode";
}
}
- if (tname == "meta-data" && attrname == "value" && string_table[attr_value] == "xr_mode_metadata_value") {
+ if (tname == "meta-data" && attrname == "value" && attr_value != 0xFFFFFFFF && string_table[attr_value] == "xr_mode_metadata_value") {
// Update the meta-data 'android:value' attribute based on the selected XR mode.
if (xr_mode_index == 1 /* XRMode.OVR */) {
string_table.write[attr_value] = "vr_only";
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index c0b0944e47..a22ddb265b 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -4071,6 +4071,7 @@ void TextEdit::_insert_text_at_cursor(const String &p_text) {
int new_column, new_line;
_insert_text(cursor.line, cursor.column, p_text, &new_line, &new_column);
+ _update_scrollbars();
cursor_set_line(new_line);
cursor_set_column(new_column);