summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/color.cpp2
-rw-r--r--core/io/resource_loader.cpp3
-rw-r--r--doc/classes/Area.xml8
-rw-r--r--doc/classes/Area2D.xml8
-rw-r--r--doc/classes/BaseButton.xml4
-rw-r--r--doc/classes/LineEdit.xml4
-rw-r--r--doc/classes/RigidBody.xml2
-rw-r--r--doc/classes/RigidBody2D.xml2
-rw-r--r--drivers/gles3/rasterizer_gles3.cpp2
-rw-r--r--drivers/gles3/shader_compiler_gles3.cpp2
-rw-r--r--drivers/gles3/shaders/scene.glsl8
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp110
-rw-r--r--editor/plugins/canvas_item_editor_plugin.h1
-rw-r--r--editor/plugins/spatial_editor_plugin.cpp2
-rw-r--r--editor/plugins/tile_set_editor_plugin.cpp9
-rw-r--r--editor/plugins/tile_set_editor_plugin.h1
-rw-r--r--editor/scene_tree_dock.cpp9
-rw-r--r--main/main.cpp10
-rw-r--r--modules/gdnative/gdnative/string.cpp264
-rw-r--r--modules/gdnative/gdnative/transform.cpp4
-rw-r--r--modules/gdnative/gdnative_api.json82
-rw-r--r--modules/gdnative/include/gdnative/string.h32
-rw-r--r--modules/gdnative/include/gdnative/transform.h4
-rw-r--r--modules/gdnative/pluginscript/pluginscript_language.cpp8
-rw-r--r--modules/mono/csharp_script.cpp2
-rw-r--r--modules/mono/glue/cs_files/Color.cs26
-rw-r--r--modules/mono/mono_gd/gd_mono_utils.cpp6
-rw-r--r--modules/mono/mono_gd/gd_mono_utils.h2
-rw-r--r--platform/osx/os_osx.h16
-rw-r--r--platform/osx/os_osx.mm172
-rw-r--r--platform/windows/os_windows.cpp7
-rw-r--r--scene/3d/baked_lightmap.cpp2
-rw-r--r--scene/3d/particles.cpp17
-rw-r--r--scene/gui/base_button.cpp4
-rw-r--r--scene/gui/line_edit.cpp4
-rw-r--r--scene/gui/text_edit.cpp2
-rw-r--r--scene/resources/bit_mask.cpp4
-rw-r--r--scene/resources/tile_set.cpp3
38 files changed, 522 insertions, 326 deletions
diff --git a/core/color.cpp b/core/color.cpp
index 7278b5c4ee..36afe5e004 100644
--- a/core/color.cpp
+++ b/core/color.cpp
@@ -396,7 +396,7 @@ String Color::to_html(bool p_alpha) const {
txt += _to_hex(g);
txt += _to_hex(b);
if (p_alpha)
- txt = _to_hex(a) + txt;
+ txt += _to_hex(a);
return txt;
}
diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp
index 87add585eb..1351030d1e 100644
--- a/core/io/resource_loader.cpp
+++ b/core/io/resource_loader.cpp
@@ -202,7 +202,8 @@ RES ResourceLoader::load(const String &p_path, const String &p_type_hint, bool p
if (OS::get_singleton()->is_stdout_verbose())
print_line("load resource: " + local_path + " (cached)");
-
+ if (r_error)
+ *r_error = OK;
return RES(ResourceCache::get(local_path));
}
diff --git a/doc/classes/Area.xml b/doc/classes/Area.xml
index b74e767fd2..58fa99f7da 100644
--- a/doc/classes/Area.xml
+++ b/doc/classes/Area.xml
@@ -33,14 +33,14 @@
<return type="Array">
</return>
<description>
- Returns a list of intersecting [code]Area[/code]s.
+ Returns a list of intersecting [code]Area[/code]s. For performance reasons (collisions are all processed at the same time) this list is modified once during the physics step, not immediately after objects are moved. Consider using signals instead.
</description>
</method>
<method name="get_overlapping_bodies" qualifiers="const">
<return type="Array">
</return>
<description>
- Returns a list of intersecting [PhysicsBody]s.
+ Returns a list of intersecting [PhysicsBody]s. For performance reasons (collisions are all processed at the same time) this list is modified once during the physics step, not immediately after objects are moved. Consider using signals instead.
</description>
</method>
<method name="overlaps_area" qualifiers="const">
@@ -49,7 +49,7 @@
<argument index="0" name="area" type="Node">
</argument>
<description>
- If [code]true[/code] the given area overlaps the Area.
+ If [code]true[/code] the given area overlaps the Area. Note that the result of this test is not immediate after moving objects. For performance, list of overlaps is updated once per frame and before the physics step. Consider using signals instead.
</description>
</method>
<method name="overlaps_body" qualifiers="const">
@@ -58,7 +58,7 @@
<argument index="0" name="body" type="Node">
</argument>
<description>
- If [code]true[/code] the given body overlaps the Area.
+ If [code]true[/code] the given body overlaps the Area. Note that the result of this test is not immediate after moving objects. For performance, list of overlaps is updated once per frame and before the physics step. Consider using signals instead.
</description>
</method>
<method name="set_collision_layer_bit">
diff --git a/doc/classes/Area2D.xml b/doc/classes/Area2D.xml
index 6a3f0e7645..ca395321e3 100644
--- a/doc/classes/Area2D.xml
+++ b/doc/classes/Area2D.xml
@@ -33,14 +33,14 @@
<return type="Array">
</return>
<description>
- Returns a list of intersecting [code]Area2D[/code]s.
+ Returns a list of intersecting [code]Area2D[/code]s. For performance reasons (collisions are all processed at the same time) this list is modified once during the physics step, not immediately after objects are moved. Consider using signals instead.
</description>
</method>
<method name="get_overlapping_bodies" qualifiers="const">
<return type="Array">
</return>
<description>
- Returns a list of intersecting [PhysicsBody2D]s.
+ Returns a list of intersecting [PhysicsBody2D]s. For performance reasons (collisions are all processed at the same time) this list is modified once during the physics step, not immediately after objects are moved. Consider using signals instead.
</description>
</method>
<method name="overlaps_area" qualifiers="const">
@@ -49,7 +49,7 @@
<argument index="0" name="area" type="Node">
</argument>
<description>
- If [code]true[/code] the given area overlaps the Area2D.
+ If [code]true[/code] the given area overlaps the Area2D. Note that the result of this test is not immediate after moving objects. For performance, list of overlaps is updated once per frame and before the physics step. Consider using signals instead.
</description>
</method>
<method name="overlaps_body" qualifiers="const">
@@ -58,7 +58,7 @@
<argument index="0" name="body" type="Node">
</argument>
<description>
- If [code]true[/code] the given body overlaps the Area2D.
+ If [code]true[/code] the given body overlaps the Area2D. Note that the result of this test is not immediate after moving objects. For performance, list of overlaps is updated once per frame and before the physics step. Consider using signals instead.
</description>
</method>
<method name="set_collision_layer_bit">
diff --git a/doc/classes/BaseButton.xml b/doc/classes/BaseButton.xml
index 7f1aaa6822..9dd3cf0eff 100644
--- a/doc/classes/BaseButton.xml
+++ b/doc/classes/BaseButton.xml
@@ -21,7 +21,7 @@
<method name="_toggled" qualifiers="virtual">
<return type="void">
</return>
- <argument index="0" name="pressed" type="bool">
+ <argument index="0" name="button_pressed" type="bool">
</argument>
<description>
Called when button is toggled (only if toggle_mode is active).
@@ -82,7 +82,7 @@
</description>
</signal>
<signal name="toggled">
- <argument index="0" name="pressed" type="bool">
+ <argument index="0" name="button_pressed" type="bool">
</argument>
<description>
This signal is emitted when the button was just toggled between pressed and normal states (only if toggle_mode is active). The new state is contained in the [i]pressed[/i] argument.
diff --git a/doc/classes/LineEdit.xml b/doc/classes/LineEdit.xml
index 4434a7b7e2..c28b722eb3 100644
--- a/doc/classes/LineEdit.xml
+++ b/doc/classes/LineEdit.xml
@@ -131,14 +131,14 @@
</members>
<signals>
<signal name="text_changed">
- <argument index="0" name="text" type="String">
+ <argument index="0" name="new_text" type="String">
</argument>
<description>
Emitted when the text changes.
</description>
</signal>
<signal name="text_entered">
- <argument index="0" name="text" type="String">
+ <argument index="0" name="new_text" type="String">
</argument>
<description>
Emitted when the user presses KEY_ENTER on the [code]LineEdit[/code].
diff --git a/doc/classes/RigidBody.xml b/doc/classes/RigidBody.xml
index 3c54f29c15..335112f5d7 100644
--- a/doc/classes/RigidBody.xml
+++ b/doc/classes/RigidBody.xml
@@ -39,7 +39,7 @@
<return type="Array">
</return>
<description>
- Return a list of the bodies colliding with this one. By default, number of max contacts reported is at 0 , see [method set_max_contacts_reported] to increase it.
+ Return a list of the bodies colliding with this one. By default, number of max contacts reported is at 0 , see [method set_max_contacts_reported] to increase it. Note that the result of this test is not immediate after moving objects. For performance, list of collisions is updated once per frame and before the physics step. Consider using signals instead.
</description>
</method>
<method name="set_axis_velocity">
diff --git a/doc/classes/RigidBody2D.xml b/doc/classes/RigidBody2D.xml
index c11e118df5..991e0fa3f4 100644
--- a/doc/classes/RigidBody2D.xml
+++ b/doc/classes/RigidBody2D.xml
@@ -67,7 +67,7 @@
<return type="Array">
</return>
<description>
- Returns a list of the bodies colliding with this one. Use [member contacts_reported] to set the maximum number reported. You must also set [member contact_monitor] to [code]true[/code].
+ Returns a list of the bodies colliding with this one. Use [member contacts_reported] to set the maximum number reported. You must also set [member contact_monitor] to [code]true[/code]. Note that the result of this test is not immediate after moving objects. For performance, list of collisions is updated once per frame and before the physics step. Consider using signals instead.
</description>
</method>
<method name="get_inertia" qualifiers="const">
diff --git a/drivers/gles3/rasterizer_gles3.cpp b/drivers/gles3/rasterizer_gles3.cpp
index 99ba0860bd..b43deab58f 100644
--- a/drivers/gles3/rasterizer_gles3.cpp
+++ b/drivers/gles3/rasterizer_gles3.cpp
@@ -345,7 +345,7 @@ void RasterizerGLES3::blit_render_target_to_screen(RID p_render_target, const Re
glBindFramebuffer(GL_READ_FRAMEBUFFER, rt->fbo);
glReadBuffer(GL_COLOR_ATTACHMENT0);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, RasterizerStorageGLES3::system_fbo);
- glBlitFramebuffer(0, 0, rt->width, rt->height, p_screen_rect.position.x, win_size.height - p_screen_rect.position.y - p_screen_rect.size.height, p_screen_rect.position.x + p_screen_rect.size.width, win_size.height, GL_COLOR_BUFFER_BIT, GL_NEAREST);
+ glBlitFramebuffer(0, 0, rt->width, rt->height, p_screen_rect.position.x, win_size.height - p_screen_rect.position.y - p_screen_rect.size.height, p_screen_rect.position.x + p_screen_rect.size.width, win_size.height - p_screen_rect.position.y, GL_COLOR_BUFFER_BIT, GL_NEAREST);
#else
canvas->canvas_begin();
diff --git a/drivers/gles3/shader_compiler_gles3.cpp b/drivers/gles3/shader_compiler_gles3.cpp
index 875946f089..ada7acb879 100644
--- a/drivers/gles3/shader_compiler_gles3.cpp
+++ b/drivers/gles3/shader_compiler_gles3.cpp
@@ -715,7 +715,7 @@ ShaderCompilerGLES3::ShaderCompilerGLES3() {
actions[VS::SHADER_CANVAS_ITEM].renames["WORLD_MATRIX"] = "modelview_matrix";
actions[VS::SHADER_CANVAS_ITEM].renames["PROJECTION_MATRIX"] = "projection_matrix";
- actions[VS::SHADER_CANVAS_ITEM].renames["EXTRA_MATRIX"] == "extra_matrix";
+ actions[VS::SHADER_CANVAS_ITEM].renames["EXTRA_MATRIX"] = "extra_matrix";
actions[VS::SHADER_CANVAS_ITEM].renames["TIME"] = "time";
actions[VS::SHADER_CANVAS_ITEM].renames["AT_LIGHT_PASS"] = "at_light_pass";
actions[VS::SHADER_CANVAS_ITEM].renames["INSTANCE_CUSTOM"] = "instance_custom";
diff --git a/drivers/gles3/shaders/scene.glsl b/drivers/gles3/shaders/scene.glsl
index 1aa28d0fd5..d3644bffdd 100644
--- a/drivers/gles3/shaders/scene.glsl
+++ b/drivers/gles3/shaders/scene.glsl
@@ -904,7 +904,7 @@ float G_GGX_anisotropic_2cos(float cos_theta_m, float alpha_x, float alpha_y, fl
float sin2 = (1.0-cos2);
float s_x = alpha_x * cos_phi;
float s_y = alpha_y * sin_phi;
- return 1.0 / (cos_theta_m + sqrt(cos2 + (s_x*s_x + s_y*s_y)*sin2 ));
+ return 1.0 / max(cos_theta_m + sqrt(cos2 + (s_x*s_x + s_y*s_y)*sin2 ), 0.001);
}
float D_GGX_anisotropic(float cos_theta_m, float alpha_x, float alpha_y, float cos_phi, float sin_phi) {
@@ -913,7 +913,7 @@ float D_GGX_anisotropic(float cos_theta_m, float alpha_x, float alpha_y, float c
float r_x = cos_phi/alpha_x;
float r_y = sin_phi/alpha_y;
float d = cos2 + sin2*(r_x * r_x + r_y * r_y);
- return 1.0 / (M_PI * alpha_x * alpha_y * d * d );
+ return 1.0 / max(M_PI * alpha_x * alpha_y * d * d, 0.001);
}
@@ -1307,7 +1307,7 @@ void reflection_process(int idx, vec3 vertex, vec3 normal,vec3 binormal, vec3 ta
//make blend more rounded
blend=mix(length(inner_pos),blend,blend);
blend*=blend;
- blend=1.001-blend;
+ blend=max(0.0, 1.0-blend);
if (reflections[idx].params.x>0.0){// compute reflection
@@ -1476,7 +1476,7 @@ void gi_probe_compute(mediump sampler3D probe, mat4 probe_xform, vec3 bounds,vec
}
vec3 blendv = abs(probe_pos/bounds * 2.0 - 1.0);
- float blend = 1.001-max(blendv.x,max(blendv.y,blendv.z));
+ float blend = clamp(1.0-max(blendv.x,max(blendv.y,blendv.z)), 0.0, 1.0);
//float blend=1.0;
float max_distance = length(bounds);
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index 2a46aba207..bd5e5c7355 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -4435,6 +4435,7 @@ void CanvasItemEditorViewport::_on_change_type_closed() {
void CanvasItemEditorViewport::_create_preview(const Vector<String> &files) const {
label->set_position(get_global_position() + Point2(14, 14) * EDSCALE);
label_desc->set_position(label->get_position() + Point2(0, label->get_size().height));
+ bool add_preview = false;
for (int i = 0; i < files.size(); i++) {
String path = files[i];
RES res = ResourceLoader::load(path);
@@ -4456,9 +4457,12 @@ void CanvasItemEditorViewport::_create_preview(const Vector<String> &files) cons
}
}
}
- editor->get_scene_root()->add_child(preview_node);
+ add_preview = true;
}
}
+
+ if (add_preview)
+ editor->get_scene_root()->add_child(preview_node);
}
void CanvasItemEditorViewport::_remove_preview() {
@@ -4603,6 +4607,14 @@ bool CanvasItemEditorViewport::_create_instance(Node *parent, String &path, cons
void CanvasItemEditorViewport::_perform_drop_data() {
_remove_preview();
+ // Without root dropping multiple files is not allowed
+ if (!target_node && selected_files.size() > 1) {
+ accept->get_ok()->set_text(TTR("Ok"));
+ accept->set_text(TTR("Cannot instantiate multiple nodes without root."));
+ accept->popup_centered_minsize();
+ return;
+ }
+
Vector<String> error_files;
editor_data->get_undo_redo().create_action(TTR("Create Node"));
@@ -4613,30 +4625,40 @@ void CanvasItemEditorViewport::_perform_drop_data() {
if (res.is_null()) {
continue;
}
- Ref<Texture> texture = Ref<Texture>(Object::cast_to<Texture>(*res));
Ref<PackedScene> scene = Ref<PackedScene>(Object::cast_to<PackedScene>(*res));
- if (texture != NULL) {
- Node *child;
- if (default_type == "Light2D")
- child = memnew(Light2D);
- else if (default_type == "Particles2D")
- child = memnew(Particles2D);
- else if (default_type == "Polygon2D")
- child = memnew(Polygon2D);
- else if (default_type == "TouchScreenButton")
- child = memnew(TouchScreenButton);
- else if (default_type == "TextureRect")
- child = memnew(TextureRect);
- else if (default_type == "NinePatchRect")
- child = memnew(NinePatchRect);
- else
- child = memnew(Sprite); // default
-
- _create_nodes(target_node, child, path, drop_pos);
- } else if (scene != NULL) {
- bool success = _create_instance(target_node, path, drop_pos);
- if (!success) {
- error_files.push_back(path);
+ if (scene != NULL && scene.is_valid()) {
+ if (!target_node) {
+ // Without root node act the same as "Load Inherited Scene"
+ Error err = EditorNode::get_singleton()->load_scene(path, false, true);
+ if (err != OK) {
+ error_files.push_back(path);
+ }
+ } else {
+ bool success = _create_instance(target_node, path, drop_pos);
+ if (!success) {
+ error_files.push_back(path);
+ }
+ }
+ } else {
+ Ref<Texture> texture = Ref<Texture>(Object::cast_to<Texture>(*res));
+ if (texture != NULL && texture.is_valid()) {
+ Node *child;
+ if (default_type == "Light2D")
+ child = memnew(Light2D);
+ else if (default_type == "Particles2D")
+ child = memnew(Particles2D);
+ else if (default_type == "Polygon2D")
+ child = memnew(Polygon2D);
+ else if (default_type == "TouchScreenButton")
+ child = memnew(TouchScreenButton);
+ else if (default_type == "TextureRect")
+ child = memnew(TextureRect);
+ else if (default_type == "NinePatchRect")
+ child = memnew(NinePatchRect);
+ else
+ child = memnew(Sprite); // default
+
+ _create_nodes(target_node, child, path, drop_pos);
}
}
}
@@ -4661,14 +4683,14 @@ bool CanvasItemEditorViewport::can_drop_data(const Point2 &p_point, const Varian
if (String(d["type"]) == "files") {
Vector<String> files = d["files"];
bool can_instance = false;
- for (int i = 0; i < files.size(); i++) { // check if dragged files contain resource or scene can be created at least one
+ for (int i = 0; i < files.size(); i++) { // check if dragged files contain resource or scene can be created at least once
RES res = ResourceLoader::load(files[i]);
if (res.is_null()) {
continue;
}
String type = res->get_class();
if (type == "PackedScene") {
- Ref<PackedScene> sdata = ResourceLoader::load(files[i]);
+ Ref<PackedScene> sdata = Ref<PackedScene>(Object::cast_to<PackedScene>(*res));
Node *instanced_scene = sdata->instance(PackedScene::GEN_EDIT_STATE_INSTANCE);
if (!instanced_scene) {
continue;
@@ -4682,7 +4704,7 @@ bool CanvasItemEditorViewport::can_drop_data(const Point2 &p_point, const Varian
type == "StreamTexture" ||
type == "AtlasTexture" ||
type == "LargeTexture") {
- Ref<Texture> texture = ResourceLoader::load(files[i]);
+ Ref<Texture> texture = Ref<Texture>(Object::cast_to<Texture>(*res));
if (texture.is_valid() == false) {
continue;
}
@@ -4708,6 +4730,7 @@ bool CanvasItemEditorViewport::can_drop_data(const Point2 &p_point, const Varian
}
void CanvasItemEditorViewport::_show_resource_type_selector() {
+ _remove_preview();
List<BaseButton *> btn_list;
button_group->get_buttons(&btn_list);
@@ -4719,6 +4742,17 @@ void CanvasItemEditorViewport::_show_resource_type_selector() {
selector->popup_centered_minsize();
}
+bool CanvasItemEditorViewport::_only_packed_scenes_selected() const {
+
+ for (int i = 0; i < selected_files.size(); ++i) {
+ if (ResourceLoader::load(selected_files[i])->get_class() != "PackedScene") {
+ return false;
+ }
+ }
+
+ return true;
+}
+
void CanvasItemEditorViewport::drop_data(const Point2 &p_point, const Variant &p_data) {
bool is_shift = Input::get_singleton()->is_key_pressed(KEY_SHIFT);
bool is_alt = Input::get_singleton()->is_key_pressed(KEY_ALT);
@@ -4728,6 +4762,8 @@ void CanvasItemEditorViewport::drop_data(const Point2 &p_point, const Variant &p
if (d.has("type") && String(d["type"]) == "files") {
selected_files = d["files"];
}
+ if (selected_files.size() == 0)
+ return;
List<Node *> list = editor->get_editor_selection()->get_selected_node_list();
if (list.size() == 0) {
@@ -4737,25 +4773,19 @@ void CanvasItemEditorViewport::drop_data(const Point2 &p_point, const Variant &p
} else {
drop_pos = p_point;
target_node = NULL;
- _show_resource_type_selector();
- return;
}
}
- if (list.size() != 1) {
- accept->get_ok()->set_text(TTR("I see.."));
- accept->set_text(TTR("This operation requires a single selected node."));
- accept->popup_centered_minsize();
- _remove_preview();
- return;
- }
- target_node = list[0];
- if (is_shift && target_node != editor->get_edited_scene()) {
- target_node = target_node->get_parent();
+ if (list.size() > 0) {
+ target_node = list[0];
+ if (is_shift && target_node != editor->get_edited_scene()) {
+ target_node = target_node->get_parent();
+ }
}
+
drop_pos = p_point;
- if (is_alt) {
+ if (is_alt && !_only_packed_scenes_selected()) {
_show_resource_type_selector();
} else {
_perform_drop_data();
diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h
index 5be71bfc28..ace87f9fe2 100644
--- a/editor/plugins/canvas_item_editor_plugin.h
+++ b/editor/plugins/canvas_item_editor_plugin.h
@@ -576,6 +576,7 @@ class CanvasItemEditorViewport : public Control {
void _remove_preview();
bool _cyclical_dependency_exists(const String &p_target_scene_path, Node *p_desired_node);
+ bool _only_packed_scenes_selected() const;
void _create_nodes(Node *parent, Node *child, String &path, const Point2 &p_point);
bool _create_instance(Node *parent, String &path, const Point2 &p_point);
void _perform_drop_data();
diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp
index 535ce79b30..b677017371 100644
--- a/editor/plugins/spatial_editor_plugin.cpp
+++ b/editor/plugins/spatial_editor_plugin.cpp
@@ -3915,7 +3915,7 @@ void SpatialEditor::set_state(const Dictionary &p_state) {
if (d.has("snap_enabled")) {
snap_enabled = d["snap_enabled"];
- tool_option_button[TOOL_OPT_LOCAL_COORDS]->set_pressed(d["snap_enabled"]);
+ tool_option_button[TOOL_OPT_USE_SNAP]->set_pressed(d["snap_enabled"]);
}
if (d.has("translate_snap"))
diff --git a/editor/plugins/tile_set_editor_plugin.cpp b/editor/plugins/tile_set_editor_plugin.cpp
index 08679b781a..612bdb1d2a 100644
--- a/editor/plugins/tile_set_editor_plugin.cpp
+++ b/editor/plugins/tile_set_editor_plugin.cpp
@@ -583,6 +583,14 @@ void AutotileEditor::_notification(int p_what) {
}
}
+void AutotileEditor::_changed_callback(Object *p_changed, const char *p_prop) {
+ if (p_prop == StringName("texture") || p_prop == StringName("is_autotile")) {
+ edit(tile_set.ptr());
+ autotile_list->update();
+ workspace->update();
+ }
+}
+
void AutotileEditor::_on_autotile_selected(int p_index) {
if (get_current_tile() >= 0) {
@@ -1581,6 +1589,7 @@ Vector2 AutotileEditor::snap_point(const Vector2 &point) {
void AutotileEditor::edit(Object *p_node) {
tile_set = Ref<TileSet>(Object::cast_to<TileSet>(p_node));
+ tile_set->add_change_receptor(this);
helper->set_tileset(tile_set);
autotile_list->clear();
diff --git a/editor/plugins/tile_set_editor_plugin.h b/editor/plugins/tile_set_editor_plugin.h
index 9bd3e23181..93d403deea 100644
--- a/editor/plugins/tile_set_editor_plugin.h
+++ b/editor/plugins/tile_set_editor_plugin.h
@@ -124,6 +124,7 @@ class AutotileEditor : public Control {
protected:
static void _bind_methods();
void _notification(int p_what);
+ virtual void _changed_callback(Object *p_changed, const char *p_prop);
private:
void _on_autotile_selected(int p_index);
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp
index d8d44a635a..b1b65952f4 100644
--- a/editor/scene_tree_dock.cpp
+++ b/editor/scene_tree_dock.cpp
@@ -237,13 +237,20 @@ void SceneTreeDock::_replace_with_branch_scene(const String &p_file, Node *base)
Node *parent = base->get_parent();
int pos = base->get_index();
- memdelete(base);
+ parent->remove_child(base);
parent->add_child(instanced_scene);
parent->move_child(instanced_scene, pos);
instanced_scene->set_owner(edited_scene);
editor_selection->clear();
editor_selection->add_node(instanced_scene);
scene_tree->set_selected(instanced_scene);
+
+ // Delete the node as late as possible because before another one is selected
+ // an editor plugin could be referencing it to do something with it before
+ // switching to another (or to none); and since some steps of changing the
+ // editor state are deferred, the safest thing is to do this is as the last
+ // step of this function and also by enqueing instead of memdelete()-ing it here
+ base->queue_delete();
}
bool SceneTreeDock::_cyclical_dependency_exists(const String &p_target_scene_path, Node *p_desired_node) {
diff --git a/main/main.cpp b/main/main.cpp
index 48537dc3a7..0b231b9d30 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -1845,11 +1845,6 @@ void Main::cleanup() {
EditorNode::unregister_editor_types();
#endif
- if (audio_server) {
- audio_server->finish();
- memdelete(audio_server);
- }
-
if (arvr_server) {
// cleanup now before we pull the rug from underneath...
memdelete(arvr_server);
@@ -1861,6 +1856,11 @@ void Main::cleanup() {
unregister_scene_types();
unregister_server_types();
+ if (audio_server) {
+ audio_server->finish();
+ memdelete(audio_server);
+ }
+
OS::get_singleton()->finalize();
finalize_physics();
diff --git a/modules/gdnative/gdnative/string.cpp b/modules/gdnative/gdnative/string.cpp
index 350dc540f7..9ce2b1406d 100644
--- a/modules/gdnative/gdnative/string.cpp
+++ b/modules/gdnative/gdnative/string.cpp
@@ -40,6 +40,24 @@
extern "C" {
#endif
+godot_int GDAPI godot_char_string_length(const godot_char_string *p_cs) {
+ const CharString *cs = (const CharString *)p_cs;
+
+ return cs->length();
+}
+
+const char GDAPI *godot_char_string_get_data(const godot_char_string *p_cs) {
+ const CharString *cs = (const CharString *)p_cs;
+
+ return cs->get_data();
+}
+
+void GDAPI godot_char_string_destroy(godot_char_string *p_cs) {
+ CharString *cs = (CharString *)p_cs;
+
+ cs->~CharString();
+}
+
void GDAPI godot_string_new(godot_string *r_dest) {
String *dest = (String *)r_dest;
memnew_placement(dest, String);
@@ -51,35 +69,11 @@ void GDAPI godot_string_new_copy(godot_string *r_dest, const godot_string *p_src
memnew_placement(dest, String(*src));
}
-void GDAPI godot_string_new_data(godot_string *r_dest, const char *p_contents, const int p_size) {
- String *dest = (String *)r_dest;
- memnew_placement(dest, String(String::utf8(p_contents, p_size)));
-}
-
-void GDAPI godot_string_new_unicode_data(godot_string *r_dest, const wchar_t *p_contents, const int p_size) {
+void GDAPI godot_string_new_with_wide_string(godot_string *r_dest, const wchar_t *p_contents, const int p_size) {
String *dest = (String *)r_dest;
memnew_placement(dest, String(p_contents, p_size));
}
-void GDAPI godot_string_get_data(const godot_string *p_self, char *p_dest, int *p_size) {
- String *self = (String *)p_self;
-
- if (p_size) {
- // we have a length pointer, that means we either want to know
- // the length or want to write *p_size bytes into a buffer
-
- CharString utf8_string = self->utf8();
-
- int len = utf8_string.length();
-
- if (p_dest) {
- memcpy(p_dest, utf8_string.get_data(), *p_size);
- } else {
- *p_size = len;
- }
- }
-}
-
wchar_t GDAPI *godot_string_operator_index(godot_string *p_self, const godot_int p_idx) {
String *self = (String *)p_self;
return &(self->operator[](p_idx));
@@ -90,7 +84,7 @@ wchar_t GDAPI godot_string_operator_index_const(const godot_string *p_self, cons
return self->operator[](p_idx);
}
-const wchar_t GDAPI *godot_string_unicode_str(const godot_string *p_self) {
+const wchar_t GDAPI *godot_string_wide_str(const godot_string *p_self) {
const String *self = (const String *)p_self;
return self->c_str();
}
@@ -130,6 +124,26 @@ godot_int GDAPI godot_string_length(const godot_string *p_self) {
/* Helpers */
+signed char GDAPI godot_string_casecmp_to(const godot_string *p_self, const godot_string *p_str) {
+ const String *self = (const String *)p_self;
+ const String *str = (const String *)p_str;
+
+ return self->casecmp_to(*str);
+}
+
+signed char GDAPI godot_string_nocasecmp_to(const godot_string *p_self, const godot_string *p_str) {
+ const String *self = (const String *)p_self;
+ const String *str = (const String *)p_str;
+
+ return self->nocasecmp_to(*str);
+}
+signed char GDAPI godot_string_naturalnocasecmp_to(const godot_string *p_self, const godot_string *p_str) {
+ const String *self = (const String *)p_self;
+ const String *str = (const String *)p_str;
+
+ return self->naturalnocasecmp_to(*str);
+}
+
godot_bool GDAPI godot_string_begins_with(const godot_string *p_self, const godot_string *p_string) {
const String *self = (const String *)p_self;
const String *string = (const String *)p_string;
@@ -534,7 +548,7 @@ godot_string GDAPI godot_string_capitalize(const godot_string *p_self) {
memnew_placement(&result, String(self->capitalize()));
return result;
-};
+}
godot_string GDAPI godot_string_camelcase_to_underscore(const godot_string *p_self) {
const String *self = (const String *)p_self;
@@ -542,7 +556,7 @@ godot_string GDAPI godot_string_camelcase_to_underscore(const godot_string *p_se
memnew_placement(&result, String(self->camelcase_to_underscore(false)));
return result;
-};
+}
godot_string GDAPI godot_string_camelcase_to_underscore_lowercased(const godot_string *p_self) {
const String *self = (const String *)p_self;
@@ -550,45 +564,45 @@ godot_string GDAPI godot_string_camelcase_to_underscore_lowercased(const godot_s
memnew_placement(&result, String(self->camelcase_to_underscore()));
return result;
-};
+}
double GDAPI godot_string_char_to_double(const char *p_what) {
return String::to_double(p_what);
-};
+}
godot_int GDAPI godot_string_char_to_int(const char *p_what) {
return String::to_int(p_what);
-};
+}
int64_t GDAPI godot_string_wchar_to_int(const wchar_t *p_str) {
return String::to_int(p_str);
-};
+}
godot_int GDAPI godot_string_char_to_int_with_len(const char *p_what, godot_int p_len) {
return String::to_int(p_what, p_len);
-};
+}
int64_t GDAPI godot_string_char_to_int64_with_len(const wchar_t *p_str, int p_len) {
return String::to_int(p_str, p_len);
-};
+}
int64_t GDAPI godot_string_hex_to_int64(const godot_string *p_self) {
const String *self = (const String *)p_self;
return self->hex_to_int64(false);
-};
+}
int64_t GDAPI godot_string_hex_to_int64_with_prefix(const godot_string *p_self) {
const String *self = (const String *)p_self;
return self->hex_to_int64();
-};
+}
int64_t GDAPI godot_string_to_int64(const godot_string *p_self) {
const String *self = (const String *)p_self;
return self->to_int64();
-};
+}
double GDAPI godot_string_unicode_char_to_double(const wchar_t *p_str, const wchar_t **r_end) {
return String::to_double(p_str, r_end);
@@ -601,7 +615,7 @@ godot_string GDAPI godot_string_get_slice(const godot_string *p_self, godot_stri
memnew_placement(&result, String(self->get_slice(*splitter, p_slice)));
return result;
-};
+}
godot_string GDAPI godot_string_get_slicec(const godot_string *p_self, wchar_t p_splitter, godot_int p_slice) {
const String *self = (const String *)p_self;
@@ -609,7 +623,7 @@ godot_string GDAPI godot_string_get_slicec(const godot_string *p_self, wchar_t p
memnew_placement(&result, String(self->get_slicec(p_splitter, p_slice)));
return result;
-};
+}
godot_array GDAPI godot_string_split(const godot_string *p_self, const godot_string *p_splitter) {
const String *self = (const String *)p_self;
@@ -625,7 +639,7 @@ godot_array GDAPI godot_string_split(const godot_string *p_self, const godot_str
}
return result;
-};
+}
godot_array GDAPI godot_string_split_allow_empty(const godot_string *p_self, const godot_string *p_splitter) {
const String *self = (const String *)p_self;
@@ -641,7 +655,7 @@ godot_array GDAPI godot_string_split_allow_empty(const godot_string *p_self, con
}
return result;
-};
+}
godot_array GDAPI godot_string_split_floats(const godot_string *p_self, const godot_string *p_splitter) {
const String *self = (const String *)p_self;
@@ -657,7 +671,7 @@ godot_array GDAPI godot_string_split_floats(const godot_string *p_self, const go
}
return result;
-};
+}
godot_array GDAPI godot_string_split_floats_allows_empty(const godot_string *p_self, const godot_string *p_splitter) {
const String *self = (const String *)p_self;
@@ -673,7 +687,7 @@ godot_array GDAPI godot_string_split_floats_allows_empty(const godot_string *p_s
}
return result;
-};
+}
godot_array GDAPI godot_string_split_floats_mk(const godot_string *p_self, const godot_array *p_splitters) {
const String *self = (const String *)p_self;
@@ -696,7 +710,7 @@ godot_array GDAPI godot_string_split_floats_mk(const godot_string *p_self, const
}
return result;
-};
+}
godot_array GDAPI godot_string_split_floats_mk_allows_empty(const godot_string *p_self, const godot_array *p_splitters) {
const String *self = (const String *)p_self;
@@ -719,7 +733,7 @@ godot_array GDAPI godot_string_split_floats_mk_allows_empty(const godot_string *
}
return result;
-};
+}
godot_array GDAPI godot_string_split_ints(const godot_string *p_self, const godot_string *p_splitter) {
const String *self = (const String *)p_self;
@@ -735,7 +749,7 @@ godot_array GDAPI godot_string_split_ints(const godot_string *p_self, const godo
}
return result;
-};
+}
godot_array GDAPI godot_string_split_ints_allows_empty(const godot_string *p_self, const godot_string *p_splitter) {
const String *self = (const String *)p_self;
@@ -751,7 +765,7 @@ godot_array GDAPI godot_string_split_ints_allows_empty(const godot_string *p_sel
}
return result;
-};
+}
godot_array GDAPI godot_string_split_ints_mk(const godot_string *p_self, const godot_array *p_splitters) {
const String *self = (const String *)p_self;
@@ -774,7 +788,7 @@ godot_array GDAPI godot_string_split_ints_mk(const godot_string *p_self, const g
}
return result;
-};
+}
godot_array GDAPI godot_string_split_ints_mk_allows_empty(const godot_string *p_self, const godot_array *p_splitters) {
const String *self = (const String *)p_self;
@@ -797,7 +811,7 @@ godot_array GDAPI godot_string_split_ints_mk_allows_empty(const godot_string *p_
}
return result;
-};
+}
godot_array GDAPI godot_string_split_spaces(const godot_string *p_self) {
const String *self = (const String *)p_self;
@@ -812,22 +826,22 @@ godot_array GDAPI godot_string_split_spaces(const godot_string *p_self) {
}
return result;
-};
+}
godot_int GDAPI godot_string_get_slice_count(const godot_string *p_self, godot_string p_splitter) {
const String *self = (const String *)p_self;
String *splitter = (String *)&p_splitter;
return self->get_slice_count(*splitter);
-};
+}
wchar_t GDAPI godot_string_char_lowercase(wchar_t p_char) {
return String::char_lowercase(p_char);
-};
+}
wchar_t GDAPI godot_string_char_uppercase(wchar_t p_char) {
return String::char_uppercase(p_char);
-};
+}
godot_string GDAPI godot_string_to_lower(const godot_string *p_self) {
const String *self = (const String *)p_self;
@@ -835,7 +849,7 @@ godot_string GDAPI godot_string_to_lower(const godot_string *p_self) {
memnew_placement(&result, String(self->to_lower()));
return result;
-};
+}
godot_string GDAPI godot_string_to_upper(const godot_string *p_self) {
const String *self = (const String *)p_self;
@@ -843,7 +857,7 @@ godot_string GDAPI godot_string_to_upper(const godot_string *p_self) {
memnew_placement(&result, String(self->to_upper()));
return result;
-};
+}
godot_string GDAPI godot_string_get_basename(const godot_string *p_self) {
const String *self = (const String *)p_self;
@@ -851,7 +865,7 @@ godot_string GDAPI godot_string_get_basename(const godot_string *p_self) {
memnew_placement(&result, String(self->get_basename()));
return result;
-};
+}
godot_string GDAPI godot_string_get_extension(const godot_string *p_self) {
const String *self = (const String *)p_self;
@@ -859,7 +873,7 @@ godot_string GDAPI godot_string_get_extension(const godot_string *p_self) {
memnew_placement(&result, String(self->get_extension()));
return result;
-};
+}
godot_string GDAPI godot_string_left(const godot_string *p_self, godot_int p_pos) {
const String *self = (const String *)p_self;
@@ -867,13 +881,13 @@ godot_string GDAPI godot_string_left(const godot_string *p_self, godot_int p_pos
memnew_placement(&result, String(self->left(p_pos)));
return result;
-};
+}
wchar_t GDAPI godot_string_ord_at(const godot_string *p_self, godot_int p_idx) {
const String *self = (const String *)p_self;
return self->ord_at(p_idx);
-};
+}
godot_string GDAPI godot_string_plus_file(const godot_string *p_self, const godot_string *p_file) {
const String *self = (const String *)p_self;
@@ -882,7 +896,7 @@ godot_string GDAPI godot_string_plus_file(const godot_string *p_self, const godo
memnew_placement(&result, String(self->plus_file(*file)));
return result;
-};
+}
godot_string GDAPI godot_string_right(const godot_string *p_self, godot_int p_pos) {
const String *self = (const String *)p_self;
@@ -890,7 +904,7 @@ godot_string GDAPI godot_string_right(const godot_string *p_self, godot_int p_po
memnew_placement(&result, String(self->right(p_pos)));
return result;
-};
+}
godot_string GDAPI godot_string_strip_edges(const godot_string *p_self, godot_bool p_left, godot_bool p_right) {
const String *self = (const String *)p_self;
@@ -898,7 +912,7 @@ godot_string GDAPI godot_string_strip_edges(const godot_string *p_self, godot_bo
memnew_placement(&result, String(self->strip_edges(p_left, p_right)));
return result;
-};
+}
godot_string GDAPI godot_string_strip_escapes(const godot_string *p_self) {
const String *self = (const String *)p_self;
@@ -906,94 +920,96 @@ godot_string GDAPI godot_string_strip_escapes(const godot_string *p_self) {
memnew_placement(&result, String(self->strip_escapes()));
return result;
-};
+}
void GDAPI godot_string_erase(godot_string *p_self, godot_int p_pos, godot_int p_chars) {
String *self = (String *)p_self;
return self->erase(p_pos, p_chars);
-};
+}
-void GDAPI godot_string_ascii(godot_string *p_self, char *result) {
- String *self = (String *)p_self;
- Vector<char> return_value = self->ascii();
+godot_char_string GDAPI godot_string_ascii(const godot_string *p_self) {
+ const String *self = (const String *)p_self;
+ godot_char_string result;
- for (int i = 0; i < return_value.size(); i++) {
- result[i] = return_value[i];
- }
+ memnew_placement(&result, String(self->ascii()));
+
+ return result;
}
-void GDAPI godot_string_ascii_extended(godot_string *p_self, char *result) {
- String *self = (String *)p_self;
- Vector<char> return_value = self->ascii(true);
+godot_char_string GDAPI godot_string_ascii_extended(const godot_string *p_self) {
+ const String *self = (const String *)p_self;
- for (int i = 0; i < return_value.size(); i++) {
- result[i] = return_value[i];
- }
+ godot_char_string result;
+
+ memnew_placement(&result, String(self->ascii(true)));
+
+ return result;
}
-void GDAPI godot_string_utf8(godot_string *p_self, char *result) {
- String *self = (String *)p_self;
- Vector<char> return_value = self->utf8();
+godot_char_string GDAPI godot_string_utf8(const godot_string *p_self) {
+ const String *self = (const String *)p_self;
- for (int i = 0; i < return_value.size(); i++) {
- result[i] = return_value[i];
- }
+ godot_char_string result;
+
+ memnew_placement(&result, String(self->utf8()));
+
+ return result;
}
godot_bool GDAPI godot_string_parse_utf8(godot_string *p_self, const char *p_utf8) {
String *self = (String *)p_self;
return self->parse_utf8(p_utf8);
-};
+}
godot_bool GDAPI godot_string_parse_utf8_with_len(godot_string *p_self, const char *p_utf8, godot_int p_len) {
String *self = (String *)p_self;
return self->parse_utf8(p_utf8, p_len);
-};
+}
godot_string GDAPI godot_string_chars_to_utf8(const char *p_utf8) {
godot_string result;
memnew_placement(&result, String(String::utf8(p_utf8)));
return result;
-};
+}
godot_string GDAPI godot_string_chars_to_utf8_with_len(const char *p_utf8, godot_int p_len) {
godot_string result;
memnew_placement(&result, String(String::utf8(p_utf8, p_len)));
return result;
-};
+}
uint32_t GDAPI godot_string_hash(const godot_string *p_self) {
const String *self = (const String *)p_self;
return self->hash();
-};
+}
uint64_t GDAPI godot_string_hash64(const godot_string *p_self) {
const String *self = (const String *)p_self;
return self->hash64();
-};
+}
uint32_t GDAPI godot_string_hash_chars(const char *p_cstr) {
return String::hash(p_cstr);
-};
+}
uint32_t GDAPI godot_string_hash_chars_with_len(const char *p_cstr, godot_int p_len) {
return String::hash(p_cstr, p_len);
-};
+}
uint32_t GDAPI godot_string_hash_utf8_chars(const wchar_t *p_str) {
return String::hash(p_str);
-};
+}
uint32_t GDAPI godot_string_hash_utf8_chars_with_len(const wchar_t *p_str, godot_int p_len) {
return String::hash(p_str, p_len);
-};
+}
godot_pool_byte_array GDAPI godot_string_md5_buffer(const godot_string *p_self) {
const String *self = (const String *)p_self;
@@ -1010,7 +1026,7 @@ godot_pool_byte_array GDAPI godot_string_md5_buffer(const godot_string *p_self)
}
return result;
-};
+}
godot_string GDAPI godot_string_md5_text(const godot_string *p_self) {
const String *self = (const String *)p_self;
@@ -1018,7 +1034,7 @@ godot_string GDAPI godot_string_md5_text(const godot_string *p_self) {
memnew_placement(&result, String(self->md5_text()));
return result;
-};
+}
godot_pool_byte_array GDAPI godot_string_sha256_buffer(const godot_string *p_self) {
const String *self = (const String *)p_self;
@@ -1035,7 +1051,7 @@ godot_pool_byte_array GDAPI godot_string_sha256_buffer(const godot_string *p_sel
}
return result;
-};
+}
godot_string GDAPI godot_string_sha256_text(const godot_string *p_self) {
const String *self = (const String *)p_self;
@@ -1043,13 +1059,13 @@ godot_string GDAPI godot_string_sha256_text(const godot_string *p_self) {
memnew_placement(&result, String(self->sha256_text()));
return result;
-};
+}
godot_bool godot_string_empty(const godot_string *p_self) {
const String *self = (const String *)p_self;
return self->empty();
-};
+}
// path functions
godot_string GDAPI godot_string_get_base_dir(const godot_string *p_self) {
@@ -1059,7 +1075,7 @@ godot_string GDAPI godot_string_get_base_dir(const godot_string *p_self) {
memnew_placement(&result, String(return_value));
return result;
-};
+}
godot_string GDAPI godot_string_get_file(const godot_string *p_self) {
const String *self = (const String *)p_self;
@@ -1068,7 +1084,7 @@ godot_string GDAPI godot_string_get_file(const godot_string *p_self) {
memnew_placement(&result, String(return_value));
return result;
-};
+}
godot_string GDAPI godot_string_humanize_size(size_t p_size) {
godot_string result;
@@ -1076,25 +1092,25 @@ godot_string GDAPI godot_string_humanize_size(size_t p_size) {
memnew_placement(&result, String(return_value));
return result;
-};
+}
godot_bool GDAPI godot_string_is_abs_path(const godot_string *p_self) {
const String *self = (const String *)p_self;
return self->is_abs_path();
-};
+}
godot_bool GDAPI godot_string_is_rel_path(const godot_string *p_self) {
const String *self = (const String *)p_self;
return self->is_rel_path();
-};
+}
godot_bool GDAPI godot_string_is_resource_file(const godot_string *p_self) {
const String *self = (const String *)p_self;
return self->is_resource_file();
-};
+}
godot_string GDAPI godot_string_path_to(const godot_string *p_self, const godot_string *p_path) {
const String *self = (const String *)p_self;
@@ -1104,7 +1120,7 @@ godot_string GDAPI godot_string_path_to(const godot_string *p_self, const godot_
memnew_placement(&result, String(return_value));
return result;
-};
+}
godot_string GDAPI godot_string_path_to_file(const godot_string *p_self, const godot_string *p_path) {
const String *self = (const String *)p_self;
@@ -1114,7 +1130,7 @@ godot_string GDAPI godot_string_path_to_file(const godot_string *p_self, const g
memnew_placement(&result, String(return_value));
return result;
-};
+}
godot_string GDAPI godot_string_simplify_path(const godot_string *p_self) {
const String *self = (const String *)p_self;
@@ -1123,7 +1139,7 @@ godot_string GDAPI godot_string_simplify_path(const godot_string *p_self) {
memnew_placement(&result, String(return_value));
return result;
-};
+}
godot_string GDAPI godot_string_c_escape(const godot_string *p_self) {
const String *self = (const String *)p_self;
@@ -1132,7 +1148,7 @@ godot_string GDAPI godot_string_c_escape(const godot_string *p_self) {
memnew_placement(&result, String(return_value));
return result;
-};
+}
godot_string GDAPI godot_string_c_escape_multiline(const godot_string *p_self) {
const String *self = (const String *)p_self;
@@ -1141,7 +1157,7 @@ godot_string GDAPI godot_string_c_escape_multiline(const godot_string *p_self) {
memnew_placement(&result, String(return_value));
return result;
-};
+}
godot_string GDAPI godot_string_c_unescape(const godot_string *p_self) {
const String *self = (const String *)p_self;
@@ -1150,7 +1166,7 @@ godot_string GDAPI godot_string_c_unescape(const godot_string *p_self) {
memnew_placement(&result, String(return_value));
return result;
-};
+}
godot_string GDAPI godot_string_http_escape(const godot_string *p_self) {
const String *self = (const String *)p_self;
@@ -1159,7 +1175,7 @@ godot_string GDAPI godot_string_http_escape(const godot_string *p_self) {
memnew_placement(&result, String(return_value));
return result;
-};
+}
godot_string GDAPI godot_string_http_unescape(const godot_string *p_self) {
const String *self = (const String *)p_self;
@@ -1168,7 +1184,7 @@ godot_string GDAPI godot_string_http_unescape(const godot_string *p_self) {
memnew_placement(&result, String(return_value));
return result;
-};
+}
godot_string GDAPI godot_string_json_escape(const godot_string *p_self) {
const String *self = (const String *)p_self;
@@ -1177,7 +1193,7 @@ godot_string GDAPI godot_string_json_escape(const godot_string *p_self) {
memnew_placement(&result, String(return_value));
return result;
-};
+}
godot_string GDAPI godot_string_word_wrap(const godot_string *p_self, godot_int p_chars_per_line) {
const String *self = (const String *)p_self;
@@ -1186,7 +1202,7 @@ godot_string GDAPI godot_string_word_wrap(const godot_string *p_self, godot_int
memnew_placement(&result, String(return_value));
return result;
-};
+}
godot_string GDAPI godot_string_xml_escape(const godot_string *p_self) {
const String *self = (const String *)p_self;
@@ -1195,7 +1211,7 @@ godot_string GDAPI godot_string_xml_escape(const godot_string *p_self) {
memnew_placement(&result, String(return_value));
return result;
-};
+}
godot_string GDAPI godot_string_xml_escape_with_quotes(const godot_string *p_self) {
const String *self = (const String *)p_self;
@@ -1204,7 +1220,7 @@ godot_string GDAPI godot_string_xml_escape_with_quotes(const godot_string *p_sel
memnew_placement(&result, String(return_value));
return result;
-};
+}
godot_string GDAPI godot_string_xml_unescape(const godot_string *p_self) {
const String *self = (const String *)p_self;
@@ -1213,7 +1229,7 @@ godot_string GDAPI godot_string_xml_unescape(const godot_string *p_self) {
memnew_placement(&result, String(return_value));
return result;
-};
+}
godot_string GDAPI godot_string_percent_decode(const godot_string *p_self) {
const String *self = (const String *)p_self;
@@ -1222,7 +1238,7 @@ godot_string GDAPI godot_string_percent_decode(const godot_string *p_self) {
memnew_placement(&result, String(return_value));
return result;
-};
+}
godot_string GDAPI godot_string_percent_encode(const godot_string *p_self) {
const String *self = (const String *)p_self;
@@ -1231,43 +1247,43 @@ godot_string GDAPI godot_string_percent_encode(const godot_string *p_self) {
memnew_placement(&result, String(return_value));
return result;
-};
+}
godot_bool GDAPI godot_string_is_valid_float(const godot_string *p_self) {
const String *self = (const String *)p_self;
return self->is_valid_float();
-};
+}
godot_bool GDAPI godot_string_is_valid_hex_number(const godot_string *p_self, godot_bool p_with_prefix) {
const String *self = (const String *)p_self;
return self->is_valid_hex_number(p_with_prefix);
-};
+}
godot_bool GDAPI godot_string_is_valid_html_color(const godot_string *p_self) {
const String *self = (const String *)p_self;
return self->is_valid_html_color();
-};
+}
godot_bool GDAPI godot_string_is_valid_identifier(const godot_string *p_self) {
const String *self = (const String *)p_self;
return self->is_valid_identifier();
-};
+}
godot_bool GDAPI godot_string_is_valid_integer(const godot_string *p_self) {
const String *self = (const String *)p_self;
return self->is_valid_integer();
-};
+}
godot_bool GDAPI godot_string_is_valid_ip_address(const godot_string *p_self) {
const String *self = (const String *)p_self;
return self->is_valid_ip_address();
-};
+}
#ifdef __cplusplus
}
diff --git a/modules/gdnative/gdnative/transform.cpp b/modules/gdnative/gdnative/transform.cpp
index 9bd8c99612..715f2e3c08 100644
--- a/modules/gdnative/gdnative/transform.cpp
+++ b/modules/gdnative/gdnative/transform.cpp
@@ -63,7 +63,7 @@ godot_basis GDAPI godot_transform_get_basis(const godot_transform *p_self) {
return dest;
}
-void GDAPI godot_transform_set_basis(godot_transform *p_self, godot_basis *p_v) {
+void GDAPI godot_transform_set_basis(godot_transform *p_self, const godot_basis *p_v) {
Transform *self = (Transform *)p_self;
const Basis *v = (const Basis *)p_v;
self->basis = *v;
@@ -76,7 +76,7 @@ godot_vector3 GDAPI godot_transform_get_origin(const godot_transform *p_self) {
return dest;
}
-void GDAPI godot_transform_set_origin(godot_transform *p_self, godot_vector3 *p_v) {
+void GDAPI godot_transform_set_origin(godot_transform *p_self, const godot_vector3 *p_v) {
Transform *self = (Transform *)p_self;
const Vector3 *v = (const Vector3 *)p_v;
self->origin = *v;
diff --git a/modules/gdnative/gdnative_api.json b/modules/gdnative/gdnative_api.json
index 06c6e9f410..6e3cf16758 100644
--- a/modules/gdnative/gdnative_api.json
+++ b/modules/gdnative/gdnative_api.json
@@ -3516,7 +3516,7 @@
"return_type": "void",
"arguments": [
["godot_transform *", "p_self"],
- ["godot_basis *", "p_v"]
+ ["const godot_basis *", "p_v"]
]
},
{
@@ -3531,7 +3531,7 @@
"return_type": "void",
"arguments": [
["godot_transform *", "p_self"],
- ["godot_vector3 *", "p_v"]
+ ["const godot_vector3 *", "p_v"]
]
},
{
@@ -4324,45 +4324,48 @@
]
},
{
- "name": "godot_string_new",
- "return_type": "void",
+ "name": "godot_char_string_length",
+ "return_type": "godot_int",
"arguments": [
- ["godot_string *", "r_dest"]
+ ["const godot_char_string *", "p_cs"]
]
},
{
- "name": "godot_string_new_copy",
+ "name": "godot_char_string_get_data",
+ "return_type": "const char *",
+ "arguments": [
+ ["const godot_char_string *", "p_cs"]
+ ]
+ },
+ {
+ "name": "godot_char_string_destroy",
"return_type": "void",
"arguments": [
- ["godot_string *", "r_dest"],
- ["const godot_string *", "p_src"]
+ ["godot_char_string *", "p_cs"]
]
},
{
- "name": "godot_string_new_data",
+ "name": "godot_string_new",
"return_type": "void",
"arguments": [
- ["godot_string *", "r_dest"],
- ["const char *", "p_contents"],
- ["const int", "p_size"]
+ ["godot_string *", "r_dest"]
]
},
{
- "name": "godot_string_new_unicode_data",
+ "name": "godot_string_new_copy",
"return_type": "void",
"arguments": [
["godot_string *", "r_dest"],
- ["const wchar_t *", "p_contents"],
- ["const int", "p_size"]
+ ["const godot_string *", "p_src"]
]
},
{
- "name": "godot_string_get_data",
+ "name": "godot_string_new_with_wide_string",
"return_type": "void",
"arguments": [
- ["const godot_string *", "p_self"],
- ["char *", "p_dest"],
- ["int *", "p_size"]
+ ["godot_string *", "r_dest"],
+ ["const wchar_t *", "p_contents"],
+ ["const int", "p_size"]
]
},
{
@@ -4382,7 +4385,7 @@
]
},
{
- "name": "godot_string_unicode_str",
+ "name": "godot_string_wide_str",
"return_type": "const wchar_t *",
"arguments": [
["const godot_string *", "p_self"]
@@ -4420,6 +4423,30 @@
]
},
{
+ "name": "godot_string_casecmp_to",
+ "return_type": "signed char",
+ "arguments": [
+ ["const godot_string *", "p_self"],
+ ["const godot_string *", "p_str"]
+ ]
+ },
+ {
+ "name": "godot_string_nocasecmp_to",
+ "return_type": "signed char",
+ "arguments": [
+ ["const godot_string *", "p_self"],
+ ["const godot_string *", "p_str"]
+ ]
+ },
+ {
+ "name": "godot_string_naturalnocasecmp_to",
+ "return_type": "signed char",
+ "arguments": [
+ ["const godot_string *", "p_self"],
+ ["const godot_string *", "p_str"]
+ ]
+ },
+ {
"name": "godot_string_begins_with",
"return_type": "godot_bool",
"arguments": [
@@ -5125,26 +5152,23 @@
},
{
"name": "godot_string_ascii",
- "return_type": "void",
+ "return_type": "godot_char_string",
"arguments": [
- ["godot_string *", "p_self"],
- ["char *", "result"]
+ ["const godot_string *", "p_self"]
]
},
{
"name": "godot_string_ascii_extended",
- "return_type": "void",
+ "return_type": "godot_char_string",
"arguments": [
- ["godot_string *", "p_self"],
- ["char *", "result"]
+ ["const godot_string *", "p_self"]
]
},
{
"name": "godot_string_utf8",
- "return_type": "void",
+ "return_type": "godot_char_string",
"arguments": [
- ["godot_string *", "p_self"],
- ["char *", "result"]
+ ["const godot_string *", "p_self"]
]
},
{
diff --git a/modules/gdnative/include/gdnative/string.h b/modules/gdnative/include/gdnative/string.h
index 080c0aa171..73245160c1 100644
--- a/modules/gdnative/include/gdnative/string.h
+++ b/modules/gdnative/include/gdnative/string.h
@@ -38,13 +38,24 @@ extern "C" {
#include <stdint.h>
#include <wchar.h>
+typedef wchar_t godot_char_type;
+
#define GODOT_STRING_SIZE sizeof(void *)
+#define GODOT_CHAR_STRING_SIZE sizeof(void *)
#ifndef GODOT_CORE_API_GODOT_STRING_TYPE_DEFINED
#define GODOT_CORE_API_GODOT_STRING_TYPE_DEFINED
typedef struct {
uint8_t _dont_touch_that[GODOT_STRING_SIZE];
} godot_string;
+
+#endif
+
+#ifndef GODOT_CORE_API_GODOT_CHAR_STRING_TYPE_DEFINED
+#define GODOT_CORE_API_GODOT_CHAR_STRING_TYPE_DEFINED
+typedef struct {
+ uint8_t _dont_touch_that[GODOT_CHAR_STRING_SIZE];
+} godot_char_string;
#endif
// reduce extern "C" nesting for VS2013
@@ -60,16 +71,17 @@ typedef struct {
extern "C" {
#endif
+godot_int GDAPI godot_char_string_length(const godot_char_string *p_cs);
+const char GDAPI *godot_char_string_get_data(const godot_char_string *p_cs);
+void GDAPI godot_char_string_destroy(godot_char_string *p_cs);
+
void GDAPI godot_string_new(godot_string *r_dest);
void GDAPI godot_string_new_copy(godot_string *r_dest, const godot_string *p_src);
-void GDAPI godot_string_new_data(godot_string *r_dest, const char *p_contents, const int p_size);
-void GDAPI godot_string_new_unicode_data(godot_string *r_dest, const wchar_t *p_contents, const int p_size);
-
-void GDAPI godot_string_get_data(const godot_string *p_self, char *p_dest, int *p_size);
+void GDAPI godot_string_new_with_wide_string(godot_string *r_dest, const wchar_t *p_contents, const int p_size);
wchar_t GDAPI *godot_string_operator_index(godot_string *p_self, const godot_int p_idx);
wchar_t GDAPI godot_string_operator_index_const(const godot_string *p_self, const godot_int p_idx);
-const wchar_t GDAPI *godot_string_unicode_str(const godot_string *p_self);
+const wchar_t GDAPI *godot_string_wide_str(const godot_string *p_self);
godot_bool GDAPI godot_string_operator_equal(const godot_string *p_self, const godot_string *p_b);
godot_bool GDAPI godot_string_operator_less(const godot_string *p_self, const godot_string *p_b);
@@ -81,6 +93,10 @@ godot_int GDAPI godot_string_length(const godot_string *p_self);
/* Helpers */
+signed char GDAPI godot_string_casecmp_to(const godot_string *p_self, const godot_string *p_str);
+signed char GDAPI godot_string_nocasecmp_to(const godot_string *p_self, const godot_string *p_str);
+signed char GDAPI godot_string_naturalnocasecmp_to(const godot_string *p_self, const godot_string *p_str);
+
godot_bool GDAPI godot_string_begins_with(const godot_string *p_self, const godot_string *p_string);
godot_bool GDAPI godot_string_begins_with_char_array(const godot_string *p_self, const char *p_char_array);
godot_array GDAPI godot_string_bigrams(const godot_string *p_self);
@@ -177,9 +193,9 @@ godot_string GDAPI godot_string_strip_escapes(const godot_string *p_self);
void GDAPI godot_string_erase(godot_string *p_self, godot_int p_pos, godot_int p_chars);
-void GDAPI godot_string_ascii(godot_string *p_self, char *result);
-void GDAPI godot_string_ascii_extended(godot_string *p_self, char *result);
-void GDAPI godot_string_utf8(godot_string *p_self, char *result);
+godot_char_string GDAPI godot_string_ascii(const godot_string *p_self);
+godot_char_string GDAPI godot_string_ascii_extended(const godot_string *p_self);
+godot_char_string GDAPI godot_string_utf8(const godot_string *p_self);
godot_bool GDAPI godot_string_parse_utf8(godot_string *p_self, const char *p_utf8);
godot_bool GDAPI godot_string_parse_utf8_with_len(godot_string *p_self, const char *p_utf8, godot_int p_len);
godot_string GDAPI godot_string_chars_to_utf8(const char *p_utf8);
diff --git a/modules/gdnative/include/gdnative/transform.h b/modules/gdnative/include/gdnative/transform.h
index 10a242b205..a646da146a 100644
--- a/modules/gdnative/include/gdnative/transform.h
+++ b/modules/gdnative/include/gdnative/transform.h
@@ -64,10 +64,10 @@ void GDAPI godot_transform_new_with_axis_origin(godot_transform *r_dest, const g
void GDAPI godot_transform_new(godot_transform *r_dest, const godot_basis *p_basis, const godot_vector3 *p_origin);
godot_basis GDAPI godot_transform_get_basis(const godot_transform *p_self);
-void GDAPI godot_transform_set_basis(godot_transform *p_self, godot_basis *p_v);
+void GDAPI godot_transform_set_basis(godot_transform *p_self, const godot_basis *p_v);
godot_vector3 GDAPI godot_transform_get_origin(const godot_transform *p_self);
-void GDAPI godot_transform_set_origin(godot_transform *p_self, godot_vector3 *p_v);
+void GDAPI godot_transform_set_origin(godot_transform *p_self, const godot_vector3 *p_v);
godot_string GDAPI godot_transform_as_string(const godot_transform *p_self);
diff --git a/modules/gdnative/pluginscript/pluginscript_language.cpp b/modules/gdnative/pluginscript/pluginscript_language.cpp
index 2405afc677..8101ebc6f3 100644
--- a/modules/gdnative/pluginscript/pluginscript_language.cpp
+++ b/modules/gdnative/pluginscript/pluginscript_language.cpp
@@ -45,7 +45,11 @@ void PluginScriptLanguage::init() {
}
String PluginScriptLanguage::get_type() const {
- return String(_desc.type);
+ // We should use _desc.type here, however the returned type is used to
+ // query ClassDB which would complain given the type is not registered
+ // from his point of view...
+ // To solve this we just use a more generic (but present in ClassDB) type.
+ return String("PluginScript");
}
String PluginScriptLanguage::get_extension() const {
@@ -168,7 +172,7 @@ Error PluginScriptLanguage::complete_code(const String &p_code, const String &p_
for (int i = 0; i < options.size(); i++) {
r_options->push_back(String(options[i]));
}
- Error err = *(Error *)tmp;
+ Error err = *(Error *)&tmp;
return err;
}
return ERR_UNAVAILABLE;
diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp
index 2d7583cc23..db2d0a9780 100644
--- a/modules/mono/csharp_script.cpp
+++ b/modules/mono/csharp_script.cpp
@@ -449,7 +449,7 @@ Vector<ScriptLanguage::StackInfo> CSharpLanguage::debug_get_current_stack_info()
// Printing an error here will result in endless recursion, so we must be careful
- if (!gdmono->is_runtime_initialized() && GDMono::get_singleton()->get_editor_tools_assembly())
+ if (!gdmono->is_runtime_initialized() && GDMono::get_singleton()->get_api_assembly())
return Vector<StackInfo>();
MonoObject *stack_trace = mono_object_new(mono_domain_get(), CACHED_CLASS(System_Diagnostics_StackTrace)->get_mono_ptr());
diff --git a/modules/mono/glue/cs_files/Color.cs b/modules/mono/glue/cs_files/Color.cs
index db0e1fb744..f9e31e9703 100644
--- a/modules/mono/glue/cs_files/Color.cs
+++ b/modules/mono/glue/cs_files/Color.cs
@@ -336,7 +336,7 @@ namespace Godot
this.r = (rgba & 0xFF) / 255.0f;
}
- private static float _parse_col(string str, int ofs)
+ private static int _parse_col(string str, int ofs)
{
int ig = 0;
@@ -415,17 +415,17 @@ namespace Godot
if (alpha)
{
- if ((int)_parse_col(color, 0) < 0)
+ if (_parse_col(color, 0) < 0)
return false;
}
int from = alpha ? 2 : 0;
- if ((int)_parse_col(color, from + 0) < 0)
+ if (_parse_col(color, from + 0) < 0)
return false;
- if ((int)_parse_col(color, from + 2) < 0)
+ if (_parse_col(color, from + 2) < 0)
return false;
- if ((int)_parse_col(color, from + 4) < 0)
+ if (_parse_col(color, from + 4) < 0)
return false;
return true;
@@ -467,10 +467,10 @@ namespace Godot
if (alpha)
{
- a = _parse_col(rgba, 0);
+ a = _parse_col(rgba, 0) / 255f;
if (a < 0)
- throw new ArgumentOutOfRangeException("Invalid color code. Alpha is " + a + " but zero or greater is expected: " + rgba);
+ throw new ArgumentOutOfRangeException("Invalid color code. Alpha part is not valid hexadecimal: " + rgba);
}
else
{
@@ -479,20 +479,20 @@ namespace Godot
int from = alpha ? 2 : 0;
- r = _parse_col(rgba, from + 0);
+ r = _parse_col(rgba, from + 0) / 255f;
if (r < 0)
- throw new ArgumentOutOfRangeException("Invalid color code. Red is " + r + " but zero or greater is expected: " + rgba);
+ throw new ArgumentOutOfRangeException("Invalid color code. Red part is not valid hexadecimal: " + rgba);
- g = _parse_col(rgba, from + 2);
+ g = _parse_col(rgba, from + 2) / 255f;
if (g < 0)
- throw new ArgumentOutOfRangeException("Invalid color code. Green is " + g + " but zero or greater is expected: " + rgba);
+ throw new ArgumentOutOfRangeException("Invalid color code. Green part is not valid hexadecimal: " + rgba);
- b = _parse_col(rgba, from + 4);
+ b = _parse_col(rgba, from + 4) / 255f;
if (b < 0)
- throw new ArgumentOutOfRangeException("Invalid color code. Blue is " + b + " but zero or greater is expected: " + rgba);
+ throw new ArgumentOutOfRangeException("Invalid color code. Blue part is not valid hexadecimal: " + rgba);
}
public static bool operator ==(Color left, Color right)
diff --git a/modules/mono/mono_gd/gd_mono_utils.cpp b/modules/mono/mono_gd/gd_mono_utils.cpp
index 4aa2c007c2..d02c73978e 100644
--- a/modules/mono/mono_gd/gd_mono_utils.cpp
+++ b/modules/mono/mono_gd/gd_mono_utils.cpp
@@ -399,7 +399,7 @@ void print_unhandled_exception(MonoObject *p_exc) {
print_unhandled_exception(p_exc, false);
}
-void print_unhandled_exception(MonoObject *p_exc, bool p_fail_silently) {
+void print_unhandled_exception(MonoObject *p_exc, bool p_recursion_caution) {
mono_print_unhandled_exception(p_exc);
#ifdef DEBUG_ENABLED
GDMonoClass *st_klass = CACHED_CLASS(System_Diagnostics_StackTrace);
@@ -414,7 +414,7 @@ void print_unhandled_exception(MonoObject *p_exc, bool p_fail_silently) {
if (unexpected_exc != NULL) {
mono_print_unhandled_exception(unexpected_exc);
- if (p_fail_silently) {
+ if (p_recursion_caution) {
// Called from CSharpLanguage::get_current_stack_info,
// so printing an error here could result in endless recursion
OS::get_singleton()->printerr("Mono: Method GDMonoUtils::print_unhandled_exception failed");
@@ -425,7 +425,7 @@ void print_unhandled_exception(MonoObject *p_exc, bool p_fail_silently) {
}
Vector<ScriptLanguage::StackInfo> si;
- if (stack_trace != NULL)
+ if (stack_trace != NULL && !p_recursion_caution)
si = CSharpLanguage::get_singleton()->stack_trace_get_info(stack_trace);
String file = si.size() ? si[0].file : __FILE__;
diff --git a/modules/mono/mono_gd/gd_mono_utils.h b/modules/mono/mono_gd/gd_mono_utils.h
index 1acc547993..597397eced 100644
--- a/modules/mono/mono_gd/gd_mono_utils.h
+++ b/modules/mono/mono_gd/gd_mono_utils.h
@@ -177,7 +177,7 @@ MonoDomain *create_domain(const String &p_friendly_name);
String get_exception_name_and_message(MonoObject *p_ex);
void print_unhandled_exception(MonoObject *p_exc);
-void print_unhandled_exception(MonoObject *p_exc, bool p_fail_silently);
+void print_unhandled_exception(MonoObject *p_exc, bool p_recursion_caution);
} // namespace GDMonoUtils
diff --git a/platform/osx/os_osx.h b/platform/osx/os_osx.h
index 3648d41604..a1869497ef 100644
--- a/platform/osx/os_osx.h
+++ b/platform/osx/os_osx.h
@@ -52,6 +52,21 @@
class OS_OSX : public OS_Unix {
public:
+ enum {
+ KEY_EVENT_BUFFER_SIZE = 512
+ };
+
+ struct KeyEvent {
+ unsigned int osx_state;
+ bool pressed;
+ bool echo;
+ uint32_t scancode;
+ uint32_t unicode;
+ };
+
+ KeyEvent key_event_buffer[KEY_EVENT_BUFFER_SIZE];
+ int key_event_pos;
+
bool force_quit;
// rasterizer seems to no longer be given to visual server, its using GLES3 directly?
//Rasterizer *rasterizer;
@@ -72,6 +87,7 @@ public:
CGEventSourceRef eventSource;
void process_events();
+ void process_key_events();
void *framework;
// pthread_key_t current;
diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm
index 939f75859c..d0cc115f0e 100644
--- a/platform/osx/os_osx.mm
+++ b/platform/osx/os_osx.mm
@@ -407,13 +407,6 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
- (void)insertText:(id)aString replacementRange:(NSRange)replacementRange {
NSEvent *event = [NSApp currentEvent];
- Ref<InputEventKey> k;
- k.instance();
-
- get_key_modifier_state([event modifierFlags], k);
- k->set_pressed(true);
- k->set_echo(false);
- k->set_scancode(0);
NSString *characters;
if ([aString isKindOfClass:[NSAttributedString class]]) {
@@ -438,8 +431,15 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
if ((codepoint & 0xFF00) == 0xF700)
continue;
- k->set_unicode(codepoint);
- OS_OSX::singleton->push_input(k);
+ OS_OSX::KeyEvent ke;
+
+ ke.osx_state = [event modifierFlags];
+ ke.pressed = true;
+ ke.echo = false;
+ ke.scancode = 0;
+ ke.unicode = codepoint;
+
+ OS_OSX::singleton->key_event_buffer[OS_OSX::singleton->key_event_pos++] = ke;
}
[self cancelComposition];
}
@@ -788,80 +788,87 @@ static int translateKey(unsigned int key) {
- (void)keyDown:(NSEvent *)event {
- Ref<InputEventKey> k;
- k.instance();
-
- get_key_modifier_state([event modifierFlags], k);
- k->set_pressed(true);
- k->set_scancode(latin_keyboard_keycode_convert(translateKey([event keyCode])));
- k->set_echo([event isARepeat]);
+ //disable raw input in IME mode
+ if (!imeMode) {
+ OS_OSX::KeyEvent ke;
- NSString *characters = [event characters];
- NSUInteger i, length = [characters length];
+ ke.osx_state = [event modifierFlags];
+ ke.pressed = true;
+ ke.echo = [event isARepeat];
+ ke.scancode = latin_keyboard_keycode_convert(translateKey([event keyCode]));
+ ke.unicode = 0;
- //disable raw input in IME mode
- if (!imeMode)
- OS_OSX::singleton->push_input(k);
+ OS_OSX::singleton->key_event_buffer[OS_OSX::singleton->key_event_pos++] = ke;
+ }
if ((OS_OSX::singleton->im_position.x != 0) && (OS_OSX::singleton->im_position.y != 0))
[self interpretKeyEvents:[NSArray arrayWithObject:event]];
}
- (void)flagsChanged:(NSEvent *)event {
- Ref<InputEventKey> k;
- k.instance();
- int key = [event keyCode];
- int mod = [event modifierFlags];
+ if (!imeMode) {
+ OS_OSX::KeyEvent ke;
- if (key == 0x36 || key == 0x37) {
- if (mod & NSEventModifierFlagCommand) {
- mod &= ~NSEventModifierFlagCommand;
- k->set_pressed(true);
- } else {
- k->set_pressed(false);
- }
- } else if (key == 0x38 || key == 0x3c) {
- if (mod & NSEventModifierFlagShift) {
- mod &= ~NSEventModifierFlagShift;
- k->set_pressed(true);
- } else {
- k->set_pressed(false);
- }
- } else if (key == 0x3a || key == 0x3d) {
- if (mod & NSEventModifierFlagOption) {
- mod &= ~NSEventModifierFlagOption;
- k->set_pressed(true);
- } else {
- k->set_pressed(false);
- }
- } else if (key == 0x3b || key == 0x3e) {
- if (mod & NSEventModifierFlagControl) {
- mod &= ~NSEventModifierFlagControl;
- k->set_pressed(true);
+ ke.echo = false;
+
+ int key = [event keyCode];
+ int mod = [event modifierFlags];
+
+ if (key == 0x36 || key == 0x37) {
+ if (mod & NSEventModifierFlagCommand) {
+ mod &= ~NSEventModifierFlagCommand;
+ ke.pressed = true;
+ } else {
+ ke.pressed = false;
+ }
+ } else if (key == 0x38 || key == 0x3c) {
+ if (mod & NSEventModifierFlagShift) {
+ mod &= ~NSEventModifierFlagShift;
+ ke.pressed = true;
+ } else {
+ ke.pressed = false;
+ }
+ } else if (key == 0x3a || key == 0x3d) {
+ if (mod & NSEventModifierFlagOption) {
+ mod &= ~NSEventModifierFlagOption;
+ ke.pressed = true;
+ } else {
+ ke.pressed = false;
+ }
+ } else if (key == 0x3b || key == 0x3e) {
+ if (mod & NSEventModifierFlagControl) {
+ mod &= ~NSEventModifierFlagControl;
+ ke.pressed = true;
+ } else {
+ ke.pressed = false;
+ }
} else {
- k->set_pressed(false);
+ return;
}
- } else {
- return;
- }
- get_key_modifier_state(mod, k);
- k->set_scancode(latin_keyboard_keycode_convert(translateKey(key)));
+ ke.osx_state = mod;
+ ke.scancode = latin_keyboard_keycode_convert(translateKey(key));
+ ke.unicode = 0;
- OS_OSX::singleton->push_input(k);
+ OS_OSX::singleton->key_event_buffer[OS_OSX::singleton->key_event_pos++] = ke;
+ }
}
- (void)keyUp:(NSEvent *)event {
- Ref<InputEventKey> k;
- k.instance();
+ if (!imeMode) {
+
+ OS_OSX::KeyEvent ke;
- get_key_modifier_state([event modifierFlags], k);
- k->set_pressed(false);
- k->set_scancode(latin_keyboard_keycode_convert(translateKey([event keyCode])));
+ ke.osx_state = [event modifierFlags];
+ ke.pressed = false;
+ ke.echo = false;
+ ke.scancode = latin_keyboard_keycode_convert(translateKey([event keyCode]));
+ ke.unicode = 0;
- OS_OSX::singleton->push_input(k);
+ OS_OSX::singleton->key_event_buffer[OS_OSX::singleton->key_event_pos++] = ke;
+ }
}
inline void sendScrollEvent(int button, double factor, int modifierFlags) {
@@ -2060,11 +2067,49 @@ void OS_OSX::process_events() {
[NSApp sendEvent:event];
}
+ process_key_events();
[autoreleasePool drain];
autoreleasePool = [[NSAutoreleasePool alloc] init];
}
+void OS_OSX::process_key_events() {
+
+ Ref<InputEventKey> k;
+ for (int i = 0; i < key_event_pos; i++) {
+
+ KeyEvent &ke = key_event_buffer[i];
+
+ if ((i == 0 && ke.scancode == 0) || (i > 0 && key_event_buffer[i - 1].scancode == 0)) {
+ k.instance();
+
+ get_key_modifier_state(ke.osx_state, k);
+ k->set_pressed(ke.pressed);
+ k->set_echo(ke.echo);
+ k->set_scancode(0);
+ k->set_unicode(ke.unicode);
+
+ push_input(k);
+ }
+ if (ke.scancode != 0) {
+ k.instance();
+
+ get_key_modifier_state(ke.osx_state, k);
+ k->set_pressed(ke.pressed);
+ k->set_echo(ke.echo);
+ k->set_scancode(ke.scancode);
+
+ if (i + 1 < key_event_pos && key_event_buffer[i + 1].scancode == 0) {
+ k->set_unicode(key_event_buffer[i + 1].unicode);
+ }
+
+ push_input(k);
+ }
+ }
+
+ key_event_pos = 0;
+}
+
void OS_OSX::push_input(const Ref<InputEvent> &p_event) {
Ref<InputEvent> ev = p_event;
@@ -2184,6 +2229,7 @@ OS_OSX *OS_OSX::singleton = NULL;
OS_OSX::OS_OSX() {
+ key_event_pos = 0;
mouse_mode = OS::MOUSE_MODE_VISIBLE;
main_loop = NULL;
singleton = this;
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp
index 4f4b225b14..5736ae1585 100644
--- a/platform/windows/os_windows.cpp
+++ b/platform/windows/os_windows.cpp
@@ -462,6 +462,7 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
case WM_MOUSEWHEEL:
case WM_MOUSEHWHEEL:
case WM_LBUTTONDBLCLK:
+ case WM_MBUTTONDBLCLK:
case WM_RBUTTONDBLCLK:
/*case WM_XBUTTONDOWN:
case WM_XBUTTONUP: */ {
@@ -520,6 +521,12 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
mb->set_button_index(2);
mb->set_doubleclick(true);
} break;
+ case WM_MBUTTONDBLCLK: {
+
+ mb->set_pressed(true);
+ mb->set_button_index(3);
+ mb->set_doubleclick(true);
+ } break;
case WM_MOUSEWHEEL: {
mb->set_pressed(true);
diff --git a/scene/3d/baked_lightmap.cpp b/scene/3d/baked_lightmap.cpp
index 96eb7eb6f4..9d77951bff 100644
--- a/scene/3d/baked_lightmap.cpp
+++ b/scene/3d/baked_lightmap.cpp
@@ -784,7 +784,7 @@ void BakedLightmap::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::REAL, "capture_cell_size", PROPERTY_HINT_RANGE, "0.01,64,0.01"), "set_capture_cell_size", "get_capture_cell_size");
ADD_GROUP("Data", "");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "image_path", PROPERTY_HINT_DIR), "set_image_path", "get_image_path");
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "light_data", PROPERTY_HINT_RESOURCE_TYPE, "BakedIndirectLightData"), "set_light_data", "get_light_data");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "light_data", PROPERTY_HINT_RESOURCE_TYPE, "BakedLightmapData"), "set_light_data", "get_light_data");
BIND_ENUM_CONSTANT(BAKE_QUALITY_LOW);
BIND_ENUM_CONSTANT(BAKE_QUALITY_MEDIUM);
diff --git a/scene/3d/particles.cpp b/scene/3d/particles.cpp
index 219464ae1f..8617bbc2f6 100644
--- a/scene/3d/particles.cpp
+++ b/scene/3d/particles.cpp
@@ -1597,4 +1597,21 @@ ParticlesMaterial::ParticlesMaterial() :
}
ParticlesMaterial::~ParticlesMaterial() {
+
+ if (material_mutex)
+ material_mutex->lock();
+
+ if (shader_map.has(current_key)) {
+ shader_map[current_key].users--;
+ if (shader_map[current_key].users == 0) {
+ //deallocate shader, as it's no longer in use
+ VS::get_singleton()->free(shader_map[current_key].shader);
+ shader_map.erase(current_key);
+ }
+
+ VS::get_singleton()->material_set_shader(_get_material(), RID());
+ }
+
+ if (material_mutex)
+ material_mutex->unlock();
}
diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp
index d765248cca..8b9469021c 100644
--- a/scene/gui/base_button.cpp
+++ b/scene/gui/base_button.cpp
@@ -504,12 +504,12 @@ void BaseButton::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_button_group"), &BaseButton::get_button_group);
BIND_VMETHOD(MethodInfo("_pressed"));
- BIND_VMETHOD(MethodInfo("_toggled", PropertyInfo(Variant::BOOL, "pressed")));
+ BIND_VMETHOD(MethodInfo("_toggled", PropertyInfo(Variant::BOOL, "button_pressed")));
ADD_SIGNAL(MethodInfo("pressed"));
ADD_SIGNAL(MethodInfo("button_up"));
ADD_SIGNAL(MethodInfo("button_down"));
- ADD_SIGNAL(MethodInfo("toggled", PropertyInfo(Variant::BOOL, "pressed")));
+ ADD_SIGNAL(MethodInfo("toggled", PropertyInfo(Variant::BOOL, "button_pressed")));
ADD_PROPERTYNZ(PropertyInfo(Variant::BOOL, "disabled"), "set_disabled", "is_disabled");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "toggle_mode"), "set_toggle_mode", "is_toggle_mode");
ADD_PROPERTYNZ(PropertyInfo(Variant::BOOL, "pressed"), "set_pressed", "is_pressed");
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp
index 53f609723f..97f740a4ba 100644
--- a/scene/gui/line_edit.cpp
+++ b/scene/gui/line_edit.cpp
@@ -1413,8 +1413,8 @@ void LineEdit::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_context_menu_enabled", "enable"), &LineEdit::set_context_menu_enabled);
ClassDB::bind_method(D_METHOD("is_context_menu_enabled"), &LineEdit::is_context_menu_enabled);
- ADD_SIGNAL(MethodInfo("text_changed", PropertyInfo(Variant::STRING, "text")));
- ADD_SIGNAL(MethodInfo("text_entered", PropertyInfo(Variant::STRING, "text")));
+ ADD_SIGNAL(MethodInfo("text_changed", PropertyInfo(Variant::STRING, "new_text")));
+ ADD_SIGNAL(MethodInfo("text_entered", PropertyInfo(Variant::STRING, "new_text")));
BIND_ENUM_CONSTANT(ALIGN_LEFT);
BIND_ENUM_CONSTANT(ALIGN_CENTER);
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index f686dc52a0..aa4310da46 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -883,7 +883,7 @@ void TextEdit::_notification(int p_what) {
}
// give visual indication of empty selected line
- if (selection.active && line >= selection.from_line && line <= selection.to_line) {
+ if (selection.active && line >= selection.from_line && line <= selection.to_line && char_margin >= xmargin_beg) {
int char_w = cache.font->get_char_size(' ').width;
VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(xmargin_beg + ofs_x, ofs_y, char_w, get_row_height()), cache.selection_color);
}
diff --git a/scene/resources/bit_mask.cpp b/scene/resources/bit_mask.cpp
index e99db8d9cb..e9e15a2532 100644
--- a/scene/resources/bit_mask.cpp
+++ b/scene/resources/bit_mask.cpp
@@ -81,7 +81,7 @@ void BitMap::set_bit_rect(const Rect2 &p_rect, bool p_value) {
if (p_value)
b |= (1 << bbit);
else
- b &= !(1 << bbit);
+ b &= ~(1 << bbit);
data[bbyte] = b;
}
@@ -127,7 +127,7 @@ void BitMap::set_bit(const Point2 &p_pos, bool p_value) {
if (p_value)
b |= (1 << bbit);
else
- b &= !(1 << bbit);
+ b &= ~(1 << bbit);
bitmask[bbyte] = b;
}
diff --git a/scene/resources/tile_set.cpp b/scene/resources/tile_set.cpp
index 710612d5f4..4d200f5548 100644
--- a/scene/resources/tile_set.cpp
+++ b/scene/resources/tile_set.cpp
@@ -309,6 +309,7 @@ void TileSet::tile_set_texture(int p_id, const Ref<Texture> &p_texture) {
ERR_FAIL_COND(!tile_map.has(p_id));
tile_map[p_id].texture = p_texture;
emit_changed();
+ _change_notify("texture");
}
Ref<Texture> TileSet::tile_get_texture(int p_id) const {
@@ -386,8 +387,8 @@ void TileSet::tile_set_is_autotile(int p_id, bool p_is_autotile) {
ERR_FAIL_COND(!tile_map.has(p_id));
tile_map[p_id].is_autotile = p_is_autotile;
- _change_notify("");
emit_changed();
+ _change_notify("is_autotile");
}
bool TileSet::tile_get_is_autotile(int p_id) const {