Skip to content

Commit

Permalink
Merge pull request #10469 from godotengine/classref/sync-bdf625b
Browse files Browse the repository at this point in the history
classref: Sync with current master branch (bdf625b)
  • Loading branch information
mhilbrunner authored Jan 5, 2025
2 parents cb6eb02 + eab235f commit 2cf3938
Show file tree
Hide file tree
Showing 37 changed files with 485 additions and 334 deletions.
2 changes: 2 additions & 0 deletions classes/[email protected]
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
58 changes: 29 additions & 29 deletions classes/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -5767,9 +5767,9 @@ Returns a human-readable name for the given :ref:`Error<enum_@GlobalScope_Error>
::

print(OK) # Prints 0
print(error_string(OK)) # Prints OK
print(error_string(ERR_BUSY)) # Prints Busy
print(error_string(ERR_OUT_OF_MEMORY)) # Prints Out of memory
print(error_string(OK)) # Prints "OK"
print(error_string(ERR_BUSY)) # Prints "Busy"
print(error_string(ERR_OUT_OF_MEMORY)) # Prints "Out of memory"

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

Expand Down Expand Up @@ -5934,24 +5934,24 @@ Returns the :ref:`Object<class_Object>` that corresponds to ``instance_id``. All

.. code-tab:: gdscript

var foo = "bar"
var drink = "water"

func _ready():
var id = get_instance_id()
var inst = instance_from_id(id)
print(inst.foo) # Prints bar
var instance = instance_from_id(id)
print(instance.foo) # Prints "water"

.. code-tab:: csharp

public partial class MyNode : Node
{
public string Foo { get; set; } = "bar";
public string Drink { get; set; } = "water";

public override void _Ready()
{
ulong id = GetInstanceId();
var inst = (MyNode)InstanceFromId(Id);
GD.Print(inst.Foo); // Prints bar
var instance = (MyNode)InstanceFromId(Id);
GD.Print(instance.Drink); // Prints "water"
}
}

Expand Down Expand Up @@ -6448,12 +6448,12 @@ Converts one or more arguments of any type to string in the best way possible an
.. code-tab:: gdscript

var a = [1, 2, 3]
print("a", "b", a) # Prints ab[1, 2, 3]
print("a", "b", a) # Prints "ab[1, 2, 3]"

.. code-tab:: csharp

Godot.Collections.Array a = [1, 2, 3];
GD.Print("a", "b", a); // Prints ab[1, 2, 3]
GD.Print("a", "b", a); // Prints "ab[1, 2, 3]"



Expand Down Expand Up @@ -6482,11 +6482,11 @@ When printing to standard output, the supported subset of BBCode is converted to

.. code-tab:: gdscript

print_rich("[color=green][b]Hello world![/b][/color]") # Prints out "Hello world!" in green with a bold font
print_rich("[color=green][b]Hello world![/b][/color]") # Prints "Hello world!", in green with a bold font.

.. code-tab:: csharp

GD.PrintRich("[color=green][b]Hello world![/b][/color]"); // Prints out "Hello world!" in green with a bold font
GD.PrintRich("[color=green][b]Hello world![/b][/color]"); // Prints "Hello world!", in green with a bold font.



Expand Down Expand Up @@ -6552,17 +6552,17 @@ Prints one or more arguments to strings in the best way possible to the OS termi

.. code-tab:: gdscript

# Prints "ABC" to terminal.
printraw("A")
printraw("B")
printraw("C")
# Prints ABC to terminal

.. code-tab:: csharp

// Prints "ABC" to terminal.
GD.PrintRaw("A");
GD.PrintRaw("B");
GD.PrintRaw("C");
// Prints ABC to terminal



Expand All @@ -6583,11 +6583,11 @@ Prints one or more arguments to the console with a space between each argument.

.. code-tab:: gdscript

prints("A", "B", "C") # Prints A B C
prints("A", "B", "C") # Prints "A B C"

.. code-tab:: csharp

GD.PrintS("A", "B", "C"); // Prints A B C
GD.PrintS("A", "B", "C"); // Prints "A B C"



Expand All @@ -6608,11 +6608,11 @@ Prints one or more arguments to the console with a tab between each argument.

.. code-tab:: gdscript

printt("A", "B", "C") # Prints A B C
printt("A", "B", "C") # Prints "A B C"

.. code-tab:: csharp

GD.PrintT("A", "B", "C"); // Prints A B C
GD.PrintT("A", "B", "C"); // Prints "A B C"



Expand All @@ -6633,11 +6633,11 @@ Pushes an error message to Godot's built-in debugger and to the OS terminal.

.. code-tab:: gdscript

push_error("test error") # Prints "test error" to debugger and terminal as error call
push_error("test error") # Prints "test error" to debugger and terminal as an error.

.. code-tab:: csharp

GD.PushError("test error"); // Prints "test error" to debugger and terminal as error call
GD.PushError("test error"); // Prints "test error" to debugger and terminal as an error.



Expand All @@ -6660,11 +6660,11 @@ Pushes a warning message to Godot's built-in debugger and to the OS terminal.

.. code-tab:: gdscript

push_warning("test warning") # Prints "test warning" to debugger and terminal as warning call
push_warning("test warning") # Prints "test warning" to debugger and terminal as a warning.

.. code-tab:: csharp

GD.PushWarning("test warning"); // Prints "test warning" to debugger and terminal as warning call
GD.PushWarning("test warning"); // Prints "test warning" to debugger and terminal as a warning.



Expand Down Expand Up @@ -7337,9 +7337,9 @@ Returns a human-readable name of the given ``type``, using the :ref:`Variant.Typ

