Merge pull request #5380 from vnen/string-canvasitem-docs

Documentation for String and CanvasItem
This commit is contained in:
Rémi Verschelde 2016-06-24 21:16:20 +02:00 committed by GitHub
commit d52fa2e0eb
5 changed files with 79 additions and 21 deletions

View File

@ -2416,6 +2416,23 @@ Vector<uint8_t> String::md5_buffer() const {
return ret;
};
Vector<uint8_t> String::sha256_buffer() const {
CharString cs = utf8();
unsigned char hash[32];
sha256_context ctx;
sha256_init(&ctx);
sha256_hash(&ctx, (unsigned char*)cs.ptr(), cs.length());
sha256_done(&ctx, hash);
Vector<uint8_t> ret;
ret.resize(32);
for (int i = 0; i < 32; i++) {
ret[i] = hash[i];
}
return ret;
}
String String::insert(int p_at_pos,String p_string) const {

View File

@ -196,6 +196,7 @@ public:
String md5_text() const;
String sha256_text() const;
Vector<uint8_t> md5_buffer() const;
Vector<uint8_t> sha256_buffer() const;
inline bool empty() const { return length() == 0; }

View File

@ -271,6 +271,7 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var
VCALL_LOCALMEM0R(String,md5_text);
VCALL_LOCALMEM0R(String,sha256_text);
VCALL_LOCALMEM0R(String,md5_buffer);
VCALL_LOCALMEM0R(String,sha256_buffer);
VCALL_LOCALMEM0R(String,empty);
VCALL_LOCALMEM0R(String,is_abs_path);
VCALL_LOCALMEM0R(String,is_rel_path);
@ -1322,6 +1323,7 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl
ADDFUNC0(STRING,STRING,String,md5_text,varray());
ADDFUNC0(STRING,STRING,String,sha256_text,varray());
ADDFUNC0(STRING,RAW_ARRAY,String,md5_buffer,varray());
ADDFUNC0(STRING,RAW_ARRAY,String,sha256_buffer,varray());
ADDFUNC0(STRING,BOOL,String,empty,varray());
ADDFUNC0(STRING,BOOL,String,is_abs_path,varray());
ADDFUNC0(STRING,BOOL,String,is_rel_path,varray());

View File

@ -7059,8 +7059,11 @@
Draw a textured rectangle region at a given position, optionally modulated by a color. Transpose swaps the x and y coordinates when reading the texture.
</description>
</method>
<method name="edit_get" qualifiers="const">
<method name="edit_get_state" qualifiers="const">
<return type="Variant">
</return>
<description>
Used for editing, returns an opaque value representing the transform state.
</description>
</method>
<method name="edit_rotate">
@ -7080,7 +7083,7 @@
<argument index="0" name="state" type="Variant">
</argument>
<description>
Used for editing, returns an opaque value representing the transform state.
Set the transform state of this CanvasItem. For [Node2D], this is an [Array] with (in order) a [Vector2] for position, a float for rotation and another [Vector2] for scale. For [Control] this is a [Rect2] with the position and size.
</description>
</method>
<method name="get_blend_mode" qualifiers="const">
@ -7094,6 +7097,7 @@
<return type="RID">
</return>
<description>
Return the [RID] of the [World2D] canvas where this item is in.
</description>
</method>
<method name="get_canvas_item" qualifiers="const">
@ -7107,55 +7111,63 @@
<return type="Matrix32">
</return>
<description>
Get the transform matrix of this item's canvas.
</description>
</method>
<method name="get_global_mouse_pos" qualifiers="const">
<return type="Vector2">
</return>
<description>
Get the global position of the mouse.
</description>
</method>
<method name="get_global_transform" qualifiers="const">
<return type="Matrix32">
</return>
<description>
Get the global transform matrix of this item.
</description>
</method>
<method name="get_global_transform_with_canvas" qualifiers="const">
<return type="Matrix32">
</return>
<description>
Get the global transform matrix of this item in relation to the canvas.
</description>
</method>
<method name="get_item_and_children_rect" qualifiers="const">
<return type="Rect2">
</return>
<description>
Get a [Rect2] with the boundaries of this item and its children.
</description>
</method>
<method name="get_item_rect" qualifiers="const">
<return type="Rect2">
</return>
<description>
Return a rect containing the editable contents of the item.
Return a rect containing the editable boundaries of the item.
</description>
</method>
<method name="get_light_mask" qualifiers="const">
<return type="int">
</return>
<description>
Get this item's light mask number.
</description>
</method>
<method name="get_local_mouse_pos" qualifiers="const">
<return type="Vector2">
</return>
<description>
Get the mouse position relative to this item's position.
</description>
</method>
<method name="get_material" qualifiers="const">
<return type="CanvasItemMaterial">
</return>
<description>
Get the material of this item.
</description>
</method>
<method name="get_opacity" qualifiers="const">
@ -7176,30 +7188,35 @@
<return type="Matrix32">
</return>
<description>
Get the transform matrix of this item.
</description>
</method>
<method name="get_use_parent_material" qualifiers="const">
<return type="bool">
</return>
<description>
Get whether this item uses its parent's material.
</description>
</method>
<method name="get_viewport_rect" qualifiers="const">
<return type="Rect2">
</return>
<description>
Get the viewport's boundaries as a [Rect2].
</description>
</method>
<method name="get_viewport_transform" qualifiers="const">
<return type="Matrix32">
</return>
<description>
Get this item's transform in relation to the viewport.
</description>
</method>
<method name="get_world_2d" qualifiers="const">
<return type="Object">
</return>
<description>
Get the [World2D] where this item is in.
</description>
</method>
<method name="hide">
@ -7241,13 +7258,14 @@
<argument index="0" name="event" type="InputEvent">
</argument>
<description>
Takes a global input event and convert to this item's coordinate system.
</description>
</method>
<method name="set_as_toplevel">
<argument index="0" name="enable" type="bool">
</argument>
<description>
Set as toplevel. This means that it will not inherit transform from parent canvas items.
Set as top level. This means that it will not inherit transform from parent canvas items.
</description>
</method>
<method name="set_blend_mode">
@ -7261,25 +7279,28 @@
<argument index="0" name="enable" type="bool">
</argument>
<description>
Sets whether the canvas item is drawn behind its parent.
Set whether the canvas item is drawn behind its parent.
</description>
</method>
<method name="set_hidden">
<argument index="0" name="hidden" type="bool">
</argument>
<description>
Set whether this item should be hidden or not. Note that no matter what is set here this item won't be shown if its parent or grandparents nodes are also hidden. A hidden CanvasItem make all children hidden too.
</description>
</method>
<method name="set_light_mask">
<argument index="0" name="light_mask" type="int">
</argument>
<description>
Set the ligtht mask number of this item.
</description>
</method>
<method name="set_material">
<argument index="0" name="material" type="CanvasItemMaterial">
</argument>
<description>
Set the material of this item.
</description>
</method>
<method name="set_opacity">
@ -7300,6 +7321,7 @@
<argument index="0" name="enable" type="bool">
</argument>
<description>
Set whether or not this item should use its parent's material.
</description>
</method>
<method name="show">
@ -7309,7 +7331,7 @@
</method>
<method name="update">
<description>
Queue the CanvasItem for update. NOTIFICATION_DRAW will be called on idle time to request redraw.
Queue the CanvasItem for update. [code]NOTIFICATION_DRAW[/code] will be called on idle time to request redraw.
</description>
</method>
</methods>
@ -37568,12 +37590,14 @@ A similar effect may be achieved moving this node's descendants.
<return type="String">
</return>
<description>
Return a copy of the string with special characters escaped using the C language standard.
</description>
</method>
<method name="c_unescape">
<return type="String">
</return>
<description>
Return a copy of the string with escaped characters replaced by their meanings according to the C language standard.
</description>
</method>
<method name="capitalize">
@ -37605,6 +37629,7 @@ A similar effect may be achieved moving this node's descendants.
<argument index="0" name="text" type="String">
</argument>
<description>
Return true if the strings ends with the given string.
</description>
</method>
<method name="erase">
@ -37613,6 +37638,7 @@ A similar effect may be achieved moving this node's descendants.
<argument index="1" name="chars" type="int">
</argument>
<description>
Erase [code]chars[/code] characters from the string starting from [code]pos[/code].
</description>
</method>
<method name="extension">
@ -37712,7 +37738,7 @@ A similar effect may be achieved moving this node's descendants.
<argument index="0" name="text" type="String">
</argument>
<description>
Checked whether this string is a subsequence of the given string.
Check whether this string is a subsequence of the given string.
</description>
</method>
<method name="is_subsequence_ofi">
@ -37721,7 +37747,7 @@ A similar effect may be achieved moving this node's descendants.
<argument index="0" name="text" type="String">
</argument>
<description>
Checked whether this string is a subsequence of the given string, without considering case.
Check whether this string is a subsequence of the given string, without considering case.
</description>
</method>
<method name="is_valid_float">
@ -37742,6 +37768,7 @@ A similar effect may be achieved moving this node's descendants.
<return type="bool">
</return>
<description>
Check whether the string is a valid identifier. As is common in programming languages, a valid identifier may contain only letters, digits and underscores (_) and the first character may not be a digit.
</description>
</method>
<method name="is_valid_integer">
@ -37762,6 +37789,7 @@ A similar effect may be achieved moving this node's descendants.
<return type="String">
</return>
<description>
Return a copy of the string with special characters escaped using the JSON standard.
</description>
</method>
<method name="left">
@ -37802,12 +37830,14 @@ A similar effect may be achieved moving this node's descendants.
<return type="RawArray">
</return>
<description>
Return the MD5 hash of the string as an array of bytes.
</description>
</method>
<method name="md5_text">
<return type="String">
</return>
<description>
Return the MD5 hash of the string as a string.
</description>
</method>
<method name="nocasecmp_to">
@ -37825,7 +37855,7 @@ A similar effect may be achieved moving this node's descendants.
<argument index="0" name="at" type="int">
</argument>
<description>
Return the character code at position "at".
Return the character code at position [code]at[/code].
</description>
</method>
<method name="pad_decimals">
@ -37834,6 +37864,7 @@ A similar effect may be achieved moving this node's descendants.
<argument index="0" name="digits" type="int">
</argument>
<description>
Format a number to have an exact number of [code]digits[/code] after the decimal point.
</description>
</method>
<method name="pad_zeros">
@ -37842,18 +37873,21 @@ A similar effect may be achieved moving this node's descendants.
<argument index="0" name="digits" type="int">
</argument>
<description>
Format a number to have an exact number of [code]digits[/code] before the decimal point.
</description>
</method>
<method name="percent_decode">
<return type="String">
</return>
<description>
Decode a percent-encoded string. See [method percent_encode].
</description>
</method>
<method name="percent_encode">
<return type="String">
</return>
<description>
Percent-encode a string. This is meant to encode parameters in a URL when sending a HTTP GET request and bodies of form-urlencoded POST request.
</description>
</method>
<method name="plus_file">
@ -37862,6 +37896,7 @@ A similar effect may be achieved moving this node's descendants.
<argument index="0" name="file" type="String">
</argument>
<description>
If the string is a path, this concatenates [code]file[/code] at the end of the string as a subpath. E.g. [code]"this/is".plus_file("path") == "this/is/path"[/code].
</description>
</method>
<method name="replace">
@ -37917,10 +37952,17 @@ A similar effect may be achieved moving this node's descendants.
Return the right side of the string from a given position.
</description>
</method>
<method name="sha256_buffer">
<return type="RawArray">
</return>
<description>
</description>
</method>
<method name="sha256_text">
<return type="String">
</return>
<description>
Return the SHA-256 hash of the string as a string.
</description>
</method>
<method name="similarity">
@ -37940,7 +37982,7 @@ A similar effect may be achieved moving this node's descendants.
<argument index="1" name="allow_empty" type="bool" default="True">
</argument>
<description>
Split the string by a divisor string, return an array of the substrings. Example "One,Two,Three" will return \["One","Two","Three"\] if split by ",".
Split the string by a divisor string, return an array of the substrings. Example "One,Two,Three" will return ["One","Two","Three"] if split by ",".
</description>
</method>
<method name="split_floats">
@ -37951,7 +37993,7 @@ A similar effect may be achieved moving this node's descendants.
<argument index="1" name="allow_empty" type="bool" default="True">
</argument>
<description>
Split the string in floats by using a divisor string, return an array of the substrings. Example "1,2.5,3" will return \[1,2.5,3\] if split by ",".
Split the string in floats by using a divisor string, return an array of the substrings. Example "1,2.5,3" will return [1,2.5,3] if split by ",".
</description>
</method>
<method name="strip_edges">
@ -37973,7 +38015,7 @@ A similar effect may be achieved moving this node's descendants.
<argument index="1" name="len" type="int">
</argument>
<description>
Return part of the string from "from", with length "len".
Return part of the string from the position [code]from[/code], with length [code]len[/code].
</description>
</method>
<method name="to_ascii">
@ -37987,14 +38029,14 @@ A similar effect may be achieved moving this node's descendants.
<return type="float">
</return>
<description>
Convert a string, containing a decimal number, into a float.
Convert a string, containing a decimal number, into a [code]float[/code].
</description>
</method>
<method name="to_int">
<return type="int">
</return>
<description>
Convert a string, containing an integer number, into an int.
Convert a string, containing an integer number, into an [code]int[/code].
</description>
</method>
<method name="to_lower">
@ -38022,14 +38064,14 @@ A similar effect may be achieved moving this node's descendants.
<return type="String">
</return>
<description>
Perform XML escaping on the string.
Return a copy of the string with special characters escaped using the XML standard.
</description>
</method>
<method name="xml_unescape">
<return type="String">
</return>
<description>
Perform XML un-escaping of the string.
Return a copy of the string with escaped characters replaced by their meanings according to the XML standard.
</description>
</method>
</methods>
@ -39290,8 +39332,6 @@ A similar effect may be achieved moving this node's descendants.
</theme_item>
<theme_item name="completion" type="StyleBox">
</theme_item>
<theme_item name="completion_existing" type="Color">
</theme_item>
<theme_item name="completion_lines" type="int">
</theme_item>
<theme_item name="completion_max_width" type="int">
@ -39300,8 +39340,6 @@ A similar effect may be achieved moving this node's descendants.
</theme_item>
<theme_item name="completion_scroll_width" type="int">
</theme_item>
<theme_item name="completion_selected" type="StyleBox">
</theme_item>
<theme_item name="current_line_color" type="Color">
</theme_item>
<theme_item name="focus" type="StyleBox">

View File

@ -1023,7 +1023,7 @@ void CanvasItem::_bind_methods() {
ObjectTypeDB::bind_method(_MD("_is_visible_"),&CanvasItem::_is_visible_);
ObjectTypeDB::bind_method(_MD("edit_set_state","state"),&CanvasItem::edit_set_state);
ObjectTypeDB::bind_method(_MD("edit_get"),&CanvasItem::edit_get_state);
ObjectTypeDB::bind_method(_MD("edit_get_state:Variant"),&CanvasItem::edit_get_state);
ObjectTypeDB::bind_method(_MD("edit_set_rect","rect"),&CanvasItem::edit_set_rect);
ObjectTypeDB::bind_method(_MD("edit_rotate","degrees"),&CanvasItem::edit_rotate);