diff options
53 files changed, 1068 insertions, 361 deletions
diff --git a/.gitignore b/.gitignore index 6acab19251..2697507adb 100644 --- a/.gitignore +++ b/.gitignore @@ -8,13 +8,10 @@ doc/_build/ *.bc # Android specific -platform/android/java/build.gradle platform/android/java/.gradle platform/android/java/.gradletasknamecache platform/android/java/local.properties platform/android/java/project.properties -platform/android/java/build.gradle -platform/android/java/AndroidManifest.xml platform/android/java/libs/* platform/android/java/assets platform/android/java/.idea/* diff --git a/SConstruct b/SConstruct index 8e6795cbcb..6bb129a174 100644 --- a/SConstruct +++ b/SConstruct @@ -66,20 +66,6 @@ if 'TERM' in os.environ: env_base['ENV']['TERM'] = os.environ['TERM'] env_base.AppendENVPath('PATH', os.getenv('PATH')) env_base.AppendENVPath('PKG_CONFIG_PATH', os.getenv('PKG_CONFIG_PATH')) -env_base.android_maven_repos = [] -env_base.android_flat_dirs = [] -env_base.android_dependencies = [] -env_base.android_gradle_plugins = [] -env_base.android_gradle_classpath = [] -env_base.android_java_dirs = [] -env_base.android_res_dirs = [] -env_base.android_asset_dirs = [] -env_base.android_aidl_dirs = [] -env_base.android_jni_dirs = [] -env_base.android_default_config = [] -env_base.android_manifest_chunk = "" -env_base.android_permission_chunk = "" -env_base.android_appattributes_chunk = "" env_base.disabled_modules = [] env_base.use_ptrcall = False env_base.split_drivers = False @@ -87,20 +73,6 @@ env_base.split_modules = False env_base.module_version_string = "" env_base.msvc = False -env_base.__class__.android_add_maven_repository = methods.android_add_maven_repository -env_base.__class__.android_add_flat_dir = methods.android_add_flat_dir -env_base.__class__.android_add_dependency = methods.android_add_dependency -env_base.__class__.android_add_java_dir = methods.android_add_java_dir -env_base.__class__.android_add_res_dir = methods.android_add_res_dir -env_base.__class__.android_add_asset_dir = methods.android_add_asset_dir -env_base.__class__.android_add_aidl_dir = methods.android_add_aidl_dir -env_base.__class__.android_add_jni_dir = methods.android_add_jni_dir -env_base.__class__.android_add_default_config = methods.android_add_default_config -env_base.__class__.android_add_to_manifest = methods.android_add_to_manifest -env_base.__class__.android_add_to_permissions = methods.android_add_to_permissions -env_base.__class__.android_add_to_attributes = methods.android_add_to_attributes -env_base.__class__.android_add_gradle_plugin = methods.android_add_gradle_plugin -env_base.__class__.android_add_gradle_classpath = methods.android_add_gradle_classpath env_base.__class__.disable_module = methods.disable_module env_base.__class__.add_module_version_string = methods.add_module_version_string diff --git a/core/io/file_access_buffered_fa.h b/core/io/file_access_buffered_fa.h index be960fbc25..24b40cbce8 100644 --- a/core/io/file_access_buffered_fa.h +++ b/core/io/file_access_buffered_fa.h @@ -143,6 +143,14 @@ public: return f._get_modified_time(p_file); } + virtual uint32_t _get_unix_permissions(const String &p_file) { + return f._get_unix_permissions(p_file); + } + + virtual Error _set_unix_permissions(const String &p_file, uint32_t p_permissions) { + return f._set_unix_permissions(p_file, p_permissions); + } + FileAccessBufferedFA(){ }; diff --git a/core/io/file_access_compressed.cpp b/core/io/file_access_compressed.cpp index b268d5c710..6c4310a572 100644 --- a/core/io/file_access_compressed.cpp +++ b/core/io/file_access_compressed.cpp @@ -373,6 +373,19 @@ uint64_t FileAccessCompressed::_get_modified_time(const String &p_file) { return 0; } +uint32_t FileAccessCompressed::_get_unix_permissions(const String &p_file) { + if (f) + return f->_get_unix_permissions(p_file); + return 0; +} + +Error FileAccessCompressed::_set_unix_permissions(const String &p_file, uint32_t p_permissions) { + if (f) { + return f->_set_unix_permissions(p_file, p_permissions); + } + return FAILED; +} + FileAccessCompressed::FileAccessCompressed() : cmode(Compression::MODE_ZSTD), writing(false), diff --git a/core/io/file_access_compressed.h b/core/io/file_access_compressed.h index f408b1bc29..773fed6a3a 100644 --- a/core/io/file_access_compressed.h +++ b/core/io/file_access_compressed.h @@ -91,6 +91,8 @@ public: virtual bool file_exists(const String &p_name); ///< return true if a file exists virtual uint64_t _get_modified_time(const String &p_file); + virtual uint32_t _get_unix_permissions(const String &p_file); + virtual Error _set_unix_permissions(const String &p_file, uint32_t p_permissions); FileAccessCompressed(); virtual ~FileAccessCompressed(); diff --git a/core/io/file_access_encrypted.cpp b/core/io/file_access_encrypted.cpp index 6ad68dd74d..3cf6908961 100644 --- a/core/io/file_access_encrypted.cpp +++ b/core/io/file_access_encrypted.cpp @@ -301,6 +301,16 @@ uint64_t FileAccessEncrypted::_get_modified_time(const String &p_file) { return 0; } +uint32_t FileAccessEncrypted::_get_unix_permissions(const String &p_file) { + + return 0; +} + +Error FileAccessEncrypted::_set_unix_permissions(const String &p_file, uint32_t p_permissions) { + + return FAILED; +} + FileAccessEncrypted::FileAccessEncrypted() { file = NULL; diff --git a/core/io/file_access_encrypted.h b/core/io/file_access_encrypted.h index e77d62a9f4..d779a150ac 100644 --- a/core/io/file_access_encrypted.h +++ b/core/io/file_access_encrypted.h @@ -79,6 +79,8 @@ public: virtual bool file_exists(const String &p_name); ///< return true if a file exists virtual uint64_t _get_modified_time(const String &p_file); + virtual uint32_t _get_unix_permissions(const String &p_file); + virtual Error _set_unix_permissions(const String &p_file, uint32_t p_permissions); FileAccessEncrypted(); ~FileAccessEncrypted(); diff --git a/core/io/file_access_memory.h b/core/io/file_access_memory.h index 73952133c1..4db7811aaa 100644 --- a/core/io/file_access_memory.h +++ b/core/io/file_access_memory.h @@ -70,6 +70,8 @@ public: virtual bool file_exists(const String &p_name); ///< return true if a file exists virtual uint64_t _get_modified_time(const String &p_file) { return 0; } + virtual uint32_t _get_unix_permissions(const String &p_file) { return 0; } + virtual Error _set_unix_permissions(const String &p_file, uint32_t p_permissions) { return FAILED; } FileAccessMemory(); }; diff --git a/core/io/file_access_network.cpp b/core/io/file_access_network.cpp index 501a21a50d..722e62c54e 100644 --- a/core/io/file_access_network.cpp +++ b/core/io/file_access_network.cpp @@ -497,6 +497,16 @@ uint64_t FileAccessNetwork::_get_modified_time(const String &p_file) { return exists_modtime; } +uint32_t FileAccessNetwork::_get_unix_permissions(const String &p_file) { + //could be implemented, not sure if worth it + return 0; +} + +Error FileAccessNetwork::_set_unix_permissions(const String &p_file, uint32_t p_permissions) { + + return FAILED; +} + void FileAccessNetwork::configure() { GLOBAL_DEF("network/remote_fs/page_size", 65536); diff --git a/core/io/file_access_network.h b/core/io/file_access_network.h index 5bbf7588c7..073b75a37b 100644 --- a/core/io/file_access_network.h +++ b/core/io/file_access_network.h @@ -159,6 +159,8 @@ public: virtual bool file_exists(const String &p_path); ///< return true if a file exists virtual uint64_t _get_modified_time(const String &p_file); + virtual uint32_t _get_unix_permissions(const String &p_file); + virtual Error _set_unix_permissions(const String &p_file, uint32_t p_permissions); static void configure(); diff --git a/core/io/file_access_pack.h b/core/io/file_access_pack.h index a90672ce26..a21dd7d22d 100644 --- a/core/io/file_access_pack.h +++ b/core/io/file_access_pack.h @@ -142,6 +142,8 @@ class FileAccessPack : public FileAccess { FileAccess *f; virtual Error _open(const String &p_path, int p_mode_flags); virtual uint64_t _get_modified_time(const String &p_file) { return 0; } + virtual uint32_t _get_unix_permissions(const String &p_file) { return 0; } + virtual Error _set_unix_permissions(const String &p_file, uint32_t p_permissions) { return FAILED; } public: virtual void close(); diff --git a/core/io/file_access_zip.h b/core/io/file_access_zip.h index fc8f85c07b..217176c0af 100644 --- a/core/io/file_access_zip.h +++ b/core/io/file_access_zip.h @@ -112,6 +112,8 @@ public: virtual bool file_exists(const String &p_name); ///< return true if a file exists virtual uint64_t _get_modified_time(const String &p_file) { return 0; } // todo + virtual uint32_t _get_unix_permissions(const String &p_file) { return 0; } + virtual Error _set_unix_permissions(const String &p_file, uint32_t p_permissions) { return FAILED; } FileAccessZip(const String &p_path, const PackedData::PackedFile &p_file); ~FileAccessZip(); diff --git a/core/os/dir_access.cpp b/core/os/dir_access.cpp index 2c1c655175..d81c30f33a 100644 --- a/core/os/dir_access.cpp +++ b/core/os/dir_access.cpp @@ -330,7 +330,7 @@ Error DirAccess::copy(String p_from, String p_to, int p_chmod_flags) { if (err == OK && p_chmod_flags != -1) { fdst->close(); - err = fdst->_chmod(p_to, p_chmod_flags); + err = FileAccess::set_unix_permissions(p_to, p_chmod_flags); // If running on a platform with no chmod support (i.e., Windows), don't fail if (err == ERR_UNAVAILABLE) err = OK; diff --git a/core/os/file_access.cpp b/core/os/file_access.cpp index 4be1364278..079f51bada 100644 --- a/core/os/file_access.cpp +++ b/core/os/file_access.cpp @@ -507,6 +507,29 @@ uint64_t FileAccess::get_modified_time(const String &p_file) { return mt; } +uint32_t FileAccess::get_unix_permissions(const String &p_file) { + + if (PackedData::get_singleton() && !PackedData::get_singleton()->is_disabled() && PackedData::get_singleton()->has_path(p_file)) + return 0; + + FileAccess *fa = create_for_path(p_file); + ERR_FAIL_COND_V(!fa, 0); + + uint32_t mt = fa->_get_unix_permissions(p_file); + memdelete(fa); + return mt; +} + +Error FileAccess::set_unix_permissions(const String &p_file, uint32_t p_permissions) { + + FileAccess *fa = create_for_path(p_file); + ERR_FAIL_COND_V(!fa, ERR_CANT_CREATE); + + Error err = fa->_set_unix_permissions(p_file, p_permissions); + memdelete(fa); + return err; +} + void FileAccess::store_string(const String &p_string) { if (p_string.length() == 0) diff --git a/core/os/file_access.h b/core/os/file_access.h index 9df2a5cade..4930eae35a 100644 --- a/core/os/file_access.h +++ b/core/os/file_access.h @@ -56,6 +56,9 @@ public: bool endian_swap; bool real_is_double; + virtual uint32_t _get_unix_permissions(const String &p_file) = 0; + virtual Error _set_unix_permissions(const String &p_file, uint32_t p_permissions) = 0; + protected: String fix_path(const String &p_path) const; virtual Error _open(const String &p_path, int p_mode_flags) = 0; ///< open a file @@ -148,14 +151,14 @@ public: virtual Error reopen(const String &p_path, int p_mode_flags); ///< does not change the AccessType - virtual Error _chmod(const String &p_path, int p_mod) { return ERR_UNAVAILABLE; } - static FileAccess *create(AccessType p_access); /// Create a file access (for the current platform) this is the only portable way of accessing files. static FileAccess *create_for_path(const String &p_path); static FileAccess *open(const String &p_path, int p_mode_flags, Error *r_error = NULL); /// Create a file access (for the current platform) this is the only portable way of accessing files. static CreateFunc get_create_func(AccessType p_access); static bool exists(const String &p_name); ///< return true if a file exists static uint64_t get_modified_time(const String &p_file); + static uint32_t get_unix_permissions(const String &p_file); + static Error set_unix_permissions(const String &p_file, uint32_t p_permissions); static void set_backup_save(bool p_enable) { backup_save = p_enable; }; static bool is_backup_save_enabled() { return backup_save; }; diff --git a/core/os/os.h b/core/os/os.h index 12012fba80..4ae8a354e5 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -45,6 +45,8 @@ @author Juan Linietsky <reduzio@gmail.com> */ +class Mutex; + class OS { static OS *singleton; @@ -260,7 +262,7 @@ public: virtual int get_low_processor_usage_mode_sleep_usec() const; virtual String get_executable_path() const; - virtual Error execute(const String &p_path, const List<String> &p_arguments, bool p_blocking, ProcessID *r_child_id = NULL, String *r_pipe = NULL, int *r_exitcode = NULL, bool read_stderr = false) = 0; + virtual Error execute(const String &p_path, const List<String> &p_arguments, bool p_blocking, ProcessID *r_child_id = NULL, String *r_pipe = NULL, int *r_exitcode = NULL, bool read_stderr = false, Mutex *p_pipe_mutex = NULL) = 0; virtual Error kill(const ProcessID &p_pid) = 0; virtual int get_process_id() const; diff --git a/doc/classes/Camera.xml b/doc/classes/Camera.xml index d75203b988..014df2b72a 100644 --- a/doc/classes/Camera.xml +++ b/doc/classes/Camera.xml @@ -101,6 +101,20 @@ <description> </description> </method> + <method name="set_frustum"> + <return type="void"> + </return> + <argument index="0" name="size" type="float"> + </argument> + <argument index="1" name="offset" type="Vector2"> + </argument> + <argument index="2" name="z_near" type="float"> + </argument> + <argument index="3" name="z_far" type="float"> + </argument> + <description> + </description> + </method> <method name="set_orthogonal"> <return type="void"> </return> @@ -156,6 +170,8 @@ <member name="fov" type="float" setter="set_fov" getter="get_fov"> The camera's field of view angle (in degrees). Only applicable in perspective mode. Since [member keep_aspect] locks one axis, [code]fov[/code] sets the other axis' field of view angle. </member> + <member name="frustum_offset" type="Vector2" setter="set_frustum_offset" getter="get_frustum_offset"> + </member> <member name="h_offset" type="float" setter="set_h_offset" getter="get_h_offset"> The horizontal (X) offset of the Camera viewport. </member> @@ -182,6 +198,8 @@ <constant name="PROJECTION_ORTHOGONAL" value="1" enum="Projection"> Orthogonal Projection (objects remain the same size on the screen no matter how far away they are). </constant> + <constant name="PROJECTION_FRUSTUM" value="2" enum="Projection"> + </constant> <constant name="KEEP_WIDTH" value="0" enum="KeepAspect"> Preserves the horizontal aspect ratio. </constant> diff --git a/doc/classes/CanvasItem.xml b/doc/classes/CanvasItem.xml index f3e598c17d..82a5679172 100644 --- a/doc/classes/CanvasItem.xml +++ b/doc/classes/CanvasItem.xml @@ -97,6 +97,10 @@ </argument> <argument index="2" name="normal_map" type="Texture" default="null"> </argument> + <argument index="3" name="transform" type="Transform2D" default="Transform2D( 1, 0, 0, 1, 0, 0 )"> + </argument> + <argument index="4" name="modulate" type="Color" default="Color( 1, 1, 1, 1 )"> + </argument> <description> </description> </method> diff --git a/doc/classes/EditorInspectorPlugin.xml b/doc/classes/EditorInspectorPlugin.xml index 49efee49f4..dd60c479c6 100644 --- a/doc/classes/EditorInspectorPlugin.xml +++ b/doc/classes/EditorInspectorPlugin.xml @@ -1,8 +1,16 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="EditorInspectorPlugin" inherits="Reference" category="Core" version="3.2"> <brief_description> + Plugin for adding custom property editors on inspector. </brief_description> <description> + This plugins allows adding custom property editors to [EditorInspector]. + Plugins are registered via [method EditorPlugin.add_inspector_plugin]. + When an object is edited, the [method can_handle] function is called and must return true if the object type is supported. + If supported, the function [method parse_begin] will be called, allowing to place custom controls at the beginning of the class. + Subsequently, the [method parse_category] and [method parse_property] are called for every category and property. They offer the ability to add custom controls to the inspector too. + Finally [method parse_end] will be called. + On each of these calls, the "add" functions can be called. </description> <tutorials> </tutorials> @@ -13,6 +21,7 @@ <argument index="0" name="control" type="Control"> </argument> <description> + Add a custom control, not necesarily a property editor. </description> </method> <method name="add_property_editor"> @@ -23,6 +32,7 @@ <argument index="1" name="editor" type="Control"> </argument> <description> + Add a property editor, this must inherit [EditorProperty]. </description> </method> <method name="add_property_editor_for_multiple_properties"> @@ -35,6 +45,7 @@ <argument index="2" name="editor" type="Control"> </argument> <description> + Add am editor that allows modifying multiple properties, this must inherit [EditorProperty]. </description> </method> <method name="can_handle" qualifiers="virtual"> @@ -43,6 +54,7 @@ <argument index="0" name="object" type="Object"> </argument> <description> + Return true if this object can be handled by this plugin. </description> </method> <method name="parse_begin" qualifiers="virtual"> @@ -51,6 +63,7 @@ <argument index="0" name="object" type="Object"> </argument> <description> + Called to allow adding controls at the beginning of the list. </description> </method> <method name="parse_category" qualifiers="virtual"> @@ -61,12 +74,14 @@ <argument index="1" name="category" type="String"> </argument> <description> + Called to allow adding controls at the beginning of the category. </description> </method> <method name="parse_end" qualifiers="virtual"> <return type="void"> </return> <description> + Called to allow adding controls at the end of the list. </description> </method> <method name="parse_property" qualifiers="virtual"> @@ -85,6 +100,7 @@ <argument index="5" name="usage" type="int"> </argument> <description> + Called to allow adding property specific editors to the inspector. Usually these inherit [EditorProperty] </description> </method> </methods> diff --git a/doc/classes/EditorProperty.xml b/doc/classes/EditorProperty.xml index 2fd7f18461..e187b8156b 100644 --- a/doc/classes/EditorProperty.xml +++ b/doc/classes/EditorProperty.xml @@ -1,12 +1,23 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="EditorProperty" inherits="Container" category="Core" version="3.2"> <brief_description> + Custom control to edit properties for adding into the inspector </brief_description> <description> + This control allows property editing for one or multiple properties into [EditorInspector]. It is added via [EditorInspectorPlugin]. </description> <tutorials> </tutorials> <methods> + <method name="add_focusable"> + <return type="void"> + </return> + <argument index="0" name="control" type="Control"> + </argument> + <description> + If any of the controls added can gain keyboard focus, add it here. This ensures that focus will be restored if the inspector is refreshed. + </description> + </method> <method name="emit_changed"> <return type="void"> </return> @@ -19,45 +30,65 @@ <argument index="3" name="changing" type="bool" default="false"> </argument> <description> + If one (or many properties) changed, this must be called. "Field" is used in case your editor can modify fields separately (as an example, Vector3.x). The "changing" argument avoids the editor requesting this property to be refreshed (leave as false if unsure). </description> </method> <method name="get_edited_object"> <return type="Object"> </return> <description> + Get the edited object. </description> </method> <method name="get_edited_property"> <return type="String"> </return> <description> + Get the edited property. If your editor is for a single property (added via [method EditorInspectorPlugin.parse_property]), then this will return it.. </description> </method> <method name="get_tooltip_text" qualifiers="const"> <return type="String"> </return> <description> + Override if you want to allow a custom tooltip over your property. + </description> + </method> + <method name="set_bottom_editor"> + <return type="void"> + </return> + <argument index="0" name="editor" type="Control"> + </argument> + <description> + Add controls with this function if you want them on the bottom (below the label). </description> </method> <method name="update_property" qualifiers="virtual"> <return type="void"> </return> <description> + When this virtual function is called, you must update your editor. </description> </method> </methods> <members> <member name="checkable" type="bool" setter="set_checkable" getter="is_checkable"> + Used by the inspector, set when property is checkable. </member> <member name="checked" type="bool" setter="set_checked" getter="is_checked"> + Used by the inspector, when the property is checked. </member> <member name="draw_red" type="bool" setter="set_draw_red" getter="is_draw_red"> + Used by the inspector, when the property must draw with error color. </member> <member name="keying" type="bool" setter="set_keying" getter="is_keying"> + Used by the inspector, when the property can add keys for animation/ </member> <member name="label" type="String" setter="set_label" getter="get_label"> + Set this property to change the label (if you want to show one) </member> <member name="read_only" type="bool" setter="set_read_only" getter="is_read_only"> + Used by the inspector, when the property is read-only. </member> </members> <signals> @@ -67,6 +98,7 @@ <argument index="1" name="value" type="Array"> </argument> <description> + Emit yourself if you want multiple properties modified at the same time. Do not use if added via [method EditorInspectorPlugin.parse_property] </description> </signal> <signal name="object_id_selected"> @@ -75,6 +107,7 @@ <argument index="1" name="id" type="int"> </argument> <description> + Used by sub-inspectors. Emit if what was selected was an Object ID. </description> </signal> <signal name="property_changed"> @@ -83,6 +116,7 @@ <argument index="1" name="value" type="Nil"> </argument> <description> + Do not emit this manually, use the [method emit_changed] method instead. </description> </signal> <signal name="property_checked"> @@ -91,12 +125,14 @@ <argument index="1" name="bool" type="String"> </argument> <description> + Used internally, when a property was checked. </description> </signal> <signal name="property_keyed"> <argument index="0" name="property" type="String"> </argument> <description> + Emit if you want to add this value as an animation key (check keying being enabled first). </description> </signal> <signal name="property_keyed_with_value"> @@ -105,6 +141,7 @@ <argument index="1" name="value" type="Nil"> </argument> <description> + Emit if you want to key a property with a single value. </description> </signal> <signal name="resource_selected"> @@ -113,6 +150,7 @@ <argument index="1" name="resource" type="Resource"> </argument> <description> + If you want a sub-resource to be edited, emit this signal with the resource. </description> </signal> <signal name="selected"> @@ -121,6 +159,7 @@ <argument index="1" name="focusable_idx" type="int"> </argument> <description> + Internal, used when selected. </description> </signal> </signals> diff --git a/doc/classes/MeshTexture.xml b/doc/classes/MeshTexture.xml new file mode 100644 index 0000000000..915e5f07cc --- /dev/null +++ b/doc/classes/MeshTexture.xml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="MeshTexture" inherits="Texture" category="Core" version="3.2"> + <brief_description> + Simple texture that uses a mesh to draw itself. + </brief_description> + <description> + Simple texture that uses a mesh to draw itself. It's limited because flags can't be changed and region drawing is not supported. + </description> + <tutorials> + </tutorials> + <methods> + </methods> + <members> + <member name="base_texture" type="Texture" setter="set_base_texture" getter="get_base_texture"> + Set the base texture that the Mesh will use to draw. + </member> + <member name="image_size" type="Vector2" setter="set_image_size" getter="get_image_size"> + Set the size of the image, needed for reference. + </member> + <member name="mesh" type="Mesh" setter="set_mesh" getter="get_mesh"> + Set the mesh used to draw. It must be a mesh using 2D vertices. + </member> + </members> + <constants> + </constants> +</class> diff --git a/doc/classes/MultiMesh.xml b/doc/classes/MultiMesh.xml index 723ba7ea2b..7148871e8c 100644 --- a/doc/classes/MultiMesh.xml +++ b/doc/classes/MultiMesh.xml @@ -116,6 +116,8 @@ <member name="transform_format" type="int" setter="set_transform_format" getter="get_transform_format" enum="MultiMesh.TransformFormat"> Format of transform used to transform mesh, either 2D or 3D. </member> + <member name="visible_instance_count" type="int" setter="set_visible_instance_count" getter="get_visible_instance_count"> + </member> </members> <constants> <constant name="TRANSFORM_2D" value="0" enum="TransformFormat"> diff --git a/doc/classes/Performance.xml b/doc/classes/Performance.xml index 8067095cce..3860511615 100644 --- a/doc/classes/Performance.xml +++ b/doc/classes/Performance.xml @@ -57,8 +57,7 @@ <constant name="OBJECT_NODE_COUNT" value="10" enum="Monitor"> Number of nodes currently instanced in the scene tree. This also includes the root node. </constant> - <constant name="OBJECT_ORPHANS_NODE_COUNT" value="11" enum="Monitor"> - Number of instanced nodes that aren't included in the scene tree. + <constant name="OBJECT_ORPHAN_NODE_COUNT" value="11" enum="Monitor"> </constant> <constant name="RENDER_OBJECTS_IN_FRAME" value="12" enum="Monitor"> 3D objects drawn per frame. diff --git a/doc/classes/PoolByteArray.xml b/doc/classes/PoolByteArray.xml index 012a38a3ea..f46cb243d7 100644 --- a/doc/classes/PoolByteArray.xml +++ b/doc/classes/PoolByteArray.xml @@ -113,6 +113,8 @@ </description> </method> <method name="sha256_string"> + <return type="String"> + </return> <description> Return SHA256 string of the PoolByteArray. </description> diff --git a/doc/classes/Skeleton.xml b/doc/classes/Skeleton.xml index 4377cf52c3..8fab778a48 100644 --- a/doc/classes/Skeleton.xml +++ b/doc/classes/Skeleton.xml @@ -134,6 +134,12 @@ <description> </description> </method> + <method name="localize_rests"> + <return type="void"> + </return> + <description> + </description> + </method> <method name="physical_bones_add_collision_exception"> <return type="void"> </return> diff --git a/doc/classes/TextEdit.xml b/doc/classes/TextEdit.xml index 18dc82d377..1817055bab 100644 --- a/doc/classes/TextEdit.xml +++ b/doc/classes/TextEdit.xml @@ -418,6 +418,14 @@ Emitted when the cursor changes. </description> </signal> + <signal name="info_clicked"> + <argument index="0" name="row" type="int"> + </argument> + <argument index="1" name="info" type="String"> + </argument> + <description> + </description> + </signal> <signal name="request_completion"> <description> </description> diff --git a/doc/classes/VisualInstance.xml b/doc/classes/VisualInstance.xml index 381679f8bb..59f0a531dd 100644 --- a/doc/classes/VisualInstance.xml +++ b/doc/classes/VisualInstance.xml @@ -14,6 +14,18 @@ Returns the [AABB] (also known as the bounding box) for this VisualInstance. </description> </method> + <method name="get_base" qualifiers="const"> + <return type="RID"> + </return> + <description> + </description> + </method> + <method name="get_instance" qualifiers="const"> + <return type="RID"> + </return> + <description> + </description> + </method> <method name="get_layer_mask_bit" qualifiers="const"> <return type="bool"> </return> diff --git a/doc/classes/VisualServer.xml b/doc/classes/VisualServer.xml index 0030795a6b..87bf0b79b6 100644 --- a/doc/classes/VisualServer.xml +++ b/doc/classes/VisualServer.xml @@ -66,6 +66,22 @@ <description> </description> </method> + <method name="camera_set_frustum"> + <return type="void"> + </return> + <argument index="0" name="camera" type="RID"> + </argument> + <argument index="1" name="size" type="float"> + </argument> + <argument index="2" name="offset" type="Vector2"> + </argument> + <argument index="3" name="z_near" type="float"> + </argument> + <argument index="4" name="z_far" type="float"> + </argument> + <description> + </description> + </method> <method name="camera_set_orthogonal"> <return type="void"> </return> @@ -173,12 +189,15 @@ </argument> <argument index="1" name="mesh" type="RID"> </argument> - <argument index="2" name="texture" type="RID"> + <argument index="2" name="texture" type="Transform2D"> </argument> - <argument index="3" name="normal_map" type="RID"> + <argument index="3" name="normal_map" type="Color"> + </argument> + <argument index="4" name="arg4" type="RID"> + </argument> + <argument index="5" name="arg5" type="RID"> </argument> <description> - Adds a [Mesh] to the [CanvasItem]'s draw commands. Only affects its aabb at the moment. </description> </method> <method name="canvas_item_add_multimesh"> diff --git a/drivers/unix/file_access_unix.cpp b/drivers/unix/file_access_unix.cpp index 6e045817bc..a285b3b65f 100644 --- a/drivers/unix/file_access_unix.cpp +++ b/drivers/unix/file_access_unix.cpp @@ -293,8 +293,25 @@ uint64_t FileAccessUnix::_get_modified_time(const String &p_file) { }; } -Error FileAccessUnix::_chmod(const String &p_path, int p_mod) { - int err = chmod(p_path.utf8().get_data(), p_mod); +uint32_t FileAccessUnix::_get_unix_permissions(const String &p_file) { + + String file = fix_path(p_file); + struct stat flags; + int err = stat(file.utf8().get_data(), &flags); + + if (!err) { + return flags.st_mode & 0x7FF; //only permissions + } else { + ERR_EXPLAIN("Failed to get unix permissions for: " + p_file); + ERR_FAIL_V(0); + }; +} + +Error FileAccessUnix::_set_unix_permissions(const String &p_file, uint32_t p_permissions) { + + String file = fix_path(p_file); + + int err = chmod(file.utf8().get_data(), p_permissions); if (!err) { return OK; } diff --git a/drivers/unix/file_access_unix.h b/drivers/unix/file_access_unix.h index 6405589b4d..2a369048a4 100644 --- a/drivers/unix/file_access_unix.h +++ b/drivers/unix/file_access_unix.h @@ -85,8 +85,8 @@ public: virtual bool file_exists(const String &p_path); ///< return true if a file exists virtual uint64_t _get_modified_time(const String &p_file); - - virtual Error _chmod(const String &p_path, int p_mod); + virtual uint32_t _get_unix_permissions(const String &p_file); + virtual Error _set_unix_permissions(const String &p_file, uint32_t p_permissions); FileAccessUnix(); virtual ~FileAccessUnix(); diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp index 2778590658..25cdc8d8a0 100644 --- a/drivers/unix/os_unix.cpp +++ b/drivers/unix/os_unix.cpp @@ -119,15 +119,6 @@ int OS_Unix::unix_initialize_audio(int p_audio_driver) { return 0; } -// Very simple signal handler to reap processes where ::execute was called with -// !p_blocking -void handle_sigchld(int sig) { - int saved_errno = errno; - while (waitpid((pid_t)(-1), 0, WNOHANG) > 0) { - } - errno = saved_errno; -} - void OS_Unix::initialize_core() { #ifdef NO_THREADS @@ -155,14 +146,6 @@ void OS_Unix::initialize_core() { #endif _setup_clock(); - - struct sigaction sa; - sa.sa_handler = &handle_sigchld; - sigemptyset(&sa.sa_mask); - sa.sa_flags = SA_RESTART | SA_NOCLDSTOP; - if (sigaction(SIGCHLD, &sa, 0) == -1) { - perror("ERROR sigaction() failed:"); - } } void OS_Unix::finalize_core() { @@ -293,7 +276,7 @@ uint64_t OS_Unix::get_ticks_usec() const { return longtime; } -Error OS_Unix::execute(const String &p_path, const List<String> &p_arguments, bool p_blocking, ProcessID *r_child_id, String *r_pipe, int *r_exitcode, bool read_stderr) { +Error OS_Unix::execute(const String &p_path, const List<String> &p_arguments, bool p_blocking, ProcessID *r_child_id, String *r_pipe, int *r_exitcode, bool read_stderr, Mutex *p_pipe_mutex) { #ifdef __EMSCRIPTEN__ // Don't compile this code at all to avoid undefined references. @@ -320,11 +303,17 @@ Error OS_Unix::execute(const String &p_path, const List<String> &p_arguments, bo ERR_FAIL_COND_V(!f, ERR_CANT_OPEN); char buf[65535]; + while (fgets(buf, 65535, f)) { + if (p_pipe_mutex) { + p_pipe_mutex->lock(); + } (*r_pipe) += buf; + if (p_pipe_mutex) { + p_pipe_mutex->unlock(); + } } - int rv = pclose(f); if (r_exitcode) *r_exitcode = rv; @@ -337,6 +326,13 @@ Error OS_Unix::execute(const String &p_path, const List<String> &p_arguments, bo if (pid == 0) { // is child + + if (!p_blocking) { + // For non blocking calls, create a new session-ID so parent won't wait for it. + // This ensures the process won't go zombie at end. + setsid(); + } + Vector<CharString> cs; cs.push_back(p_path.utf8()); for (int i = 0; i < p_arguments.size(); i++) @@ -359,6 +355,7 @@ Error OS_Unix::execute(const String &p_path, const List<String> &p_arguments, bo waitpid(pid, &status, 0); if (r_exitcode) *r_exitcode = WEXITSTATUS(status); + } else { if (r_child_id) diff --git a/drivers/unix/os_unix.h b/drivers/unix/os_unix.h index 09ab4aa1d8..6a05877a8c 100644 --- a/drivers/unix/os_unix.h +++ b/drivers/unix/os_unix.h @@ -89,7 +89,7 @@ public: virtual void delay_usec(uint32_t p_usec) const; virtual uint64_t get_ticks_usec() const; - virtual Error execute(const String &p_path, const List<String> &p_arguments, bool p_blocking, ProcessID *r_child_id = NULL, String *r_pipe = NULL, int *r_exitcode = NULL, bool read_stderr = false); + virtual Error execute(const String &p_path, const List<String> &p_arguments, bool p_blocking, ProcessID *r_child_id = NULL, String *r_pipe = NULL, int *r_exitcode = NULL, bool read_stderr = false, Mutex *p_pipe_mutex = NULL); virtual Error kill(const ProcessID &p_pid); virtual int get_process_id() const; diff --git a/drivers/windows/file_access_windows.cpp b/drivers/windows/file_access_windows.cpp index c4c5e0d709..c13300d09f 100644 --- a/drivers/windows/file_access_windows.cpp +++ b/drivers/windows/file_access_windows.cpp @@ -339,6 +339,16 @@ uint64_t FileAccessWindows::_get_modified_time(const String &p_file) { } } +uint32_t FileAccessWindows::_get_unix_permissions(const String &p_file) { + ERR_PRINT("Windows does not support unix permissions"); + return 0; +} + +Error FileAccessWindows::_set_unix_permissions(const String &p_file, uint32_t p_permissions) { + ERR_PRINT("Windows does not support unix permissions"); + return FAILED; +} + FileAccessWindows::FileAccessWindows() : f(NULL), flags(0), diff --git a/drivers/windows/file_access_windows.h b/drivers/windows/file_access_windows.h index 35b1f0b2d8..2848ed5279 100644 --- a/drivers/windows/file_access_windows.h +++ b/drivers/windows/file_access_windows.h @@ -80,6 +80,8 @@ public: virtual bool file_exists(const String &p_name); ///< return true if a file exists uint64_t _get_modified_time(const String &p_file); + virtual uint32_t _get_unix_permissions(const String &p_file); + virtual Error _set_unix_permissions(const String &p_file, uint32_t p_permissions); FileAccessWindows(); virtual ~FileAccessWindows(); diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index f7527763eb..b0a1331b2e 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -805,6 +805,9 @@ void EditorProperty::_bind_methods() { ClassDB::bind_method(D_METHOD("get_tooltip_text"), &EditorProperty::get_tooltip_text); + ClassDB::bind_method(D_METHOD("add_focusable", "control"), &EditorProperty::add_focusable); + ClassDB::bind_method(D_METHOD("set_bottom_editor", "editor"), &EditorProperty::set_bottom_editor); + ClassDB::bind_method(D_METHOD("emit_changed", "property", "value", "field", "changing"), &EditorProperty::emit_changed, DEFVAL(StringName()), DEFVAL(false)); ADD_PROPERTY(PropertyInfo(Variant::STRING, "label"), "set_label", "get_label"); diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index f7a952d5cc..477a6b7f73 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -47,6 +47,7 @@ #include "core/translation.h" #include "core/version.h" #include "main/input_default.h" +#include "main/main.h" #include "scene/resources/packed_scene.h" #include "servers/physics_2d_server.h" @@ -2270,6 +2271,23 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { OS::get_singleton()->shell_open(String("file://") + OS::get_singleton()->get_user_data_dir()); } break; + case FILE_INSTALL_ANDROID_SOURCE: { + + if (p_confirmed) { + export_template_manager->install_android_template(); + } else { + if (DirAccess::exists("res://android/build")) { + remove_android_build_template->popup_centered_minsize(); + } else if (export_template_manager->can_install_android_template()) { + install_android_build_template->popup_centered_minsize(); + } else { + custom_build_manage_templates->popup_centered_minsize(); + } + } + } break; + case FILE_EXPLORE_ANDROID_BUILD_TEMPLATES: { + OS::get_singleton()->shell_open(String("file://") + ProjectSettings::get_singleton()->get_resource_path().plus_file("android")); + } break; case FILE_QUIT: case RUN_PROJECT_MANAGER: { @@ -5044,6 +5062,68 @@ void EditorNode::_print_handler(void *p_this, const String &p_string, bool p_err en->log->add_message(p_string, p_error ? EditorLog::MSG_TYPE_ERROR : EditorLog::MSG_TYPE_STD); } +static void _execute_thread(void *p_ud) { + + EditorNode::ExecuteThreadArgs *eta = (EditorNode::ExecuteThreadArgs *)p_ud; + Error err = OS::get_singleton()->execute(eta->path, eta->args, true, NULL, &eta->output, &eta->exitcode, true, eta->execute_output_mutex); + print_verbose("Thread exit status: " + itos(eta->exitcode)); + if (err != OK) { + eta->exitcode = err; + } + + eta->done = true; +} + +int EditorNode::execute_and_show_output(const String &p_title, const String &p_path, const List<String> &p_arguments, bool p_close_on_ok, bool p_close_on_errors) { + + execute_output_dialog->set_title(p_title); + execute_output_dialog->get_ok()->set_disabled(true); + execute_outputs->clear(); + execute_outputs->set_scroll_follow(true); + execute_output_dialog->popup_centered_ratio(); + + ExecuteThreadArgs eta; + eta.path = p_path; + eta.args = p_arguments; + eta.execute_output_mutex = Mutex::create(); + eta.exitcode = 255; + eta.done = false; + + int prev_len = 0; + + eta.execute_output_thread = Thread::create(_execute_thread, &eta); + + ERR_FAIL_COND_V(!eta.execute_output_thread, 0); + + while (!eta.done) { + eta.execute_output_mutex->lock(); + if (prev_len != eta.output.length()) { + String to_add = eta.output.substr(prev_len, eta.output.length()); + prev_len = eta.output.length(); + execute_outputs->add_text(to_add); + Main::iteration(); + } + eta.execute_output_mutex->unlock(); + OS::get_singleton()->delay_usec(1000); + } + + Thread::wait_to_finish(eta.execute_output_thread); + memdelete(eta.execute_output_thread); + memdelete(eta.execute_output_mutex); + execute_outputs->add_text("\nExit Code: " + itos(eta.exitcode)); + + if (p_close_on_errors && eta.exitcode != 0) { + execute_output_dialog->hide(); + } + if (p_close_on_ok && eta.exitcode == 0) { + execute_output_dialog->hide(); + } + + execute_output_dialog->get_ok()->set_disabled(false); + + return eta.exitcode; +} + EditorNode::EditorNode() { Input::get_singleton()->set_use_accumulated_input(true); @@ -5618,12 +5698,13 @@ EditorNode::EditorNode() { tool_menu = memnew(PopupMenu); tool_menu->set_name("Tools"); tool_menu->connect("index_pressed", this, "_tool_menu_option"); + p->add_separator(); p->add_child(tool_menu); p->add_submenu_item(TTR("Tools"), "Tools"); - tool_menu->add_shortcut(ED_SHORTCUT("editor/orphan_resource_explorer", TTR("Orphan Resource Explorer")), TOOLS_ORPHAN_RESOURCES); + tool_menu->add_item(TTR("Orphan Resource Explorer"), TOOLS_ORPHAN_RESOURCES); + tool_menu->add_item(TTR("Open Project Data Folder"), RUN_PROJECT_DATA_FOLDER); p->add_separator(); - - p->add_shortcut(ED_SHORTCUT("editor/open_project_data_folder", TTR("Open Project Data Folder")), RUN_PROJECT_DATA_FOLDER); + p->add_item(TTR("Install Android Build Template"), FILE_INSTALL_ANDROID_SOURCE); p->add_separator(); #ifdef OSX_ENABLED @@ -5970,6 +6051,24 @@ EditorNode::EditorNode() { save_confirmation->connect("confirmed", this, "_menu_confirm_current"); save_confirmation->connect("custom_action", this, "_discard_changes"); + custom_build_manage_templates = memnew(ConfirmationDialog); + custom_build_manage_templates->set_text(TTR("Android build template is missing, please install relevant templates.")); + custom_build_manage_templates->get_ok()->set_text(TTR("Manage Templates")); + custom_build_manage_templates->connect("confirmed", this, "_menu_option", varray(SETTINGS_MANAGE_EXPORT_TEMPLATES)); + gui_base->add_child(custom_build_manage_templates); + + install_android_build_template = memnew(ConfirmationDialog); + install_android_build_template->set_text(TTR("This will install the Android project for custom builds.\nNote that, in order to use it, it needs to be enabled per export preset.")); + install_android_build_template->get_ok()->set_text(TTR("Install")); + install_android_build_template->connect("confirmed", this, "_menu_confirm_current"); + gui_base->add_child(install_android_build_template); + + remove_android_build_template = memnew(ConfirmationDialog); + remove_android_build_template->set_text(TTR("Android build template is already installed and it won't be overwritten.\nRemove the \"build\" directory manually before attempting this operation again.")); + remove_android_build_template->get_ok()->set_text(TTR("Show in File Manager")); + remove_android_build_template->connect("confirmed", this, "_menu_option", varray(FILE_EXPLORE_ANDROID_BUILD_TEMPLATES)); + gui_base->add_child(remove_android_build_template); + file_templates = memnew(EditorFileDialog); file_templates->set_title(TTR("Import Templates From ZIP File")); @@ -6184,6 +6283,12 @@ EditorNode::EditorNode() { load_error_dialog->set_title(TTR("Load Errors")); gui_base->add_child(load_error_dialog); + execute_outputs = memnew(RichTextLabel); + execute_output_dialog = memnew(AcceptDialog); + execute_output_dialog->add_child(execute_outputs); + execute_output_dialog->set_title(TTR("")); + gui_base->add_child(execute_output_dialog); + EditorFileSystem::get_singleton()->connect("sources_changed", this, "_sources_changed"); EditorFileSystem::get_singleton()->connect("filesystem_changed", this, "_fs_changed"); EditorFileSystem::get_singleton()->connect("resources_reimported", this, "_resources_reimported"); diff --git a/editor/editor_node.h b/editor/editor_node.h index 328986fc69..a06708eb54 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -112,6 +112,16 @@ public: DOCK_SLOT_MAX }; + struct ExecuteThreadArgs { + String path; + List<String> args; + String output; + Thread *execute_output_thread; + Mutex *execute_output_mutex; + int exitcode; + volatile bool done; + }; + private: enum { HISTORY_SIZE = 64 @@ -130,6 +140,8 @@ private: FILE_IMPORT_SUBSCENE, FILE_EXPORT_PROJECT, FILE_EXPORT_MESH_LIBRARY, + FILE_INSTALL_ANDROID_SOURCE, + FILE_EXPLORE_ANDROID_BUILD_TEMPLATES, FILE_EXPORT_TILESET, FILE_SAVE_OPTIMIZED, FILE_OPEN_RECENT, @@ -267,6 +279,9 @@ private: RichTextLabel *load_errors; AcceptDialog *load_error_dialog; + RichTextLabel *execute_outputs; + AcceptDialog *execute_output_dialog; + Ref<Theme> theme; PopupMenu *recent_scenes; @@ -290,6 +305,10 @@ private: PopupMenu *editor_layouts; EditorNameDialog *layout_dialog; + ConfirmationDialog *custom_build_manage_templates; + ConfirmationDialog *install_android_build_template; + ConfirmationDialog *remove_android_build_template; + EditorSettingsDialog *settings_config_dialog; RunSettingsDialog *run_settings_dialog; ProjectSettingsEditor *project_settings; @@ -800,6 +819,8 @@ public: void update_keying() const { inspector_dock->update_keying(); }; bool has_scenes_in_session(); + int execute_and_show_output(const String &p_title, const String &p_path, const List<String> &p_arguments, bool p_close_on_ok = true, bool p_close_on_errors = false); + EditorNode(); ~EditorNode(); void get_singleton(const char *arg1, bool arg2); diff --git a/editor/export_template_manager.cpp b/editor/export_template_manager.cpp index 97ccfb0db1..aa2a03510d 100644 --- a/editor/export_template_manager.cpp +++ b/editor/export_template_manager.cpp @@ -308,7 +308,8 @@ bool ExportTemplateManager::_install_from_file(const String &p_file, bool p_use_ p->step(TTR("Importing:") + " " + file, fc); } - FileAccess *f = FileAccess::open(template_path.plus_file(file), FileAccess::WRITE); + String to_write = template_path.plus_file(file); + FileAccess *f = FileAccess::open(to_write, FileAccess::WRITE); if (!f) { ret = unzGoToNextFile(pkg); @@ -320,6 +321,10 @@ bool ExportTemplateManager::_install_from_file(const String &p_file, bool p_use_ memdelete(f); +#ifndef WINDOWS_ENABLED + FileAccess::set_unix_permissions(to_write, (info.external_fa >> 16) & 0x01FF); +#endif + ret = unzGoToNextFile(pkg); fc++; } @@ -541,6 +546,112 @@ void ExportTemplateManager::_notification(int p_what) { } } +bool ExportTemplateManager::can_install_android_template() { + + return FileAccess::exists(EditorSettings::get_singleton()->get_templates_dir().plus_file(VERSION_FULL_CONFIG).plus_file("android_source.zip")); +} + +Error ExportTemplateManager::install_android_template() { + + DirAccessRef da = DirAccess::open("res://"); + ERR_FAIL_COND_V(!da, ERR_CANT_CREATE); + //make android dir (if it does not exist) + + da->make_dir("android"); + { + //add an empty .gdignore file to avoid scan + FileAccessRef f = FileAccess::open("res://android/.gdignore", FileAccess::WRITE); + ERR_FAIL_COND_V(!f, ERR_CANT_CREATE); + f->store_line(""); + f->close(); + } + { + //add version, to ensure building wont work if template and Godot version are mismatch + FileAccessRef f = FileAccess::open("res://android/.build_version", FileAccess::WRITE); + ERR_FAIL_COND_V(!f, ERR_CANT_CREATE); + f->store_line(VERSION_FULL_CONFIG); + f->close(); + } + + Error err = da->make_dir_recursive("android/build"); + ERR_FAIL_COND_V(err != OK, err); + + String source_zip = EditorSettings::get_singleton()->get_templates_dir().plus_file(VERSION_FULL_CONFIG).plus_file("android_source.zip"); + ERR_FAIL_COND_V(!FileAccess::exists(source_zip), ERR_CANT_OPEN); + + FileAccess *src_f = NULL; + zlib_filefunc_def io = zipio_create_io_from_file(&src_f); + + unzFile pkg = unzOpen2(source_zip.utf8().get_data(), &io); + ERR_EXPLAIN("Android sources not in zip format"); + ERR_FAIL_COND_V(!pkg, ERR_CANT_OPEN); + + int ret = unzGoToFirstFile(pkg); + + int total_files = 0; + //count files + while (ret == UNZ_OK) { + total_files++; + ret = unzGoToNextFile(pkg); + } + + ret = unzGoToFirstFile(pkg); + //decompress files + ProgressDialog::get_singleton()->add_task("uncompress", TTR("Uncompressing Android Build Sources"), total_files); + + Set<String> dirs_tested; + + int idx = 0; + while (ret == UNZ_OK) { + + //get filename + unz_file_info info; + char fname[16384]; + ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, NULL, 0, NULL, 0); + + String name = fname; + + String base_dir = name.get_base_dir(); + + if (!name.ends_with("/")) { + Vector<uint8_t> data; + data.resize(info.uncompressed_size); + + //read + unzOpenCurrentFile(pkg); + unzReadCurrentFile(pkg, data.ptrw(), data.size()); + unzCloseCurrentFile(pkg); + + if (!dirs_tested.has(base_dir)) { + da->make_dir_recursive(String("android/build").plus_file(base_dir)); + dirs_tested.insert(base_dir); + } + + String to_write = String("res://android/build").plus_file(name); + FileAccess *f = FileAccess::open(to_write, FileAccess::WRITE); + if (f) { + f->store_buffer(data.ptr(), data.size()); + memdelete(f); +#ifndef WINDOWS_ENABLED + FileAccess::set_unix_permissions(to_write, (info.external_fa >> 16) & 0x01FF); +#endif + } else { + ERR_PRINTS("Cant uncompress file: " + to_write); + } + } + + ProgressDialog::get_singleton()->task_step("uncompress", name, idx); + + idx++; + ret = unzGoToNextFile(pkg); + } + + ProgressDialog::get_singleton()->end_task("uncompress"); + unzClose(pkg); + + return OK; +} + void ExportTemplateManager::_bind_methods() { ClassDB::bind_method("_download_template", &ExportTemplateManager::_download_template); diff --git a/editor/export_template_manager.h b/editor/export_template_manager.h index 2edd3db6d7..608830c990 100644 --- a/editor/export_template_manager.h +++ b/editor/export_template_manager.h @@ -84,6 +84,9 @@ protected: static void _bind_methods(); public: + bool can_install_android_template(); + Error install_android_template(); + void popup_manager(); ExportTemplateManager(); diff --git a/methods.py b/methods.py index ec9ecdb17f..d2bad7f9dd 100644 --- a/methods.py +++ b/methods.py @@ -211,70 +211,6 @@ def win32_spawn(sh, escape, cmd, args, spawnenv): return exit_code """ -def android_add_flat_dir(self, dir): - if (dir not in self.android_flat_dirs): - self.android_flat_dirs.append(dir) - -def android_add_maven_repository(self, url): - if (url not in self.android_maven_repos): - self.android_maven_repos.append(url) - -def android_add_dependency(self, depline): - if (depline not in self.android_dependencies): - self.android_dependencies.append(depline) - -def android_add_java_dir(self, subpath): - base_path = self.Dir(".").abspath + "/modules/" + self.current_module + "/" + subpath - if (base_path not in self.android_java_dirs): - self.android_java_dirs.append(base_path) - -def android_add_res_dir(self, subpath): - base_path = self.Dir(".").abspath + "/modules/" + self.current_module + "/" + subpath - if (base_path not in self.android_res_dirs): - self.android_res_dirs.append(base_path) - -def android_add_asset_dir(self, subpath): - base_path = self.Dir(".").abspath + "/modules/" + self.current_module + "/" + subpath - if (base_path not in self.android_asset_dirs): - self.android_asset_dirs.append(base_path) - -def android_add_aidl_dir(self, subpath): - base_path = self.Dir(".").abspath + "/modules/" + self.current_module + "/" + subpath - if (base_path not in self.android_aidl_dirs): - self.android_aidl_dirs.append(base_path) - -def android_add_jni_dir(self, subpath): - base_path = self.Dir(".").abspath + "/modules/" + self.current_module + "/" + subpath - if (base_path not in self.android_jni_dirs): - self.android_jni_dirs.append(base_path) - -def android_add_gradle_plugin(self, plugin): - if (plugin not in self.android_gradle_plugins): - self.android_gradle_plugins.append(plugin) - -def android_add_gradle_classpath(self, classpath): - if (classpath not in self.android_gradle_classpath): - self.android_gradle_classpath.append(classpath) - -def android_add_default_config(self, config): - if (config not in self.android_default_config): - self.android_default_config.append(config) - -def android_add_to_manifest(self, file): - base_path = self.Dir(".").abspath + "/modules/" + self.current_module + "/" + file - with open(base_path, "r") as f: - self.android_manifest_chunk += f.read() - -def android_add_to_permissions(self, file): - base_path = self.Dir(".").abspath + "/modules/" + self.current_module + "/" + file - with open(base_path, "r") as f: - self.android_permission_chunk += f.read() - -def android_add_to_attributes(self, file): - base_path = self.Dir(".").abspath + "/modules/" + self.current_module + "/" + file - with open(base_path, "r") as f: - self.android_appattributes_chunk += f.read() - def disable_module(self): self.disabled_modules.append(self.current_module) diff --git a/modules/csg/doc_classes/CSGMesh.xml b/modules/csg/doc_classes/CSGMesh.xml index c1f04d724a..afe0bc262d 100644 --- a/modules/csg/doc_classes/CSGMesh.xml +++ b/modules/csg/doc_classes/CSGMesh.xml @@ -11,6 +11,8 @@ <methods> </methods> <members> + <member name="material" type="Material" setter="set_material" getter="get_material"> + </member> <member name="mesh" type="Mesh" setter="set_mesh" getter="get_mesh"> The mesh resource to use as a CSG shape. </member> diff --git a/modules/csg/doc_classes/CSGShape.xml b/modules/csg/doc_classes/CSGShape.xml index 2311830ae0..7fa7c78534 100644 --- a/modules/csg/doc_classes/CSGShape.xml +++ b/modules/csg/doc_classes/CSGShape.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="CSGShape" inherits="VisualInstance" category="Core" version="3.2"> +<class name="CSGShape" inherits="GeometryInstance" category="Core" version="3.2"> <brief_description> The CSG base class. </brief_description> diff --git a/platform/android/SCsub b/platform/android/SCsub index d494372bcd..22ed476c6f 100644 --- a/platform/android/SCsub +++ b/platform/android/SCsub @@ -34,114 +34,6 @@ env_thirdparty = env_android.Clone() env_thirdparty.disable_warnings() android_objects.append(env_thirdparty.SharedObject('#thirdparty/misc/ifaddrs-android.cc')) -abspath = env.Dir(".").abspath - -with open_utf8(abspath + "/build.gradle.template", "r") as gradle_basein: - gradle_text = gradle_basein.read() - -gradle_maven_flat_text = "" -if len(env.android_flat_dirs) > 0: - gradle_maven_flat_text += "flatDir {\n" - gradle_maven_flat_text += "\tdirs " - for x in env.android_flat_dirs: - gradle_maven_flat_text += "'" + x + "'," - - gradle_maven_flat_text = gradle_maven_flat_text[:-1] - gradle_maven_flat_text += "\n\t}\n" - -gradle_maven_repos_text = "" -gradle_maven_repos_text += gradle_maven_flat_text - -if len(env.android_maven_repos) > 0: - gradle_maven_repos_text += "" - for x in env.android_maven_repos: - gradle_maven_repos_text += "\tmaven {\n" - gradle_maven_repos_text += "\t" + x + "\n" - gradle_maven_repos_text += "\t}\n" - -gradle_maven_dependencies_text = "" - -for x in env.android_dependencies: - gradle_maven_dependencies_text += x + "\n\t" - -gradle_java_dirs_text = "" - -for x in env.android_java_dirs: - gradle_java_dirs_text += ",'" + x.replace("\\", "/") + "'" - -gradle_plugins = "" -for x in env.android_gradle_plugins: - gradle_plugins += "apply plugin: \"" + x + "\"\n" - -gradle_classpath = "" -for x in env.android_gradle_classpath: - gradle_classpath += "\t\tclasspath \"" + x + "\"\n" - -gradle_res_dirs_text = "" - -for x in env.android_res_dirs: - gradle_res_dirs_text += ",'" + x.replace("\\", "/") + "'" - -gradle_aidl_dirs_text = "" - -for x in env.android_aidl_dirs: - gradle_aidl_dirs_text += ",'" + x.replace("\\", "/") + "'" - -gradle_jni_dirs_text = "" - -for x in env.android_jni_dirs: - gradle_jni_dirs_text += ",'" + x.replace("\\", "/") + "'" - -gradle_asset_dirs_text = "" - -for x in env.android_asset_dirs: - gradle_asset_dirs_text += ",'" + x.replace("\\", "/") + "'" - -gradle_default_config_text = "" - -minSdk = 18 -targetSdk = 28 - -for x in env.android_default_config: - if x.startswith("minSdkVersion") and int(x.split(" ")[-1]) < minSdk: - x = "minSdkVersion " + str(minSdk) - if x.startswith("targetSdkVersion") and int(x.split(" ")[-1]) > targetSdk: - x = "targetSdkVersion " + str(targetSdk) - - gradle_default_config_text += x + "\n\t\t" - -if "minSdkVersion" not in gradle_default_config_text: - gradle_default_config_text += ("minSdkVersion " + str(minSdk) + "\n\t\t") - -if "targetSdkVersion" not in gradle_default_config_text: - gradle_default_config_text += ("targetSdkVersion " + str(targetSdk) + "\n\t\t") - -gradle_text = gradle_text.replace("$$GRADLE_REPOSITORY_URLS$$", gradle_maven_repos_text) -gradle_text = gradle_text.replace("$$GRADLE_DEPENDENCIES$$", gradle_maven_dependencies_text) -gradle_text = gradle_text.replace("$$GRADLE_JAVA_DIRS$$", gradle_java_dirs_text) -gradle_text = gradle_text.replace("$$GRADLE_RES_DIRS$$", gradle_res_dirs_text) -gradle_text = gradle_text.replace("$$GRADLE_ASSET_DIRS$$", gradle_asset_dirs_text) -gradle_text = gradle_text.replace("$$GRADLE_AIDL_DIRS$$", gradle_aidl_dirs_text) -gradle_text = gradle_text.replace("$$GRADLE_JNI_DIRS$$", gradle_jni_dirs_text) -gradle_text = gradle_text.replace("$$GRADLE_DEFAULT_CONFIG$$", gradle_default_config_text) -gradle_text = gradle_text.replace("$$GRADLE_PLUGINS$$", gradle_plugins) -gradle_text = gradle_text.replace("$$GRADLE_CLASSPATH$$", gradle_classpath) - -with open_utf8(abspath + "/java/build.gradle", "w") as gradle_baseout: - gradle_baseout.write(gradle_text) - - -with open_utf8(abspath + "/AndroidManifest.xml.template", "r") as pp_basein: - manifest = pp_basein.read() - -manifest = manifest.replace("$$ADD_APPLICATION_CHUNKS$$", env.android_manifest_chunk) -manifest = manifest.replace("$$ADD_PERMISSION_CHUNKS$$", env.android_permission_chunk) -manifest = manifest.replace("$$ADD_APPATTRIBUTE_CHUNKS$$", env.android_appattributes_chunk) - -with open_utf8(abspath + "/java/AndroidManifest.xml", "w") as pp_baseout: - pp_baseout.write(manifest) - - lib = env_android.add_shared_library("#bin/libgodot", [android_objects], SHLIBSUFFIX=env["SHLIBSUFFIX"]) lib_arch_dir = '' diff --git a/platform/android/build.gradle.template b/platform/android/build.gradle.template deleted file mode 100644 index 2fea250061..0000000000 --- a/platform/android/build.gradle.template +++ /dev/null @@ -1,88 +0,0 @@ -buildscript { - repositories { - google() - jcenter() - $$GRADLE_REPOSITORY_URLS$$ - } - dependencies { - classpath 'com.android.tools.build:gradle:3.2.1' - $$GRADLE_CLASSPATH$$ - } -} - -apply plugin: 'com.android.application' - -allprojects { - repositories { - mavenCentral() - google() - jcenter() - $$GRADLE_REPOSITORY_URLS$$ - } -} - -dependencies { - implementation "com.android.support:support-core-utils:28.0.0" - $$GRADLE_DEPENDENCIES$$ -} - -android { - - lintOptions { - abortOnError false - disable 'MissingTranslation','UnusedResources' - } - - compileSdkVersion 28 - buildToolsVersion "28.0.3" - useLibrary 'org.apache.http.legacy' - - packagingOptions { - exclude 'META-INF/LICENSE' - exclude 'META-INF/NOTICE' - } - defaultConfig { - $$GRADLE_DEFAULT_CONFIG$$ - } - // Both signing and zip-aligning will be done at export time - buildTypes.all { buildType -> - buildType.zipAlignEnabled false - buildType.signingConfig null - } - sourceSets { - main { - manifest.srcFile 'AndroidManifest.xml' - java.srcDirs = ['src' - $$GRADLE_JAVA_DIRS$$ - ] - res.srcDirs = [ - 'res' - $$GRADLE_RES_DIRS$$ - ] - aidl.srcDirs = [ - 'aidl' - $$GRADLE_AIDL_DIRS$$ - ] - assets.srcDirs = [ - 'assets' - $$GRADLE_ASSET_DIRS$$ - ] - } - debug.jniLibs.srcDirs = [ - 'libs/debug' - $$GRADLE_JNI_DIRS$$ - ] - release.jniLibs.srcDirs = [ - 'libs/release' - $$GRADLE_JNI_DIRS$$ - ] - } - - applicationVariants.all { variant -> - variant.outputs.all { output -> - output.outputFileName = "../../../../../../../bin/android_${variant.name}.apk" - } - } -} - -$$GRADLE_PLUGINS$$ diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp index afccbd113e..f70cee2964 100644 --- a/platform/android/export/export.cpp +++ b/platform/android/export/export.cpp @@ -417,6 +417,7 @@ class EditorExportPlatformAndroid : public EditorExportPlatform { name = "noname"; pname = pname.replace("$genname", name); + return pname; } @@ -1143,11 +1144,12 @@ public: r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "one_click_deploy/clear_previous_install"), true)); r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_package/debug", PROPERTY_HINT_GLOBAL_FILE, "*.apk"), "")); r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_package/release", PROPERTY_HINT_GLOBAL_FILE, "*.apk"), "")); + r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "custom_package/use_custom_build"), false)); r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "command_line/extra_args"), "")); r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "version/code", PROPERTY_HINT_RANGE, "1,4096,1,or_greater"), 1)); r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "version/name"), "1.0")); - r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "package/unique_name", PROPERTY_HINT_PLACEHOLDER_TEXT, "com.example.$genname"), "")); - r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "package/name", PROPERTY_HINT_PLACEHOLDER_TEXT, "Game Name"), "")); + r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "package/unique_name", PROPERTY_HINT_PLACEHOLDER_TEXT, "ext.domain.name"), "org.godotengine.$genname")); + r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "package/name", PROPERTY_HINT_PLACEHOLDER_TEXT, "Game Name [default if blank]"), "")); r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "package/signed"), true)); r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "screen/immersive_mode"), true)); r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "screen/orientation", PROPERTY_HINT_ENUM, "Landscape,Portrait"), 0)); @@ -1388,21 +1390,25 @@ public: virtual bool can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const { String err; - r_missing_templates = find_export_template("android_debug.apk") == String() || find_export_template("android_release.apk") == String(); - if (p_preset->get("custom_package/debug") != "") { - if (FileAccess::exists(p_preset->get("custom_package/debug"))) { - r_missing_templates = false; - } else { - err += TTR("Custom debug template not found.") + "\n"; + if (!bool(p_preset->get("custom_package/use_custom_build"))) { + + r_missing_templates = find_export_template("android_debug.apk") == String() || find_export_template("android_release.apk") == String(); + + if (p_preset->get("custom_package/debug") != "") { + if (FileAccess::exists(p_preset->get("custom_package/debug"))) { + r_missing_templates = false; + } else { + err += TTR("Custom debug template not found.") + "\n"; + } } - } - if (p_preset->get("custom_package/release") != "") { - if (FileAccess::exists(p_preset->get("custom_package/release"))) { - r_missing_templates = false; - } else { - err += TTR("Custom release template not found.") + "\n"; + if (p_preset->get("custom_package/release") != "") { + if (FileAccess::exists(p_preset->get("custom_package/release"))) { + r_missing_templates = false; + } else { + err += TTR("Custom release template not found.") + "\n"; + } } } @@ -1435,6 +1441,30 @@ public: } } + if (bool(p_preset->get("custom_package/use_custom_build"))) { + String sdk_path = EditorSettings::get_singleton()->get("export/android/custom_build_sdk_path"); + if (sdk_path == "") { + err += TTR("Custom build requires a valid Android SDK path in Editor Settings.") + "\n"; + valid = false; + } else { + Error errn; + DirAccess *da = DirAccess::open(sdk_path.plus_file("tools"), &errn); + if (errn != OK) { + err += TTR("Invalid Android SDK path for custom build in Editor Settings.") + "\n"; + valid = false; + } + if (da) { + memdelete(da); + } + } + + if (!FileAccess::exists("res://android/build/build.gradle")) { + + err += TTR("Android project is not installed for compiling. Install from Editor menu.") + "\n"; + valid = false; + } + } + bool apk_expansion = p_preset->get("apk_expansion/enable"); if (apk_expansion) { @@ -1473,6 +1503,260 @@ public: return list; } + void _update_custom_build_project() { + + DirAccessRef da = DirAccess::open("res://android"); + + ERR_FAIL_COND(!da); + Map<String, List<String> > directory_paths; + Map<String, List<String> > manifest_sections; + Map<String, List<String> > gradle_sections; + da->list_dir_begin(); + String d = da->get_next(); + while (d != String()) { + + if (!d.begins_with(".") && d != "build" && da->current_is_dir()) { //a dir and not the build dir + //add directories found + DirAccessRef ds = DirAccess::open(String("res://android").plus_file(d)); + if (ds) { + ds->list_dir_begin(); + String sd = ds->get_next(); + while (sd != String()) { + + if (!sd.begins_with(".") && ds->current_is_dir()) { + String key = sd.to_upper(); + if (!directory_paths.has(key)) { + directory_paths[key] = List<String>(); + } + String path = ProjectSettings::get_singleton()->get_resource_path().plus_file("android").plus_file(d).plus_file(sd); + directory_paths[key].push_back(path); + print_line("Add: " + sd + ":" + path); + } + + sd = ds->get_next(); + } + ds->list_dir_end(); + } + //parse manifest + { + FileAccessRef f = FileAccess::open(String("res://android").plus_file(d).plus_file("AndroidManifest.conf"), FileAccess::READ); + if (f) { + + String section; + while (!f->eof_reached()) { + String l = f->get_line(); + String k = l.strip_edges(); + if (k.begins_with("[")) { + section = k.substr(1, k.length() - 2).strip_edges().to_upper(); + print_line("Section: " + section); + } else if (k != String()) { + if (!manifest_sections.has(section)) { + manifest_sections[section] = List<String>(); + } + manifest_sections[section].push_back(l); + } + } + + f->close(); + } + } + //parse gradle + { + FileAccessRef f = FileAccess::open(String("res://android").plus_file(d).plus_file("gradle.conf"), FileAccess::READ); + if (f) { + + String section; + while (!f->eof_reached()) { + String l = f->get_line().strip_edges(); + String k = l.strip_edges(); + if (k.begins_with("[")) { + section = k.substr(1, k.length() - 2).strip_edges().to_upper(); + print_line("Section: " + section); + } else if (k != String()) { + if (!gradle_sections.has(section)) { + gradle_sections[section] = List<String>(); + } + gradle_sections[section].push_back(l); + } + } + } + } + } + d = da->get_next(); + } + da->list_dir_end(); + + { //fix gradle build + + String new_file; + { + FileAccessRef f = FileAccess::open("res://android/build/build.gradle", FileAccess::READ); + if (f) { + + while (!f->eof_reached()) { + String l = f->get_line(); + + if (l.begins_with("//CHUNK_")) { + String text = l.replace_first("//CHUNK_", ""); + int begin_pos = text.find("_BEGIN"); + if (begin_pos != -1) { + text = text.substr(0, begin_pos); + text = text.to_upper(); //just in case + + String end_marker = "//CHUNK_" + text + "_END"; + size_t pos = f->get_position(); + bool found = false; + while (!f->eof_reached()) { + l = f->get_line(); + if (l.begins_with(end_marker)) { + found = true; + break; + } + } + + new_file += "//CHUNK_" + text + "_BEGIN\n"; + + if (!found) { + ERR_PRINTS("No end marker found in build.gradle for chunk: " + text); + f->seek(pos); + } else { + + //add chunk lines + if (gradle_sections.has(text)) { + for (List<String>::Element *E = gradle_sections[text].front(); E; E = E->next()) { + new_file += E->get() + "\n"; + } + } + new_file += end_marker + "\n"; + } + } else { + new_file += l + "\n"; //pass line by + } + } else if (l.begins_with("//DIR_")) { + String text = l.replace_first("//DIR_", ""); + int begin_pos = text.find("_BEGIN"); + if (begin_pos != -1) { + text = text.substr(0, begin_pos); + text = text.to_upper(); //just in case + + String end_marker = "//DIR_" + text + "_END"; + size_t pos = f->get_position(); + bool found = false; + while (!f->eof_reached()) { + l = f->get_line(); + if (l.begins_with(end_marker)) { + found = true; + break; + } + } + + new_file += "//DIR_" + text + "_BEGIN\n"; + + if (!found) { + ERR_PRINTS("No end marker found in build.gradle for dir: " + text); + f->seek(pos); + } else { + //add chunk lines + if (directory_paths.has(text)) { + for (List<String>::Element *E = directory_paths[text].front(); E; E = E->next()) { + new_file += ",'" + E->get().replace("'", "\'") + "'"; + new_file += "\n"; + } + } + new_file += end_marker + "\n"; + } + } else { + new_file += l + "\n"; //pass line by + } + + } else { + new_file += l + "\n"; + } + } + } + } + + FileAccessRef f = FileAccess::open("res://android/build/build.gradle", FileAccess::WRITE); + f->store_string(new_file); + f->close(); + } + + { //fix manifest + + String new_file; + { + FileAccessRef f = FileAccess::open("res://android/build/AndroidManifest.xml", FileAccess::READ); + if (f) { + + while (!f->eof_reached()) { + String l = f->get_line(); + + if (l.begins_with("<!--CHUNK_")) { + String text = l.replace_first("<!--CHUNK_", ""); + int begin_pos = text.find("_BEGIN-->"); + if (begin_pos != -1) { + text = text.substr(0, begin_pos); + text = text.to_upper(); //just in case + + String end_marker = "<!--CHUNK_" + text + "_END-->"; + size_t pos = f->get_position(); + bool found = false; + while (!f->eof_reached()) { + l = f->get_line(); + if (l.begins_with(end_marker)) { + found = true; + break; + } + } + + new_file += "<!--CHUNK_" + text + "_BEGIN-->\n"; + + if (!found) { + ERR_PRINTS("No end marker found in AndroidManifest.conf for chunk: " + text); + f->seek(pos); + } else { + //add chunk lines + if (manifest_sections.has(text)) { + for (List<String>::Element *E = manifest_sections[text].front(); E; E = E->next()) { + new_file += E->get() + "\n"; + } + } + new_file += end_marker + "\n"; + } + } else { + new_file += l + "\n"; //pass line by + } + + } else if (l.strip_edges().begins_with("<application")) { + String last_tag = "android:icon=\"@drawable/icon\""; + int last_tag_pos = l.find(last_tag); + if (last_tag_pos == -1) { + WARN_PRINTS("No adding of application tags because could not find last tag for <application: " + last_tag); + new_file += l + "\n"; + } else { + String base = l.substr(0, last_tag_pos + last_tag.length()); + if (manifest_sections.has("application_tags")) { + for (List<String>::Element *E = manifest_sections["application_tags"].front(); E; E = E->next()) { + String to_add = E->get().strip_edges(); + base += " " + to_add + " "; + } + } + base += ">\n"; + new_file += base; + } + } else { + new_file += l + "\n"; + } + } + } + } + + FileAccessRef f = FileAccess::open("res://android/build/AndroidManifest.xml", FileAccess::WRITE); + f->store_string(new_file); + f->close(); + } + } + virtual Error export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0) { ExportNotifier notifier(*this, p_preset, p_debug, p_path, p_flags); @@ -1481,21 +1765,86 @@ public: EditorProgress ep("export", "Exporting for Android", 105); - if (p_debug) - src_apk = p_preset->get("custom_package/debug"); - else - src_apk = p_preset->get("custom_package/release"); + if (bool(p_preset->get("custom_package/use_custom_build"))) { //custom build + //re-generate build.gradle and AndroidManifest.xml - src_apk = src_apk.strip_edges(); - if (src_apk == "") { + { //test that installed build version is alright + FileAccessRef f = FileAccess::open("res://android/.build_version", FileAccess::READ); + if (!f) { + EditorNode::get_singleton()->show_warning(TTR("Trying to build from a custom built template, but no version info for it exists. Please reinstall from the 'Project' menu.")); + return ERR_UNCONFIGURED; + } + String version = f->get_line().strip_edges(); + if (version != VERSION_FULL_CONFIG) { + EditorNode::get_singleton()->show_warning(vformat(TTR("Android build version mismatch:\n Template installed: %s\n Godot Version: %s\nPlease reinstall Android build template from 'Project' menu."), version, VERSION_FULL_CONFIG)); + return ERR_UNCONFIGURED; + } + } + //build project if custom build is enabled + String sdk_path = EDITOR_GET("export/android/custom_build_sdk_path"); + + ERR_FAIL_COND_V(sdk_path == "", ERR_UNCONFIGURED); + + _update_custom_build_project(); + + OS::get_singleton()->set_environment("ANDROID_HOME", sdk_path); //set and overwrite if required + + String build_command; +#ifdef WINDOWS_ENABLED + build_command = "gradlew.bat"; +#else + build_command = "gradlew"; +#endif + + String build_path = ProjectSettings::get_singleton()->get_resource_path().plus_file("android/build"); + + build_command = build_path.plus_file(build_command); + + List<String> cmdline; + cmdline.push_back("build"); + cmdline.push_back("-p"); + cmdline.push_back(build_path); + /*{ used for debug + int ec; + String pipe; + OS::get_singleton()->execute(build_command, cmdline, true, NULL, NULL, &ec); + print_line("exit code: " + itos(ec)); + } + */ + int result = EditorNode::get_singleton()->execute_and_show_output(TTR("Building Android Project (gradle)"), build_command, cmdline); + if (result != 0) { + EditorNode::get_singleton()->show_warning(TTR("Building of Android project failed, check output for the error.\nAlternatively visit docs.godotengine.org for Android build documentation.")); + return ERR_CANT_CREATE; + } if (p_debug) { - src_apk = find_export_template("android_debug.apk"); + src_apk = build_path.plus_file("build/outputs/apk/debug/build-debug-unsigned.apk"); } else { - src_apk = find_export_template("android_release.apk"); + src_apk = build_path.plus_file("build/outputs/apk/release/build-release-unsigned.apk"); + } + + if (!FileAccess::exists(src_apk)) { + EditorNode::get_singleton()->show_warning(TTR("No build apk generated at: ") + "\n" + src_apk); + return ERR_CANT_CREATE; } + + } else { + + if (p_debug) + src_apk = p_preset->get("custom_package/debug"); + else + src_apk = p_preset->get("custom_package/release"); + + src_apk = src_apk.strip_edges(); if (src_apk == "") { - EditorNode::add_io_error("Package not found: " + src_apk); - return ERR_FILE_NOT_FOUND; + if (p_debug) { + src_apk = find_export_template("android_debug.apk"); + } else { + src_apk = find_export_template("android_release.apk"); + } + if (src_apk == "") { + EditorNode::add_io_error("Package not found: " + src_apk); + return ERR_FILE_NOT_FOUND; + } } } @@ -1975,6 +2324,8 @@ void register_android_exporter() { EDITOR_DEF("export/android/debug_keystore_user", "androiddebugkey"); EDITOR_DEF("export/android/debug_keystore_pass", "android"); EDITOR_DEF("export/android/force_system_user", false); + EDITOR_DEF("export/android/custom_build_sdk_path", ""); + EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "export/android/custom_build_sdk_path", PROPERTY_HINT_GLOBAL_DIR, "*.keystore")); EDITOR_DEF("export/android/timestamping_authority_url", ""); EDITOR_DEF("export/android/shutdown_adb_on_exit", true); diff --git a/platform/android/file_access_android.h b/platform/android/file_access_android.h index f8d46ea5d2..b8e78627ec 100644 --- a/platform/android/file_access_android.h +++ b/platform/android/file_access_android.h @@ -70,6 +70,8 @@ public: virtual bool file_exists(const String &p_path); ///< return true if a file exists virtual uint64_t _get_modified_time(const String &p_file) { return 0; } + virtual uint32_t _get_unix_permissions(const String &p_file) { return 0; } + virtual Error _set_unix_permissions(const String &p_file, uint32_t p_permissions) { return FAILED; } //static void make_default(); diff --git a/platform/android/file_access_jandroid.h b/platform/android/file_access_jandroid.h index 4f02fea81d..9429100d65 100644 --- a/platform/android/file_access_jandroid.h +++ b/platform/android/file_access_jandroid.h @@ -74,6 +74,8 @@ public: static void setup(jobject p_io); virtual uint64_t _get_modified_time(const String &p_file) { return 0; } + virtual uint32_t _get_unix_permissions(const String &p_file) { return 0; } + virtual Error _set_unix_permissions(const String &p_file, uint32_t p_permissions) { return FAILED; } FileAccessJAndroid(); ~FileAccessJAndroid(); diff --git a/platform/android/AndroidManifest.xml.template b/platform/android/java/AndroidManifest.xml index daaf847f11..29ddd844ba 100644 --- a/platform/android/AndroidManifest.xml.template +++ b/platform/android/java/AndroidManifest.xml @@ -11,11 +11,20 @@ android:largeScreens="true" android:xlargeScreens="true"/> +<!--glEsVersion is modified by the exporter, changing this value here has no effect--> <uses-feature android:glEsVersion="0x00020000" android:required="true" /> +<!--Adding custom text to manifest is fine, but do it outside the custom user and application BEGIN/ENDregions, as that gets rewritten--> -$$ADD_PERMISSION_CHUNKS$$ +<!--Custom permissions XML added by add-ons. It's recommended to add them from the export preset, though--> +<!--CHUNK_USER_PERMISSIONS_BEGIN--> +<!--CHUNK_USER_PERMISSIONS_END--> + +<!--Anything in this line after the icon will be erased when doing custom build. If you want to add tags manually, do before it.--> + <application android:label="@string/godot_project_name_string" android:allowBackup="false" tools:ignore="GoogleAppIndexingWarning" android:icon="@drawable/icon"> + +<!--The following values are replaced when Godot exports, modifying them here has no effect. Do theses changes in the--> +<!--export preset. Adding new ones is fine.--> - <application android:label="@string/godot_project_name_string" android:icon="@drawable/icon" android:allowBackup="false" tools:ignore="GoogleAppIndexingWarning" $$ADD_APPATTRIBUTE_CHUNKS$$ > <activity android:name="org.godotengine.godot.Godot" android:label="@string/godot_project_name_string" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" @@ -32,13 +41,22 @@ $$ADD_PERMISSION_CHUNKS$$ </activity> <service android:name="org.godotengine.godot.GodotDownloaderService" /> -$$ADD_APPLICATION_CHUNKS$$ +<!--Custom application XML added by add-ons--> +<!--CHUNK_APPLICATION_BEGIN--> +<activity android:name="com.google.android.gms.ads.AdActivity" + android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/> +<meta-data android:name="com.google.android.gms.version" + android:value="@integer/google_play_services_version" /> +<meta-data + android:name="com.google.android.gms.ads.AD_MANAGER_APP" + android:value="true"/> +<!--CHUNK_APPLICATION_END--> </application> <instrumentation android:icon="@drawable/icon" android:label="@string/godot_project_name_string" android:name="org.godotengine.godot.GodotInstrumentation" - android:targetPackage="com.godot.game" /> + android:targetPackage="org.godotengine.game" /> </manifest> diff --git a/platform/android/java/build.gradle b/platform/android/java/build.gradle new file mode 100644 index 0000000000..868bbee831 --- /dev/null +++ b/platform/android/java/build.gradle @@ -0,0 +1,115 @@ +//Gradle project for Godot Engine Android port. +//Do not modify code between the BEGIN/END sections, as it's autogenerated by add-ons + +buildscript { + repositories { + google() + jcenter() +//CHUNK_BUILDSCRIPT_REPOSITORIES_BEGIN +//CHUNK_BUILDSCRIPT_REPOSITORIES_END + } + dependencies { + classpath 'com.android.tools.build:gradle:3.2.1' +//CHUNK_BUILD_DEPENDENCIES_BEGIN +//CHUNK_BUILD_DEPENDENCIES_END + } +} + +apply plugin: 'com.android.application' + +allprojects { + repositories { + mavenCentral() + google() + jcenter() +//CHUNK_ALLPROJECTS_REPOSITORIES_BEGIN +//CHUNK_ALLPROJECTS_REPOSITORIES_END + + } +} + +dependencies { + implementation "com.android.support:support-core-utils:28.0.0" +//CHUNK_DEPENDENCIES_BEGIN +compile ('com.google.android.gms:play-services-ads:16.0.0') { exclude group: 'com.android.support' } +//CHUNK_DEPENDENCIES_END +} + +android { + + lintOptions { + abortOnError false + disable 'MissingTranslation','UnusedResources' + } + + compileSdkVersion 28 + buildToolsVersion "28.0.3" + useLibrary 'org.apache.http.legacy' + + packagingOptions { + exclude 'META-INF/LICENSE' + exclude 'META-INF/NOTICE' + } + defaultConfig { + minSdkVersion 18 + targetSdkVersion 28 +//CHUNK_ANDROID_DEFAULTCONFIG_BEGIN +//CHUNK_ANDROID_DEFAULTCONFIG_END + } + // Both signing and zip-aligning will be done at export time + buildTypes.all { buildType -> + buildType.zipAlignEnabled false + buildType.signingConfig null + } + sourceSets { + main { + manifest.srcFile 'AndroidManifest.xml' + java.srcDirs = ['src' +//DIR_SRC_BEGIN +,'/home/red/coding/godot-demos/2d/platformer/android/admob/src' +//DIR_SRC_END + ] + res.srcDirs = [ + 'res' +//DIR_RES_BEGIN +//DIR_RES_END + ] + aidl.srcDirs = [ + 'aidl' +//DIR_AIDL_BEGIN +//DIR_AIDL_END + ] + assets.srcDirs = [ + 'assets' +//DIR_ASSETS_BEGIN +//DIR_ASSETS_END + + ] + } + debug.jniLibs.srcDirs = [ + 'libs/debug' +//DIR_JNI_DEBUG_BEGIN +//DIR_JNI_DEBUG_END + ] + release.jniLibs.srcDirs = [ + 'libs/release' +//DIR_JNI_RELEASE_BEGIN +//DIR_JNI_RELEASE_END + ] + } +// No longer used, as it's not useful for build source template +// applicationVariants.all { variant -> +// variant.outputs.all { output -> +// output.outputFileName = "../../../../../../../bin/android_${variant.name}.apk" +// } +// } + +} + +//CHUNK_GLOBAL_BEGIN +//CHUNK_GLOBAL_END + + + + + diff --git a/platform/osx/export/export.cpp b/platform/osx/export/export.cpp index 5e94bc457b..1a63d6ff75 100644 --- a/platform/osx/export/export.cpp +++ b/platform/osx/export/export.cpp @@ -568,7 +568,7 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p f->close(); if (is_execute) { // Chmod with 0755 if the file is executable - f->_chmod(file, 0755); + FileAccess::set_unix_permissions(file, 0755); } memdelete(f); } else { diff --git a/platform/windows/detect.py b/platform/windows/detect.py index 2f7334657f..e986c47b40 100644 --- a/platform/windows/detect.py +++ b/platform/windows/detect.py @@ -330,7 +330,7 @@ def configure_mingw(env): env.Append(CCFLAGS=['-DWASAPI_ENABLED']) env.Append(CCFLAGS=['-DWINMIDI_ENABLED']) env.Append(CCFLAGS=['-DWINVER=%s' % env['target_win_version'], '-D_WIN32_WINNT=%s' % env['target_win_version']]) - env.Append(LIBS=['mingw32', 'opengl32', 'dsound', 'ole32', 'd3d9', 'winmm', 'gdi32', 'iphlpapi', 'shlwapi', 'wsock32', 'ws2_32', 'kernel32', 'oleaut32', 'dinput8', 'dxguid', 'ksuser', 'imm32', 'bcrypt','avrt']) + env.Append(LIBS=['mingw32', 'opengl32', 'dsound', 'ole32', 'd3d9', 'winmm', 'gdi32', 'iphlpapi', 'shlwapi', 'wsock32', 'ws2_32', 'kernel32', 'oleaut32', 'dinput8', 'dxguid', 'ksuser', 'imm32', 'bcrypt', 'avrt', 'uuid']) env.Append(CPPFLAGS=['-DMINGW_ENABLED']) diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 5e12106639..a6a947761b 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -53,6 +53,7 @@ #include <avrt.h> #include <direct.h> +#include <knownfolders.h> #include <process.h> #include <regstr.h> #include <shlobj.h> @@ -2460,7 +2461,7 @@ void OS_Windows::GetMaskBitmaps(HBITMAP hSourceBitmap, COLORREF clrTransparent, DeleteDC(hMainDC); } -Error OS_Windows::execute(const String &p_path, const List<String> &p_arguments, bool p_blocking, ProcessID *r_child_id, String *r_pipe, int *r_exitcode, bool read_stderr) { +Error OS_Windows::execute(const String &p_path, const List<String> &p_arguments, bool p_blocking, ProcessID *r_child_id, String *r_pipe, int *r_exitcode, bool read_stderr, Mutex *p_pipe_mutex) { if (p_blocking && r_pipe) { @@ -2479,7 +2480,13 @@ Error OS_Windows::execute(const String &p_path, const List<String> &p_arguments, char buf[65535]; while (fgets(buf, 65535, f)) { + if (p_pipe_mutex) { + p_pipe_mutex->lock(); + } (*r_pipe) += buf; + if (p_pipe_mutex) { + p_pipe_mutex->lock(); + } } int rv = _pclose(f); diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h index c15e1cabc3..0e0b9bf3f6 100644 --- a/platform/windows/os_windows.h +++ b/platform/windows/os_windows.h @@ -261,7 +261,7 @@ public: virtual void delay_usec(uint32_t p_usec) const; virtual uint64_t get_ticks_usec() const; - virtual Error execute(const String &p_path, const List<String> &p_arguments, bool p_blocking, ProcessID *r_child_id = NULL, String *r_pipe = NULL, int *r_exitcode = NULL, bool read_stderr = false); + virtual Error execute(const String &p_path, const List<String> &p_arguments, bool p_blocking, ProcessID *r_child_id = NULL, String *r_pipe = NULL, int *r_exitcode = NULL, bool read_stderr = false, Mutex *p_pipe_mutex = NULL); virtual Error kill(const ProcessID &p_pid); virtual int get_process_id() const; |