Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

classref: Sync with current master branch (92a8c99) #97

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions classes/class_@gdscript.rst
Original file line number Diff line number Diff line change
Expand Up @@ -950,6 +950,8 @@ Method Descriptions

:ref:`Color<class_Color>` **Color8**\ (\ r8\: :ref:`int<class_int>`, g8\: :ref:`int<class_int>`, b8\: :ref:`int<class_int>`, a8\: :ref:`int<class_int>` = 255\ ) :ref:`🔗<class_@GDScript_method_Color8>`

**Deprecated:** Use :ref:`Color.from_rgba8<class_Color_method_from_rgba8>` instead.

Returns a :ref:`Color<class_Color>` constructed from red (``r8``), green (``g8``), blue (``b8``), and optionally alpha (``a8``) integer channels, each divided by ``255.0`` for their final value. Using :ref:`Color8<class_@GDScript_method_Color8>` instead of the standard :ref:`Color<class_Color>` constructor is useful when you need to match exact color values in an :ref:`Image<class_Image>`.

::
Expand Down Expand Up @@ -1038,6 +1040,8 @@ Converts ``what`` to ``type`` in the best way possible. The ``type`` uses the :r

:ref:`Object<class_Object>` **dict_to_inst**\ (\ dictionary\: :ref:`Dictionary<class_Dictionary>`\ ) :ref:`🔗<class_@GDScript_method_dict_to_inst>`

**Deprecated:** Consider using :ref:`JSON.to_native<class_JSON_method_to_native>` or :ref:`Object.get_property_list<class_Object_method_get_property_list>` instead.

Converts a ``dictionary`` (created with :ref:`inst_to_dict<class_@GDScript_method_inst_to_dict>`) back to an Object instance. Can be useful for deserializing.

.. rst-class:: classref-item-separator
Expand Down Expand Up @@ -1083,9 +1087,9 @@ Starting from ``_ready()``, ``bar()`` would print:

:ref:`Dictionary<class_Dictionary>` **inst_to_dict**\ (\ instance\: :ref:`Object<class_Object>`\ ) :ref:`🔗<class_@GDScript_method_inst_to_dict>`

Returns the passed ``instance`` converted to a Dictionary. Can be useful for serializing.
**Deprecated:** Consider using :ref:`JSON.from_native<class_JSON_method_from_native>` or :ref:`Object.get_property_list<class_Object_method_get_property_list>` instead.

\ **Note:** Cannot be used to serialize objects with built-in scripts attached or objects allocated within built-in scripts.
Returns the passed ``instance`` converted to a Dictionary. Can be useful for serializing.

::

