summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/class_db.cpp1
-rw-r--r--core/io/packet_peer.cpp5
-rw-r--r--core/io/resource_format_binary.cpp2
-rw-r--r--core/make_binders.py3
-rw-r--r--core/map.h2
-rw-r--r--core/math/camera_matrix.cpp4
-rw-r--r--core/math/math_funcs.cpp9
-rw-r--r--core/math/math_funcs.h1
-rw-r--r--core/object.h6
-rw-r--r--core/os/dir_access.cpp8
-rw-r--r--core/os/dir_access.h1
-rw-r--r--core/set.h2
-rw-r--r--core/ustring.cpp45
-rw-r--r--core/ustring.h4
-rw-r--r--core/variant_call.cpp5
-rw-r--r--doc/classes/CollisionObject2D.xml8
-rw-r--r--doc/classes/KinematicBody2D.xml1
-rw-r--r--doc/classes/PointMesh.xml17
-rw-r--r--doc/classes/ProjectSettings.xml2
-rw-r--r--doc/classes/String.xml28
-rw-r--r--doc/classes/VehicleWheel.xml16
-rwxr-xr-xdoc/tools/makerst.py1
-rw-r--r--drivers/gles3/rasterizer_scene_gles3.cpp4
-rw-r--r--editor/animation_track_editor.cpp865
-rw-r--r--editor/animation_track_editor.h2
-rw-r--r--editor/doc/doc_data.cpp14
-rw-r--r--editor/editor_file_dialog.cpp19
-rw-r--r--editor/editor_file_system.cpp10
-rw-r--r--editor/editor_inspector.cpp2
-rw-r--r--editor/editor_node.cpp22
-rw-r--r--editor/editor_properties.cpp22
-rw-r--r--editor/editor_settings.cpp5
-rw-r--r--editor/editor_spin_slider.cpp4
-rw-r--r--editor/export_template_manager.cpp20
-rw-r--r--editor/icons/icon_point_mesh.svg7
-rw-r--r--editor/import/editor_import_collada.cpp50
-rw-r--r--editor/import/resource_importer_scene.cpp1
-rw-r--r--editor/plugins/mesh_library_editor_plugin.cpp2
-rw-r--r--editor/plugins/script_editor_plugin.cpp22
-rw-r--r--editor/plugins/script_text_editor.cpp9
-rw-r--r--editor/plugins/script_text_editor.h1
-rw-r--r--editor/plugins/spatial_editor_plugin.cpp98
-rw-r--r--editor/plugins/spatial_editor_plugin.h3
-rw-r--r--editor/plugins/text_editor.cpp9
-rw-r--r--editor/plugins/text_editor.h1
-rw-r--r--editor/project_manager.cpp1382
-rw-r--r--editor/project_manager.h13
-rw-r--r--editor/scene_tree_dock.cpp2
-rw-r--r--editor/script_editor_debugger.cpp5
-rw-r--r--editor/script_editor_debugger.h2
-rw-r--r--main/input_default.cpp3
-rw-r--r--main/tests/test_string.cpp39
-rw-r--r--methods.py6
-rw-r--r--modules/arkit/arkit_interface.mm12
-rw-r--r--modules/bullet/rigid_body_bullet.h2
-rw-r--r--modules/bullet/space_bullet.cpp4
-rw-r--r--modules/gdnative/gdnative/string.cpp14
-rw-r--r--modules/gdnative/gdnative/vector2.cpp8
-rw-r--r--modules/gdnative/gdnative/vector3.cpp8
-rw-r--r--modules/gdnative/gdnative_api.json36
-rw-r--r--modules/gdnative/include/gdnative/string.h2
-rw-r--r--modules/gdnative/include/gdnative/vector2.h2
-rw-r--r--modules/gdnative/include/gdnative/vector3.h2
-rw-r--r--modules/gdnative/include/nativescript/godot_nativescript.h6
-rw-r--r--modules/gdscript/doc_classes/@GDScript.xml2
-rw-r--r--modules/mono/csharp_script.cpp1
-rw-r--r--modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectUtils.cs2
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/Build/BuildSystem.cs2
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/Build/MsBuildFinder.cs38
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/GodotSharpBuilds.cs17
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs11
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/MonoBuildTab.cs65
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/MonoDevelopInstance.cs22
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/Utils/CollectionExtensions.cs5
-rw-r--r--modules/mono/glue/Managed/Files/StringExtensions.cs60
-rw-r--r--modules/mono/mono_gd/gd_mono.cpp38
-rw-r--r--modules/mono/mono_gd/gd_mono.h13
-rw-r--r--modules/mono/mono_gd/gd_mono_internals.cpp15
-rw-r--r--modules/mono/mono_gd/gd_mono_internals.h2
-rw-r--r--modules/mono/mono_gd/gd_mono_utils.cpp17
-rw-r--r--modules/mono/mono_gd/gd_mono_utils.h2
-rw-r--r--platform/iphone/camera_ios.mm2
-rw-r--r--platform/osx/os_osx.mm1
-rw-r--r--platform/uwp/export/export.cpp4
-rw-r--r--platform/windows/os_windows.cpp1
-rw-r--r--platform/x11/joypad_linux.cpp2
-rw-r--r--platform/x11/os_x11.cpp1
-rw-r--r--platform/x11/power_x11.cpp4
-rw-r--r--scene/2d/animated_sprite.cpp8
-rw-r--r--scene/2d/sprite.cpp7
-rw-r--r--scene/3d/collision_object.cpp2
-rw-r--r--scene/3d/sprite_3d.cpp16
-rw-r--r--scene/3d/vehicle_body.cpp68
-rw-r--r--scene/3d/vehicle_body.h11
-rw-r--r--scene/gui/control.cpp55
-rw-r--r--scene/gui/file_dialog.cpp9
-rw-r--r--scene/gui/spin_box.cpp2
-rw-r--r--scene/gui/tree.cpp6
-rw-r--r--scene/main/instance_placeholder.cpp2
-rw-r--r--scene/main/scene_tree.cpp5
-rw-r--r--scene/register_scene_types.cpp3
-rwxr-xr-xscene/resources/default_theme/make_header.py5
-rw-r--r--scene/resources/primitive_meshes.cpp16
-rw-r--r--scene/resources/primitive_meshes.h15
-rw-r--r--scene/resources/theme.cpp30
-rw-r--r--scene/resources/theme.h6
-rw-r--r--scene/resources/visual_shader_nodes.h4
-rw-r--r--servers/audio/effects/audio_effect_pitch_shift.cpp2
-rw-r--r--servers/physics/collision_solver_sat.cpp4
-rw-r--r--servers/physics/collision_solver_sw.cpp4
-rw-r--r--servers/physics/joints/hinge_joint_sw.cpp1
-rw-r--r--servers/physics_2d/body_2d_sw.cpp24
-rw-r--r--servers/physics_2d/broad_phase_2d_hash_grid.cpp2
-rw-r--r--servers/physics_2d/collision_solver_2d_sat.cpp4
-rw-r--r--servers/physics_2d/collision_solver_2d_sw.cpp2
-rw-r--r--servers/visual/shader_language.cpp4
-rw-r--r--servers/visual_server.cpp4
117 files changed, 2577 insertions, 982 deletions
diff --git a/core/class_db.cpp b/core/class_db.cpp
index 794d990083..49e3f94d8f 100644
--- a/core/class_db.cpp
+++ b/core/class_db.cpp
@@ -480,6 +480,7 @@ uint64_t ClassDB::get_api_hash(APIType p_api) {
for (List<StringName>::Element *F = snames.front(); F; F = F->next()) {
PropertySetGet *psg = t->property_setget.getptr(F->get());
+ ERR_FAIL_COND_V(!psg, 0);
hash = hash_djb2_one_64(F->get().hash(), hash);
hash = hash_djb2_one_64(psg->setter.hash(), hash);
diff --git a/core/io/packet_peer.cpp b/core/io/packet_peer.cpp
index c77c81f9e2..1e4ea715b3 100644
--- a/core/io/packet_peer.cpp
+++ b/core/io/packet_peer.cpp
@@ -110,10 +110,11 @@ Error PacketPeer::put_var(const Variant &p_packet, bool p_full_objects) {
Variant PacketPeer::_bnd_get_var(bool p_allow_objects) {
Variant var;
- get_var(var, p_allow_objects);
+ Error err = get_var(var, p_allow_objects);
+ ERR_FAIL_COND_V(err != OK, Variant());
return var;
-};
+}
Error PacketPeer::_put_packet(const PoolVector<uint8_t> &p_buffer) {
return put_packet_buffer(p_buffer);
diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp
index 38bef2768e..146480e5a2 100644
--- a/core/io/resource_format_binary.cpp
+++ b/core/io/resource_format_binary.cpp
@@ -718,8 +718,8 @@ Error ResourceInteractiveLoaderBinary::poll() {
Resource *r = Object::cast_to<Resource>(obj);
if (!r) {
error = ERR_FILE_CORRUPT;
- memdelete(obj); //bye
ERR_EXPLAIN(local_path + ":Resource type in resource field not a resource, type is: " + obj->get_class());
+ memdelete(obj); //bye
ERR_FAIL_V(ERR_FILE_CORRUPT);
}
diff --git a/core/make_binders.py b/core/make_binders.py
index 24901c42a1..c38db5cef4 100644
--- a/core/make_binders.py
+++ b/core/make_binders.py
@@ -334,9 +334,6 @@ def make_version(template, nargs, argmax, const, ret):
elif (cmd == "noarg"):
for i in range(nargs + 1, argmax + 1):
outtext += data.replace("@", str(i))
- elif (cmd == "noarg"):
- for i in range(nargs + 1, argmax + 1):
- outtext += data.replace("@", str(i))
from_pos = end + 1
diff --git a/core/map.h b/core/map.h
index a701ba36f7..c8197639f2 100644
--- a/core/map.h
+++ b/core/map.h
@@ -38,7 +38,7 @@
*/
// based on the very nice implementation of rb-trees by:
-// http://web.mit.edu/~emin/www/source_code/red_black_tree/index.html
+// https://web.archive.org/web/20120507164830/http://web.mit.edu/~emin/www/source_code/red_black_tree/index.html
template <class K, class V, class C = Comparator<K>, class A = DefaultAllocator>
class Map {
diff --git a/core/math/camera_matrix.cpp b/core/math/camera_matrix.cpp
index 8b3b6c82f3..30c0cab909 100644
--- a/core/math/camera_matrix.cpp
+++ b/core/math/camera_matrix.cpp
@@ -302,8 +302,8 @@ Vector<Plane> CameraMatrix::get_projection_planes(const Transform &p_transform)
/** Fast Plane Extraction from combined modelview/projection matrices.
* References:
- * http://www.markmorley.com/opengl/frustumculling.html
- * http://www2.ravensoft.com/users/ggribb/plane%20extraction.pdf
+ * https://web.archive.org/web/20011221205252/http://www.markmorley.com/opengl/frustumculling.html
+ * https://web.archive.org/web/20061020020112/http://www2.ravensoft.com/users/ggribb/plane%20extraction.pdf
*/
Vector<Plane> planes;
diff --git a/core/math/math_funcs.cpp b/core/math/math_funcs.cpp
index 7a2e74a413..f04e40cb6c 100644
--- a/core/math/math_funcs.cpp
+++ b/core/math/math_funcs.cpp
@@ -79,6 +79,15 @@ int Math::step_decimals(double p_step) {
return 0;
}
+// Only meant for editor usage in float ranges, where a step of 0
+// means that decimal digits should not be limited in String::num.
+int Math::range_step_decimals(double p_step) {
+ if (p_step < 0.0000000000001) {
+ return 16; // Max value hardcoded in String::num
+ }
+ return step_decimals(p_step);
+}
+
double Math::dectime(double p_value, double p_amount, double p_step) {
double sgn = p_value < 0 ? -1.0 : 1.0;
double val = Math::abs(p_value);
diff --git a/core/math/math_funcs.h b/core/math/math_funcs.h
index b8b5151802..a712356ddc 100644
--- a/core/math/math_funcs.h
+++ b/core/math/math_funcs.h
@@ -270,6 +270,7 @@ public:
// double only, as these functions are mainly used by the editor and not performance-critical,
static double ease(double p_x, double p_c);
static int step_decimals(double p_step);
+ static int range_step_decimals(double p_step);
static double stepify(double p_value, double p_step);
static double dectime(double p_value, double p_amount, double p_step);
diff --git a/core/object.h b/core/object.h
index e6c5b7c5b9..dce1cc74ae 100644
--- a/core/object.h
+++ b/core/object.h
@@ -58,7 +58,7 @@ enum PropertyHint {
PROPERTY_HINT_ENUM, ///< hint_text= "val1,val2,val3,etc"
PROPERTY_HINT_EXP_EASING, /// exponential easing function (Math::ease) use "attenuation" hint string to revert (flip h), "full" to also include in/out. (ie: "attenuation,inout")
PROPERTY_HINT_LENGTH, ///< hint_text= "length" (as integer)
- PROPERTY_HINT_SPRITE_FRAME,
+ PROPERTY_HINT_SPRITE_FRAME, // FIXME: Obsolete: drop whenever we can break compat. Keeping now for GDNative compat.
PROPERTY_HINT_KEY_ACCEL, ///< hint_text= "length" (as integer)
PROPERTY_HINT_FLAGS, ///< hint_text= "flag1,flag2,etc" (as bit flags)
PROPERTY_HINT_LAYERS_2D_RENDER,
@@ -104,7 +104,8 @@ enum PropertyUsageFlags {
PROPERTY_USAGE_INTERNATIONALIZED = 64, //hint for internationalized strings
PROPERTY_USAGE_GROUP = 128, //used for grouping props in the editor
PROPERTY_USAGE_CATEGORY = 256,
- //those below are deprecated thanks to ClassDB's now class value cache
+ // FIXME: Drop in 4.0, possibly reorder other flags?
+ // Those below are deprecated thanks to ClassDB's now class value cache
//PROPERTY_USAGE_STORE_IF_NONZERO = 512, //only store if nonzero
//PROPERTY_USAGE_STORE_IF_NONONE = 1024, //only store if false
PROPERTY_USAGE_NO_INSTANCE_STATE = 2048,
@@ -121,6 +122,7 @@ enum PropertyUsageFlags {
PROPERTY_USAGE_HIGH_END_GFX = 1 << 22,
PROPERTY_USAGE_NODE_PATH_FROM_SCENE_ROOT = 1 << 23,
PROPERTY_USAGE_RESOURCE_NOT_PERSISTENT = 1 << 24,
+ PROPERTY_USAGE_KEYING_INCREMENTS = 1 << 25, // Used in inspector to increment property when keyed in animation player
PROPERTY_USAGE_DEFAULT = PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_NETWORK,
PROPERTY_USAGE_DEFAULT_INTL = PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_NETWORK | PROPERTY_USAGE_INTERNATIONALIZED,
diff --git a/core/os/dir_access.cpp b/core/os/dir_access.cpp
index 0cdb5b41b7..b444f0ae1e 100644
--- a/core/os/dir_access.cpp
+++ b/core/os/dir_access.cpp
@@ -179,14 +179,6 @@ Error DirAccess::make_dir_recursive(String p_dir) {
return OK;
}
-String DirAccess::get_next(bool *p_is_dir) {
-
- String next = get_next();
- if (p_is_dir)
- *p_is_dir = current_is_dir();
- return next;
-}
-
String DirAccess::fix_path(String p_path) const {
switch (_access_type) {
diff --git a/core/os/dir_access.h b/core/os/dir_access.h
index bde19bd5ae..704eedae5b 100644
--- a/core/os/dir_access.h
+++ b/core/os/dir_access.h
@@ -71,7 +71,6 @@ protected:
public:
virtual Error list_dir_begin() = 0; ///< This starts dir listing
- virtual String get_next(bool *p_is_dir); // compatibility
virtual String get_next() = 0;
virtual bool current_is_dir() const = 0;
virtual bool current_is_hidden() const = 0;
diff --git a/core/set.h b/core/set.h
index 81250068af..b2c717880d 100644
--- a/core/set.h
+++ b/core/set.h
@@ -39,7 +39,7 @@
*/
// based on the very nice implementation of rb-trees by:
-// http://web.mit.edu/~emin/www/source_code/red_black_tree/index.html
+// https://web.archive.org/web/20120507164830/http://web.mit.edu/~emin/www/source_code/red_black_tree/index.html
template <class T, class C = Comparator<T>, class A = DefaultAllocator>
class Set {
diff --git a/core/ustring.cpp b/core/ustring.cpp
index 75e3b6f22e..ed401c3763 100644
--- a/core/ustring.cpp
+++ b/core/ustring.cpp
@@ -2729,6 +2729,51 @@ bool String::is_quoted() const {
return is_enclosed_in("\"") || is_enclosed_in("'");
}
+int String::_count(const String &p_string, int p_from, int p_to, bool p_case_insensitive) const {
+ if (p_string.empty()) {
+ return 0;
+ }
+ int len = length();
+ int slen = p_string.length();
+ if (len < slen) {
+ return 0;
+ }
+ String str;
+ if (p_from >= 0 && p_to >= 0) {
+ if (p_to == 0) {
+ p_to = len;
+ } else if (p_from >= p_to) {
+ return 0;
+ }
+ if (p_from == 0 && p_to == len) {
+ str = String();
+ str.copy_from_unchecked(&c_str()[0], len);
+ } else {
+ str = substr(p_from, p_to - p_from);
+ }
+ } else {
+ return 0;
+ }
+ int c = 0;
+ int idx = -1;
+ do {
+ idx = p_case_insensitive ? str.findn(p_string) : str.find(p_string);
+ if (idx != -1) {
+ str = str.substr(idx + slen, str.length() - slen);
+ ++c;
+ }
+ } while (idx != -1);
+ return c;
+}
+
+int String::count(const String &p_string, int p_from, int p_to) const {
+ return _count(p_string, p_from, p_to, false);
+}
+
+int String::countn(const String &p_string, int p_from, int p_to) const {
+ return _count(p_string, p_from, p_to, true);
+}
+
bool String::_base_is_subsequence_of(const String &p_string, bool case_insensitive) const {
int len = length();
diff --git a/core/ustring.h b/core/ustring.h
index 8a52c53238..3eb5c47b3a 100644
--- a/core/ustring.h
+++ b/core/ustring.h
@@ -137,6 +137,7 @@ class String {
void copy_from(const CharType &p_char);
void copy_from_unchecked(const CharType *p_char, const int p_length);
bool _base_is_subsequence_of(const String &p_string, bool case_insensitive) const;
+ int _count(const String &p_string, int p_from, int p_to, bool p_case_insensitive) const;
public:
enum {
@@ -279,6 +280,9 @@ public:
String to_upper() const;
String to_lower() const;
+ int count(const String &p_string, int p_from = 0, int p_to = 0) const;
+ int countn(const String &p_string, int p_from = 0, int p_to = 0) const;
+
String left(int p_pos) const;
String right(int p_pos) const;
String dedent() const;
diff --git a/core/variant_call.cpp b/core/variant_call.cpp
index b637e745af..377cc889b8 100644
--- a/core/variant_call.cpp
+++ b/core/variant_call.cpp
@@ -237,6 +237,8 @@ struct _VariantCall {
VCALL_LOCALMEM1R(String, casecmp_to);
VCALL_LOCALMEM1R(String, nocasecmp_to);
VCALL_LOCALMEM0R(String, length);
+ VCALL_LOCALMEM3R(String, count);
+ VCALL_LOCALMEM3R(String, countn);
VCALL_LOCALMEM2R(String, substr);
VCALL_LOCALMEM2R(String, find);
VCALL_LOCALMEM1R(String, find_last);
@@ -1502,6 +1504,9 @@ void register_variant_methods() {
ADDFUNC2R(STRING, INT, String, find, STRING, "what", INT, "from", varray(0));
+ ADDFUNC3R(STRING, INT, String, count, STRING, "what", INT, "from", INT, "to", varray(0, 0));
+ ADDFUNC3R(STRING, INT, String, countn, STRING, "what", INT, "from", INT, "to", varray(0, 0));
+
ADDFUNC1R(STRING, INT, String, find_last, STRING, "what", varray());
ADDFUNC2R(STRING, INT, String, findn, STRING, "what", INT, "from", varray(0));
ADDFUNC2R(STRING, INT, String, rfind, STRING, "what", INT, "from", varray(-1));
diff --git a/doc/classes/CollisionObject2D.xml b/doc/classes/CollisionObject2D.xml
index eb69a4aed4..b9ec9480cf 100644
--- a/doc/classes/CollisionObject2D.xml
+++ b/doc/classes/CollisionObject2D.xml
@@ -19,7 +19,7 @@
<argument index="2" name="shape_idx" type="int">
</argument>
<description>
- Accepts unhandled [InputEvent]s. [code]shape_idx[/code] is the child index of the clicked [Shape2D]. Connect to the [code]input_event[/code] signal to easily pick up these events.
+ Accepts unhandled [InputEvent]s. Requires [member input_pickable] to be [code]true[/code]. [code]shape_idx[/code] is the child index of the clicked [Shape2D]. Connect to the [code]input_event[/code] signal to easily pick up these events.
</description>
</method>
<method name="create_shape_owner">
@@ -227,17 +227,17 @@
<argument index="2" name="shape_idx" type="int">
</argument>
<description>
- Emitted when an input event occurs. Requires [code]input_pickable[/code] to be [code]true[/code] and at least one [code]collision_layer[/code] bit to be set. See [method _input_event] for details.
+ Emitted when an input event occurs. Requires [member input_pickable] to be [code]true[/code] and at least one [code]collision_layer[/code] bit to be set. See [method _input_event] for details.
</description>
</signal>
<signal name="mouse_entered">
<description>
- Emitted when the mouse pointer enters any of this object's shapes. Requires [code]input_pickable[/code] to be [code]true[/code] and at least one [code]collision_layer[/code] bit to be set.
+ Emitted when the mouse pointer enters any of this object's shapes. Requires [member input_pickable] to be [code]true[/code] and at least one [code]collision_layer[/code] bit to be set.
</description>
</signal>
<signal name="mouse_exited">
<description>
- Emitted when the mouse pointer exits all this object's shapes. Requires [code]input_pickable[/code] to be [code]true[/code] and at least one [code]collision_layer[/code] bit to be set.
+ Emitted when the mouse pointer exits all this object's shapes. Requires [member input_pickable] to be [code]true[/code] and at least one [code]collision_layer[/code] bit to be set.
</description>
</signal>
</signals>
diff --git a/doc/classes/KinematicBody2D.xml b/doc/classes/KinematicBody2D.xml
index 39d84c6e31..22db9e3960 100644
--- a/doc/classes/KinematicBody2D.xml
+++ b/doc/classes/KinematicBody2D.xml
@@ -76,6 +76,7 @@
</argument>
<description>
Moves the body along the vector [code]rel_vec[/code]. The body will stop if it collides. Returns a [KinematicCollision2D], which contains information about the collision.
+ If [code]test_only[/code] is [code]true[/code], the body does not move but the would-be collision information is given.
</description>
</method>
<method name="move_and_slide">
diff --git a/doc/classes/PointMesh.xml b/doc/classes/PointMesh.xml
new file mode 100644
index 0000000000..dc7dd065cf
--- /dev/null
+++ b/doc/classes/PointMesh.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<class name="PointMesh" inherits="PrimitiveMesh" category="Core" version="3.2">
+ <brief_description>
+ Mesh with a single Point primitive.
+ </brief_description>
+ <description>
+ The PointMesh is made from a single point. Instead of relying on triangles, points are rendered as a single rectangle on the screen with a constant size. They are intended to be used with Particle systems, but can be used as a cheap way to render constant size billboarded sprites (for example in a point cloud).
+ PointMeshes, must be used with a material that has a point size. Point size can be accessed in a shader with [code]POINT_SIZE[/code], or in a [SpatialMaterial] by setting [member SpatialMaterial.flags_use_point_size] and the variable [member SpatialMaterial.params_point_size].
+ When using PointMeshes, properties that normally alter vertices will be ignored, including billboard mode, grow, and cull face.
+ </description>
+ <tutorials>
+ </tutorials>
+ <methods>
+ </methods>
+ <constants>
+ </constants>
+</class>
diff --git a/doc/classes/ProjectSettings.xml b/doc/classes/ProjectSettings.xml
index 7ab29e67ae..2d6ab4f72c 100644
--- a/doc/classes/ProjectSettings.xml
+++ b/doc/classes/ProjectSettings.xml
@@ -825,7 +825,7 @@
<member name="rendering/quality/subsurface_scattering/weight_samples" type="bool" setter="" getter="" default="true">
Weight subsurface scattering samples. Helps to avoid reading samples from unrelated parts of the screen.
</member>
- <member name="rendering/quality/voxel_cone_tracing/high_quality" type="bool" setter="" getter="" default="true">
+ <member name="rendering/quality/voxel_cone_tracing/high_quality" type="bool" setter="" getter="" default="false">
Use high-quality voxel cone tracing. This results in better-looking reflections, but is much more expensive on the GPU.
</member>
<member name="rendering/threads/thread_model" type="int" setter="" getter="" default="1">
diff --git a/doc/classes/String.xml b/doc/classes/String.xml
index e513a44b1d..6dc3e35558 100644
--- a/doc/classes/String.xml
+++ b/doc/classes/String.xml
@@ -272,6 +272,34 @@
Performs a case-sensitive comparison to another string. Returns [code]-1[/code] if less than, [code]+1[/code] if greater than, or [code]0[/code] if equal.
</description>
</method>
+ <method name="count">
+ <return type="int">
+ </return>
+ <argument index="0" name="what" type="String">
+ </argument>
+ <argument index="1" name="from" type="int" default="0">
+ </argument>
+ <argument index="2" name="to" type="int" default="0">
+ </argument>
+ </argument>
+ <description>
+ Returns the number of occurrences of substring [code]what[/code] between [code]from[/code] and [code]to[/code] positions. If [code]from[/code] and [code]to[/code] equals 0 the whole string will be used. If only [code]to[/code] equals 0 the remained substring will be used.
+ </description>
+ </method>
+ <method name="countn">
+ <return type="int">
+ </return>
+ <argument index="0" name="what" type="String">
+ </argument>
+ <argument index="1" name="from" type="int" default="0">
+ </argument>
+ <argument index="2" name="to" type="int" default="0">
+ </argument>
+ </argument>
+ <description>
+ Returns the number of occurrences of substring [code]what[/code] (ignoring case) between [code]from[/code] and [code]to[/code] positions. If [code]from[/code] and [code]to[/code] equals 0 the whole string will be used. If only [code]to[/code] equals 0 the remained substring will be used.
+ </description>
+ </method>
<method name="dedent">
<return type="String">
</return>
diff --git a/doc/classes/VehicleWheel.xml b/doc/classes/VehicleWheel.xml
index 6de6429531..ff6004bcba 100644
--- a/doc/classes/VehicleWheel.xml
+++ b/doc/classes/VehicleWheel.xml
@@ -13,6 +13,7 @@
<return type="float">
</return>
<description>
+ Returns the rotational speed of the wheel in revolutions per minute.
</description>
</method>
<method name="get_skidinfo" qualifiers="const">
@@ -31,12 +32,23 @@
</method>
</methods>
<members>
+ <member name="brake" type="float" setter="set_brake" getter="get_brake" default="0.0">
+ Slows down the wheel by applying a braking force. The wheel is only slowed down if it is in contact with a surface. The force you need to apply to adequately slow down your vehicle depends on the [member RigidBody.mass] of the vehicle. For a vehicle with a mass set to 1000, try a value in the 25 - 30 range for hard braking.
+ </member>
<member name="damping_compression" type="float" setter="set_damping_compression" getter="get_damping_compression" default="0.83">
The damping applied to the spring when the spring is being compressed. This value should be between 0.0 (no damping) and 1.0. A value of 0.0 means the car will keep bouncing as the spring keeps its energy. A good value for this is around 0.3 for a normal car, 0.5 for a race car.
</member>
<member name="damping_relaxation" type="float" setter="set_damping_relaxation" getter="get_damping_relaxation" default="0.88">
The damping applied to the spring when relaxing. This value should be between 0.0 (no damping) and 1.0. This value should always be slightly higher than the [member damping_compression] property. For a [member damping_compression] value of 0.3, try a relaxation value of 0.5.
</member>
+ <member name="engine_force" type="float" setter="set_engine_force" getter="get_engine_force" default="0.0">
+ Accelerates the wheel by applying an engine force. The wheel is only speed up if it is in contact with a surface. The [member RigidBody.mass] of the vehicle has an effect on the acceleration of the vehicle. For a vehicle with a mass set to 1000, try a value in the 25 - 50 range for acceleration.
+ [b]Note:[/b] The simulation does not take the effect of gears into account, you will need to add logic for this if you wish to simulate gears.
+ A negative value will result in the wheel reversing.
+ </member>
+ <member name="steering" type="float" setter="set_steering" getter="get_steering" default="0.0">
+ The steering angle for the wheel. Setting this to a non-zero value will result in the vehicle turning when it's moving.
+ </member>
<member name="suspension_max_force" type="float" setter="set_suspension_max_force" getter="get_suspension_max_force" default="6000.0">
The maximum force the spring can resist. This value should be higher than a quarter of the [member RigidBody.mass] of the [VehicleBody] or the spring will not carry the weight of the vehicle. Good results are often obtained by a value that is about 3× to 4× this number.
</member>
@@ -47,10 +59,10 @@
This is the distance the suspension can travel. As Godot units are equivalent to meters, keep this setting relatively low. Try a value between 0.1 and 0.3 depending on the type of car.
</member>
<member name="use_as_steering" type="bool" setter="set_use_as_steering" getter="is_used_as_steering" default="false">
- If [code]true[/code], this wheel will be turned when the car steers.
+ If [code]true[/code], this wheel will be turned when the car steers. This value is used in conjunction with [member VehicleBody.steering] and ignored if you are using the per-wheel [member steering] value instead.
</member>
<member name="use_as_traction" type="bool" setter="set_use_as_traction" getter="is_used_as_traction" default="false">
- If [code]true[/code], this wheel transfers engine force to the ground to propel the vehicle forward.
+ If [code]true[/code], this wheel transfers engine force to the ground to propel the vehicle forward. This value is used in conjunction with [member VehicleBody.engine_force] and ignored if you are using the per-wheel [member engine_force] value instead.
</member>
<member name="wheel_friction_slip" type="float" setter="set_friction_slip" getter="get_friction_slip" default="10.5">
This determines how much grip this wheel has. It is combined with the friction setting of the surface the wheel is in contact with. 0.0 means no grip, 1.0 is normal grip. For a drift car setup, try setting the grip of the rear wheels slightly lower than the front wheels, or use a lower value to simulate tire wear.
diff --git a/doc/tools/makerst.py b/doc/tools/makerst.py
index 763c29ab4e..b42ae3ce01 100755
--- a/doc/tools/makerst.py
+++ b/doc/tools/makerst.py
@@ -347,6 +347,7 @@ def make_rst_class(class_def, state, dry_run, output_dir): # type: (ClassDef, S
f = open(os.path.join(output_dir, "class_" + class_name.lower() + '.rst'), 'w', encoding='utf-8')
# Warn contributors not to edit this file directly
+ f.write(":github_url: hide\n\n")
f.write(".. Generated automatically by doc/tools/makerst.py in Godot's source tree.\n")
f.write(".. DO NOT EDIT THIS FILE, but the " + class_name + ".xml source instead.\n")
f.write(".. The source is found in doc/classes or modules/<name>/doc_classes.\n\n")
diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp
index 812e3711c5..f3ba29a0e7 100644
--- a/drivers/gles3/rasterizer_scene_gles3.cpp
+++ b/drivers/gles3/rasterizer_scene_gles3.cpp
@@ -2365,7 +2365,7 @@ void RasterizerSceneGLES3::_add_geometry_with_material(RasterizerStorageGLES3::G
if (p_depth_pass) {
- if (has_blend_alpha || p_material->shader->spatial.uses_depth_texture || (has_base_alpha && p_material->shader->spatial.depth_draw_mode != RasterizerStorageGLES3::Shader::Spatial::DEPTH_DRAW_ALPHA_PREPASS) || p_material->shader->spatial.depth_draw_mode == RasterizerStorageGLES3::Shader::Spatial::DEPTH_DRAW_NEVER || p_material->shader->spatial.no_depth_test)
+ if (has_blend_alpha || p_material->shader->spatial.uses_depth_texture || (has_base_alpha && p_material->shader->spatial.depth_draw_mode != RasterizerStorageGLES3::Shader::Spatial::DEPTH_DRAW_ALPHA_PREPASS) || p_material->shader->spatial.depth_draw_mode == RasterizerStorageGLES3::Shader::Spatial::DEPTH_DRAW_NEVER || p_material->shader->spatial.no_depth_test || p_instance->cast_shadows == VS::SHADOW_CASTING_SETTING_OFF)
return; //bye
if (!p_material->shader->spatial.uses_alpha_scissor && !p_material->shader->spatial.writes_modelview_or_projection && !p_material->shader->spatial.uses_vertex && !p_material->shader->spatial.uses_discard && p_material->shader->spatial.depth_draw_mode != RasterizerStorageGLES3::Shader::Spatial::DEPTH_DRAW_ALPHA_PREPASS) {
@@ -5296,7 +5296,7 @@ void RasterizerSceneGLES3::initialize() {
GLOBAL_DEF("rendering/quality/subsurface_scattering/follow_surface", false);
GLOBAL_DEF("rendering/quality/subsurface_scattering/weight_samples", true);
- GLOBAL_DEF("rendering/quality/voxel_cone_tracing/high_quality", true);
+ GLOBAL_DEF("rendering/quality/voxel_cone_tracing/high_quality", false);
}
exposure_shrink_size = 243;
diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp
index d1ac69c8d8..9b376ae090 100644
--- a/editor/animation_track_editor.cpp
+++ b/editor/animation_track_editor.cpp
@@ -82,22 +82,23 @@ public:
}
void _update_obj(const Ref<Animation> &p_anim) {
- if (setting)
- return;
- if (!(animation == p_anim))
+
+ if (setting || animation != p_anim)
return;
notify_change();
}
void _key_ofs_changed(const Ref<Animation> &p_anim, float from, float to) {
- if (!(animation == p_anim))
- return;
- if (from != key_ofs)
+
+ if (animation != p_anim || from != key_ofs)
return;
+
key_ofs = to;
+
if (setting)
return;
+
notify_change();
}
@@ -118,6 +119,7 @@ public:
}
new_time /= fps;
}
+
if (new_time == key_ofs)
return true;
@@ -141,12 +143,13 @@ public:
trans = animation->track_get_key_transition(track, existing);
undo_redo->add_undo_method(animation.ptr(), "track_insert_key", track, new_time, v, trans);
}
-
undo_redo->commit_action();
- setting = false;
+ setting = false;
return true;
- } else if (name == "easing") {
+ }
+
+ if (name == "easing") {
float val = p_value;
float prev_val = animation->track_get_key_transition(track, key);
@@ -157,6 +160,7 @@ public:
undo_redo->add_do_method(this, "_update_obj", animation);
undo_redo->add_undo_method(this, "_update_obj", animation);
undo_redo->commit_action();
+
setting = false;
return true;
}
@@ -166,7 +170,7 @@ public:
case Animation::TYPE_TRANSFORM: {
Dictionary d_old = animation->track_get_key_value(track, key);
- Dictionary d_new = d_old;
+ Dictionary d_new = d_old.duplicate();
d_new[p_name] = p_value;
setting = true;
undo_redo->create_action(TTR("Anim Change Transform"));
@@ -178,7 +182,6 @@ public:
setting = false;
return true;
-
} break;
case Animation::TYPE_VALUE: {
@@ -187,7 +190,6 @@ public:
Variant value = p_value;
if (value.get_type() == Variant::NODE_PATH) {
-
_fix_node_path(value);
}
@@ -203,12 +205,11 @@ public:
setting = false;
return true;
}
-
} break;
case Animation::TYPE_METHOD: {
Dictionary d_old = animation->track_get_key_value(track, key);
- Dictionary d_new = d_old;
+ Dictionary d_new = d_old.duplicate();
bool change_notify_deserved = false;
bool mergeable = false;
@@ -216,17 +217,13 @@ public:
if (name == "name") {
d_new["method"] = p_value;
- }
-
- if (name == "arg_count") {
+ } else if (name == "arg_count") {
Vector<Variant> args = d_old["args"];
args.resize(p_value);
d_new["args"] = args;
change_notify_deserved = true;
- }
-
- if (name.begins_with("args/")) {
+ } else if (name.begins_with("args/")) {
Vector<Variant> args = d_old["args"];
int idx = name.get_slice("/", 1).to_int();
@@ -249,8 +246,7 @@ public:
change_notify_deserved = true;
d_new["args"] = args;
}
- }
- if (what == "value") {
+ } else if (what == "value") {
Variant value = p_value;
if (value.get_type() == Variant::NODE_PATH) {
@@ -300,6 +296,7 @@ public:
setting = false;
return true;
}
+
if (name == "in_handle") {
const Variant &value = p_value;
@@ -316,6 +313,7 @@ public:
setting = false;
return true;
}
+
if (name == "out_handle") {
const Variant &value = p_value;
@@ -332,7 +330,6 @@ public:
setting = false;
return true;
}
-
} break;
case Animation::TYPE_AUDIO: {
@@ -352,6 +349,7 @@ public:
setting = false;
return true;
}
+
if (name == "start_offset") {
float value = p_value;
@@ -368,6 +366,7 @@ public:
setting = false;
return true;
}
+
if (name == "end_offset") {
float value = p_value;
@@ -384,7 +383,6 @@ public:
setting = false;
return true;
}
-
} break;
case Animation::TYPE_ANIMATION: {
@@ -400,10 +398,10 @@ public:
undo_redo->add_do_method(this, "_update_obj", animation);
undo_redo->add_undo_method(this, "_update_obj", animation);
undo_redo->commit_action();
+
setting = false;
return true;
}
-
} break;
}
@@ -419,20 +417,24 @@ public:
if (name == "time") {
r_ret = key_ofs;
return true;
- } else if (name == "frame") {
+ }
+
+ if (name == "frame") {
+
float fps = animation->get_step();
if (fps > 0) {
fps = 1.0 / fps;
}
r_ret = key_ofs * fps;
return true;
- } else if (name == "easing") {
+ }
+
+ if (name == "easing") {
r_ret = animation->track_get_key_transition(track, key);
return true;
}
switch (animation->track_get_type(track)) {
-
case Animation::TYPE_TRANSFORM: {
Dictionary d = animation->track_get_key_value(track, key);
@@ -465,7 +467,6 @@ public:
Vector<Variant> args = d["args"];
if (name == "arg_count") {
-
r_ret = args.size();
return true;
}
@@ -480,6 +481,7 @@ public:
r_ret = args[idx].get_type();
return true;
}
+
if (what == "value") {
r_ret = args[idx];
return true;
@@ -493,10 +495,12 @@ public:
r_ret = animation->bezier_track_get_key_value(track, key);
return true;
}
+
if (name == "in_handle") {
r_ret = animation->bezier_track_get_key_in_handle(track, key);
return true;
}
+
if (name == "out_handle") {
r_ret = animation->bezier_track_get_key_out_handle(track, key);
return true;
@@ -509,10 +513,12 @@ public:
r_ret = animation->audio_track_get_key_stream(track, key);
return true;
}
+
if (name == "start_offset") {
r_ret = animation->audio_track_get_key_start_offset(track, key);
return true;
}
+
if (name == "end_offset") {
r_ret = animation->audio_track_get_key_end_offset(track, key);
return true;
@@ -691,6 +697,702 @@ public:
}
};
+class AnimationMultiTrackKeyEdit : public Object {
+
+ GDCLASS(AnimationMultiTrackKeyEdit, Object);
+
+public:
+ bool setting;
+
+ bool _hide_script_from_inspector() {
+ return true;
+ }
+
+ bool _dont_undo_redo() {
+ return true;
+ }
+
+ static void _bind_methods() {
+
+ ClassDB::bind_method("_update_obj", &AnimationMultiTrackKeyEdit::_update_obj);
+ ClassDB::bind_method("_key_ofs_changed", &AnimationMultiTrackKeyEdit::_key_ofs_changed);
+ ClassDB::bind_method("_hide_script_from_inspector", &AnimationMultiTrackKeyEdit::_hide_script_from_inspector);
+ ClassDB::bind_method("get_root_path", &AnimationMultiTrackKeyEdit::get_root_path);
+ ClassDB::bind_method("_dont_undo_redo", &AnimationMultiTrackKeyEdit::_dont_undo_redo);
+ }
+
+ void _fix_node_path(Variant &value, NodePath &base) {
+
+ NodePath np = value;
+
+ if (np == NodePath())
+ return;
+
+ Node *root = EditorNode::get_singleton()->get_tree()->get_root();
+
+ Node *np_node = root->get_node(np);
+ ERR_FAIL_COND(!np_node);
+
+ Node *edited_node = root->get_node(base);
+ ERR_FAIL_COND(!edited_node);
+
+ value = edited_node->get_path_to(np_node);
+ }
+
+ void _update_obj(const Ref<Animation> &p_anim) {
+
+ if (setting || animation != p_anim)
+ return;
+
+ notify_change();
+ }
+
+ void _key_ofs_changed(const Ref<Animation> &p_anim, float from, float to) {
+
+ if (animation != p_anim)
+ return;
+
+ for (Map<int, List<float> >::Element *E = key_ofs_map.front(); E; E = E->next()) {
+
+ for (List<float>::Element *F = E->value().front(); F; F = F->next()) {
+
+ float key_ofs = F->get();
+ if (from != key_ofs)
+ continue;
+
+ int track = E->key();
+ key_ofs_map[track][key_ofs] = to;
+
+ if (setting)
+ return;
+
+ notify_change();
+
+ return;
+ }
+ }
+ }
+
+ bool _set(const StringName &p_name, const Variant &p_value) {
+
+ bool update_obj = false;
+ bool change_notify_deserved = false;
+ for (Map<int, List<float> >::Element *E = key_ofs_map.front(); E; E = E->next()) {
+
+ int track = E->key();
+ for (List<float>::Element *F = E->value().front(); F; F = F->next()) {
+
+ float key_ofs = F->get();
+ int key = animation->track_find_key(track, key_ofs, true);
+ ERR_FAIL_COND_V(key == -1, false);
+
+ String name = p_name;
+ if (name == "time" || name == "frame") {
+
+ float new_time = p_value;
+
+ if (name == "frame") {
+ float fps = animation->get_step();
+ if (fps > 0) {
+ fps = 1.0 / fps;
+ }
+ new_time /= fps;
+ }
+
+ int existing = animation->track_find_key(track, new_time, true);
+
+ if (!setting) {
+ setting = true;
+ undo_redo->create_action(TTR("Anim Multi Change Keyframe Time"), UndoRedo::MERGE_ENDS);
+ }
+
+ Variant val = animation->track_get_key_value(track, key);
+ float trans = animation->track_get_key_transition(track, key);
+
+ undo_redo->add_do_method(animation.ptr(), "track_remove_key", track, key);
+ undo_redo->add_do_method(animation.ptr(), "track_insert_key", track, new_time, val, trans);
+ undo_redo->add_do_method(this, "_key_ofs_changed", animation, key_ofs, new_time);
+ undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_position", track, new_time);
+ undo_redo->add_undo_method(animation.ptr(), "track_insert_key", track, key_ofs, val, trans);
+ undo_redo->add_undo_method(this, "_key_ofs_changed", animation, new_time, key_ofs);
+
+ if (existing != -1) {
+ Variant v = animation->track_get_key_value(track, existing);
+ trans = animation->track_get_key_transition(track, existing);
+ undo_redo->add_undo_method(animation.ptr(), "track_insert_key", track, new_time, v, trans);
+ }
+ } else if (name == "easing") {
+
+ float val = p_value;
+ float prev_val = animation->track_get_key_transition(track, key);
+
+ if (!setting) {
+ setting = true;
+ undo_redo->create_action(TTR("Anim Multi Change Transition"), UndoRedo::MERGE_ENDS);
+ }
+ undo_redo->add_do_method(animation.ptr(), "track_set_key_transition", track, key, val);
+ undo_redo->add_undo_method(animation.ptr(), "track_set_key_transition", track, key, prev_val);
+ update_obj = true;
+ }
+
+ switch (animation->track_get_type(track)) {
+
+ case Animation::TYPE_TRANSFORM: {
+
+ Dictionary d_old = animation->track_get_key_value(track, key);
+ Dictionary d_new = d_old.duplicate();
+ d_new[p_name] = p_value;
+
+ if (!setting) {
+ setting = true;
+ undo_redo->create_action(TTR("Anim Multi Change Transform"));
+ }
+ undo_redo->add_do_method(animation.ptr(), "track_set_key_value", track, key, d_new);
+ undo_redo->add_undo_method(animation.ptr(), "track_set_key_value", track, key, d_old);
+ update_obj = true;
+ } break;
+ case Animation::TYPE_VALUE: {
+
+ if (name == "value") {
+
+ Variant value = p_value;
+
+ if (value.get_type() == Variant::NODE_PATH) {
+ _fix_node_path(value, base_map[track]);
+ }
+
+ if (!setting) {
+ setting = true;
+ undo_redo->create_action(TTR("Anim Multi Change Keyframe Value"), UndoRedo::MERGE_ENDS);
+ }
+ Variant prev = animation->track_get_key_value(track, key);
+ undo_redo->add_do_method(animation.ptr(), "track_set_key_value", track, key, value);
+ undo_redo->add_undo_method(animation.ptr(), "track_set_key_value", track, key, prev);
+ update_obj = true;
+ }
+ } break;
+ case Animation::TYPE_METHOD: {
+
+ Dictionary d_old = animation->track_get_key_value(track, key);
+ Dictionary d_new = d_old.duplicate();
+
+ bool mergeable = false;
+
+ if (name == "name") {
+
+ d_new["method"] = p_value;
+ } else if (name == "arg_count") {
+
+ Vector<Variant> args = d_old["args"];
+ args.resize(p_value);
+ d_new["args"] = args;
+ change_notify_deserved = true;
+ } else if (name.begins_with("args/")) {
+
+ Vector<Variant> args = d_old["args"];
+ int idx = name.get_slice("/", 1).to_int();
+ ERR_FAIL_INDEX_V(idx, args.size(), false);
+
+ String what = name.get_slice("/", 2);
+ if (what == "type") {
+ Variant::Type t = Variant::Type(int(p_value));
+
+ if (t != args[idx].get_type()) {
+ Variant::CallError err;
+ if (Variant::can_convert(args[idx].get_type(), t)) {
+ Variant old = args[idx];
+ Variant *ptrs[1] = { &old };
+ args.write[idx] = Variant::construct(t, (const Variant **)ptrs, 1, err);
+ } else {
+
+ args.write[idx] = Variant::construct(t, NULL, 0, err);
+ }
+ change_notify_deserved = true;
+ d_new["args"] = args;
+ }
+ } else if (what == "value") {
+
+ Variant value = p_value;
+ if (value.get_type() == Variant::NODE_PATH) {
+
+ _fix_node_path(value, base_map[track]);
+ }
+
+ args.write[idx] = value;
+ d_new["args"] = args;
+ mergeable = true;
+ }
+ }
+
+ Variant prev = animation->track_get_key_value(track, key);
+
+ if (!setting) {
+ if (mergeable)
+ undo_redo->create_action(TTR("Anim Multi Change Call"), UndoRedo::MERGE_ENDS);
+ else
+ undo_redo->create_action(TTR("Anim Multi Change Call"));
+
+ setting = true;
+ }
+
+ undo_redo->add_do_method(animation.ptr(), "track_set_key_value", track, key, d_new);
+ undo_redo->add_undo_method(animation.ptr(), "track_set_key_value", track, key, d_old);
+ update_obj = true;
+ } break;
+ case Animation::TYPE_BEZIER: {
+
+ if (name == "value") {
+
+ const Variant &value = p_value;
+
+ if (!setting) {
+ setting = true;
+ undo_redo->create_action(TTR("Anim Multi Change Keyframe Value"), UndoRedo::MERGE_ENDS);
+ }
+ float prev = animation->bezier_track_get_key_value(track, key);
+ undo_redo->add_do_method(animation.ptr(), "bezier_track_set_key_value", track, key, value);
+ undo_redo->add_undo_method(animation.ptr(), "bezier_track_set_key_value", track, key, prev);
+ update_obj = true;
+ } else if (name == "in_handle") {
+
+ const Variant &value = p_value;
+
+ if (!setting) {
+ setting = true;
+ undo_redo->create_action(TTR("Anim Multi Change Keyframe Value"), UndoRedo::MERGE_ENDS);
+ }
+ Vector2 prev = animation->bezier_track_get_key_in_handle(track, key);
+ undo_redo->add_do_method(animation.ptr(), "bezier_track_set_key_in_handle", track, key, value);
+ undo_redo->add_undo_method(animation.ptr(), "bezier_track_set_key_in_handle", track, key, prev);
+ update_obj = true;
+ } else if (name == "out_handle") {
+
+ const Variant &value = p_value;
+
+ if (!setting) {
+ setting = true;
+ undo_redo->create_action(TTR("Anim Multi Change Keyframe Value"), UndoRedo::MERGE_ENDS);
+ }
+ Vector2 prev = animation->bezier_track_get_key_out_handle(track, key);
+ undo_redo->add_do_method(animation.ptr(), "bezier_track_set_key_out_handle", track, key, value);
+ undo_redo->add_undo_method(animation.ptr(), "bezier_track_set_key_out_handle", track, key, prev);
+ update_obj = true;
+ }
+ } break;
+ case Animation::TYPE_AUDIO: {
+
+ if (name == "stream") {
+
+ Ref<AudioStream> stream = p_value;
+
+ if (!setting) {
+ setting = true;
+ undo_redo->create_action(TTR("Anim Multi Change Keyframe Value"), UndoRedo::MERGE_ENDS);
+ }
+ RES prev = animation->audio_track_get_key_stream(track, key);
+ undo_redo->add_do_method(animation.ptr(), "audio_track_set_key_stream", track, key, stream);
+ undo_redo->add_undo_method(animation.ptr(), "audio_track_set_key_stream", track, key, prev);
+ update_obj = true;
+ } else if (name == "start_offset") {
+
+ float value = p_value;
+
+ if (!setting) {
+ setting = true;
+ undo_redo->create_action(TTR("Anim Multi Change Keyframe Value"), UndoRedo::MERGE_ENDS);
+ }
+ float prev = animation->audio_track_get_key_start_offset(track, key);
+ undo_redo->add_do_method(animation.ptr(), "audio_track_set_key_start_offset", track, key, value);
+ undo_redo->add_undo_method(animation.ptr(), "audio_track_set_key_start_offset", track, key, prev);
+ update_obj = true;
+ } else if (name == "end_offset") {
+
+ float value = p_value;
+
+ if (!setting) {
+ setting = true;
+ undo_redo->create_action(TTR("Anim Multi Change Keyframe Value"), UndoRedo::MERGE_ENDS);
+ }
+ float prev = animation->audio_track_get_key_end_offset(track, key);
+ undo_redo->add_do_method(animation.ptr(), "audio_track_set_key_end_offset", track, key, value);
+ undo_redo->add_undo_method(animation.ptr(), "audio_track_set_key_end_offset", track, key, prev);
+ update_obj = true;
+ }
+ } break;
+ case Animation::TYPE_ANIMATION: {
+
+ if (name == "animation") {
+
+ StringName anim_name = p_value;
+
+ if (!setting) {
+ setting = true;
+ undo_redo->create_action(TTR("Anim Multi Change Keyframe Value"), UndoRedo::MERGE_ENDS);
+ }
+ StringName prev = animation->animation_track_get_key_animation(track, key);
+ undo_redo->add_do_method(animation.ptr(), "animation_track_set_key_animation", track, key, anim_name);
+ undo_redo->add_undo_method(animation.ptr(), "animation_track_set_key_animation", track, key, prev);
+ update_obj = true;
+ }
+ } break;
+ }
+ }
+ }
+
+ if (setting) {
+
+ if (update_obj) {
+ undo_redo->add_do_method(this, "_update_obj", animation);
+ undo_redo->add_undo_method(this, "_update_obj", animation);
+ }
+
+ undo_redo->commit_action();
+ setting = false;
+
+ if (change_notify_deserved)
+ notify_change();
+
+ return true;
+ }
+
+ return false;
+ }
+
+ bool _get(const StringName &p_name, Variant &r_ret) const {
+
+ for (Map<int, List<float> >::Element *E = key_ofs_map.front(); E; E = E->next()) {
+
+ int track = E->key();
+ for (List<float>::Element *F = E->value().front(); F; F = F->next()) {
+
+ float key_ofs = F->get();
+ int key = animation->track_find_key(track, key_ofs, true);
+ ERR_CONTINUE(key == -1);
+
+ String name = p_name;
+ if (name == "time") {
+ r_ret = key_ofs;
+ return true;
+ }
+
+ if (name == "frame") {
+
+ float fps = animation->get_step();
+ if (fps > 0) {
+ fps = 1.0 / fps;
+ }
+ r_ret = key_ofs * fps;
+ return true;
+ }
+
+ if (name == "easing") {
+ r_ret = animation->track_get_key_transition(track, key);
+ return true;
+ }
+
+ switch (animation->track_get_type(track)) {
+
+ case Animation::TYPE_TRANSFORM: {
+
+ Dictionary d = animation->track_get_key_value(track, key);
+ ERR_FAIL_COND_V(!d.has(name), false);
+ r_ret = d[p_name];
+ return true;
+
+ } break;
+ case Animation::TYPE_VALUE: {
+
+ if (name == "value") {
+ r_ret = animation->track_get_key_value(track, key);
+ return true;
+ }
+
+ } break;
+ case Animation::TYPE_METHOD: {
+
+ Dictionary d = animation->track_get_key_value(track, key);
+
+ if (name == "name") {
+
+ ERR_FAIL_COND_V(!d.has("method"), false);
+ r_ret = d["method"];
+ return true;
+ }
+
+ ERR_FAIL_COND_V(!d.has("args"), false);
+
+ Vector<Variant> args = d["args"];
+
+ if (name == "arg_count") {
+
+ r_ret = args.size();
+ return true;
+ }
+
+ if (name.begins_with("args/")) {
+
+ int idx = name.get_slice("/", 1).to_int();
+ ERR_FAIL_INDEX_V(idx, args.size(), false);
+
+ String what = name.get_slice("/", 2);
+ if (what == "type") {
+ r_ret = args[idx].get_type();
+ return true;
+ }
+
+ if (what == "value") {
+ r_ret = args[idx];
+ return true;
+ }
+ }
+
+ } break;
+ case Animation::TYPE_BEZIER: {
+
+ if (name == "value") {
+ r_ret = animation->bezier_track_get_key_value(track, key);
+ return true;
+ }
+
+ if (name == "in_handle") {
+ r_ret = animation->bezier_track_get_key_in_handle(track, key);
+ return true;
+ }
+
+ if (name == "out_handle") {
+ r_ret = animation->bezier_track_get_key_out_handle(track, key);
+ return true;
+ }
+
+ } break;
+ case Animation::TYPE_AUDIO: {
+
+ if (name == "stream") {
+ r_ret = animation->audio_track_get_key_stream(track, key);
+ return true;
+ }
+
+ if (name == "start_offset") {
+ r_ret = animation->audio_track_get_key_start_offset(track, key);
+ return true;
+ }
+
+ if (name == "end_offset") {
+ r_ret = animation->audio_track_get_key_end_offset(track, key);
+ return true;
+ }
+
+ } break;
+ case Animation::TYPE_ANIMATION: {
+
+ if (name == "animation") {
+ r_ret = animation->animation_track_get_key_animation(track, key);
+ return true;
+ }
+
+ } break;
+ }
+ }
+ }
+
+ return false;
+ }
+ void _get_property_list(List<PropertyInfo> *p_list) const {
+
+ if (animation.is_null())
+ return;
+
+ int first_track = -1;
+ float first_key = -1.0;
+
+ bool show_time = true;
+ bool same_track_type = true;
+ bool same_key_type = true;
+ for (Map<int, List<float> >::Element *E = key_ofs_map.front(); E; E = E->next()) {
+
+ int track = E->key();
+ ERR_FAIL_INDEX(track, animation->get_track_count());
+
+ if (first_track < 0)
+ first_track = track;
+
+ if (show_time && E->value().size() > 1)
+ show_time = false;
+
+ if (same_track_type) {
+
+ if (animation->track_get_type(first_track) != animation->track_get_type(track)) {
+ same_track_type = false;
+ same_key_type = false;
+ }
+
+ for (List<float>::Element *F = E->value().front(); F; F = F->next()) {
+
+ int key = animation->track_find_key(track, F->get(), true);
+ ERR_FAIL_COND(key == -1);
+ if (first_key < 0)
+ first_key = key;
+
+ if (animation->track_get_key_value(first_track, first_key).get_type() != animation->track_get_key_value(track, key).get_type())
+ same_key_type = false;
+ }
+ }
+ }
+
+ if (show_time) {
+
+ if (use_fps && animation->get_step() > 0) {
+ float max_frame = animation->get_length() / animation->get_step();
+ p_list->push_back(PropertyInfo(Variant::REAL, "frame", PROPERTY_HINT_RANGE, "0," + rtos(max_frame) + ",1"));
+ } else {
+ p_list->push_back(PropertyInfo(Variant::REAL, "time", PROPERTY_HINT_RANGE, "0," + rtos(animation->get_length()) + ",0.01"));
+ }
+ }
+
+ if (same_track_type) {
+ switch (animation->track_get_type(first_track)) {
+
+ case Animation::TYPE_TRANSFORM: {
+
+ p_list->push_back(PropertyInfo(Variant::VECTOR3, "location"));
+ p_list->push_back(PropertyInfo(Variant::QUAT, "rotation"));
+ p_list->push_back(PropertyInfo(Variant::VECTOR3, "scale"));
+ } break;
+ case Animation::TYPE_VALUE: {
+
+ if (!same_key_type)
+ break;
+
+ Variant v = animation->track_get_key_value(first_track, first_key);
+
+ if (hint.type != Variant::NIL) {
+
+ PropertyInfo pi = hint;
+ pi.name = "value";
+ p_list->push_back(pi);
+ } else {
+
+ PropertyHint hint = PROPERTY_HINT_NONE;
+ String hint_string;
+
+ if (v.get_type() == Variant::OBJECT) {
+ //could actually check the object property if exists..? yes i will!
+ Ref<Resource> res = v;
+ if (res.is_valid()) {
+
+ hint = PROPERTY_HINT_RESOURCE_TYPE;
+ hint_string = res->get_class();
+ }
+ }
+
+ if (v.get_type() != Variant::NIL)
+ p_list->push_back(PropertyInfo(v.get_type(), "value", hint, hint_string));
+ }
+
+ p_list->push_back(PropertyInfo(Variant::REAL, "easing", PROPERTY_HINT_EXP_EASING));
+ } break;
+ case Animation::TYPE_METHOD: {
+
+ p_list->push_back(PropertyInfo(Variant::STRING, "name"));
+ p_list->push_back(PropertyInfo(Variant::INT, "arg_count", PROPERTY_HINT_RANGE, "0,5,1"));
+
+ Dictionary d = animation->track_get_key_value(first_track, first_key);
+ ERR_FAIL_COND(!d.has("args"));
+ Vector<Variant> args = d["args"];
+ String vtypes;
+ for (int i = 0; i < Variant::VARIANT_MAX; i++) {
+
+ if (i > 0)
+ vtypes += ",";
+ vtypes += Variant::get_type_name(Variant::Type(i));
+ }
+
+ for (int i = 0; i < args.size(); i++) {
+
+ p_list->push_back(PropertyInfo(Variant::INT, "args/" + itos(i) + "/type", PROPERTY_HINT_ENUM, vtypes));
+ if (args[i].get_type() != Variant::NIL)
+ p_list->push_back(PropertyInfo(args[i].get_type(), "args/" + itos(i) + "/value"));
+ }
+ } break;
+ case Animation::TYPE_BEZIER: {
+
+ p_list->push_back(PropertyInfo(Variant::REAL, "value"));
+ p_list->push_back(PropertyInfo(Variant::VECTOR2, "in_handle"));
+ p_list->push_back(PropertyInfo(Variant::VECTOR2, "out_handle"));
+ } break;
+ case Animation::TYPE_AUDIO: {
+
+ p_list->push_back(PropertyInfo(Variant::OBJECT, "stream", PROPERTY_HINT_RESOURCE_TYPE, "AudioStream"));
+ p_list->push_back(PropertyInfo(Variant::REAL, "start_offset", PROPERTY_HINT_RANGE, "0,3600,0.01,or_greater"));
+ p_list->push_back(PropertyInfo(Variant::REAL, "end_offset", PROPERTY_HINT_RANGE, "0,3600,0.01,or_greater"));
+ } break;
+ case Animation::TYPE_ANIMATION: {
+
+ if (key_ofs_map.size() > 1)
+ break;
+
+ String animations;
+
+ if (root_path && root_path->has_node(animation->track_get_path(first_track))) {
+
+ AnimationPlayer *ap = Object::cast_to<AnimationPlayer>(root_path->get_node(animation->track_get_path(first_track)));
+ if (ap) {
+ List<StringName> anims;
+ ap->get_animation_list(&anims);
+ for (List<StringName>::Element *G = anims.front(); G; G = G->next()) {
+ if (animations != String()) {
+ animations += ",";
+ }
+
+ animations += String(G->get());
+ }
+ }
+ }
+
+ if (animations != String()) {
+ animations += ",";
+ }
+ animations += "[stop]";
+
+ p_list->push_back(PropertyInfo(Variant::STRING, "animation", PROPERTY_HINT_ENUM, animations));
+ } break;
+ }
+ }
+ }
+
+ Ref<Animation> animation;
+
+ Map<int, List<float> > key_ofs_map;
+ Map<int, NodePath> base_map;
+ PropertyInfo hint;
+
+ Node *root_path;
+
+ bool use_fps;
+
+ UndoRedo *undo_redo;
+
+ void notify_change() {
+
+ _change_notify();
+ }
+
+ Node *get_root_path() {
+ return root_path;
+ }
+
+ void set_use_fps(bool p_enable) {
+ use_fps = p_enable;
+ _change_notify();
+ }
+
+ AnimationMultiTrackKeyEdit() {
+ use_fps = false;
+ setting = false;
+ root_path = NULL;
+ }
+};
+
void AnimationTimelineEdit::_zoom_changed(double) {
update();
@@ -4133,12 +4835,19 @@ void AnimationTrackEditor::_clear_key_edit() {
}
#else
//if key edit is the object being inspected, remove it first
- if (EditorNode::get_singleton()->get_inspector()->get_edited_object() == key_edit) {
+ if (EditorNode::get_singleton()->get_inspector()->get_edited_object() == key_edit ||
+ EditorNode::get_singleton()->get_inspector()->get_edited_object() == multi_key_edit) {
EditorNode::get_singleton()->push_item(NULL);
}
+
//then actually delete it
- memdelete(key_edit);
- key_edit = NULL;
+ if (key_edit) {
+ memdelete(key_edit);
+ key_edit = NULL;
+ } else if (multi_key_edit) {
+ memdelete(multi_key_edit);
+ multi_key_edit = NULL;
+ }
#endif
}
}
@@ -4156,38 +4865,70 @@ void AnimationTrackEditor::_update_key_edit() {
_clear_key_edit();
if (!animation.is_valid())
return;
- if (selection.size() != 1) {
- return;
- }
- key_edit = memnew(AnimationTrackKeyEdit);
- key_edit->animation = animation;
- key_edit->track = selection.front()->key().track;
- key_edit->use_fps = timeline->is_using_fps();
+ if (selection.size() == 1) {
+
+ key_edit = memnew(AnimationTrackKeyEdit);
+ key_edit->animation = animation;
+ key_edit->track = selection.front()->key().track;
+ key_edit->use_fps = timeline->is_using_fps();
+
+ float ofs = animation->track_get_key_time(key_edit->track, selection.front()->key().key);
+ key_edit->key_ofs = ofs;
+ key_edit->root_path = root;
+
+ NodePath np;
+ key_edit->hint = _find_hint_for_track(key_edit->track, np);
+ key_edit->undo_redo = undo_redo;
+ key_edit->base = np;
- float ofs = animation->track_get_key_time(key_edit->track, selection.front()->key().key);
- key_edit->key_ofs = ofs;
- key_edit->root_path = root;
+ EditorNode::get_singleton()->push_item(key_edit);
+ } else if (selection.size() > 1) {
- NodePath np;
- key_edit->hint = _find_hint_for_track(key_edit->track, np);
- key_edit->undo_redo = undo_redo;
- key_edit->base = np;
+ multi_key_edit = memnew(AnimationMultiTrackKeyEdit);
+ multi_key_edit->animation = animation;
- EditorNode::get_singleton()->push_item(key_edit);
+ Map<int, List<float> > key_ofs_map;
+ Map<int, NodePath> base_map;
+ int first_track = -1;
+ for (Map<SelectedKey, KeyInfo>::Element *E = selection.front(); E; E = E->next()) {
+
+ int track = E->key().track;
+ if (first_track < 0)
+ first_track = track;
+
+ if (!key_ofs_map.has(track)) {
+ key_ofs_map[track] = List<float>();
+ base_map[track] = *memnew(NodePath);
+ }
+
+ key_ofs_map[track].push_back(animation->track_get_key_time(track, E->key().key));
+ }
+ multi_key_edit->key_ofs_map = key_ofs_map;
+ multi_key_edit->base_map = base_map;
+ multi_key_edit->hint = _find_hint_for_track(first_track, base_map[first_track]);
+
+ multi_key_edit->use_fps = timeline->is_using_fps();
+
+ multi_key_edit->root_path = root;
+
+ multi_key_edit->undo_redo = undo_redo;
+
+ EditorNode::get_singleton()->push_item(multi_key_edit);
+ }
}
void AnimationTrackEditor::_clear_selection_for_anim(const Ref<Animation> &p_anim) {
- if (!(animation == p_anim))
+ if (animation != p_anim)
return;
- //selection.clear();
+
_clear_selection();
}
void AnimationTrackEditor::_select_at_anim(const Ref<Animation> &p_anim, int p_track, float p_pos) {
- if (!(animation == p_anim))
+ if (animation != p_anim)
return;
int idx = animation->track_find_key(p_track, p_pos, true);
@@ -4209,12 +4950,12 @@ void AnimationTrackEditor::_move_selection_commit() {
List<_AnimMoveRestore> to_restore;
float motion = moving_selection_offset;
- // 1-remove the keys
+ // 1 - remove the keys
for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) {
undo_redo->add_do_method(animation.ptr(), "track_remove_key", E->key().track, E->key().key);
}
- // 2- remove overlapped keys
+ // 2 - remove overlapped keys
for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) {
float newtime = snap_time(E->get().pos + motion);
@@ -4238,35 +4979,27 @@ void AnimationTrackEditor::_move_selection_commit() {
to_restore.push_back(amr);
}
- // 3-move the keys (re insert them)
+ // 3 - move the keys (re insert them)
for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) {
float newpos = snap_time(E->get().pos + motion);
- /*
- if (newpos<0)
- continue; //no add at the beginning
- */
undo_redo->add_do_method(animation.ptr(), "track_insert_key", E->key().track, newpos, animation->track_get_key_value(E->key().track, E->key().key), animation->track_get_key_transition(E->key().track, E->key().key));
}
- // 4-(undo) remove inserted keys
+ // 4 - (undo) remove inserted keys
for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) {
float newpos = snap_time(E->get().pos + motion);
- /*
- if (newpos<0)
- continue; //no remove what no inserted
- */
undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_position", E->key().track, newpos);
}
- // 5-(undo) reinsert keys
+ // 5 - (undo) reinsert keys
for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) {
undo_redo->add_undo_method(animation.ptr(), "track_insert_key", E->key().track, E->get().pos, animation->track_get_key_value(E->key().track, E->key().key), animation->track_get_key_transition(E->key().track, E->key().key));
}
- // 6-(undo) reinsert overlapped keys
+ // 6 - (undo) reinsert overlapped keys
for (List<_AnimMoveRestore>::Element *E = to_restore.front(); E; E = E->next()) {
_AnimMoveRestore &amr = E->get();
@@ -4276,12 +5009,12 @@ void AnimationTrackEditor::_move_selection_commit() {
undo_redo->add_do_method(this, "_clear_selection_for_anim", animation);
undo_redo->add_undo_method(this, "_clear_selection_for_anim", animation);
- // 7-reselect
+ // 7 - reselect
for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) {
float oldpos = E->get().pos;
float newpos = snap_time(oldpos + motion);
- //if (newpos>=0)
+
undo_redo->add_do_method(this, "_select_at_anim", animation, E->key().track, newpos);
undo_redo->add_undo_method(this, "_select_at_anim", animation, E->key().track, oldpos);
}
diff --git a/editor/animation_track_editor.h b/editor/animation_track_editor.h
index 8dc2304a95..9e16f2faf7 100644
--- a/editor/animation_track_editor.h
+++ b/editor/animation_track_editor.h
@@ -246,6 +246,7 @@ public:
};
class AnimationTrackKeyEdit;
+class AnimationMultiTrackKeyEdit;
class AnimationBezierTrackEdit;
class AnimationTrackEditGroup : public Control {
@@ -415,6 +416,7 @@ class AnimationTrackEditor : public VBoxContainer {
void _move_selection_cancel();
AnimationTrackKeyEdit *key_edit;
+ AnimationMultiTrackKeyEdit *multi_key_edit;
void _update_key_edit();
void _clear_key_edit();
diff --git a/editor/doc/doc_data.cpp b/editor/doc/doc_data.cpp
index 6f09e73fab..5b8c8fffb8 100644
--- a/editor/doc/doc_data.cpp
+++ b/editor/doc/doc_data.cpp
@@ -741,10 +741,9 @@ Error DocData::load_classes(const String &p_dir) {
da->list_dir_begin();
String path;
- bool isdir;
- path = da->get_next(&isdir);
+ path = da->get_next();
while (path != String()) {
- if (!isdir && path.ends_with("xml")) {
+ if (!da->current_is_dir() && path.ends_with("xml")) {
Ref<XMLParser> parser = memnew(XMLParser);
Error err2 = parser->open(p_dir.plus_file(path));
if (err2)
@@ -752,7 +751,7 @@ Error DocData::load_classes(const String &p_dir) {
_load(parser);
}
- path = da->get_next(&isdir);
+ path = da->get_next();
}
da->list_dir_end();
@@ -771,13 +770,12 @@ Error DocData::erase_classes(const String &p_dir) {
da->list_dir_begin();
String path;
- bool isdir;
- path = da->get_next(&isdir);
+ path = da->get_next();
while (path != String()) {
- if (!isdir && path.ends_with("xml")) {
+ if (!da->current_is_dir() && path.ends_with("xml")) {
to_erase.push_back(path);
}
- path = da->get_next(&isdir);
+ path = da->get_next();
}
da->list_dir_end();
diff --git a/editor/editor_file_dialog.cpp b/editor/editor_file_dialog.cpp
index 24c5a788b6..be01df76f7 100644
--- a/editor/editor_file_dialog.cpp
+++ b/editor/editor_file_dialog.cpp
@@ -29,6 +29,7 @@
/*************************************************************************/
#include "editor_file_dialog.h"
+
#include "core/os/file_access.h"
#include "core/os/keyboard.h"
#include "core/os/os.h"
@@ -731,19 +732,15 @@ void EditorFileDialog::update_file_list() {
List<String> files;
List<String> dirs;
- bool is_dir;
- bool is_hidden;
String item;
- while ((item = dir_access->get_next(&is_dir)) != "") {
+ while ((item = dir_access->get_next()) != "") {
if (item == "." || item == "..")
continue;
- is_hidden = dir_access->current_is_hidden();
-
- if (show_hidden_files || !is_hidden) {
- if (!is_dir)
+ if (show_hidden_files || !dir_access->current_is_hidden()) {
+ if (!dir_access->current_is_dir())
files.push_back(item);
else
dirs.push_back(item);
@@ -1507,9 +1504,9 @@ EditorFileDialog::EditorFileDialog() {
HBoxContainer *pathhb = memnew(HBoxContainer);
dir_prev = memnew(ToolButton);
- dir_prev->set_tooltip(TTR("Previous Folder"));
+ dir_prev->set_tooltip(TTR("Go to previous folder."));
dir_next = memnew(ToolButton);
- dir_next->set_tooltip(TTR("Next Folder"));
+ dir_next->set_tooltip(TTR("Go to next folder."));
dir_up = memnew(ToolButton);
dir_up->set_tooltip(TTR("Go to parent folder."));
@@ -1528,7 +1525,7 @@ EditorFileDialog::EditorFileDialog() {
dir->set_h_size_flags(SIZE_EXPAND_FILL);
refresh = memnew(ToolButton);
- refresh->set_tooltip(TTR("Refresh"));
+ refresh->set_tooltip(TTR("Refresh files."));
refresh->connect("pressed", this, "_update_file_list");
pathhb->add_child(refresh);
@@ -1541,7 +1538,7 @@ EditorFileDialog::EditorFileDialog() {
show_hidden = memnew(ToolButton);
show_hidden->set_toggle_mode(true);
show_hidden->set_pressed(is_showing_hidden_files());
- show_hidden->set_tooltip(TTR("Toggle visibility of hidden files."));
+ show_hidden->set_tooltip(TTR("Toggle the visibility of hidden files."));
show_hidden->connect("toggled", this, "set_show_hidden_files");
pathhb->add_child(show_hidden);
diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp
index 87a37acac6..be3df2815e 100644
--- a/editor/editor_file_system.cpp
+++ b/editor/editor_file_system.cpp
@@ -673,12 +673,11 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess
da->list_dir_begin();
while (true) {
- bool isdir;
- String f = da->get_next(&isdir);
+ String f = da->get_next();
if (f == "")
break;
- if (isdir) {
+ if (da->current_is_dir()) {
if (f.begins_with(".")) //ignore hidden and . / ..
continue;
@@ -870,12 +869,11 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir, const
da->list_dir_begin();
while (true) {
- bool isdir;
- String f = da->get_next(&isdir);
+ String f = da->get_next();
if (f == "")
break;
- if (isdir) {
+ if (da->current_is_dir()) {
if (f.begins_with(".")) //ignore hidden and . / ..
continue;
diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp
index e4ddf44bc4..70bbd0fd6c 100644
--- a/editor/editor_inspector.cpp
+++ b/editor/editor_inspector.cpp
@@ -504,7 +504,7 @@ bool EditorProperty::use_keying_next() const {
PropertyInfo &p = I->get();
if (p.name == property) {
- return p.hint == PROPERTY_HINT_SPRITE_FRAME;
+ return (p.usage & PROPERTY_USAGE_KEYING_INCREMENTS);
}
}
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 7231e33f18..3853d18e17 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -2488,12 +2488,6 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
screenshot_timer->start();
} break;
- case EDITOR_OPEN_SCREENSHOT: {
-
- bool is_checked = settings_menu->get_popup()->is_item_checked(settings_menu->get_popup()->get_item_index(EDITOR_OPEN_SCREENSHOT));
- settings_menu->get_popup()->set_item_checked(settings_menu->get_popup()->get_item_index(EDITOR_OPEN_SCREENSHOT), !is_checked);
- EditorSettings::get_singleton()->set_project_metadata("screenshot_options", "open_screenshot", !is_checked);
- } break;
case SETTINGS_PICK_MAIN_SCENE: {
file->set_mode(EditorFileDialog::MODE_OPEN_FILE);
@@ -2553,7 +2547,7 @@ void EditorNode::_screenshot(bool p_use_utc) {
String name = "editor_screenshot_" + OS::get_singleton()->get_iso_date_time(p_use_utc).replace(":", "") + ".png";
NodePath path = String("user://") + name;
_save_screenshot(path);
- if (EditorSettings::get_singleton()->get_project_metadata("screenshot_options", "open_screenshot", true)) {
+ if (EditorSettings::get_singleton()->get("interface/editor/automatically_open_screenshots")) {
OS::get_singleton()->shell_open(String("file://") + ProjectSettings::get_singleton()->globalize_path(path));
}
}
@@ -2621,7 +2615,7 @@ void EditorNode::_exit_editor() {
// Dim the editor window while it's quitting to make it clearer that it's busy.
// No transition is applied, as the effect needs to be visible immediately
- float c = 1.0f - float(EDITOR_GET("interface/editor/dim_amount"));
+ float c = 0.4f;
Color dim_color = Color(c, c, c);
gui_base->set_modulate(dim_color);
@@ -5057,9 +5051,8 @@ void EditorNode::_start_dimming(bool p_dimming) {
void EditorNode::_dim_timeout() {
_dim_time += _dim_timer->get_wait_time();
- float wait_time = EditorSettings::get_singleton()->get("interface/editor/dim_transition_time");
-
- float c = 1.0f - (float)EditorSettings::get_singleton()->get("interface/editor/dim_amount");
+ float wait_time = 0.08f;
+ float c = 0.4f;
Color base = _dimming ? Color(1, 1, 1) : Color(c, c, c);
Color final = _dimming ? Color(c, c, c) : Color(1, 1, 1);
@@ -5563,6 +5556,8 @@ EditorNode::EditorNode() {
EDITOR_DEF_RST("interface/scene_tabs/restore_scenes_on_load", false);
EDITOR_DEF_RST("interface/scene_tabs/show_thumbnail_on_hover", true);
EDITOR_DEF_RST("interface/inspector/capitalize_properties", true);
+ EDITOR_DEF_RST("interface/inspector/default_float_step", 0.001);
+ EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::REAL, "interface/inspector/default_float_step", PROPERTY_HINT_EXP_RANGE, "0,1,0"));
EDITOR_DEF_RST("interface/inspector/disable_folding", false);
EDITOR_DEF_RST("interface/inspector/auto_unfold_foreign_scenes", true);
EDITOR_DEF("interface/inspector/horizontal_vector2_editing", false);
@@ -6000,16 +5995,13 @@ EditorNode::EditorNode() {
p->add_child(editor_layouts);
editor_layouts->connect("id_pressed", this, "_layout_menu_option");
p->add_submenu_item(TTR("Editor Layout"), "Layouts");
+ p->add_separator();
#ifdef OSX_ENABLED
p->add_shortcut(ED_SHORTCUT("editor/take_screenshot", TTR("Take Screenshot"), KEY_MASK_CMD | KEY_F12), EDITOR_SCREENSHOT);
#else
p->add_shortcut(ED_SHORTCUT("editor/take_screenshot", TTR("Take Screenshot"), KEY_MASK_CTRL | KEY_F12), EDITOR_SCREENSHOT);
#endif
p->set_item_tooltip(p->get_item_count() - 1, TTR("Screenshots are stored in the Editor Data/Settings Folder."));
- p->add_check_shortcut(ED_SHORTCUT("editor/open_screenshot", TTR("Automatically Open Screenshots")), EDITOR_OPEN_SCREENSHOT);
- bool is_open_screenshot = EditorSettings::get_singleton()->get_project_metadata("screenshot_options", "open_screenshot", true);
- p->set_item_checked(p->get_item_count() - 1, is_open_screenshot);
- p->set_item_tooltip(p->get_item_count() - 1, TTR("Open in an external image editor."));
#ifdef OSX_ENABLED
p->add_shortcut(ED_SHORTCUT("editor/fullscreen_mode", TTR("Toggle Fullscreen"), KEY_MASK_CMD | KEY_MASK_CTRL | KEY_F), SETTINGS_TOGGLE_FULLSCREEN);
#else
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp
index d54f72382c..3300228921 100644
--- a/editor/editor_properties.cpp
+++ b/editor/editor_properties.cpp
@@ -2904,6 +2904,8 @@ void EditorInspectorDefaultPlugin::parse_begin(Object *p_object) {
bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Type p_type, const String &p_path, PropertyHint p_hint, const String &p_hint_text, int p_usage) {
+ float default_float_step = EDITOR_GET("interface/inspector/default_float_step");
+
switch (p_type) {
// atomic types
@@ -3010,7 +3012,7 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ
} else {
EditorPropertyFloat *editor = memnew(EditorPropertyFloat);
- double min = -65535, max = 65535, step = 0.001;
+ double min = -65535, max = 65535, step = default_float_step;
bool hide_slider = true;
bool exp_range = false;
bool greater = true, lesser = true;
@@ -3107,7 +3109,7 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ
case Variant::VECTOR2: {
EditorPropertyVector2 *editor = memnew(EditorPropertyVector2);
- double min = -65535, max = 65535, step = 0.001;
+ double min = -65535, max = 65535, step = default_float_step;
bool hide_slider = true;
if (p_hint == PROPERTY_HINT_RANGE && p_hint_text.get_slice_count(",") >= 2) {
@@ -3125,7 +3127,7 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ
} break; // 5
case Variant::RECT2: {
EditorPropertyRect2 *editor = memnew(EditorPropertyRect2);
- double min = -65535, max = 65535, step = 0.001;
+ double min = -65535, max = 65535, step = default_float_step;
bool hide_slider = true;
if (p_hint == PROPERTY_HINT_RANGE && p_hint_text.get_slice_count(",") >= 2) {
@@ -3142,7 +3144,7 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ
} break;
case Variant::VECTOR3: {
EditorPropertyVector3 *editor = memnew(EditorPropertyVector3);
- double min = -65535, max = 65535, step = 0.001;
+ double min = -65535, max = 65535, step = default_float_step;
bool hide_slider = true;
if (p_hint == PROPERTY_HINT_RANGE && p_hint_text.get_slice_count(",") >= 2) {
@@ -3160,7 +3162,7 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ
} break;
case Variant::TRANSFORM2D: {
EditorPropertyTransform2D *editor = memnew(EditorPropertyTransform2D);
- double min = -65535, max = 65535, step = 0.001;
+ double min = -65535, max = 65535, step = default_float_step;
bool hide_slider = true;
if (p_hint == PROPERTY_HINT_RANGE && p_hint_text.get_slice_count(",") >= 2) {
@@ -3178,7 +3180,7 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ
} break;
case Variant::PLANE: {
EditorPropertyPlane *editor = memnew(EditorPropertyPlane);
- double min = -65535, max = 65535, step = 0.001;
+ double min = -65535, max = 65535, step = default_float_step;
bool hide_slider = true;
if (p_hint == PROPERTY_HINT_RANGE && p_hint_text.get_slice_count(",") >= 2) {
@@ -3195,7 +3197,7 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ
} break;
case Variant::QUAT: {
EditorPropertyQuat *editor = memnew(EditorPropertyQuat);
- double min = -65535, max = 65535, step = 0.001;
+ double min = -65535, max = 65535, step = default_float_step;
bool hide_slider = true;
if (p_hint == PROPERTY_HINT_RANGE && p_hint_text.get_slice_count(",") >= 2) {
@@ -3212,7 +3214,7 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ
} break; // 10
case Variant::AABB: {
EditorPropertyAABB *editor = memnew(EditorPropertyAABB);
- double min = -65535, max = 65535, step = 0.001;
+ double min = -65535, max = 65535, step = default_float_step;
bool hide_slider = true;
if (p_hint == PROPERTY_HINT_RANGE && p_hint_text.get_slice_count(",") >= 2) {
@@ -3229,7 +3231,7 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ
} break;
case Variant::BASIS: {
EditorPropertyBasis *editor = memnew(EditorPropertyBasis);
- double min = -65535, max = 65535, step = 0.001;
+ double min = -65535, max = 65535, step = default_float_step;
bool hide_slider = true;
if (p_hint == PROPERTY_HINT_RANGE && p_hint_text.get_slice_count(",") >= 2) {
@@ -3246,7 +3248,7 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ
} break;
case Variant::TRANSFORM: {
EditorPropertyTransform *editor = memnew(EditorPropertyTransform);
- double min = -65535, max = 65535, step = 0.001;
+ double min = -65535, max = 65535, step = default_float_step;
bool hide_slider = true;
if (p_hint == PROPERTY_HINT_RANGE && p_hint_text.get_slice_count(",") >= 2) {
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index 223ca7a108..948a86924b 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -336,15 +336,12 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
_initial_set("interface/editor/code_font", "");
hints["interface/editor/code_font"] = PropertyInfo(Variant::STRING, "interface/editor/code_font", PROPERTY_HINT_GLOBAL_FILE, "*.ttf,*.otf", PROPERTY_USAGE_DEFAULT);
_initial_set("interface/editor/dim_editor_on_dialog_popup", true);
- _initial_set("interface/editor/dim_amount", 0.6f);
- hints["interface/editor/dim_amount"] = PropertyInfo(Variant::REAL, "interface/editor/dim_amount", PROPERTY_HINT_RANGE, "0,1,0.01", PROPERTY_USAGE_DEFAULT);
- _initial_set("interface/editor/dim_transition_time", 0.08f);
- hints["interface/editor/dim_transition_time"] = PropertyInfo(Variant::REAL, "interface/editor/dim_transition_time", PROPERTY_HINT_RANGE, "0,1,0.001", PROPERTY_USAGE_DEFAULT);
_initial_set("interface/editor/low_processor_mode_sleep_usec", 6900); // ~144 FPS
hints["interface/editor/low_processor_mode_sleep_usec"] = PropertyInfo(Variant::REAL, "interface/editor/low_processor_mode_sleep_usec", PROPERTY_HINT_RANGE, "1,100000,1", PROPERTY_USAGE_DEFAULT);
_initial_set("interface/editor/unfocused_low_processor_mode_sleep_usec", 50000); // 20 FPS
hints["interface/editor/unfocused_low_processor_mode_sleep_usec"] = PropertyInfo(Variant::REAL, "interface/editor/unfocused_low_processor_mode_sleep_usec", PROPERTY_HINT_RANGE, "1,100000,1", PROPERTY_USAGE_DEFAULT);
_initial_set("interface/editor/separate_distraction_mode", false);
+ _initial_set("interface/editor/automatically_open_screenshots", true);
_initial_set("interface/editor/hide_console_window", false);
_initial_set("interface/editor/save_each_scene_on_quit", true); // Regression
_initial_set("interface/editor/quit_confirmation", true);
diff --git a/editor/editor_spin_slider.cpp b/editor/editor_spin_slider.cpp
index dcb106899e..9966394025 100644
--- a/editor/editor_spin_slider.cpp
+++ b/editor/editor_spin_slider.cpp
@@ -38,9 +38,9 @@ String EditorSpinSlider::get_tooltip(const Point2 &p_pos) const {
}
String EditorSpinSlider::get_text_value() const {
- int zeros = Math::step_decimals(get_step());
- return String::num(get_value(), zeros);
+ return String::num(get_value(), Math::range_step_decimals(get_step()));
}
+
void EditorSpinSlider::_gui_input(const Ref<InputEvent> &p_event) {
if (read_only)
diff --git a/editor/export_template_manager.cpp b/editor/export_template_manager.cpp
index bd61e6182c..ecfad4d146 100644
--- a/editor/export_template_manager.cpp
+++ b/editor/export_template_manager.cpp
@@ -52,18 +52,16 @@ void ExportTemplateManager::_update_template_list() {
DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
Error err = d->change_dir(EditorSettings::get_singleton()->get_templates_dir());
- d->list_dir_begin();
Set<String> templates;
-
+ d->list_dir_begin();
if (err == OK) {
- bool isdir;
- String c = d->get_next(&isdir);
+ String c = d->get_next();
while (c != String()) {
- if (isdir && !c.begins_with(".")) {
+ if (d->current_is_dir() && !c.begins_with(".")) {
templates.insert(c);
}
- c = d->get_next(&isdir);
+ c = d->get_next();
}
}
d->list_dir_end();
@@ -154,18 +152,14 @@ void ExportTemplateManager::_uninstall_template_confirm() {
ERR_FAIL_COND(err != OK);
Vector<String> files;
-
d->list_dir_begin();
-
- bool isdir;
- String c = d->get_next(&isdir);
+ String c = d->get_next();
while (c != String()) {
- if (!isdir) {
+ if (!d->current_is_dir()) {
files.push_back(c);
}
- c = d->get_next(&isdir);
+ c = d->get_next();
}
-
d->list_dir_end();
for (int i = 0; i < files.size(); i++) {
diff --git a/editor/icons/icon_point_mesh.svg b/editor/icons/icon_point_mesh.svg
new file mode 100644
index 0000000000..8da7759daf
--- /dev/null
+++ b/editor/icons/icon_point_mesh.svg
@@ -0,0 +1,7 @@
+<svg width="16" height="16" xmlns="http://www.w3.org/2000/svg">
+<g fill="#ffd684" stroke="#000" stroke-dasharray="null" stroke-linecap="null" stroke-linejoin="null" stroke-opacity="0" stroke-width="0">
+<ellipse cx="3.7237" cy="3.0268" rx="2.0114" ry="1.9956"/>
+<ellipse cx="11.717" cy="6.1734" rx="2.0114" ry="1.9956"/>
+<ellipse cx="6.5219" cy="12.477" rx="2.0114" ry="1.9956"/>
+</g>
+</svg>
diff --git a/editor/import/editor_import_collada.cpp b/editor/import/editor_import_collada.cpp
index e152827c63..1c4a8c43a9 100644
--- a/editor/import/editor_import_collada.cpp
+++ b/editor/import/editor_import_collada.cpp
@@ -1175,35 +1175,33 @@ Error ColladaImport::_create_resources(Collada::Node *p_node, bool p_use_compres
morph = &collada.state.morph_controller_data_map[ngsource];
meshid = morph->mesh;
- Vector<String> targets;
-
- morph->targets.has("MORPH_TARGET");
- String target = morph->targets["MORPH_TARGET"];
- bool valid = false;
- if (morph->sources.has(target)) {
- valid = true;
- Vector<String> names = morph->sources[target].sarray;
- for (int i = 0; i < names.size(); i++) {
-
- String meshid2 = names[i];
- if (collada.state.mesh_data_map.has(meshid2)) {
- Ref<ArrayMesh> mesh = Ref<ArrayMesh>(memnew(ArrayMesh));
- const Collada::MeshData &meshdata = collada.state.mesh_data_map[meshid2];
- mesh->set_name(meshdata.name);
- Error err = _create_mesh_surfaces(false, mesh, ng2->material_map, meshdata, apply_xform, bone_remap, skin, NULL, Vector<Ref<ArrayMesh> >(), false);
- ERR_FAIL_COND_V(err, err);
-
- morphs.push_back(mesh);
- } else {
- valid = false;
+ if (morph->targets.has("MORPH_TARGET")) {
+ String target = morph->targets["MORPH_TARGET"];
+ bool valid = false;
+ if (morph->sources.has(target)) {
+ valid = true;
+ Vector<String> names = morph->sources[target].sarray;
+ for (int i = 0; i < names.size(); i++) {
+
+ String meshid2 = names[i];
+ if (collada.state.mesh_data_map.has(meshid2)) {
+ Ref<ArrayMesh> mesh = Ref<ArrayMesh>(memnew(ArrayMesh));
+ const Collada::MeshData &meshdata = collada.state.mesh_data_map[meshid2];
+ mesh->set_name(meshdata.name);
+ Error err = _create_mesh_surfaces(false, mesh, ng2->material_map, meshdata, apply_xform, bone_remap, skin, NULL, Vector<Ref<ArrayMesh> >(), false);
+ ERR_FAIL_COND_V(err, err);
+
+ morphs.push_back(mesh);
+ } else {
+ valid = false;
+ }
}
}
- }
-
- if (!valid)
- morphs.clear();
- ngsource = "";
+ if (!valid)
+ morphs.clear();
+ ngsource = "";
+ }
}
if (ngsource != "") {
diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp
index 53b67c46b0..8e6a56a929 100644
--- a/editor/import/resource_importer_scene.cpp
+++ b/editor/import/resource_importer_scene.cpp
@@ -435,6 +435,7 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh>
Object::cast_to<Spatial>(sb)->set_transform(Object::cast_to<Spatial>(p_node)->get_transform());
p_node->replace_by(sb);
memdelete(p_node);
+ p_node = NULL;
CollisionShape *colshape = memnew(CollisionShape);
if (empty_draw_type == "CUBE") {
BoxShape *boxShape = memnew(BoxShape);
diff --git a/editor/plugins/mesh_library_editor_plugin.cpp b/editor/plugins/mesh_library_editor_plugin.cpp
index e582f6ded2..1fc6dae978 100644
--- a/editor/plugins/mesh_library_editor_plugin.cpp
+++ b/editor/plugins/mesh_library_editor_plugin.cpp
@@ -201,6 +201,8 @@ void MeshLibraryEditor::_import_scene_cbk(const String &p_str) {
ERR_FAIL_COND(ps.is_null());
Node *scene = ps->instance();
+ ERR_FAIL_COND(!scene);
+
_import_scene(scene, mesh_library, option == MENU_OPTION_UPDATE_FROM_SCENE);
memdelete(scene);
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index d999f3189e..9cf889c5b0 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -2088,16 +2088,18 @@ bool ScriptEditor::edit(const RES &p_resource, int p_line, int p_col, bool p_gra
}
ERR_FAIL_COND_V(!se, false);
- bool highlighter_set = false;
- for (int i = 0; i < syntax_highlighters_func_count; i++) {
- SyntaxHighlighter *highlighter = syntax_highlighters_funcs[i]();
- se->add_syntax_highlighter(highlighter);
-
- if (script != NULL && !highlighter_set) {
- List<String> languages = highlighter->get_supported_languages();
- if (languages.find(script->get_language()->get_name())) {
- se->set_syntax_highlighter(highlighter);
- highlighter_set = true;
+ if (p_resource->get_class_name() != StringName("VisualScript")) {
+ bool highlighter_set = false;
+ for (int i = 0; i < syntax_highlighters_func_count; i++) {
+ SyntaxHighlighter *highlighter = syntax_highlighters_funcs[i]();
+ se->add_syntax_highlighter(highlighter);
+
+ if (script != NULL && !highlighter_set) {
+ List<String> languages = highlighter->get_supported_languages();
+ if (languages.find(script->get_language()->get_name())) {
+ se->set_syntax_highlighter(highlighter);
+ highlighter_set = true;
+ }
}
}
}
diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp
index 438621115b..07303da2ff 100644
--- a/editor/plugins/script_text_editor.cpp
+++ b/editor/plugins/script_text_editor.cpp
@@ -1819,6 +1819,15 @@ ScriptTextEditor::ScriptTextEditor() {
code_editor->get_text_edit()->set_drag_forwarding(this);
}
+ScriptTextEditor::~ScriptTextEditor() {
+ for (const Map<String, SyntaxHighlighter *>::Element *E = highlighters.front(); E; E = E->next()) {
+ if (E->get() != NULL) {
+ memdelete(E->get());
+ }
+ }
+ highlighters.clear();
+}
+
static ScriptEditorBase *create_editor(const RES &p_resource) {
if (Object::cast_to<Script>(*p_resource)) {
diff --git a/editor/plugins/script_text_editor.h b/editor/plugins/script_text_editor.h
index 9a2a514a6e..4dbade472c 100644
--- a/editor/plugins/script_text_editor.h
+++ b/editor/plugins/script_text_editor.h
@@ -231,6 +231,7 @@ public:
virtual void validate();
ScriptTextEditor();
+ ~ScriptTextEditor();
};
#endif // SCRIPT_TEXT_EDITOR_H
diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp
index b475eee920..630f3ba9e1 100644
--- a/editor/plugins/spatial_editor_plugin.cpp
+++ b/editor/plugins/spatial_editor_plugin.cpp
@@ -69,7 +69,7 @@
#define FREELOOK_SPEED_MULTIPLIER 1.08
#define MIN_Z 0.01
-#define MAX_Z 10000
+#define MAX_Z 1000000.0
#define MIN_FOV 0.01
#define MAX_FOV 179
@@ -645,7 +645,7 @@ bool SpatialEditorViewport::_gizmo_select(const Vector2 &p_screenpos, bool p_hig
Vector3 r;
- if (Geometry::segment_intersects_sphere(ray_pos, ray_pos + ray * 10000.0, grabber_pos, grabber_radius, &r)) {
+ if (Geometry::segment_intersects_sphere(ray_pos, ray_pos + ray * MAX_Z, grabber_pos, grabber_radius, &r)) {
float d = r.distance_to(ray_pos);
if (d < col_d) {
col_d = d;
@@ -753,7 +753,7 @@ bool SpatialEditorViewport::_gizmo_select(const Vector2 &p_screenpos, bool p_hig
Vector3 r;
- if (Geometry::segment_intersects_sphere(ray_pos, ray_pos + ray * 10000.0, grabber_pos, grabber_radius, &r)) {
+ if (Geometry::segment_intersects_sphere(ray_pos, ray_pos + ray * MAX_Z, grabber_pos, grabber_radius, &r)) {
float d = r.distance_to(ray_pos);
if (d < col_d) {
col_d = d;
@@ -1291,6 +1291,8 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
Vector3 ray_pos = _get_ray_pos(m->get_position());
Vector3 ray = _get_ray(m->get_position());
+ float snap = EDITOR_GET("interface/inspector/default_float_step");
+ int snap_step_decimals = Math::range_step_decimals(snap);
switch (_edit.mode) {
@@ -1372,18 +1374,14 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
// Disable local transformation for TRANSFORM_VIEW
bool local_coords = (spatial_editor->are_local_coords_enabled() && _edit.plane != TRANSFORM_VIEW);
- float snap = 0;
if (_edit.snap || spatial_editor->is_snap_enabled()) {
-
snap = spatial_editor->get_scale_snap() / 100;
-
- Vector3 motion_snapped = motion;
- motion_snapped.snap(Vector3(snap, snap, snap));
- set_message(TTR("Scaling: ") + motion_snapped);
-
- } else {
- set_message(TTR("Scaling: ") + motion);
}
+ Vector3 motion_snapped = motion;
+ motion_snapped.snap(Vector3(snap, snap, snap));
+ // This might not be necessary anymore after issue #288 is solved (in 4.0?).
+ set_message(TTR("Scaling: ") + "(" + String::num(motion_snapped.x, snap_step_decimals) + ", " +
+ String::num(motion_snapped.y, snap_step_decimals) + ", " + String::num(motion_snapped.z, snap_step_decimals) + ")");
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
@@ -1502,17 +1500,13 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
// Disable local transformation for TRANSFORM_VIEW
bool local_coords = (spatial_editor->are_local_coords_enabled() && _edit.plane != TRANSFORM_VIEW);
- float snap = 0;
if (_edit.snap || spatial_editor->is_snap_enabled()) {
-
snap = spatial_editor->get_translate_snap();
-
- Vector3 motion_snapped = motion;
- motion_snapped.snap(Vector3(snap, snap, snap));
- set_message(TTR("Translating: ") + motion_snapped);
- } else {
- set_message(TTR("Translating: ") + motion);
}
+ Vector3 motion_snapped = motion;
+ motion_snapped.snap(Vector3(snap, snap, snap));
+ set_message(TTR("Translating: ") + "(" + String::num(motion_snapped.x, snap_step_decimals) + ", " +
+ String::num(motion_snapped.y, snap_step_decimals) + ", " + String::num(motion_snapped.z, snap_step_decimals) + ")");
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
@@ -1601,20 +1595,12 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
float angle = Math::atan2(x_axis.dot(intersection - _edit.center), y_axis.dot(intersection - _edit.center));
if (_edit.snap || spatial_editor->is_snap_enabled()) {
-
- float snap = spatial_editor->get_rotate_snap();
-
- if (snap) {
- angle = Math::rad2deg(angle) + snap * 0.5; //else it won't reach +180
- angle -= Math::fmod(angle, snap);
- set_message(vformat(TTR("Rotating %s degrees."), rtos(angle)));
- angle = Math::deg2rad(angle);
- } else
- set_message(vformat(TTR("Rotating %s degrees."), rtos(Math::rad2deg(angle))));
-
- } else {
- set_message(vformat(TTR("Rotating %s degrees."), rtos(Math::rad2deg(angle))));
+ snap = spatial_editor->get_rotate_snap();
}
+ angle = Math::rad2deg(angle) + snap * 0.5; //else it won't reach +180
+ angle -= Math::fmod(angle, snap);
+ set_message(vformat(TTR("Rotating %s degrees."), String::num(angle, snap_step_decimals)));
+ angle = Math::deg2rad(angle);
List<Node *> &selection = editor_selection->get_selected_node_list();
@@ -1835,8 +1821,11 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
_menu_option(orthogonal ? VIEW_PERSPECTIVE : VIEW_ORTHOGONAL);
_update_name();
}
- if (ED_IS_SHORTCUT("spatial_editor/align_selection_with_view", p_event)) {
- _menu_option(VIEW_ALIGN_SELECTION_WITH_VIEW);
+ if (ED_IS_SHORTCUT("spatial_editor/align_transform_with_view", p_event)) {
+ _menu_option(VIEW_ALIGN_TRANSFORM_WITH_VIEW);
+ }
+ if (ED_IS_SHORTCUT("spatial_editor/align_rotation_with_view", p_event)) {
+ _menu_option(VIEW_ALIGN_ROTATION_WITH_VIEW);
}
if (ED_IS_SHORTCUT("spatial_editor/insert_anim_key", p_event)) {
if (!get_selected_count() || _edit.mode != TRANSFORM_NONE)
@@ -2562,7 +2551,7 @@ void SpatialEditorViewport::_menu_option(int p_option) {
focus_selection();
} break;
- case VIEW_ALIGN_SELECTION_WITH_VIEW: {
+ case VIEW_ALIGN_TRANSFORM_WITH_VIEW: {
if (!get_selected_count())
break;
@@ -2571,7 +2560,8 @@ void SpatialEditorViewport::_menu_option(int p_option) {
List<Node *> &selection = editor_selection->get_selected_node_list();
- undo_redo->create_action(TTR("Align with View"));
+ undo_redo->create_action(TTR("Align Transform with View"));
+
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
Spatial *sp = Object::cast_to<Spatial>(E->get());
@@ -2595,6 +2585,34 @@ void SpatialEditorViewport::_menu_option(int p_option) {
undo_redo->add_undo_method(sp, "set_global_transform", sp->get_global_gizmo_transform());
}
undo_redo->commit_action();
+ focus_selection();
+
+ } break;
+ case VIEW_ALIGN_ROTATION_WITH_VIEW: {
+
+ if (!get_selected_count())
+ break;
+
+ Transform camera_transform = camera->get_global_transform();
+
+ List<Node *> &selection = editor_selection->get_selected_node_list();
+
+ undo_redo->create_action(TTR("Align Rotation with View"));
+ for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
+
+ Spatial *sp = Object::cast_to<Spatial>(E->get());
+ if (!sp)
+ continue;
+
+ SpatialEditorSelectedItem *se = editor_selection->get_node_editor_data<SpatialEditorSelectedItem>(sp);
+ if (!se)
+ continue;
+
+ undo_redo->add_do_method(sp, "set_rotation", camera_transform.basis.get_rotation());
+ undo_redo->add_undo_method(sp, "set_rotation", sp->get_rotation());
+ }
+ undo_redo->commit_action();
+
} break;
case VIEW_ENVIRONMENT: {
@@ -3544,7 +3562,8 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed
view_menu->get_popup()->add_separator();
view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/focus_origin"), VIEW_CENTER_TO_ORIGIN);
view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/focus_selection"), VIEW_CENTER_TO_SELECTION);
- view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/align_selection_with_view"), VIEW_ALIGN_SELECTION_WITH_VIEW);
+ view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/align_transform_with_view"), VIEW_ALIGN_TRANSFORM_WITH_VIEW);
+ view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/align_rotation_with_view"), VIEW_ALIGN_ROTATION_WITH_VIEW);
view_menu->get_popup()->connect("id_pressed", this, "_menu_option");
view_menu->set_disable_shortcuts(true);
@@ -5601,7 +5620,8 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
ED_SHORTCUT("spatial_editor/insert_anim_key", TTR("Insert Animation Key"), KEY_K);
ED_SHORTCUT("spatial_editor/focus_origin", TTR("Focus Origin"), KEY_O);
ED_SHORTCUT("spatial_editor/focus_selection", TTR("Focus Selection"), KEY_F);
- ED_SHORTCUT("spatial_editor/align_selection_with_view", TTR("Align Selection With View"), KEY_MASK_ALT + KEY_MASK_CMD + KEY_F);
+ ED_SHORTCUT("spatial_editor/align_transform_with_view", TTR("Align Transform with View"), KEY_MASK_ALT + KEY_MASK_CMD + KEY_M);
+ ED_SHORTCUT("spatial_editor/align_rotation_with_view", TTR("Align Rotation with View"), KEY_MASK_ALT + KEY_MASK_CMD + KEY_F);
ED_SHORTCUT("spatial_editor/tool_select", TTR("Tool Select"), KEY_Q);
ED_SHORTCUT("spatial_editor/tool_move", TTR("Tool Move"), KEY_W);
diff --git a/editor/plugins/spatial_editor_plugin.h b/editor/plugins/spatial_editor_plugin.h
index 1a32d6e047..dde402c0ff 100644
--- a/editor/plugins/spatial_editor_plugin.h
+++ b/editor/plugins/spatial_editor_plugin.h
@@ -153,7 +153,8 @@ class SpatialEditorViewport : public Control {
VIEW_REAR,
VIEW_CENTER_TO_ORIGIN,
VIEW_CENTER_TO_SELECTION,
- VIEW_ALIGN_SELECTION_WITH_VIEW,
+ VIEW_ALIGN_TRANSFORM_WITH_VIEW,
+ VIEW_ALIGN_ROTATION_WITH_VIEW,
VIEW_PERSPECTIVE,
VIEW_ENVIRONMENT,
VIEW_ORTHOGONAL,
diff --git a/editor/plugins/text_editor.cpp b/editor/plugins/text_editor.cpp
index fae88f4eb7..34d8e6aff5 100644
--- a/editor/plugins/text_editor.cpp
+++ b/editor/plugins/text_editor.cpp
@@ -695,5 +695,14 @@ TextEditor::TextEditor() {
code_editor->get_text_edit()->set_drag_forwarding(this);
}
+TextEditor::~TextEditor() {
+ for (const Map<String, SyntaxHighlighter *>::Element *E = highlighters.front(); E; E = E->next()) {
+ if (E->get() != NULL) {
+ memdelete(E->get());
+ }
+ }
+ highlighters.clear();
+}
+
void TextEditor::validate() {
}
diff --git a/editor/plugins/text_editor.h b/editor/plugins/text_editor.h
index ae0c0bcf93..3a330576ae 100644
--- a/editor/plugins/text_editor.h
+++ b/editor/plugins/text_editor.h
@@ -154,6 +154,7 @@ public:
static void register_editor();
TextEditor();
+ ~TextEditor();
};
#endif // TEXT_EDITOR_H
diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp
index e013aae164..feb2cdd071 100644
--- a/editor/project_manager.cpp
+++ b/editor/project_manager.cpp
@@ -52,6 +52,10 @@
#include "scene/gui/texture_rect.h"
#include "scene/gui/tool_button.h"
+static inline String get_project_key_from_path(const String &dir) {
+ return dir.replace("/", "::");
+}
+
class ProjectDialog : public ConfirmationDialog {
GDCLASS(ProjectDialog, ConfirmationDialog);
@@ -606,7 +610,7 @@ private:
dir = dir.replace("\\", "/");
if (dir.ends_with("/"))
dir = dir.substr(0, dir.length() - 1);
- String proj = dir.replace("/", "::");
+ String proj = get_project_key_from_path(dir);
EditorSettings::get_singleton()->set("projects/" + proj, dir);
EditorSettings::get_singleton()->save();
@@ -918,596 +922,960 @@ public:
}
};
-struct ProjectItem {
- String project;
- String project_name;
- String path;
- String conf;
- String icon;
- String main_scene;
- uint64_t last_modified;
- bool favorite;
- bool grayed;
- ProjectListFilter::FilterOption filter_order_option;
- ProjectItem() {}
- ProjectItem(const String &p_project, const String &p_name, const String &p_path, const String &p_conf, const String &p_icon, const String &p_main_scene, uint64_t p_last_modified, bool p_favorite = false, bool p_grayed = false, const ProjectListFilter::FilterOption p_filter_order_option = ProjectListFilter::FILTER_NAME) {
- project = p_project;
- project_name = p_name;
- path = p_path;
- conf = p_conf;
- icon = p_icon;
- main_scene = p_main_scene;
- last_modified = p_last_modified;
- favorite = p_favorite;
- grayed = p_grayed;
- filter_order_option = p_filter_order_option;
- }
- _FORCE_INLINE_ bool operator<(const ProjectItem &l) const {
- switch (filter_order_option) {
+class ProjectListItemControl : public HBoxContainer {
+ GDCLASS(ProjectListItemControl, HBoxContainer)
+public:
+ TextureButton *favorite_button;
+ TextureRect *icon;
+ bool icon_needs_reload;
+
+ ProjectListItemControl() {
+ favorite_button = NULL;
+ icon = NULL;
+ icon_needs_reload = true;
+ }
+
+ void set_is_favorite(bool fav) {
+ favorite_button->set_modulate(fav ? Color(1, 1, 1, 1) : Color(1, 1, 1, 0.2));
+ }
+};
+
+class ProjectList : public ScrollContainer {
+ GDCLASS(ProjectList, ScrollContainer)
+public:
+ static const char *SIGNAL_SELECTION_CHANGED;
+ static const char *SIGNAL_PROJECT_ASK_OPEN;
+
+ // Can often be passed by copy
+ struct Item {
+ String project_key;
+ String project_name;
+ String path;
+ String icon;
+ String main_scene;
+ uint64_t last_modified;
+ bool favorite;
+ bool grayed;
+ bool missing;
+ int version;
+
+ ProjectListItemControl *control;
+
+ Item() {}
+
+ Item(const String &p_project,
+ const String &p_name,
+ const String &p_path,
+ const String &p_icon,
+ const String &p_main_scene,
+ uint64_t p_last_modified,
+ bool p_favorite,
+ bool p_grayed,
+ bool p_missing,
+ int p_version) {
+
+ project_key = p_project;
+ project_name = p_name;
+ path = p_path;
+ icon = p_icon;
+ main_scene = p_main_scene;
+ last_modified = p_last_modified;
+ favorite = p_favorite;
+ grayed = p_grayed;
+ missing = p_missing;
+ version = p_version;
+ control = NULL;
+ }
+
+ _FORCE_INLINE_ bool operator==(const Item &l) const {
+ return project_key == l.project_key;
+ }
+ };
+
+ ProjectList();
+ ~ProjectList();
+
+ void load_projects();
+ void set_search_term(String p_search_term);
+ void set_filter_option(ProjectListFilter::FilterOption p_option);
+ void set_order_option(ProjectListFilter::FilterOption p_option);
+ void sort_projects();
+ int get_project_count() const;
+ void select_project(int p_index);
+ void erase_selected_projects();
+ Vector<Item> get_selected_projects() const;
+ const Set<String> &get_selected_project_keys() const;
+ void ensure_project_visible(int p_index);
+ int get_single_selected_index() const;
+ bool is_any_project_missing() const;
+ void erase_missing_projects();
+ int refresh_project(const String &dir_path);
+
+private:
+ static void _bind_methods();
+ void _notification(int p_what);
+
+ void _panel_draw(Node *p_hb);
+ void _panel_input(const Ref<InputEvent> &p_ev, Node *p_hb);
+ void _favorite_pressed(Node *p_hb);
+ void _show_project(const String &p_path);
+
+ void select_range(int p_begin, int p_end);
+ void toggle_select(int p_index);
+ void create_project_item_control(int p_index);
+ void remove_project(int p_index, bool p_update_settings);
+ void update_icons_async();
+ void load_project_icon(int p_index);
+
+ static void load_project_data(const String &p_property_key, Item &p_item, bool p_favorite);
+
+ String _search_term;
+ ProjectListFilter::FilterOption _filter_option;
+ ProjectListFilter::FilterOption _order_option;
+ Set<String> _selected_project_keys;
+ String _last_clicked; // Project key
+ VBoxContainer *_scroll_children;
+ int _icon_load_index;
+
+ Vector<Item> _projects;
+};
+
+struct ProjectListComparator {
+ ProjectListFilter::FilterOption order_option;
+
+ // operator<
+ _FORCE_INLINE_ bool operator()(const ProjectList::Item &a, const ProjectList::Item &b) const {
+ if (a.favorite && !b.favorite) {
+ return true;
+ }
+ if (b.favorite && !a.favorite) {
+ return false;
+ }
+ switch (order_option) {
case ProjectListFilter::FILTER_PATH:
- return project < l.project;
+ return a.project_key < b.project_key;
case ProjectListFilter::FILTER_MODIFIED:
- return last_modified > l.last_modified;
+ return a.last_modified > b.last_modified;
default:
- return project_name < l.project_name;
+ return a.project_name < b.project_name;
}
}
- _FORCE_INLINE_ bool operator==(const ProjectItem &l) const { return project == l.project; }
};
-void ProjectManager::_notification(int p_what) {
+ProjectList::ProjectList() {
+ _filter_option = ProjectListFilter::FILTER_NAME;
+ _order_option = ProjectListFilter::FILTER_MODIFIED;
- switch (p_what) {
- case NOTIFICATION_ENTER_TREE: {
+ _scroll_children = memnew(VBoxContainer);
+ _scroll_children->set_h_size_flags(SIZE_EXPAND_FILL);
+ add_child(_scroll_children);
- Engine::get_singleton()->set_editor_hint(false);
- } break;
- case NOTIFICATION_READY: {
+ _icon_load_index = 0;
+}
- if (scroll_children->get_child_count() == 0 && StreamPeerSSL::is_available())
- open_templates->popup_centered_minsize();
- } break;
- case NOTIFICATION_VISIBILITY_CHANGED: {
+ProjectList::~ProjectList() {
+}
- set_process_unhandled_input(is_visible_in_tree());
- } break;
- case NOTIFICATION_WM_QUIT_REQUEST: {
+void ProjectList::update_icons_async() {
+ _icon_load_index = 0;
+ set_process(true);
+}
- _dim_window();
- } break;
+void ProjectList::_notification(int p_what) {
+ if (p_what == NOTIFICATION_PROCESS) {
+
+ // Load icons as a coroutine to speed up launch when you have hundreds of projects
+ if (_icon_load_index < _projects.size()) {
+ Item &item = _projects.write[_icon_load_index];
+ if (item.control->icon_needs_reload) {
+ load_project_icon(_icon_load_index);
+ }
+ _icon_load_index++;
+
+ } else {
+ set_process(false);
+ }
}
}
-void ProjectManager::_dim_window() {
-
- // This method must be called before calling `get_tree()->quit()`.
- // Otherwise, its effect won't be visible
+void ProjectList::load_project_icon(int p_index) {
+ Item &item = _projects.write[p_index];
+
+ Ref<Texture> default_icon = get_icon("DefaultProjectIcon", "EditorIcons");
+ Ref<Texture> icon;
+ if (item.icon != "") {
+ Ref<Image> img;
+ img.instance();
+ Error err = img->load(item.icon.replace_first("res://", item.path + "/"));
+ if (err == OK) {
+
+ img->resize(default_icon->get_width(), default_icon->get_height());
+ Ref<ImageTexture> it = memnew(ImageTexture);
+ it->create_from_image(img);
+ icon = it;
+ }
+ }
+ if (icon.is_null()) {
+ icon = default_icon;
+ }
- // Dim the project manager window while it's quitting to make it clearer that it's busy.
- // No transition is applied, as the effect needs to be visible immediately
- float c = 1.0f - float(EDITOR_GET("interface/editor/dim_amount"));
- Color dim_color = Color(c, c, c);
- gui_base->set_modulate(dim_color);
+ item.control->icon->set_texture(icon);
+ item.control->icon_needs_reload = false;
}
-void ProjectManager::_panel_draw(Node *p_hb) {
+void ProjectList::load_project_data(const String &p_property_key, Item &p_item, bool p_favorite) {
- HBoxContainer *hb = Object::cast_to<HBoxContainer>(p_hb);
+ String path = EditorSettings::get_singleton()->get(p_property_key);
+ String conf = path.plus_file("project.godot");
+ bool grayed = false;
+ bool missing = false;
- hb->draw_line(Point2(0, hb->get_size().y + 1), Point2(hb->get_size().x - 10, hb->get_size().y + 1), get_color("guide_color", "Tree"));
+ Ref<ConfigFile> cf = memnew(ConfigFile);
+ Error cf_err = cf->load(conf);
+
+ int config_version = 0;
+ String project_name = TTR("Unnamed Project");
+ if (cf_err == OK) {
+ String cf_project_name = static_cast<String>(cf->get_value("application", "config/name", ""));
+ if (cf_project_name != "")
+ project_name = cf_project_name.xml_unescape();
+ config_version = (int)cf->get_value("", "config_version", 0);
+ }
- if (selected_list.has(hb->get_meta("name"))) {
- hb->draw_style_box(gui_base->get_stylebox("selected", "Tree"), Rect2(Point2(), hb->get_size() - Size2(10, 0) * EDSCALE));
+ if (config_version > ProjectSettings::CONFIG_VERSION) {
+ // Comes from an incompatible (more recent) Godot version, grey it out
+ grayed = true;
}
+
+ String icon = cf->get_value("application", "config/icon", "");
+ String main_scene = cf->get_value("application", "run/main_scene", "");
+
+ uint64_t last_modified = 0;
+ if (FileAccess::exists(conf)) {
+ last_modified = FileAccess::get_modified_time(conf);
+
+ String fscache = path.plus_file(".fscache");
+ if (FileAccess::exists(fscache)) {
+ uint64_t cache_modified = FileAccess::get_modified_time(fscache);
+ if (cache_modified > last_modified)
+ last_modified = cache_modified;
+ }
+ } else {
+ grayed = true;
+ missing = true;
+ print_line("Project is missing: " + conf);
+ }
+
+ String project_key = p_property_key.get_slice("/", 1);
+
+ p_item = Item(project_key, project_name, path, icon, main_scene, last_modified, p_favorite, grayed, missing, config_version);
}
-void ProjectManager::_update_project_buttons() {
- for (int i = 0; i < scroll_children->get_child_count(); i++) {
+void ProjectList::load_projects() {
+ // This is a full, hard reload of the list. Don't call this unless really required, it's expensive.
+ // If you have 150 projects, it may read through 150 files on your disk at once + load 150 icons.
- CanvasItem *item = Object::cast_to<CanvasItem>(scroll_children->get_child(i));
- item->update();
+ // Clear whole list
+ for (int i = 0; i < _projects.size(); ++i) {
+ Item &project = _projects.write[i];
+ CRASH_COND(project.control == NULL);
+ memdelete(project.control); // Why not queue_free()?
}
+ _projects.clear();
+ _last_clicked = "";
+ _selected_project_keys.clear();
- bool empty_selection = selected_list.empty();
- erase_btn->set_disabled(empty_selection);
- open_btn->set_disabled(empty_selection);
- rename_btn->set_disabled(empty_selection);
- run_btn->set_disabled(empty_selection);
+ // Load data
+ // TODO Would be nice to change how projects and favourites are stored... it complicates things a bit.
+ // Use a dictionary associating project path to metadata (like is_favorite).
+
+ List<PropertyInfo> properties;
+ EditorSettings::get_singleton()->get_property_list(&properties);
- bool missing_projects = false;
- Map<String, String> list_all_projects;
- for (int i = 0; i < scroll_children->get_child_count(); i++) {
- HBoxContainer *hb = Object::cast_to<HBoxContainer>(scroll_children->get_child(i));
- if (hb) {
- list_all_projects.insert(hb->get_meta("name"), hb->get_meta("main_scene"));
+ Set<String> favorites;
+ // Find favourites...
+ for (List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) {
+ String property_key = E->get().name;
+ if (property_key.begins_with("favorite_projects/")) {
+ favorites.insert(property_key);
}
}
- for (Map<String, String>::Element *E = list_all_projects.front(); E; E = E->next()) {
- String project_name = E->key().replace(":::", ":/").replace("::", "/") + "/project.godot";
- if (!FileAccess::exists(project_name)) {
- missing_projects = true;
- break;
- }
+
+ for (List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) {
+ // This is actually something like "projects/C:::Documents::Godot::Projects::MyGame"
+ String property_key = E->get().name;
+ if (!property_key.begins_with("projects/"))
+ continue;
+
+ String project_key = property_key.get_slice("/", 1);
+ bool favorite = favorites.has("favorite_projects/" + project_key);
+
+ Item item;
+ load_project_data(property_key, item, favorite);
+
+ _projects.push_back(item);
}
- erase_missing_btn->set_visible(missing_projects);
+ // Create controls
+ for (int i = 0; i < _projects.size(); ++i) {
+ create_project_item_control(i);
+ }
+
+ sort_projects();
+
+ set_v_scroll(0);
+
+ update_icons_async();
}
-void ProjectManager::_panel_input(const Ref<InputEvent> &p_ev, Node *p_hb) {
+void ProjectList::create_project_item_control(int p_index) {
- Ref<InputEventMouseButton> mb = p_ev;
+ // Will be added last in the list, so make sure indexes match
+ ERR_FAIL_COND(p_index != _scroll_children->get_child_count());
- if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) {
+ Item &item = _projects.write[p_index];
+ ERR_FAIL_COND(item.control != NULL); // Already created
- String clicked = p_hb->get_meta("name");
- String clicked_main_scene = p_hb->get_meta("main_scene");
+ Ref<Texture> favorite_icon = get_icon("Favorites", "EditorIcons");
+ Color font_color = get_color("font_color", "Tree");
+
+ ProjectListItemControl *hb = memnew(ProjectListItemControl);
+ hb->connect("draw", this, "_panel_draw", varray(hb));
+ hb->connect("gui_input", this, "_panel_input", varray(hb));
+ hb->add_constant_override("separation", 10 * EDSCALE);
+
+ VBoxContainer *favorite_box = memnew(VBoxContainer);
+ favorite_box->set_name("FavoriteBox");
+ TextureButton *favorite = memnew(TextureButton);
+ favorite->set_name("FavoriteButton");
+ favorite->set_normal_texture(favorite_icon);
+ favorite->connect("pressed", this, "_favorite_pressed", varray(hb));
+ favorite_box->add_child(favorite);
+ favorite_box->set_alignment(BoxContainer::ALIGN_CENTER);
+ hb->add_child(favorite_box);
+ hb->favorite_button = favorite;
+ hb->set_is_favorite(item.favorite);
+
+ TextureRect *tf = memnew(TextureRect);
+ tf->set_texture(get_icon("DefaultProjectIcon", "EditorIcons"));
+ hb->add_child(tf);
+ hb->icon = tf;
- if (mb->get_shift() && selected_list.size() > 0 && last_clicked != "" && clicked != last_clicked) {
+ VBoxContainer *vb = memnew(VBoxContainer);
+ if (item.grayed)
+ vb->set_modulate(Color(0.5, 0.5, 0.5));
+ vb->set_h_size_flags(SIZE_EXPAND_FILL);
+ hb->add_child(vb);
+ Control *ec = memnew(Control);
+ ec->set_custom_minimum_size(Size2(0, 1));
+ ec->set_mouse_filter(MOUSE_FILTER_PASS);
+ vb->add_child(ec);
+ Label *title = memnew(Label(item.project_name));
+ title->add_font_override("font", get_font("title", "EditorFonts"));
+ title->add_color_override("font_color", font_color);
+ title->set_clip_text(true);
+ vb->add_child(title);
+
+ HBoxContainer *path_hb = memnew(HBoxContainer);
+ path_hb->set_h_size_flags(SIZE_EXPAND_FILL);
+ vb->add_child(path_hb);
+
+ Button *show = memnew(Button);
+ show->set_icon(get_icon("Load", "EditorIcons")); // Folder icon
+ show->set_flat(true);
+ show->set_modulate(Color(1, 1, 1, 0.5));
+ path_hb->add_child(show);
+ show->connect("pressed", this, "_show_project", varray(item.path));
+ show->set_tooltip(TTR("Show in File Manager"));
+
+ Label *fpath = memnew(Label(item.path));
+ path_hb->add_child(fpath);
+ fpath->set_h_size_flags(SIZE_EXPAND_FILL);
+ fpath->set_modulate(Color(1, 1, 1, 0.5));
+ fpath->add_color_override("font_color", font_color);
+ fpath->set_clip_text(true);
+
+ _scroll_children->add_child(hb);
+ item.control = hb;
+}
- int clicked_id = -1;
- int last_clicked_id = -1;
- for (int i = 0; i < scroll_children->get_child_count(); i++) {
- HBoxContainer *hb = Object::cast_to<HBoxContainer>(scroll_children->get_child(i));
- if (!hb) continue;
- if (hb->get_meta("name") == clicked) clicked_id = i;
- if (hb->get_meta("name") == last_clicked) last_clicked_id = i;
- }
+void ProjectList::set_search_term(String p_search_term) {
+ _search_term = p_search_term;
+}
- if (last_clicked_id != -1 && clicked_id != -1) {
- int min = clicked_id < last_clicked_id ? clicked_id : last_clicked_id;
- int max = clicked_id > last_clicked_id ? clicked_id : last_clicked_id;
- for (int i = 0; i < scroll_children->get_child_count(); ++i) {
- HBoxContainer *hb = Object::cast_to<HBoxContainer>(scroll_children->get_child(i));
- if (!hb) continue;
- if (i != clicked_id && (i < min || i > max) && !mb->get_control()) {
- selected_list.erase(hb->get_meta("name"));
- } else if (i >= min && i <= max) {
- selected_list.insert(hb->get_meta("name"), hb->get_meta("main_scene"));
- }
- }
- }
+void ProjectList::set_filter_option(ProjectListFilter::FilterOption p_option) {
+ if (_filter_option != p_option) {
+ _filter_option = p_option;
+ }
+}
- } else if (selected_list.has(clicked) && mb->get_control()) {
+void ProjectList::set_order_option(ProjectListFilter::FilterOption p_option) {
+ if (_order_option != p_option) {
+ _order_option = p_option;
+ EditorSettings::get_singleton()->set("project_manager/sorting_order", (int)_filter_option);
+ EditorSettings::get_singleton()->save();
+ }
+}
- selected_list.erase(clicked);
+void ProjectList::sort_projects() {
- } else {
+ SortArray<Item, ProjectListComparator> sorter;
+ sorter.compare.order_option = _order_option;
+ sorter.sort(_projects.ptrw(), _projects.size());
- last_clicked = clicked;
- if (mb->get_control() || selected_list.size() == 0) {
- selected_list.insert(clicked, clicked_main_scene);
- } else {
- selected_list.clear();
- selected_list.insert(clicked, clicked_main_scene);
+ for (int i = 0; i < _projects.size(); ++i) {
+ Item &item = _projects.write[i];
+
+ bool visible = true;
+ if (_search_term != "") {
+ if (_filter_option == ProjectListFilter::FILTER_PATH) {
+ visible = item.path.findn(_search_term) != -1;
+ } else if (_filter_option == ProjectListFilter::FILTER_NAME) {
+ visible = item.project_name.findn(_search_term) != -1;
}
}
- _update_project_buttons();
+ item.control->set_visible(visible);
+ }
- if (mb->is_doubleclick())
- _open_selected_projects_ask(); //open if doubleclicked
+ for (int i = 0; i < _projects.size(); ++i) {
+ Item &item = _projects.write[i];
+ if (item.control->is_visible()) {
+ item.control->get_parent()->move_child(item.control, i);
+ }
}
+
+ // Rewind the coroutine because order of projects changed
+ update_icons_async();
}
-void ProjectManager::_unhandled_input(const Ref<InputEvent> &p_ev) {
+const Set<String> &ProjectList::get_selected_project_keys() const {
+ // Faster if that's all you need
+ return _selected_project_keys;
+}
- Ref<InputEventKey> k = p_ev;
+Vector<ProjectList::Item> ProjectList::get_selected_projects() const {
+ Vector<Item> items;
+ if (_selected_project_keys.size() == 0) {
+ return items;
+ }
+ items.resize(_selected_project_keys.size());
+ int j = 0;
+ for (int i = 0; i < _projects.size(); ++i) {
+ const Item &item = _projects[i];
+ if (_selected_project_keys.has(item.project_key)) {
+ items.write[j++] = item;
+ }
+ }
+ ERR_FAIL_COND_V(j != items.size(), items);
+ return items;
+}
- if (k.is_valid()) {
+void ProjectList::ensure_project_visible(int p_index) {
+ const Item &item = _projects[p_index];
- if (!k->is_pressed())
- return;
+ int item_top = item.control->get_position().y;
+ int item_bottom = item.control->get_position().y + item.control->get_size().y;
- if (tabs->get_current_tab() != 0)
- return;
+ if (item_top < get_v_scroll()) {
+ set_v_scroll(item_top);
- bool scancode_handled = true;
+ } else if (item_bottom > get_v_scroll() + get_size().y) {
+ set_v_scroll(item_bottom - get_size().y);
+ }
+}
- switch (k->get_scancode()) {
+int ProjectList::get_single_selected_index() const {
+ if (_selected_project_keys.size() == 0) {
+ // Default selection
+ return 0;
+ }
+ String key;
+ if (_selected_project_keys.size() == 1) {
+ // Only one selected
+ key = _selected_project_keys.front()->get();
+ } else {
+ // Multiple selected, consider the last clicked one as "main"
+ key = _last_clicked;
+ }
+ for (int i = 0; i < _projects.size(); ++i) {
+ if (_projects[i].project_key == key) {
+ return i;
+ }
+ }
+ return 0;
+}
- case KEY_ENTER: {
+void ProjectList::remove_project(int p_index, bool p_update_settings) {
+ const Item item = _projects[p_index]; // Take a copy
- _open_selected_projects_ask();
- } break;
- case KEY_DELETE: {
+ _selected_project_keys.erase(item.project_key);
- _erase_project();
- } break;
- case KEY_HOME: {
+ if (_last_clicked == item.project_key) {
+ _last_clicked = "";
+ }
- for (int i = 0; i < scroll_children->get_child_count(); i++) {
+ memdelete(item.control);
+ _projects.remove(p_index);
- HBoxContainer *hb = Object::cast_to<HBoxContainer>(scroll_children->get_child(i));
- if (hb) {
- selected_list.clear();
- selected_list.insert(hb->get_meta("name"), hb->get_meta("main_scene"));
- scroll->set_v_scroll(0);
- _update_project_buttons();
- break;
- }
- }
+ if (p_update_settings) {
+ EditorSettings::get_singleton()->erase("projects/" + item.project_key);
+ EditorSettings::get_singleton()->erase("favorite_projects/" + item.project_key);
+ // Not actually saving the file, in case you are doing more changes to settings
+ }
+}
- } break;
- case KEY_END: {
+bool ProjectList::is_any_project_missing() const {
+ for (int i = 0; i < _projects.size(); ++i) {
+ if (_projects[i].missing) {
+ return true;
+ }
+ }
+ return false;
+}
- for (int i = scroll_children->get_child_count() - 1; i >= 0; i--) {
+void ProjectList::erase_missing_projects() {
- HBoxContainer *hb = Object::cast_to<HBoxContainer>(scroll_children->get_child(i));
- if (hb) {
- selected_list.clear();
- selected_list.insert(hb->get_meta("name"), hb->get_meta("main_scene"));
- scroll->set_v_scroll(scroll_children->get_size().y);
- _update_project_buttons();
- break;
- }
- }
+ if (_projects.empty()) {
+ return;
+ }
- } break;
- case KEY_UP: {
+ int deleted_count = 0;
+ int remaining_count = 0;
- if (k->get_shift())
- break;
+ for (int i = 0; i < _projects.size(); ++i) {
+ const Item &item = _projects[i];
- if (selected_list.size()) {
+ if (item.missing) {
+ remove_project(i, true);
+ --i;
+ ++deleted_count;
- bool found = false;
+ } else {
+ ++remaining_count;
+ }
+ }
- for (int i = scroll_children->get_child_count() - 1; i >= 0; i--) {
+ print_line("Removed " + itos(deleted_count) + " projects from the list, remaining " + itos(remaining_count) + " projects");
- HBoxContainer *hb = Object::cast_to<HBoxContainer>(scroll_children->get_child(i));
- if (!hb) continue;
+ EditorSettings::get_singleton()->save();
+}
- String current = hb->get_meta("name");
+int ProjectList::refresh_project(const String &dir_path) {
+ // Reads editor settings and reloads information about a specific project.
+ // If it wasn't loaded and should be in the list, it is added (i.e new project).
+ // If it isn't in the list anymore, it is removed.
+ // If it is in the list but doesn't exist anymore, it is marked as missing.
- if (found) {
- selected_list.clear();
- selected_list.insert(current, hb->get_meta("main_scene"));
+ String project_key = get_project_key_from_path(dir_path);
- int offset_diff = scroll->get_v_scroll() - hb->get_position().y;
+ // Read project manager settings
+ bool is_favourite = false;
+ bool should_be_in_list = false;
+ String property_key = "projects/" + project_key;
+ {
+ List<PropertyInfo> properties;
+ EditorSettings::get_singleton()->get_property_list(&properties);
+ String favorite_property_key = "favorite_projects/" + project_key;
+
+ bool found = false;
+ for (List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) {
+ String prop = E->get().name;
+ if (!found && prop == property_key) {
+ found = true;
+ } else if (!is_favourite && prop == favorite_property_key) {
+ is_favourite = true;
+ }
+ }
- if (offset_diff > 0)
- scroll->set_v_scroll(scroll->get_v_scroll() - offset_diff);
+ should_be_in_list = found;
+ }
- _update_project_buttons();
+ bool was_selected = _selected_project_keys.has(project_key);
- break;
+ // Remove item in any case
+ for (int i = 0; i < _projects.size(); ++i) {
+ const Item &existing_item = _projects[i];
+ if (existing_item.path == dir_path) {
+ remove_project(i, false);
+ break;
+ }
+ }
- } else if (current == selected_list.back()->key()) {
+ int index = -1;
+ if (should_be_in_list) {
+ // Recreate it with updated info
- found = true;
- }
- }
+ Item item;
+ load_project_data(property_key, item, is_favourite);
- break;
+ _projects.push_back(item);
+ create_project_item_control(_projects.size() - 1);
+
+ sort_projects();
+
+ for (int i = 0; i < _projects.size(); ++i) {
+ if (_projects[i].project_key == project_key) {
+ if (was_selected) {
+ select_project(i);
+ ensure_project_visible(i);
}
- FALLTHROUGH;
+ load_project_icon(i);
+ index = i;
+ break;
}
- case KEY_DOWN: {
+ }
+ }
- if (k->get_shift())
- break;
+ return index;
+}
+
+int ProjectList::get_project_count() const {
+ return _projects.size();
+}
+
+void ProjectList::select_project(int p_index) {
+
+ Vector<Item> previous_selected_items = get_selected_projects();
+ _selected_project_keys.clear();
- bool found = selected_list.empty();
+ for (int i = 0; i < previous_selected_items.size(); ++i) {
+ previous_selected_items[i].control->update();
+ }
+
+ toggle_select(p_index);
+}
+
+inline void sort(int &a, int &b) {
+ if (a > b) {
+ int temp = a;
+ a = b;
+ b = temp;
+ }
+}
+
+void ProjectList::select_range(int p_begin, int p_end) {
+ sort(p_begin, p_end);
+ select_project(p_begin);
+ for (int i = p_begin + 1; i <= p_end; ++i) {
+ toggle_select(i);
+ }
+}
+
+void ProjectList::toggle_select(int p_index) {
+ Item &item = _projects.write[p_index];
+ if (_selected_project_keys.has(item.project_key)) {
+ _selected_project_keys.erase(item.project_key);
+ } else {
+ _selected_project_keys.insert(item.project_key);
+ }
+ item.control->update();
+}
- for (int i = 0; i < scroll_children->get_child_count(); i++) {
+void ProjectList::erase_selected_projects() {
- HBoxContainer *hb = Object::cast_to<HBoxContainer>(scroll_children->get_child(i));
- if (!hb) continue;
+ if (_selected_project_keys.size() == 0) {
+ return;
+ }
- String current = hb->get_meta("name");
+ for (int i = 0; i < _projects.size(); ++i) {
+ Item &item = _projects.write[i];
+ if (_selected_project_keys.has(item.project_key) && item.control->is_visible()) {
- if (found) {
- selected_list.clear();
- selected_list.insert(current, hb->get_meta("main_scene"));
+ EditorSettings::get_singleton()->erase("projects/" + item.project_key);
+ EditorSettings::get_singleton()->erase("favorite_projects/" + item.project_key);
- int last_y_visible = scroll->get_v_scroll() + scroll->get_size().y;
- int offset_diff = (hb->get_position().y + hb->get_size().y) - last_y_visible;
+ memdelete(item.control);
+ _projects.remove(i);
+ --i;
+ }
+ }
- if (offset_diff > 0)
- scroll->set_v_scroll(scroll->get_v_scroll() + offset_diff);
+ EditorSettings::get_singleton()->save();
- _update_project_buttons();
+ _selected_project_keys.clear();
+ _last_clicked = "";
+}
- break;
+// Draws selected project highlight
+void ProjectList::_panel_draw(Node *p_hb) {
+ Control *hb = Object::cast_to<Control>(p_hb);
- } else if (current == selected_list.back()->key()) {
+ hb->draw_line(Point2(0, hb->get_size().y + 1), Point2(hb->get_size().x - 10, hb->get_size().y + 1), get_color("guide_color", "Tree"));
- found = true;
- }
+ String key = _projects[p_hb->get_index()].project_key;
+
+ if (_selected_project_keys.has(key)) {
+ hb->draw_style_box(get_stylebox("selected", "Tree"), Rect2(Point2(), hb->get_size() - Size2(10, 0) * EDSCALE));
+ }
+}
+
+// Input for each item in the list
+void ProjectList::_panel_input(const Ref<InputEvent> &p_ev, Node *p_hb) {
+
+ Ref<InputEventMouseButton> mb = p_ev;
+ int clicked_index = p_hb->get_index();
+ const Item &clicked_project = _projects[clicked_index];
+
+ if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) {
+
+ if (mb->get_shift() && _selected_project_keys.size() > 0 && _last_clicked != "" && clicked_project.project_key != _last_clicked) {
+
+ int anchor_index = -1;
+ for (int i = 0; i < _projects.size(); ++i) {
+ const Item &p = _projects[i];
+ if (p.project_key == _last_clicked) {
+ anchor_index = p.control->get_index();
+ break;
}
+ }
+ CRASH_COND(anchor_index == -1);
+ select_range(anchor_index, clicked_index);
- } break;
- case KEY_F: {
- if (k->get_command())
- this->project_filter->search_box->grab_focus();
- else
- scancode_handled = false;
- } break;
- default: {
- scancode_handled = false;
- } break;
+ } else if (mb->get_control()) {
+ toggle_select(clicked_index);
+
+ } else {
+ _last_clicked = clicked_project.project_key;
+ select_project(clicked_index);
}
- if (scancode_handled) {
- accept_event();
+ emit_signal(SIGNAL_SELECTION_CHANGED);
+
+ if (mb->is_doubleclick()) {
+ emit_signal(SIGNAL_PROJECT_ASK_OPEN);
}
}
}
-void ProjectManager::_favorite_pressed(Node *p_hb) {
+void ProjectList::_favorite_pressed(Node *p_hb) {
+
+ ProjectListItemControl *control = Object::cast_to<ProjectListItemControl>(p_hb);
+
+ int index = control->get_index();
+ Item item = _projects.write[index]; // Take copy
- String clicked = p_hb->get_meta("name");
- bool favorite = !p_hb->get_meta("favorite");
- String proj = clicked.replace(":::", ":/");
- proj = proj.replace("::", "/");
+ item.favorite = !item.favorite;
- if (favorite) {
- EditorSettings::get_singleton()->set("favorite_projects/" + clicked, proj);
+ if (item.favorite) {
+ EditorSettings::get_singleton()->set("favorite_projects/" + item.project_key, item.path);
} else {
- EditorSettings::get_singleton()->erase("favorite_projects/" + clicked);
+ EditorSettings::get_singleton()->erase("favorite_projects/" + item.project_key);
}
EditorSettings::get_singleton()->save();
- call_deferred("_load_recent_projects");
-}
-void ProjectManager::_load_recent_projects() {
+ _projects.write[index] = item;
+
+ control->set_is_favorite(item.favorite);
- ProjectListFilter::FilterOption filter_option = project_filter->get_filter_option();
- String search_term = project_filter->get_search_term();
+ sort_projects();
- while (scroll_children->get_child_count() > 0) {
- memdelete(scroll_children->get_child(0));
+ if (item.favorite) {
+ for (int i = 0; i < _projects.size(); ++i) {
+ if (_projects[i].project_key == item.project_key) {
+ ensure_project_visible(i);
+ break;
+ }
+ }
}
+}
- Map<String, String> selected_list_copy = selected_list;
+void ProjectList::_show_project(const String &p_path) {
- List<PropertyInfo> properties;
- EditorSettings::get_singleton()->get_property_list(&properties);
+ OS::get_singleton()->shell_open(String("file://") + p_path);
+}
- Color font_color = gui_base->get_color("font_color", "Tree");
+const char *ProjectList::SIGNAL_SELECTION_CHANGED = "selection_changed";
+const char *ProjectList::SIGNAL_PROJECT_ASK_OPEN = "project_ask_open";
- ProjectListFilter::FilterOption filter_order_option = project_order_filter->get_filter_option();
- EditorSettings::get_singleton()->set("project_manager/sorting_order", (int)filter_order_option);
+void ProjectList::_bind_methods() {
- List<ProjectItem> projects;
- List<ProjectItem> favorite_projects;
+ ClassDB::bind_method("_panel_draw", &ProjectList::_panel_draw);
+ ClassDB::bind_method("_panel_input", &ProjectList::_panel_input);
+ ClassDB::bind_method("_favorite_pressed", &ProjectList::_favorite_pressed);
+ ClassDB::bind_method("_show_project", &ProjectList::_show_project);
+ //ClassDB::bind_method("_unhandled_input", &ProjectList::_unhandled_input);
- for (List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) {
+ ADD_SIGNAL(MethodInfo(SIGNAL_SELECTION_CHANGED));
+ ADD_SIGNAL(MethodInfo(SIGNAL_PROJECT_ASK_OPEN));
+}
- String _name = E->get().name;
- if (!_name.begins_with("projects/") && !_name.begins_with("favorite_projects/"))
- continue;
+void ProjectManager::_notification(int p_what) {
- String path = EditorSettings::get_singleton()->get(_name);
- if (filter_option == ProjectListFilter::FILTER_PATH && search_term != "" && path.findn(search_term) == -1)
- continue;
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE: {
- String project = _name.get_slice("/", 1);
- String conf = path.plus_file("project.godot");
- bool favorite = (_name.begins_with("favorite_projects/")) ? true : false;
- bool grayed = false;
+ Engine::get_singleton()->set_editor_hint(false);
+ } break;
+ case NOTIFICATION_READY: {
- Ref<ConfigFile> cf = memnew(ConfigFile);
- Error cf_err = cf->load(conf);
+ if (_project_list->get_project_count() == 0 && StreamPeerSSL::is_available())
+ open_templates->popup_centered_minsize();
+ } break;
+ case NOTIFICATION_VISIBILITY_CHANGED: {
- int config_version = 0;
- String project_name = TTR("Unnamed Project");
- if (cf_err == OK) {
+ set_process_unhandled_input(is_visible_in_tree());
+ } break;
+ case NOTIFICATION_WM_QUIT_REQUEST: {
- String cf_project_name = static_cast<String>(cf->get_value("application", "config/name", ""));
- if (cf_project_name != "")
- project_name = cf_project_name.xml_unescape();
- config_version = (int)cf->get_value("", "config_version", 0);
- }
+ _dim_window();
+ } break;
+ }
+}
- if (config_version > ProjectSettings::CONFIG_VERSION) {
- // Comes from an incompatible (more recent) Godot version, grey it out
- grayed = true;
- }
+void ProjectManager::_dim_window() {
- String icon = cf->get_value("application", "config/icon", "");
- String main_scene = cf->get_value("application", "run/main_scene", "");
+ // This method must be called before calling `get_tree()->quit()`.
+ // Otherwise, its effect won't be visible
- uint64_t last_modified = 0;
- if (FileAccess::exists(conf)) {
- last_modified = FileAccess::get_modified_time(conf);
+ // Dim the project manager window while it's quitting to make it clearer that it's busy.
+ // No transition is applied, as the effect needs to be visible immediately
+ float c = 0.4f;
+ Color dim_color = Color(c, c, c);
+ gui_base->set_modulate(dim_color);
+}
- String fscache = path.plus_file(".fscache");
- if (FileAccess::exists(fscache)) {
- uint64_t cache_modified = FileAccess::get_modified_time(fscache);
- if (cache_modified > last_modified)
- last_modified = cache_modified;
- }
- } else {
- grayed = true;
- }
+void ProjectManager::_update_project_buttons() {
- ProjectItem item(project, project_name, path, conf, icon, main_scene, last_modified, favorite, grayed, filter_order_option);
- if (favorite)
- favorite_projects.push_back(item);
- else
- projects.push_back(item);
- }
- projects.sort();
- favorite_projects.sort();
+ Vector<ProjectList::Item> selected_projects = _project_list->get_selected_projects();
+ bool empty_selection = selected_projects.empty();
- for (List<ProjectItem>::Element *E = projects.front(); E;) {
- List<ProjectItem>::Element *next = E->next();
- if (favorite_projects.find(E->get()) != NULL)
- projects.erase(E->get());
- E = next;
- }
- for (List<ProjectItem>::Element *E = favorite_projects.back(); E; E = E->prev()) {
- projects.push_front(E->get());
- }
+ erase_btn->set_disabled(empty_selection);
+ open_btn->set_disabled(empty_selection);
+ rename_btn->set_disabled(empty_selection);
+ run_btn->set_disabled(empty_selection);
- Ref<Texture> favorite_icon = get_icon("Favorites", "EditorIcons");
+ erase_missing_btn->set_visible(_project_list->is_any_project_missing());
+}
+
+void ProjectManager::_unhandled_input(const Ref<InputEvent> &p_ev) {
- for (List<ProjectItem>::Element *E = projects.front(); E; E = E->next()) {
+ Ref<InputEventKey> k = p_ev;
- ProjectItem &item = E->get();
- String project = item.project;
- String path = item.path;
- String conf = item.conf;
+ if (k.is_valid()) {
- if (filter_option == ProjectListFilter::FILTER_NAME && search_term != "" && item.project_name.findn(search_term) == -1)
- continue;
+ if (!k->is_pressed())
+ return;
+
+ if (tabs->get_current_tab() != 0)
+ return;
+
+ bool scancode_handled = true;
+
+ switch (k->get_scancode()) {
+
+ case KEY_ENTER: {
+
+ _open_selected_projects_ask();
+ } break;
+ case KEY_DELETE: {
+
+ _erase_project();
+ } break;
+ case KEY_HOME: {
+
+ if (_project_list->get_project_count() > 0) {
+ _project_list->select_project(0);
+ _update_project_buttons();
+ }
+
+ } break;
+ case KEY_END: {
+
+ if (_project_list->get_project_count() > 0) {
+ _project_list->select_project(_project_list->get_project_count() - 1);
+ _update_project_buttons();
+ }
+
+ } break;
+ case KEY_UP: {
- Ref<Texture> icon;
+ if (k->get_shift())
+ break;
- if (item.icon != "") {
- Ref<Image> img;
- img.instance();
- Error err = img->load(item.icon.replace_first("res://", path + "/"));
- if (err == OK) {
+ int index = _project_list->get_single_selected_index();
+ if (index - 1 > 0) {
+ _project_list->select_project(index - 1);
+ _project_list->ensure_project_visible(index - 1);
+ _update_project_buttons();
+ }
- Ref<Texture> default_icon = get_icon("DefaultProjectIcon", "EditorIcons");
- img->resize(default_icon->get_width(), default_icon->get_height());
- Ref<ImageTexture> it = memnew(ImageTexture);
- it->create_from_image(img);
- icon = it;
+ break;
}
+ case KEY_DOWN: {
+
+ if (k->get_shift())
+ break;
+
+ int index = _project_list->get_single_selected_index();
+ if (index + 1 < _project_list->get_project_count()) {
+ _project_list->select_project(index + 1);
+ _project_list->ensure_project_visible(index + 1);
+ _update_project_buttons();
+ }
+
+ } break;
+ case KEY_F: {
+ if (k->get_command())
+ this->project_filter->search_box->grab_focus();
+ else
+ scancode_handled = false;
+ } break;
+ default: {
+ scancode_handled = false;
+ } break;
}
- if (icon.is_null()) {
- icon = get_icon("DefaultProjectIcon", "EditorIcons");
+ if (scancode_handled) {
+ accept_event();
}
+ }
+}
- selected_list_copy.erase(project);
-
- bool is_favorite = item.favorite;
- bool is_grayed = item.grayed;
-
- HBoxContainer *hb = memnew(HBoxContainer);
- hb->set_meta("name", project);
- hb->set_meta("main_scene", item.main_scene);
- hb->set_meta("favorite", is_favorite);
- hb->connect("draw", this, "_panel_draw", varray(hb));
- hb->connect("gui_input", this, "_panel_input", varray(hb));
- hb->add_constant_override("separation", 10 * EDSCALE);
-
- VBoxContainer *favorite_box = memnew(VBoxContainer);
- TextureButton *favorite = memnew(TextureButton);
- favorite->set_normal_texture(favorite_icon);
- if (!is_favorite)
- favorite->set_modulate(Color(1, 1, 1, 0.2));
- favorite->connect("pressed", this, "_favorite_pressed", varray(hb));
- favorite_box->add_child(favorite);
- favorite_box->set_alignment(BoxContainer::ALIGN_CENTER);
- hb->add_child(favorite_box);
-
- TextureRect *tf = memnew(TextureRect);
- tf->set_texture(icon);
- hb->add_child(tf);
+void ProjectManager::_load_recent_projects() {
- VBoxContainer *vb = memnew(VBoxContainer);
- if (is_grayed)
- vb->set_modulate(Color(0.5, 0.5, 0.5));
- vb->set_name("project");
- vb->set_h_size_flags(SIZE_EXPAND_FILL);
- hb->add_child(vb);
- Control *ec = memnew(Control);
- ec->set_custom_minimum_size(Size2(0, 1));
- ec->set_mouse_filter(MOUSE_FILTER_PASS);
- vb->add_child(ec);
- Label *title = memnew(Label(item.project_name));
- title->add_font_override("font", gui_base->get_font("title", "EditorFonts"));
- title->add_color_override("font_color", font_color);
- title->set_clip_text(true);
- vb->add_child(title);
-
- HBoxContainer *path_hb = memnew(HBoxContainer);
- path_hb->set_name("path_box");
- path_hb->set_h_size_flags(SIZE_EXPAND_FILL);
- vb->add_child(path_hb);
-
- Button *show = memnew(Button);
- show->set_name("show");
- show->set_icon(get_icon("Filesystem", "EditorIcons"));
- show->set_flat(true);
- show->set_modulate(Color(1, 1, 1, 0.5));
- path_hb->add_child(show);
- show->connect("pressed", this, "_show_project", varray(path));
- show->set_tooltip(TTR("Show in File Manager"));
-
- Label *fpath = memnew(Label(path));
- fpath->set_name("path");
- path_hb->add_child(fpath);
- fpath->set_h_size_flags(SIZE_EXPAND_FILL);
- fpath->set_modulate(Color(1, 1, 1, 0.5));
- fpath->add_color_override("font_color", font_color);
- fpath->set_clip_text(true);
-
- scroll_children->add_child(hb);
- }
-
- for (Map<String, String>::Element *E = selected_list_copy.front(); E; E = E->next()) {
- String key = E->key();
- selected_list.erase(key);
- }
-
- scroll->set_v_scroll(0);
+ _project_list->set_filter_option(project_filter->get_filter_option());
+ _project_list->set_order_option(project_order_filter->get_filter_option());
+ _project_list->set_search_term(project_filter->get_search_term());
+ _project_list->load_projects();
_update_project_buttons();
- EditorSettings::get_singleton()->save();
-
tabs->set_current_tab(0);
}
void ProjectManager::_on_projects_updated() {
- _load_recent_projects();
+ Vector<ProjectList::Item> selected_projects = _project_list->get_selected_projects();
+ int index = 0;
+ for (int i = 0; i < selected_projects.size(); ++i) {
+ index = _project_list->refresh_project(selected_projects[i].path);
+ }
+ if (index != -1) {
+ _project_list->ensure_project_visible(index);
+ }
}
void ProjectManager::_on_project_created(const String &dir) {
project_filter->clear();
- bool has_already = false;
- for (int i = 0; i < scroll_children->get_child_count(); i++) {
- HBoxContainer *hb = Object::cast_to<HBoxContainer>(scroll_children->get_child(i));
- Label *fpath = Object::cast_to<Label>(hb->get_node(NodePath("project/path_box/path")));
- if (fpath->get_text() == dir) {
- has_already = true;
- break;
- }
- }
- if (has_already) {
- _update_scroll_position(dir);
- } else {
- _load_recent_projects();
- _update_scroll_position(dir);
- }
+ int i = _project_list->refresh_project(dir);
+ _project_list->select_project(i);
+ _project_list->ensure_project_visible(i);
_open_selected_projects_ask();
}
-void ProjectManager::_update_scroll_position(const String &dir) {
- for (int i = 0; i < scroll_children->get_child_count(); i++) {
- HBoxContainer *hb = Object::cast_to<HBoxContainer>(scroll_children->get_child(i));
- Label *fpath = Object::cast_to<Label>(hb->get_node(NodePath("project/path_box/path")));
- if (fpath->get_text() == dir) {
- last_clicked = hb->get_meta("name");
- selected_list.clear();
- selected_list.insert(hb->get_meta("name"), hb->get_meta("main_scene"));
- _update_project_buttons();
- int last_y_visible = scroll->get_v_scroll() + scroll->get_size().y;
- int offset_diff = (hb->get_position().y + hb->get_size().y) - last_y_visible;
-
- if (offset_diff > 0)
- scroll->set_v_scroll(scroll->get_v_scroll() + offset_diff);
- break;
- }
- }
-}
-
void ProjectManager::_confirm_update_settings() {
_open_selected_projects();
}
void ProjectManager::_open_selected_projects() {
- for (const Map<String, String>::Element *E = selected_list.front(); E; E = E->next()) {
- const String &selected = E->key();
+ const Set<String> &selected_list = _project_list->get_selected_project_keys();
+
+ for (const Set<String>::Element *E = selected_list.front(); E; E = E->next()) {
+ const String &selected = E->get();
String path = EditorSettings::get_singleton()->get("projects/" + selected);
String conf = path.plus_file("project.godot");
+
if (!FileAccess::exists(conf)) {
dialog_error->set_text(vformat(TTR("Can't open project at '%s'."), path));
dialog_error->popup_centered_minsize();
@@ -1540,6 +1908,8 @@ void ProjectManager::_open_selected_projects() {
void ProjectManager::_open_selected_projects_ask() {
+ const Set<String> &selected_list = _project_list->get_selected_project_keys();
+
if (selected_list.size() < 1) {
return;
}
@@ -1550,22 +1920,11 @@ void ProjectManager::_open_selected_projects_ask() {
return;
}
- // Update the project settings or don't open
- String path = EditorSettings::get_singleton()->get("projects/" + selected_list.front()->key());
- String conf = path.plus_file("project.godot");
+ ProjectList::Item project = _project_list->get_selected_projects()[0];
- // FIXME: We already parse those in _load_recent_projects, we could instead make
- // its `projects` list global and reuse its parsed metadata here.
- Ref<ConfigFile> cf = memnew(ConfigFile);
- Error cf_err = cf->load(conf);
-
- if (cf_err != OK) {
- dialog_error->set_text(vformat(TTR("Can't open project at '%s'."), path));
- dialog_error->popup_centered_minsize();
- return;
- }
-
- int config_version = (int)cf->get_value("", "config_version", 0);
+ // Update the project settings or don't open
+ String conf = project.path.plus_file("project.godot");
+ int config_version = project.version;
// Check if the config_version property was empty or 0
if (config_version == 0) {
@@ -1581,7 +1940,7 @@ void ProjectManager::_open_selected_projects_ask() {
}
// Check if the file was generated by a newer, incompatible engine version
if (config_version > ProjectSettings::CONFIG_VERSION) {
- dialog_error->set_text(vformat(TTR("Can't open project at '%s'.") + "\n" + TTR("The project settings were created by a newer engine version, whose settings are not compatible with this version."), path));
+ dialog_error->set_text(vformat(TTR("Can't open project at '%s'.") + "\n" + TTR("The project settings were created by a newer engine version, whose settings are not compatible with this version."), project.path));
dialog_error->popup_centered_minsize();
return;
}
@@ -1592,16 +1951,18 @@ void ProjectManager::_open_selected_projects_ask() {
void ProjectManager::_run_project_confirm() {
- for (Map<String, String>::Element *E = selected_list.front(); E; E = E->next()) {
+ Vector<ProjectList::Item> selected_list = _project_list->get_selected_projects();
+
+ for (int i = 0; i < selected_list.size(); ++i) {
- const String &selected_main = E->get();
+ const String &selected_main = selected_list[i].main_scene;
if (selected_main == "") {
run_error_diag->set_text(TTR("Can't run project: no main scene defined.\nPlease edit the project and set the main scene in the Project Settings under the \"Application\" category."));
run_error_diag->popup_centered();
return;
}
- const String &selected = E->key();
+ const String &selected = selected_list[i].project_key;
String path = EditorSettings::get_singleton()->get("projects/" + selected);
if (!DirAccess::exists(path + "/.import")) {
@@ -1629,8 +1990,11 @@ void ProjectManager::_run_project_confirm() {
}
}
+// When you press the "Run" button
void ProjectManager::_run_project() {
+ const Set<String> &selected_list = _project_list->get_selected_project_keys();
+
if (selected_list.size() < 1) {
return;
}
@@ -1643,11 +2007,6 @@ void ProjectManager::_run_project() {
}
}
-void ProjectManager::_show_project(const String &p_path) {
-
- OS::get_singleton()->shell_open(String("file://") + p_path);
-}
-
void ProjectManager::_scan_dir(const String &path, List<String> *r_projects) {
DirAccess *da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
da->change_dir(path);
@@ -1673,7 +2032,7 @@ void ProjectManager::_scan_begin(const String &p_base) {
print_line("Found " + itos(projects.size()) + " projects.");
for (List<String>::Element *E = projects.front(); E; E = E->next()) {
- String proj = E->get().replace("/", "::");
+ String proj = get_project_key_from_path(E->get());
EditorSettings::get_singleton()->set("projects/" + proj, E->get());
}
EditorSettings::get_singleton()->save();
@@ -1699,12 +2058,14 @@ void ProjectManager::_import_project() {
void ProjectManager::_rename_project() {
+ const Set<String> &selected_list = _project_list->get_selected_project_keys();
+
if (selected_list.size() == 0) {
return;
}
- for (Map<String, String>::Element *E = selected_list.front(); E; E = E->next()) {
- const String &selected = E->key();
+ for (Set<String>::Element *E = selected_list.front(); E; E = E->next()) {
+ const String &selected = E->get();
String path = EditorSettings::get_singleton()->get("projects/" + selected);
npdialog->set_project_path(path);
npdialog->set_mode(ProjectDialog::MODE_RENAME);
@@ -1713,55 +2074,17 @@ void ProjectManager::_rename_project() {
}
void ProjectManager::_erase_project_confirm() {
-
- if (selected_list.size() == 0) {
- return;
- }
- for (Map<String, String>::Element *E = selected_list.front(); E; E = E->next()) {
- EditorSettings::get_singleton()->erase("projects/" + E->key());
- EditorSettings::get_singleton()->erase("favorite_projects/" + E->key());
- }
- EditorSettings::get_singleton()->save();
- selected_list.clear();
- last_clicked = "";
- _load_recent_projects();
+ _project_list->erase_selected_projects();
}
void ProjectManager::_erase_missing_projects_confirm() {
-
- Map<String, String> list_all_projects;
- for (int i = 0; i < scroll_children->get_child_count(); i++) {
- HBoxContainer *hb = Object::cast_to<HBoxContainer>(scroll_children->get_child(i));
- if (hb) {
- list_all_projects.insert(hb->get_meta("name"), hb->get_meta("main_scene"));
- }
- }
-
- if (list_all_projects.size() == 0) {
- return;
- }
-
- int deleted_projects = 0;
- int remaining_projects = 0;
- for (Map<String, String>::Element *E = list_all_projects.front(); E; E = E->next()) {
- String project_name = E->key().replace(":::", ":/").replace("::", "/") + "/project.godot";
- if (!FileAccess::exists(project_name)) {
- deleted_projects++;
- EditorSettings::get_singleton()->erase("projects/" + E->key());
- EditorSettings::get_singleton()->erase("favorite_projects/" + E->key());
- } else {
- remaining_projects++;
- }
- }
- print_line("Deleted " + itos(deleted_projects) + " projects, remaining " + itos(remaining_projects) + " projects");
- EditorSettings::get_singleton()->save();
- selected_list.clear();
- last_clicked = "";
- _load_recent_projects();
+ _project_list->erase_missing_projects();
}
void ProjectManager::_erase_project() {
+ const Set<String> &selected_list = _project_list->get_selected_project_keys();
+
if (selected_list.size() == 0)
return;
@@ -1867,13 +2190,23 @@ void ProjectManager::_scan_multiple_folders(PoolStringArray p_files) {
}
}
+void ProjectManager::_on_order_option_changed() {
+ _project_list->set_order_option(project_order_filter->get_filter_option());
+ _project_list->sort_projects();
+}
+
+void ProjectManager::_on_filter_option_changed() {
+ _project_list->set_filter_option(project_filter->get_filter_option());
+ _project_list->set_search_term(project_filter->get_search_term());
+ _project_list->sort_projects();
+}
+
void ProjectManager::_bind_methods() {
ClassDB::bind_method("_open_selected_projects_ask", &ProjectManager::_open_selected_projects_ask);
ClassDB::bind_method("_open_selected_projects", &ProjectManager::_open_selected_projects);
ClassDB::bind_method("_run_project", &ProjectManager::_run_project);
ClassDB::bind_method("_run_project_confirm", &ProjectManager::_run_project_confirm);
- ClassDB::bind_method("_show_project", &ProjectManager::_show_project);
ClassDB::bind_method("_scan_projects", &ProjectManager::_scan_projects);
ClassDB::bind_method("_scan_begin", &ProjectManager::_scan_begin);
ClassDB::bind_method("_import_project", &ProjectManager::_import_project);
@@ -1886,18 +2219,16 @@ void ProjectManager::_bind_methods() {
ClassDB::bind_method("_language_selected", &ProjectManager::_language_selected);
ClassDB::bind_method("_restart_confirm", &ProjectManager::_restart_confirm);
ClassDB::bind_method("_exit_dialog", &ProjectManager::_exit_dialog);
- ClassDB::bind_method("_load_recent_projects", &ProjectManager::_load_recent_projects);
+ ClassDB::bind_method("_on_order_option_changed", &ProjectManager::_on_order_option_changed);
+ ClassDB::bind_method("_on_filter_option_changed", &ProjectManager::_on_filter_option_changed);
ClassDB::bind_method("_on_projects_updated", &ProjectManager::_on_projects_updated);
ClassDB::bind_method("_on_project_created", &ProjectManager::_on_project_created);
- ClassDB::bind_method("_update_scroll_position", &ProjectManager::_update_scroll_position);
- ClassDB::bind_method("_panel_draw", &ProjectManager::_panel_draw);
- ClassDB::bind_method("_panel_input", &ProjectManager::_panel_input);
ClassDB::bind_method("_unhandled_input", &ProjectManager::_unhandled_input);
- ClassDB::bind_method("_favorite_pressed", &ProjectManager::_favorite_pressed);
ClassDB::bind_method("_install_project", &ProjectManager::_install_project);
ClassDB::bind_method("_files_dropped", &ProjectManager::_files_dropped);
ClassDB::bind_method("_open_asset_library", &ProjectManager::_open_asset_library);
ClassDB::bind_method("_confirm_update_settings", &ProjectManager::_confirm_update_settings);
+ ClassDB::bind_method("_update_project_buttons", &ProjectManager::_update_project_buttons);
ClassDB::bind_method(D_METHOD("_scan_multiple_folders", "files"), &ProjectManager::_scan_multiple_folders);
}
@@ -1925,29 +2256,12 @@ ProjectManager::ProjectManager() {
editor_set_scale(OS::get_singleton()->get_screen_dpi(screen) >= 192 && OS::get_singleton()->get_screen_size(screen).x > 2000 ? 2.0 : 1.0);
} break;
- case 1: {
- editor_set_scale(0.75);
- } break;
-
- case 2: {
- editor_set_scale(1.0);
- } break;
-
- case 3: {
- editor_set_scale(1.25);
- } break;
-
- case 4: {
- editor_set_scale(1.5);
- } break;
-
- case 5: {
- editor_set_scale(1.75);
- } break;
-
- case 6: {
- editor_set_scale(2.0);
- } break;
+ case 1: editor_set_scale(0.75); break;
+ case 2: editor_set_scale(1.0); break;
+ case 3: editor_set_scale(1.25); break;
+ case 4: editor_set_scale(1.5); break;
+ case 5: editor_set_scale(1.75); break;
+ case 6: editor_set_scale(2.0); break;
default: {
editor_set_scale(custom_display_scale);
@@ -2030,7 +2344,7 @@ ProjectManager::ProjectManager() {
project_order_filter->_setup_filters(sort_filter_titles);
project_order_filter->set_filter_size(150);
sort_filters->add_child(project_order_filter);
- project_order_filter->connect("filter_changed", this, "_load_recent_projects");
+ project_order_filter->connect("filter_changed", this, "_on_order_option_changed");
project_order_filter->set_custom_minimum_size(Size2(180, 10) * EDSCALE);
int projects_sorting_order = (int)EditorSettings::get_singleton()->get("project_manager/sorting_order");
@@ -2049,7 +2363,7 @@ ProjectManager::ProjectManager() {
project_filter->_setup_filters(vec2);
project_filter->add_search_box();
search_filters->add_child(project_filter);
- project_filter->connect("filter_changed", this, "_load_recent_projects");
+ project_filter->connect("filter_changed", this, "_on_filter_option_changed");
project_filter->set_custom_minimum_size(Size2(280, 10) * EDSCALE);
sort_filters->add_child(search_filters);
@@ -2060,15 +2374,14 @@ ProjectManager::ProjectManager() {
search_tree_vb->add_child(pc);
pc->set_v_size_flags(SIZE_EXPAND_FILL);
- scroll = memnew(ScrollContainer);
- pc->add_child(scroll);
- scroll->set_enable_h_scroll(false);
+ _project_list = memnew(ProjectList);
+ _project_list->connect(ProjectList::SIGNAL_SELECTION_CHANGED, this, "_update_project_buttons");
+ _project_list->connect(ProjectList::SIGNAL_PROJECT_ASK_OPEN, this, "_open_selected_projects_ask");
+ pc->add_child(_project_list);
+ _project_list->set_enable_h_scroll(false);
VBoxContainer *tree_vb = memnew(VBoxContainer);
tree_hb->add_child(tree_vb);
- scroll_children = memnew(VBoxContainer);
- scroll_children->set_h_size_flags(SIZE_EXPAND_FILL);
- scroll->add_child(scroll_children);
Button *open = memnew(Button);
open->set_text(TTR("Edit"));
@@ -2238,14 +2551,13 @@ ProjectManager::ProjectManager() {
npdialog->connect("projects_updated", this, "_on_projects_updated");
npdialog->connect("project_created", this, "_on_project_created");
+
_load_recent_projects();
if (EditorSettings::get_singleton()->get("filesystem/directories/autoscan_project_path")) {
_scan_begin(EditorSettings::get_singleton()->get("filesystem/directories/autoscan_project_path"));
}
- last_clicked = "";
-
SceneTree::get_singleton()->connect("files_dropped", this, "_files_dropped");
run_error_diag = memnew(AcceptDialog);
diff --git a/editor/project_manager.h b/editor/project_manager.h
index d75d7164cc..4ccb99d6bd 100644
--- a/editor/project_manager.h
+++ b/editor/project_manager.h
@@ -39,6 +39,7 @@
#include "scene/gui/tree.h"
class ProjectDialog;
+class ProjectList;
class ProjectListFilter;
class ProjectManager : public Control {
@@ -68,16 +69,13 @@ class ProjectManager : public Control {
AcceptDialog *dialog_error;
ProjectDialog *npdialog;
- ScrollContainer *scroll;
- VBoxContainer *scroll_children;
HBoxContainer *projects_hb;
TabContainer *tabs;
+ ProjectList *_project_list;
OptionButton *language_btn;
Control *gui_base;
- Map<String, String> selected_list; // name -> main_scene
- String last_clicked;
bool importing;
void _open_asset_library();
@@ -86,7 +84,6 @@ class ProjectManager : public Control {
void _run_project_confirm();
void _open_selected_projects();
void _open_selected_projects_ask();
- void _show_project(const String &p_path);
void _import_project();
void _new_project();
void _rename_project();
@@ -111,13 +108,13 @@ class ProjectManager : public Control {
void _install_project(const String &p_zip_path, const String &p_title);
void _dim_window();
- void _panel_draw(Node *p_hb);
- void _panel_input(const Ref<InputEvent> &p_ev, Node *p_hb);
void _unhandled_input(const Ref<InputEvent> &p_ev);
- void _favorite_pressed(Node *p_hb);
void _files_dropped(PoolStringArray p_files, int p_screen);
void _scan_multiple_folders(PoolStringArray p_files);
+ void _on_order_option_changed();
+ void _on_filter_option_changed();
+
protected:
void _notification(int p_what);
static void _bind_methods();
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp
index 009ac603e2..aeee829de2 100644
--- a/editor/scene_tree_dock.cpp
+++ b/editor/scene_tree_dock.cpp
@@ -301,6 +301,8 @@ bool SceneTreeDock::_track_inherit(const String &p_target_scene_path, Node *p_de
Ref<PackedScene> data = ResourceLoader::load(path);
if (data.is_valid()) {
p = data->instance(PackedScene::GEN_EDIT_STATE_INSTANCE);
+ if (!p)
+ continue;
instances.push_back(p);
} else
break;
diff --git a/editor/script_editor_debugger.cpp b/editor/script_editor_debugger.cpp
index 0c280b16b2..a749509ce4 100644
--- a/editor/script_editor_debugger.cpp
+++ b/editor/script_editor_debugger.cpp
@@ -1009,7 +1009,10 @@ void ScriptEditorDebugger::_performance_draw() {
Ref<Font> graph_font = get_font("font", "TextEdit");
if (which.empty()) {
- perf_draw->draw_string(graph_font, Point2(0, graph_font->get_ascent()), TTR("Pick one or more items from the list to display the graph."), get_color("font_color", "Label"), perf_draw->get_size().x);
+ String text = TTR("Pick one or more items from the list to display the graph.");
+
+ perf_draw->draw_string(graph_font, Point2i(MAX(0, perf_draw->get_size().x - graph_font->get_string_size(text).x), perf_draw->get_size().y + graph_font->get_ascent()) / 2, text, get_color("font_color", "Label"), perf_draw->get_size().x);
+
return;
}
diff --git a/editor/script_editor_debugger.h b/editor/script_editor_debugger.h
index 505eab266f..947b0cca52 100644
--- a/editor/script_editor_debugger.h
+++ b/editor/script_editor_debugger.h
@@ -173,7 +173,7 @@ class ScriptEditorDebugger : public Control {
void _set_reason_text(const String &p_reason, MessageType p_type);
void _scene_tree_property_select_object(ObjectID p_object);
void _scene_tree_property_value_edited(const String &p_prop, const Variant &p_value);
- int _update_scene_tree(TreeItem *parent, const Array &items, int current_index);
+ int _update_scene_tree(TreeItem *parent, const Array &nodes, int current_index);
void _video_mem_request();
diff --git a/main/input_default.cpp b/main/input_default.cpp
index a03d015fc3..caa5c10518 100644
--- a/main/input_default.cpp
+++ b/main/input_default.cpp
@@ -686,7 +686,8 @@ void InputDefault::release_pressed_events() {
_joy_axis.clear();
for (Map<StringName, InputDefault::Action>::Element *E = action_state.front(); E; E = E->next()) {
- action_release(E->key());
+ if (E->get().pressed)
+ action_release(E->key());
}
}
diff --git a/main/tests/test_string.cpp b/main/tests/test_string.cpp
index 05df888f40..ab5fb64252 100644
--- a/main/tests/test_string.cpp
+++ b/main/tests/test_string.cpp
@@ -1078,6 +1078,44 @@ bool test_34() {
return state;
}
+bool test_35() {
+#define COUNT_TEST(x) \
+ { \
+ bool success = x; \
+ state = state && success; \
+ if (!success) { \
+ OS::get_singleton()->print("\tfailed at: %s\n", #x); \
+ } \
+ }
+
+ OS::get_singleton()->print("\n\nTest 35: count and countn function\n");
+ bool state = true;
+
+ COUNT_TEST(String("").count("Test") == 0);
+ COUNT_TEST(String("Test").count("") == 0);
+ COUNT_TEST(String("Test").count("test") == 0);
+ COUNT_TEST(String("Test").count("TEST") == 0);
+ COUNT_TEST(String("TEST").count("TEST") == 1);
+ COUNT_TEST(String("Test").count("Test") == 1);
+ COUNT_TEST(String("aTest").count("Test") == 1);
+ COUNT_TEST(String("Testa").count("Test") == 1);
+ COUNT_TEST(String("TestTestTest").count("Test") == 3);
+ COUNT_TEST(String("TestTestTest").count("TestTest") == 1);
+ COUNT_TEST(String("TestGodotTestGodotTestGodot").count("Test") == 3);
+
+ COUNT_TEST(String("TestTestTestTest").count("Test", 4, 8) == 1);
+ COUNT_TEST(String("TestTestTestTest").count("Test", 4, 12) == 2);
+ COUNT_TEST(String("TestTestTestTest").count("Test", 4, 16) == 3);
+ COUNT_TEST(String("TestTestTestTest").count("Test", 4) == 3);
+
+ COUNT_TEST(String("Test").countn("test") == 1);
+ COUNT_TEST(String("Test").countn("TEST") == 1);
+ COUNT_TEST(String("testTest-Testatest").countn("tEst") == 4);
+ COUNT_TEST(String("testTest-TeStatest").countn("tEsT", 4, 16) == 2);
+
+ return state;
+}
+
typedef bool (*TestFunc)(void);
TestFunc test_funcs[] = {
@@ -1116,6 +1154,7 @@ TestFunc test_funcs[] = {
test_32,
test_33,
test_34,
+ test_35,
0
};
diff --git a/methods.py b/methods.py
index 7840fb1b64..86ab7cd9af 100644
--- a/methods.py
+++ b/methods.py
@@ -617,7 +617,11 @@ def detect_darwin_sdk_path(platform, env):
raise
def get_compiler_version(env):
- version = decode_utf8(subprocess.check_output([env['CXX'], '--version']).strip())
+ # Not using this method on clang because it returns 4.2.1 # https://reviews.llvm.org/D56803
+ if using_gcc(env):
+ version = decode_utf8(subprocess.check_output([env['CXX'], '-dumpversion']).strip())
+ else:
+ version = decode_utf8(subprocess.check_output([env['CXX'], '--version']).strip())
match = re.search('[0-9][0-9.]*', version)
if match is not None:
return match.group().split('.')
diff --git a/modules/arkit/arkit_interface.mm b/modules/arkit/arkit_interface.mm
index de58f93276..68844c54c2 100644
--- a/modules/arkit/arkit_interface.mm
+++ b/modules/arkit/arkit_interface.mm
@@ -430,7 +430,7 @@ void ARKitInterface::process() {
// get some info about our screen and orientation
Size2 screen_size = OS::get_singleton()->get_window_size();
- UIDeviceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
+ UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
// Grab our camera image for our backbuffer
CVPixelBufferRef pixelBuffer = current_frame.capturedImage;
@@ -531,7 +531,7 @@ void ARKitInterface::process() {
// we need to invert this, probably row v.s. column notation
affine_transform = CGAffineTransformInvert(affine_transform);
- if (orientation != UIDeviceOrientationPortrait) {
+ if (orientation != UIInterfaceOrientationPortrait) {
affine_transform.b = -affine_transform.b;
affine_transform.d = -affine_transform.d;
affine_transform.ty = 1.0 - affine_transform.ty;
@@ -582,28 +582,28 @@ void ARKitInterface::process() {
// copy our current frame transform
matrix_float4x4 m44 = camera.transform;
- if (orientation == UIDeviceOrientationLandscapeLeft) {
+ if (orientation == UIInterfaceOrientationLandscapeLeft) {
transform.basis.elements[0].x = m44.columns[0][0];
transform.basis.elements[1].x = m44.columns[0][1];
transform.basis.elements[2].x = m44.columns[0][2];
transform.basis.elements[0].y = m44.columns[1][0];
transform.basis.elements[1].y = m44.columns[1][1];
transform.basis.elements[2].y = m44.columns[1][2];
- } else if (orientation == UIDeviceOrientationPortrait) {
+ } else if (orientation == UIInterfaceOrientationPortrait) {
transform.basis.elements[0].x = m44.columns[1][0];
transform.basis.elements[1].x = m44.columns[1][1];
transform.basis.elements[2].x = m44.columns[1][2];
transform.basis.elements[0].y = -m44.columns[0][0];
transform.basis.elements[1].y = -m44.columns[0][1];
transform.basis.elements[2].y = -m44.columns[0][2];
- } else if (orientation == UIDeviceOrientationLandscapeRight) {
+ } else if (orientation == UIInterfaceOrientationLandscapeRight) {
transform.basis.elements[0].x = -m44.columns[0][0];
transform.basis.elements[1].x = -m44.columns[0][1];
transform.basis.elements[2].x = -m44.columns[0][2];
transform.basis.elements[0].y = -m44.columns[1][0];
transform.basis.elements[1].y = -m44.columns[1][1];
transform.basis.elements[2].y = -m44.columns[1][2];
- } else if (orientation == UIDeviceOrientationPortraitUpsideDown) {
+ } else if (orientation == UIInterfaceOrientationPortraitUpsideDown) {
// this may not be correct
transform.basis.elements[0].x = m44.columns[1][0];
transform.basis.elements[1].x = m44.columns[1][1];
diff --git a/modules/bullet/rigid_body_bullet.h b/modules/bullet/rigid_body_bullet.h
index 2c9bdb8b0b..f63148092f 100644
--- a/modules/bullet/rigid_body_bullet.h
+++ b/modules/bullet/rigid_body_bullet.h
@@ -305,7 +305,7 @@ public:
void reload_axis_lock();
/// Doc:
- /// http://www.bulletphysics.org/mediawiki-1.5.8/index.php?title=Anti_tunneling_by_Motion_Clamping
+ /// https://web.archive.org/web/20180404091446/http://www.bulletphysics.org/mediawiki-1.5.8/index.php/Anti_tunneling_by_Motion_Clamping
void set_continuous_collision_detection(bool p_enable);
bool is_continuous_collision_detection_enabled() const;
diff --git a/modules/bullet/space_bullet.cpp b/modules/bullet/space_bullet.cpp
index 738b415d16..9d632aaf83 100644
--- a/modules/bullet/space_bullet.cpp
+++ b/modules/bullet/space_bullet.cpp
@@ -581,6 +581,10 @@ void SpaceBullet::create_empty_world(bool p_create_soft_world) {
} else {
world_mem = malloc(sizeof(btDiscreteDynamicsWorld));
}
+ if (!world_mem) {
+ ERR_EXPLAIN("Out of memory");
+ ERR_FAIL();
+ }
if (p_create_soft_world) {
collisionConfiguration = bulletnew(GodotSoftCollisionConfiguration(static_cast<btDiscreteDynamicsWorld *>(world_mem)));
diff --git a/modules/gdnative/gdnative/string.cpp b/modules/gdnative/gdnative/string.cpp
index 913c57eb56..9086121940 100644
--- a/modules/gdnative/gdnative/string.cpp
+++ b/modules/gdnative/gdnative/string.cpp
@@ -186,6 +186,20 @@ godot_bool GDAPI godot_string_ends_with(const godot_string *p_self, const godot_
return self->ends_with(*string);
}
+godot_int GDAPI godot_string_count(const godot_string *p_self, godot_string p_what, godot_int p_from, godot_int p_to) {
+ const String *self = (const String *)p_self;
+ String *what = (String *)&p_what;
+
+ return self->count(*what, p_from, p_to);
+}
+
+godot_int GDAPI godot_string_countn(const godot_string *p_self, godot_string p_what, godot_int p_from, godot_int p_to) {
+ const String *self = (const String *)p_self;
+ String *what = (String *)&p_what;
+
+ return self->countn(*what, p_from, p_to);
+}
+
godot_int GDAPI godot_string_find(const godot_string *p_self, godot_string p_what) {
const String *self = (const String *)p_self;
String *what = (String *)&p_what;
diff --git a/modules/gdnative/gdnative/vector2.cpp b/modules/gdnative/gdnative/vector2.cpp
index a2ac61b35e..d82f2c692d 100644
--- a/modules/gdnative/gdnative/vector2.cpp
+++ b/modules/gdnative/gdnative/vector2.cpp
@@ -77,6 +77,14 @@ godot_bool GDAPI godot_vector2_is_normalized(const godot_vector2 *p_self) {
return self->is_normalized();
}
+godot_vector2 GDAPI godot_vector2_direction_to(const godot_vector2 *p_self, const godot_vector2 *p_to) {
+ godot_vector2 dest;
+ const Vector2 *self = (const Vector2 *)p_self;
+ const Vector2 *to = (const Vector2 *)p_to;
+ *((Vector2 *)&dest) = self->direction_to(*to);
+ return dest;
+}
+
godot_real GDAPI godot_vector2_distance_to(const godot_vector2 *p_self, const godot_vector2 *p_to) {
const Vector2 *self = (const Vector2 *)p_self;
const Vector2 *to = (const Vector2 *)p_to;
diff --git a/modules/gdnative/gdnative/vector3.cpp b/modules/gdnative/gdnative/vector3.cpp
index 894683ab38..15a8ef9a2e 100644
--- a/modules/gdnative/gdnative/vector3.cpp
+++ b/modules/gdnative/gdnative/vector3.cpp
@@ -182,6 +182,14 @@ godot_vector3 GDAPI godot_vector3_ceil(const godot_vector3 *p_self) {
return dest;
}
+godot_vector3 GDAPI godot_vector3_direction_to(const godot_vector3 *p_self, const godot_vector3 *p_to) {
+ godot_vector3 dest;
+ const Vector3 *self = (const Vector3 *)p_self;
+ const Vector3 *to = (const Vector3 *)p_to;
+ *((Vector3 *)&dest) = self->direction_to(*to);
+ return dest;
+}
+
godot_real GDAPI godot_vector3_distance_to(const godot_vector3 *p_self, const godot_vector3 *p_b) {
const Vector3 *self = (const Vector3 *)p_self;
const Vector3 *b = (const Vector3 *)p_b;
diff --git a/modules/gdnative/gdnative_api.json b/modules/gdnative/gdnative_api.json
index 6c12ee6534..8dcea26a7b 100644
--- a/modules/gdnative/gdnative_api.json
+++ b/modules/gdnative/gdnative_api.json
@@ -44,6 +44,42 @@
["const godot_vector2 *", "p_to"],
["const godot_real", "p_delta"]
]
+ },
+ {
+ "name": "godot_string_count",
+ "return_type": "godot_int",
+ "arguments": [
+ ["const godot_string *", "p_self"],
+ ["godot_string", "p_what"],
+ ["godot_int", "p_from"],
+ ["godot_int", "p_to"]
+ ]
+ },
+ {
+ "name": "godot_string_countn",
+ "return_type": "godot_int",
+ "arguments": [
+ ["const godot_string *", "p_self"],
+ ["godot_string", "p_what"],
+ ["godot_int", "p_from"],
+ ["godot_int", "p_to"]
+ ]
+ },
+ {
+ "name": "godot_vector3_direction_to",
+ "return_type": "godot_vector3",
+ "arguments": [
+ ["const godot_vector3 *", "p_self"],
+ ["const godot_vector3 *", "p_to"]
+ ]
+ },
+ {
+ "name": "godot_vector2_direction_to",
+ "return_type": "godot_vector2",
+ "arguments": [
+ ["const godot_vector2 *", "p_self"],
+ ["const godot_vector2 *", "p_to"]
+ ]
}
]
},
diff --git a/modules/gdnative/include/gdnative/string.h b/modules/gdnative/include/gdnative/string.h
index f045ac9d58..7500d70f20 100644
--- a/modules/gdnative/include/gdnative/string.h
+++ b/modules/gdnative/include/gdnative/string.h
@@ -102,6 +102,8 @@ godot_bool GDAPI godot_string_begins_with_char_array(const godot_string *p_self,
godot_array GDAPI godot_string_bigrams(const godot_string *p_self);
godot_string GDAPI godot_string_chr(wchar_t p_character);
godot_bool GDAPI godot_string_ends_with(const godot_string *p_self, const godot_string *p_string);
+godot_int GDAPI godot_string_count(const godot_string *p_self, godot_string p_what, godot_int p_from, godot_int p_to);
+godot_int GDAPI godot_string_countn(const godot_string *p_self, godot_string p_what, godot_int p_from, godot_int p_to);
godot_int GDAPI godot_string_find(const godot_string *p_self, godot_string p_what);
godot_int GDAPI godot_string_find_from(const godot_string *p_self, godot_string p_what, godot_int p_from);
godot_int GDAPI godot_string_findmk(const godot_string *p_self, const godot_array *p_keys);
diff --git a/modules/gdnative/include/gdnative/vector2.h b/modules/gdnative/include/gdnative/vector2.h
index 7a5ae6afa9..15a6c80887 100644
--- a/modules/gdnative/include/gdnative/vector2.h
+++ b/modules/gdnative/include/gdnative/vector2.h
@@ -71,6 +71,8 @@ godot_real GDAPI godot_vector2_length_squared(const godot_vector2 *p_self);
godot_bool GDAPI godot_vector2_is_normalized(const godot_vector2 *p_self);
+godot_vector2 GDAPI godot_vector2_direction_to(const godot_vector2 *p_self, const godot_vector2 *p_b);
+
godot_real GDAPI godot_vector2_distance_to(const godot_vector2 *p_self, const godot_vector2 *p_to);
godot_real GDAPI godot_vector2_distance_squared_to(const godot_vector2 *p_self, const godot_vector2 *p_to);
diff --git a/modules/gdnative/include/gdnative/vector3.h b/modules/gdnative/include/gdnative/vector3.h
index 70ec6422ac..ee7d029028 100644
--- a/modules/gdnative/include/gdnative/vector3.h
+++ b/modules/gdnative/include/gdnative/vector3.h
@@ -106,6 +106,8 @@ godot_vector3 GDAPI godot_vector3_floor(const godot_vector3 *p_self);
godot_vector3 GDAPI godot_vector3_ceil(const godot_vector3 *p_self);
+godot_vector3 GDAPI godot_vector3_direction_to(const godot_vector3 *p_self, const godot_vector3 *p_b);
+
godot_real GDAPI godot_vector3_distance_to(const godot_vector3 *p_self, const godot_vector3 *p_b);
godot_real GDAPI godot_vector3_distance_squared_to(const godot_vector3 *p_self, const godot_vector3 *p_b);
diff --git a/modules/gdnative/include/nativescript/godot_nativescript.h b/modules/gdnative/include/nativescript/godot_nativescript.h
index f3b9f7fb31..7f52f5736c 100644
--- a/modules/gdnative/include/nativescript/godot_nativescript.h
+++ b/modules/gdnative/include/nativescript/godot_nativescript.h
@@ -56,7 +56,7 @@ typedef enum {
GODOT_PROPERTY_HINT_ENUM, ///< hint_text= "val1,val2,val3,etc"
GODOT_PROPERTY_HINT_EXP_EASING, /// exponential easing function (Math::ease)
GODOT_PROPERTY_HINT_LENGTH, ///< hint_text= "length" (as integer)
- GODOT_PROPERTY_HINT_SPRITE_FRAME,
+ GODOT_PROPERTY_HINT_SPRITE_FRAME, // FIXME: Obsolete: drop whenever we can break compat
GODOT_PROPERTY_HINT_KEY_ACCEL, ///< hint_text= "length" (as integer)
GODOT_PROPERTY_HINT_FLAGS, ///< hint_text= "flag1,flag2,etc" (as bit flags)
GODOT_PROPERTY_HINT_LAYERS_2D_RENDER,
@@ -98,8 +98,8 @@ typedef enum {
GODOT_PROPERTY_USAGE_INTERNATIONALIZED = 64, //hint for internationalized strings
GODOT_PROPERTY_USAGE_GROUP = 128, //used for grouping props in the editor
GODOT_PROPERTY_USAGE_CATEGORY = 256,
- GODOT_PROPERTY_USAGE_STORE_IF_NONZERO = 512, //only store if nonzero
- GODOT_PROPERTY_USAGE_STORE_IF_NONONE = 1024, //only store if false
+ GODOT_PROPERTY_USAGE_STORE_IF_NONZERO = 512, // FIXME: Obsolete: drop whenever we can break compat
+ GODOT_PROPERTY_USAGE_STORE_IF_NONONE = 1024, // FIXME: Obsolete: drop whenever we can break compat
GODOT_PROPERTY_USAGE_NO_INSTANCE_STATE = 2048,
GODOT_PROPERTY_USAGE_RESTART_IF_CHANGED = 4096,
GODOT_PROPERTY_USAGE_SCRIPT_VARIABLE = 8192,
diff --git a/modules/gdscript/doc_classes/@GDScript.xml b/modules/gdscript/doc_classes/@GDScript.xml
index 62a3794c6d..f65f2a8935 100644
--- a/modules/gdscript/doc_classes/@GDScript.xml
+++ b/modules/gdscript/doc_classes/@GDScript.xml
@@ -1095,7 +1095,7 @@
<argument index="0" name="step" type="float">
</argument>
<description>
- Returns the position of the first non-zero digit, after the decimal point.
+ Returns the position of the first non-zero digit, after the decimal point. Note that the maximum return value is 10, which is a design decision in the implementation.
[codeblock]
# n is 0
n = step_decimals(5)
diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp
index 078a490b22..846c84d222 100644
--- a/modules/mono/csharp_script.cpp
+++ b/modules/mono/csharp_script.cpp
@@ -629,7 +629,6 @@ void CSharpLanguage::frame() {
if (exc) {
GDMonoUtils::debug_unhandled_exception(exc);
- GD_UNREACHABLE();
}
}
}
diff --git a/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectUtils.cs b/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectUtils.cs
index 1edc426e00..233aab45b3 100644
--- a/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectUtils.cs
+++ b/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectUtils.cs
@@ -85,7 +85,7 @@ namespace GodotTools.ProjectEditor
void AddPropertyIfNotPresent(string name, string condition, string value)
{
if (root.PropertyGroups
- .Any(g => g.Condition == string.Empty || g.Condition == condition &&
+ .Any(g => (g.Condition == string.Empty || g.Condition == condition) &&
g.Properties
.Any(p => p.Name == name &&
p.Value == value &&
diff --git a/modules/mono/editor/GodotTools/GodotTools/Build/BuildSystem.cs b/modules/mono/editor/GodotTools/GodotTools/Build/BuildSystem.cs
index f849356919..d8cb9024c3 100644
--- a/modules/mono/editor/GodotTools/GodotTools/Build/BuildSystem.cs
+++ b/modules/mono/editor/GodotTools/GodotTools/Build/BuildSystem.cs
@@ -137,7 +137,7 @@ namespace GodotTools.Build
private static string BuildArguments(string solution, string config, string loggerOutputDir, List<string> customProperties)
{
- string arguments = $@"""{solution}"" /v:normal /t:Rebuild ""/p:{"Configuration=" + config}"" " +
+ string arguments = $@"""{solution}"" /v:normal /t:Build ""/p:{"Configuration=" + config}"" " +
$@"""/l:{typeof(GodotBuildLogger).FullName},{GodotBuildLogger.AssemblyPath};{loggerOutputDir}""";
foreach (string customProperty in customProperties)
diff --git a/modules/mono/editor/GodotTools/GodotTools/Build/MsBuildFinder.cs b/modules/mono/editor/GodotTools/GodotTools/Build/MsBuildFinder.cs
index f0068385f4..926aabdf89 100644
--- a/modules/mono/editor/GodotTools/GodotTools/Build/MsBuildFinder.cs
+++ b/modules/mono/editor/GodotTools/GodotTools/Build/MsBuildFinder.cs
@@ -15,7 +15,6 @@ namespace GodotTools.Build
{
private static string _msbuildToolsPath = string.Empty;
private static string _msbuildUnixPath = string.Empty;
- private static string _xbuildUnixPath = string.Empty;
public static string FindMsBuild()
{
@@ -44,7 +43,6 @@ namespace GodotTools.Build
return Path.Combine(_msbuildToolsPath, "MSBuild.exe");
}
-
case GodotSharpBuilds.BuildTool.MsBuildMono:
{
string msbuildPath = Path.Combine(Internal.MonoWindowsInstallRoot, "bin", "msbuild.bat");
@@ -56,19 +54,6 @@ namespace GodotTools.Build
return msbuildPath;
}
-
- case GodotSharpBuilds.BuildTool.XBuild:
- {
- string xbuildPath = Path.Combine(Internal.MonoWindowsInstallRoot, "bin", "xbuild.bat");
-
- if (!File.Exists(xbuildPath))
- {
- throw new FileNotFoundException($"Cannot find executable for '{GodotSharpBuilds.PropNameXbuild}'. Tried with path: {xbuildPath}");
- }
-
- return xbuildPath;
- }
-
default:
throw new IndexOutOfRangeException("Invalid build tool in editor settings");
}
@@ -76,20 +61,7 @@ namespace GodotTools.Build
if (OS.IsUnix())
{
- if (buildTool == GodotSharpBuilds.BuildTool.XBuild)
- {
- if (_xbuildUnixPath.Empty() || !File.Exists(_xbuildUnixPath))
- {
- // Try to search it again if it wasn't found last time or if it was removed from its location
- _xbuildUnixPath = FindBuildEngineOnUnix("msbuild");
- }
-
- if (_xbuildUnixPath.Empty())
- {
- throw new FileNotFoundException($"Cannot find binary for '{GodotSharpBuilds.PropNameXbuild}'");
- }
- }
- else
+ if (buildTool == GodotSharpBuilds.BuildTool.MsBuildMono)
{
if (_msbuildUnixPath.Empty() || !File.Exists(_msbuildUnixPath))
{
@@ -101,9 +73,13 @@ namespace GodotTools.Build
{
throw new FileNotFoundException($"Cannot find binary for '{GodotSharpBuilds.PropNameMsbuildMono}'");
}
- }
- return buildTool != GodotSharpBuilds.BuildTool.XBuild ? _msbuildUnixPath : _xbuildUnixPath;
+ return _msbuildUnixPath;
+ }
+ else
+ {
+ throw new IndexOutOfRangeException("Invalid build tool in editor settings");
+ }
}
throw new PlatformNotSupportedException();
diff --git a/modules/mono/editor/GodotTools/GodotTools/GodotSharpBuilds.cs b/modules/mono/editor/GodotTools/GodotTools/GodotSharpBuilds.cs
index a884b0ead0..de3a4d9a6e 100644
--- a/modules/mono/editor/GodotTools/GodotTools/GodotSharpBuilds.cs
+++ b/modules/mono/editor/GodotTools/GodotTools/GodotSharpBuilds.cs
@@ -18,7 +18,6 @@ namespace GodotTools
public const string PropNameMsbuildMono = "MSBuild (Mono)";
public const string PropNameMsbuildVs = "MSBuild (VS Build Tools)";
- public const string PropNameXbuild = "xbuild (Deprecated)";
public const string MsBuildIssuesFileName = "msbuild_issues.csv";
public const string MsBuildLogFileName = "msbuild_log.txt";
@@ -26,8 +25,7 @@ namespace GodotTools
public enum BuildTool
{
MsBuildMono,
- MsBuildVs,
- XBuild // Deprecated
+ MsBuildVs
}
private static void RemoveOldIssuesFile(MonoBuildInfo buildInfo)
@@ -64,7 +62,7 @@ namespace GodotTools
private static string GetIssuesFilePath(MonoBuildInfo buildInfo)
{
- return Path.Combine(Godot.ProjectSettings.LocalizePath(buildInfo.LogsDirPath), MsBuildIssuesFileName);
+ return Path.Combine(buildInfo.LogsDirPath, MsBuildIssuesFileName);
}
private static void PrintVerbose(string text)
@@ -202,6 +200,9 @@ namespace GodotTools
// case the user decided to delete them at some point after they were loaded.
Internal.UpdateApiAssembliesFromPrebuilt();
+ var editorSettings = GodotSharpEditor.Instance.GetEditorInterface().GetEditorSettings();
+ var buildTool = (BuildTool)editorSettings.GetSetting("mono/builds/build_tool");
+
using (var pr = new EditorProgress("mono_project_debug_build", "Building project solution...", 1))
{
pr.Step("Building project solution", 0);
@@ -209,7 +210,7 @@ namespace GodotTools
var buildInfo = new MonoBuildInfo(GodotSharpDirs.ProjectSlnPath, config);
// Add Godot defines
- string constants = OS.IsWindows() ? "GodotDefineConstants=\"" : "GodotDefineConstants=\\\"";
+ string constants = buildTool == BuildTool.MsBuildVs ? "GodotDefineConstants=\"" : "GodotDefineConstants=\\\"";
foreach (var godotDefine in godotDefines)
constants += $"GODOT_{godotDefine.ToUpper().Replace("-", "_").Replace(" ", "_").Replace(";", "_")};";
@@ -217,7 +218,7 @@ namespace GodotTools
if (Internal.GodotIsRealTDouble())
constants += "GODOT_REAL_T_IS_DOUBLE;";
- constants += OS.IsWindows() ? "\"" : "\\\"";
+ constants += buildTool == BuildTool.MsBuildVs ? "\"" : "\\\"";
buildInfo.CustomProperties.Add(constants);
@@ -267,8 +268,8 @@ namespace GodotTools
["name"] = "mono/builds/build_tool",
["hint"] = Godot.PropertyHint.Enum,
["hint_string"] = OS.IsWindows() ?
- $"{PropNameMsbuildMono},{PropNameMsbuildVs},{PropNameXbuild}" :
- $"{PropNameMsbuildMono},{PropNameXbuild}"
+ $"{PropNameMsbuildMono},{PropNameMsbuildVs}" :
+ $"{PropNameMsbuildMono}"
});
EditorDef("mono/builds/print_build_output", false);
diff --git a/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs b/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs
index 90dec43412..9b5afb94a3 100644
--- a/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs
+++ b/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs
@@ -298,7 +298,16 @@ namespace GodotTools
if (line >= 0)
scriptPath += $";{line + 1};{col}";
- GetMonoDevelopInstance(GodotSharpDirs.ProjectSlnPath).Execute(scriptPath);
+ try
+ {
+ GetMonoDevelopInstance(GodotSharpDirs.ProjectSlnPath).Execute(scriptPath);
+ }
+ catch (FileNotFoundException)
+ {
+ string editorName = editor == ExternalEditor.VisualStudioForMac ? "Visual Studio" : "MonoDevelop";
+ GD.PushError($"Cannot find code editor: {editorName}");
+ return Error.FileNotFound;
+ }
break;
}
diff --git a/modules/mono/editor/GodotTools/GodotTools/MonoBuildTab.cs b/modules/mono/editor/GodotTools/GodotTools/MonoBuildTab.cs
index 75fdacc0da..3a74fa2f66 100644
--- a/modules/mono/editor/GodotTools/GodotTools/MonoBuildTab.cs
+++ b/modules/mono/editor/GodotTools/GodotTools/MonoBuildTab.cs
@@ -61,41 +61,48 @@ namespace GodotTools
{
using (var file = new Godot.File())
{
- Error openError = file.Open(csvFile, Godot.File.ModeFlags.Read);
-
- if (openError != Error.Ok)
- return;
-
- while (!file.EofReached())
+ try
{
- string[] csvColumns = file.GetCsvLine();
+ Error openError = file.Open(csvFile, Godot.File.ModeFlags.Read);
- if (csvColumns.Length == 1 && csvColumns[0].Empty())
+ if (openError != Error.Ok)
return;
- if (csvColumns.Length != 7)
+ while (!file.EofReached())
{
- GD.PushError($"Expected 7 columns, got {csvColumns.Length}");
- continue;
+ string[] csvColumns = file.GetCsvLine();
+
+ if (csvColumns.Length == 1 && csvColumns[0].Empty())
+ return;
+
+ if (csvColumns.Length != 7)
+ {
+ GD.PushError($"Expected 7 columns, got {csvColumns.Length}");
+ continue;
+ }
+
+ var issue = new BuildIssue
+ {
+ Warning = csvColumns[0] == "warning",
+ File = csvColumns[1],
+ Line = int.Parse(csvColumns[2]),
+ Column = int.Parse(csvColumns[3]),
+ Code = csvColumns[4],
+ Message = csvColumns[5],
+ ProjectFile = csvColumns[6]
+ };
+
+ if (issue.Warning)
+ WarningCount += 1;
+ else
+ ErrorCount += 1;
+
+ issues.Add(issue);
}
-
- var issue = new BuildIssue
- {
- Warning = csvColumns[0] == "warning",
- File = csvColumns[1],
- Line = int.Parse(csvColumns[2]),
- Column = int.Parse(csvColumns[3]),
- Code = csvColumns[4],
- Message = csvColumns[5],
- ProjectFile = csvColumns[6]
- };
-
- if (issue.Warning)
- WarningCount += 1;
- else
- ErrorCount += 1;
-
- issues.Add(issue);
+ }
+ finally
+ {
+ file.Close(); // Disposing it is not enough. We need to call Close()
}
}
}
diff --git a/modules/mono/editor/GodotTools/GodotTools/MonoDevelopInstance.cs b/modules/mono/editor/GodotTools/GodotTools/MonoDevelopInstance.cs
index 0c8d86e799..61a0a992ce 100644
--- a/modules/mono/editor/GodotTools/GodotTools/MonoDevelopInstance.cs
+++ b/modules/mono/editor/GodotTools/GodotTools/MonoDevelopInstance.cs
@@ -4,6 +4,7 @@ using System.IO;
using System.Collections.Generic;
using System.Diagnostics;
using GodotTools.Internals;
+using GodotTools.Utils;
namespace GodotTools
{
@@ -30,7 +31,7 @@ namespace GodotTools
if (Utils.OS.IsOSX())
{
- string bundleId = CodeEditorBundleIds[editorId];
+ string bundleId = BundleIds[editorId];
if (Internal.IsOsxAppBundleInstalled(bundleId))
{
@@ -47,12 +48,12 @@ namespace GodotTools
}
else
{
- command = CodeEditorPaths[editorId];
+ command = OS.PathWhich(ExecutableNames[editorId]);
}
}
else
{
- command = CodeEditorPaths[editorId];
+ command = OS.PathWhich(ExecutableNames[editorId]);
}
args.Add("--ipc-tcp");
@@ -70,6 +71,9 @@ namespace GodotTools
args.Add("\"" + Path.GetFullPath(filePath.NormalizePath()) + cursor + "\"");
}
+ if (command == null)
+ throw new FileNotFoundException();
+
if (newWindow)
{
process = Process.Start(new ProcessStartInfo
@@ -99,20 +103,20 @@ namespace GodotTools
this.editorId = editorId;
}
- private static readonly IReadOnlyDictionary<EditorId, string> CodeEditorPaths;
- private static readonly IReadOnlyDictionary<EditorId, string> CodeEditorBundleIds;
+ private static readonly IReadOnlyDictionary<EditorId, string> ExecutableNames;
+ private static readonly IReadOnlyDictionary<EditorId, string> BundleIds;
static MonoDevelopInstance()
{
if (Utils.OS.IsOSX())
{
- CodeEditorPaths = new Dictionary<EditorId, string>
+ ExecutableNames = new Dictionary<EditorId, string>
{
// Rely on PATH
{EditorId.MonoDevelop, "monodevelop"},
{EditorId.VisualStudioForMac, "VisualStudio"}
};
- CodeEditorBundleIds = new Dictionary<EditorId, string>
+ BundleIds = new Dictionary<EditorId, string>
{
// TODO EditorId.MonoDevelop
{EditorId.VisualStudioForMac, "com.microsoft.visual-studio"}
@@ -120,7 +124,7 @@ namespace GodotTools
}
else if (Utils.OS.IsWindows())
{
- CodeEditorPaths = new Dictionary<EditorId, string>
+ ExecutableNames = new Dictionary<EditorId, string>
{
// XamarinStudio is no longer a thing, and the latest version is quite old
// MonoDevelop is available from source only on Windows. The recommendation
@@ -131,7 +135,7 @@ namespace GodotTools
}
else if (Utils.OS.IsUnix())
{
- CodeEditorPaths = new Dictionary<EditorId, string>
+ ExecutableNames = new Dictionary<EditorId, string>
{
// Rely on PATH
{EditorId.MonoDevelop, "monodevelop"}
diff --git a/modules/mono/editor/GodotTools/GodotTools/Utils/CollectionExtensions.cs b/modules/mono/editor/GodotTools/GodotTools/Utils/CollectionExtensions.cs
index 3ae6c10bbf..288c65de74 100644
--- a/modules/mono/editor/GodotTools/GodotTools/Utils/CollectionExtensions.cs
+++ b/modules/mono/editor/GodotTools/GodotTools/Utils/CollectionExtensions.cs
@@ -10,8 +10,9 @@ namespace GodotTools.Utils
{
foreach (T elem in enumerable)
{
- if (predicate(elem) != null)
- return elem;
+ T result = predicate(elem);
+ if (result != null)
+ return result;
}
return orElse;
diff --git a/modules/mono/glue/Managed/Files/StringExtensions.cs b/modules/mono/glue/Managed/Files/StringExtensions.cs
index b43034fbb5..6045c83e95 100644
--- a/modules/mono/glue/Managed/Files/StringExtensions.cs
+++ b/modules/mono/glue/Managed/Files/StringExtensions.cs
@@ -98,6 +98,66 @@ namespace Godot
}
// <summary>
+ // Return the amount of substrings in string.
+ // </summary>
+ public static int Count(this string instance, string what, bool caseSensitive = true, int from = 0, int to = 0)
+ {
+ if (what.Length == 0)
+ {
+ return 0;
+ }
+
+ int len = instance.Length;
+ int slen = what.Length;
+
+ if (len < slen)
+ {
+ return 0;
+ }
+
+ string str;
+
+ if (from >= 0 && to >= 0)
+ {
+ if (to == 0)
+ {
+ to = len;
+ }
+ else if (from >= to)
+ {
+ return 0;
+ }
+ if (from == 0 && to == len)
+ {
+ str = instance;
+ }
+ else
+ {
+ str = instance.Substring(from, to - from);
+ }
+ }
+ else
+ {
+ return 0;
+ }
+
+ int c = 0;
+ int idx;
+
+ do
+ {
+ idx = str.IndexOf(what, caseSensitive ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase);
+ if (idx != -1)
+ {
+ str = str.Substring(idx + slen);
+ ++c;
+ }
+ } while (idx != -1);
+
+ return c;
+ }
+
+ // <summary>
// Return a copy of the string with special characters escaped using the C language standard.
// </summary>
public static string CEscape(this string instance)
diff --git a/modules/mono/mono_gd/gd_mono.cpp b/modules/mono/mono_gd/gd_mono.cpp
index 571bf598f3..45f79074be 100644
--- a/modules/mono/mono_gd/gd_mono.cpp
+++ b/modules/mono/mono_gd/gd_mono.cpp
@@ -283,6 +283,18 @@ void GDMono::initialize() {
add_mono_shared_libs_dir_to_path();
+ {
+ PropertyInfo exc_policy_prop = PropertyInfo(Variant::INT, "mono/unhandled_exception_policy", PROPERTY_HINT_ENUM,
+ vformat("Terminate Application:%s,Log Error:%s", (int)POLICY_TERMINATE_APP, (int)POLICY_LOG_ERROR));
+ unhandled_exception_policy = (UnhandledExceptionPolicy)(int)GLOBAL_DEF(exc_policy_prop.name, (int)POLICY_TERMINATE_APP);
+ ProjectSettings::get_singleton()->set_custom_property_info(exc_policy_prop.name, exc_policy_prop);
+
+ if (Engine::get_singleton()->is_editor_hint()) {
+ // Unhandled exceptions should not terminate the editor
+ unhandled_exception_policy = POLICY_LOG_ERROR;
+ }
+ }
+
GDMonoAssembly::initialize();
gdmono_profiler_init();
@@ -645,7 +657,14 @@ bool GDMono::_load_core_api_assembly() {
#ifdef TOOLS_ENABLED
// 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
- String assembly_path = GodotSharpDirs::get_res_assemblies_dir().plus_file(CORE_API_ASSEMBLY_NAME ".dll");
+
+ // 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");
+
+ 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);
#else
@@ -676,7 +695,14 @@ bool GDMono::_load_editor_api_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
- String assembly_path = GodotSharpDirs::get_res_assemblies_dir().plus_file(EDITOR_API_ASSEMBLY_NAME ".dll");
+
+ // 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");
+
+ 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);
@@ -728,6 +754,12 @@ void GDMono::_load_api_assemblies() {
// 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.
+ // Shouldn't happen. The project manager loads the prebuilt API assemblies
+ if (Main::is_project_manager()) {
+ ERR_EXPLAIN("Failed to load one of the prebuilt API assemblies");
+ CRASH_NOW();
+ }
+
// 1. Unload the scripts domain
if (_unload_scripts_domain() != OK) {
ERR_EXPLAIN("Mono: Failed to unload scripts domain");
@@ -1063,6 +1095,8 @@ GDMono::GDMono() {
#ifdef TOOLS_ENABLED
api_editor_hash = 0;
#endif
+
+ unhandled_exception_policy = POLICY_TERMINATE_APP;
}
GDMono::~GDMono() {
diff --git a/modules/mono/mono_gd/gd_mono.h b/modules/mono/mono_gd/gd_mono.h
index deebe5fd50..c5bcce4fa1 100644
--- a/modules/mono/mono_gd/gd_mono.h
+++ b/modules/mono/mono_gd/gd_mono.h
@@ -80,6 +80,13 @@ String to_string(Type p_type);
class GDMono {
+public:
+ enum UnhandledExceptionPolicy {
+ POLICY_TERMINATE_APP,
+ POLICY_LOG_ERROR
+ };
+
+private:
bool runtime_initialized;
bool finalizing_scripts_domain;
@@ -102,6 +109,8 @@ class GDMono {
HashMap<uint32_t, HashMap<String, GDMonoAssembly *> > assemblies;
+ UnhandledExceptionPolicy unhandled_exception_policy;
+
void _domain_assemblies_cleanup(uint32_t p_domain_id);
bool _are_api_assemblies_out_of_sync();
@@ -162,7 +171,9 @@ public:
static GDMono *get_singleton() { return singleton; }
- static void unhandled_exception_hook(MonoObject *p_exc, void *p_user_data);
+ GD_NORETURN static void unhandled_exception_hook(MonoObject *p_exc, void *p_user_data);
+
+ UnhandledExceptionPolicy get_unhandled_exception_policy() const { return unhandled_exception_policy; }
// Do not use these, unless you know what you're doing
void add_assembly(uint32_t p_domain_id, GDMonoAssembly *p_assembly);
diff --git a/modules/mono/mono_gd/gd_mono_internals.cpp b/modules/mono/mono_gd/gd_mono_internals.cpp
index a84332d4cd..e50e3b0794 100644
--- a/modules/mono/mono_gd/gd_mono_internals.cpp
+++ b/modules/mono/mono_gd/gd_mono_internals.cpp
@@ -108,9 +108,18 @@ void tie_managed_to_unmanaged(MonoObject *managed, Object *unmanaged) {
void unhandled_exception(MonoException *p_exc) {
mono_unhandled_exception((MonoObject *)p_exc); // prints the exception as well
- // Too bad 'mono_invoke_unhandled_exception_hook' is not exposed to embedders
- GDMono::unhandled_exception_hook((MonoObject *)p_exc, NULL);
- GD_UNREACHABLE();
+
+ if (GDMono::get_singleton()->get_unhandled_exception_policy() == GDMono::POLICY_TERMINATE_APP) {
+ // Too bad 'mono_invoke_unhandled_exception_hook' is not exposed to embedders
+ GDMono::unhandled_exception_hook((MonoObject *)p_exc, NULL);
+ GD_UNREACHABLE();
+ } else {
+#ifdef DEBUG_ENABLED
+ GDMonoUtils::debug_send_unhandled_exception_error((MonoException *)p_exc);
+ if (ScriptDebugger::get_singleton())
+ ScriptDebugger::get_singleton()->idle_poll();
+#endif
+ }
}
} // namespace GDMonoInternals
diff --git a/modules/mono/mono_gd/gd_mono_internals.h b/modules/mono/mono_gd/gd_mono_internals.h
index 2d77bde27c..0d82723913 100644
--- a/modules/mono/mono_gd/gd_mono_internals.h
+++ b/modules/mono/mono_gd/gd_mono_internals.h
@@ -45,7 +45,7 @@ void tie_managed_to_unmanaged(MonoObject *managed, Object *unmanaged);
* Do not call this function directly.
* Use GDMonoUtils::debug_unhandled_exception(MonoException *) instead.
*/
-GD_NORETURN void unhandled_exception(MonoException *p_exc);
+void unhandled_exception(MonoException *p_exc);
} // namespace GDMonoInternals
diff --git a/modules/mono/mono_gd/gd_mono_utils.cpp b/modules/mono/mono_gd/gd_mono_utils.cpp
index 5987fa8ebb..7afdfc8ac8 100644
--- a/modules/mono/mono_gd/gd_mono_utils.cpp
+++ b/modules/mono/mono_gd/gd_mono_utils.cpp
@@ -37,6 +37,10 @@
#include "core/project_settings.h"
#include "core/reference.h"
+#ifdef TOOLS_ENABLED
+#include "editor/script_editor_debugger.h"
+#endif
+
#include "../csharp_script.h"
#include "../utils/macros.h"
#include "../utils/mutex_utils.h"
@@ -596,8 +600,14 @@ void debug_print_unhandled_exception(MonoException *p_exc) {
void debug_send_unhandled_exception_error(MonoException *p_exc) {
#ifdef DEBUG_ENABLED
- if (!ScriptDebugger::get_singleton())
+ if (!ScriptDebugger::get_singleton()) {
+#ifdef TOOLS_ENABLED
+ if (Engine::get_singleton()->is_editor_hint()) {
+ ERR_PRINTS(GDMonoUtils::get_exception_name_and_message(p_exc));
+ }
+#endif
return;
+ }
_TLS_RECURSION_GUARD_;
@@ -621,7 +631,7 @@ void debug_send_unhandled_exception_error(MonoException *p_exc) {
if (unexpected_exc) {
GDMonoInternals::unhandled_exception(unexpected_exc);
- GD_UNREACHABLE();
+ return;
}
Vector<ScriptLanguage::StackInfo> _si;
@@ -655,7 +665,6 @@ void debug_send_unhandled_exception_error(MonoException *p_exc) {
void debug_unhandled_exception(MonoException *p_exc) {
GDMonoInternals::unhandled_exception(p_exc); // prints the exception as well
- GD_UNREACHABLE();
}
void print_unhandled_exception(MonoException *p_exc) {
@@ -665,11 +674,9 @@ void print_unhandled_exception(MonoException *p_exc) {
void set_pending_exception(MonoException *p_exc) {
#ifdef NO_PENDING_EXCEPTIONS
debug_unhandled_exception(p_exc);
- GD_UNREACHABLE();
#else
if (get_runtime_invoke_count() == 0) {
debug_unhandled_exception(p_exc);
- GD_UNREACHABLE();
}
if (!mono_runtime_set_pending_exception(p_exc, false)) {
diff --git a/modules/mono/mono_gd/gd_mono_utils.h b/modules/mono/mono_gd/gd_mono_utils.h
index f535fbb6d0..d73743bf0b 100644
--- a/modules/mono/mono_gd/gd_mono_utils.h
+++ b/modules/mono/mono_gd/gd_mono_utils.h
@@ -289,7 +289,7 @@ void set_exception_message(MonoException *p_exc, String message);
void debug_print_unhandled_exception(MonoException *p_exc);
void debug_send_unhandled_exception_error(MonoException *p_exc);
-GD_NORETURN void debug_unhandled_exception(MonoException *p_exc);
+void debug_unhandled_exception(MonoException *p_exc);
void print_unhandled_exception(MonoException *p_exc);
/**
diff --git a/platform/iphone/camera_ios.mm b/platform/iphone/camera_ios.mm
index 029ce6debf..ff84df66ff 100644
--- a/platform/iphone/camera_ios.mm
+++ b/platform/iphone/camera_ios.mm
@@ -158,7 +158,7 @@
} else if (dataCbCr == NULL) {
print_line("Couldn't access CbCr pixel buffer data");
} else {
- UIDeviceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
+ UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
Ref<Image> img[2];
{
diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm
index 726882438b..992aff54f1 100644
--- a/platform/osx/os_osx.mm
+++ b/platform/osx/os_osx.mm
@@ -1599,6 +1599,7 @@ void OS_OSX::finalize() {
memdelete(joypad_osx);
memdelete(input);
+ cursors_cache.clear();
visual_server->finish();
memdelete(visual_server);
//memdelete(rasterizer);
diff --git a/platform/uwp/export/export.cpp b/platform/uwp/export/export.cpp
index abb7b391d3..75ce422e9e 100644
--- a/platform/uwp/export/export.cpp
+++ b/platform/uwp/export/export.cpp
@@ -519,7 +519,9 @@ Error AppxPackager::add_file(String p_file_name, const uint8_t *p_buffer, size_t
int total_out_before = strm.total_out;
- deflate(&strm, Z_FULL_FLUSH);
+ int err = deflate(&strm, Z_FULL_FLUSH);
+ ERR_FAIL_COND_V(err >= 0, ERR_BUG); // Negative means bug
+
bh.compressed_size = strm.total_out - total_out_before;
//package->store_buffer(strm_out.ptr(), strm.total_out - total_out_before);
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp
index 745f3ce379..4c7e35ed88 100644
--- a/platform/windows/os_windows.cpp
+++ b/platform/windows/os_windows.cpp
@@ -1537,6 +1537,7 @@ void OS_Windows::finalize() {
memdelete(camera_server);
touch_state.clear();
+ cursors_cache.clear();
visual_server->finish();
memdelete(visual_server);
#ifdef OPENGL_ENABLED
diff --git a/platform/x11/joypad_linux.cpp b/platform/x11/joypad_linux.cpp
index e6328ee14d..4242952374 100644
--- a/platform/x11/joypad_linux.cpp
+++ b/platform/x11/joypad_linux.cpp
@@ -513,6 +513,8 @@ void JoypadLinux::process_joypads() {
break;
default:
+ if (ev.code >= MAX_ABS)
+ return;
if (joy->abs_map[ev.code] != -1 && joy->abs_info[ev.code]) {
InputDefault::JoyAxis value = axis_correct(joy->abs_info[ev.code], ev.value);
joy->curr_axis[joy->abs_map[ev.code]] = value;
diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp
index 9b35648046..36bf51e7f9 100644
--- a/platform/x11/os_x11.cpp
+++ b/platform/x11/os_x11.cpp
@@ -788,6 +788,7 @@ void OS_X11::finalize() {
memdelete(camera_server);
+ cursors_cache.clear();
visual_server->finish();
memdelete(visual_server);
//memdelete(rasterizer);
diff --git a/platform/x11/power_x11.cpp b/platform/x11/power_x11.cpp
index 758bd84114..c33c77e16b 100644
--- a/platform/x11/power_x11.cpp
+++ b/platform/x11/power_x11.cpp
@@ -268,9 +268,7 @@ bool PowerX11::GetPowerInfo_Linux_proc_acpi() {
check_proc_acpi_battery(node.utf8().get_data(), &have_battery, &charging /*, seconds, percent*/);
node = dirp->get_next();
}
- memdelete(dirp);
}
-
dirp->change_dir(proc_acpi_ac_adapter_path);
err = dirp->list_dir_begin();
if (err != OK) {
@@ -281,7 +279,6 @@ bool PowerX11::GetPowerInfo_Linux_proc_acpi() {
check_proc_acpi_ac_adapter(node.utf8().get_data(), &have_ac);
node = dirp->get_next();
}
- memdelete(dirp);
}
if (!have_battery) {
@@ -294,6 +291,7 @@ bool PowerX11::GetPowerInfo_Linux_proc_acpi() {
this->power_state = OS::POWERSTATE_ON_BATTERY;
}
+ memdelete(dirp);
return true; /* definitive answer. */
}
diff --git a/scene/2d/animated_sprite.cpp b/scene/2d/animated_sprite.cpp
index c7f622dee3..83cc1eeb46 100644
--- a/scene/2d/animated_sprite.cpp
+++ b/scene/2d/animated_sprite.cpp
@@ -29,6 +29,7 @@
/*************************************************************************/
#include "animated_sprite.h"
+
#include "core/os/os.h"
#include "scene/scene_string_names.h"
@@ -356,12 +357,11 @@ void AnimatedSprite::_validate_property(PropertyInfo &property) const {
}
if (property.name == "frame") {
-
- property.hint = PROPERTY_HINT_SPRITE_FRAME;
-
+ property.hint = PROPERTY_HINT_RANGE;
if (frames->has_animation(animation) && frames->get_frame_count(animation) > 1) {
property.hint_string = "0," + itos(frames->get_frame_count(animation) - 1) + ",1";
}
+ property.usage |= PROPERTY_USAGE_KEYING_INCREMENTS;
}
}
@@ -709,7 +709,7 @@ void AnimatedSprite::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "frames", PROPERTY_HINT_RESOURCE_TYPE, "SpriteFrames"), "set_sprite_frames", "get_sprite_frames");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "animation"), "set_animation", "get_animation");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "frame", PROPERTY_HINT_SPRITE_FRAME), "set_frame", "get_frame");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "frame"), "set_frame", "get_frame");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "speed_scale"), "set_speed_scale", "get_speed_scale");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "playing"), "_set_playing", "_is_playing");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "centered"), "set_centered", "is_centered");
diff --git a/scene/2d/sprite.cpp b/scene/2d/sprite.cpp
index 6626fccf1c..dbe47e89ec 100644
--- a/scene/2d/sprite.cpp
+++ b/scene/2d/sprite.cpp
@@ -371,10 +371,9 @@ Rect2 Sprite::get_rect() const {
void Sprite::_validate_property(PropertyInfo &property) const {
if (property.name == "frame") {
-
- property.hint = PROPERTY_HINT_SPRITE_FRAME;
-
+ property.hint = PROPERTY_HINT_RANGE;
property.hint_string = "0," + itos(vframes * hframes - 1) + ",1";
+ property.usage |= PROPERTY_USAGE_KEYING_INCREMENTS;
}
}
@@ -442,7 +441,7 @@ void Sprite::_bind_methods() {
ADD_GROUP("Animation", "");
ADD_PROPERTY(PropertyInfo(Variant::INT, "vframes", PROPERTY_HINT_RANGE, "1,16384,1"), "set_vframes", "get_vframes");
ADD_PROPERTY(PropertyInfo(Variant::INT, "hframes", PROPERTY_HINT_RANGE, "1,16384,1"), "set_hframes", "get_hframes");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "frame", PROPERTY_HINT_SPRITE_FRAME), "set_frame", "get_frame");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "frame"), "set_frame", "get_frame");
ADD_GROUP("Region", "region_");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "region_enabled"), "set_region", "is_region");
diff --git a/scene/3d/collision_object.cpp b/scene/3d/collision_object.cpp
index 9d3e2983c4..63301fc226 100644
--- a/scene/3d/collision_object.cpp
+++ b/scene/3d/collision_object.cpp
@@ -370,7 +370,7 @@ String CollisionObject::get_configuration_warning() const {
String warning = Spatial::get_configuration_warning();
if (shapes.empty()) {
- if (warning == String()) {
+ if (!warning.empty()) {
warning += "\n\n";
}
warning += TTR("This node has no shape, so it can't collide or interact with other objects.\nConsider adding a CollisionShape or CollisionPolygon as a child to define its shape.");
diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp
index 2c315790ac..b39762fde8 100644
--- a/scene/3d/sprite_3d.cpp
+++ b/scene/3d/sprite_3d.cpp
@@ -628,10 +628,9 @@ Rect2 Sprite3D::get_item_rect() const {
void Sprite3D::_validate_property(PropertyInfo &property) const {
if (property.name == "frame") {
-
- property.hint = PROPERTY_HINT_SPRITE_FRAME;
-
+ property.hint = PROPERTY_HINT_RANGE;
property.hint_string = "0," + itos(vframes * hframes - 1) + ",1";
+ property.usage |= PROPERTY_USAGE_KEYING_INCREMENTS;
}
}
@@ -659,7 +658,7 @@ void Sprite3D::_bind_methods() {
ADD_GROUP("Animation", "");
ADD_PROPERTY(PropertyInfo(Variant::INT, "vframes", PROPERTY_HINT_RANGE, "1,16384,1"), "set_vframes", "get_vframes");
ADD_PROPERTY(PropertyInfo(Variant::INT, "hframes", PROPERTY_HINT_RANGE, "1,16384,1"), "set_hframes", "get_hframes");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "frame", PROPERTY_HINT_SPRITE_FRAME), "set_frame", "get_frame");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "frame"), "set_frame", "get_frame");
ADD_GROUP("Region", "region_");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "region_enabled"), "set_region", "is_region");
ADD_PROPERTY(PropertyInfo(Variant::RECT2, "region_rect"), "set_region_rect", "get_region_rect");
@@ -851,14 +850,11 @@ void AnimatedSprite3D::_validate_property(PropertyInfo &property) const {
}
if (property.name == "frame") {
-
property.hint = PROPERTY_HINT_RANGE;
-
- if (frames->has_animation(animation)) {
+ if (frames->has_animation(animation) && frames->get_frame_count(animation) > 1) {
property.hint_string = "0," + itos(frames->get_frame_count(animation) - 1) + ",1";
- } else {
- property.hint_string = "0,0,0";
}
+ property.usage |= PROPERTY_USAGE_KEYING_INCREMENTS;
}
}
@@ -1091,7 +1087,7 @@ void AnimatedSprite3D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "frames", PROPERTY_HINT_RESOURCE_TYPE, "SpriteFrames"), "set_sprite_frames", "get_sprite_frames");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "animation"), "set_animation", "get_animation");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "frame", PROPERTY_HINT_SPRITE_FRAME), "set_frame", "get_frame");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "frame"), "set_frame", "get_frame");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "playing"), "_set_playing", "_is_playing");
}
diff --git a/scene/3d/vehicle_body.cpp b/scene/3d/vehicle_body.cpp
index 89e96e0227..98e68cfbda 100644
--- a/scene/3d/vehicle_body.cpp
+++ b/scene/3d/vehicle_body.cpp
@@ -272,6 +272,20 @@ void VehicleWheel::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_rpm"), &VehicleWheel::get_rpm);
+ ClassDB::bind_method(D_METHOD("set_engine_force", "engine_force"), &VehicleWheel::set_engine_force);
+ ClassDB::bind_method(D_METHOD("get_engine_force"), &VehicleWheel::get_engine_force);
+
+ ClassDB::bind_method(D_METHOD("set_brake", "brake"), &VehicleWheel::set_brake);
+ ClassDB::bind_method(D_METHOD("get_brake"), &VehicleWheel::get_brake);
+
+ ClassDB::bind_method(D_METHOD("set_steering", "steering"), &VehicleWheel::set_steering);
+ ClassDB::bind_method(D_METHOD("get_steering"), &VehicleWheel::get_steering);
+
+ ADD_GROUP("Per-Wheel Motion", "");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "engine_force", PROPERTY_HINT_RANGE, "0.00,1024.0,0.01,or_greater"), "set_engine_force", "get_engine_force");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "brake", PROPERTY_HINT_RANGE, "0.0,1.0,0.01"), "set_brake", "get_brake");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "steering", PROPERTY_HINT_RANGE, "-180,180.0,0.01"), "set_steering", "get_steering");
+ ADD_GROUP("VehicleBody Motion", "");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_as_traction"), "set_use_as_traction", "is_used_as_traction");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_as_steering"), "set_use_as_steering", "is_used_as_steering");
ADD_GROUP("Wheel", "wheel_");
@@ -288,6 +302,34 @@ void VehicleWheel::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::REAL, "damping_relaxation"), "set_damping_relaxation", "get_damping_relaxation");
}
+void VehicleWheel::set_engine_force(float p_engine_force) {
+
+ m_engineForce = p_engine_force;
+}
+
+float VehicleWheel::get_engine_force() const {
+
+ return m_engineForce;
+}
+
+void VehicleWheel::set_brake(float p_brake) {
+
+ m_brake = p_brake;
+}
+float VehicleWheel::get_brake() const {
+
+ return m_brake;
+}
+
+void VehicleWheel::set_steering(float p_steering) {
+
+ m_steering = p_steering;
+}
+float VehicleWheel::get_steering() const {
+
+ return m_steering;
+}
+
void VehicleWheel::set_use_as_traction(bool p_enable) {
engine_traction = p_enable;
@@ -374,10 +416,7 @@ void VehicleBody::_update_wheel(int p_idx, PhysicsDirectBodyState *s) {
Vector3 fwd = up.cross(right);
fwd = fwd.normalized();
- //rotate around steering over de wheelAxleWS
- real_t steering = wheel.steers ? m_steeringValue : 0.0;
-
- Basis steeringMat(up, steering);
+ Basis steeringMat(up, wheel.m_steering);
Basis rotatingMat(right, wheel.m_rotation);
@@ -723,12 +762,11 @@ void VehicleBody::_update_friction(PhysicsDirectBodyState *s) {
real_t rollingFriction = 0.f;
if (wheelInfo.m_raycastInfo.m_isInContact) {
- if (engine_force != 0.f && wheelInfo.engine_traction) {
- rollingFriction = -engine_force * s->get_step();
+ if (wheelInfo.m_engineForce != 0.f) {
+ rollingFriction = -wheelInfo.m_engineForce * s->get_step();
} else {
real_t defaultRollingFrictionImpulse = 0.f;
- float cbrake = MAX(wheelInfo.m_brake, brake);
- real_t maxImpulse = cbrake ? cbrake : defaultRollingFrictionImpulse;
+ real_t maxImpulse = wheelInfo.m_brake ? wheelInfo.m_brake : defaultRollingFrictionImpulse;
btVehicleWheelContactPoint contactPt(s, wheelInfo.m_raycastInfo.m_groundObject, wheelInfo.m_raycastInfo.m_contactPointWS, m_forwardWS[wheel], maxImpulse);
rollingFriction = _calc_rolling_friction(contactPt);
}
@@ -886,6 +924,11 @@ void VehicleBody::_direct_state_changed(Object *p_state) {
void VehicleBody::set_engine_force(float p_engine_force) {
engine_force = p_engine_force;
+ for (int i = 0; i < wheels.size(); i++) {
+ VehicleWheel &wheelInfo = *wheels[i];
+ if (wheelInfo.engine_traction)
+ wheelInfo.m_engineForce = p_engine_force;
+ }
}
float VehicleBody::get_engine_force() const {
@@ -896,6 +939,10 @@ float VehicleBody::get_engine_force() const {
void VehicleBody::set_brake(float p_brake) {
brake = p_brake;
+ for (int i = 0; i < wheels.size(); i++) {
+ VehicleWheel &wheelInfo = *wheels[i];
+ wheelInfo.m_brake = p_brake;
+ }
}
float VehicleBody::get_brake() const {
@@ -905,6 +952,11 @@ float VehicleBody::get_brake() const {
void VehicleBody::set_steering(float p_steering) {
m_steeringValue = p_steering;
+ for (int i = 0; i < wheels.size(); i++) {
+ VehicleWheel &wheelInfo = *wheels[i];
+ if (wheelInfo.steers)
+ wheelInfo.m_steering = p_steering;
+ }
}
float VehicleBody::get_steering() const {
diff --git a/scene/3d/vehicle_body.h b/scene/3d/vehicle_body.h
index 9e3fe72282..914bfd54bd 100644
--- a/scene/3d/vehicle_body.h
+++ b/scene/3d/vehicle_body.h
@@ -70,7 +70,7 @@ class VehicleWheel : public Spatial {
real_t m_deltaRotation;
real_t m_rpm;
real_t m_rollInfluence;
- //real_t m_engineForce;
+ real_t m_engineForce;
real_t m_brake;
real_t m_clippedInvContactDotSuspension;
@@ -137,6 +137,15 @@ public:
float get_rpm() const;
+ void set_engine_force(float p_engine_force);
+ float get_engine_force() const;
+
+ void set_brake(float p_brake);
+ float get_brake() const;
+
+ void set_steering(float p_steering);
+ float get_steering() const;
+
String get_configuration_warning() const;
VehicleWheel();
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index 26be17f6c1..1d6f3dc782 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -850,6 +850,12 @@ Ref<Texture> Control::get_icon(const StringName &p_name, const StringName &p_typ
theme_owner = NULL;
}
+ if (Theme::get_project_default().is_valid()) {
+ if (Theme::get_project_default()->has_icon(p_name, type)) {
+ return Theme::get_project_default()->get_icon(p_name, type);
+ }
+ }
+
return Theme::get_default()->get_icon(p_name, type);
}
@@ -886,6 +892,12 @@ Ref<Shader> Control::get_shader(const StringName &p_name, const StringName &p_ty
theme_owner = NULL;
}
+ if (Theme::get_project_default().is_valid()) {
+ if (Theme::get_project_default()->has_shader(p_name, type)) {
+ return Theme::get_project_default()->get_shader(p_name, type);
+ }
+ }
+
return Theme::get_default()->get_shader(p_name, type);
}
@@ -925,6 +937,9 @@ Ref<StyleBox> Control::get_stylebox(const StringName &p_name, const StringName &
}
while (class_name != StringName()) {
+ if (Theme::get_project_default().is_valid() && Theme::get_project_default()->has_stylebox(p_name, type))
+ return Theme::get_project_default()->get_stylebox(p_name, type);
+
if (Theme::get_default()->has_stylebox(p_name, class_name))
return Theme::get_default()->get_stylebox(p_name, class_name);
@@ -1001,6 +1016,11 @@ Color Control::get_color(const StringName &p_name, const StringName &p_type) con
theme_owner = NULL;
}
+ if (Theme::get_project_default().is_valid()) {
+ if (Theme::get_project_default()->has_color(p_name, type)) {
+ return Theme::get_project_default()->get_color(p_name, type);
+ }
+ }
return Theme::get_default()->get_color(p_name, type);
}
@@ -1036,6 +1056,11 @@ int Control::get_constant(const StringName &p_name, const StringName &p_type) co
theme_owner = NULL;
}
+ if (Theme::get_project_default().is_valid()) {
+ if (Theme::get_project_default()->has_constant(p_name, type)) {
+ return Theme::get_project_default()->get_constant(p_name, type);
+ }
+ }
return Theme::get_default()->get_constant(p_name, type);
}
@@ -1106,6 +1131,11 @@ bool Control::has_icon(const StringName &p_name, const StringName &p_type) const
theme_owner = NULL;
}
+ if (Theme::get_project_default().is_valid()) {
+ if (Theme::get_project_default()->has_color(p_name, type)) {
+ return true;
+ }
+ }
return Theme::get_default()->has_icon(p_name, type);
}
@@ -1140,6 +1170,11 @@ bool Control::has_shader(const StringName &p_name, const StringName &p_type) con
theme_owner = NULL;
}
+ if (Theme::get_project_default().is_valid()) {
+ if (Theme::get_project_default()->has_shader(p_name, type)) {
+ return true;
+ }
+ }
return Theme::get_default()->has_shader(p_name, type);
}
bool Control::has_stylebox(const StringName &p_name, const StringName &p_type) const {
@@ -1173,6 +1208,11 @@ bool Control::has_stylebox(const StringName &p_name, const StringName &p_type) c
theme_owner = NULL;
}
+ if (Theme::get_project_default().is_valid()) {
+ if (Theme::get_project_default()->has_stylebox(p_name, type)) {
+ return true;
+ }
+ }
return Theme::get_default()->has_stylebox(p_name, type);
}
bool Control::has_font(const StringName &p_name, const StringName &p_type) const {
@@ -1206,6 +1246,11 @@ bool Control::has_font(const StringName &p_name, const StringName &p_type) const
theme_owner = NULL;
}
+ if (Theme::get_project_default().is_valid()) {
+ if (Theme::get_project_default()->has_font(p_name, type)) {
+ return true;
+ }
+ }
return Theme::get_default()->has_font(p_name, type);
}
@@ -1240,6 +1285,11 @@ bool Control::has_color(const StringName &p_name, const StringName &p_type) cons
theme_owner = NULL;
}
+ if (Theme::get_project_default().is_valid()) {
+ if (Theme::get_project_default()->has_color(p_name, type)) {
+ return true;
+ }
+ }
return Theme::get_default()->has_color(p_name, type);
}
@@ -1274,6 +1324,11 @@ bool Control::has_constant(const StringName &p_name, const StringName &p_type) c
theme_owner = NULL;
}
+ if (Theme::get_project_default().is_valid()) {
+ if (Theme::get_project_default()->has_constant(p_name, type)) {
+ return true;
+ }
+ }
return Theme::get_default()->has_constant(p_name, type);
}
diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp
index 04fb991f78..f1bdbb5ff5 100644
--- a/scene/gui/file_dialog.cpp
+++ b/scene/gui/file_dialog.cpp
@@ -403,11 +403,10 @@ void FileDialog::update_file_list() {
List<String> files;
List<String> dirs;
- bool is_dir;
bool is_hidden;
String item;
- while ((item = dir_access->get_next(&is_dir)) != "") {
+ while ((item = dir_access->get_next()) != "") {
if (item == "." || item == "..")
continue;
@@ -415,7 +414,7 @@ void FileDialog::update_file_list() {
is_hidden = dir_access->current_is_hidden();
if (show_hidden_files || !is_hidden) {
- if (!is_dir)
+ if (!dir_access->current_is_dir())
files.push_back(item);
else
dirs.push_back(item);
@@ -880,14 +879,14 @@ FileDialog::FileDialog() {
dir->set_h_size_flags(SIZE_EXPAND_FILL);
refresh = memnew(ToolButton);
- refresh->set_tooltip(RTR("Refresh"));
+ refresh->set_tooltip(RTR("Refresh files."));
refresh->connect("pressed", this, "_update_file_list");
hbc->add_child(refresh);
show_hidden = memnew(ToolButton);
show_hidden->set_toggle_mode(true);
show_hidden->set_pressed(is_showing_hidden_files());
- show_hidden->set_tooltip(RTR("Toggle Hidden Files"));
+ show_hidden->set_tooltip(RTR("Toggle the visibility of hidden files."));
show_hidden->connect("toggled", this, "set_show_hidden_files");
hbc->add_child(show_hidden);
diff --git a/scene/gui/spin_box.cpp b/scene/gui/spin_box.cpp
index 279253889c..db277d3705 100644
--- a/scene/gui/spin_box.cpp
+++ b/scene/gui/spin_box.cpp
@@ -40,7 +40,7 @@ Size2 SpinBox::get_minimum_size() const {
void SpinBox::_value_changed(double) {
- String value = String::num(get_value(), Math::step_decimals(get_step()));
+ String value = String::num(get_value(), Math::range_step_decimals(get_step()));
if (prefix != "")
value = prefix + " " + value;
if (suffix != "")
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index 814100afdc..81f2f46a80 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -1315,7 +1315,7 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
Ref<Texture> updown = cache.updown;
- String valtext = String::num(p_item->cells[i].val, Math::step_decimals(p_item->cells[i].step));
+ String valtext = String::num(p_item->cells[i].val, Math::range_step_decimals(p_item->cells[i].step));
//String valtext = rtos( p_item->cells[i].val );
if (p_item->cells[i].suffix != String())
@@ -1926,7 +1926,7 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool
} else {
- editor_text = String::num(p_item->cells[col].val, Math::step_decimals(p_item->cells[col].step));
+ editor_text = String::num(p_item->cells[col].val, Math::range_step_decimals(p_item->cells[col].step));
if (select_mode == SELECT_MULTI && get_tree()->get_event_count() == focus_in_id)
bring_up_editor = false;
}
@@ -2755,7 +2755,7 @@ bool Tree::edit_selected() {
text_editor->set_position(textedpos);
text_editor->set_size(rect.size);
text_editor->clear();
- text_editor->set_text(c.mode == TreeItem::CELL_MODE_STRING ? c.text : String::num(c.val, Math::step_decimals(c.step)));
+ text_editor->set_text(c.mode == TreeItem::CELL_MODE_STRING ? c.text : String::num(c.val, Math::range_step_decimals(c.step)));
text_editor->select_all();
if (c.mode == TreeItem::CELL_MODE_RANGE) {
diff --git a/scene/main/instance_placeholder.cpp b/scene/main/instance_placeholder.cpp
index 71addd6fea..99ecc8bc37 100644
--- a/scene/main/instance_placeholder.cpp
+++ b/scene/main/instance_placeholder.cpp
@@ -92,6 +92,8 @@ Node *InstancePlaceholder::create_instance(bool p_replace, const Ref<PackedScene
if (!ps.is_valid())
return NULL;
Node *scene = ps->instance();
+ if (!scene)
+ return NULL;
scene->set_name(get_name());
int pos = get_position_in_parent();
diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp
index 2badf19f2b..dbf3150ae0 100644
--- a/scene/main/scene_tree.cpp
+++ b/scene/main/scene_tree.cpp
@@ -1507,8 +1507,11 @@ void SceneTree::_live_edit_instance_node_func(const NodePath &p_parent, const St
Node *n2 = n->get_node(p_parent);
Node *no = ps->instance();
- no->set_name(p_name);
+ if (!no) {
+ continue;
+ }
+ no->set_name(p_name);
n2->add_child(no);
}
}
diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp
index 2533d91156..974c9771e0 100644
--- a/scene/register_scene_types.cpp
+++ b/scene/register_scene_types.cpp
@@ -607,6 +607,7 @@ void register_scene_types() {
ClassDB::register_class<PrismMesh>();
ClassDB::register_class<QuadMesh>();
ClassDB::register_class<SphereMesh>();
+ ClassDB::register_class<PointMesh>();
ClassDB::register_virtual_class<Material>();
ClassDB::register_class<SpatialMaterial>();
SceneTree::add_idle_callback(SpatialMaterial::flush_changes);
@@ -751,7 +752,7 @@ void register_scene_types() {
if (theme_path != String()) {
Ref<Theme> theme = ResourceLoader::load(theme_path);
if (theme.is_valid()) {
- Theme::set_default(theme);
+ Theme::set_project_default(theme);
if (font.is_valid()) {
Theme::set_default_font(font);
}
diff --git a/scene/resources/default_theme/make_header.py b/scene/resources/default_theme/make_header.py
index bd5a723b23..cf0ccf1c3a 100755
--- a/scene/resources/default_theme/make_header.py
+++ b/scene/resources/default_theme/make_header.py
@@ -1,9 +1,14 @@
#!/usr/bin/env python
import glob
+import os
enc = "utf-8"
+# Change to the directory where the script is located,
+# so that the script can be run from any location
+os.chdir(os.path.dirname(os.path.realpath(__file__)))
+
# Generate include files
f = open("theme_data.h", "wb")
diff --git a/scene/resources/primitive_meshes.cpp b/scene/resources/primitive_meshes.cpp
index 74a493d3b5..24fdaafbe1 100644
--- a/scene/resources/primitive_meshes.cpp
+++ b/scene/resources/primitive_meshes.cpp
@@ -1572,3 +1572,19 @@ SphereMesh::SphereMesh() {
rings = 32;
is_hemisphere = false;
}
+
+/**
+ PointMesh
+*/
+
+void PointMesh::_create_mesh_array(Array &p_arr) const {
+ PoolVector<Vector3> faces;
+ faces.resize(1);
+ faces.set(0, Vector3(0.0, 0.0, 0.0));
+
+ p_arr[VS::ARRAY_VERTEX] = faces;
+}
+
+PointMesh::PointMesh() {
+ primitive_type = PRIMITIVE_POINTS;
+}
diff --git a/scene/resources/primitive_meshes.h b/scene/resources/primitive_meshes.h
index 312899c028..fad49f9642 100644
--- a/scene/resources/primitive_meshes.h
+++ b/scene/resources/primitive_meshes.h
@@ -322,4 +322,19 @@ public:
SphereMesh();
};
+/**
+ A single point for use in particle systems
+*/
+
+class PointMesh : public PrimitiveMesh {
+
+ GDCLASS(PointMesh, PrimitiveMesh)
+
+protected:
+ virtual void _create_mesh_array(Array &p_arr) const;
+
+public:
+ PointMesh();
+};
+
#endif
diff --git a/scene/resources/theme.cpp b/scene/resources/theme.cpp
index 69258bc834..ae18be1695 100644
--- a/scene/resources/theme.cpp
+++ b/scene/resources/theme.cpp
@@ -32,8 +32,6 @@
#include "core/os/file_access.h"
#include "core/print_string.h"
-Ref<Theme> Theme::default_theme;
-
void Theme::_emit_theme_changed() {
emit_changed();
@@ -186,11 +184,6 @@ void Theme::_get_property_list(List<PropertyInfo> *p_list) const {
}
}
-Ref<Theme> Theme::get_default() {
-
- return default_theme;
-}
-
void Theme::set_default_theme_font(const Ref<Font> &p_default_font) {
if (default_theme_font == p_default_font)
@@ -215,14 +208,31 @@ Ref<Font> Theme::get_default_theme_font() const {
return default_theme_font;
}
+Ref<Theme> Theme::project_default_theme;
+Ref<Theme> Theme::default_theme;
+Ref<Texture> Theme::default_icon;
+Ref<StyleBox> Theme::default_style;
+Ref<Font> Theme::default_font;
+
+Ref<Theme> Theme::get_default() {
+
+ return default_theme;
+}
+
void Theme::set_default(const Ref<Theme> &p_default) {
default_theme = p_default;
}
-Ref<Texture> Theme::default_icon;
-Ref<StyleBox> Theme::default_style;
-Ref<Font> Theme::default_font;
+Ref<Theme> Theme::get_project_default() {
+
+ return project_default_theme;
+}
+
+void Theme::set_project_default(const Ref<Theme> &p_project_default) {
+
+ project_default_theme = p_project_default;
+}
void Theme::set_default_icon(const Ref<Texture> &p_icon) {
diff --git a/scene/resources/theme.h b/scene/resources/theme.h
index fb59073cbe..4c4f9b5aba 100644
--- a/scene/resources/theme.h
+++ b/scene/resources/theme.h
@@ -46,7 +46,6 @@ class Theme : public Resource {
GDCLASS(Theme, Resource);
RES_BASE_EXTENSION("theme");
- static Ref<Theme> default_theme;
void _emit_theme_changed();
HashMap<StringName, HashMap<StringName, Ref<Texture> > > icon_map;
@@ -61,6 +60,8 @@ protected:
bool _get(const StringName &p_name, Variant &r_ret) const;
void _get_property_list(List<PropertyInfo> *p_list) const;
+ static Ref<Theme> project_default_theme;
+ static Ref<Theme> default_theme;
static Ref<Texture> default_icon;
static Ref<StyleBox> default_style;
static Ref<Font> default_font;
@@ -137,6 +138,9 @@ public:
static Ref<Theme> get_default();
static void set_default(const Ref<Theme> &p_default);
+ static Ref<Theme> get_project_default();
+ static void set_project_default(const Ref<Theme> &p_default);
+
static void set_default_icon(const Ref<Texture> &p_icon);
static void set_default_style(const Ref<StyleBox> &p_style);
static void set_default_font(const Ref<Font> &p_font);
diff --git a/scene/resources/visual_shader_nodes.h b/scene/resources/visual_shader_nodes.h
index cafc7a0f00..4585e7fdcc 100644
--- a/scene/resources/visual_shader_nodes.h
+++ b/scene/resources/visual_shader_nodes.h
@@ -1624,13 +1624,13 @@ public:
virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty
- void set_comparsion_type(ComparsionType p_func);
+ void set_comparsion_type(ComparsionType p_type);
ComparsionType get_comparsion_type() const;
void set_function(Function p_func);
Function get_function() const;
- void set_condition(Condition p_mode);
+ void set_condition(Condition p_cond);
Condition get_condition() const;
virtual Vector<StringName> get_editable_properties() const;
diff --git a/servers/audio/effects/audio_effect_pitch_shift.cpp b/servers/audio/effects/audio_effect_pitch_shift.cpp
index c250f2e2bd..ec3182685f 100644
--- a/servers/audio/effects/audio_effect_pitch_shift.cpp
+++ b/servers/audio/effects/audio_effect_pitch_shift.cpp
@@ -70,7 +70,7 @@
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice and this license appear in all source copies.
* THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF
-* ANY KIND. See http://www.dspguru.com/wol.htm for more information.
+* ANY KIND. See https://dspguru.com/wide-open-license/ for more information.
*
*****************************************************************************/
diff --git a/servers/physics/collision_solver_sat.cpp b/servers/physics/collision_solver_sat.cpp
index a13fa65009..d0f8fd8aff 100644
--- a/servers/physics/collision_solver_sat.cpp
+++ b/servers/physics/collision_solver_sat.cpp
@@ -274,8 +274,8 @@ static void _generate_contacts_from_supports(const Vector3 *p_points_A, int p_po
points_B = p_points_B;
}
- int version_A = (pointcount_A > 3 ? 3 : pointcount_A) - 1;
- int version_B = (pointcount_B > 3 ? 3 : pointcount_B) - 1;
+ int version_A = (pointcount_A > 2 ? 2 : pointcount_A) - 1;
+ int version_B = (pointcount_B > 2 ? 2 : pointcount_B) - 1;
GenerateContactsFunc contacts_func = generate_contacts_func_table[version_A][version_B];
ERR_FAIL_COND(!contacts_func);
diff --git a/servers/physics/collision_solver_sw.cpp b/servers/physics/collision_solver_sw.cpp
index 0d10dae8cc..d970dd39fb 100644
--- a/servers/physics/collision_solver_sw.cpp
+++ b/servers/physics/collision_solver_sw.cpp
@@ -233,8 +233,6 @@ bool CollisionSolverSW::solve_static(const ShapeSW *p_shape_A, const Transform &
return collision_solver(p_shape_A, p_transform_A, p_shape_B, p_transform_B, p_result_callback, p_userdata, false, r_sep_axis, p_margin_A, p_margin_B);
}
-
- return false;
}
void CollisionSolverSW::concave_distance_callback(void *p_userdata, ShapeSW *p_convex) {
@@ -371,6 +369,4 @@ bool CollisionSolverSW::solve_distance(const ShapeSW *p_shape_A, const Transform
return gjk_epa_calculate_distance(p_shape_A, p_transform_A, p_shape_B, p_transform_B, r_point_A, r_point_B); //should pass sepaxis..
}
-
- return false;
}
diff --git a/servers/physics/joints/hinge_joint_sw.cpp b/servers/physics/joints/hinge_joint_sw.cpp
index 1d1b30286e..209cddda5e 100644
--- a/servers/physics/joints/hinge_joint_sw.cpp
+++ b/servers/physics/joints/hinge_joint_sw.cpp
@@ -198,7 +198,6 @@ bool HingeJointSW::setup(real_t p_step) {
plane_space(m_rbAFrame.basis.get_axis(2), jointAxis0local, jointAxis1local);
- A->get_transform().basis.xform(m_rbAFrame.basis.get_axis(2));
Vector3 jointAxis0 = A->get_transform().basis.xform(jointAxis0local);
Vector3 jointAxis1 = A->get_transform().basis.xform(jointAxis1local);
Vector3 hingeAxisWorld = A->get_transform().basis.xform(m_rbAFrame.basis.get_axis(2));
diff --git a/servers/physics_2d/body_2d_sw.cpp b/servers/physics_2d/body_2d_sw.cpp
index 60bbcef4b6..5dff655ea1 100644
--- a/servers/physics_2d/body_2d_sw.cpp
+++ b/servers/physics_2d/body_2d_sw.cpp
@@ -185,28 +185,28 @@ real_t Body2DSW::get_param(Physics2DServer::BodyParameter p_param) const {
case Physics2DServer::BODY_PARAM_BOUNCE: {
return bounce;
- } break;
+ }
case Physics2DServer::BODY_PARAM_FRICTION: {
return friction;
- } break;
+ }
case Physics2DServer::BODY_PARAM_MASS: {
return mass;
- } break;
+ }
case Physics2DServer::BODY_PARAM_INERTIA: {
return _inv_inertia == 0 ? 0 : 1.0 / _inv_inertia;
- } break;
+ }
case Physics2DServer::BODY_PARAM_GRAVITY_SCALE: {
return gravity_scale;
- } break;
+ }
case Physics2DServer::BODY_PARAM_LINEAR_DAMP: {
return linear_damp;
- } break;
+ }
case Physics2DServer::BODY_PARAM_ANGULAR_DAMP: {
return angular_damp;
- } break;
+ }
default: {
}
}
@@ -343,19 +343,19 @@ Variant Body2DSW::get_state(Physics2DServer::BodyState p_state) const {
switch (p_state) {
case Physics2DServer::BODY_STATE_TRANSFORM: {
return get_transform();
- } break;
+ }
case Physics2DServer::BODY_STATE_LINEAR_VELOCITY: {
return linear_velocity;
- } break;
+ }
case Physics2DServer::BODY_STATE_ANGULAR_VELOCITY: {
return angular_velocity;
- } break;
+ }
case Physics2DServer::BODY_STATE_SLEEPING: {
return !is_active();
- } break;
+ }
case Physics2DServer::BODY_STATE_CAN_SLEEP: {
return can_sleep;
- } break;
+ }
}
return Variant();
diff --git a/servers/physics_2d/broad_phase_2d_hash_grid.cpp b/servers/physics_2d/broad_phase_2d_hash_grid.cpp
index 1bbb50c974..6dd19c2868 100644
--- a/servers/physics_2d/broad_phase_2d_hash_grid.cpp
+++ b/servers/physics_2d/broad_phase_2d_hash_grid.cpp
@@ -673,7 +673,7 @@ public IEnumerable<Point3D> GetCellsOnRay(Ray ray, int maxDepth)
// "A Fast Voxel Traversal Algorithm for Ray Tracing"
// John Amanatides, Andrew Woo
// http://www.cse.yorku.ca/~amana/research/grid.pdf
- // http://www.devmaster.net/articles/raytracing_series/A%20faster%20voxel%20traversal%20algorithm%20for%20ray%20tracing.pdf
+ // https://web.archive.org/web/20100616193049/http://www.devmaster.net/articles/raytracing_series/A%20faster%20voxel%20traversal%20algorithm%20for%20ray%20tracing.pdf
// NOTES:
// * This code assumes that the ray's position and direction are in 'cell coordinates', which means
diff --git a/servers/physics_2d/collision_solver_2d_sat.cpp b/servers/physics_2d/collision_solver_2d_sat.cpp
index 9d75f71ff0..19e4b8c1d9 100644
--- a/servers/physics_2d/collision_solver_2d_sat.cpp
+++ b/servers/physics_2d/collision_solver_2d_sat.cpp
@@ -172,8 +172,8 @@ static void _generate_contacts_from_supports(const Vector2 *p_points_A, int p_po
points_B = p_points_B;
}
- int version_A = (pointcount_A > 3 ? 3 : pointcount_A) - 1;
- int version_B = (pointcount_B > 3 ? 3 : pointcount_B) - 1;
+ int version_A = (pointcount_A > 2 ? 2 : pointcount_A) - 1;
+ int version_B = (pointcount_B > 2 ? 2 : pointcount_B) - 1;
GenerateContactsFunc contacts_func = generate_contacts_func_table[version_A][version_B];
ERR_FAIL_COND(!contacts_func);
diff --git a/servers/physics_2d/collision_solver_2d_sw.cpp b/servers/physics_2d/collision_solver_2d_sw.cpp
index e49961c048..03c0fd5981 100644
--- a/servers/physics_2d/collision_solver_2d_sw.cpp
+++ b/servers/physics_2d/collision_solver_2d_sw.cpp
@@ -249,6 +249,4 @@ bool CollisionSolver2DSW::solve(const Shape2DSW *p_shape_A, const Transform2D &p
return collision_solver(p_shape_A, p_transform_A, p_motion_A, p_shape_B, p_transform_B, p_motion_B, p_result_callback, p_userdata, false, sep_axis, margin_A, margin_B);
}
-
- return false;
}
diff --git a/servers/visual/shader_language.cpp b/servers/visual/shader_language.cpp
index 14fefbf195..25973aa295 100644
--- a/servers/visual/shader_language.cpp
+++ b/servers/visual/shader_language.cpp
@@ -967,7 +967,7 @@ bool ShaderLanguage::_find_identifier(const BlockNode *p_block, const Map<String
bool ShaderLanguage::_validate_operator(OperatorNode *p_op, DataType *r_ret_type) {
bool valid = false;
- DataType ret_type;
+ DataType ret_type = TYPE_VOID;
switch (p_op->op) {
case OP_EQUAL:
@@ -3059,7 +3059,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
String ident = identifier;
bool ok = true;
- DataType member_type;
+ DataType member_type = TYPE_VOID;
switch (dt) {
case TYPE_BVEC2:
case TYPE_IVEC2:
diff --git a/servers/visual_server.cpp b/servers/visual_server.cpp
index c6468694fd..25e18d0623 100644
--- a/servers/visual_server.cpp
+++ b/servers/visual_server.cpp
@@ -1118,7 +1118,7 @@ void VisualServer::mesh_add_surface_from_arrays(RID p_mesh, PrimitiveType p_prim
}
offsets[i] = elem_size;
continue;
- } break;
+ }
default: {
ERR_FAIL();
}
@@ -1286,7 +1286,7 @@ Array VisualServer::_get_array_from_surface(uint32_t p_format, PoolVector<uint8_
}
offsets[i] = elem_size;
continue;
- } break;
+ }
default: {
ERR_FAIL_V(Array());
}