::

print(TYPE_INT) # Prints 2.
print(type_string(TYPE_INT)) # Prints "int".
print(type_string(TYPE_STRING)) # Prints "String".
print(TYPE_INT) # Prints 2
print(type_string(TYPE_INT)) # Prints "int"
print(type_string(TYPE_STRING)) # Prints "String"

See also :ref:`typeof<class_@GlobalScope_method_typeof>`.

Expand All @@ -7360,10 +7360,10 @@ Returns the internal type of the given ``variable``, using the :ref:`Variant.Typ
var json = JSON.new()
json.parse('["a", "b", "c"]')
var result = json.get_data()
if typeof(result) == TYPE_ARRAY:
print(result[0]) # Prints a
if result is Array:
print(result[0]) # Prints "a"
else:
print("Unexpected result")
print("Unexpected result!")

See also :ref:`type_string<class_@GlobalScope_method_type_string>`.

Expand Down
10 changes: 5 additions & 5 deletions classes/class_array.rst
Original file line number Diff line number Diff line change
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 @@ -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
2 changes: 1 addition & 1 deletion classes/class_arraymesh.rst
Original file line number Diff line number Diff line change
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: 3 additions & 1 deletion classes/class_basis.rst
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,9 @@ Creates a new **Basis** with a rotation such that the forward axis (-Z) points t

By default, the -Z axis (camera forward) is treated as forward (implies +X is right). If ``use_model_front`` is ``true``, the +Z axis (asset front) is treated as forward (implies +X is left) and points toward the ``target`` position.

The up axis (+Y) points as close to the ``up`` vector as possible while staying perpendicular to the forward axis. The returned basis is orthonormalized (see :ref:`orthonormalized<class_Basis_method_orthonormalized>`). The ``target`` and ``up`` vectors cannot be :ref:`Vector3.ZERO<class_Vector3_constant_ZERO>`, and cannot be parallel to each other.
The up axis (+Y) points as close to the ``up`` vector as possible while staying perpendicular to the forward axis. The returned basis is orthonormalized (see :ref:`orthonormalized<class_Basis_method_orthonormalized>`).

The ``target`` and the ``up`` cannot be :ref:`Vector3.ZERO<class_Vector3_constant_ZERO>`, and shouldn't be colinear to avoid unintended rotation around local Z axis.

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

Expand Down
6 changes: 3 additions & 3 deletions classes/class_callable.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Description
func test():
var callable = Callable(self, "print_args")
callable.call("hello", "world") # Prints "hello world ".
callable.call(Vector2.UP, 42, callable) # Prints "(0.0, -1.0) 42 Node(node.gd)::print_args".
callable.call(Vector2.UP, 42, callable) # Prints "(0.0, -1.0) 42 Node(node.gd)::print_args"
callable.call("invalid") # Invalid call, should have at least 2 arguments.

.. code-tab:: csharp
Expand All @@ -46,7 +46,7 @@ Description
// Invalid calls fail silently.
Callable callable = new Callable(this, MethodName.PrintArgs);
callable.Call("hello", "world"); // Default parameter values are not supported, should have 3 arguments.
callable.Call(Vector2.Up, 42, callable); // Prints "(0, -1) 42 Node(Node.cs)::PrintArgs".
callable.Call(Vector2.Up, 42, callable); // Prints "(0, -1) 42 Node(Node.cs)::PrintArgs"
callable.Call("invalid"); // Invalid call, should have 3 arguments.
}

Expand All @@ -60,7 +60,7 @@ In GDScript, it's possible to create lambda functions within a method. Lambda fu
var my_lambda = func (message):
print(message)
# Prints Hello everyone!
# Prints "Hello everyone!"
my_lambda.call("Hello everyone!")
# Prints "Attack!", when the button_pressed signal is emitted.
Expand Down
22 changes: 22 additions & 0 deletions classes/class_color.rst
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ Methods
+-----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Color<class_Color>` | :ref:`from_ok_hsl<class_Color_method_from_ok_hsl>`\ (\ h\: :ref:`float<class_float>`, s\: :ref:`float<class_float>`, l\: :ref:`float<class_float>`, alpha\: :ref:`float<class_float>` = 1.0\ ) |static| |
+-----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Color<class_Color>` | :ref:`from_rgba8<class_Color_method_from_rgba8>`\ (\ r8\: :ref:`int<class_int>`, g8\: :ref:`int<class_int>`, b8\: :ref:`int<class_int>`, a8\: :ref:`int<class_int>` = 255\ ) |static| |
+-----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Color<class_Color>` | :ref:`from_rgbe9995<class_Color_method_from_rgbe9995>`\ (\ rgbe\: :ref:`int<class_int>`\ ) |static| |
+-----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Color<class_Color>` | :ref:`from_string<class_Color_method_from_string>`\ (\ str\: :ref:`String<class_String>`, default\: :ref:`Color<class_Color>`\ ) |static| |
Expand Down Expand Up @@ -1789,6 +1791,26 @@ Constructs a color from an `OK HSL profile <https://bottosson.github.io/posts/co



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