Expand All @@ -1102,6 +1106,10 @@ Prints out:
[@subpath, @path, foo]
[, res://test.gd, bar]

\ **Note:** This function can only be used to serialize objects with an attached :ref:`GDScript<class_GDScript>` stored in a separate file. Objects without an attached script, with a script written in another language, or with a built-in script are not supported.

\ **Note:** This function is not recursive, which means that nested objects will not be represented as dictionaries. Also, properties passed by reference (:ref:`Object<class_Object>`, :ref:`Dictionary<class_Dictionary>`, :ref:`Array<class_Array>`, and packed arrays) are copied by reference, not duplicated.

.. rst-class:: classref-item-separator

----
Expand Down
182 changes: 151 additions & 31 deletions classes/class_@globalscope.rst

Large diffs are not rendered by default.

30 changes: 15 additions & 15 deletions classes/class_array.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ An array data structure that can contain a sequence of elements of any :ref:`Var

.. code-tab:: csharp

var array = new Godot.Collections.Array{"First", 2, 3, "Last"};
Godot.Collections.Array array = ["First", 2, 3, "Last"];
GD.Print(array[0]); // Prints "First"
GD.Print(array[2]); // Prints 3
GD.Print(array[array.Count - 1]); // Prints "Last"
GD.Print(array[^1]); // Prints "Last"

array[2] = "Second";
array[1] = "Second";
GD.Print(array[1]); // Prints "Second"
GD.Print(array[array.Count - 3]); // Prints "Second"
GD.Print(array[^3]); // Prints "Second"



Expand Down Expand Up @@ -707,7 +707,7 @@ This method can often be combined with :ref:`resize<class_Array_method_resize>`

.. code-tab:: csharp

var array = new Godot.Collections.Array();
Godot.Collections.Array array = [];
array.Resize(5);
array.Fill(2);
GD.Print(array); // Prints [2, 2, 2, 2, 2]
Expand Down Expand Up @@ -784,7 +784,7 @@ Returns the index of the **first** element in the array that causes ``method`` t
return number % 2 == 0

func _ready():
print([1, 3, 4, 7].find_custom(is_even.bind())) # prints 2
print([1, 3, 4, 7].find_custom(is_even.bind())) # Prints 2



Expand Down Expand Up @@ -874,7 +874,7 @@ Returns ``true`` if the array contains the given ``value``.

.. code-tab:: csharp

var arr = new Godot.Collections.Array { "inside", 7 };
Godot.Collections.Array arr = ["inside", 7];
// By C# convention, this method is renamed to `Contains`.
GD.Print(arr.Contains("inside")); // Prints True
GD.Print(arr.Contains("outside")); // Prints False
Expand Down Expand Up @@ -1068,7 +1068,7 @@ Returns a random element from the array. Generates an error and returns ``null``

.. code-tab:: csharp

var array = new Godot.Collections.Array { 1, 2, 3.25f, "Hi" };
Godot.Collections.Array array = [1, 2, 3.25f, "Hi"];
GD.Print(array.PickRandom()); // May print 1, 2, 3.25, or "Hi".


Expand Down Expand Up @@ -1172,10 +1172,10 @@ If :ref:`max<class_Array_method_max>` is not desirable, this method may also be
::

func _ready():
var arr = [Vector2(5, 0), Vector2(3, 4), Vector2(1, 2)]
var arr = [Vector2i(5, 0), Vector2i(3, 4), Vector2i(1, 2)]

var longest_vec = arr.reduce(func(max, vec): return vec if is_length_greater(vec, max) else max)
print(longest_vec) # Prints Vector2(3, 4).
print(longest_vec) # Prints (3, 4)

func is_length_greater(a, b):
return a.length() > b.length()
Expand All @@ -1189,11 +1189,11 @@ This method can also be used to count how many elements in an array satisfy a ce

func _ready():
var arr = [1, 2, 3, 4, 5]
# Increment count if it's even, else leaves count the same.
# If the current element is even, increment count, otherwise leave count the same.
var even_count = arr.reduce(func(count, next): return count + 1 if is_even(next) else count, 0)
print(even_count) # Prints 2

See also :ref:`map<class_Array_method_map>`, :ref:`filter<class_Array_method_filter>`, :ref:`any<class_Array_method_any>` and :ref:`all<class_Array_method_all>`.
See also :ref:`map<class_Array_method_map>`, :ref:`filter<class_Array_method_filter>`, :ref:`any<class_Array_method_any>`, and :ref:`all<class_Array_method_all>`.

.. rst-class:: classref-item-separator

Expand Down Expand Up @@ -1355,7 +1355,7 @@ Sorts the array in ascending order. The final order is dependent on the "less th

.. code-tab:: csharp

var numbers = new Godot.Collections.Array { 10, 5, 2.5, 8 };
Godot.Collections.Array numbers = [10, 5, 2.5, 8];
numbers.Sort();
GD.Print(numbers); // Prints [2.5, 5, 8, 10]

Expand Down Expand Up @@ -1448,8 +1448,8 @@ Appends the ``right`` array to the left operand, creating a new **Array**. This
.. code-tab:: csharp

// Note that concatenation is not possible with C#'s native Array type.
var array1 = new Godot.Collections.Array{"One", 2};
var array2 = new Godot.Collections.Array{3, "Four"};
Godot.Collections.Array array1 = ["One", 2];
Godot.Collections.Array array2 = [3, "Four"];
GD.Print(array1 + array2); // Prints ["One", 2, 3, "Four"]


Expand Down
10 changes: 5 additions & 5 deletions classes/class_arraymesh.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,16 @@ The most basic example is the creation of a single triangle:

.. code-tab:: csharp

var vertices = new Vector3[]
{
Vector3[] vertices =
[
new Vector3(0, 1, 0),
new Vector3(1, 0, 0),
new Vector3(0, 0, 1),
};
];

// Initialize the ArrayMesh.
var arrMesh = new ArrayMesh();
var arrays = new Godot.Collections.Array();
Godot.Collections.Array arrays = [];
arrays.Resize((int)Mesh.ArrayType.Max);
arrays[(int)Mesh.ArrayType.Vertex] = vertices;

Expand Down Expand Up @@ -240,7 +240,7 @@ The ``blend_shapes`` argument is an array of vertex data for each blend shape. E

The ``lods`` argument is a dictionary with :ref:`float<class_float>` keys and :ref:`PackedInt32Array<class_PackedInt32Array>` values. Each entry in the dictionary represents an LOD level of the surface, where the value is the :ref:`Mesh.ARRAY_INDEX<class_Mesh_constant_ARRAY_INDEX>` array to use for the LOD level and the key is roughly proportional to the distance at which the LOD stats being used. I.e., increasing the key of an LOD also increases the distance that the objects has to be from the camera before the LOD is used.

The ``flags`` argument is the bitwise or of, as required: One value of :ref:`ArrayCustomFormat<enum_Mesh_ArrayCustomFormat>` left shifted by ``ARRAY_FORMAT_CUSTOMn_SHIFT`` for each custom channel in use, :ref:`Mesh.ARRAY_FLAG_USE_DYNAMIC_UPDATE<class_Mesh_constant_ARRAY_FLAG_USE_DYNAMIC_UPDATE>`, :ref:`Mesh.ARRAY_FLAG_USE_8_BONE_WEIGHTS<class_Mesh_constant_ARRAY_FLAG_USE_8_BONE_WEIGHTS>`, or :ref:`Mesh.ARRAY_FLAG_USES_EMPTY_VERTEX_ARRAY<class_Mesh_constant_ARRAY_FLAG_USES_EMPTY_VERTEX_ARRAY>`.
The ``flags`` argument is the bitwise OR of, as required: One value of :ref:`ArrayCustomFormat<enum_Mesh_ArrayCustomFormat>` left shifted by ``ARRAY_FORMAT_CUSTOMn_SHIFT`` for each custom channel in use, :ref:`Mesh.ARRAY_FLAG_USE_DYNAMIC_UPDATE<class_Mesh_constant_ARRAY_FLAG_USE_DYNAMIC_UPDATE>`, :ref:`Mesh.ARRAY_FLAG_USE_8_BONE_WEIGHTS<class_Mesh_constant_ARRAY_FLAG_USE_8_BONE_WEIGHTS>`, or :ref:`Mesh.ARRAY_FLAG_USES_EMPTY_VERTEX_ARRAY<class_Mesh_constant_ARRAY_FLAG_USES_EMPTY_VERTEX_ARRAY>`.

\ **Note:** When using indices, it is recommended to only use points, lines, or triangles.

Expand Down
4 changes: 2 additions & 2 deletions classes/class_astargrid2d.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ To use **AStarGrid2D**, you only need to set the :ref:`region<class_AStarGrid2D_
astarGrid.Region = new Rect2I(0, 0, 32, 32);
astarGrid.CellSize = new Vector2I(16, 16);
astarGrid.Update();
GD.Print(astarGrid.GetIdPath(Vector2I.Zero, new Vector2I(3, 4))); // prints (0, 0), (1, 1), (2, 2), (3, 3), (3, 4)
GD.Print(astarGrid.GetPointPath(Vector2I.Zero, new Vector2I(3, 4))); // prints (0, 0), (16, 16), (32, 32), (48, 48), (48, 64)
GD.Print(astarGrid.GetIdPath(Vector2I.Zero, new Vector2I(3, 4))); // Prints [(0, 0), (1, 1), (2, 2), (3, 3), (3, 4)]
GD.Print(astarGrid.GetPointPath(Vector2I.Zero, new Vector2I(3, 4))); // Prints [(0, 0), (16, 16), (32, 32), (48, 48), (48, 64)]



Expand Down
4 changes: 2 additions & 2 deletions classes/class_audiostreamgenerator.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ Here's a sample on how to use it to generate a sine wave:
var playback # Will hold the AudioStreamGeneratorPlayback.
@onready var sample_hz = $AudioStreamPlayer.stream.mix_rate
var pulse_hz = 440.0 # The frequency of the sound wave.
var phase = 0.0

func _ready():
$AudioStreamPlayer.play()
playback = $AudioStreamPlayer.get_stream_playback()
fill_buffer()

func fill_buffer():
var phase = 0.0
var increment = pulse_hz / sample_hz
var frames_available = playback.get_frames_available()

Expand All @@ -53,6 +53,7 @@ Here's a sample on how to use it to generate a sine wave:
private AudioStreamGeneratorPlayback _playback; // Will hold the AudioStreamGeneratorPlayback.
private float _sampleHz;
private float _pulseHz = 440.0f; // The frequency of the sound wave.
private double phase = 0.0;

public override void _Ready()
{
Expand All @@ -67,7 +68,6 @@ Here's a sample on how to use it to generate a sine wave:

public void FillBuffer()
{
double phase = 0.0;
float increment = _pulseHz / _sampleHz;
int framesAvailable = _playback.GetFramesAvailable();

Expand Down
45 changes: 45 additions & 0 deletions classes/class_audiostreammp3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ Description

MP3 audio stream driver. See :ref:`data<class_AudioStreamMP3_property_data>` if you want to load an MP3 file at run-time.

\ **Note:** This class can optionally support legacy MP1 and MP2 formats, provided that the engine is compiled with the ``minimp3_extra_formats=yes`` SCons option. These extra formats are not enabled by default.

.. rst-class:: classref-reftable-group

Properties
Expand All @@ -43,6 +45,20 @@ Properties
| :ref:`float<class_float>` | :ref:`loop_offset<class_AudioStreamMP3_property_loop_offset>` | ``0.0`` |
+-----------------------------------------------+---------------------------------------------------------------+-----------------------+

.. rst-class:: classref-reftable-group

Methods
-------

.. table::
:widths: auto

+---------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`AudioStreamMP3<class_AudioStreamMP3>` | :ref:`load_from_buffer<class_AudioStreamMP3_method_load_from_buffer>`\ (\ stream_data\: :ref:`PackedByteArray<class_PackedByteArray>`\ ) |static| |
+---------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`AudioStreamMP3<class_AudioStreamMP3>` | :ref:`load_from_file<class_AudioStreamMP3_method_load_from_file>`\ (\ path\: :ref:`String<class_String>`\ ) |static| |
+---------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+

.. rst-class:: classref-section-separator

----
Expand Down Expand Up @@ -183,6 +199,35 @@ If ``true``, the stream will automatically loop when it reaches the end.

Time in seconds at which the stream starts after being looped.

.. rst-class:: classref-section-separator

----

.. rst-class:: classref-descriptions-group

Method Descriptions
-------------------

.. _class_AudioStreamMP3_method_load_from_buffer:

.. rst-class:: classref-method

:ref:`AudioStreamMP3<class_AudioStreamMP3>` **load_from_buffer**\ (\ stream_data\: :ref:`PackedByteArray<class_PackedByteArray>`\ ) |static| :ref:`🔗<class_AudioStreamMP3_method_load_from_buffer>`

Creates a new **AudioStreamMP3** instance from the given buffer. The buffer must contain MP3 data.

.. rst-class:: classref-item-separator

----

.. _class_AudioStreamMP3_method_load_from_file:

.. rst-class:: classref-method

:ref:`AudioStreamMP3<class_AudioStreamMP3>` **load_from_file**\ (\ path\: :ref:`String<class_String>`\ ) |static| :ref:`🔗<class_AudioStreamMP3_method_load_from_file>`

Creates a new **AudioStreamMP3** instance from the given file path. The file must be in MP3 format.

.. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
.. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
.. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
Expand Down
16 changes: 8 additions & 8 deletions classes/class_audiostreamoggvorbis.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ Methods
.. table::
:widths: auto

+---------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`AudioStreamOggVorbis<class_AudioStreamOggVorbis>` | :ref:`load_from_buffer<class_AudioStreamOggVorbis_method_load_from_buffer>`\ (\ buffer\: :ref:`PackedByteArray<class_PackedByteArray>`\ ) |static| |
+---------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`AudioStreamOggVorbis<class_AudioStreamOggVorbis>` | :ref:`load_from_file<class_AudioStreamOggVorbis_method_load_from_file>`\ (\ path\: :ref:`String<class_String>`\ ) |static| |
+---------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------+
+---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`AudioStreamOggVorbis<class_AudioStreamOggVorbis>` | :ref:`load_from_buffer<class_AudioStreamOggVorbis_method_load_from_buffer>`\ (\ stream_data\: :ref:`PackedByteArray<class_PackedByteArray>`\ ) |static| |
+---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`AudioStreamOggVorbis<class_AudioStreamOggVorbis>` | :ref:`load_from_file<class_AudioStreamOggVorbis_method_load_from_file>`\ (\ path\: :ref:`String<class_String>`\ ) |static| |
+---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+

.. rst-class:: classref-section-separator

Expand Down Expand Up @@ -190,9 +190,9 @@ Method Descriptions

.. rst-class:: classref-method

:ref:`AudioStreamOggVorbis<class_AudioStreamOggVorbis>` **load_from_buffer**\ (\ buffer\: :ref:`PackedByteArray<class_PackedByteArray>`\ ) |static| :ref:`🔗<class_AudioStreamOggVorbis_method_load_from_buffer>`
:ref:`AudioStreamOggVorbis<class_AudioStreamOggVorbis>` **load_from_buffer**\ (\ stream_data\: :ref:`PackedByteArray<class_PackedByteArray>`\ ) |static| :ref:`🔗<class_AudioStreamOggVorbis_method_load_from_buffer>`

Creates a new AudioStreamOggVorbis instance from the given buffer. The buffer must contain Ogg Vorbis data.
Creates a new **AudioStreamOggVorbis** instance from the given buffer. The buffer must contain Ogg Vorbis data.

.. rst-class:: classref-item-separator

Expand All @@ -204,7 +204,7 @@ Creates a new AudioStreamOggVorbis instance from the given buffer. The buffer mu

:ref:`AudioStreamOggVorbis<class_AudioStreamOggVorbis>` **load_from_file**\ (\ path\: :ref:`String<class_String>`\ ) |static| :ref:`🔗<class_AudioStreamOggVorbis_method_load_from_file>`

Creates a new AudioStreamOggVorbis instance from the given file path. The file must be in Ogg Vorbis format.
Creates a new **AudioStreamOggVorbis** instance from the given file path. The file must be in Ogg Vorbis format.

.. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
.. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
Expand Down
2 changes: 1 addition & 1 deletion classes/class_audiostreamsynchronized.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Stream that can be fitted with sub-streams, which will be played in-sync.
Description
-----------

This is a stream that can be fitted with sub-streams, which will be played in-sync. The streams being at exactly the same time when play is pressed, and will end when the last of them ends. If one of the sub-streams loops, then playback will continue.
This is a stream that can be fitted with sub-streams, which will be played in-sync. The streams begin at exactly the same time when play is pressed, and will end when the last of them ends. If one of the sub-streams loops, then playback will continue.

.. rst-class:: classref-reftable-group

Expand Down
Loading