diff options
Diffstat (limited to 'doc/classes')
-rw-r--r-- | doc/classes/DirAccess.xml | 93 | ||||
-rw-r--r-- | doc/classes/FileAccess.xml | 1 | ||||
-rw-r--r-- | doc/classes/ImageFormatLoader.xml | 19 | ||||
-rw-r--r-- | doc/classes/ImageFormatLoaderExtension.xml | 42 | ||||
-rw-r--r-- | doc/classes/StreamPeerGZIP.xml | 42 |
5 files changed, 185 insertions, 12 deletions
diff --git a/doc/classes/DirAccess.xml b/doc/classes/DirAccess.xml index de2e32b17b..cb7bf56f11 100644 --- a/doc/classes/DirAccess.xml +++ b/doc/classes/DirAccess.xml @@ -6,6 +6,15 @@ <description> Directory type. It is used to manage directories and their content (not restricted to the project folder). [DirAccess] can't be instantiated directly. Instead it is created with a static method that takes a path for which it will be opened. + Most of the methods have a static alternative that can be used without creating a [DirAccess]. Static methods only support absolute paths (including [code]res://[/code] and [code]user://[/code]). + [codeblock] + # Standard + var dir = Directory.new() + dir.open("user://levels") + dir.make_dir("world1") + # Static + Directory.make_dir_absolute("user://levels/world1") + [/codeblock] [b]Note:[/b] Many resources types are imported (e.g. textures or sound files), and their source asset will not be included in the exported game, as only the imported version is used. Use [ResourceLoader] to access imported resources. Here is an example on how to iterate through the files of a directory: [codeblocks] @@ -59,7 +68,7 @@ <methods> <method name="change_dir"> <return type="int" enum="Error" /> - <param index="0" name="todir" type="String" /> + <param index="0" name="to_dir" type="String" /> <description> Changes the currently opened directory to the one passed as an argument. The argument can be relative to the current directory (e.g. [code]newdir[/code] or [code]../newdir[/code]), or an absolute path (e.g. [code]/tmp/newdir[/code] or [code]res://somedir/newdir[/code]). Returns one of the [enum Error] code constants ([code]OK[/code] on success). @@ -76,6 +85,15 @@ Returns one of the [enum Error] code constants ([code]OK[/code] on success). </description> </method> + <method name="copy_absolute" qualifiers="static"> + <return type="int" enum="Error" /> + <param index="0" name="from" type="String" /> + <param index="1" name="to" type="String" /> + <param index="2" name="chmod_flags" type="int" default="-1" /> + <description> + Static version of [method copy]. Supports only absolute paths. + </description> + </method> <method name="current_is_dir" qualifiers="const"> <return type="bool" /> <description> @@ -87,7 +105,13 @@ <param index="0" name="path" type="String" /> <description> Returns whether the target directory exists. The argument can be relative to the current directory, or an absolute path. - If the [DirAccess] is not open, the path is relative to [code]res://[/code]. + </description> + </method> + <method name="dir_exists_absolute" qualifiers="static"> + <return type="bool" /> + <param index="0" name="path" type="String" /> + <description> + Static version of [method dir_exists]. Supports only absolute paths. </description> </method> <method name="file_exists"> @@ -95,7 +119,7 @@ <param index="0" name="path" type="String" /> <description> Returns whether the target file exists. The argument can be relative to the current directory, or an absolute path. - If the [DirAccess] is not open, the path is relative to [code]res://[/code]. + For a static equivalent, use [method FileAccess.file_exists]. </description> </method> <method name="get_current_dir" qualifiers="const"> @@ -108,7 +132,7 @@ <method name="get_current_drive"> <return type="int" /> <description> - Returns the currently opened directory's drive index. See [method get_drive] to convert returned index to the name of the drive. + Returns the currently opened directory's drive index. See [method get_drive_name] to convert returned index to the name of the drive. </description> </method> <method name="get_directories"> @@ -118,17 +142,15 @@ Affected by [member include_hidden] and [member include_navigational]. </description> </method> - <method name="get_drive"> - <return type="String" /> - <param index="0" name="idx" type="int" /> + <method name="get_directories_at" qualifiers="static"> + <return type="PackedStringArray" /> + <param index="0" name="path" type="String" /> <description> - On Windows, returns the name of the drive (partition) passed as an argument (e.g. [code]C:[/code]). - On macOS, returns the path to the mounted volume passed as an argument. - On Linux, returns the path to the mounted volume or GTK 3 bookmark passed as an argument. - On other platforms, or if the requested drive does not exist, the method returns an empty String. + Returns a [PackedStringArray] containing filenames of the directory contents, excluding files, at the given [param path]. The array is sorted alphabetically. + Use [method get_directories] if you want more control of what gets included. </description> </method> - <method name="get_drive_count"> + <method name="get_drive_count" qualifiers="static"> <return type="int" /> <description> On Windows, returns the number of drives (partitions) mounted on the current filesystem. @@ -137,6 +159,16 @@ On other platforms, the method returns 0. </description> </method> + <method name="get_drive_name" qualifiers="static"> + <return type="String" /> + <param index="0" name="idx" type="int" /> + <description> + On Windows, returns the name of the drive (partition) passed as an argument (e.g. [code]C:[/code]). + On macOS, returns the path to the mounted volume passed as an argument. + On Linux, returns the path to the mounted volume or GTK 3 bookmark passed as an argument. + On other platforms, or if the requested drive does not exist, the method returns an empty String. + </description> + </method> <method name="get_files"> <return type="PackedStringArray" /> <description> @@ -144,6 +176,14 @@ Affected by [member include_hidden]. </description> </method> + <method name="get_files_at" qualifiers="static"> + <return type="PackedStringArray" /> + <param index="0" name="path" type="String" /> + <description> + Returns a [PackedStringArray] containing filenames of the directory contents, excluding directories, at the given [param path]. The array is sorted alphabetically. + Use [method get_files] if you want more control of what gets included. + </description> + </method> <method name="get_next"> <return type="String" /> <description> @@ -185,6 +225,13 @@ Returns one of the [enum Error] code constants ([code]OK[/code] on success). </description> </method> + <method name="make_dir_absolute" qualifiers="static"> + <return type="int" enum="Error" /> + <param index="0" name="path" type="String" /> + <description> + Static version of [method make_dir]. Supports only absolute paths. + </description> + </method> <method name="make_dir_recursive"> <return type="int" enum="Error" /> <param index="0" name="path" type="String" /> @@ -193,6 +240,13 @@ Returns one of the [enum Error] code constants ([code]OK[/code] on success). </description> </method> + <method name="make_dir_recursive_absolute" qualifiers="static"> + <return type="int" enum="Error" /> + <param index="0" name="path" type="String" /> + <description> + Static version of [method make_dir_recursive]. Supports only absolute paths. + </description> + </method> <method name="open" qualifiers="static"> <return type="DirAccess" /> <param index="0" name="path" type="String" /> @@ -210,6 +264,13 @@ Returns one of the [enum Error] code constants ([code]OK[/code] on success). </description> </method> + <method name="remove_absolute" qualifiers="static"> + <return type="int" enum="Error" /> + <param index="0" name="path" type="String" /> + <description> + Static version of [method remove]. Supports only absolute paths. + </description> + </method> <method name="rename"> <return type="int" enum="Error" /> <param index="0" name="from" type="String" /> @@ -219,6 +280,14 @@ Returns one of the [enum Error] code constants ([code]OK[/code] on success). </description> </method> + <method name="rename_absolute" qualifiers="static"> + <return type="int" enum="Error" /> + <param index="0" name="from" type="String" /> + <param index="1" name="to" type="String" /> + <description> + Static version of [method rename]. Supports only absolute paths. + </description> + </method> </methods> <members> <member name="include_hidden" type="bool" setter="set_include_hidden" getter="get_include_hidden"> diff --git a/doc/classes/FileAccess.xml b/doc/classes/FileAccess.xml index 32f6a1dd3e..adc0f4c3dd 100644 --- a/doc/classes/FileAccess.xml +++ b/doc/classes/FileAccess.xml @@ -77,6 +77,7 @@ <description> Returns [code]true[/code] if the file exists in the given path. [b]Note:[/b] Many resources types are imported (e.g. textures or sound files), and their source asset will not be included in the exported game, as only the imported version is used. See [method ResourceLoader.exists] for an alternative approach that takes resource remapping into account. + For a non-static, relative equivalent, use [method DirAccess.file_exists]. </description> </method> <method name="flush"> diff --git a/doc/classes/ImageFormatLoader.xml b/doc/classes/ImageFormatLoader.xml new file mode 100644 index 0000000000..c6b1ec922a --- /dev/null +++ b/doc/classes/ImageFormatLoader.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="ImageFormatLoader" inherits="RefCounted" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd"> + <brief_description> + Base class to add support for specific image formats. + </brief_description> + <description> + The engine supports multiple image formats out of the box (PNG, SVG, JPEG, WebP to name a few), but you can choose to implement support for additional image formats by extending [ImageFormatLoaderExtension]. + </description> + <tutorials> + </tutorials> + <constants> + <constant name="FLAG_NONE" value="0" enum="LoaderFlags" is_bitfield="true"> + </constant> + <constant name="FLAG_FORCE_LINEAR" value="1" enum="LoaderFlags" is_bitfield="true"> + </constant> + <constant name="FLAG_CONVERT_COLORS" value="2" enum="LoaderFlags" is_bitfield="true"> + </constant> + </constants> +</class> diff --git a/doc/classes/ImageFormatLoaderExtension.xml b/doc/classes/ImageFormatLoaderExtension.xml new file mode 100644 index 0000000000..b2a7ebc60f --- /dev/null +++ b/doc/classes/ImageFormatLoaderExtension.xml @@ -0,0 +1,42 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="ImageFormatLoaderExtension" inherits="ImageFormatLoader" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd"> + <brief_description> + Base class for creating [ImageFormatLoader] extensions (adding support for extra image formats). + </brief_description> + <description> + The engine supports multiple image formats out of the box (PNG, SVG, JPEG, WebP to name a few), but you can choose to implement support for additional image formats by extending this class. + Be sure to respect the documented return types and values. You should create an instance of it, and call [method add_format_loader] to register that loader during the initializaiton phase. + </description> + <tutorials> + </tutorials> + <methods> + <method name="_get_recognized_extensions" qualifiers="virtual const"> + <return type="PackedStringArray" /> + <description> + Returns the list of file extensions for this image format. Files with the given extentions will be treated as image file and loaded using this class. + </description> + </method> + <method name="_load_image" qualifiers="virtual"> + <return type="int" enum="Error" /> + <param index="0" name="image" type="Image" /> + <param index="1" name="fileaccess" type="FileAccess" /> + <param index="2" name="flags" type="int" enum="ImageFormatLoader.LoaderFlags" /> + <param index="3" name="scale" type="float" /> + <description> + Loads the content of [param fileaccess] into the provided [param image]. + </description> + </method> + <method name="add_format_loader"> + <return type="void" /> + <description> + Add this format loader to the engine, allowing it to recognize the file extensions returned by [method _get_recognized_extensions]. + </description> + </method> + <method name="remove_format_loader"> + <return type="void" /> + <description> + Remove this format loader from the engine. + </description> + </method> + </methods> +</class> diff --git a/doc/classes/StreamPeerGZIP.xml b/doc/classes/StreamPeerGZIP.xml new file mode 100644 index 0000000000..71dd36160d --- /dev/null +++ b/doc/classes/StreamPeerGZIP.xml @@ -0,0 +1,42 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="StreamPeerGZIP" inherits="StreamPeer" is_experimental="true" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd"> + <brief_description> + Stream peer handling GZIP and deflate compression/decompresison. + </brief_description> + <description> + This class allows to compress or decompress data using GZIP/deflate in a streaming fashion. This is particularly useful when compressing or decompressing files that has to be sent through the network without having to allocate them all in memory. + After starting the stream via [method start_compression] (or [method start_decompression]), calling [method StreamPeer.put_partial_data] on this stream will compress (or decompress) the data, writing it to the internal buffer. Calling [method StreamPeer.get_available_bytes] will return the pending bytes in the internal buffer, and [method StreamPeer.get_partial_data] will retrieve the compressed (or decompressed) bytes from it. When the stream is over, you must call [method finish] to ensure the internal buffer is properly flushed (make sure to call [method StreamPeer.get_available_bytes] on last time to check if more data needs to be read after that). + </description> + <tutorials> + </tutorials> + <methods> + <method name="clear"> + <return type="void" /> + <description> + Clears this stream, resetting the internal state. + </description> + </method> + <method name="finish"> + <return type="int" enum="Error" /> + <description> + Finalizes the stream, compressing or decompressing any buffered chunk left. + </description> + </method> + <method name="start_compression"> + <return type="int" enum="Error" /> + <param index="0" name="use_deflate" type="bool" default="false" /> + <param index="1" name="buffer_size" type="int" default="65535" /> + <description> + Start the stream in compression mode with the given [param buffer_size], if [param use_deflate] is [code]true[/code] uses deflate instead of GZIP. + </description> + </method> + <method name="start_decompression"> + <return type="int" enum="Error" /> + <param index="0" name="use_deflate" type="bool" default="false" /> + <param index="1" name="buffer_size" type="int" default="65535" /> + <description> + Start the stream in decompression mode with the given [param buffer_size], if [param use_deflate] is [code]true[/code] uses deflate instead of GZIP. + </description> + </method> + </methods> +</class> |