----

.. _class_Color_method_from_rgba8:

.. rst-class:: classref-method

:ref:`Color<class_Color>` **from_rgba8**\ (\ r8\: :ref:`int<class_int>`, g8\: :ref:`int<class_int>`, b8\: :ref:`int<class_int>`, a8\: :ref:`int<class_int>` = 255\ ) |static| :ref:`🔗<class_Color_method_from_rgba8>`

Returns a **Color** constructed from red (``r8``), green (``g8``), blue (``b8``), and optionally alpha (``a8``) integer channels, each divided by ``255.0`` for their final value.

::

var red = Color.from_rgba8(255, 0, 0) # Same as Color(1, 0, 0).
var dark_blue = Color.from_rgba8(0, 0, 51) # Same as Color(0, 0, 0.2).
var my_color = Color.from_rgba8(306, 255, 0, 102) # Same as Color(1.2, 1, 0, 0.4).

\ **Note:** Due to the lower precision of :ref:`from_rgba8<class_Color_method_from_rgba8>` compared to the standard **Color** constructor, a color created with :ref:`from_rgba8<class_Color_method_from_rgba8>` will generally not be equal to the same color created with the standard **Color** constructor. Use :ref:`is_equal_approx<class_Color_method_is_equal_approx>` for comparisons to avoid issues with floating-point precision error.

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

----
Expand Down
2 changes: 1 addition & 1 deletion classes/class_editorcontextmenuplugin.rst
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ Add a submenu to the context menu of the plugin's specified slot. The submenu is
popup_menu.add_item("White")
popup_menu.id_pressed.connect(_on_color_submenu_option)
add_context_menu_item("Set Node Color", popup_menu)
add_context_submenu_item("Set Node Color", popup_menu)

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

Expand Down
Loading

0 comments on commit 2cf3938

Please sign in to comment.