diff options
68 files changed, 3216 insertions, 1755 deletions
diff --git a/.gitignore b/.gitignore index cc5c822e69..9096ff228a 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,7 @@ local.properties .idea .gradletasknamecache project.properties +platform/android/java/lib/.cxx/ platform/android/java/libs/* platform/android/java/app/libs/* diff --git a/doc/classes/AcceptDialog.xml b/doc/classes/AcceptDialog.xml index 01540383dc..99b566e74f 100644 --- a/doc/classes/AcceptDialog.xml +++ b/doc/classes/AcceptDialog.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="AcceptDialog" inherits="WindowDialog" version="4.0"> +<class name="AcceptDialog" inherits="Window" version="4.0"> <brief_description> Base dialog for user notification. </brief_description> @@ -67,9 +67,16 @@ <member name="dialog_text" type="String" setter="set_text" getter="get_text" default=""""> The text displayed by the dialog. </member> - <member name="window_title" type="String" setter="set_title" getter="get_title" override="true" default=""Alert!"" /> + <member name="title" type="String" setter="set_title" getter="get_title" override="true" default=""Alert!"" /> + <member name="transient" type="bool" setter="set_transient" getter="is_transient" override="true" default="true" /> + <member name="visible" type="bool" setter="set_visible" getter="is_visible" override="true" default="false" /> + <member name="wrap_controls" type="bool" setter="set_wrap_controls" getter="is_wrapping_controls" override="true" default="true" /> </members> <signals> + <signal name="cancelled"> + <description> + </description> + </signal> <signal name="confirmed"> <description> Emitted when the dialog is accepted, i.e. the OK button is pressed. diff --git a/doc/classes/ConfirmationDialog.xml b/doc/classes/ConfirmationDialog.xml index 801d9508dd..6d5871508b 100644 --- a/doc/classes/ConfirmationDialog.xml +++ b/doc/classes/ConfirmationDialog.xml @@ -22,8 +22,9 @@ </method> </methods> <members> - <member name="rect_min_size" type="Vector2" setter="set_custom_minimum_size" getter="get_custom_minimum_size" override="true" default="Vector2( 200, 70 )" /> - <member name="window_title" type="String" setter="set_title" getter="get_title" override="true" default=""Please Confirm..."" /> + <member name="min_size" type="Vector2i" setter="set_min_size" getter="get_min_size" override="true" default="Vector2i( 200, 70 )" /> + <member name="size" type="Vector2i" setter="set_size" getter="get_size" override="true" default="Vector2i( 200, 100 )" /> + <member name="title" type="String" setter="set_title" getter="get_title" override="true" default=""Please Confirm..."" /> </members> <constants> </constants> diff --git a/doc/classes/Control.xml b/doc/classes/Control.xml index 89db5baf8a..85a75fda37 100644 --- a/doc/classes/Control.xml +++ b/doc/classes/Control.xml @@ -7,10 +7,12 @@ Base class for all UI-related nodes. [Control] features a bounding rectangle that defines its extents, an anchor position relative to its parent control or the current viewport, and margins that represent an offset to the anchor. The margins update automatically when the node, any of its parents, or the screen size change. For more information on Godot's UI system, anchors, margins, and containers, see the related tutorials in the manual. To build flexible UIs, you'll need a mix of UI elements that inherit from [Control] and [Container] nodes. [b]User Interface nodes and input[/b] - Godot sends input events to the scene's root node first, by calling [method Node._input]. [method Node._input] forwards the event down the node tree to the nodes under the mouse cursor, or on keyboard focus. To do so, it calls [method MainLoop._input_event]. Call [method accept_event] so no other node receives the event. Once you accepted an input, it becomes handled so [method Node._unhandled_input] will not process it. + Godot sends input events to the scene's root node first, by calling [method Node._input]. [method Node._input] forwards the event down the node tree to the nodes under the mouse cursor, or on keyboard focus. To do so, it calls [code]MainLoop._input_event[/code]. + [b]FIXME:[/b] No longer valid after DisplayServer split and Input refactoring. + Call [method accept_event] so no other node receives the event. Once you accepted an input, it becomes handled so [method Node._unhandled_input] will not process it. Only one [Control] node can be in keyboard focus. Only the node in focus will receive keyboard events. To get the focus, call [method grab_focus]. [Control] nodes lose focus when another node grabs it, or if you hide the node in focus. Sets [member mouse_filter] to [constant MOUSE_FILTER_IGNORE] to tell a [Control] node to ignore mouse or touch events. You'll need it if you place an icon on top of a button. - [Theme] resources change the Control's appearance. If you change the [Theme] on a [Control] node, it affects all of its children. To override some of the theme's parameters, call one of the [code]add_*_override[/code] methods, like [method add_font_override]. You can override the theme with the inspector. + [Theme] resources change the Control's appearance. If you change the [Theme] on a [Control] node, it affects all of its children. To override some of the theme's parameters, call one of the [code]add_theme_*_override[/code] methods, like [method add_theme_font_override]. You can override the theme with the inspector. </description> <tutorials> <link>https://docs.godotengine.org/en/latest/tutorials/gui/index.html</link> @@ -87,7 +89,7 @@ Marks an input event as handled. Once you accept an input event, it stops propagating, even to nodes listening to [method Node._unhandled_input] or [method Node._unhandled_key_input]. </description> </method> - <method name="add_color_override"> + <method name="add_theme_color_override"> <return type="void"> </return> <argument index="0" name="name" type="StringName"> @@ -98,7 +100,7 @@ Overrides the [Color] with given [code]name[/code] in the [member theme] resource the control uses. If the [code]color[/code] is empty or invalid, the override is cleared and the color from assigned [Theme] is used. </description> </method> - <method name="add_constant_override"> + <method name="add_theme_constant_override"> <return type="void"> </return> <argument index="0" name="name" type="StringName"> @@ -109,7 +111,7 @@ Overrides an integer constant with given [code]name[/code] in the [member theme] resource the control uses. If the [code]constant[/code] is empty or invalid, the override is cleared and the constant from assigned [Theme] is used. </description> </method> - <method name="add_font_override"> + <method name="add_theme_font_override"> <return type="void"> </return> <argument index="0" name="name" type="StringName"> @@ -120,7 +122,7 @@ Overrides the font with given [code]name[/code] in the [member theme] resource the control uses. If [code]font[/code] is empty or invalid, the override is cleared and the font from assigned [Theme] is used. </description> </method> - <method name="add_icon_override"> + <method name="add_theme_icon_override"> <return type="void"> </return> <argument index="0" name="name" type="StringName"> @@ -131,7 +133,7 @@ Overrides the icon with given [code]name[/code] in the [member theme] resource the control uses. If [code]icon[/code] is empty or invalid, the override is cleared and the icon from assigned [Theme] is used. </description> </method> - <method name="add_shader_override"> + <method name="add_theme_shader_override"> <return type="void"> </return> <argument index="0" name="name" type="StringName"> @@ -142,7 +144,7 @@ Overrides the [Shader] with given [code]name[/code] in the [member theme] resource the control uses. If [code]shader[/code] is empty or invalid, the override is cleared and the shader from assigned [Theme] is used. </description> </method> - <method name="add_stylebox_override"> + <method name="add_theme_stylebox_override"> <return type="void"> </return> <argument index="0" name="name" type="StringName"> @@ -217,21 +219,6 @@ Returns [member margin_left] and [member margin_top]. See also [member rect_position]. </description> </method> - <method name="get_color" qualifiers="const"> - <return type="Color"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="type" type="StringName" default=""""> - </argument> - <description> - Returns a color from assigned [Theme] with given [code]name[/code] and associated with [Control] of given [code]type[/code]. - [codeblock] - func _ready(): - modulate = get_color("font_color", "Button") #get the color defined for button fonts - [/codeblock] - </description> - </method> <method name="get_combined_minimum_size" qualifiers="const"> <return type="Vector2"> </return> @@ -239,17 +226,6 @@ Returns combined minimum size from [member rect_min_size] and [method get_minimum_size]. </description> </method> - <method name="get_constant" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="type" type="StringName" default=""""> - </argument> - <description> - Returns a constant from assigned [Theme] with given [code]name[/code] and associated with [Control] of given [code]type[/code]. - </description> - </method> <method name="get_cursor_shape" qualifiers="const"> <return type="int" enum="Control.CursorShape"> </return> @@ -298,17 +274,6 @@ Returns the control that has the keyboard focus or [code]null[/code] if none. </description> </method> - <method name="get_font" qualifiers="const"> - <return type="Font"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="type" type="StringName" default=""""> - </argument> - <description> - Returns a font from assigned [Theme] with given [code]name[/code] and associated with [Control] of given [code]type[/code]. - </description> - </method> <method name="get_global_rect" qualifiers="const"> <return type="Rect2"> </return> @@ -316,17 +281,6 @@ Returns the position and size of the control relative to the top-left corner of the screen. See [member rect_position] and [member rect_size]. </description> </method> - <method name="get_icon" qualifiers="const"> - <return type="Texture2D"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="type" type="StringName" default=""""> - </argument> - <description> - Returns an icon from assigned [Theme] with given [code]name[/code] and associated with [Control] of given [code]type[/code]. - </description> - </method> <method name="get_margin" qualifiers="const"> <return type="float"> </return> @@ -371,7 +325,55 @@ Returns the rotation (in radians). </description> </method> - <method name="get_stylebox" qualifiers="const"> + <method name="get_theme_color" qualifiers="const"> + <return type="Color"> + </return> + <argument index="0" name="name" type="StringName"> + </argument> + <argument index="1" name="type" type="StringName" default=""""> + </argument> + <description> + Returns a color from assigned [Theme] with given [code]name[/code] and associated with [Control] of given [code]type[/code]. + [codeblock] + func _ready(): + modulate = get_theme_color("font_color", "Button") #get the color defined for button fonts + [/codeblock] + </description> + </method> + <method name="get_theme_constant" qualifiers="const"> + <return type="int"> + </return> + <argument index="0" name="name" type="StringName"> + </argument> + <argument index="1" name="type" type="StringName" default=""""> + </argument> + <description> + Returns a constant from assigned [Theme] with given [code]name[/code] and associated with [Control] of given [code]type[/code]. + </description> + </method> + <method name="get_theme_font" qualifiers="const"> + <return type="Font"> + </return> + <argument index="0" name="name" type="StringName"> + </argument> + <argument index="1" name="type" type="StringName" default=""""> + </argument> + <description> + Returns a font from assigned [Theme] with given [code]name[/code] and associated with [Control] of given [code]type[/code]. + </description> + </method> + <method name="get_theme_icon" qualifiers="const"> + <return type="Texture2D"> + </return> + <argument index="0" name="name" type="StringName"> + </argument> + <argument index="1" name="type" type="StringName" default=""""> + </argument> + <description> + Returns an icon from assigned [Theme] with given [code]name[/code] and associated with [Control] of given [code]type[/code]. + </description> + </method> + <method name="get_theme_stylebox" qualifiers="const"> <return type="StyleBox"> </return> <argument index="0" name="name" type="StringName"> @@ -409,7 +411,25 @@ Steal the focus from another control and become the focused control (see [member focus_mode]). </description> </method> - <method name="has_color" qualifiers="const"> + <method name="has_focus" qualifiers="const"> + <return type="bool"> + </return> + <description> + Returns [code]true[/code] if this is the current focused control. See [member focus_mode]. + </description> + </method> + <method name="has_point" qualifiers="virtual"> + <return type="bool"> + </return> + <argument index="0" name="point" type="Vector2"> + </argument> + <description> + Virtual method to be implemented by the user. Returns whether the given [code]point[/code] is inside this control. + If not overridden, default behavior is checking if the point is within control's Rect. + [b]Note:[/b] If you want to check if a point is inside the control, you can use [code]get_rect().has_point(point)[/code]. + </description> + </method> + <method name="has_theme_color" qualifiers="const"> <return type="bool"> </return> <argument index="0" name="name" type="StringName"> @@ -420,7 +440,7 @@ Returns [code]true[/code] if [Color] with given [code]name[/code] and associated with [Control] of given [code]type[/code] exists in assigned [Theme]. </description> </method> - <method name="has_color_override" qualifiers="const"> + <method name="has_theme_color_override" qualifiers="const"> <return type="bool"> </return> <argument index="0" name="name" type="StringName"> @@ -429,7 +449,7 @@ Returns [code]true[/code] if [Color] with given [code]name[/code] has a valid override in this [Control] node. </description> </method> - <method name="has_constant" qualifiers="const"> + <method name="has_theme_constant" qualifiers="const"> <return type="bool"> </return> <argument index="0" name="name" type="StringName"> @@ -440,7 +460,7 @@ Returns [code]true[/code] if constant with given [code]name[/code] and associated with [Control] of given [code]type[/code] exists in assigned [Theme]. </description> </method> - <method name="has_constant_override" qualifiers="const"> + <method name="has_theme_constant_override" qualifiers="const"> <return type="bool"> </return> <argument index="0" name="name" type="StringName"> @@ -449,14 +469,7 @@ Returns [code]true[/code] if constant with given [code]name[/code] has a valid override in this [Control] node. </description> </method> - <method name="has_focus" qualifiers="const"> - <return type="bool"> - </return> - <description> - Returns [code]true[/code] if this is the current focused control. See [member focus_mode]. - </description> - </method> - <method name="has_font" qualifiers="const"> + <method name="has_theme_font" qualifiers="const"> <return type="bool"> </return> <argument index="0" name="name" type="StringName"> @@ -467,7 +480,7 @@ Returns [code]true[/code] if font with given [code]name[/code] and associated with [Control] of given [code]type[/code] exists in assigned [Theme]. </description> </method> - <method name="has_font_override" qualifiers="const"> + <method name="has_theme_font_override" qualifiers="const"> <return type="bool"> </return> <argument index="0" name="name" type="StringName"> @@ -476,7 +489,7 @@ Returns [code]true[/code] if font with given [code]name[/code] has a valid override in this [Control] node. </description> </method> - <method name="has_icon" qualifiers="const"> + <method name="has_theme_icon" qualifiers="const"> <return type="bool"> </return> <argument index="0" name="name" type="StringName"> @@ -487,7 +500,7 @@ Returns [code]true[/code] if icon with given [code]name[/code] and associated with [Control] of given [code]type[/code] exists in assigned [Theme]. </description> </method> - <method name="has_icon_override" qualifiers="const"> + <method name="has_theme_icon_override" qualifiers="const"> <return type="bool"> </return> <argument index="0" name="name" type="StringName"> @@ -496,18 +509,7 @@ Returns [code]true[/code] if icon with given [code]name[/code] has a valid override in this [Control] node. </description> </method> - <method name="has_point" qualifiers="virtual"> - <return type="bool"> - </return> - <argument index="0" name="point" type="Vector2"> - </argument> - <description> - Virtual method to be implemented by the user. Returns whether the given [code]point[/code] is inside this control. - If not overridden, default behavior is checking if the point is within control's Rect. - [b]Note:[/b] If you want to check if a point is inside the control, you can use [code]get_rect().has_point(point)[/code]. - </description> - </method> - <method name="has_shader_override" qualifiers="const"> + <method name="has_theme_shader_override" qualifiers="const"> <return type="bool"> </return> <argument index="0" name="name" type="StringName"> @@ -516,7 +518,7 @@ Returns [code]true[/code] if [Shader] with given [code]name[/code] has a valid override in this [Control] node. </description> </method> - <method name="has_stylebox" qualifiers="const"> + <method name="has_theme_stylebox" qualifiers="const"> <return type="bool"> </return> <argument index="0" name="name" type="StringName"> @@ -527,7 +529,7 @@ Returns [code]true[/code] if [StyleBox] with given [code]name[/code] and associated with [Control] of given [code]type[/code] exists in assigned [Theme]. </description> </method> - <method name="has_stylebox_override" qualifiers="const"> + <method name="has_theme_stylebox_override" qualifiers="const"> <return type="bool"> </return> <argument index="0" name="name" type="StringName"> @@ -757,16 +759,6 @@ If [code]keep_margins[/code] is [code]true[/code], control's anchors will be updated instead of margins. </description> </method> - <method name="show_modal"> - <return type="void"> - </return> - <argument index="0" name="exclusive" type="bool" default="false"> - </argument> - <description> - Displays a control as modal. Control must be a subwindow. Modal controls capture the input signals until closed or the area outside them is accessed. When a modal control loses focus, or the ESC key is pressed, they automatically hide. Modal controls are used extensively for popup dialogs and menus. - If [code]exclusive[/code] is [code]true[/code], other controls will not receive input and clicking outside this control will not close it. - </description> - </method> <method name="warp_mouse"> <return type="void"> </return> @@ -905,11 +897,6 @@ Emitted when the node's minimum size changes. </description> </signal> - <signal name="modal_closed"> - <description> - Emitted when a modal [Control] is closed. See [method show_modal]. - </description> - </signal> <signal name="mouse_entered"> <description> Emitted when the mouse enters the control's [code]Rect[/code] area, provided its [member mouse_filter] lets the event reach it. @@ -930,6 +917,10 @@ Emitted when one of the size flags changes. See [member size_flags_horizontal] and [member size_flags_vertical]. </description> </signal> + <signal name="theme_changed"> + <description> + </description> + </signal> </signals> <constants> <constant name="FOCUS_NONE" value="0" enum="FocusMode"> @@ -957,10 +948,7 @@ Sent when the node loses focus. </constant> <constant name="NOTIFICATION_THEME_CHANGED" value="45"> - Sent when the node's [member theme] changes, right before Godot redraws the control. Happens when you call one of the [code]add_*_override[/code] methods. - </constant> - <constant name="NOTIFICATION_MODAL_CLOSE" value="46"> - Sent when an open modal dialog closes. See [method show_modal]. + Sent when the node's [member theme] changes, right before Godot redraws the control. Happens when you call one of the [code]add_theme_*_override[/code] methods. </constant> <constant name="NOTIFICATION_SCROLL_BEGIN" value="47"> Sent when this node is inside a [ScrollContainer] which has begun being scrolled. diff --git a/doc/classes/DisplayServer.xml b/doc/classes/DisplayServer.xml new file mode 100644 index 0000000000..7fa64c21cb --- /dev/null +++ b/doc/classes/DisplayServer.xml @@ -0,0 +1,1059 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="DisplayServer" inherits="Object" version="4.0"> + <brief_description> + </brief_description> + <description> + </description> + <tutorials> + </tutorials> + <methods> + <method name="alert"> + <return type="void"> + </return> + <argument index="0" name="text" type="String"> + </argument> + <argument index="1" name="title" type="String" default=""Alert!""> + </argument> + <description> + </description> + </method> + <method name="clipboard_get" qualifiers="const"> + <return type="String"> + </return> + <description> + </description> + </method> + <method name="clipboard_set"> + <return type="void"> + </return> + <argument index="0" name="clipboard" type="String"> + </argument> + <description> + </description> + </method> + <method name="console_set_visible"> + <return type="void"> + </return> + <argument index="0" name="console_visible" type="bool"> + </argument> + <description> + </description> + </method> + <method name="create_sub_window"> + <return type="int"> + </return> + <argument index="0" name="mode" type="int" enum="DisplayServer.WindowMode"> + </argument> + <argument index="1" name="rect" type="int"> + </argument> + <argument index="2" name="arg2" type="Rect2i" default="Rect2i( 0, 0, 0, 0 )"> + </argument> + <description> + </description> + </method> + <method name="cursor_get_shape" qualifiers="const"> + <return type="int" enum="DisplayServer.CursorShape"> + </return> + <description> + </description> + </method> + <method name="cursor_set_custom_image"> + <return type="void"> + </return> + <argument index="0" name="cursor" type="Resource"> + </argument> + <argument index="1" name="shape" type="int" enum="DisplayServer.CursorShape" default="0"> + </argument> + <argument index="2" name="hotspot" type="Vector2" default="Vector2( 0, 0 )"> + </argument> + <description> + </description> + </method> + <method name="cursor_set_shape"> + <return type="void"> + </return> + <argument index="0" name="shape" type="int" enum="DisplayServer.CursorShape"> + </argument> + <description> + </description> + </method> + <method name="delete_sub_window"> + <return type="void"> + </return> + <argument index="0" name="window_id" type="int"> + </argument> + <description> + </description> + </method> + <method name="dialog_input_text"> + <return type="int" enum="Error"> + </return> + <argument index="0" name="title" type="String"> + </argument> + <argument index="1" name="description" type="String"> + </argument> + <argument index="2" name="existing_text" type="PackedStringArray"> + </argument> + <argument index="3" name="callback" type="Callable"> + </argument> + <description> + </description> + </method> + <method name="dialog_show"> + <return type="int" enum="Error"> + </return> + <argument index="0" name="title" type="String"> + </argument> + <argument index="1" name="description" type="String"> + </argument> + <argument index="2" name="buttons" type="PackedStringArray"> + </argument> + <argument index="3" name="callback" type="Callable"> + </argument> + <description> + </description> + </method> + <method name="enable_for_stealing_focus"> + <return type="void"> + </return> + <argument index="0" name="process_id" type="int"> + </argument> + <description> + </description> + </method> + <method name="force_process_and_drop_events"> + <return type="void"> + </return> + <description> + </description> + </method> + <method name="get_latin_keyboard_variant" qualifiers="const"> + <return type="int" enum="DisplayServer.LatinKeyboardVariant"> + </return> + <description> + </description> + </method> + <method name="get_name" qualifiers="const"> + <return type="String"> + </return> + <description> + </description> + </method> + <method name="get_screen_count" qualifiers="const"> + <return type="int"> + </return> + <description> + </description> + </method> + <method name="get_swap_ok_cancel"> + <return type="bool"> + </return> + <description> + </description> + </method> + <method name="get_window_at_screen_position" qualifiers="const"> + <return type="int"> + </return> + <argument index="0" name="position" type="Vector2i"> + </argument> + <description> + </description> + </method> + <method name="get_window_list" qualifiers="const"> + <return type="PackedInt32Array"> + </return> + <description> + </description> + </method> + <method name="global_menu_add_check_item"> + <return type="void"> + </return> + <argument index="0" name="menu_root" type="String"> + </argument> + <argument index="1" name="label" type="String"> + </argument> + <argument index="2" name="callback" type="Callable"> + </argument> + <argument index="3" name="tag" type="Variant" default="null"> + </argument> + <description> + </description> + </method> + <method name="global_menu_add_item"> + <return type="void"> + </return> + <argument index="0" name="menu_root" type="String"> + </argument> + <argument index="1" name="label" type="String"> + </argument> + <argument index="2" name="callback" type="Callable"> + </argument> + <argument index="3" name="tag" type="Variant" default="null"> + </argument> + <description> + </description> + </method> + <method name="global_menu_add_separator"> + <return type="void"> + </return> + <argument index="0" name="menu_root" type="String"> + </argument> + <description> + </description> + </method> + <method name="global_menu_add_submenu_item"> + <return type="void"> + </return> + <argument index="0" name="menu_root" type="String"> + </argument> + <argument index="1" name="label" type="String"> + </argument> + <argument index="2" name="submenu" type="String"> + </argument> + <description> + </description> + </method> + <method name="global_menu_clear"> + <return type="void"> + </return> + <argument index="0" name="menu_root" type="String"> + </argument> + <description> + </description> + </method> + <method name="global_menu_get_item_callback"> + <return type="Callable"> + </return> + <argument index="0" name="menu_root" type="String"> + </argument> + <argument index="1" name="idx" type="int"> + </argument> + <description> + </description> + </method> + <method name="global_menu_get_item_submenu"> + <return type="String"> + </return> + <argument index="0" name="menu_root" type="String"> + </argument> + <argument index="1" name="idx" type="int"> + </argument> + <description> + </description> + </method> + <method name="global_menu_get_item_tag"> + <return type="Variant"> + </return> + <argument index="0" name="menu_root" type="String"> + </argument> + <argument index="1" name="idx" type="int"> + </argument> + <description> + </description> + </method> + <method name="global_menu_get_item_text"> + <return type="String"> + </return> + <argument index="0" name="menu_root" type="String"> + </argument> + <argument index="1" name="idx" type="int"> + </argument> + <description> + </description> + </method> + <method name="global_menu_is_item_checkable" qualifiers="const"> + <return type="bool"> + </return> + <argument index="0" name="menu_root" type="String"> + </argument> + <argument index="1" name="idx" type="int"> + </argument> + <description> + </description> + </method> + <method name="global_menu_is_item_checked" qualifiers="const"> + <return type="bool"> + </return> + <argument index="0" name="menu_root" type="String"> + </argument> + <argument index="1" name="idx" type="int"> + </argument> + <description> + </description> + </method> + <method name="global_menu_remove_item"> + <return type="void"> + </return> + <argument index="0" name="menu_root" type="String"> + </argument> + <argument index="1" name="idx" type="int"> + </argument> + <description> + </description> + </method> + <method name="global_menu_set_item_callback"> + <return type="void"> + </return> + <argument index="0" name="menu_root" type="String"> + </argument> + <argument index="1" name="idx" type="int"> + </argument> + <argument index="2" name="callback" type="Callable"> + </argument> + <description> + </description> + </method> + <method name="global_menu_set_item_checkable"> + <return type="void"> + </return> + <argument index="0" name="menu_root" type="String"> + </argument> + <argument index="1" name="idx" type="int"> + </argument> + <argument index="2" name="checkable" type="bool"> + </argument> + <description> + </description> + </method> + <method name="global_menu_set_item_checked"> + <return type="void"> + </return> + <argument index="0" name="menu_root" type="String"> + </argument> + <argument index="1" name="idx" type="int"> + </argument> + <argument index="2" name="checked" type="bool"> + </argument> + <description> + </description> + </method> + <method name="global_menu_set_item_submenu"> + <return type="void"> + </return> + <argument index="0" name="menu_root" type="String"> + </argument> + <argument index="1" name="idx" type="int"> + </argument> + <argument index="2" name="submenu" type="String"> + </argument> + <description> + </description> + </method> + <method name="global_menu_set_item_tag"> + <return type="void"> + </return> + <argument index="0" name="menu_root" type="String"> + </argument> + <argument index="1" name="idx" type="int"> + </argument> + <argument index="2" name="tag" type="Variant"> + </argument> + <description> + </description> + </method> + <method name="global_menu_set_item_text"> + <return type="void"> + </return> + <argument index="0" name="menu_root" type="String"> + </argument> + <argument index="1" name="idx" type="int"> + </argument> + <argument index="2" name="text" type="String"> + </argument> + <description> + </description> + </method> + <method name="has_feature" qualifiers="const"> + <return type="bool"> + </return> + <argument index="0" name="feature" type="int" enum="DisplayServer.Feature"> + </argument> + <description> + </description> + </method> + <method name="ime_get_selection" qualifiers="const"> + <return type="Vector2i"> + </return> + <description> + </description> + </method> + <method name="ime_get_text" qualifiers="const"> + <return type="String"> + </return> + <description> + </description> + </method> + <method name="is_console_visible" qualifiers="const"> + <return type="bool"> + </return> + <description> + </description> + </method> + <method name="mouse_get_absolute_position" qualifiers="const"> + <return type="Vector2i"> + </return> + <description> + </description> + </method> + <method name="mouse_get_button_state" qualifiers="const"> + <return type="int"> + </return> + <description> + </description> + </method> + <method name="mouse_get_mode" qualifiers="const"> + <return type="int" enum="DisplayServer.MouseMode"> + </return> + <description> + </description> + </method> + <method name="mouse_get_position" qualifiers="const"> + <return type="Vector2i"> + </return> + <description> + </description> + </method> + <method name="mouse_set_mode"> + <return type="void"> + </return> + <argument index="0" name="mouse_mode" type="int" enum="DisplayServer.MouseMode"> + </argument> + <description> + </description> + </method> + <method name="mouse_warp_to_position"> + <return type="void"> + </return> + <argument index="0" name="position" type="Vector2i"> + </argument> + <description> + </description> + </method> + <method name="native_video_is_playing" qualifiers="const"> + <return type="bool"> + </return> + <description> + </description> + </method> + <method name="native_video_pause"> + <return type="void"> + </return> + <description> + </description> + </method> + <method name="native_video_play"> + <return type="int" enum="Error"> + </return> + <argument index="0" name="path" type="String"> + </argument> + <argument index="1" name="volume" type="float"> + </argument> + <argument index="2" name="audio_track" type="String"> + </argument> + <argument index="3" name="subtitle_track" type="String"> + </argument> + <argument index="4" name="arg4" type="int"> + </argument> + <description> + </description> + </method> + <method name="native_video_stop"> + <return type="void"> + </return> + <description> + </description> + </method> + <method name="native_video_unpause"> + <return type="void"> + </return> + <description> + </description> + </method> + <method name="process_events"> + <return type="void"> + </return> + <description> + </description> + </method> + <method name="screen_get_dpi" qualifiers="const"> + <return type="int"> + </return> + <argument index="0" name="screen" type="int" default="-1"> + </argument> + <description> + </description> + </method> + <method name="screen_get_orientation" qualifiers="const"> + <return type="int" enum="DisplayServer.ScreenOrientation"> + </return> + <argument index="0" name="screen" type="int" default="-1"> + </argument> + <description> + </description> + </method> + <method name="screen_get_position" qualifiers="const"> + <return type="Vector2i"> + </return> + <argument index="0" name="screen" type="int" default="-1"> + </argument> + <description> + </description> + </method> + <method name="screen_get_scale" qualifiers="const"> + <return type="float"> + </return> + <argument index="0" name="screen" type="int" default="-1"> + </argument> + <description> + </description> + </method> + <method name="screen_get_size" qualifiers="const"> + <return type="Vector2i"> + </return> + <argument index="0" name="screen" type="int" default="-1"> + </argument> + <description> + </description> + </method> + <method name="screen_get_usable_rect" qualifiers="const"> + <return type="Rect2i"> + </return> + <argument index="0" name="screen" type="int" default="-1"> + </argument> + <description> + </description> + </method> + <method name="screen_is_kept_on" qualifiers="const"> + <return type="bool"> + </return> + <description> + </description> + </method> + <method name="screen_is_touchscreen" qualifiers="const"> + <return type="bool"> + </return> + <argument index="0" name="screen" type="int" default="-1"> + </argument> + <description> + </description> + </method> + <method name="screen_set_keep_on"> + <return type="void"> + </return> + <argument index="0" name="enable" type="bool"> + </argument> + <description> + </description> + </method> + <method name="screen_set_orientation"> + <return type="void"> + </return> + <argument index="0" name="orientation" type="int" enum="DisplayServer.ScreenOrientation"> + </argument> + <argument index="1" name="screen" type="int" default="-1"> + </argument> + <description> + </description> + </method> + <method name="set_icon"> + <return type="void"> + </return> + <argument index="0" name="image" type="Image"> + </argument> + <description> + </description> + </method> + <method name="set_native_icon"> + <return type="void"> + </return> + <argument index="0" name="filename" type="String"> + </argument> + <description> + </description> + </method> + <method name="virtual_keyboard_get_height" qualifiers="const"> + <return type="int"> + </return> + <description> + </description> + </method> + <method name="virtual_keyboard_hide"> + <return type="void"> + </return> + <description> + </description> + </method> + <method name="virtual_keyboard_show"> + <return type="void"> + </return> + <argument index="0" name="existing_text" type="String"> + </argument> + <argument index="1" name="position" type="Rect2" default="Rect2i( 0, 0, 0, 0 )"> + </argument> + <argument index="2" name="max_length" type="int" default="-1"> + </argument> + <description> + </description> + </method> + <method name="vsync_is_enabled" qualifiers="const"> + <return type="bool"> + </return> + <description> + </description> + </method> + <method name="vsync_is_using_via_compositor" qualifiers="const"> + <return type="bool"> + </return> + <description> + </description> + </method> + <method name="vsync_set_enabled"> + <return type="void"> + </return> + <argument index="0" name="enabled" type="bool"> + </argument> + <description> + </description> + </method> + <method name="vsync_set_use_via_compositor"> + <return type="void"> + </return> + <argument index="0" name="enabled" type="bool"> + </argument> + <description> + </description> + </method> + <method name="window_attach_instance_id"> + <return type="void"> + </return> + <argument index="0" name="instance_id" type="int"> + </argument> + <argument index="1" name="window_id" type="int" default="0"> + </argument> + <description> + </description> + </method> + <method name="window_can_draw" qualifiers="const"> + <return type="bool"> + </return> + <argument index="0" name="window_id" type="int" default="0"> + </argument> + <description> + </description> + </method> + <method name="window_get_attached_instance_id" qualifiers="const"> + <return type="int"> + </return> + <argument index="0" name="window_id" type="int" default="0"> + </argument> + <description> + </description> + </method> + <method name="window_get_current_screen" qualifiers="const"> + <return type="int"> + </return> + <argument index="0" name="window_id" type="int" default="0"> + </argument> + <description> + </description> + </method> + <method name="window_get_flag" qualifiers="const"> + <return type="bool"> + </return> + <argument index="0" name="flag" type="int" enum="DisplayServer.WindowFlags"> + </argument> + <argument index="1" name="window_id" type="int" default="0"> + </argument> + <description> + </description> + </method> + <method name="window_get_max_size" qualifiers="const"> + <return type="Vector2i"> + </return> + <argument index="0" name="window_id" type="int" default="0"> + </argument> + <description> + </description> + </method> + <method name="window_get_min_size" qualifiers="const"> + <return type="Vector2i"> + </return> + <argument index="0" name="window_id" type="int" default="0"> + </argument> + <description> + </description> + </method> + <method name="window_get_mode" qualifiers="const"> + <return type="int" enum="DisplayServer.WindowMode"> + </return> + <argument index="0" name="window_id" type="int" default="0"> + </argument> + <description> + </description> + </method> + <method name="window_get_position" qualifiers="const"> + <return type="Vector2i"> + </return> + <argument index="0" name="window_id" type="int" default="0"> + </argument> + <description> + </description> + </method> + <method name="window_get_real_size" qualifiers="const"> + <return type="Vector2i"> + </return> + <argument index="0" name="window_id" type="int" default="0"> + </argument> + <description> + </description> + </method> + <method name="window_get_size" qualifiers="const"> + <return type="Vector2i"> + </return> + <argument index="0" name="window_id" type="int" default="0"> + </argument> + <description> + </description> + </method> + <method name="window_move_to_foreground"> + <return type="void"> + </return> + <argument index="0" name="window_id" type="int" default="0"> + </argument> + <description> + </description> + </method> + <method name="window_request_attention"> + <return type="void"> + </return> + <argument index="0" name="window_id" type="int" default="0"> + </argument> + <description> + </description> + </method> + <method name="window_set_current_screen"> + <return type="void"> + </return> + <argument index="0" name="screen" type="int"> + </argument> + <argument index="1" name="window_id" type="int" default="0"> + </argument> + <description> + </description> + </method> + <method name="window_set_drop_files_callback"> + <return type="void"> + </return> + <argument index="0" name="callback" type="Callable"> + </argument> + <argument index="1" name="window_id" type="int" default="0"> + </argument> + <description> + </description> + </method> + <method name="window_set_flag"> + <return type="void"> + </return> + <argument index="0" name="flag" type="int" enum="DisplayServer.WindowFlags"> + </argument> + <argument index="1" name="enabled" type="bool"> + </argument> + <argument index="2" name="window_id" type="int" default="0"> + </argument> + <description> + </description> + </method> + <method name="window_set_ime_active"> + <return type="void"> + </return> + <argument index="0" name="active" type="bool"> + </argument> + <argument index="1" name="window_id" type="int" default="0"> + </argument> + <description> + </description> + </method> + <method name="window_set_ime_position"> + <return type="void"> + </return> + <argument index="0" name="position" type="Vector2i"> + </argument> + <argument index="1" name="window_id" type="int" default="0"> + </argument> + <description> + </description> + </method> + <method name="window_set_input_event_callback"> + <return type="void"> + </return> + <argument index="0" name="callback" type="Callable"> + </argument> + <argument index="1" name="window_id" type="int" default="0"> + </argument> + <description> + </description> + </method> + <method name="window_set_input_text_callback"> + <return type="void"> + </return> + <argument index="0" name="callback" type="Callable"> + </argument> + <argument index="1" name="window_id" type="int" default="0"> + </argument> + <description> + </description> + </method> + <method name="window_set_max_size"> + <return type="void"> + </return> + <argument index="0" name="max_size" type="Vector2i"> + </argument> + <argument index="1" name="window_id" type="int" default="0"> + </argument> + <description> + </description> + </method> + <method name="window_set_min_size"> + <return type="void"> + </return> + <argument index="0" name="min_size" type="Vector2i"> + </argument> + <argument index="1" name="window_id" type="int" default="0"> + </argument> + <description> + </description> + </method> + <method name="window_set_mode"> + <return type="void"> + </return> + <argument index="0" name="mode" type="int" enum="DisplayServer.WindowMode"> + </argument> + <argument index="1" name="window_id" type="int" default="0"> + </argument> + <description> + </description> + </method> + <method name="window_set_position"> + <return type="void"> + </return> + <argument index="0" name="position" type="Vector2i"> + </argument> + <argument index="1" name="window_id" type="int" default="0"> + </argument> + <description> + </description> + </method> + <method name="window_set_rect_changed_callback"> + <return type="void"> + </return> + <argument index="0" name="callback" type="Callable"> + </argument> + <argument index="1" name="window_id" type="int" default="0"> + </argument> + <description> + </description> + </method> + <method name="window_set_size"> + <return type="void"> + </return> + <argument index="0" name="size" type="Vector2i"> + </argument> + <argument index="1" name="window_id" type="int" default="0"> + </argument> + <description> + </description> + </method> + <method name="window_set_title"> + <return type="void"> + </return> + <argument index="0" name="title" type="String"> + </argument> + <argument index="1" name="window_id" type="int" default="0"> + </argument> + <description> + </description> + </method> + <method name="window_set_transient"> + <return type="void"> + </return> + <argument index="0" name="window_id" type="int"> + </argument> + <argument index="1" name="parent_window_id" type="int"> + </argument> + <description> + </description> + </method> + <method name="window_set_window_event_callback"> + <return type="void"> + </return> + <argument index="0" name="callback" type="Callable"> + </argument> + <argument index="1" name="window_id" type="int" default="0"> + </argument> + <description> + </description> + </method> + </methods> + <constants> + <constant name="FEATURE_GLOBAL_MENU" value="0" enum="Feature"> + </constant> + <constant name="FEATURE_SUBWINDOWS" value="1" enum="Feature"> + </constant> + <constant name="FEATURE_TOUCHSCREEN" value="2" enum="Feature"> + </constant> + <constant name="FEATURE_MOUSE" value="3" enum="Feature"> + </constant> + <constant name="FEATURE_MOUSE_WARP" value="4" enum="Feature"> + </constant> + <constant name="FEATURE_CLIPBOARD" value="5" enum="Feature"> + </constant> + <constant name="FEATURE_VIRTUAL_KEYBOARD" value="6" enum="Feature"> + </constant> + <constant name="FEATURE_CURSOR_SHAPE" value="7" enum="Feature"> + </constant> + <constant name="FEATURE_CUSTOM_CURSOR_SHAPE" value="8" enum="Feature"> + </constant> + <constant name="FEATURE_NATIVE_VIDEO" value="9" enum="Feature"> + </constant> + <constant name="FEATURE_NATIVE_DIALOG" value="10" enum="Feature"> + </constant> + <constant name="FEATURE_CONSOLE_WINDOW" value="11" enum="Feature"> + </constant> + <constant name="FEATURE_IME" value="12" enum="Feature"> + </constant> + <constant name="FEATURE_WINDOW_TRANSPARENCY" value="13" enum="Feature"> + </constant> + <constant name="FEATURE_HIDPI" value="14" enum="Feature"> + </constant> + <constant name="FEATURE_ICON" value="15" enum="Feature"> + </constant> + <constant name="FEATURE_NATIVE_ICON" value="16" enum="Feature"> + </constant> + <constant name="FEATURE_ORIENTATION" value="17" enum="Feature"> + </constant> + <constant name="FEATURE_SWAP_BUFFERS" value="18" enum="Feature"> + </constant> + <constant name="MOUSE_MODE_VISIBLE" value="0" enum="MouseMode"> + </constant> + <constant name="MOUSE_MODE_HIDDEN" value="1" enum="MouseMode"> + </constant> + <constant name="MOUSE_MODE_CAPTURED" value="2" enum="MouseMode"> + </constant> + <constant name="MOUSE_MODE_CONFINED" value="3" enum="MouseMode"> + </constant> + <constant name="SCREEN_OF_MAIN_WINDOW" value="-1"> + </constant> + <constant name="MAIN_WINDOW_ID" value="0"> + </constant> + <constant name="INVALID_WINDOW_ID" value="-1"> + </constant> + <constant name="SCREEN_LANDSCAPE" value="0" enum="ScreenOrientation"> + </constant> + <constant name="SCREEN_PORTRAIT" value="1" enum="ScreenOrientation"> + </constant> + <constant name="SCREEN_REVERSE_LANDSCAPE" value="2" enum="ScreenOrientation"> + </constant> + <constant name="SCREEN_REVERSE_PORTRAIT" value="3" enum="ScreenOrientation"> + </constant> + <constant name="SCREEN_SENSOR_LANDSCAPE" value="4" enum="ScreenOrientation"> + </constant> + <constant name="SCREEN_SENSOR_PORTRAIT" value="5" enum="ScreenOrientation"> + </constant> + <constant name="SCREEN_SENSOR" value="6" enum="ScreenOrientation"> + </constant> + <constant name="CURSOR_ARROW" value="0" enum="CursorShape"> + </constant> + <constant name="CURSOR_IBEAM" value="1" enum="CursorShape"> + </constant> + <constant name="CURSOR_POINTING_HAND" value="2" enum="CursorShape"> + </constant> + <constant name="CURSOR_CROSS" value="3" enum="CursorShape"> + </constant> + <constant name="CURSOR_WAIT" value="4" enum="CursorShape"> + </constant> + <constant name="CURSOR_BUSY" value="5" enum="CursorShape"> + </constant> + <constant name="CURSOR_DRAG" value="6" enum="CursorShape"> + </constant> + <constant name="CURSOR_CAN_DROP" value="7" enum="CursorShape"> + </constant> + <constant name="CURSOR_FORBIDDEN" value="8" enum="CursorShape"> + </constant> + <constant name="CURSOR_VSIZE" value="9" enum="CursorShape"> + </constant> + <constant name="CURSOR_HSIZE" value="10" enum="CursorShape"> + </constant> + <constant name="CURSOR_BDIAGSIZE" value="11" enum="CursorShape"> + </constant> + <constant name="CURSOR_FDIAGSIZE" value="12" enum="CursorShape"> + </constant> + <constant name="CURSOR_MOVE" value="13" enum="CursorShape"> + </constant> + <constant name="CURSOR_VSPLIT" value="14" enum="CursorShape"> + </constant> + <constant name="CURSOR_HSPLIT" value="15" enum="CursorShape"> + </constant> + <constant name="CURSOR_HELP" value="16" enum="CursorShape"> + </constant> + <constant name="CURSOR_MAX" value="17" enum="CursorShape"> + </constant> + <constant name="WINDOW_MODE_WINDOWED" value="0" enum="WindowMode"> + </constant> + <constant name="WINDOW_MODE_MINIMIZED" value="1" enum="WindowMode"> + </constant> + <constant name="WINDOW_MODE_MAXIMIZED" value="2" enum="WindowMode"> + </constant> + <constant name="WINDOW_MODE_FULLSCREEN" value="3" enum="WindowMode"> + </constant> + <constant name="WINDOW_FLAG_RESIZE_DISABLED" value="0" enum="WindowFlags"> + </constant> + <constant name="WINDOW_FLAG_BORDERLESS" value="1" enum="WindowFlags"> + </constant> + <constant name="WINDOW_FLAG_ALWAYS_ON_TOP" value="2" enum="WindowFlags"> + </constant> + <constant name="WINDOW_FLAG_TRANSPARENT" value="3" enum="WindowFlags"> + </constant> + <constant name="WINDOW_FLAG_NO_FOCUS" value="4" enum="WindowFlags"> + </constant> + <constant name="WINDOW_FLAG_MAX" value="5" enum="WindowFlags"> + </constant> + <constant name="WINDOW_FLAG_RESIZE_DISABLED_BIT" value="1" enum="WindowFlags"> + </constant> + <constant name="WINDOW_FLAG_BORDERLESS_BIT" value="2" enum="WindowFlags"> + </constant> + <constant name="WINDOW_FLAG_ALWAYS_ON_TOP_BIT" value="4" enum="WindowFlags"> + </constant> + <constant name="WINDOW_FLAG_TRANSPARENT_BIT" value="8" enum="WindowFlags"> + </constant> + <constant name="WINDOW_FLAG_NO_FOCUS_BIT" value="16" enum="WindowFlags"> + </constant> + <constant name="LATIN_KEYBOARD_QWERTY" value="0" enum="LatinKeyboardVariant"> + </constant> + <constant name="LATIN_KEYBOARD_QWERTZ" value="1" enum="LatinKeyboardVariant"> + </constant> + <constant name="LATIN_KEYBOARD_AZERTY" value="2" enum="LatinKeyboardVariant"> + </constant> + <constant name="LATIN_KEYBOARD_QZERTY" value="3" enum="LatinKeyboardVariant"> + </constant> + <constant name="LATIN_KEYBOARD_DVORAK" value="4" enum="LatinKeyboardVariant"> + </constant> + <constant name="LATIN_KEYBOARD_NEO" value="5" enum="LatinKeyboardVariant"> + </constant> + <constant name="LATIN_KEYBOARD_COLEMAK" value="6" enum="LatinKeyboardVariant"> + </constant> + <constant name="WINDOW_EVENT_MOUSE_ENTER" value="0" enum="WindowEvent"> + </constant> + <constant name="WINDOW_EVENT_MOUSE_EXIT" value="1" enum="WindowEvent"> + </constant> + <constant name="WINDOW_EVENT_FOCUS_IN" value="2" enum="WindowEvent"> + </constant> + <constant name="WINDOW_EVENT_FOCUS_OUT" value="3" enum="WindowEvent"> + </constant> + <constant name="WINDOW_EVENT_CLOSE_REQUEST" value="4" enum="WindowEvent"> + </constant> + <constant name="WINDOW_EVENT_GO_BACK_REQUEST" value="5" enum="WindowEvent"> + </constant> + <constant name="WINDOW_EVENT_DPI_CHANGE" value="6" enum="WindowEvent"> + </constant> + </constants> +</class> diff --git a/doc/classes/EditorFileDialog.xml b/doc/classes/EditorFileDialog.xml index 3e6bbd682d..084459e518 100644 --- a/doc/classes/EditorFileDialog.xml +++ b/doc/classes/EditorFileDialog.xml @@ -60,14 +60,13 @@ <member name="display_mode" type="int" setter="set_display_mode" getter="get_display_mode" enum="EditorFileDialog.DisplayMode" default="0"> The view format in which the [EditorFileDialog] displays resources to the user. </member> - <member name="mode" type="int" setter="set_mode" getter="get_mode" enum="EditorFileDialog.Mode" default="4"> - The purpose of the [EditorFileDialog], which defines the allowed behaviors. + <member name="file_mode" type="int" setter="set_file_mode" getter="get_file_mode" enum="EditorFileDialog.FileMode" default="4"> + The dialog's open or save mode, which affects the selection behavior. See [enum FileMode] </member> - <member name="resizable" type="bool" setter="set_resizable" getter="get_resizable" override="true" default="true" /> <member name="show_hidden_files" type="bool" setter="set_show_hidden_files" getter="is_showing_hidden_files" default="false"> If [code]true[/code], hidden files and directories will be visible in the [EditorFileDialog]. </member> - <member name="window_title" type="String" setter="set_title" getter="get_title" override="true" default=""Save a File"" /> + <member name="title" type="String" setter="set_title" getter="get_title" override="true" default=""Save a File"" /> </members> <signals> <signal name="dir_selected"> @@ -93,19 +92,19 @@ </signal> </signals> <constants> - <constant name="MODE_OPEN_FILE" value="0" enum="Mode"> + <constant name="FILE_MODE_OPEN_FILE" value="0" enum="FileMode"> The [EditorFileDialog] can select only one file. Accepting the window will open the file. </constant> - <constant name="MODE_OPEN_FILES" value="1" enum="Mode"> + <constant name="FILE_MODE_OPEN_FILES" value="1" enum="FileMode"> The [EditorFileDialog] can select multiple files. Accepting the window will open all files. </constant> - <constant name="MODE_OPEN_DIR" value="2" enum="Mode"> + <constant name="FILE_MODE_OPEN_DIR" value="2" enum="FileMode"> The [EditorFileDialog] can select only one directory. Accepting the window will open the directory. </constant> - <constant name="MODE_OPEN_ANY" value="3" enum="Mode"> + <constant name="FILE_MODE_OPEN_ANY" value="3" enum="FileMode"> The [EditorFileDialog] can select a file or directory. Accepting the window will open it. </constant> - <constant name="MODE_SAVE_FILE" value="4" enum="Mode"> + <constant name="FILE_MODE_SAVE_FILE" value="4" enum="FileMode"> The [EditorFileDialog] can select only one file. Accepting the window will save the file. </constant> <constant name="ACCESS_RESOURCES" value="0" enum="Access"> diff --git a/doc/classes/Environment.xml b/doc/classes/Environment.xml index c2e250d491..18d1fc8eca 100644 --- a/doc/classes/Environment.xml +++ b/doc/classes/Environment.xml @@ -137,10 +137,6 @@ <member name="fog_transmit_enabled" type="bool" setter="set_fog_transmit_enabled" getter="is_fog_transmit_enabled" default="false"> Enables fog's light transmission effect. If [code]true[/code], light will be more visible in the fog to simulate light scattering as in real life. </member> - <member name="glow_bicubic_upscale" type="bool" setter="set_glow_bicubic_upscale" getter="is_glow_bicubic_upscale_enabled" default="false"> - Smooths out the blockiness created by sampling higher levels, at the cost of performance. - [b]Note:[/b] When using the GLES2 renderer, this is only available if the GPU supports the [code]GL_EXT_gpu_shader4[/code] extension. - </member> <member name="glow_blend_mode" type="int" setter="set_glow_blend_mode" getter="get_glow_blend_mode" enum="Environment.GlowBlendMode" default="2"> The glow blending mode. </member> diff --git a/doc/classes/FileDialog.xml b/doc/classes/FileDialog.xml index 78fcec33ea..99563ee367 100644 --- a/doc/classes/FileDialog.xml +++ b/doc/classes/FileDialog.xml @@ -68,19 +68,19 @@ The currently selected file path of the file dialog. </member> <member name="dialog_hide_on_ok" type="bool" setter="set_hide_on_ok" getter="get_hide_on_ok" override="true" default="false" /> + <member name="file_mode" type="int" setter="set_file_mode" getter="get_file_mode" enum="FileDialog.FileMode" default="4"> + The dialog's open or save mode, which affects the selection behavior. See [enum FileMode]. + </member> <member name="filters" type="PackedStringArray" setter="set_filters" getter="get_filters" default="PackedStringArray( )"> The available file type filters. For example, this shows only [code].png[/code] and [code].gd[/code] files: [code]set_filters(PackedStringArray(["*.png ; PNG Images","*.gd ; GDScript Files"]))[/code]. </member> - <member name="mode" type="int" setter="set_mode" getter="get_mode" enum="FileDialog.Mode" default="4"> - The dialog's open or save mode, which affects the selection behavior. See enum [code]Mode[/code] constants. - </member> <member name="mode_overrides_title" type="bool" setter="set_mode_overrides_title" getter="is_mode_overriding_title" default="true"> - If [code]true[/code], changing the [code]Mode[/code] property will set the window title accordingly (e.g. setting mode to [constant MODE_OPEN_FILE] will change the window title to "Open a File"). + If [code]true[/code], changing the [code]Mode[/code] property will set the window title accordingly (e.g. setting mode to [constant FILE_MODE_OPEN_FILE] will change the window title to "Open a File"). </member> <member name="show_hidden_files" type="bool" setter="set_show_hidden_files" getter="is_showing_hidden_files" default="false"> If [code]true[/code], the dialog will show hidden files. </member> - <member name="window_title" type="String" setter="set_title" getter="get_title" override="true" default=""Save a File"" /> + <member name="title" type="String" setter="set_title" getter="get_title" override="true" default=""Save a File"" /> </members> <signals> <signal name="dir_selected"> @@ -106,19 +106,19 @@ </signal> </signals> <constants> - <constant name="MODE_OPEN_FILE" value="0" enum="Mode"> + <constant name="FILE_MODE_OPEN_FILE" value="0" enum="FileMode"> The dialog allows selecting one, and only one file. </constant> - <constant name="MODE_OPEN_FILES" value="1" enum="Mode"> + <constant name="FILE_MODE_OPEN_FILES" value="1" enum="FileMode"> The dialog allows selecting multiple files. </constant> - <constant name="MODE_OPEN_DIR" value="2" enum="Mode"> + <constant name="FILE_MODE_OPEN_DIR" value="2" enum="FileMode"> The dialog only allows selecting a directory, disallowing the selection of any file. </constant> - <constant name="MODE_OPEN_ANY" value="3" enum="Mode"> + <constant name="FILE_MODE_OPEN_ANY" value="3" enum="FileMode"> The dialog allows selecting one file or directory. </constant> - <constant name="MODE_SAVE_FILE" value="4" enum="Mode"> + <constant name="FILE_MODE_SAVE_FILE" value="4" enum="FileMode"> The dialog will warn when a file exists. </constant> <constant name="ACCESS_RESOURCES" value="0" enum="Access"> diff --git a/doc/classes/InputEventKey.xml b/doc/classes/InputEventKey.xml index c8d0769b90..34afa90553 100644 --- a/doc/classes/InputEventKey.xml +++ b/doc/classes/InputEventKey.xml @@ -43,7 +43,7 @@ If [code]true[/code], the key's state is pressed. If [code]false[/code], the key's state is released. </member> <member name="unicode" type="int" setter="set_unicode" getter="get_unicode" default="0"> - The key Unicode identifier (when relevant). Unicode identifiers for the composite characters and complex scripts may not be available unless IME input mode is active. See [method OS.set_ime_active] for more information. + The key Unicode identifier (when relevant). Unicode identifiers for the composite characters and complex scripts may not be available unless IME input mode is active. See [method Window.set_ime_active] for more information. </member> </members> <constants> diff --git a/doc/classes/MainLoop.xml b/doc/classes/MainLoop.xml index af71c30936..7bb478fce2 100644 --- a/doc/classes/MainLoop.xml +++ b/doc/classes/MainLoop.xml @@ -7,6 +7,7 @@ [MainLoop] is the abstract base class for a Godot project's game loop. It is inherited by [SceneTree], which is the default game loop implementation used in Godot projects, though it is also possible to write and use one's own [MainLoop] subclass instead of the scene tree. Upon the application start, a [MainLoop] implementation must be provided to the OS; otherwise, the application will exit. This happens automatically (and a [SceneTree] is created) unless a main [Script] is provided from the command line (with e.g. [code]godot -s my_loop.gd[/code], which should then be a [MainLoop] implementation. Here is an example script implementing a simple [MainLoop]: + [b]FIXME:[/b] No longer valid after DisplayServer split and Input refactoring. [codeblock] extends MainLoop @@ -43,17 +44,6 @@ <tutorials> </tutorials> <methods> - <method name="_drop_files" qualifiers="virtual"> - <return type="void"> - </return> - <argument index="0" name="files" type="PackedStringArray"> - </argument> - <argument index="1" name="from_screen" type="int"> - </argument> - <description> - Called when files are dragged from the OS file manager and dropped in the game window. The arguments are a list of file paths and the identifier of the screen where the drag originated. - </description> - </method> <method name="_finalize" qualifiers="virtual"> <return type="void"> </return> @@ -61,17 +51,6 @@ Called before the program exits. </description> </method> - <method name="_global_menu_action" qualifiers="virtual"> - <return type="void"> - </return> - <argument index="0" name="id" type="Variant"> - </argument> - <argument index="1" name="meta" type="Variant"> - </argument> - <description> - Called when the user performs an action in the system global menu (e.g. the Mac OS menu bar). - </description> - </method> <method name="_idle" qualifiers="virtual"> <return type="bool"> </return> @@ -89,24 +68,6 @@ Called once during initialization. </description> </method> - <method name="_input_event" qualifiers="virtual"> - <return type="void"> - </return> - <argument index="0" name="event" type="InputEvent"> - </argument> - <description> - Called whenever an [InputEvent] is received by the main loop. - </description> - </method> - <method name="_input_text" qualifiers="virtual"> - <return type="void"> - </return> - <argument index="0" name="text" type="String"> - </argument> - <description> - Deprecated callback, does not do anything. Use [method _input_event] to parse text input. Will be removed in Godot 4.0. - </description> - </method> <method name="_iteration" qualifiers="virtual"> <return type="bool"> </return> @@ -140,24 +101,6 @@ Should not be called manually, override [method _initialize] instead. Will be removed in Godot 4.0. </description> </method> - <method name="input_event"> - <return type="void"> - </return> - <argument index="0" name="event" type="InputEvent"> - </argument> - <description> - Should not be called manually, override [method _input_event] instead. Will be removed in Godot 4.0. - </description> - </method> - <method name="input_text"> - <return type="void"> - </return> - <argument index="0" name="text" type="String"> - </argument> - <description> - Should not be called manually, override [method _input_text] instead. Will be removed in Godot 4.0. - </description> - </method> <method name="iteration"> <return type="bool"> </return> @@ -180,58 +123,30 @@ </signal> </signals> <constants> - <constant name="NOTIFICATION_WM_MOUSE_ENTER" value="1002"> - Notification received from the OS when the mouse enters the game window. - Implemented on desktop and web platforms. - </constant> - <constant name="NOTIFICATION_WM_MOUSE_EXIT" value="1003"> - Notification received from the OS when the mouse leaves the game window. - Implemented on desktop and web platforms. - </constant> - <constant name="NOTIFICATION_WM_FOCUS_IN" value="1004"> - Notification received from the OS when the game window is focused. - Implemented on all platforms. - </constant> - <constant name="NOTIFICATION_WM_FOCUS_OUT" value="1005"> - Notification received from the OS when the game window is unfocused. - Implemented on all platforms. - </constant> - <constant name="NOTIFICATION_WM_QUIT_REQUEST" value="1006"> - Notification received from the OS when a quit request is sent (e.g. closing the window with a "Close" button or Alt+F4). - Implemented on desktop platforms. - </constant> - <constant name="NOTIFICATION_WM_GO_BACK_REQUEST" value="1007"> - Notification received from the OS when a go back request is sent (e.g. pressing the "Back" button on Android). - Specific to the Android platform. - </constant> - <constant name="NOTIFICATION_WM_UNFOCUS_REQUEST" value="1008"> - Notification received from the OS when an unfocus request is sent (e.g. another OS window wants to take the focus). - No supported platforms currently send this notification. - </constant> - <constant name="NOTIFICATION_OS_MEMORY_WARNING" value="1009"> + <constant name="NOTIFICATION_OS_MEMORY_WARNING" value="2009"> Notification received from the OS when the application is exceeding its allocated memory. Specific to the iOS platform. </constant> - <constant name="NOTIFICATION_TRANSLATION_CHANGED" value="1010"> + <constant name="NOTIFICATION_TRANSLATION_CHANGED" value="2010"> Notification received when translations may have changed. Can be triggered by the user changing the locale. Can be used to respond to language changes, for example to change the UI strings on the fly. Useful when working with the built-in translation support, like [method Object.tr]. </constant> - <constant name="NOTIFICATION_WM_ABOUT" value="1011"> + <constant name="NOTIFICATION_WM_ABOUT" value="2011"> Notification received from the OS when a request for "About" information is sent. Specific to the macOS platform. </constant> - <constant name="NOTIFICATION_CRASH" value="1012"> + <constant name="NOTIFICATION_CRASH" value="2012"> Notification received from Godot's crash handler when the engine is about to crash. Implemented on desktop platforms if the crash handler is enabled. </constant> - <constant name="NOTIFICATION_OS_IME_UPDATE" value="1013"> + <constant name="NOTIFICATION_OS_IME_UPDATE" value="2013"> Notification received from the OS when an update of the Input Method Engine occurs (e.g. change of IME cursor position or composition string). Specific to the macOS platform. </constant> - <constant name="NOTIFICATION_APP_RESUMED" value="1014"> + <constant name="NOTIFICATION_APP_RESUMED" value="2014"> Notification received from the OS when the app is resumed. Specific to the Android platform. </constant> - <constant name="NOTIFICATION_APP_PAUSED" value="1015"> + <constant name="NOTIFICATION_APP_PAUSED" value="2015"> Notification received from the OS when the app is paused. Specific to the Android platform. </constant> diff --git a/doc/classes/MenuButton.xml b/doc/classes/MenuButton.xml index 6ec9d60df4..316315f777 100644 --- a/doc/classes/MenuButton.xml +++ b/doc/classes/MenuButton.xml @@ -38,9 +38,9 @@ <member name="toggle_mode" type="bool" setter="set_toggle_mode" getter="is_toggle_mode" override="true" default="true" /> </members> <signals> - <signal name="about_to_show"> + <signal name="about_to_popup"> <description> - Emitted when [PopupMenu] of this MenuButton is about to show. + Emitted when the [PopupMenu] of this MenuButton is about to show. </description> </signal> </signals> diff --git a/doc/classes/Node.xml b/doc/classes/Node.xml index 717130728d..d7bff83575 100644 --- a/doc/classes/Node.xml +++ b/doc/classes/Node.xml @@ -53,7 +53,7 @@ <description> Called when there is an input event. The input event propagates up through the node tree until a node consumes it. It is only called if input processing is enabled, which is done automatically if this method is overridden, and can be toggled with [method set_process_input]. - To consume the input event and stop it propagating further to other nodes, [method SceneTree.set_input_as_handled] can be called. + To consume the input event and stop it propagating further to other nodes, [method Viewport.set_input_as_handled] can be called. For gameplay input, [method _unhandled_input] and [method _unhandled_key_input] are usually a better fit as they allow the GUI to intercept the events first. </description> </method> @@ -97,7 +97,7 @@ <description> Called when an [InputEvent] hasn't been consumed by [method _input] or any GUI. The input event propagates up through the node tree until a node consumes it. It is only called if unhandled input processing is enabled, which is done automatically if this method is overridden, and can be toggled with [method set_process_unhandled_input]. - To consume the input event and stop it propagating further to other nodes, [method SceneTree.set_input_as_handled] can be called. + To consume the input event and stop it propagating further to other nodes, [method Viewport.set_input_as_handled] can be called. For gameplay input, this and [method _unhandled_key_input] are usually a better fit than [method _input] as they allow the GUI to intercept the events first. </description> </method> @@ -109,7 +109,7 @@ <description> Called when an [InputEventKey] hasn't been consumed by [method _input] or any GUI. The input event propagates up through the node tree until a node consumes it. It is only called if unhandled key input processing is enabled, which is done automatically if this method is overridden, and can be toggled with [method set_process_unhandled_key_input]. - To consume the input event and stop it propagating further to other nodes, [method SceneTree.set_input_as_handled] can be called. + To consume the input event and stop it propagating further to other nodes, [method Viewport.set_input_as_handled] can be called. For gameplay input, this and [method _unhandled_input] are usually a better fit than [method _input] as they allow the GUI to intercept the events first. </description> </method> @@ -938,42 +938,40 @@ Notification received from the OS when the game window is unfocused. Implemented on all platforms. </constant> - <constant name="NOTIFICATION_WM_QUIT_REQUEST" value="1006"> - Notification received from the OS when a quit request is sent (e.g. closing the window with a "Close" button or Alt+F4). + <constant name="NOTIFICATION_WM_CLOSE_REQUEST" value="1006"> + Notification received from the OS when a close request is sent (e.g. closing the window with a "Close" button or Alt+F4). Implemented on desktop platforms. </constant> <constant name="NOTIFICATION_WM_GO_BACK_REQUEST" value="1007"> Notification received from the OS when a go back request is sent (e.g. pressing the "Back" button on Android). Specific to the Android platform. </constant> - <constant name="NOTIFICATION_WM_UNFOCUS_REQUEST" value="1008"> - Notification received from the OS when an unfocus request is sent (e.g. another OS window wants to take the focus). - No supported platforms currently send this notification. + <constant name="NOTIFICATION_WM_SIZE_CHANGED" value="1008"> </constant> - <constant name="NOTIFICATION_OS_MEMORY_WARNING" value="1009"> + <constant name="NOTIFICATION_OS_MEMORY_WARNING" value="2009"> Notification received from the OS when the application is exceeding its allocated memory. Specific to the iOS platform. </constant> - <constant name="NOTIFICATION_TRANSLATION_CHANGED" value="1010"> + <constant name="NOTIFICATION_TRANSLATION_CHANGED" value="2010"> Notification received when translations may have changed. Can be triggered by the user changing the locale. Can be used to respond to language changes, for example to change the UI strings on the fly. Useful when working with the built-in translation support, like [method Object.tr]. </constant> - <constant name="NOTIFICATION_WM_ABOUT" value="1011"> + <constant name="NOTIFICATION_WM_ABOUT" value="2011"> Notification received from the OS when a request for "About" information is sent. Specific to the macOS platform. </constant> - <constant name="NOTIFICATION_CRASH" value="1012"> + <constant name="NOTIFICATION_CRASH" value="2012"> Notification received from Godot's crash handler when the engine is about to crash. Implemented on desktop platforms if the crash handler is enabled. </constant> - <constant name="NOTIFICATION_OS_IME_UPDATE" value="1013"> + <constant name="NOTIFICATION_OS_IME_UPDATE" value="2013"> Notification received from the OS when an update of the Input Method Engine occurs (e.g. change of IME cursor position or composition string). Specific to the macOS platform. </constant> - <constant name="NOTIFICATION_APP_RESUMED" value="1014"> + <constant name="NOTIFICATION_APP_RESUMED" value="2014"> Notification received from the OS when the app is resumed. Specific to the Android platform. </constant> - <constant name="NOTIFICATION_APP_PAUSED" value="1015"> + <constant name="NOTIFICATION_APP_PAUSED" value="2015"> Notification received from the OS when the app is paused. Specific to the Android platform. </constant> diff --git a/doc/classes/OS.xml b/doc/classes/OS.xml index d43c395433..db79ee7765 100644 --- a/doc/classes/OS.xml +++ b/doc/classes/OS.xml @@ -9,24 +9,6 @@ <tutorials> </tutorials> <methods> - <method name="alert"> - <return type="void"> - </return> - <argument index="0" name="text" type="String"> - </argument> - <argument index="1" name="title" type="String" default=""Alert!""> - </argument> - <description> - Displays a modal dialog box using the host OS' facilities. Execution is blocked until the dialog is closed. - </description> - </method> - <method name="can_draw" qualifiers="const"> - <return type="bool"> - </return> - <description> - Returns [code]true[/code] if the host OS allows drawing. - </description> - </method> <method name="can_use_threads" qualifiers="const"> <return type="bool"> </return> @@ -34,13 +16,6 @@ Returns [code]true[/code] if the current host platform is using multiple threads. </description> </method> - <method name="center_window"> - <return type="void"> - </return> - <description> - Centers the window on the screen if in windowed mode. - </description> - </method> <method name="close_midi_inputs"> <return type="void"> </return> @@ -133,22 +108,6 @@ Returns the keycode of the given string (e.g. "Escape"). </description> </method> - <method name="get_audio_driver_count" qualifiers="const"> - <return type="int"> - </return> - <description> - Returns the total number of available audio drivers. - </description> - </method> - <method name="get_audio_driver_name" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="driver" type="int"> - </argument> - <description> - Returns the audio driver name for the given index. - </description> - </method> <method name="get_cmdline_args"> <return type="PackedStringArray"> </return> @@ -165,13 +124,6 @@ [b]Note:[/b] This method is implemented on Linux, macOS and Windows. </description> </method> - <method name="get_current_video_driver" qualifiers="const"> - <return type="int" enum="OS.VideoDriver"> - </return> - <description> - Returns the currently used video driver, using one of the values from [enum VideoDriver]. - </description> - </method> <method name="get_date" qualifiers="const"> <return type="Dictionary"> </return> @@ -224,24 +176,6 @@ [b]Note:[/b] This method is implemented on Android. </description> </method> - <method name="get_ime_selection" qualifiers="const"> - <return type="Vector2"> - </return> - <description> - Returns the IME cursor position (the currently-edited portion of the string) relative to the characters in the composition string. - [constant MainLoop.NOTIFICATION_OS_IME_UPDATE] is sent to the application to notify it of changes to the IME cursor position. - [b]Note:[/b] This method is implemented on macOS. - </description> - </method> - <method name="get_ime_text" qualifiers="const"> - <return type="String"> - </return> - <description> - Returns the IME intermediate composition string. - [constant MainLoop.NOTIFICATION_OS_IME_UPDATE] is sent to the application to notify it of changes to the IME composition string. - [b]Note:[/b] This method is implemented on macOS. - </description> - </method> <method name="get_keycode_string" qualifiers="const"> <return type="String"> </return> @@ -252,15 +186,6 @@ See also [member InputEventKey.keycode] and [method InputEventKey.get_keycode_with_modifiers]. </description> </method> - <method name="get_latin_keyboard_variant" qualifiers="const"> - <return type="String"> - </return> - <description> - Returns the current latin keyboard variant as a String. - Possible return values are: [code]"QWERTY"[/code], [code]"AZERTY"[/code], [code]"QZERTY"[/code], [code]"DVORAK"[/code], [code]"NEO"[/code], [code]"COLEMAK"[/code] or [code]"ERROR"[/code]. - [b]Note:[/b] This method is implemented on Linux, macOS and Windows. Returns [code]"QWERTY"[/code] on unsupported platforms. - </description> - </method> <method name="get_locale" qualifiers="const"> <return type="String"> </return> @@ -298,57 +223,6 @@ Returns the number of threads available on the host machine. </description> </method> - <method name="get_real_window_size" qualifiers="const"> - <return type="Vector2"> - </return> - <description> - Returns the window size including decorations like window borders. - </description> - </method> - <method name="get_screen_count" qualifiers="const"> - <return type="int"> - </return> - <description> - Returns the number of displays attached to the host machine. - </description> - </method> - <method name="get_screen_dpi" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="screen" type="int" default="-1"> - </argument> - <description> - Returns the dots per inch density of the specified screen. If [code]screen[/code] is [/code]-1[/code] (the default value), the current screen will be used. - On Android devices, the actual screen densities are grouped into six generalized densities: - [codeblock] - ldpi - 120 dpi - mdpi - 160 dpi - hdpi - 240 dpi - xhdpi - 320 dpi - xxhdpi - 480 dpi - xxxhdpi - 640 dpi - [/codeblock] - [b]Note:[/b] This method is implemented on Android, Linux, macOS and Windows. Returns [code]72[/code] on unsupported platforms. - </description> - </method> - <method name="get_screen_position" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="screen" type="int" default="-1"> - </argument> - <description> - Returns the position of the specified screen by index. If [code]screen[/code] is [/code]-1[/code] (the default value), the current screen will be used. - </description> - </method> - <method name="get_screen_size" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="screen" type="int" default="-1"> - </argument> - <description> - Returns the dimensions in pixels of the specified screen. If [code]screen[/code] is [/code]-1[/code] (the default value), the current screen will be used. - </description> - </method> <method name="get_splash_tick_msec" qualifiers="const"> <return type="int"> </return> @@ -461,84 +335,6 @@ If the project name is empty, [code]user://[/code] falls back to [code]res://[/code]. </description> </method> - <method name="get_video_driver_count" qualifiers="const"> - <return type="int"> - </return> - <description> - Returns the number of video drivers supported on the current platform. - </description> - </method> - <method name="get_video_driver_name" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="driver" type="int" enum="OS.VideoDriver"> - </argument> - <description> - Returns the name of the video driver matching the given [code]driver[/code] index. This index is a value from [enum VideoDriver], and you can use [method get_current_video_driver] to get the current backend's index. - </description> - </method> - <method name="get_virtual_keyboard_height"> - <return type="int"> - </return> - <description> - Returns the on-screen keyboard's height in pixels. Returns 0 if there is no keyboard or if it is currently hidden. - </description> - </method> - <method name="get_window_safe_area" qualifiers="const"> - <return type="Rect2"> - </return> - <description> - Returns unobscured area of the window where interactive controls should be rendered. - </description> - </method> - <method name="global_menu_add_item"> - <return type="void"> - </return> - <argument index="0" name="menu" type="String"> - </argument> - <argument index="1" name="label" type="String"> - </argument> - <argument index="2" name="id" type="Variant"> - </argument> - <argument index="3" name="meta" type="Variant"> - </argument> - <description> - Add a new item with text "label" to global menu. Use "_dock" menu to add item to the macOS dock icon menu. - [b]Note:[/b] This method is implemented on macOS. - </description> - </method> - <method name="global_menu_add_separator"> - <return type="void"> - </return> - <argument index="0" name="menu" type="String"> - </argument> - <description> - Add a separator between items. Separators also occupy an index. - [b]Note:[/b] This method is implemented on macOS. - </description> - </method> - <method name="global_menu_clear"> - <return type="void"> - </return> - <argument index="0" name="menu" type="String"> - </argument> - <description> - Clear the global menu, in effect removing all items. - [b]Note:[/b] This method is implemented on macOS. - </description> - </method> - <method name="global_menu_remove_item"> - <return type="void"> - </return> - <argument index="0" name="menu" type="String"> - </argument> - <argument index="1" name="idx" type="int"> - </argument> - <description> - Removes the item at index "idx" from the global menu. Note that the indexes of items after the removed item are going to be shifted by one. - [b]Note:[/b] This method is implemented on macOS. - </description> - </method> <method name="has_environment" qualifiers="const"> <return type="bool"> </return> @@ -558,27 +354,6 @@ [b]Note:[/b] Tag names are case-sensitive. </description> </method> - <method name="has_touchscreen_ui_hint" qualifiers="const"> - <return type="bool"> - </return> - <description> - Returns [code]true[/code] if the device has a touchscreen or emulates one. - </description> - </method> - <method name="has_virtual_keyboard" qualifiers="const"> - <return type="bool"> - </return> - <description> - Returns [code]true[/code] if the platform has a virtual keyboard, [code]false[/code] otherwise. - </description> - </method> - <method name="hide_virtual_keyboard"> - <return type="void"> - </return> - <description> - Hides the virtual keyboard if it is shown, does nothing otherwise. - </description> - </method> <method name="is_debug_build" qualifiers="const"> <return type="bool"> </return> @@ -597,13 +372,6 @@ Returns [code]true[/code] if the input keycode corresponds to a Unicode character. </description> </method> - <method name="is_ok_left_and_cancel_right" qualifiers="const"> - <return type="bool"> - </return> - <description> - Returns [code]true[/code] if the [b]OK[/b] button should appear on the left and [b]Cancel[/b] on the right. - </description> - </method> <method name="is_stdout_verbose" qualifiers="const"> <return type="bool"> </return> @@ -618,21 +386,6 @@ If [code]true[/code], the [code]user://[/code] file system is persistent, so that its state is the same after a player quits and starts the game again. Relevant to the HTML5 platform, where this persistence may be unavailable. </description> </method> - <method name="is_window_always_on_top" qualifiers="const"> - <return type="bool"> - </return> - <description> - Returns [code]true[/code] if the window should always be on top of other windows. - </description> - </method> - <method name="is_window_focused" qualifiers="const"> - <return type="bool"> - </return> - <description> - Returns [code]true[/code] if the window is currently focused. - [b]Note:[/b] Only implemented on desktop platforms. On other platforms, it will always return [code]true[/code]. - </description> - </method> <method name="kill"> <return type="int" enum="Error"> </return> @@ -644,62 +397,6 @@ [b]Note:[/b] This method is implemented on Android, iOS, Linux, macOS and Windows. </description> </method> - <method name="move_window_to_foreground"> - <return type="void"> - </return> - <description> - Moves the window to the front. - [b]Note:[/b] This method is implemented on Linux, macOS and Windows. - </description> - </method> - <method name="native_video_is_playing"> - <return type="bool"> - </return> - <description> - Returns [code]true[/code] if native video is playing. - [b]Note:[/b] This method is implemented on Android and iOS. - </description> - </method> - <method name="native_video_pause"> - <return type="void"> - </return> - <description> - Pauses native video playback. - [b]Note:[/b] This method is implemented on Android and iOS. - </description> - </method> - <method name="native_video_play"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="path" type="String"> - </argument> - <argument index="1" name="volume" type="float"> - </argument> - <argument index="2" name="audio_track" type="String"> - </argument> - <argument index="3" name="subtitle_track" type="String"> - </argument> - <description> - Plays native video from the specified path, at the given volume and with audio and subtitle tracks. - [b]Note:[/b] This method is implemented on Android and iOS, and the current Android implementation does not support the [code]volume[/code], [code]audio_track[/code] and [code]subtitle_track[/code] options. - </description> - </method> - <method name="native_video_stop"> - <return type="void"> - </return> - <description> - Stops native video playback. - [b]Note:[/b] This method is implemented on Android and iOS. - </description> - </method> - <method name="native_video_unpause"> - <return type="void"> - </return> - <description> - Resumes native video playback. - [b]Note:[/b] This method is implemented on Android and iOS. - </description> - </method> <method name="open_midi_inputs"> <return type="void"> </return> @@ -742,14 +439,6 @@ Shows all resources currently used by the game. </description> </method> - <method name="request_attention"> - <return type="void"> - </return> - <description> - Request the user attention to the window. It'll flash the taskbar button on Windows or bounce the dock icon on OSX. - [b]Note:[/b] This method is implemented on Linux, macOS and Windows. - </description> - </method> <method name="request_permission"> <return type="bool"> </return> @@ -767,51 +456,6 @@ [b]Note:[/b] This method is implemented on Android. </description> </method> - <method name="set_icon"> - <return type="void"> - </return> - <argument index="0" name="icon" type="Image"> - </argument> - <description> - Sets the game's icon using an [Image] resource. - The same image is used for window caption, taskbar/dock and window selection dialog. Image is scaled as needed. - [b]Note:[/b] This method is implemented on HTML5, Linux, macOS and Windows. - </description> - </method> - <method name="set_ime_active"> - <return type="void"> - </return> - <argument index="0" name="active" type="bool"> - </argument> - <description> - Sets whether IME input mode should be enabled. - If active IME handles key events before the application and creates an composition string and suggestion list. - Application can retrieve the composition status by using [method get_ime_selection] and [method get_ime_text] functions. - Completed composition string is committed when input is finished. - [b]Note:[/b] This method is implemented on Linux, macOS and Windows. - </description> - </method> - <method name="set_ime_position"> - <return type="void"> - </return> - <argument index="0" name="position" type="Vector2"> - </argument> - <description> - Sets position of IME suggestion list popup (in window coordinates). - [b]Note:[/b] This method is implemented on Linux, macOS and Windows. - </description> - </method> - <method name="set_native_icon"> - <return type="void"> - </return> - <argument index="0" name="filename" type="String"> - </argument> - <description> - Sets the game's icon using a multi-size platform-specific icon file ([code]*.ico[/code] on Windows and [code]*.icns[/code] on macOS). - Appropriate size sub-icons are used for window caption, taskbar/dock and window selection dialog. - [b]Note:[/b] This method is implemented on macOS and Windows. - </description> - </method> <method name="set_thread_name"> <return type="int" enum="Error"> </return> @@ -830,27 +474,6 @@ Enables backup saves if [code]enabled[/code] is [code]true[/code]. </description> </method> - <method name="set_window_always_on_top"> - <return type="void"> - </return> - <argument index="0" name="enabled" type="bool"> - </argument> - <description> - Sets whether the window should always be on top. - [b]Note:[/b] This method is implemented on Linux, macOS and Windows. - </description> - </method> - <method name="set_window_title"> - <return type="void"> - </return> - <argument index="0" name="title" type="String"> - </argument> - <description> - Sets the window title to the specified string. - [b]Note:[/b] This should be used sporadically. Don't set this every frame, as that will negatively affect performance on some window managers. - [b]Note:[/b] This method is implemented on HTML5, Linux, macOS and Windows. - </description> - </method> <method name="shell_open"> <return type="int" enum="Error"> </return> @@ -864,82 +487,18 @@ [b]Note:[/b] This method is implemented on Android, iOS, HTML5, Linux, macOS and Windows. </description> </method> - <method name="show_virtual_keyboard"> - <return type="void"> - </return> - <argument index="0" name="existing_text" type="String" default=""""> - </argument> - <description> - Shows the virtual keyboard if the platform has one. The [code]existing_text[/code] parameter is useful for implementing your own LineEdit, as it tells the virtual keyboard what text has already been typed (the virtual keyboard uses it for auto-correct and predictions). - [b]Note:[/b] This method is implemented on Android, iOS and UWP. - </description> - </method> </methods> <members> - <member name="clipboard" type="String" setter="set_clipboard" getter="get_clipboard" default=""""> - The clipboard from the host OS. Might be unavailable on some platforms. - </member> - <member name="current_screen" type="int" setter="set_current_screen" getter="get_current_screen" default="0"> - The current screen index (starting from 0). - </member> <member name="exit_code" type="int" setter="set_exit_code" getter="get_exit_code" default="0"> The exit code passed to the OS when the main loop exits. By convention, an exit code of [code]0[/code] indicates success whereas a non-zero exit code indicates an error. For portability reasons, the exit code should be set between 0 and 125 (inclusive). [b]Note:[/b] This value will be ignored if using [method SceneTree.quit] with an [code]exit_code[/code] argument passed. </member> - <member name="keep_screen_on" type="bool" setter="set_keep_screen_on" getter="is_keep_screen_on" default="true"> - If [code]true[/code], the engine tries to keep the screen on while the game is running. Useful on mobile. - </member> <member name="low_processor_usage_mode" type="bool" setter="set_low_processor_usage_mode" getter="is_in_low_processor_usage_mode" default="false"> If [code]true[/code], the engine optimizes for low processor usage by only refreshing the screen if needed. Can improve battery consumption on mobile. </member> <member name="low_processor_usage_mode_sleep_usec" type="int" setter="set_low_processor_usage_mode_sleep_usec" getter="get_low_processor_usage_mode_sleep_usec" default="6900"> The amount of sleeping between frames when the low-processor usage mode is enabled (in microseconds). Higher values will result in lower CPU usage. </member> - <member name="max_window_size" type="Vector2" setter="set_max_window_size" getter="get_max_window_size" default="Vector2( 0, 0 )"> - The maximum size of the window (without counting window manager decorations). Does not affect fullscreen mode. Set to [code](0, 0)[/code] to reset to the system default value. - </member> - <member name="min_window_size" type="Vector2" setter="set_min_window_size" getter="get_min_window_size" default="Vector2( 0, 0 )"> - The minimum size of the window (without counting window manager decorations). Does not affect fullscreen mode. Set to [code](0, 0)[/code] to reset to the system default value. - </member> - <member name="screen_orientation" type="int" setter="set_screen_orientation" getter="get_screen_orientation" enum="_OS.ScreenOrientation" default="0"> - The current screen orientation. - </member> - <member name="vsync_enabled" type="bool" setter="set_use_vsync" getter="is_vsync_enabled" default="true"> - If [code]true[/code], vertical synchronization (Vsync) is enabled. - </member> - <member name="vsync_via_compositor" type="bool" setter="set_vsync_via_compositor" getter="is_vsync_via_compositor_enabled" default="false"> - If [code]true[/code] and [code]vsync_enabled[/code] is true, the operating system's window compositor will be used for vsync when the compositor is enabled and the game is in windowed mode. - [b]Note:[/b] This option is experimental and meant to alleviate stutter experienced by some users. However, some users have experienced a Vsync framerate halving (e.g. from 60 FPS to 30 FPS) when using it. - [b]Note:[/b] This property is only implemented on Windows. - </member> - <member name="window_borderless" type="bool" setter="set_borderless_window" getter="get_borderless_window" default="false"> - If [code]true[/code], removes the window frame. - [b]Note:[/b] Setting [code]window_borderless[/code] to [code]false[/code] disables per-pixel transparency. - </member> - <member name="window_fullscreen" type="bool" setter="set_window_fullscreen" getter="is_window_fullscreen" default="false"> - If [code]true[/code], the window is fullscreen. - </member> - <member name="window_maximized" type="bool" setter="set_window_maximized" getter="is_window_maximized" default="false"> - If [code]true[/code], the window is maximized. - </member> - <member name="window_minimized" type="bool" setter="set_window_minimized" getter="is_window_minimized" default="false"> - If [code]true[/code], the window is minimized. - </member> - <member name="window_per_pixel_transparency_enabled" type="bool" setter="set_window_per_pixel_transparency_enabled" getter="get_window_per_pixel_transparency_enabled" default="false"> - If [code]true[/code], the window background is transparent and window frame is removed. - Use [code]get_tree().get_root().set_transparent_background(true)[/code] to disable main viewport background rendering. - [b]Note:[/b] This property has no effect if [b]Project > Project Settings > Display > Window > Per-pixel transparency > Allowed[/b] setting is disabled. - [b]Note:[/b] This property is implemented on HTML5, Linux, macOS and Windows. - </member> - <member name="window_position" type="Vector2" setter="set_window_position" getter="get_window_position" default="Vector2( 0, 0 )"> - The window position relative to the screen, the origin is the top left corner, +Y axis goes to the bottom and +X axis goes to the right. - </member> - <member name="window_resizable" type="bool" setter="set_window_resizable" getter="is_window_resizable" default="true"> - If [code]true[/code], the window is resizable by the user. - </member> - <member name="window_size" type="Vector2" setter="set_window_size" getter="get_window_size" default="Vector2( 0, 0 )"> - The size of the window (without counting window manager decorations). - </member> </members> <constants> <constant name="VIDEO_DRIVER_GLES2" value="0" enum="VideoDriver"> @@ -1005,27 +564,6 @@ <constant name="MONTH_DECEMBER" value="12" enum="Month"> December. </constant> - <constant name="SCREEN_ORIENTATION_LANDSCAPE" value="0" enum="ScreenOrientation"> - Landscape screen orientation. - </constant> - <constant name="SCREEN_ORIENTATION_PORTRAIT" value="1" enum="ScreenOrientation"> - Portrait screen orientation. - </constant> - <constant name="SCREEN_ORIENTATION_REVERSE_LANDSCAPE" value="2" enum="ScreenOrientation"> - Reverse landscape screen orientation. - </constant> - <constant name="SCREEN_ORIENTATION_REVERSE_PORTRAIT" value="3" enum="ScreenOrientation"> - Reverse portrait screen orientation. - </constant> - <constant name="SCREEN_ORIENTATION_SENSOR_LANDSCAPE" value="4" enum="ScreenOrientation"> - Uses landscape or reverse landscape based on the hardware sensor. - </constant> - <constant name="SCREEN_ORIENTATION_SENSOR_PORTRAIT" value="5" enum="ScreenOrientation"> - Uses portrait or reverse portrait based on the hardware sensor. - </constant> - <constant name="SCREEN_ORIENTATION_SENSOR" value="6" enum="ScreenOrientation"> - Uses most suitable orientation based on the hardware sensor. - </constant> <constant name="SYSTEM_DIR_DESKTOP" value="0" enum="SystemDir"> Desktop directory path. </constant> diff --git a/doc/classes/Panel.xml b/doc/classes/Panel.xml index a3f6a0be8f..7285bc9e2e 100644 --- a/doc/classes/Panel.xml +++ b/doc/classes/Panel.xml @@ -10,11 +10,21 @@ </tutorials> <methods> </methods> + <members> + <member name="mode" type="int" setter="set_mode" getter="get_mode" enum="Panel.Mode" default="0"> + </member> + </members> <constants> + <constant name="MODE_BACKGROUND" value="0" enum="Mode"> + </constant> + <constant name="MODE_FOREGROUND" value="1" enum="Mode"> + </constant> </constants> <theme_items> <theme_item name="panel" type="StyleBox"> The style of this [Panel]. </theme_item> + <theme_item name="panel_fg" type="StyleBox"> + </theme_item> </theme_items> </class> diff --git a/doc/classes/Popup.xml b/doc/classes/Popup.xml index 483e262f60..6f77f3371d 100644 --- a/doc/classes/Popup.xml +++ b/doc/classes/Popup.xml @@ -1,81 +1,23 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Popup" inherits="Control" version="4.0"> +<class name="Popup" inherits="Window" version="4.0"> <brief_description> Base container control for popups and dialogs. </brief_description> <description> - Popup is a base [Control] used to show dialogs and popups. It's a subwindow and modal by default (see [Control]) and has helpers for custom popup behavior. All popup methods ensure correct placement within the viewport. + Popup is a base [Control] used to show dialogs and popups. It's a subwindow and modal by default (see [Control]) and has helpers for custom popup behavior. </description> <tutorials> </tutorials> <methods> - <method name="popup"> - <return type="void"> - </return> - <argument index="0" name="bounds" type="Rect2" default="Rect2( 0, 0, 0, 0 )"> - </argument> - <description> - Popup (show the control in modal form). - </description> - </method> - <method name="popup_centered"> - <return type="void"> - </return> - <argument index="0" name="size" type="Vector2" default="Vector2( 0, 0 )"> - </argument> - <description> - Popup (show the control in modal form) in the center of the screen relative to its current canvas transform, at the current size, or at a size determined by [code]size[/code]. - </description> - </method> - <method name="popup_centered_clamped"> - <return type="void"> - </return> - <argument index="0" name="size" type="Vector2" default="Vector2( 0, 0 )"> - </argument> - <argument index="1" name="fallback_ratio" type="float" default="0.75"> - </argument> - <description> - Popup (show the control in modal form) in the center of the screen relative to the current canvas transform, clamping the size to [code]size[/code], then ensuring the popup is no larger than the viewport size multiplied by [code]fallback_ratio[/code]. - </description> - </method> - <method name="popup_centered_minsize"> - <return type="void"> - </return> - <argument index="0" name="minsize" type="Vector2" default="Vector2( 0, 0 )"> - </argument> - <description> - Popup (show the control in modal form) in the center of the screen relative to the current canvas transform, ensuring the size is never smaller than [code]minsize[/code]. - </description> - </method> - <method name="popup_centered_ratio"> - <return type="void"> - </return> - <argument index="0" name="ratio" type="float" default="0.75"> - </argument> - <description> - Popup (show the control in modal form) in the center of the screen relative to the current canvas transform, scaled at a ratio of size of the screen. - </description> - </method> - <method name="set_as_minsize"> - <return type="void"> - </return> - <description> - Shrink popup to keep to the minimum size of content. - </description> - </method> </methods> <members> - <member name="popup_exclusive" type="bool" setter="set_exclusive" getter="is_exclusive" default="false"> - If [code]true[/code], the popup will not be hidden when a click event occurs outside of it, or when it receives the [code]ui_cancel[/code] action event. - </member> + <member name="borderless" type="bool" setter="set_flag" getter="get_flag" override="true" default="true" /> + <member name="transient" type="bool" setter="set_transient" getter="is_transient" override="true" default="true" /> + <member name="unresizable" type="bool" setter="set_flag" getter="get_flag" override="true" default="true" /> <member name="visible" type="bool" setter="set_visible" getter="is_visible" override="true" default="false" /> + <member name="wrap_controls" type="bool" setter="set_wrap_controls" getter="is_wrapping_controls" override="true" default="true" /> </members> <signals> - <signal name="about_to_show"> - <description> - Emitted when a popup is about to be shown. This is often used in [PopupMenu] to clear the list of options then create a new one according to the current context. - </description> - </signal> <signal name="popup_hide"> <description> Emitted when a popup is hidden. @@ -83,11 +25,5 @@ </signal> </signals> <constants> - <constant name="NOTIFICATION_POST_POPUP" value="80"> - Notification sent right after the popup is shown. - </constant> - <constant name="NOTIFICATION_POPUP_HIDE" value="81"> - Notification sent right after the popup is hidden. - </constant> </constants> </class> diff --git a/doc/classes/PopupDialog.xml b/doc/classes/PopupDialog.xml deleted file mode 100644 index a8fd9c1b7d..0000000000 --- a/doc/classes/PopupDialog.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> -<class name="PopupDialog" inherits="Popup" version="4.0"> - <brief_description> - Base class for popup dialogs. - </brief_description> - <description> - PopupDialog is a base class for popup dialogs, along with [WindowDialog]. - </description> - <tutorials> - </tutorials> - <methods> - </methods> - <constants> - </constants> - <theme_items> - <theme_item name="panel" type="StyleBox"> - Sets a custom [StyleBox] for the panel of the [PopupDialog]. - </theme_item> - </theme_items> -</class> diff --git a/doc/classes/PopupMenu.xml b/doc/classes/PopupMenu.xml index 8dda33f624..569da5c58b 100644 --- a/doc/classes/PopupMenu.xml +++ b/doc/classes/PopupMenu.xml @@ -330,13 +330,6 @@ Returns the tooltip associated with the specified index index [code]idx[/code]. </description> </method> - <method name="is_hide_on_window_lose_focus" qualifiers="const"> - <return type="bool"> - </return> - <description> - Returns [code]true[/code] if the popup will be hidden when the window loses focus or not. - </description> - </method> <method name="is_item_checkable" qualifiers="const"> <return type="bool"> </return> @@ -404,15 +397,6 @@ [b]Note:[/b] The indices of items after the removed item will be shifted by one. </description> </method> - <method name="set_hide_on_window_lose_focus"> - <return type="void"> - </return> - <argument index="0" name="enable" type="bool"> - </argument> - <description> - Hides the [PopupMenu] when the window loses focus. - </description> - </method> <method name="set_item_accelerator"> <return type="void"> </return> @@ -604,7 +588,6 @@ <member name="allow_search" type="bool" setter="set_allow_search" getter="get_allow_search" default="false"> If [code]true[/code], allows to navigate [PopupMenu] with letter keys. </member> - <member name="focus_mode" type="int" setter="set_focus_mode" getter="get_focus_mode" override="true" enum="Control.FocusMode" default="2" /> <member name="hide_on_checkable_item_selection" type="bool" setter="set_hide_on_checkable_item_selection" getter="is_hide_on_checkable_item_selection" default="true"> If [code]true[/code], hides the [PopupMenu] when a checkbox or radio button is selected. </member> diff --git a/doc/classes/PopupPanel.xml b/doc/classes/PopupPanel.xml index 2e62d09f8f..72045c5559 100644 --- a/doc/classes/PopupPanel.xml +++ b/doc/classes/PopupPanel.xml @@ -4,7 +4,7 @@ Class for displaying popups with a panel background. </brief_description> <description> - Class for displaying popups with a panel background. In some cases it might be simpler to use than [Popup], since it provides a configurable background. If you are making windows, better check [WindowDialog]. + Class for displaying popups with a panel background. In some cases it might be simpler to use than [Popup], since it provides a configurable background. If you are making windows, better check [Window]. </description> <tutorials> </tutorials> diff --git a/doc/classes/ProjectSettings.xml b/doc/classes/ProjectSettings.xml index 121e55c87e..46f6fd2284 100644 --- a/doc/classes/ProjectSettings.xml +++ b/doc/classes/ProjectSettings.xml @@ -202,7 +202,7 @@ Icon used for the project, set when project loads. Exporters will also use this icon when possible. </member> <member name="application/config/macos_native_icon" type="String" setter="" getter="" default=""""> - Icon set in [code].icns[/code] format used on macOS to set the game's icon. This is done automatically on start by calling [method OS.set_native_icon]. + Icon set in [code].icns[/code] format used on macOS to set the game's icon. This is done automatically on start by calling [method DisplayServer.set_native_icon]. </member> <member name="application/config/name" type="String" setter="" getter="" default=""""> The project's name. It is used both by the Project Manager and by exporters. The project name can be translated by translating its value in localization files. @@ -215,7 +215,7 @@ If [code]true[/code], the project will save user data to its own user directory (see [member application/config/custom_user_dir_name]). This setting is only effective on desktop platforms. A name must be set in the [member application/config/custom_user_dir_name] setting for this to take effect. If [code]false[/code], the project will save user data to [code](OS user data directory)/Godot/app_userdata/(project name)[/code]. </member> <member name="application/config/windows_native_icon" type="String" setter="" getter="" default=""""> - Icon set in [code].ico[/code] format used on Windows to set the game's icon. This is done automatically on start by calling [method OS.set_native_icon]. + Icon set in [code].ico[/code] format used on Windows to set the game's icon. This is done automatically on start by calling [method DisplayServer.set_native_icon]. </member> <member name="application/run/disable_stderr" type="bool" setter="" getter="" default="false"> If [code]true[/code], disables printing to standard error in an exported build. @@ -426,12 +426,6 @@ <member name="display/window/ios/hide_home_indicator" type="bool" setter="" getter="" default="true"> If [code]true[/code], the home indicator is hidden automatically. This only affects iOS devices without a physical home button. </member> - <member name="display/window/per_pixel_transparency/allowed" type="bool" setter="" getter="" default="false"> - If [code]true[/code], allows per-pixel transparency in a desktop window. This affects performance, so leave it on [code]false[/code] unless you need it. - </member> - <member name="display/window/per_pixel_transparency/enabled" type="bool" setter="" getter="" default="false"> - Sets the window background to transparent when it starts. - </member> <member name="display/window/size/always_on_top" type="bool" setter="" getter="" default="false"> Force the window to be always on top. </member> @@ -1002,7 +996,9 @@ </member> <member name="rendering/quality/driver/driver_name" type="String" setter="" getter="" default=""Vulkan""> The video driver to use ("GLES2" or "Vulkan"). - [b]Note:[/b] The backend in use can be overridden at runtime via the [code]--video-driver[/code] command line argument. In such cases, this property is not updated, so use [method OS.get_current_video_driver] to query it at run-time. + [b]Note:[/b] The backend in use can be overridden at runtime via the [code]--rendering-driver[/code] command line argument. + [b]FIXME:[/b] No longer valid after DisplayServer split: + In such cases, this property is not updated, so use [code]OS.get_current_video_driver[/code] to query it at run-time. </member> <member name="rendering/quality/filters/depth_of_field_bokeh_quality" type="int" setter="" getter="" default="2"> </member> @@ -1027,6 +1023,10 @@ </member> <member name="rendering/quality/gi_probes/quality" type="int" setter="" getter="" default="1"> </member> + <member name="rendering/quality/glow/upscale_mode" type="int" setter="" getter="" default="1"> + </member> + <member name="rendering/quality/glow/upscale_mode.mobile" type="int" setter="" getter="" default="0"> + </member> <member name="rendering/quality/intended_usage/framebuffer_allocation" type="int" setter="" getter="" default="2"> Strategy used for framebuffer allocation. The simpler it is, the less resources it uses (but the less features it supports). If set to "2D Without Sampling" or "3D Without Effects", sample buffers will not be allocated. This means [code]SCREEN_TEXTURE[/code] and [code]DEPTH_TEXTURE[/code] will not be available in shaders and post-processing effects will not be available in the [Environment]. </member> diff --git a/doc/classes/RenderingServer.xml b/doc/classes/RenderingServer.xml index 7127ba8b71..965d6bf175 100644 --- a/doc/classes/RenderingServer.xml +++ b/doc/classes/RenderingServer.xml @@ -763,8 +763,6 @@ </argument> <argument index="10" name="hdr_luminance_cap" type="float"> </argument> - <argument index="11" name="bicubic_upscale" type="bool"> - </argument> <description> </description> </method> @@ -2812,7 +2810,7 @@ <argument index="2" name="screen" type="int" default="0"> </argument> <description> - Copies viewport to a region of the screen specified by [code]rect[/code]. If [member Viewport.render_direct_to_screen] is [code]true[/code], then viewport does not use a framebuffer and the contents of the viewport are rendered directly to screen. However, note that the root viewport is drawn last, therefore it will draw over the screen. Accordingly, you must set the root viewport to an area that does not cover the area that you have attached this viewport to. + Copies the viewport to a region of the screen specified by [code]rect[/code]. If [method viewport_set_render_direct_to_screen] is [code]true[/code], then the viewport does not use a framebuffer and the contents of the viewport are rendered directly to screen. However, note that the root viewport is drawn last, therefore it will draw over the screen. Accordingly, you must set the root viewport to an area that does not cover the area that you have attached this viewport to. For example, you can set the root viewport to not render at all with the following code: [codeblock] func _ready(): @@ -2830,15 +2828,6 @@ Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method. </description> </method> - <method name="viewport_detach"> - <return type="void"> - </return> - <argument index="0" name="viewport" type="RID"> - </argument> - <description> - Detaches the viewport from the screen. - </description> - </method> <method name="viewport_get_render_info"> <return type="int"> </return> @@ -3378,7 +3367,9 @@ <constant name="VIEWPORT_UPDATE_WHEN_VISIBLE" value="2" enum="ViewportUpdateMode"> Update the viewport whenever it is visible. </constant> - <constant name="VIEWPORT_UPDATE_ALWAYS" value="3" enum="ViewportUpdateMode"> + <constant name="VIEWPORT_UPDATE_WHEN_PARENT_VISIBLE" value="3" enum="ViewportUpdateMode"> + </constant> + <constant name="VIEWPORT_UPDATE_ALWAYS" value="4" enum="ViewportUpdateMode"> Always update the viewport. </constant> <constant name="VIEWPORT_CLEAR_ALWAYS" value="0" enum="ViewportClearMode"> diff --git a/doc/classes/SceneTree.xml b/doc/classes/SceneTree.xml index e6778013cf..00ca5c6e9f 100644 --- a/doc/classes/SceneTree.xml +++ b/doc/classes/SceneTree.xml @@ -135,13 +135,6 @@ Returns [code]true[/code] if there is a [member network_peer] set. </description> </method> - <method name="is_input_handled"> - <return type="bool"> - </return> - <description> - Returns [code]true[/code] if the most recent [InputEvent] was marked as handled with [method set_input_as_handled]. - </description> - </method> <method name="is_network_server" qualifiers="const"> <return type="bool"> </return> @@ -237,13 +230,6 @@ Sets the given [code]property[/code] to [code]value[/code] on all members of the given group, respecting the given [enum GroupCallFlags]. </description> </method> - <method name="set_input_as_handled"> - <return type="void"> - </return> - <description> - Marks the most recent [InputEvent] as handled. - </description> - </method> <method name="set_quit_on_go_back"> <return type="void"> </return> @@ -251,22 +237,7 @@ </argument> <description> If [code]true[/code], the application quits automatically on going back (e.g. on Android). Enabled by default. - To handle 'Go Back' button when this option is disabled, use [constant MainLoop.NOTIFICATION_WM_GO_BACK_REQUEST]. - </description> - </method> - <method name="set_screen_stretch"> - <return type="void"> - </return> - <argument index="0" name="mode" type="int" enum="SceneTree.StretchMode"> - </argument> - <argument index="1" name="aspect" type="int" enum="SceneTree.StretchAspect"> - </argument> - <argument index="2" name="minsize" type="Vector2"> - </argument> - <argument index="3" name="shrink" type="float" default="1"> - </argument> - <description> - Configures screen stretching to the given [enum StretchMode], [enum StretchAspect], minimum size and [code]shrink[/code] ratio. + To handle 'Go Back' button when this option is disabled, use [constant DisplayServer.WINDOW_EVENT_GO_BACK_REQUEST]. </description> </method> </methods> @@ -301,11 +272,8 @@ <member name="refuse_new_network_connections" type="bool" setter="set_refuse_new_network_connections" getter="is_refusing_new_network_connections" default="false"> If [code]true[/code], the [SceneTree]'s [member network_peer] refuses new incoming connections. </member> - <member name="root" type="Viewport" setter="" getter="get_root"> - The [SceneTree]'s root [Viewport]. - </member> - <member name="use_font_oversampling" type="bool" setter="set_use_font_oversampling" getter="is_using_font_oversampling" default="false"> - If [code]true[/code], font oversampling is used. + <member name="root" type="Window" setter="" getter="get_root"> + The [SceneTree]'s root [Window]. </member> </members> <signals> @@ -328,15 +296,6 @@ Emitted when files are dragged from the OS file manager and dropped in the game window. The arguments are a list of file paths and the identifier of the screen where the drag originated. </description> </signal> - <signal name="global_menu_action"> - <argument index="0" name="id" type="Variant"> - </argument> - <argument index="1" name="meta" type="Variant"> - </argument> - <description> - Emitted whenever global menu item is clicked. - </description> - </signal> <signal name="idle_frame"> <description> Emitted immediately before [method Node._process] is called on every node in the [SceneTree]. @@ -389,11 +348,6 @@ Emitted immediately before [method Node._physics_process] is called on every node in the [SceneTree]. </description> </signal> - <signal name="screen_resized"> - <description> - Emitted when the screen resolution (fullscreen) or window size (windowed) changes. - </description> - </signal> <signal name="server_disconnected"> <description> Emitted whenever this [SceneTree]'s [member network_peer] disconnected from server. Only emitted on clients. @@ -418,29 +372,5 @@ <constant name="GROUP_CALL_UNIQUE" value="4" enum="GroupCallFlags"> Call a group only once even if the call is executed many times. </constant> - <constant name="STRETCH_MODE_DISABLED" value="0" enum="StretchMode"> - No stretching. - </constant> - <constant name="STRETCH_MODE_2D" value="1" enum="StretchMode"> - Render stretching in higher resolution (interpolated). - </constant> - <constant name="STRETCH_MODE_VIEWPORT" value="2" enum="StretchMode"> - Keep the specified display resolution. No interpolation. Content may appear pixelated. - </constant> - <constant name="STRETCH_ASPECT_IGNORE" value="0" enum="StretchAspect"> - Fill the window with the content stretched to cover excessive space. Content may appear stretched. - </constant> - <constant name="STRETCH_ASPECT_KEEP" value="1" enum="StretchAspect"> - Retain the same aspect ratio by padding with black bars on either axis. This prevents distortion. - </constant> - <constant name="STRETCH_ASPECT_KEEP_WIDTH" value="2" enum="StretchAspect"> - Expand vertically. Left/right black bars may appear if the window is too wide. - </constant> - <constant name="STRETCH_ASPECT_KEEP_HEIGHT" value="3" enum="StretchAspect"> - Expand horizontally. Top/bottom black bars may appear if the window is too tall. - </constant> - <constant name="STRETCH_ASPECT_EXPAND" value="4" enum="StretchAspect"> - Expand in both directions, retaining the same aspect ratio. This prevents distortion while avoiding black bars. - </constant> </constants> </class> diff --git a/doc/classes/ScriptCreateDialog.xml b/doc/classes/ScriptCreateDialog.xml index 9f16a6ed46..aa60ecb12b 100644 --- a/doc/classes/ScriptCreateDialog.xml +++ b/doc/classes/ScriptCreateDialog.xml @@ -4,7 +4,7 @@ The Editor's popup dialog for creating new [Script] files. </brief_description> <description> - The [ScriptCreateDialog] creates script files according to a given template for a given scripting language. The standard use is to configure its fields prior to calling one of the [method Popup.popup] methods. + The [ScriptCreateDialog] creates script files according to a given template for a given scripting language. The standard use is to configure its fields prior to calling one of the [method Window.popup] methods. [codeblock] func _ready(): dialog.config("Node", "res://new_node.gd") # For in-engine types @@ -33,10 +33,7 @@ </methods> <members> <member name="dialog_hide_on_ok" type="bool" setter="set_hide_on_ok" getter="get_hide_on_ok" override="true" default="false" /> - <member name="margin_bottom" type="float" setter="set_margin" getter="get_margin" override="true" default="232.0" /> - <member name="margin_right" type="float" setter="set_margin" getter="get_margin" override="true" default="361.0" /> - <member name="rect_size" type="Vector2" setter="_set_size" getter="get_size" override="true" default="Vector2( 361, 232 )" /> - <member name="window_title" type="String" setter="set_title" getter="get_title" override="true" default=""Attach Node Script"" /> + <member name="title" type="String" setter="set_title" getter="get_title" override="true" default=""Attach Node Script"" /> </members> <signals> <signal name="script_created"> diff --git a/doc/classes/SubViewport.xml b/doc/classes/SubViewport.xml new file mode 100644 index 0000000000..561e5d1a15 --- /dev/null +++ b/doc/classes/SubViewport.xml @@ -0,0 +1,51 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="SubViewport" inherits="Viewport" version="4.0"> + <brief_description> + </brief_description> + <description> + </description> + <tutorials> + </tutorials> + <methods> + <method name="get_size" qualifiers="const"> + <return type="Vector2i"> + </return> + <description> + </description> + </method> + <method name="set_size"> + <return type="void"> + </return> + <argument index="0" name="size" type="Vector2i"> + </argument> + <description> + </description> + </method> + </methods> + <members> + <member name="arvr" type="bool" setter="set_use_arvr" getter="is_using_arvr" default="false"> + </member> + <member name="render_target_clear_mode" type="int" setter="set_clear_mode" getter="get_clear_mode" enum="SubViewport.ClearMode" default="0"> + </member> + <member name="render_target_update_mode" type="int" setter="set_update_mode" getter="get_update_mode" enum="SubViewport.UpdateMode" default="2"> + </member> + </members> + <constants> + <constant name="UPDATE_DISABLED" value="0" enum="UpdateMode"> + </constant> + <constant name="UPDATE_ONCE" value="1" enum="UpdateMode"> + </constant> + <constant name="UPDATE_WHEN_VISIBLE" value="2" enum="UpdateMode"> + </constant> + <constant name="UPDATE_WHEN_PARENT_VISIBLE" value="3" enum="UpdateMode"> + </constant> + <constant name="UPDATE_ALWAYS" value="4" enum="UpdateMode"> + </constant> + <constant name="CLEAR_MODE_ALWAYS" value="0" enum="ClearMode"> + </constant> + <constant name="CLEAR_MODE_NEVER" value="1" enum="ClearMode"> + </constant> + <constant name="CLEAR_MODE_ONLY_NEXT_FRAME" value="2" enum="ClearMode"> + </constant> + </constants> +</class> diff --git a/doc/classes/Thread.xml b/doc/classes/Thread.xml index 3bb5797df5..4d6e89fa6f 100644 --- a/doc/classes/Thread.xml +++ b/doc/classes/Thread.xml @@ -36,7 +36,7 @@ <argument index="3" name="priority" type="int" enum="Thread.Priority" default="1"> </argument> <description> - Starts a new [Thread] that runs [code]method[/code] on object [code]instance[/code] with [code]userdata[/code] passed as an argument. The [code]priority[/code] of the [Thread] can be changed by passing a value from the [enum Priority] enum. + Starts a new [Thread] that runs [code]method[/code] on object [code]instance[/code] with [code]userdata[/code] passed as an argument. Even if no userdata is passed, [code]method[/code] must accept one argument and it will be null. The [code]priority[/code] of the [Thread] can be changed by passing a value from the [enum Priority] enum. Returns [constant OK] on success, or [constant ERR_CANT_CREATE] on failure. </description> </method> diff --git a/doc/classes/Viewport.xml b/doc/classes/Viewport.xml index dd0b17d084..517eb3b24c 100644 --- a/doc/classes/Viewport.xml +++ b/doc/classes/Viewport.xml @@ -44,13 +44,6 @@ Returns the total transform of the viewport. </description> </method> - <method name="get_modal_stack_top" qualifiers="const"> - <return type="Control"> - </return> - <description> - Returns the topmost modal in the stack. - </description> - </method> <method name="get_mouse_position" qualifiers="const"> <return type="Vector2"> </return> @@ -76,13 +69,6 @@ Returns the [enum ShadowAtlasQuadrantSubdiv] of the specified quadrant. </description> </method> - <method name="get_size_override" qualifiers="const"> - <return type="Vector2"> - </return> - <description> - Returns the size override set with [method set_size_override]. - </description> - </method> <method name="get_texture" qualifiers="const"> <return type="ViewportTexture"> </return> @@ -116,13 +102,6 @@ Returns the drag data from the GUI, that was previously returned by [method Control.get_drag_data]. </description> </method> - <method name="gui_has_modal_stack" qualifiers="const"> - <return type="bool"> - </return> - <description> - Returns [code]true[/code] if there are visible modals on-screen. - </description> - </method> <method name="gui_is_dragging" qualifiers="const"> <return type="bool"> </return> @@ -133,31 +112,31 @@ <method name="input"> <return type="void"> </return> - <argument index="0" name="local_event" type="InputEvent"> + <argument index="0" name="event" type="InputEvent"> + </argument> + <argument index="1" name="in_local_coords" type="bool" default="false"> </argument> <description> </description> </method> - <method name="is_input_handled" qualifiers="const"> - <return type="bool"> + <method name="input_text"> + <return type="void"> </return> + <argument index="0" name="text" type="String"> + </argument> <description> </description> </method> - <method name="is_size_override_enabled" qualifiers="const"> + <method name="is_embedding_subwindows" qualifiers="const"> <return type="bool"> </return> <description> - Returns [code]true[/code] if the size override is enabled. See [method set_size_override]. </description> </method> - <method name="set_attach_to_screen_rect"> - <return type="void"> + <method name="is_input_handled" qualifiers="const"> + <return type="bool"> </return> - <argument index="0" name="rect" type="Rect2"> - </argument> <description> - Attaches this [Viewport] to the root [Viewport] with the specified rectangle. This bypasses the need for another node to display this [Viewport] but makes you responsible for updating the position of this [Viewport] manually. </description> </method> <method name="set_input_as_handled"> @@ -178,23 +157,12 @@ Sets the number of subdivisions to use in the specified quadrant. A higher number of subdivisions allows you to have more shadows in the scene at once, but reduces the quality of the shadows. A good practice is to have quadrants with a varying number of subdivisions and to have as few subdivisions as possible. </description> </method> - <method name="set_size_override"> - <return type="void"> - </return> - <argument index="0" name="enable" type="bool"> - </argument> - <argument index="1" name="size" type="Vector2" default="Vector2( -1, -1 )"> - </argument> - <argument index="2" name="margin" type="Vector2" default="Vector2( 0, 0 )"> - </argument> - <description> - Sets the size override of the viewport. If the [code]enable[/code] parameter is [code]true[/code] the override is used, otherwise it uses the default size. If the size parameter is [code](-1, -1)[/code], it won't update the size. - </description> - </method> <method name="unhandled_input"> <return type="void"> </return> - <argument index="0" name="local_event" type="InputEvent"> + <argument index="0" name="event" type="InputEvent"> + </argument> + <argument index="1" name="in_local_coords" type="bool" default="false"> </argument> <description> </description> @@ -217,9 +185,6 @@ </method> </methods> <members> - <member name="arvr" type="bool" setter="set_use_arvr" getter="use_arvr" default="false"> - If [code]true[/code], the viewport will be used in AR/VR process. - </member> <member name="audio_listener_enable_2d" type="bool" setter="set_as_audio_listener_2d" getter="is_audio_listener_2d" default="false"> If [code]true[/code], the viewport will process 2D audio streams. </member> @@ -242,6 +207,8 @@ <member name="gui_disable_input" type="bool" setter="set_disable_input" getter="is_input_disabled" default="false"> If [code]true[/code], the viewport will not receive input event. </member> + <member name="gui_embed_subwindows" type="bool" setter="set_embed_subwindows_hint" getter="get_embed_subwindows_hint" default="false"> + </member> <member name="gui_snap_controls_to_pixels" type="bool" setter="set_snap_controls_to_pixels" getter="is_snap_controls_to_pixels_enabled" default="true"> If [code]true[/code], the GUI controls on the viewport will lay pixel perfectly. </member> @@ -256,15 +223,6 @@ <member name="physics_object_picking" type="bool" setter="set_physics_object_picking" getter="get_physics_object_picking" default="false"> If [code]true[/code], the objects rendered by viewport become subjects of mouse picking process. </member> - <member name="render_direct_to_screen" type="bool" setter="set_use_render_direct_to_screen" getter="is_using_render_direct_to_screen" default="false"> - If [code]true[/code], renders the Viewport directly to the screen instead of to the root viewport. Only available in GLES2. This is a low-level optimization and should not be used in most cases. If used, reading from the Viewport or from [code]SCREEN_TEXTURE[/code] becomes unavailable. For more information see [method RenderingServer.viewport_set_render_direct_to_screen]. - </member> - <member name="render_target_clear_mode" type="int" setter="set_clear_mode" getter="get_clear_mode" enum="Viewport.ClearMode" default="0"> - The clear mode when viewport used as a render target. - </member> - <member name="render_target_update_mode" type="int" setter="set_update_mode" getter="get_update_mode" enum="Viewport.UpdateMode" default="2"> - The update mode when viewport used as a render target. - </member> <member name="shadow_atlas_quad_0" type="int" setter="set_shadow_atlas_quadrant_subdiv" getter="get_shadow_atlas_quadrant_subdiv" enum="Viewport.ShadowAtlasQuadrantSubdiv" default="2"> The subdivision amount of the first quadrant on the shadow atlas. </member> @@ -281,12 +239,6 @@ The shadow atlas' resolution (used for omni and spot lights). The value will be rounded up to the nearest power of 2. [b]Note:[/b] If this is set to 0, shadows won't be visible. Since user-created viewports default to a value of 0, this value must be set above 0 manually. </member> - <member name="size" type="Vector2" setter="set_size" getter="get_size" default="Vector2( 0, 0 )"> - The width and height of viewport. - </member> - <member name="size_override_stretch" type="bool" setter="set_size_override_stretch" getter="is_size_override_stretch_enabled" default="false"> - If [code]true[/code], the size override affects stretch as well. - </member> <member name="transparent_bg" type="bool" setter="set_transparent_background" getter="has_transparent_background" default="false"> If [code]true[/code], the viewport should render its background as transparent. </member> @@ -307,23 +259,11 @@ </signal> <signal name="size_changed"> <description> - Emitted when the size of the viewport is changed, whether by [method set_size_override], resize of window, or some other means. + Emitted when the size of the viewport is changed, whether by resizing of window, or some other means. </description> </signal> </signals> <constants> - <constant name="UPDATE_DISABLED" value="0" enum="UpdateMode"> - Do not update the render target. - </constant> - <constant name="UPDATE_ONCE" value="1" enum="UpdateMode"> - Update the render target once, then switch to [constant UPDATE_DISABLED]. - </constant> - <constant name="UPDATE_WHEN_VISIBLE" value="2" enum="UpdateMode"> - Update the render target only when it is visible. This is the default value. - </constant> - <constant name="UPDATE_ALWAYS" value="3" enum="UpdateMode"> - Always update the render target. - </constant> <constant name="SHADOW_ATLAS_QUADRANT_SUBDIV_DISABLED" value="0" enum="ShadowAtlasQuadrantSubdiv"> This quadrant will not be used. </constant> @@ -410,15 +350,6 @@ <constant name="MSAA_16X" value="4" enum="MSAA"> Use 16x Multisample Antialiasing. Likely unsupported on medium and low-end hardware. </constant> - <constant name="CLEAR_MODE_ALWAYS" value="0" enum="ClearMode"> - Always clear the render target before drawing. - </constant> - <constant name="CLEAR_MODE_NEVER" value="1" enum="ClearMode"> - Never clear the render target. - </constant> - <constant name="CLEAR_MODE_ONLY_NEXT_FRAME" value="2" enum="ClearMode"> - Clear the render target next frame, then switch to [constant CLEAR_MODE_NEVER]. - </constant> <constant name="DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_NEAREST" value="0" enum="DefaultCanvasItemTextureFilter"> </constant> <constant name="DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_LINEAR" value="1" enum="DefaultCanvasItemTextureFilter"> diff --git a/doc/classes/Window.xml b/doc/classes/Window.xml new file mode 100644 index 0000000000..e1a0f1f22a --- /dev/null +++ b/doc/classes/Window.xml @@ -0,0 +1,419 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="Window" inherits="Viewport" version="4.0"> + <brief_description> + </brief_description> + <description> + </description> + <tutorials> + </tutorials> + <methods> + <method name="can_draw" qualifiers="const"> + <return type="bool"> + </return> + <description> + </description> + </method> + <method name="child_controls_changed"> + <return type="void"> + </return> + <description> + </description> + </method> + <method name="get_flag" qualifiers="const"> + <return type="bool"> + </return> + <argument index="0" name="flag" type="int" enum="Window.Flags"> + </argument> + <description> + </description> + </method> + <method name="get_real_size" qualifiers="const"> + <return type="Vector2i"> + </return> + <description> + </description> + </method> + <method name="get_theme_color" qualifiers="const"> + <return type="Color"> + </return> + <argument index="0" name="name" type="StringName"> + </argument> + <argument index="1" name="type" type="StringName" default=""""> + </argument> + <description> + </description> + </method> + <method name="get_theme_constant" qualifiers="const"> + <return type="int"> + </return> + <argument index="0" name="name" type="StringName"> + </argument> + <argument index="1" name="type" type="StringName" default=""""> + </argument> + <description> + </description> + </method> + <method name="get_theme_font" qualifiers="const"> + <return type="Font"> + </return> + <argument index="0" name="name" type="StringName"> + </argument> + <argument index="1" name="type" type="StringName" default=""""> + </argument> + <description> + </description> + </method> + <method name="get_theme_icon" qualifiers="const"> + <return type="Texture2D"> + </return> + <argument index="0" name="name" type="StringName"> + </argument> + <argument index="1" name="type" type="StringName" default=""""> + </argument> + <description> + </description> + </method> + <method name="get_theme_stylebox" qualifiers="const"> + <return type="StyleBox"> + </return> + <argument index="0" name="name" type="StringName"> + </argument> + <argument index="1" name="type" type="StringName" default=""""> + </argument> + <description> + </description> + </method> + <method name="grab_focus"> + <return type="void"> + </return> + <description> + </description> + </method> + <method name="has_focus" qualifiers="const"> + <return type="bool"> + </return> + <description> + </description> + </method> + <method name="has_theme_color" qualifiers="const"> + <return type="bool"> + </return> + <argument index="0" name="name" type="StringName"> + </argument> + <argument index="1" name="type" type="StringName" default=""""> + </argument> + <description> + </description> + </method> + <method name="has_theme_constant" qualifiers="const"> + <return type="bool"> + </return> + <argument index="0" name="name" type="StringName"> + </argument> + <argument index="1" name="type" type="StringName" default=""""> + </argument> + <description> + </description> + </method> + <method name="has_theme_font" qualifiers="const"> + <return type="bool"> + </return> + <argument index="0" name="name" type="StringName"> + </argument> + <argument index="1" name="type" type="StringName" default=""""> + </argument> + <description> + </description> + </method> + <method name="has_theme_icon" qualifiers="const"> + <return type="bool"> + </return> + <argument index="0" name="name" type="StringName"> + </argument> + <argument index="1" name="type" type="StringName" default=""""> + </argument> + <description> + </description> + </method> + <method name="has_theme_stylebox" qualifiers="const"> + <return type="bool"> + </return> + <argument index="0" name="name" type="StringName"> + </argument> + <argument index="1" name="type" type="StringName" default=""""> + </argument> + <description> + </description> + </method> + <method name="hide"> + <return type="void"> + </return> + <description> + </description> + </method> + <method name="is_embedded" qualifiers="const"> + <return type="bool"> + </return> + <description> + </description> + </method> + <method name="is_maximize_allowed" qualifiers="const"> + <return type="bool"> + </return> + <description> + </description> + </method> + <method name="is_using_font_oversampling" qualifiers="const"> + <return type="bool"> + </return> + <description> + </description> + </method> + <method name="move_to_foreground"> + <return type="void"> + </return> + <description> + </description> + </method> + <method name="popup"> + <return type="void"> + </return> + <argument index="0" name="rect" type="Rect2i" default="Rect2i( 0, 0, 0, 0 )"> + </argument> + <description> + </description> + </method> + <method name="popup_centered"> + <return type="void"> + </return> + <argument index="0" name="minsize" type="Vector2i" default="Vector2i( 0, 0 )"> + </argument> + <description> + </description> + </method> + <method name="popup_centered_clamped"> + <return type="void"> + </return> + <argument index="0" name="minsize" type="Vector2i" default="Vector2i( 0, 0 )"> + </argument> + <argument index="1" name="fallback_ratio" type="float" default="0.75"> + </argument> + <description> + </description> + </method> + <method name="popup_centered_ratio"> + <return type="void"> + </return> + <argument index="0" name="ratio" type="float" default="0.8"> + </argument> + <description> + </description> + </method> + <method name="popup_on_parent"> + <return type="void"> + </return> + <argument index="0" name="parent_rect" type="Rect2i"> + </argument> + <description> + </description> + </method> + <method name="request_attention"> + <return type="void"> + </return> + <description> + </description> + </method> + <method name="set_flag"> + <return type="void"> + </return> + <argument index="0" name="flag" type="int" enum="Window.Flags"> + </argument> + <argument index="1" name="enabled" type="bool"> + </argument> + <description> + </description> + </method> + <method name="set_ime_active"> + <return type="void"> + </return> + <argument index="0" name="arg0" type="bool"> + </argument> + <description> + </description> + </method> + <method name="set_ime_position"> + <return type="void"> + </return> + <argument index="0" name="arg0" type="Vector2i"> + </argument> + <description> + </description> + </method> + <method name="set_use_font_oversampling"> + <return type="void"> + </return> + <argument index="0" name="enable" type="bool"> + </argument> + <description> + </description> + </method> + <method name="show"> + <return type="void"> + </return> + <description> + </description> + </method> + </methods> + <members> + <member name="always_on_top" type="bool" setter="set_flag" getter="get_flag" default="false"> + </member> + <member name="borderless" type="bool" setter="set_flag" getter="get_flag" default="false"> + </member> + <member name="content_scale_aspect" type="int" setter="set_content_scale_aspect" getter="get_content_scale_aspect" enum="Window.ContentScaleAspect" default="0"> + </member> + <member name="content_scale_mode" type="int" setter="set_content_scale_mode" getter="get_content_scale_mode" enum="Window.ContentScaleMode" default="0"> + </member> + <member name="content_scale_size" type="Vector2i" setter="set_content_scale_size" getter="get_content_scale_size" default="Vector2i( 0, 0 )"> + </member> + <member name="current_screen" type="int" setter="set_current_screen" getter="get_current_screen" default="0"> + </member> + <member name="exclusive" type="bool" setter="set_exclusive" getter="is_exclusive" default="false"> + </member> + <member name="max_size" type="Vector2i" setter="set_max_size" getter="get_max_size" default="Vector2i( 0, 0 )"> + </member> + <member name="min_size" type="Vector2i" setter="set_min_size" getter="get_min_size" default="Vector2i( 0, 0 )"> + </member> + <member name="mode" type="int" setter="set_mode" getter="get_mode" enum="Window.Mode" default="0"> + </member> + <member name="position" type="Vector2i" setter="set_position" getter="get_position" default="Vector2i( 0, 0 )"> + </member> + <member name="size" type="Vector2i" setter="set_size" getter="get_size" default="Vector2i( 100, 100 )"> + </member> + <member name="theme" type="Theme" setter="set_theme" getter="get_theme"> + </member> + <member name="title" type="String" setter="set_title" getter="get_title" default=""""> + </member> + <member name="transient" type="bool" setter="set_transient" getter="is_transient" default="false"> + </member> + <member name="transparent" type="bool" setter="set_flag" getter="get_flag" default="false"> + </member> + <member name="unfocusable" type="bool" setter="set_flag" getter="get_flag" default="false"> + </member> + <member name="unresizable" type="bool" setter="set_flag" getter="get_flag" default="false"> + </member> + <member name="visible" type="bool" setter="set_visible" getter="is_visible" default="true"> + </member> + <member name="wrap_controls" type="bool" setter="set_wrap_controls" getter="is_wrapping_controls" default="false"> + </member> + </members> + <signals> + <signal name="about_to_popup"> + <description> + </description> + </signal> + <signal name="close_requested"> + <description> + </description> + </signal> + <signal name="files_dropped"> + <argument index="0" name="files" type="PackedStringArray"> + </argument> + <description> + </description> + </signal> + <signal name="focus_entered"> + <description> + </description> + </signal> + <signal name="focus_exited"> + <description> + </description> + </signal> + <signal name="go_back_requested"> + <description> + </description> + </signal> + <signal name="mouse_entered"> + <description> + </description> + </signal> + <signal name="mouse_exited"> + <description> + </description> + </signal> + <signal name="visibility_changed"> + <description> + </description> + </signal> + <signal name="window_input"> + <argument index="0" name="event" type="InputEvent"> + </argument> + <description> + </description> + </signal> + </signals> + <constants> + <constant name="NOTIFICATION_VISIBILITY_CHANGED" value="30"> + </constant> + <constant name="MODE_WINDOWED" value="0" enum="Mode"> + </constant> + <constant name="MODE_MINIMIZED" value="1" enum="Mode"> + </constant> + <constant name="MODE_MAXIMIZED" value="2" enum="Mode"> + </constant> + <constant name="MODE_FULLSCREEN" value="3" enum="Mode"> + </constant> + <constant name="FLAG_RESIZE_DISABLED" value="0" enum="Flags"> + </constant> + <constant name="FLAG_BORDERLESS" value="1" enum="Flags"> + </constant> + <constant name="FLAG_ALWAYS_ON_TOP" value="2" enum="Flags"> + </constant> + <constant name="FLAG_TRANSPARENT" value="3" enum="Flags"> + </constant> + <constant name="FLAG_NO_FOCUS" value="4" enum="Flags"> + </constant> + <constant name="FLAG_MAX" value="5" enum="Flags"> + </constant> + <constant name="CONTENT_SCALE_MODE_DISABLED" value="0" enum="ContentScaleMode"> + </constant> + <constant name="CONTENT_SCALE_MODE_OBJECTS" value="1" enum="ContentScaleMode"> + </constant> + <constant name="CONTENT_SCALE_MODE_PIXELS" value="2" enum="ContentScaleMode"> + </constant> + <constant name="CONTENT_SCALE_ASPECT_IGNORE" value="0" enum="ContentScaleAspect"> + </constant> + <constant name="CONTENT_SCALE_ASPECT_KEEP" value="1" enum="ContentScaleAspect"> + </constant> + <constant name="CONTENT_SCALE_ASPECT_KEEP_WIDTH" value="2" enum="ContentScaleAspect"> + </constant> + <constant name="CONTENT_SCALE_ASPECT_KEEP_HEIGHT" value="3" enum="ContentScaleAspect"> + </constant> + <constant name="CONTENT_SCALE_ASPECT_EXPAND" value="4" enum="ContentScaleAspect"> + </constant> + </constants> + <theme_items> + <theme_item name="close" type="Texture2D"> + </theme_item> + <theme_item name="close_h_ofs" type="int" default="18"> + </theme_item> + <theme_item name="close_highlight" type="Texture2D"> + </theme_item> + <theme_item name="close_v_ofs" type="int" default="18"> + </theme_item> + <theme_item name="panel" type="StyleBox"> + </theme_item> + <theme_item name="resize_margin" type="int" default="4"> + </theme_item> + <theme_item name="scaleborder_size" type="int" default="4"> + </theme_item> + <theme_item name="title_color" type="Color" default="Color( 0, 0, 0, 1 )"> + </theme_item> + <theme_item name="title_font" type="Font"> + </theme_item> + <theme_item name="title_height" type="int" default="20"> + </theme_item> + <theme_item name="window_panel" type="StyleBox"> + </theme_item> + </theme_items> +</class> diff --git a/doc/classes/WindowDialog.xml b/doc/classes/WindowDialog.xml deleted file mode 100644 index 8b6bf00508..0000000000 --- a/doc/classes/WindowDialog.xml +++ /dev/null @@ -1,59 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> -<class name="WindowDialog" inherits="Popup" version="4.0"> - <brief_description> - Base class for window dialogs. - </brief_description> - <description> - Windowdialog is the base class for all window-based dialogs. It's a by-default toplevel [Control] that draws a window decoration and allows motion and resizing. - </description> - <tutorials> - </tutorials> - <methods> - <method name="get_close_button"> - <return type="TextureButton"> - </return> - <description> - Returns the close [TextureButton]. - </description> - </method> - </methods> - <members> - <member name="resizable" type="bool" setter="set_resizable" getter="get_resizable" default="false"> - If [code]true[/code], the user can resize the window. - </member> - <member name="window_title" type="String" setter="set_title" getter="get_title" default=""""> - The text displayed in the window's title bar. - </member> - </members> - <constants> - </constants> - <theme_items> - <theme_item name="close" type="Texture2D"> - The icon for the close button. - </theme_item> - <theme_item name="close_h_ofs" type="int" default="18"> - The horizontal offset of the close button. - </theme_item> - <theme_item name="close_highlight" type="Texture2D"> - The icon used for the close button when it's hovered with the mouse cursor. - </theme_item> - <theme_item name="close_v_ofs" type="int" default="18"> - The vertical offset of the close button. - </theme_item> - <theme_item name="panel" type="StyleBox"> - The style for both the content background of the [WindowDialog] and the title bar. - </theme_item> - <theme_item name="scaleborder_size" type="int" default="4"> - The thickness of the border that can be dragged when scaling the window (if [member resizable] is enabled). - </theme_item> - <theme_item name="title_color" type="Color" default="Color( 0, 0, 0, 1 )"> - The color of the title text. - </theme_item> - <theme_item name="title_font" type="Font"> - The font used to draw the title. - </theme_item> - <theme_item name="title_height" type="int" default="20"> - The vertical offset of the title text. - </theme_item> - </theme_items> -</class> diff --git a/drivers/dummy/rasterizer_dummy.h b/drivers/dummy/rasterizer_dummy.h index a503492595..338e4b8501 100644 --- a/drivers/dummy/rasterizer_dummy.h +++ b/drivers/dummy/rasterizer_dummy.h @@ -77,7 +77,7 @@ public: void environment_set_camera_feed_id(RID p_env, int p_camera_feed_id) {} #endif - void environment_set_glow(RID p_env, bool p_enable, int p_level_flags, float p_intensity, float p_strength, float p_mix, float p_bloom_threshold, RS::EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, float p_hdr_luminance_cap, bool p_bicubic_upscale) {} + void environment_set_glow(RID p_env, bool p_enable, int p_level_flags, float p_intensity, float p_strength, float p_mix, float p_bloom_threshold, RS::EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, float p_hdr_luminance_cap) {} void environment_set_fog(RID p_env, bool p_enable, float p_begin, float p_end, RID p_gradient_texture) {} diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp index 5883b5eb1e..1321ee9144 100644 --- a/editor/editor_export.cpp +++ b/editor/editor_export.cpp @@ -582,6 +582,14 @@ String EditorExportPlugin::get_ios_cpp_code() const { return ios_cpp_code; } +void EditorExportPlugin::add_ios_project_static_lib(const String &p_path) { + ios_project_static_libs.push_back(p_path); +} + +Vector<String> EditorExportPlugin::get_ios_project_static_libs() const { + return ios_project_static_libs; +} + void EditorExportPlugin::_export_file_script(const String &p_path, const String &p_type, const Vector<String> &p_features) { if (get_script_instance()) { @@ -617,6 +625,7 @@ void EditorExportPlugin::skip() { void EditorExportPlugin::_bind_methods() { ClassDB::bind_method(D_METHOD("add_shared_object", "path", "tags"), &EditorExportPlugin::add_shared_object); + ClassDB::bind_method(D_METHOD("add_ios_project_static_lib", "path"), &EditorExportPlugin::add_ios_project_static_lib); ClassDB::bind_method(D_METHOD("add_file", "path", "file", "remap"), &EditorExportPlugin::add_file); ClassDB::bind_method(D_METHOD("add_ios_framework", "path"), &EditorExportPlugin::add_ios_framework); ClassDB::bind_method(D_METHOD("add_ios_plist_content", "plist_content"), &EditorExportPlugin::add_ios_plist_content); diff --git a/editor/editor_export.h b/editor/editor_export.h index 81790eb0a4..845638a691 100644 --- a/editor/editor_export.h +++ b/editor/editor_export.h @@ -291,6 +291,7 @@ class EditorExportPlugin : public Reference { bool skipped; Vector<String> ios_frameworks; + Vector<String> ios_project_static_libs; String ios_plist_content; String ios_linker_flags; Vector<String> ios_bundle_files; @@ -322,6 +323,7 @@ protected: void add_shared_object(const String &p_path, const Vector<String> &tags); void add_ios_framework(const String &p_path); + void add_ios_project_static_lib(const String &p_path); void add_ios_plist_content(const String &p_plist_content); void add_ios_linker_flags(const String &p_flags); void add_ios_bundle_file(const String &p_path); @@ -336,6 +338,7 @@ protected: public: Vector<String> get_ios_frameworks() const; + Vector<String> get_ios_project_static_libs() const; String get_ios_plist_content() const; String get_ios_linker_flags() const; Vector<String> get_ios_bundle_files() const; diff --git a/editor/icons/SubViewport.svg b/editor/icons/SubViewport.svg new file mode 100644 index 0000000000..103b1006ad --- /dev/null +++ b/editor/icons/SubViewport.svg @@ -0,0 +1 @@ +<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m3 2c-.5304.0000801-1.0390625.2108475-1.4140625.5859375-.37509.37501-.5858575.8836225-.5859375 1.4140625v8c.0000803.5304.2108475 1.039063.5859375 1.414062.37501.375091.8836225.585858 1.4140625.585938h10c1.1046 0 2-.89543 2-2v-8c0-1.1046-.89543-2-2-2zm0 1h10c.55228.0000096.99999.44772 1 1v8c-.00001.55228-.44772.99999-1 1h-10c-.55228-.00001-.99999-.44772-1-1v-8c.0000096-.55228.44772-.99999 1-1zm3 1c-.5304.0001-1.0390625.2108375-1.4140625.5859375-.37509.375-.5858575.8836225-.5859375 1.4140625v4c.00008.5304.2108475 1.039062.5859375 1.414062.37501.3751.8836225.585838 1.4140625.585938h4c1.1046 0 2-.8954 2-2v-4c0-1.1046-.89543-2-2-2zm0 1h4c.55228 0 .99999.4477 1 1v4c-.00001.5523-.44772 1-1 1h-4c-.55228 0-.99999-.4477-1-1v-4c.00001-.5523.44772-1 1-1z" fill="#e0e0e0" fill-opacity=".996078"/></svg>
\ No newline at end of file diff --git a/editor/import/resource_importer_texture.cpp b/editor/import/resource_importer_texture.cpp index c218697423..c92251ca60 100644 --- a/editor/import/resource_importer_texture.cpp +++ b/editor/import/resource_importer_texture.cpp @@ -424,7 +424,7 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String String normal_map = p_options["roughness/src_normal"]; Ref<Image> normal_image; - Image::RoughnessChannel roughness_channel; + Image::RoughnessChannel roughness_channel = Image::ROUGHNESS_CHANNEL_R; if (mipmaps && roughness > 1 && FileAccess::exists(normal_map)) { normal_image.instance(); diff --git a/editor/plugins/mesh_instance_3d_editor_plugin.cpp b/editor/plugins/mesh_instance_3d_editor_plugin.cpp index f7a90b8ab3..ccefdcd28f 100644 --- a/editor/plugins/mesh_instance_3d_editor_plugin.cpp +++ b/editor/plugins/mesh_instance_3d_editor_plugin.cpp @@ -337,18 +337,15 @@ void MeshInstance3DEditor::_create_uv_lines(int p_layer) { const Vector2 *r = uv.ptr(); Vector<int> indices = a[Mesh::ARRAY_INDEX]; - const int *ri; + const int *ri = NULL; int ic; - bool use_indices; if (indices.size()) { ic = indices.size(); ri = indices.ptr(); - use_indices = true; } else { ic = uv.size(); - use_indices = false; } for (int j = 0; j < ic; j += 3) { @@ -356,7 +353,7 @@ void MeshInstance3DEditor::_create_uv_lines(int p_layer) { for (int k = 0; k < 3; k++) { MeshInstance3DEditorEdgeSort edge; - if (use_indices) { + if (ri) { edge.a = r[ri[j + k]]; edge.b = r[ri[j + ((k + 1) % 3)]]; } else { diff --git a/editor/plugins/polygon_2d_editor_plugin.cpp b/editor/plugins/polygon_2d_editor_plugin.cpp index f570baa885..a5bd5aed6b 100644 --- a/editor/plugins/polygon_2d_editor_plugin.cpp +++ b/editor/plugins/polygon_2d_editor_plugin.cpp @@ -1031,7 +1031,7 @@ void Polygon2DEditor::_uv_draw() { uvs = node->get_polygon(); } - const float *weight_r; + const float *weight_r = NULL; if (uv_edit_mode[3]->is_pressed()) { int bone_selected = -1; @@ -1044,7 +1044,6 @@ void Polygon2DEditor::_uv_draw() { } if (bone_selected != -1 && node->get_bone_weights(bone_selected).size() == uvs.size()) { - weight_r = node->get_bone_weights(bone_selected).ptr(); } } diff --git a/misc/dist/ios_xcode/godot_ios.xcodeproj/project.pbxproj b/misc/dist/ios_xcode/godot_ios.xcodeproj/project.pbxproj index 0b8a508d2f..4b2870b67a 100644 --- a/misc/dist/ios_xcode/godot_ios.xcodeproj/project.pbxproj +++ b/misc/dist/ios_xcode/godot_ios.xcodeproj/project.pbxproj @@ -50,10 +50,10 @@ 1FF4C1841F584E3F00A41E41 /* GameKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GameKit.framework; path = System/Library/Frameworks/GameKit.framework; sourceTree = SDKROOT; }; 1FF4C1861F584E5600A41E41 /* StoreKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = StoreKit.framework; path = System/Library/Frameworks/StoreKit.framework; sourceTree = SDKROOT; }; 1FF4C1881F584E7600A41E41 /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; }; - 1FF4C1881F584E6300A41E41 /* $binary.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = $binary.entitlements; sourceTree = "<group>"; }; + 1FF4C1881F584E6300A41E41 /* $binary.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "$binary.entitlements"; sourceTree = "<group>"; }; 1FF8DBB01FBA9DE1009DE660 /* dummy.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = dummy.cpp; sourceTree = "<group>"; }; D07CD44D1C5D589C00B7FB28 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; }; - D0BCFE3418AEBDA2004A7AAE /* $binary.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = $binary.app; sourceTree = BUILT_PRODUCTS_DIR; }; + D0BCFE3418AEBDA2004A7AAE /* $binary.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "$binary.app"; sourceTree = BUILT_PRODUCTS_DIR; }; D0BCFE3718AEBDA2004A7AAE /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; D0BCFE3918AEBDA2004A7AAE /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; E360193621F32F37009258C1 /* CoreVideo.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreVideo.framework; path = System/Library/Frameworks/CoreVideo.framework; sourceTree = SDKROOT; }; @@ -62,7 +62,7 @@ D0BCFE3F18AEBDA2004A7AAE /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; }; D0BCFE4318AEBDA2004A7AAE /* $binary-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "$binary-Info.plist"; sourceTree = "<group>"; }; D0BCFE4518AEBDA2004A7AAE /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; }; - D0BCFE7718AEBFEB004A7AAE /* $binary.pck */ = {isa = PBXFileReference; lastKnownFileType = file; path = $binary.pck; sourceTree = "<group>"; }; + D0BCFE7718AEBFEB004A7AAE /* $binary.pck */ = {isa = PBXFileReference; lastKnownFileType = file; path = "$binary.pck"; sourceTree = "<group>"; }; /* End PBXFileReference section */ $additional_pbx_files @@ -155,7 +155,7 @@ D0BCFE4218AEBDA2004A7AAE /* Supporting Files */, 1FF8DBB01FBA9DE1009DE660 /* dummy.cpp */, ); - path = $binary; + path = "$binary"; sourceTree = "<group>"; }; D0BCFE4218AEBDA2004A7AAE /* Supporting Files */ = { @@ -422,7 +422,7 @@ ARCHS = "$godot_archs"; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; - CODE_SIGN_ENTITLEMENTS = $binary/$binary.entitlements; + CODE_SIGN_ENTITLEMENTS = "$binary/$binary.entitlements"; CODE_SIGN_IDENTITY = "$code_sign_identity_debug"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "$code_sign_identity_debug"; CONFIGURATION_BUILD_DIR = "$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)"; @@ -448,7 +448,7 @@ ARCHS = "$godot_archs"; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; - CODE_SIGN_ENTITLEMENTS = $binary/$binary.entitlements; + CODE_SIGN_ENTITLEMENTS = "$binary/$binary.entitlements"; CODE_SIGN_IDENTITY = "$code_sign_identity_release"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "$code_sign_identity_release"; CONFIGURATION_BUILD_DIR = "$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)"; diff --git a/misc/scripts/fix_style.sh b/misc/scripts/fix_style.sh index b33cb0a7b4..2eee61a459 100755 --- a/misc/scripts/fix_style.sh +++ b/misc/scripts/fix_style.sh @@ -1,9 +1,10 @@ #!/usr/bin/env bash # Command line arguments +run_black=false run_clang_format=false run_fix_headers=false -usage="Invalid argument. Usage:\n$0 <option>\n\t--clang-format|-c\n\t--headers|-h\n\t--all|-a" +usage="Invalid argument. Usage:\n$0 <option>\n\t--black|-b\n\t--clang-format|-c\n\t--headers|-h\n\t--all|-a" if [ -z "$1" ]; then echo -e $usage @@ -12,6 +13,9 @@ fi while [ $# -gt 0 ]; do case "$1" in + --black|-b) + run_black=true + ;; --clang-format|-c) run_clang_format=true ;; @@ -19,6 +23,7 @@ while [ $# -gt 0 ]; do run_fix_headers=true ;; --all|-a) + run_black=true run_clang_format=true run_fix_headers=true ;; @@ -32,6 +37,19 @@ done echo "Removing generated files, some have binary data and make clang-format freeze." find -name "*.gen.*" -delete +# Apply black +if $run_black; then + echo -e "Formatting Python files..." + PY_FILES=$(find \( -path "./.git" \ + -o -path "./thirdparty" \ + \) -prune \ + -o \( -name "SConstruct" \ + -o -name "SCsub" \ + -o -name "*.py" \ + \) -print) + black -l 120 $PY_FILES +fi + # Apply clang-format if $run_clang_format; then # Sync list with pre-commit hook diff --git a/modules/basis_universal/register_types.cpp b/modules/basis_universal/register_types.cpp index 6b74b8bf4a..5784341d80 100644 --- a/modules/basis_universal/register_types.cpp +++ b/modules/basis_universal/register_types.cpp @@ -98,7 +98,7 @@ static Vector<uint8_t> basis_universal_packer(const Ref<Image> &p_image, Image:: params.m_mip_gen = false; //sorry, please some day support provided mipmaps. params.m_source_images.push_back(buimg); - BasisDecompressFormat decompress_format; + BasisDecompressFormat decompress_format = BASIS_DECOMPRESS_RG; params.m_check_for_alpha = false; switch (p_channels) { diff --git a/modules/mono/SCsub b/modules/mono/SCsub index af77913b91..c723b210cb 100644 --- a/modules/mono/SCsub +++ b/modules/mono/SCsub @@ -47,5 +47,11 @@ env_mono.add_source_files(env.modules_sources, "glue/*.cpp") env_mono.add_source_files(env.modules_sources, "mono_gd/*.cpp") env_mono.add_source_files(env.modules_sources, "utils/*.cpp") +env_mono.add_source_files(env.modules_sources, "mono_gd/support/*.cpp") + +if env["platform"] in ["osx", "iphone"]: + env_mono.add_source_files(env.modules_sources, "mono_gd/support/*.mm") + env_mono.add_source_files(env.modules_sources, "mono_gd/support/*.m") + if env["tools"]: env_mono.add_source_files(env.modules_sources, "editor/*.cpp") diff --git a/modules/mono/build_scripts/mono_configure.py b/modules/mono/build_scripts/mono_configure.py index c8d97c56ba..23f01b3cca 100644 --- a/modules/mono/build_scripts/mono_configure.py +++ b/modules/mono/build_scripts/mono_configure.py @@ -25,25 +25,42 @@ def get_android_out_dir(env): ) -def find_file_in_dir(directory, files, prefix="", extension=""): - if not extension.startswith("."): - extension = "." + extension - for curfile in files: - if os.path.isfile(os.path.join(directory, prefix + curfile + extension)): - return curfile +def find_name_in_dir_files(directory, names, prefixes=[""], extensions=[""]): + for extension in extensions: + if extension and not extension.startswith("."): + extension = "." + extension + for prefix in prefixes: + for curname in names: + if os.path.isfile(os.path.join(directory, prefix + curname + extension)): + return curname return "" -def copy_file(src_dir, dst_dir, name): +def find_file_in_dir(directory, names, prefixes=[""], extensions=[""]): + for extension in extensions: + if extension and not extension.startswith("."): + extension = "." + extension + for prefix in prefixes: + for curname in names: + filename = prefix + curname + extension + if os.path.isfile(os.path.join(directory, filename)): + return filename + return "" + + +def copy_file(src_dir, dst_dir, src_name, dst_name=""): from shutil import copy - src_path = os.path.join(Dir(src_dir).abspath, name) + src_path = os.path.join(Dir(src_dir).abspath, src_name) dst_dir = Dir(dst_dir).abspath if not os.path.isdir(dst_dir): os.makedirs(dst_dir) - copy(src_path, dst_dir) + if dst_name: + copy(src_path, os.path.join(dst_dir, dst_name)) + else: + copy(src_path, dst_dir) def is_desktop(platform): @@ -51,11 +68,11 @@ def is_desktop(platform): def is_unix_like(platform): - return platform in ["osx", "linuxbsd", "server", "android", "haiku"] + return platform in ["osx", "linuxbsd", "server", "android", "haiku", "iphone"] def module_supports_tools_on(platform): - return platform not in ["android", "javascript"] + return platform not in ["android", "javascript", "iphone"] def find_wasm_src_dir(mono_root): @@ -73,6 +90,8 @@ def configure(env, env_mono): bits = env["bits"] is_android = env["platform"] == "android" is_javascript = env["platform"] == "javascript" + is_ios = env["platform"] == "iphone" + is_ios_sim = is_ios and env["arch"] in ["x86", "x86_64"] tools_enabled = env["tools"] mono_static = env["mono_static"] @@ -97,17 +116,32 @@ def configure(env, env_mono): raise RuntimeError("This module does not currently support building for this platform with tools enabled") if is_android and mono_static: - # Android: When static linking and doing something that requires libmono-native, we get a dlopen error as libmono-native seems to depend on libmonosgen-2.0 - raise RuntimeError("Statically linking Mono is not currently supported on this platform") + # FIXME: When static linking and doing something that requires libmono-native, we get a dlopen error as 'libmono-native' + # seems to depend on 'libmonosgen-2.0'. Could be fixed by re-directing to '__Internal' with a dllmap or in the dlopen hook. + raise RuntimeError("Statically linking Mono is not currently supported for this platform") - if is_javascript: - mono_static = True + if not mono_static and (is_javascript or is_ios): + raise RuntimeError("Dynamically linking Mono is not currently supported for this platform") if not mono_prefix and (os.getenv("MONO32_PREFIX") or os.getenv("MONO64_PREFIX")): print( "WARNING: The environment variables 'MONO32_PREFIX' and 'MONO64_PREFIX' are deprecated; use the 'mono_prefix' SCons parameter instead" ) + # Although we don't support building with tools for any platform where we currently use static AOT, + # if these are supported in the future, we won't be using static AOT for them as that would be + # too restrictive for the editor. These builds would probably be made to only use the interpreter. + mono_aot_static = (is_ios and not is_ios_sim) and not env["tools"] + + # Static AOT is only supported on the root domain + mono_single_appdomain = mono_aot_static + + if mono_single_appdomain: + env_mono.Append(CPPDEFINES=["GD_MONO_SINGLE_APPDOMAIN"]) + + if (env["tools"] or env["target"] != "release") and not mono_single_appdomain: + env_mono.Append(CPPDEFINES=["GD_MONO_HOT_RELOAD"]) + if env["platform"] == "windows": mono_root = mono_prefix @@ -126,7 +160,11 @@ def configure(env, env_mono): env.Append(LIBPATH=mono_lib_path) env_mono.Prepend(CPPPATH=os.path.join(mono_root, "include", "mono-2.0")) - lib_suffix = Environment()["LIBSUFFIX"] + lib_suffixes = [".lib"] + + if not env.msvc: + # MingW supports both '.a' and '.lib' + lib_suffixes.insert(0, ".a") if mono_static: if env.msvc: @@ -134,55 +172,61 @@ def configure(env, env_mono): else: mono_static_lib_name = "libmonosgen-2.0" - if not os.path.isfile(os.path.join(mono_lib_path, mono_static_lib_name + lib_suffix)): + mono_static_lib_file = find_file_in_dir(mono_lib_path, [mono_static_lib_name], extensions=lib_suffixes) + + if not mono_static_lib_file: raise RuntimeError("Could not find static mono library in: " + mono_lib_path) if env.msvc: - env.Append(LINKFLAGS=mono_static_lib_name + lib_suffix) + env.Append(LINKFLAGS=mono_static_lib_file) - env.Append(LINKFLAGS="Mincore" + lib_suffix) - env.Append(LINKFLAGS="msvcrt" + lib_suffix) - env.Append(LINKFLAGS="LIBCMT" + lib_suffix) - env.Append(LINKFLAGS="Psapi" + lib_suffix) + env.Append(LINKFLAGS="Mincore.lib") + env.Append(LINKFLAGS="msvcrt.lib") + env.Append(LINKFLAGS="LIBCMT.lib") + env.Append(LINKFLAGS="Psapi.lib") else: - env.Append(LINKFLAGS=os.path.join(mono_lib_path, mono_static_lib_name + lib_suffix)) + mono_static_lib_file_path = os.path.join(mono_lib_path, mono_static_lib_file) + env.Append(LINKFLAGS=["-Wl,-whole-archive", mono_static_lib_file_path, "-Wl,-no-whole-archive"]) env.Append(LIBS=["psapi"]) env.Append(LIBS=["version"]) else: - mono_lib_name = find_file_in_dir(mono_lib_path, mono_lib_names, extension=lib_suffix) + mono_lib_name = find_name_in_dir_files( + mono_lib_path, mono_lib_names, prefixes=["", "lib"], extensions=lib_suffixes + ) if not mono_lib_name: raise RuntimeError("Could not find mono library in: " + mono_lib_path) if env.msvc: - env.Append(LINKFLAGS=mono_lib_name + lib_suffix) + env.Append(LINKFLAGS=mono_lib_name + ".lib") else: env.Append(LIBS=[mono_lib_name]) mono_bin_path = os.path.join(mono_root, "bin") - mono_dll_name = find_file_in_dir(mono_bin_path, mono_lib_names, extension=".dll") + mono_dll_file = find_file_in_dir(mono_bin_path, mono_lib_names, prefixes=["", "lib"], extensions=[".dll"]) - if not mono_dll_name: + if not mono_dll_file: raise RuntimeError("Could not find mono shared library in: " + mono_bin_path) - copy_file(mono_bin_path, "#bin", mono_dll_name + ".dll") + copy_file(mono_bin_path, "#bin", mono_dll_file) else: is_apple = env["platform"] in ["osx", "iphone"] + is_macos = is_apple and not is_ios sharedlib_ext = ".dylib" if is_apple else ".so" mono_root = mono_prefix mono_lib_path = "" - mono_so_name = "" + mono_so_file = "" - if not mono_root and (is_android or is_javascript): + if not mono_root and (is_android or is_javascript or is_ios): raise RuntimeError( "Mono installation directory not found; specify one manually with the 'mono_prefix' SCons parameter" ) - if not mono_root and is_apple: + if not mono_root and is_macos: # Try with some known directories under OSX hint_dirs = ["/Library/Frameworks/Mono.framework/Versions/Current", "/usr/local/var/homebrew/linked/mono"] for hint_dir in hint_dirs: @@ -200,6 +244,9 @@ def configure(env, env_mono): + "specify one manually with the 'mono_prefix' SCons parameter" ) + if is_ios and not is_ios_sim: + env_mono.Append(CPPDEFINES=["IOS_DEVICE"]) + if mono_root: print("Found Mono root directory: " + mono_root) @@ -208,7 +255,7 @@ def configure(env, env_mono): env.Append(LIBPATH=[mono_lib_path]) env_mono.Prepend(CPPPATH=os.path.join(mono_root, "include", "mono-2.0")) - mono_lib = find_file_in_dir(mono_lib_path, mono_lib_names, prefix="lib", extension=".a") + mono_lib = find_name_in_dir_files(mono_lib_path, mono_lib_names, prefixes=["lib"], extensions=[".a"]) if not mono_lib: raise RuntimeError("Could not find mono library in: " + mono_lib_path) @@ -221,7 +268,26 @@ def configure(env, env_mono): mono_lib_file = os.path.join(mono_lib_path, "lib" + mono_lib + ".a") if is_apple: - env.Append(LINKFLAGS=["-Wl,-force_load," + mono_lib_file]) + if is_macos: + env.Append(LINKFLAGS=["-Wl,-force_load," + mono_lib_file]) + else: + arch = env["arch"] + + def copy_mono_lib(libname_wo_ext): + copy_file( + mono_lib_path, "#bin", libname_wo_ext + ".a", "%s.iphone.%s.a" % (libname_wo_ext, arch) + ) + + # Copy Mono libraries to the output folder. These are meant to be bundled with + # the export templates and added to the Xcode project when exporting a game. + copy_mono_lib("lib" + mono_lib) + copy_mono_lib("libmono-native") + copy_mono_lib("libmono-profiler-log") + + if not is_ios_sim: + copy_mono_lib("libmono-ee-interp") + copy_mono_lib("libmono-icall-table") + copy_mono_lib("libmono-ilgen") else: assert is_desktop(env["platform"]) or is_android or is_javascript env.Append(LINKFLAGS=["-Wl,-whole-archive", mono_lib_file, "-Wl,-no-whole-archive"]) @@ -258,22 +324,24 @@ def configure(env, env_mono): else: env.Append(LIBS=[mono_lib]) - if is_apple: + if is_macos: env.Append(LIBS=["iconv", "pthread"]) elif is_android: pass # Nothing + elif is_ios: + pass # Nothing, linking is delegated to the exported Xcode project elif is_javascript: env.Append(LIBS=["m", "rt", "dl", "pthread"]) else: env.Append(LIBS=["m", "rt", "dl", "pthread"]) if not mono_static: - mono_so_name = find_file_in_dir(mono_lib_path, mono_lib_names, prefix="lib", extension=sharedlib_ext) + mono_so_file = find_file_in_dir( + mono_lib_path, mono_lib_names, prefixes=["lib"], extensions=[sharedlib_ext] + ) - if not mono_so_name: + if not mono_so_file: raise RuntimeError("Could not find mono shared library in: " + mono_lib_path) - - copy_file(mono_lib_path, "#bin", "lib" + mono_so_name + sharedlib_ext) else: assert not mono_static @@ -288,18 +356,18 @@ def configure(env, env_mono): tmpenv.ParseConfig("pkg-config monosgen-2 --libs-only-L") for hint_dir in tmpenv["LIBPATH"]: - name_found = find_file_in_dir(hint_dir, mono_lib_names, prefix="lib", extension=sharedlib_ext) - if name_found: + file_found = find_file_in_dir(hint_dir, mono_lib_names, prefixes=["lib"], extensions=[sharedlib_ext]) + if file_found: mono_lib_path = hint_dir - mono_so_name = name_found + mono_so_file = file_found break - if not mono_so_name: + if not mono_so_file: raise RuntimeError("Could not find mono shared library in: " + str(tmpenv["LIBPATH"])) if not mono_static: libs_output_dir = get_android_out_dir(env) if is_android else "#bin" - copy_file(mono_lib_path, libs_output_dir, "lib" + mono_so_name + sharedlib_ext) + copy_file(mono_lib_path, libs_output_dir, mono_so_file) if not tools_enabled: if is_desktop(env["platform"]): @@ -321,6 +389,8 @@ def configure(env, env_mono): copy_mono_shared_libs(env, mono_root, None) elif is_javascript: pass # No data directory for this platform + elif is_ios: + pass # No data directory for this platform if copy_mono_root: if not mono_root: @@ -454,11 +524,11 @@ def copy_mono_shared_libs(env, mono_root, target_mono_root_dir): if not os.path.isdir(target_mono_bin_dir): os.makedirs(target_mono_bin_dir) - mono_posix_helper_name = find_file_in_dir( - src_mono_bin_dir, ["MonoPosixHelper", "libMonoPosixHelper"], extension=".dll" + mono_posix_helper_file = find_file_in_dir( + src_mono_bin_dir, ["MonoPosixHelper"], prefixes=["", "lib"], extensions=[".dll"] ) copy( - os.path.join(src_mono_bin_dir, mono_posix_helper_name + ".dll"), + os.path.join(src_mono_bin_dir, mono_posix_helper_file), os.path.join(target_mono_bin_dir, "MonoPosixHelper.dll"), ) @@ -504,7 +574,7 @@ def pkgconfig_try_find_mono_root(mono_lib_names, sharedlib_ext): tmpenv.AppendENVPath("PKG_CONFIG_PATH", os.getenv("PKG_CONFIG_PATH")) tmpenv.ParseConfig("pkg-config monosgen-2 --libs-only-L") for hint_dir in tmpenv["LIBPATH"]: - name_found = find_file_in_dir(hint_dir, mono_lib_names, prefix="lib", extension=sharedlib_ext) + name_found = find_name_in_dir_files(hint_dir, mono_lib_names, prefixes=["lib"], extensions=[sharedlib_ext]) if name_found and os.path.isdir(os.path.join(hint_dir, "..", "include", "mono-2.0")): return os.path.join(hint_dir, "..") return "" diff --git a/modules/mono/config.py b/modules/mono/config.py index 2ea8a5247d..106ca6e028 100644 --- a/modules/mono/config.py +++ b/modules/mono/config.py @@ -1,9 +1,14 @@ +supported_platforms = ["windows", "osx", "linuxbsd", "server", "android", "haiku", "javascript", "iphone"] + + def can_build(env, platform): return True def configure(env): - if env["platform"] not in ["windows", "osx", "linuxbsd", "server", "android", "haiku", "javascript"]: + platform = env["platform"] + + if platform not in supported_platforms: raise RuntimeError("This module does not currently support building for this platform") env.use_ptrcall = True @@ -11,6 +16,9 @@ def configure(env): from SCons.Script import BoolVariable, PathVariable, Variables, Help + default_mono_static = platform in ["iphone", "javascript"] + default_mono_bundles_zlib = platform in ["javascript"] + envvars = Variables() envvars.Add( PathVariable( @@ -20,7 +28,7 @@ def configure(env): PathVariable.PathAccept, ) ) - envvars.Add(BoolVariable("mono_static", "Statically link mono", False)) + envvars.Add(BoolVariable("mono_static", "Statically link mono", default_mono_static)) envvars.Add(BoolVariable("mono_glue", "Build with the mono glue sources", True)) envvars.Add( BoolVariable( @@ -28,12 +36,20 @@ def configure(env): ) ) envvars.Add(BoolVariable("xbuild_fallback", "If MSBuild is not found, fallback to xbuild", False)) + + # TODO: It would be great if this could be detected automatically instead + envvars.Add( + BoolVariable( + "mono_bundles_zlib", "Specify if the Mono runtime was built with bundled zlib", default_mono_bundles_zlib + ) + ) + envvars.Update(env) Help(envvars.GenerateHelpText(env)) - if env["platform"] == "javascript": - # Mono wasm already has zlib builtin, so we need this workaround to avoid symbol collisions - print("Compiling with Mono wasm disables 'builtin_zlib'") + if env["mono_bundles_zlib"]: + # Mono may come with zlib bundled for WASM or on newer version when built with MinGW. + print("This Mono runtime comes with zlib bundled. Disabling 'builtin_zlib'...") env["builtin_zlib"] = False thirdparty_zlib_dir = "#thirdparty/zlib/" env.Prepend(CPPPATH=[thirdparty_zlib_dir]) diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index 28bacbd0f0..bb3d0ef46f 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -763,7 +763,7 @@ bool CSharpLanguage::is_assembly_reloading_needed() { if (proj_assembly) { String proj_asm_path = proj_assembly->get_path(); - if (!FileAccess::exists(proj_assembly->get_path())) { + if (!FileAccess::exists(proj_asm_path)) { // Maybe it wasn't loaded from the default path, so check this as well proj_asm_path = GodotSharpDirs::get_res_temp_assemblies_dir().plus_file(appname_safe); if (!FileAccess::exists(proj_asm_path)) diff --git a/modules/mono/editor/GodotTools/GodotTools/Export/AotBuilder.cs b/modules/mono/editor/GodotTools/GodotTools/Export/AotBuilder.cs new file mode 100755 index 0000000000..f1765f7e19 --- /dev/null +++ b/modules/mono/editor/GodotTools/GodotTools/Export/AotBuilder.cs @@ -0,0 +1,618 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Text; +using GodotTools.Internals; +using Directory = GodotTools.Utils.Directory; +using File = GodotTools.Utils.File; +using OS = GodotTools.Utils.OS; +using Path = System.IO.Path; + +namespace GodotTools.Export +{ + public struct AotOptions + { + public bool EnableLLVM; + public bool LLVMOnly; + public string LLVMPath; + public string LLVMOutputPath; + + public bool FullAot; + + private bool _useInterpreter; + public bool UseInterpreter { get => _useInterpreter && !LLVMOnly; set => _useInterpreter = value; } + + public string[] ExtraAotOptions; + public string[] ExtraOptimizerOptions; + + public string ToolchainPath; + } + + public static class AotBuilder + { + public static void CompileAssemblies(ExportPlugin exporter, AotOptions aotOpts, string[] features, string platform, bool isDebug, string bclDir, string outputDir, string outputDataDir, IDictionary<string, string> assemblies) + { + // TODO: WASM + + string aotTempDir = Path.Combine(Path.GetTempPath(), $"godot-aot-{Process.GetCurrentProcess().Id}"); + + if (!Directory.Exists(aotTempDir)) + Directory.CreateDirectory(aotTempDir); + + var assembliesPrepared = new Dictionary<string, string>(); + + foreach (var dependency in assemblies) + { + string assemblyName = dependency.Key; + string assemblyPath = dependency.Value; + + string assemblyPathInBcl = Path.Combine(bclDir, assemblyName + ".dll"); + + if (File.Exists(assemblyPathInBcl)) + { + // Don't create teporaries for assemblies from the BCL + assembliesPrepared.Add(assemblyName, assemblyPathInBcl); + } + else + { + string tempAssemblyPath = Path.Combine(aotTempDir, assemblyName + ".dll"); + File.Copy(assemblyPath, tempAssemblyPath); + assembliesPrepared.Add(assemblyName, tempAssemblyPath); + } + } + + if (platform == OS.Platforms.iOS) + { + var architectures = GetEnablediOSArchs(features).ToArray(); + CompileAssembliesForiOS(exporter, isDebug, architectures, aotOpts, aotTempDir, assembliesPrepared, bclDir); + } + else if (platform == OS.Platforms.Android) + { + var abis = GetEnabledAndroidAbis(features).ToArray(); + CompileAssembliesForAndroid(exporter, isDebug, abis, aotOpts, aotTempDir, assembliesPrepared, bclDir); + } + else + { + string bits = features.Contains("64") ? "64" : features.Contains("32") ? "32" : null; + CompileAssembliesForDesktop(exporter, platform, isDebug, bits, aotOpts, aotTempDir, outputDataDir, assembliesPrepared, bclDir); + } + } + + public static void CompileAssembliesForAndroid(ExportPlugin exporter, bool isDebug, string[] abis, AotOptions aotOpts, string aotTempDir, IDictionary<string, string> assemblies, string bclDir) + { + + foreach (var assembly in assemblies) + { + string assemblyName = assembly.Key; + string assemblyPath = assembly.Value; + + // Not sure if the 'lib' prefix is an Android thing or just Godot being picky, + // but we use '-aot-' as well just in case to avoid conflicts with other libs. + string outputFileName = "lib-aot-" + assemblyName + ".dll.so"; + + foreach (string abi in abis) + { + string aotAbiTempDir = Path.Combine(aotTempDir, abi); + string soFilePath = Path.Combine(aotAbiTempDir, outputFileName); + + var compilerArgs = GetAotCompilerArgs(OS.Platforms.Android, isDebug, abi, aotOpts, assemblyPath, soFilePath); + + // Make sure the output directory exists + Directory.CreateDirectory(aotAbiTempDir); + + string compilerDirPath = Path.Combine(GodotSharpDirs.DataEditorToolsDir, "aot-compilers", $"{OS.Platforms.Android}-{abi}"); + + ExecuteCompiler(FindCrossCompiler(compilerDirPath), compilerArgs, bclDir); + + // The Godot exporter expects us to pass the abi in the tags parameter + exporter.AddSharedObject(soFilePath, tags: new[] { abi }); + } + } + } + + public static void CompileAssembliesForDesktop(ExportPlugin exporter, string platform, bool isDebug, string bits, AotOptions aotOpts, string aotTempDir, string outputDataDir, IDictionary<string, string> assemblies, string bclDir) + { + foreach (var assembly in assemblies) + { + string assemblyName = assembly.Key; + string assemblyPath = assembly.Value; + + string outputFileExtension = platform == OS.Platforms.Windows ? ".dll" : + platform == OS.Platforms.OSX ? ".dylib" : + ".so"; + + string outputFileName = assemblyName + ".dll" + outputFileExtension; + string tempOutputFilePath = Path.Combine(aotTempDir, outputFileName); + + var compilerArgs = GetAotCompilerArgs(platform, isDebug, bits, aotOpts, assemblyPath, tempOutputFilePath); + + string compilerDirPath = GetMonoCrossDesktopDirName(platform, bits); + + ExecuteCompiler(FindCrossCompiler(compilerDirPath), compilerArgs, bclDir); + + if (platform == OS.Platforms.OSX) + { + exporter.AddSharedObject(tempOutputFilePath, tags: null); + } + else + { + string outputDataLibDir = Path.Combine(outputDataDir, "Mono", platform == OS.Platforms.Windows ? "bin" : "lib"); + File.Copy(tempOutputFilePath, Path.Combine(outputDataLibDir, outputFileName)); + } + } + } + + public static void CompileAssembliesForiOS(ExportPlugin exporter, bool isDebug, string[] architectures, AotOptions aotOpts, string aotTempDir, IDictionary<string, string> assemblies, string bclDir) + { + var cppCode = new StringBuilder(); + var aotModuleInfoSymbols = new List<string>(assemblies.Count); + + // {arch: paths} + var objFilePathsForiOSArch = architectures.ToDictionary(arch => arch, arch => new List<string>(assemblies.Count)); + + foreach (var assembly in assemblies) + { + string assemblyName = assembly.Key; + string assemblyPath = assembly.Value; + + string asmFileName = assemblyName + ".dll.S"; + string objFileName = assemblyName + ".dll.o"; + + foreach (string arch in architectures) + { + string aotArchTempDir = Path.Combine(aotTempDir, arch); + string asmFilePath = Path.Combine(aotArchTempDir, asmFileName); + + var compilerArgs = GetAotCompilerArgs(OS.Platforms.iOS, isDebug, arch, aotOpts, assemblyPath, asmFilePath); + + // Make sure the output directory exists + Directory.CreateDirectory(aotArchTempDir); + + string compilerDirPath = Path.Combine(GodotSharpDirs.DataEditorToolsDir, "aot-compilers", $"{OS.Platforms.iOS}-{arch}"); + + ExecuteCompiler(FindCrossCompiler(compilerDirPath), compilerArgs, bclDir); + + // Assembling + bool isSim = arch == "i386" || arch == "x86_64"; // Shouldn't really happen as we don't do AOT for the simulator + string versionMinName = isSim ? "iphonesimulator" : "iphoneos"; + string iOSPlatformName = isSim ? "iPhoneSimulator" : "iPhoneOS"; + const string versionMin = "10.0"; // TODO: Turn this hard-coded version into an exporter setting + string iOSSdkPath = Path.Combine(XcodeHelper.XcodePath, + $"Contents/Developer/Platforms/{iOSPlatformName}.platform/Developer/SDKs/{iOSPlatformName}.sdk"); + + string objFilePath = Path.Combine(aotArchTempDir, objFileName); + + var clangArgs = new List<string>() + { + "-isysroot", iOSSdkPath, + "-Qunused-arguments", + $"-m{versionMinName}-version-min={versionMin}", + "-arch", arch, + "-c", + "-o", objFilePath, + "-x", "assembler" + }; + + if (isDebug) + clangArgs.Add("-DDEBUG"); + + clangArgs.Add(asmFilePath); + + int clangExitCode = OS.ExecuteCommand(XcodeHelper.FindXcodeTool("clang"), clangArgs); + if (clangExitCode != 0) + throw new Exception($"Command 'clang' exited with code: {clangExitCode}"); + + objFilePathsForiOSArch[arch].Add(objFilePath); + } + + aotModuleInfoSymbols.Add($"mono_aot_module_{AssemblyNameToAotSymbol(assemblyName)}_info"); + } + + // Generate driver code + cppCode.AppendLine("#if defined(__arm__) || defined(__arm64__) || defined(__aarch64__)"); + cppCode.AppendLine("#define IOS_DEVICE"); + cppCode.AppendLine("#endif"); + + cppCode.AppendLine("#ifdef IOS_DEVICE"); + cppCode.AppendLine("extern \"C\" {"); + cppCode.AppendLine("// Mono API"); + cppCode.AppendLine(@" +typedef enum { +MONO_AOT_MODE_NONE, +MONO_AOT_MODE_NORMAL, +MONO_AOT_MODE_HYBRID, +MONO_AOT_MODE_FULL, +MONO_AOT_MODE_LLVMONLY, +MONO_AOT_MODE_INTERP, +MONO_AOT_MODE_INTERP_LLVMONLY, +MONO_AOT_MODE_LLVMONLY_INTERP, +MONO_AOT_MODE_LAST = 1000, +} MonoAotMode;"); + cppCode.AppendLine("void mono_jit_set_aot_mode(MonoAotMode);"); + cppCode.AppendLine("void mono_aot_register_module(void *);"); + + if (aotOpts.UseInterpreter) + { + cppCode.AppendLine("void mono_ee_interp_init(const char *);"); + cppCode.AppendLine("void mono_icall_table_init();"); + cppCode.AppendLine("void mono_marshal_ilgen_init();"); + cppCode.AppendLine("void mono_method_builder_ilgen_init();"); + cppCode.AppendLine("void mono_sgen_mono_ilgen_init();"); + } + + foreach (string symbol in aotModuleInfoSymbols) + cppCode.AppendLine($"extern void *{symbol};"); + + cppCode.AppendLine("void gd_mono_setup_aot() {"); + + foreach (string symbol in aotModuleInfoSymbols) + cppCode.AppendLine($"\tmono_aot_register_module({symbol});"); + + if (aotOpts.UseInterpreter) + { + cppCode.AppendLine("\tmono_icall_table_init();"); + cppCode.AppendLine("\tmono_marshal_ilgen_init();"); + cppCode.AppendLine("\tmono_method_builder_ilgen_init();"); + cppCode.AppendLine("\tmono_sgen_mono_ilgen_init();"); + cppCode.AppendLine("\tmono_ee_interp_init(0);"); + } + + string aotModeStr = null; + + if (aotOpts.LLVMOnly) + { + aotModeStr = "MONO_AOT_MODE_LLVMONLY"; // --aot=llvmonly + } + else + { + if (aotOpts.UseInterpreter) + aotModeStr = "MONO_AOT_MODE_INTERP"; // --aot=interp or --aot=interp,full + else if (aotOpts.FullAot) + aotModeStr = "MONO_AOT_MODE_FULL"; // --aot=full + } + + // One of the options above is always set for iOS + Debug.Assert(aotModeStr != null); + + cppCode.AppendLine($"\tmono_jit_set_aot_mode({aotModeStr});"); + + cppCode.AppendLine("} // gd_mono_setup_aot"); + cppCode.AppendLine("} // extern \"C\""); + cppCode.AppendLine("#endif // IOS_DEVICE"); + + // Add the driver code to the Xcode project + exporter.AddIosCppCode(cppCode.ToString()); + + // Archive the AOT object files into a static library + + var arFilePathsForAllArchs = new List<string>(); + string projectAssemblyName = GodotSharpEditor.ProjectAssemblyName; + + foreach (var archPathsPair in objFilePathsForiOSArch) + { + string arch = archPathsPair.Key; + var objFilePaths = archPathsPair.Value; + + string arOutputFilePath = Path.Combine(aotTempDir, $"lib-aot-{projectAssemblyName}.{arch}.a"); + + var arArgs = new List<string>() + { + "cr", + arOutputFilePath + }; + + foreach (string objFilePath in objFilePaths) + arArgs.Add(objFilePath); + + int arExitCode = OS.ExecuteCommand(XcodeHelper.FindXcodeTool("ar"), arArgs); + if (arExitCode != 0) + throw new Exception($"Command 'ar' exited with code: {arExitCode}"); + + arFilePathsForAllArchs.Add(arOutputFilePath); + } + + // It's lipo time + + string fatOutputFileName = $"lib-aot-{projectAssemblyName}.fat.a"; + string fatOutputFilePath = Path.Combine(aotTempDir, fatOutputFileName); + + var lipoArgs = new List<string>(); + lipoArgs.Add("-create"); + lipoArgs.AddRange(arFilePathsForAllArchs); + lipoArgs.Add("-output"); + lipoArgs.Add(fatOutputFilePath); + + int lipoExitCode = OS.ExecuteCommand(XcodeHelper.FindXcodeTool("lipo"), lipoArgs); + if (lipoExitCode != 0) + throw new Exception($"Command 'lipo' exited with code: {lipoExitCode}"); + + // TODO: Add the AOT lib and interpreter libs as device only to supress warnings when targeting the simulator + + // Add the fat AOT static library to the Xcode project + exporter.AddIosProjectStaticLib(fatOutputFilePath); + + // Add the required Mono libraries to the Xcode project + + string MonoLibFile(string libFileName) => libFileName + ".iphone.fat.a"; + + string MonoLibFromTemplate(string libFileName) => + Path.Combine(Internal.FullTemplatesDir, "iphone-mono-libs", MonoLibFile(libFileName)); + + exporter.AddIosProjectStaticLib(MonoLibFromTemplate("libmonosgen-2.0")); + + exporter.AddIosProjectStaticLib(MonoLibFromTemplate("libmono-native")); + + if (aotOpts.UseInterpreter) + { + exporter.AddIosProjectStaticLib(MonoLibFromTemplate("libmono-ee-interp")); + exporter.AddIosProjectStaticLib(MonoLibFromTemplate("libmono-icall-table")); + exporter.AddIosProjectStaticLib(MonoLibFromTemplate("libmono-ilgen")); + } + + // TODO: Turn into an exporter option + bool enableProfiling = false; + if (enableProfiling) + exporter.AddIosProjectStaticLib(MonoLibFromTemplate("libmono-profiler-log")); + + // Add frameworks required by Mono to the Xcode project + exporter.AddIosFramework("libiconv.tbd"); + exporter.AddIosFramework("GSS.framework"); + exporter.AddIosFramework("CFNetwork.framework"); + + // Force load and export dynamic are needed for the linker to not strip required symbols. + // In theory we shouldn't be relying on this for P/Invoked functions (as is the case with + // functions in System.Native/libmono-native). Instead, we should use cecil to search for + // DllImports in assemblies and pass them to 'ld' as '-u/--undefined {pinvoke_symbol}'. + exporter.AddIosLinkerFlags("-rdynamic"); + exporter.AddIosLinkerFlags($"-force_load \"$(SRCROOT)/{MonoLibFile("libmono-native")}\""); + } + + /// Converts an assembly name to a valid symbol name in the same way the AOT compiler does + private static string AssemblyNameToAotSymbol(string assemblyName) + { + var builder = new StringBuilder(); + + foreach (var charByte in Encoding.UTF8.GetBytes(assemblyName)) + { + char @char = (char)charByte; + builder.Append(Char.IsLetterOrDigit(@char) || @char == '_' ? @char : '_'); + } + + return builder.ToString(); + } + + private static IEnumerable<string> GetAotCompilerArgs(string platform, bool isDebug, string target, AotOptions aotOpts, string assemblyPath, string outputFilePath) + { + // TODO: LLVM + + bool aotSoftDebug = isDebug && !aotOpts.EnableLLVM; + bool aotDwarfDebug = platform == OS.Platforms.iOS; + + var aotOptions = new List<string>(); + var optimizerOptions = new List<string>(); + + if (aotOpts.LLVMOnly) + { + aotOptions.Add("llvmonly"); + } + else + { + // Can be both 'interp' and 'full' + if (aotOpts.UseInterpreter) + aotOptions.Add("interp"); + if (aotOpts.FullAot) + aotOptions.Add("full"); + } + + aotOptions.Add(aotSoftDebug ? "soft-debug" : "nodebug"); + + if (aotDwarfDebug) + aotOptions.Add("dwarfdebug"); + + if (platform == OS.Platforms.Android) + { + string abi = target; + + string androidToolchain = aotOpts.ToolchainPath; + + if (string.IsNullOrEmpty(androidToolchain)) + { + androidToolchain = Path.Combine(GodotSharpDirs.DataEditorToolsDir, "android-toolchains", $"{abi}"); // TODO: $"{abi}-{apiLevel}{(clang?"clang":"")}" + + if (!Directory.Exists(androidToolchain)) + throw new FileNotFoundException("Missing android toolchain. Specify one in the AOT export settings."); + } + else if (!Directory.Exists(androidToolchain)) + { + throw new FileNotFoundException("Android toolchain not found: " + androidToolchain); + } + + var androidToolPrefixes = new Dictionary<string, string> + { + ["armeabi-v7a"] = "arm-linux-androideabi-", + ["arm64-v8a"] = "aarch64-linux-android-", + ["x86"] = "i686-linux-android-", + ["x86_64"] = "x86_64-linux-android-" + }; + + aotOptions.Add("tool-prefix=" + Path.Combine(androidToolchain, "bin", androidToolPrefixes[abi])); + + string triple = GetAndroidTriple(abi); + aotOptions.Add($"mtriple={triple}"); + } + else if (platform == OS.Platforms.iOS) + { + if (!aotOpts.LLVMOnly && !aotOpts.UseInterpreter) + optimizerOptions.Add("gsharedvt"); + + aotOptions.Add("static"); + + // I couldn't get the Mono cross-compiler to do assembling, so we'll have to do it ourselves + aotOptions.Add("asmonly"); + + aotOptions.Add("direct-icalls"); + + if (aotSoftDebug) + aotOptions.Add("no-direct-calls"); + + if (aotOpts.LLVMOnly || !aotOpts.UseInterpreter) + aotOptions.Add("direct-pinvoke"); + + string arch = target; + aotOptions.Add($"mtriple={arch}-ios"); + } + + aotOptions.Add($"outfile={outputFilePath}"); + + if (aotOpts.EnableLLVM) + { + aotOptions.Add($"llvm-path={aotOpts.LLVMPath}"); + aotOptions.Add($"llvm-outfile={aotOpts.LLVMOutputPath}"); + } + + if (aotOpts.ExtraAotOptions.Length > 0) + aotOptions.AddRange(aotOpts.ExtraAotOptions); + + if (aotOpts.ExtraOptimizerOptions.Length > 0) + optimizerOptions.AddRange(aotOpts.ExtraOptimizerOptions); + + string EscapeOption(string option) => option.Contains(',') ? $"\"{option}\"" : option; + string OptionsToString(IEnumerable<string> options) => string.Join(",", options.Select(EscapeOption)); + + var runtimeArgs = new List<string>(); + + // The '--debug' runtime option is required when using the 'soft-debug' and 'dwarfdebug' AOT options + if (aotSoftDebug || aotDwarfDebug) + runtimeArgs.Add("--debug"); + + if (aotOpts.EnableLLVM) + runtimeArgs.Add("--llvm"); + + runtimeArgs.Add(aotOptions.Count > 0 ? $"--aot={OptionsToString(aotOptions)}" : "--aot"); + + if (optimizerOptions.Count > 0) + runtimeArgs.Add($"-O={OptionsToString(optimizerOptions)}"); + + runtimeArgs.Add(assemblyPath); + + return runtimeArgs; + } + + private static void ExecuteCompiler(string compiler, IEnumerable<string> compilerArgs, string bclDir) + { + // TODO: Once we move to .NET Standard 2.1 we can use ProcessStartInfo.ArgumentList instead + string CmdLineArgsToString(IEnumerable<string> args) + { + // Not perfect, but as long as we are careful... + return string.Join(" ", args.Select(arg => arg.Contains(" ") ? $@"""{arg}""" : arg)); + } + + using (var process = new Process()) + { + process.StartInfo = new ProcessStartInfo(compiler, CmdLineArgsToString(compilerArgs)) + { + UseShellExecute = false + }; + + process.StartInfo.EnvironmentVariables.Remove("MONO_ENV_OPTIONS"); + process.StartInfo.EnvironmentVariables.Remove("MONO_THREADS_SUSPEND"); + process.StartInfo.EnvironmentVariables.Add("MONO_PATH", bclDir); + + Console.WriteLine($"Running: \"{process.StartInfo.FileName}\" {process.StartInfo.Arguments}"); + + if (!process.Start()) + throw new Exception("Failed to start process for Mono AOT compiler"); + + process.WaitForExit(); + + if (process.ExitCode != 0) + throw new Exception($"Mono AOT compiler exited with code: {process.ExitCode}"); + } + } + + private static IEnumerable<string> GetEnablediOSArchs(string[] features) + { + var iosArchs = new[] + { + "armv7", + "arm64" + }; + + return iosArchs.Where(features.Contains); + } + + private static IEnumerable<string> GetEnabledAndroidAbis(string[] features) + { + var androidAbis = new[] + { + "armeabi-v7a", + "arm64-v8a", + "x86", + "x86_64" + }; + + return androidAbis.Where(features.Contains); + } + + private static string GetAndroidTriple(string abi) + { + var abiArchs = new Dictionary<string, string> + { + ["armeabi-v7a"] = "armv7", + ["arm64-v8a"] = "aarch64-v8a", + ["x86"] = "i686", + ["x86_64"] = "x86_64" + }; + + string arch = abiArchs[abi]; + + return $"{arch}-linux-android"; + } + + private static string GetMonoCrossDesktopDirName(string platform, string bits) + { + switch (platform) + { + case OS.Platforms.Windows: + case OS.Platforms.UWP: + { + string arch = bits == "64" ? "x86_64" : "i686"; + return $"windows-{arch}"; + } + case OS.Platforms.OSX: + { + Debug.Assert(bits == null || bits == "64"); + string arch = "x86_64"; + return $"{platform}-{arch}"; + } + case OS.Platforms.X11: + case OS.Platforms.Server: + { + string arch = bits == "64" ? "x86_64" : "i686"; + return $"linux-{arch}"; + } + case OS.Platforms.Haiku: + { + string arch = bits == "64" ? "x86_64" : "i686"; + return $"{platform}-{arch}"; + } + default: + throw new NotSupportedException($"Platform not supported: {platform}"); + } + } + + // TODO: Replace this for a specific path for each platform + private static string FindCrossCompiler(string monoCrossBin) + { + string exeExt = OS.IsWindows ? ".exe" : string.Empty; + + var files = new DirectoryInfo(monoCrossBin).GetFiles($"*mono-sgen{exeExt}", SearchOption.TopDirectoryOnly); + if (files.Length > 0) + return Path.Combine(monoCrossBin, files[0].Name); + + throw new FileNotFoundException($"Cannot find the mono runtime executable in {monoCrossBin}"); + } + } +} diff --git a/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs b/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs index 022005ad0b..d782d4e61b 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs @@ -29,15 +29,13 @@ namespace GodotTools.Export All = CJK | MidEast | Other | Rare | West } - private void AddI18NAssemblies(Godot.Collections.Dictionary<string, string> assemblies, string platform) + private void AddI18NAssemblies(Godot.Collections.Dictionary<string, string> assemblies, string bclDir) { - var codesets = (I18NCodesets) ProjectSettings.GetSetting("mono/export/i18n_codesets"); + var codesets = (I18NCodesets)ProjectSettings.GetSetting("mono/export/i18n_codesets"); if (codesets == I18NCodesets.None) return; - string bclDir = DeterminePlatformBclDir(platform) ?? typeof(object).Assembly.Location.GetBaseDir(); - void AddI18NAssembly(string name) => assemblies.Add(name, Path.Combine(bclDir, $"{name}.dll")); AddI18NAssembly("I18N"); @@ -73,6 +71,7 @@ namespace GodotTools.Export GlobalDef("mono/export/aot/enabled", false); GlobalDef("mono/export/aot/full_aot", false); + GlobalDef("mono/export/aot/use_interpreter", true); // --aot or --aot=opt1,opt2 (use 'mono --aot=help AuxAssembly.dll' to list AOT options) GlobalDef("mono/export/aot/extra_aot_options", new string[] { }); @@ -86,9 +85,11 @@ namespace GodotTools.Export private void AddFile(string srcPath, string dstPath, bool remap = false) { + // Add file to the PCK AddFile(dstPath.Replace("\\", "/"), File.ReadAllBytes(srcPath), remap); } + // With this method we can override how a file is exported in the PCK public override void _ExportFile(string path, string type, string[] features) { base._ExportFile(path, type, features); @@ -110,6 +111,8 @@ namespace GodotTools.Export // Sadly, Godot prints errors when adding an empty file (nothing goes wrong, it's just noise). // Because of this, we add a file which contains a line break. AddFile(path, System.Text.Encoding.UTF8.GetBytes("\n"), remap: false); + + // Tell the Godot exporter that we already took care of the file Skip(); } } @@ -167,12 +170,7 @@ namespace GodotTools.Export var dependencies = new Godot.Collections.Dictionary<string, string>(); - var projectDllName = (string)ProjectSettings.GetSetting("application/config/name"); - if (projectDllName.Empty()) - { - projectDllName = "UnnamedProject"; - } - + string projectDllName = GodotSharpEditor.ProjectAssemblyName; string projectDllSrcDir = Path.Combine(GodotSharpDirs.ResTempAssembliesBaseDir, buildConfig); string projectDllSrcPath = Path.Combine(projectDllSrcDir, $"{projectDllName}.dll"); @@ -189,10 +187,12 @@ namespace GodotTools.Export dependencies["Mono.Android"] = monoAndroidAssemblyPath; } + string bclDir = DeterminePlatformBclDir(platform); + var initialDependencies = dependencies.Duplicate(); - internal_GetExportedAssemblyDependencies(initialDependencies, buildConfig, DeterminePlatformBclDir(platform), dependencies); + internal_GetExportedAssemblyDependencies(initialDependencies, buildConfig, bclDir, dependencies); - AddI18NAssemblies(dependencies, platform); + AddI18NAssemblies(dependencies, bclDir); string outputDataDir = null; @@ -227,11 +227,34 @@ namespace GodotTools.Export } } - // AOT + // AOT compilation + bool aotEnabled = platform == OS.Platforms.iOS || (bool)ProjectSettings.GetSetting("mono/export/aot/enabled"); - if ((bool)ProjectSettings.GetSetting("mono/export/aot/enabled")) + if (aotEnabled) { - AotCompileDependencies(features, platform, isDebug, outputDir, outputDataDir, dependencies); + string aotToolchainPath = null; + + if (platform == OS.Platforms.Android) + aotToolchainPath = (string)ProjectSettings.GetSetting("mono/export/aot/android_toolchain_path"); + + if (aotToolchainPath == string.Empty) + aotToolchainPath = null; // Don't risk it being used as current working dir + + // TODO: LLVM settings are hard-coded and disabled for now + var aotOpts = new AotOptions + { + EnableLLVM = false, + LLVMOnly = false, + LLVMPath = "", + LLVMOutputPath = "", + FullAot = platform == OS.Platforms.iOS || (bool)(ProjectSettings.GetSetting("mono/export/aot/full_aot") ?? false), + UseInterpreter = (bool)ProjectSettings.GetSetting("mono/export/aot/use_interpreter"), + ExtraAotOptions = (string[])ProjectSettings.GetSetting("mono/export/aot/extra_aot_options") ?? new string[] { }, + ExtraOptimizerOptions = (string[])ProjectSettings.GetSetting("mono/export/aot/extra_optimizer_options") ?? new string[] { }, + ToolchainPath = aotToolchainPath + }; + + AotBuilder.CompileAssemblies(this, aotOpts, features, platform, isDebug, bclDir, outputDir, outputDataDir, dependencies); } } @@ -258,7 +281,8 @@ namespace GodotTools.Export { string target = isDebug ? "release_debug" : "release"; - // NOTE: Bits is ok for now as all platforms with a data directory have it, but that may change in the future. + // NOTE: Bits is ok for now as all platforms with a data directory only have one or two architectures. + // However, this may change in the future if we add arm linux or windows desktop templates. string bits = features.Contains("64") ? "64" : "32"; string TemplateDirName() => $"data.mono.{platform}.{bits}.{target}"; @@ -284,7 +308,7 @@ namespace GodotTools.Export if (!validTemplatePathFound) throw new FileNotFoundException("Data template directory not found", templateDirPath); - string outputDataDir = Path.Combine(outputDir, DataDirName); + string outputDataDir = Path.Combine(outputDir, DetermineDataDirNameForProject()); if (Directory.Exists(outputDataDir)) Directory.Delete(outputDataDir, recursive: true); // Clean first @@ -304,333 +328,10 @@ namespace GodotTools.Export return outputDataDir; } - private void AotCompileDependencies(string[] features, string platform, bool isDebug, string outputDir, string outputDataDir, IDictionary<string, string> dependencies) - { - // TODO: WASM - - string bclDir = DeterminePlatformBclDir(platform) ?? typeof(object).Assembly.Location.GetBaseDir(); - - string aotTempDir = Path.Combine(Path.GetTempPath(), $"godot-aot-{Process.GetCurrentProcess().Id}"); - - if (!Directory.Exists(aotTempDir)) - Directory.CreateDirectory(aotTempDir); - - var assemblies = new Dictionary<string, string>(); - - foreach (var dependency in dependencies) - { - string assemblyName = dependency.Key; - string assemblyPath = dependency.Value; - - string assemblyPathInBcl = Path.Combine(bclDir, assemblyName + ".dll"); - - if (File.Exists(assemblyPathInBcl)) - { - // Don't create teporaries for assemblies from the BCL - assemblies.Add(assemblyName, assemblyPathInBcl); - } - else - { - string tempAssemblyPath = Path.Combine(aotTempDir, assemblyName + ".dll"); - File.Copy(assemblyPath, tempAssemblyPath); - assemblies.Add(assemblyName, tempAssemblyPath); - } - } - - foreach (var assembly in assemblies) - { - string assemblyName = assembly.Key; - string assemblyPath = assembly.Value; - - string sharedLibExtension = platform == OS.Platforms.Windows ? ".dll" : - platform == OS.Platforms.OSX ? ".dylib" : - platform == OS.Platforms.HTML5 ? ".wasm" : - ".so"; - - string outputFileName = assemblyName + ".dll" + sharedLibExtension; - - if (platform == OS.Platforms.Android) - { - // Not sure if the 'lib' prefix is an Android thing or just Godot being picky, - // but we use '-aot-' as well just in case to avoid conflicts with other libs. - outputFileName = "lib-aot-" + outputFileName; - } - - string outputFilePath = null; - string tempOutputFilePath; - - switch (platform) - { - case OS.Platforms.OSX: - tempOutputFilePath = Path.Combine(aotTempDir, outputFileName); - break; - case OS.Platforms.Android: - tempOutputFilePath = Path.Combine(aotTempDir, "%%ANDROID_ABI%%", outputFileName); - break; - case OS.Platforms.HTML5: - tempOutputFilePath = Path.Combine(aotTempDir, outputFileName); - outputFilePath = Path.Combine(outputDir, outputFileName); - break; - default: - tempOutputFilePath = Path.Combine(aotTempDir, outputFileName); - outputFilePath = Path.Combine(outputDataDir, "Mono", platform == OS.Platforms.Windows ? "bin" : "lib", outputFileName); - break; - } - - var data = new Dictionary<string, string>(); - var enabledAndroidAbis = platform == OS.Platforms.Android ? GetEnabledAndroidAbis(features).ToArray() : null; - - if (platform == OS.Platforms.Android) - { - Debug.Assert(enabledAndroidAbis != null); - - foreach (var abi in enabledAndroidAbis) - { - data["abi"] = abi; - var outputFilePathForThisAbi = tempOutputFilePath.Replace("%%ANDROID_ABI%%", abi); - - AotCompileAssembly(platform, isDebug, data, assemblyPath, outputFilePathForThisAbi); - - AddSharedObject(outputFilePathForThisAbi, tags: new[] { abi }); - } - } - else - { - string bits = features.Contains("64") ? "64" : features.Contains("64") ? "32" : null; - - if (bits != null) - data["bits"] = bits; - - AotCompileAssembly(platform, isDebug, data, assemblyPath, tempOutputFilePath); - - if (platform == OS.Platforms.OSX) - { - AddSharedObject(tempOutputFilePath, tags: null); - } - else - { - Debug.Assert(outputFilePath != null); - File.Copy(tempOutputFilePath, outputFilePath); - } - } - } - } - - private static void AotCompileAssembly(string platform, bool isDebug, Dictionary<string, string> data, string assemblyPath, string outputFilePath) - { - // Make sure the output directory exists - Directory.CreateDirectory(outputFilePath.GetBaseDir()); - - string exeExt = OS.IsWindows ? ".exe" : string.Empty; - - string monoCrossDirName = DetermineMonoCrossDirName(platform, data); - string monoCrossRoot = Path.Combine(GodotSharpDirs.DataEditorToolsDir, "aot-compilers", monoCrossDirName); - string monoCrossBin = Path.Combine(monoCrossRoot, "bin"); - - string toolPrefix = DetermineToolPrefix(monoCrossBin); - string monoExeName = System.IO.File.Exists(Path.Combine(monoCrossBin, $"{toolPrefix}mono{exeExt}")) ? "mono" : "mono-sgen"; - - string compilerCommand = Path.Combine(monoCrossBin, $"{toolPrefix}{monoExeName}{exeExt}"); - - bool fullAot = (bool)ProjectSettings.GetSetting("mono/export/aot/full_aot"); - - string EscapeOption(string option) => option.Contains(',') ? $"\"{option}\"" : option; - string OptionsToString(IEnumerable<string> options) => string.Join(",", options.Select(EscapeOption)); - - var aotOptions = new List<string>(); - var optimizerOptions = new List<string>(); - - if (fullAot) - aotOptions.Add("full"); - - aotOptions.Add(isDebug ? "soft-debug" : "nodebug"); - - if (platform == OS.Platforms.Android) - { - string abi = data["abi"]; - - string androidToolchain = (string)ProjectSettings.GetSetting("mono/export/aot/android_toolchain_path"); - - if (string.IsNullOrEmpty(androidToolchain)) - { - androidToolchain = Path.Combine(GodotSharpDirs.DataEditorToolsDir, "android-toolchains", $"{abi}"); // TODO: $"{abi}-{apiLevel}{(clang?"clang":"")}" - - if (!Directory.Exists(androidToolchain)) - throw new FileNotFoundException("Missing android toolchain. Specify one in the AOT export settings."); - } - else if (!Directory.Exists(androidToolchain)) - { - throw new FileNotFoundException("Android toolchain not found: " + androidToolchain); - } - - var androidToolPrefixes = new Dictionary<string, string> - { - ["armeabi-v7a"] = "arm-linux-androideabi-", - ["arm64-v8a"] = "aarch64-linux-android-", - ["x86"] = "i686-linux-android-", - ["x86_64"] = "x86_64-linux-android-" - }; - - aotOptions.Add("tool-prefix=" + Path.Combine(androidToolchain, "bin", androidToolPrefixes[abi])); - - string triple = GetAndroidTriple(abi); - aotOptions.Add($"mtriple={triple}"); - } - - aotOptions.Add($"outfile={outputFilePath}"); - - var extraAotOptions = (string[])ProjectSettings.GetSetting("mono/export/aot/extra_aot_options"); - var extraOptimizerOptions = (string[])ProjectSettings.GetSetting("mono/export/aot/extra_optimizer_options"); - - if (extraAotOptions.Length > 0) - aotOptions.AddRange(extraAotOptions); - - if (extraOptimizerOptions.Length > 0) - optimizerOptions.AddRange(extraOptimizerOptions); - - var compilerArgs = new List<string>(); - - if (isDebug) - compilerArgs.Add("--debug"); // Required for --aot=soft-debug - - compilerArgs.Add(aotOptions.Count > 0 ? $"--aot={OptionsToString(aotOptions)}" : "--aot"); - - if (optimizerOptions.Count > 0) - compilerArgs.Add($"-O={OptionsToString(optimizerOptions)}"); - - compilerArgs.Add(ProjectSettings.GlobalizePath(assemblyPath)); - - // TODO: Once we move to .NET Standard 2.1 we can use ProcessStartInfo.ArgumentList instead - string CmdLineArgsToString(IEnumerable<string> args) - { - // Not perfect, but as long as we are careful... - return string.Join(" ", args.Select(arg => arg.Contains(" ") ? $@"""{arg}""" : arg)); - } - - using (var process = new Process()) - { - process.StartInfo = new ProcessStartInfo(compilerCommand, CmdLineArgsToString(compilerArgs)) - { - UseShellExecute = false - }; - - string platformBclDir = DeterminePlatformBclDir(platform); - process.StartInfo.EnvironmentVariables.Add("MONO_PATH", string.IsNullOrEmpty(platformBclDir) ? - typeof(object).Assembly.Location.GetBaseDir() : - platformBclDir); - - Console.WriteLine($"Running: \"{process.StartInfo.FileName}\" {process.StartInfo.Arguments}"); - - if (!process.Start()) - throw new Exception("Failed to start process for Mono AOT compiler"); - - process.WaitForExit(); - - if (process.ExitCode != 0) - throw new Exception($"Mono AOT compiler exited with error code: {process.ExitCode}"); - - if (!System.IO.File.Exists(outputFilePath)) - throw new Exception("Mono AOT compiler finished successfully but the output file is missing"); - } - } - - private static string DetermineMonoCrossDirName(string platform, IReadOnlyDictionary<string, string> data) - { - switch (platform) - { - case OS.Platforms.Windows: - case OS.Platforms.UWP: - { - string arch = data["bits"] == "64" ? "x86_64" : "i686"; - return $"windows-{arch}"; - } - case OS.Platforms.OSX: - { - string arch = "x86_64"; - return $"{platform}-{arch}"; - } - case OS.Platforms.X11: - case OS.Platforms.Server: - { - string arch = data["bits"] == "64" ? "x86_64" : "i686"; - return $"linux-{arch}"; - } - case OS.Platforms.Haiku: - { - string arch = data["bits"] == "64" ? "x86_64" : "i686"; - return $"{platform}-{arch}"; - } - case OS.Platforms.Android: - { - string abi = data["abi"]; - return $"{platform}-{abi}"; - } - case OS.Platforms.HTML5: - return "wasm-wasm32"; - default: - throw new NotSupportedException($"Platform not supported: {platform}"); - } - } - - private static string DetermineToolPrefix(string monoCrossBin) - { - string exeExt = OS.IsWindows ? ".exe" : string.Empty; - - if (System.IO.File.Exists(Path.Combine(monoCrossBin, $"mono{exeExt}"))) - return string.Empty; - - if (System.IO.File.Exists(Path.Combine(monoCrossBin, $"mono-sgen{exeExt}" + exeExt))) - return string.Empty; - - var files = new DirectoryInfo(monoCrossBin).GetFiles($"*mono{exeExt}" + exeExt, SearchOption.TopDirectoryOnly); - if (files.Length > 0) - { - string fileName = files[0].Name; - return fileName.Substring(0, fileName.Length - $"mono{exeExt}".Length); - } - - files = new DirectoryInfo(monoCrossBin).GetFiles($"*mono-sgen{exeExt}" + exeExt, SearchOption.TopDirectoryOnly); - if (files.Length > 0) - { - string fileName = files[0].Name; - return fileName.Substring(0, fileName.Length - $"mono-sgen{exeExt}".Length); - } - - throw new FileNotFoundException($"Cannot find the mono runtime executable in {monoCrossBin}"); - } - - private static IEnumerable<string> GetEnabledAndroidAbis(string[] features) - { - var androidAbis = new[] - { - "armeabi-v7a", - "arm64-v8a", - "x86", - "x86_64" - }; - - return androidAbis.Where(features.Contains); - } - - private static string GetAndroidTriple(string abi) - { - var abiArchs = new Dictionary<string, string> - { - ["armeabi-v7a"] = "armv7", - ["arm64-v8a"] = "aarch64-v8a", - ["x86"] = "i686", - ["x86_64"] = "x86_64" - }; - - string arch = abiArchs[abi]; - - return $"{arch}-linux-android"; - } - private static bool PlatformHasTemplateDir(string platform) { // OSX export templates are contained in a zip, so we place our custom template inside it and let Godot do the rest. - return !new[] { OS.Platforms.OSX, OS.Platforms.Android, OS.Platforms.HTML5 }.Contains(platform); + return !new[] { OS.Platforms.OSX, OS.Platforms.Android, OS.Platforms.iOS, OS.Platforms.HTML5 }.Contains(platform); } private static string DeterminePlatformFromFeatures(IEnumerable<string> features) @@ -665,7 +366,7 @@ namespace GodotTools.Export if (PlatformRequiresCustomBcl(platform)) throw new FileNotFoundException($"Missing BCL (Base Class Library) for platform: {platform}"); - platformBclDir = null; // Use the one we're running on + platformBclDir = typeof(object).Assembly.Location; // Use the one we're running on } } @@ -678,7 +379,7 @@ namespace GodotTools.Export /// </summary> private static bool PlatformRequiresCustomBcl(string platform) { - if (new[] { OS.Platforms.Android, OS.Platforms.HTML5 }.Contains(platform)) + if (new[] { OS.Platforms.Android, OS.Platforms.iOS, OS.Platforms.HTML5 }.Contains(platform)) return true; // The 'net_4_x' BCL is not compatible between Windows and the other platforms. @@ -707,6 +408,8 @@ namespace GodotTools.Export return "net_4_x"; case OS.Platforms.Android: return "monodroid"; + case OS.Platforms.iOS: + return "monotouch"; case OS.Platforms.HTML5: return "wasm"; default: @@ -714,14 +417,11 @@ namespace GodotTools.Export } } - private static string DataDirName + private static string DetermineDataDirNameForProject() { - get - { - var appName = (string)ProjectSettings.GetSetting("application/config/name"); - string appNameSafe = appName.ToSafeDirName(allowDirSeparator: false); - return $"data_{appNameSafe}"; - } + var appName = (string)ProjectSettings.GetSetting("application/config/name"); + string appNameSafe = appName.ToSafeDirName(allowDirSeparator: false); + return $"data_{appNameSafe}"; } [MethodImpl(MethodImplOptions.InternalCall)] diff --git a/modules/mono/editor/GodotTools/GodotTools/Export/XcodeHelper.cs b/modules/mono/editor/GodotTools/GodotTools/Export/XcodeHelper.cs new file mode 100755 index 0000000000..219b7a698a --- /dev/null +++ b/modules/mono/editor/GodotTools/GodotTools/Export/XcodeHelper.cs @@ -0,0 +1,93 @@ +using System; +using System.IO; + +namespace GodotTools.Export +{ + public static class XcodeHelper + { + private static string _XcodePath = null; + + public static string XcodePath + { + get + { + if (_XcodePath == null) + { + _XcodePath = FindXcode(); + + if (_XcodePath == null) + throw new Exception("Could not find Xcode"); + } + + return _XcodePath; + } + } + + private static string FindSelectedXcode() + { + var outputWrapper = new Godot.Collections.Array(); + + int exitCode = Godot.OS.Execute("xcode-select", new string[] { "--print-path" }, blocking: true, output: outputWrapper); + + if (exitCode == 0) + { + string output = (string)outputWrapper[0]; + return output.Trim(); + } + + Console.Error.WriteLine($"'xcode-select --print-path' exited with code: {exitCode}"); + + return null; + } + + public static string FindXcode() + { + string selectedXcode = FindSelectedXcode(); + if (selectedXcode != null) + { + if (Directory.Exists(Path.Combine(selectedXcode, "Contents", "Developer"))) + return selectedXcode; + + // The path already pointed to Contents/Developer + var dirInfo = new DirectoryInfo(selectedXcode); + if (dirInfo.Name != "Developer" || dirInfo.Parent.Name != "Contents") + { + Console.WriteLine(Path.GetDirectoryName(selectedXcode)); + Console.WriteLine(System.IO.Directory.GetParent(selectedXcode).Name); + Console.Error.WriteLine("Unrecognized path for selected Xcode"); + } + else + { + return System.IO.Path.GetFullPath($"{selectedXcode}/../.."); + } + } + else + { + Console.Error.WriteLine("Could not find the selected Xcode; trying with a hint path"); + } + + const string XcodeHintPath = "/Applications/Xcode.app"; + + if (Directory.Exists(XcodeHintPath)) + { + if (Directory.Exists(Path.Combine(XcodeHintPath, "Contents", "Developer"))) + return XcodeHintPath; + + Console.Error.WriteLine($"Found Xcode at '{XcodeHintPath}' but it's missing the 'Contents/Developer' sub-directory"); + } + + return null; + } + + public static string FindXcodeTool(string toolName) + { + string XcodeDefaultToolchain = Path.Combine(XcodePath, "Contents", "Developer", "Toolchains", "XcodeDefault.xctoolchain"); + + string path = Path.Combine(XcodeDefaultToolchain, "usr", "bin", toolName); + if (File.Exists(path)) + return path; + + throw new FileNotFoundException($"Cannot find Xcode tool: {toolName}"); + } + } +} diff --git a/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs b/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs index e6d5dd9895..afe7670165 100644 --- a/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs +++ b/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs @@ -36,6 +36,17 @@ namespace GodotTools public BottomPanel BottomPanel { get; private set; } + public static string ProjectAssemblyName + { + get + { + var projectAssemblyName = (string)ProjectSettings.GetSetting("application/config/name"); + if (string.IsNullOrEmpty(projectAssemblyName)) + projectAssemblyName = "UnnamedProject"; + return projectAssemblyName; + } + } + private bool CreateProjectSolution() { using (var pr = new EditorProgress("create_csharp_solution", "Generating solution...".TTR(), 3)) @@ -45,9 +56,7 @@ namespace GodotTools string resourceDir = ProjectSettings.GlobalizePath("res://"); string path = resourceDir; - string name = (string)ProjectSettings.GetSetting("application/config/name"); - if (name.Empty()) - name = "UnnamedProject"; + string name = ProjectAssemblyName; string guid = CsProjOperations.GenerateGameProject(path, name); diff --git a/modules/mono/editor/GodotTools/GodotTools/GodotTools.csproj b/modules/mono/editor/GodotTools/GodotTools/GodotTools.csproj index 379dfd9f7d..ac9379adf8 100644 --- a/modules/mono/editor/GodotTools/GodotTools/GodotTools.csproj +++ b/modules/mono/editor/GodotTools/GodotTools/GodotTools.csproj @@ -51,7 +51,9 @@ </ItemGroup> <ItemGroup> <Compile Include="Build\MsBuildFinder.cs" /> + <Compile Include="Export\AotBuilder.cs" /> <Compile Include="Export\ExportPlugin.cs" /> + <Compile Include="Export\XcodeHelper.cs" /> <Compile Include="ExternalEditorId.cs" /> <Compile Include="Ides\GodotIdeManager.cs" /> <Compile Include="Ides\GodotIdeServer.cs" /> diff --git a/modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs b/modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs index 11a4109d97..b057ac12c6 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs @@ -5,6 +5,7 @@ using System.Diagnostics.CodeAnalysis; using System.IO; using System.Linq; using System.Runtime.CompilerServices; +using JetBrains.Annotations; namespace GodotTools.Utils { @@ -26,6 +27,7 @@ namespace GodotTools.Utils public const string UWP = "UWP"; public const string Haiku = "Haiku"; public const string Android = "Android"; + public const string iOS = "iOS"; public const string HTML5 = "HTML5"; } @@ -38,6 +40,7 @@ namespace GodotTools.Utils public const string UWP = "uwp"; public const string Haiku = "haiku"; public const string Android = "android"; + public const string iOS = "iphone"; public const string HTML5 = "javascript"; } @@ -50,6 +53,7 @@ namespace GodotTools.Utils [Names.UWP] = Platforms.UWP, [Names.Haiku] = Platforms.Haiku, [Names.Android] = Platforms.Android, + [Names.iOS] = Platforms.iOS, [Names.HTML5] = Platforms.HTML5 }; @@ -65,6 +69,7 @@ namespace GodotTools.Utils private static readonly Lazy<bool> _isUWP = new Lazy<bool>(() => IsOS(Names.UWP)); private static readonly Lazy<bool> _isHaiku = new Lazy<bool>(() => IsOS(Names.Haiku)); private static readonly Lazy<bool> _isAndroid = new Lazy<bool>(() => IsOS(Names.Android)); + private static readonly Lazy<bool> _isiOS = new Lazy<bool>(() => IsOS(Names.iOS)); private static readonly Lazy<bool> _isHTML5 = new Lazy<bool>(() => IsOS(Names.HTML5)); public static bool IsWindows => _isWindows.Value || IsUWP; @@ -74,10 +79,11 @@ namespace GodotTools.Utils public static bool IsUWP => _isUWP.Value; public static bool IsHaiku => _isHaiku.Value; public static bool IsAndroid => _isAndroid.Value; + public static bool IsiOS => _isiOS.Value; public static bool IsHTML5 => _isHTML5.Value; private static bool? _isUnixCache; - private static readonly string[] UnixLikePlatforms = { Names.OSX, Names.X11, Names.Server, Names.Haiku, Names.Android }; + private static readonly string[] UnixLikePlatforms = { Names.OSX, Names.X11, Names.Server, Names.Haiku, Names.Android, Names.iOS }; public static bool IsUnixLike() { @@ -91,12 +97,12 @@ namespace GodotTools.Utils public static char PathSep => IsWindows ? ';' : ':'; - public static string PathWhich(string name) + public static string PathWhich([NotNull] string name) { return IsWindows ? PathWhichWindows(name) : PathWhichUnix(name); } - private static string PathWhichWindows(string name) + private static string PathWhichWindows([NotNull] string name) { string[] windowsExts = Environment.GetEnvironmentVariable("PATHEXT")?.Split(PathSep) ?? new string[] { }; string[] pathDirs = Environment.GetEnvironmentVariable("PATH")?.Split(PathSep); @@ -121,7 +127,7 @@ namespace GodotTools.Utils select path + ext).FirstOrDefault(File.Exists); } - private static string PathWhichUnix(string name) + private static string PathWhichUnix([NotNull] string name) { string[] pathDirs = Environment.GetEnvironmentVariable("PATH")?.Split(PathSep); @@ -163,5 +169,33 @@ namespace GodotTools.Utils User32Dll.AllowSetForegroundWindow(process.Id); // allows application to focus itself } } + + public static int ExecuteCommand(string command, IEnumerable<string> arguments) + { + // TODO: Once we move to .NET Standard 2.1 we can use ProcessStartInfo.ArgumentList instead + string CmdLineArgsToString(IEnumerable<string> args) + { + // Not perfect, but as long as we are careful... + return string.Join(" ", args.Select(arg => arg.Contains(" ") ? $@"""{arg}""" : arg)); + } + + var startInfo = new ProcessStartInfo(command, CmdLineArgsToString(arguments)); + + Console.WriteLine($"Executing: \"{startInfo.FileName}\" {startInfo.Arguments}"); + + // Print the output + startInfo.RedirectStandardOutput = false; + startInfo.RedirectStandardError = false; + + startInfo.UseShellExecute = false; + + using (var process = new Process { StartInfo = startInfo }) + { + process.Start(); + process.WaitForExit(); + + return process.ExitCode; + } + } } } diff --git a/modules/mono/editor/godotsharp_export.cpp b/modules/mono/editor/godotsharp_export.cpp index ce0b6ad0e6..19b3bea5cf 100644 --- a/modules/mono/editor/godotsharp_export.cpp +++ b/modules/mono/editor/godotsharp_export.cpp @@ -92,7 +92,8 @@ Error get_assembly_dependencies(GDMonoAssembly *p_assembly, const Vector<String> ERR_FAIL_COND_V_MSG(!ref_assembly, ERR_CANT_RESOLVE, "Cannot load assembly (refonly): '" + ref_name + "'."); - r_dependencies[ref_name] = ref_assembly->get_path(); + // Use the path we got from the search. Don't try to get the path from the loaded assembly as we can't trust it will be from the selected BCL dir. + r_dependencies[ref_name] = path; Error err = get_assembly_dependencies(ref_assembly, p_search_dirs, r_dependencies); ERR_FAIL_COND_V_MSG(err != OK, err, "Cannot load one of the dependencies for the assembly: '" + ref_name + "'."); diff --git a/modules/mono/godotsharp_dirs.cpp b/modules/mono/godotsharp_dirs.cpp index 828ab73c82..fe8b925257 100644 --- a/modules/mono/godotsharp_dirs.cpp +++ b/modules/mono/godotsharp_dirs.cpp @@ -40,7 +40,7 @@ #endif #ifdef ANDROID_ENABLED -#include "mono_gd/gd_mono_android.h" +#include "mono_gd/support/mono-support.h" #endif #include "mono_gd/gd_mono.h" @@ -169,7 +169,7 @@ private: data_mono_etc_dir = data_mono_root_dir.plus_file("etc"); #ifdef ANDROID_ENABLED - data_mono_lib_dir = GDMonoAndroid::get_app_native_lib_dir(); + data_mono_lib_dir = gdmono::android::support::get_app_native_lib_dir(); #else data_mono_lib_dir = data_mono_root_dir.plus_file("lib"); #endif @@ -206,7 +206,7 @@ private: data_mono_etc_dir = data_mono_root_dir.plus_file("etc"); #ifdef ANDROID_ENABLED - data_mono_lib_dir = GDMonoAndroid::get_app_native_lib_dir(); + data_mono_lib_dir = gdmono::android::support::get_app_native_lib_dir(); #else data_mono_lib_dir = data_mono_root_dir.plus_file("lib"); data_game_assemblies_dir = data_dir_root.plus_file("Assemblies"); diff --git a/modules/mono/mono_gd/gd_mono.cpp b/modules/mono/mono_gd/gd_mono.cpp index eb4c263745..3390aaae88 100644 --- a/modules/mono/mono_gd/gd_mono.cpp +++ b/modules/mono/mono_gd/gd_mono.cpp @@ -58,7 +58,18 @@ #ifdef ANDROID_ENABLED #include "android_mono_config.h" -#include "gd_mono_android.h" +#include "support/android_support.h" +#elif defined(IPHONE_ENABLED) +#include "support/ios_support.h" +#endif + +#if defined(TOOL_ENABLED) && defined(GD_MONO_SINGLE_APPDOMAIN) +// This will no longer be the case if we replace appdomains with AssemblyLoadContext +#error "Editor build requires support for multiple appdomains" +#endif + +#if defined(GD_MONO_HOT_RELOAD) && defined(GD_MONO_SINGLE_APPDOMAIN) +#error "Hot reloading requires multiple appdomains" #endif // TODO: @@ -178,7 +189,14 @@ MonoDomain *gd_initialize_mono_runtime() { gd_mono_debug_init(); #endif - return mono_jit_init_version("GodotEngine.RootDomain", "v4.0.30319"); +#if defined(IPHONE_ENABLED) || defined(ANDROID_ENABLED) + // I don't know whether this actually matters or not + const char *runtime_version = "mobile"; +#else + const char *runtime_version = "v4.0.30319"; +#endif + + return mono_jit_init_version("GodotEngine.RootDomain", runtime_version); } #endif @@ -320,8 +338,16 @@ void GDMono::initialize() { add_mono_shared_libs_dir_to_path(); #endif +#ifdef ANDROID_ENABLED + mono_config_parse_memory(get_godot_android_mono_config().utf8().get_data()); +#else + mono_config_parse(NULL); +#endif + #if defined(ANDROID_ENABLED) - GDMonoAndroid::initialize(); + gdmono::android::support::initialize(); +#elif defined(IPHONE_ENABLED) + gdmono::ios::support::initialize(); #endif GDMonoAssembly::initialize(); @@ -330,12 +356,6 @@ void GDMono::initialize() { gd_mono_profiler_init(); #endif -#ifdef ANDROID_ENABLED - mono_config_parse_memory(get_godot_android_mono_config().utf8().get_data()); -#else - mono_config_parse(NULL); -#endif - mono_install_unhandled_exception_hook(&unhandled_exception_hook, NULL); #ifndef TOOLS_ENABLED @@ -371,15 +391,19 @@ void GDMono::initialize() { print_verbose("Mono: Runtime initialized"); #if defined(ANDROID_ENABLED) - GDMonoAndroid::register_internal_calls(); + gdmono::android::support::register_internal_calls(); #endif // mscorlib assembly MUST be present at initialization bool corlib_loaded = _load_corlib_assembly(); ERR_FAIL_COND_MSG(!corlib_loaded, "Mono: Failed to load mscorlib assembly."); +#ifndef GD_MONO_SINGLE_APPDOMAIN Error domain_load_err = _load_scripts_domain(); ERR_FAIL_COND_MSG(domain_load_err != OK, "Mono: Failed to load scripts domain."); +#else + scripts_domain = root_domain; +#endif _register_internal_calls(); @@ -491,11 +515,15 @@ void GDMono::add_assembly(uint32_t p_domain_id, GDMonoAssembly *p_assembly) { assemblies[p_domain_id][p_assembly->get_name()] = p_assembly; } -GDMonoAssembly **GDMono::get_loaded_assembly(const String &p_name) { +GDMonoAssembly *GDMono::get_loaded_assembly(const String &p_name) { + + if (p_name == "mscorlib") + return get_corlib_assembly(); MonoDomain *domain = mono_domain_get(); uint32_t domain_id = domain ? mono_domain_get_id(domain) : 0; - return assemblies[domain_id].getptr(p_name); + GDMonoAssembly **result = assemblies[domain_id].getptr(p_name); + return result ? *result : NULL; } bool GDMono::load_assembly(const String &p_name, GDMonoAssembly **r_assembly, bool p_refonly) { @@ -549,14 +577,6 @@ bool GDMono::load_assembly_from(const String &p_name, const String &p_path, GDMo if (!assembly) return false; -#ifdef DEBUG_ENABLED - uint32_t domain_id = mono_domain_get_id(mono_domain_get()); - GDMonoAssembly **stored_assembly = assemblies[domain_id].getptr(p_name); - - ERR_FAIL_COND_V(stored_assembly == NULL, false); - ERR_FAIL_COND_V(*stored_assembly != assembly, false); -#endif - *r_assembly = assembly; print_verbose("Mono: Assembly " + p_name + (p_refonly ? " (refonly)" : "") + " loaded from path: " + (*r_assembly)->get_path()); @@ -894,8 +914,8 @@ void GDMono::_load_api_assemblies() { bool api_assemblies_loaded = _try_load_api_assemblies_preset(); +#if defined(TOOLS_ENABLED) && !defined(GD_MONO_SINGLE_APPDOMAIN) if (!api_assemblies_loaded) { -#ifdef TOOLS_ENABLED // The API assemblies are out of sync or some other error happened. Fine, try one more time, but // this time update them from the prebuilt assemblies directory before trying to load them again. @@ -916,8 +936,8 @@ void GDMono::_load_api_assemblies() { // 4. Try loading the updated assemblies api_assemblies_loaded = _try_load_api_assemblies_preset(); -#endif } +#endif if (!api_assemblies_loaded) { // welp... too bad @@ -991,6 +1011,7 @@ void GDMono::_install_trace_listener() { #endif } +#ifndef GD_MONO_SINGLE_APPDOMAIN Error GDMono::_load_scripts_domain() { ERR_FAIL_COND_V(scripts_domain != NULL, ERR_BUG); @@ -1010,7 +1031,7 @@ Error GDMono::_unload_scripts_domain() { ERR_FAIL_NULL_V(scripts_domain, ERR_BUG); - print_verbose("Mono: Unloading scripts domain..."); + print_verbose("Mono: Finalizing scripts domain..."); if (mono_domain_get() != root_domain) mono_domain_set(root_domain, true); @@ -1043,6 +1064,8 @@ Error GDMono::_unload_scripts_domain() { MonoDomain *domain = scripts_domain; scripts_domain = NULL; + print_verbose("Mono: Unloading scripts domain..."); + MonoException *exc = NULL; mono_domain_try_unload(domain, (MonoObject **)&exc); @@ -1054,6 +1077,7 @@ Error GDMono::_unload_scripts_domain() { return OK; } +#endif #ifdef GD_MONO_HOT_RELOAD Error GDMono::reload_scripts_domain() { @@ -1092,6 +1116,7 @@ Error GDMono::reload_scripts_domain() { } #endif +#ifndef GD_MONO_SINGLE_APPDOMAIN Error GDMono::finalize_and_unload_domain(MonoDomain *p_domain) { CRASH_COND(p_domain == NULL); @@ -1123,6 +1148,7 @@ Error GDMono::finalize_and_unload_domain(MonoDomain *p_domain) { return OK; } +#endif GDMonoClass *GDMono::get_class(MonoClass *p_raw_class) { @@ -1150,13 +1176,17 @@ GDMonoClass *GDMono::get_class(MonoClass *p_raw_class) { GDMonoClass *GDMono::get_class(const StringName &p_namespace, const StringName &p_name) { + GDMonoClass *klass = corlib_assembly->get_class(p_namespace, p_name); + if (klass) + return klass; + uint32_t domain_id = mono_domain_get_id(mono_domain_get()); HashMap<String, GDMonoAssembly *> &domain_assemblies = assemblies[domain_id]; const String *k = NULL; while ((k = domain_assemblies.next(k))) { GDMonoAssembly *assembly = domain_assemblies.get(*k); - GDMonoClass *klass = assembly->get_class(p_namespace, p_name); + klass = assembly->get_class(p_namespace, p_name); if (klass) return klass; } @@ -1223,12 +1253,44 @@ GDMono::GDMono() { GDMono::~GDMono() { if (is_runtime_initialized()) { +#ifndef GD_MONO_SINGLE_APPDOMAIN if (scripts_domain) { Error err = _unload_scripts_domain(); if (err != OK) { ERR_PRINT("Mono: Failed to unload scripts domain."); } } +#else + CRASH_COND(scripts_domain != root_domain); + + print_verbose("Mono: Finalizing scripts domain..."); + + if (mono_domain_get() != root_domain) + mono_domain_set(root_domain, true); + + finalizing_scripts_domain = true; + + if (!mono_domain_finalize(root_domain, 2000)) { + ERR_PRINT("Mono: Domain finalization timeout."); + } + + finalizing_scripts_domain = false; + + mono_gc_collect(mono_gc_max_generation()); + + GDMonoCache::clear_godot_api_cache(); + + _domain_assemblies_cleanup(mono_domain_get_id(root_domain)); + + core_api_assembly.assembly = NULL; + + project_assembly = NULL; + + root_domain = NULL; + scripts_domain = NULL; + + // Leave the rest to 'mono_jit_cleanup' +#endif const uint32_t *k = NULL; while ((k = assemblies.next(k))) { @@ -1245,15 +1307,15 @@ GDMono::~GDMono() { mono_jit_cleanup(root_domain); -#if defined(ANDROID_ENABLED) - GDMonoAndroid::cleanup(); -#endif - print_verbose("Mono: Finalized"); runtime_initialized = false; } +#if defined(ANDROID_ENABLED) + gdmono::android::support::cleanup(); +#endif + if (gdmono_log) memdelete(gdmono_log); diff --git a/modules/mono/mono_gd/gd_mono.h b/modules/mono/mono_gd/gd_mono.h index 9528c64f8d..f7c2426734 100644 --- a/modules/mono/mono_gd/gd_mono.h +++ b/modules/mono/mono_gd/gd_mono.h @@ -144,8 +144,10 @@ private: void _register_internal_calls(); +#ifndef GD_MONO_SINGLE_APPDOMAIN Error _load_scripts_domain(); Error _unload_scripts_domain(); +#endif void _domain_assemblies_cleanup(uint32_t p_domain_id); @@ -209,7 +211,7 @@ public: // Do not use these, unless you know what you're doing void add_assembly(uint32_t p_domain_id, GDMonoAssembly *p_assembly); - GDMonoAssembly **get_loaded_assembly(const String &p_name); + GDMonoAssembly *get_loaded_assembly(const String &p_name); _FORCE_INLINE_ bool is_runtime_initialized() const { return runtime_initialized && !mono_runtime_is_shutting_down() /* stays true after shutdown finished */; } diff --git a/modules/mono/mono_gd/gd_mono_assembly.cpp b/modules/mono/mono_gd/gd_mono_assembly.cpp index 6da1db249c..a6a44fe8eb 100644 --- a/modules/mono/mono_gd/gd_mono_assembly.cpp +++ b/modules/mono/mono_gd/gd_mono_assembly.cpp @@ -42,9 +42,6 @@ #include "gd_mono_cache.h" #include "gd_mono_class.h" -bool GDMonoAssembly::no_search = false; -bool GDMonoAssembly::in_preload = false; - Vector<String> GDMonoAssembly::search_dirs; void GDMonoAssembly::fill_search_dirs(Vector<String> &r_search_dirs, const String &p_custom_config, const String &p_custom_bcl_dir) { @@ -94,19 +91,30 @@ void GDMonoAssembly::fill_search_dirs(Vector<String> &r_search_dirs, const Strin #endif } +// This is how these assembly loading hooks work: +// +// - The 'search' hook checks if the assembly has already been loaded, to avoid loading again. +// - The 'preload' hook does the actual loading and is only called if the +// 'search' hook didn't find the assembly in the list of loaded assemblies. +// - The 'load' hook is called after the assembly has been loaded. Its job is to add the +// assembly to the list of loaded assemblies so that the 'search' hook can look it up. + void GDMonoAssembly::assembly_load_hook(MonoAssembly *assembly, void *user_data) { - if (no_search) - return; - - // If our search and preload hooks fail to load the assembly themselves, the mono runtime still might. - // Just do Assembly.LoadFrom("/Full/Path/On/Disk.dll"); - // In this case, we wouldn't have the assembly known in GDMono, which causes crashes - // if any class inside the assembly is looked up by Godot. - // And causing a lookup like that is as easy as throwing an exception defined in it... - // No, we can't make the assembly load hooks smart enough because they get passed a MonoAssemblyName* only, - // not the disk path passed to say Assembly.LoadFrom(). - _wrap_mono_assembly(assembly); + String name = String::utf8(mono_assembly_name_get_name(mono_assembly_get_name(assembly))); + + MonoImage *image = mono_assembly_get_image(assembly); + + GDMonoAssembly *gdassembly = memnew(GDMonoAssembly(name, image, assembly)); + +#ifdef GD_MONO_HOT_RELOAD + const char *path = mono_image_get_filename(image); + if (FileAccess::exists(path)) + gdassembly->modified_time = FileAccess::get_modified_time(path); +#endif + + MonoDomain *domain = mono_domain_get(); + GDMono::get_singleton()->add_assembly(domain ? mono_domain_get_id(domain) : 0, gdassembly); } MonoAssembly *GDMonoAssembly::assembly_search_hook(MonoAssemblyName *aname, void *user_data) { @@ -132,71 +140,24 @@ MonoAssembly *GDMonoAssembly::_search_hook(MonoAssemblyName *aname, void *user_d String name = String::utf8(mono_assembly_name_get_name(aname)); bool has_extension = name.ends_with(".dll") || name.ends_with(".exe"); - if (no_search) - return NULL; - - GDMonoAssembly **loaded_asm = GDMono::get_singleton()->get_loaded_assembly(has_extension ? name.get_basename() : name); + GDMonoAssembly *loaded_asm = GDMono::get_singleton()->get_loaded_assembly(has_extension ? name.get_basename() : name); if (loaded_asm) - return (*loaded_asm)->get_assembly(); - - no_search = true; // Avoid the recursion madness - - GDMonoAssembly *res = _load_assembly_search(name, search_dirs, refonly); + return loaded_asm->get_assembly(); - no_search = false; - - return res ? res->get_assembly() : NULL; + return NULL; } -static thread_local MonoImage *image_corlib_loading = NULL; - MonoAssembly *GDMonoAssembly::_preload_hook(MonoAssemblyName *aname, char **, void *user_data, bool refonly) { (void)user_data; // UNUSED - { - // If we find the assembly here, we load it with 'mono_assembly_load_from_full', - // which in turn invokes load hooks before returning the MonoAssembly to us. - // One of the load hooks is 'load_aot_module'. This hook can end up calling preload hooks - // again for the same assembly in certain in certain circumstances (the 'do_load_image' part). - // If this is the case and we return NULL due to the no_search condition below, - // it will result in an internal crash later on. Therefore we need to return the assembly we didn't - // get yet from 'mono_assembly_load_from_full'. Luckily we have the image, which already got it. - // This must be done here. If done in search hooks, it would cause 'mono_assembly_load_from_full' - // to think another MonoAssembly for this assembly was already loaded, making it delete its own, - // when in fact both pointers were the same... This hooks thing is confusing. - if (image_corlib_loading) { - return mono_image_get_assembly(image_corlib_loading); - } - } - - if (no_search) - return NULL; - - no_search = true; - in_preload = true; - String name = String::utf8(mono_assembly_name_get_name(aname)); - bool has_extension = name.ends_with(".dll"); - - GDMonoAssembly *res = NULL; - if (has_extension ? name == "mscorlib.dll" : name == "mscorlib") { - GDMonoAssembly **stored_assembly = GDMono::get_singleton()->get_loaded_assembly(has_extension ? name.get_basename() : name); - if (stored_assembly) - return (*stored_assembly)->get_assembly(); - - res = _load_assembly_search("mscorlib.dll", search_dirs, refonly); - } - - no_search = false; - in_preload = false; - - return res ? res->get_assembly() : NULL; + return _load_assembly_search(name, search_dirs, refonly); } -GDMonoAssembly *GDMonoAssembly::_load_assembly_search(const String &p_name, const Vector<String> &p_search_dirs, bool p_refonly) { +MonoAssembly *GDMonoAssembly::_load_assembly_search(const String &p_name, const Vector<String> &p_search_dirs, bool p_refonly) { - GDMonoAssembly *res = NULL; + MonoAssembly *res = NULL; String path; bool has_extension = p_name.ends_with(".dll") || p_name.ends_with(".exe"); @@ -207,21 +168,21 @@ GDMonoAssembly *GDMonoAssembly::_load_assembly_search(const String &p_name, cons if (has_extension) { path = search_dir.plus_file(p_name); if (FileAccess::exists(path)) { - res = _load_assembly_from(p_name.get_basename(), path, p_refonly); + res = _real_load_assembly_from(path, p_refonly); if (res != NULL) return res; } } else { path = search_dir.plus_file(p_name + ".dll"); if (FileAccess::exists(path)) { - res = _load_assembly_from(p_name, path, p_refonly); + res = _real_load_assembly_from(path, p_refonly); if (res != NULL) return res; } path = search_dir.plus_file(p_name + ".exe"); if (FileAccess::exists(path)) { - res = _load_assembly_from(p_name, path, p_refonly); + res = _real_load_assembly_from(path, p_refonly); if (res != NULL) return res; } @@ -258,40 +219,6 @@ String GDMonoAssembly::find_assembly(const String &p_name) { return String(); } -GDMonoAssembly *GDMonoAssembly::_load_assembly_from(const String &p_name, const String &p_path, bool p_refonly) { - - GDMonoAssembly *assembly = memnew(GDMonoAssembly(p_name, p_path)); - - Error err = assembly->load(p_refonly); - - if (err != OK) { - memdelete(assembly); - ERR_FAIL_V(NULL); - } - - MonoDomain *domain = mono_domain_get(); - GDMono::get_singleton()->add_assembly(domain ? mono_domain_get_id(domain) : 0, assembly); - - return assembly; -} - -void GDMonoAssembly::_wrap_mono_assembly(MonoAssembly *assembly) { - String name = String::utf8(mono_assembly_name_get_name(mono_assembly_get_name(assembly))); - - MonoImage *image = mono_assembly_get_image(assembly); - - GDMonoAssembly *gdassembly = memnew(GDMonoAssembly(name, mono_image_get_filename(image))); - Error err = gdassembly->wrapper_for_image(image); - - if (err != OK) { - memdelete(gdassembly); - ERR_FAIL(); - } - - MonoDomain *domain = mono_domain_get(); - GDMono::get_singleton()->add_assembly(domain ? mono_domain_get_id(domain) : 0, gdassembly); -} - void GDMonoAssembly::initialize() { fill_search_dirs(search_dirs); @@ -303,46 +230,39 @@ void GDMonoAssembly::initialize() { mono_install_assembly_load_hook(&assembly_load_hook, NULL); } -Error GDMonoAssembly::load(bool p_refonly) { - - ERR_FAIL_COND_V(loaded, ERR_FILE_ALREADY_IN_USE); - - refonly = p_refonly; +MonoAssembly *GDMonoAssembly::_real_load_assembly_from(const String &p_path, bool p_refonly) { - uint64_t last_modified_time = FileAccess::get_modified_time(path); - - Vector<uint8_t> data = FileAccess::get_file_as_array(path); - ERR_FAIL_COND_V(data.empty(), ERR_FILE_CANT_READ); + Vector<uint8_t> data = FileAccess::get_file_as_array(p_path); + ERR_FAIL_COND_V_MSG(data.empty(), NULL, "Could read the assembly in the specified location"); String image_filename; #ifdef ANDROID_ENABLED - if (path.begins_with("res://")) { - image_filename = path.substr(6, path.length()); + if (p_path.begins_with("res://")) { + image_filename = p_path.substr(6, p_path.length()); } else { - image_filename = ProjectSettings::get_singleton()->globalize_path(path); + image_filename = ProjectSettings::get_singleton()->globalize_path(p_path); } #else // FIXME: globalize_path does not work on exported games - image_filename = ProjectSettings::get_singleton()->globalize_path(path); + image_filename = ProjectSettings::get_singleton()->globalize_path(p_path); #endif MonoImageOpenStatus status = MONO_IMAGE_OK; - image = mono_image_open_from_data_with_name( + MonoImage *image = mono_image_open_from_data_with_name( (char *)&data[0], data.size(), - true, &status, refonly, - image_filename.utf8().get_data()); + true, &status, p_refonly, + image_filename.utf8()); - ERR_FAIL_COND_V(status != MONO_IMAGE_OK, ERR_FILE_CANT_OPEN); - ERR_FAIL_NULL_V(image, ERR_FILE_CANT_OPEN); + ERR_FAIL_COND_V_MSG(status != MONO_IMAGE_OK || !image, NULL, "Failed to open assembly image from the loaded data"); #ifdef DEBUG_ENABLED Vector<uint8_t> pdb_data; - String pdb_path(path + ".pdb"); + String pdb_path(p_path + ".pdb"); if (!FileAccess::exists(pdb_path)) { - pdb_path = path.get_basename() + ".pdb"; // without .dll + pdb_path = p_path.get_basename() + ".pdb"; // without .dll if (!FileAccess::exists(pdb_path)) goto no_pdb; @@ -357,44 +277,21 @@ no_pdb: #endif - bool is_corlib_preload = in_preload && name == "mscorlib"; - - if (is_corlib_preload) - image_corlib_loading = image; + status = MONO_IMAGE_OK; - assembly = mono_assembly_load_from_full(image, image_filename.utf8().get_data(), &status, refonly); + MonoAssembly *assembly = mono_assembly_load_from_full(image, image_filename.utf8().get_data(), &status, p_refonly); - if (is_corlib_preload) - image_corlib_loading = NULL; - - ERR_FAIL_COND_V(status != MONO_IMAGE_OK || assembly == NULL, ERR_FILE_CANT_OPEN); + ERR_FAIL_COND_V_MSG(status != MONO_IMAGE_OK || !assembly, NULL, "Failed to load assembly for image"); // Decrement refcount which was previously incremented by mono_image_open_from_data_with_name mono_image_close(image); - loaded = true; - modified_time = last_modified_time; - - return OK; -} - -Error GDMonoAssembly::wrapper_for_image(MonoImage *p_image) { - - ERR_FAIL_COND_V(loaded, ERR_FILE_ALREADY_IN_USE); - - assembly = mono_image_get_assembly(p_image); - ERR_FAIL_NULL_V(assembly, FAILED); - - image = p_image; - - loaded = true; - - return OK; + return assembly; } void GDMonoAssembly::unload() { - ERR_FAIL_COND(!loaded); + ERR_FAIL_NULL(image); // Should not be called if already unloaded for (Map<MonoClass *, GDMonoClass *>::Element *E = cached_raw.front(); E; E = E->next()) { memdelete(E->value()); @@ -405,12 +302,15 @@ void GDMonoAssembly::unload() { assembly = NULL; image = NULL; - loaded = false; +} + +String GDMonoAssembly::get_path() const { + return String::utf8(mono_image_get_filename(image)); } GDMonoClass *GDMonoAssembly::get_class(const StringName &p_namespace, const StringName &p_name) { - ERR_FAIL_COND_V(!loaded, NULL); + ERR_FAIL_NULL_V(image, NULL); ClassKey key(p_namespace, p_name); @@ -434,7 +334,7 @@ GDMonoClass *GDMonoAssembly::get_class(const StringName &p_namespace, const Stri GDMonoClass *GDMonoAssembly::get_class(MonoClass *p_mono_class) { - ERR_FAIL_COND_V(!loaded, NULL); + ERR_FAIL_NULL_V(image, NULL); Map<MonoClass *, GDMonoClass *>::Element *match = cached_raw.find(p_mono_class); @@ -514,32 +414,38 @@ GDMonoClass *GDMonoAssembly::get_object_derived_class(const StringName &p_class) GDMonoAssembly *GDMonoAssembly::load_from(const String &p_name, const String &p_path, bool p_refonly) { - GDMonoAssembly **loaded_asm = GDMono::get_singleton()->get_loaded_assembly(p_name); - if (loaded_asm) - return *loaded_asm; -#ifdef DEBUG_ENABLED - CRASH_COND(!FileAccess::exists(p_path)); -#endif - no_search = true; - GDMonoAssembly *res = _load_assembly_from(p_name, p_path, p_refonly); - no_search = false; - return res; -} + if (p_name == "mscorlib" || p_name == "mscorlib.dll") + return GDMono::get_singleton()->get_corlib_assembly(); -GDMonoAssembly::GDMonoAssembly(const String &p_name, const String &p_path) { + // We need to manually call the search hook in this case, as it won't be called in the next step + MonoAssemblyName *aname = mono_assembly_name_new(p_name.utf8()); + MonoAssembly *assembly = mono_assembly_invoke_search_hook(aname); + mono_assembly_name_free(aname); + mono_free(aname); - loaded = false; - gdobject_class_cache_updated = false; - name = p_name; - path = p_path; - refonly = false; - modified_time = 0; - assembly = NULL; - image = NULL; + if (!assembly) { + assembly = _real_load_assembly_from(p_path, p_refonly); + ERR_FAIL_NULL_V(assembly, NULL); + } + + GDMonoAssembly *loaded_asm = GDMono::get_singleton()->get_loaded_assembly(p_name); + ERR_FAIL_NULL_V_MSG(loaded_asm, NULL, "Loaded assembly missing from table. Did we not receive the load hook?"); + + return loaded_asm; +} + +GDMonoAssembly::GDMonoAssembly(const String &p_name, MonoImage *p_image, MonoAssembly *p_assembly) : + name(p_name), + image(p_image), + assembly(p_assembly), +#ifdef GD_MONO_HOT_RELOAD + modified_time(0), +#endif + gdobject_class_cache_updated(false) { } GDMonoAssembly::~GDMonoAssembly() { - if (loaded) + if (image) unload(); } diff --git a/modules/mono/mono_gd/gd_mono_assembly.h b/modules/mono/mono_gd/gd_mono_assembly.h index 4740e10339..43c8225b74 100644 --- a/modules/mono/mono_gd/gd_mono_assembly.h +++ b/modules/mono/mono_gd/gd_mono_assembly.h @@ -68,24 +68,20 @@ class GDMonoAssembly { StringName class_name; }; - MonoAssembly *assembly; + String name; MonoImage *image; + MonoAssembly *assembly; - bool refonly; - bool loaded; - - String name; - String path; +#ifdef GD_MONO_HOT_RELOAD uint64_t modified_time; - - HashMap<ClassKey, GDMonoClass *, ClassKey::Hasher> cached_classes; - Map<MonoClass *, GDMonoClass *> cached_raw; +#endif bool gdobject_class_cache_updated; Map<StringName, GDMonoClass *> gdobject_class_cache; - static bool no_search; - static bool in_preload; + HashMap<ClassKey, GDMonoClass *, ClassKey::Hasher> cached_classes; + Map<MonoClass *, GDMonoClass *> cached_raw; + static Vector<String> search_dirs; static void assembly_load_hook(MonoAssembly *assembly, void *user_data); @@ -97,25 +93,24 @@ class GDMonoAssembly { static MonoAssembly *_search_hook(MonoAssemblyName *aname, void *user_data, bool refonly); static MonoAssembly *_preload_hook(MonoAssemblyName *aname, char **assemblies_path, void *user_data, bool refonly); - static GDMonoAssembly *_load_assembly_from(const String &p_name, const String &p_path, bool p_refonly); - static GDMonoAssembly *_load_assembly_search(const String &p_name, const Vector<String> &p_search_dirs, bool p_refonly); - static void _wrap_mono_assembly(MonoAssembly *assembly); + static MonoAssembly *_real_load_assembly_from(const String &p_path, bool p_refonly); + static MonoAssembly *_load_assembly_search(const String &p_name, const Vector<String> &p_search_dirs, bool p_refonly); friend class GDMono; static void initialize(); public: - Error load(bool p_refonly); - Error wrapper_for_image(MonoImage *p_image); void unload(); - _FORCE_INLINE_ bool is_refonly() const { return refonly; } - _FORCE_INLINE_ bool is_loaded() const { return loaded; } _FORCE_INLINE_ MonoImage *get_image() const { return image; } _FORCE_INLINE_ MonoAssembly *get_assembly() const { return assembly; } _FORCE_INLINE_ String get_name() const { return name; } - _FORCE_INLINE_ String get_path() const { return path; } + +#ifdef GD_MONO_HOT_RELOAD _FORCE_INLINE_ uint64_t get_modified_time() const { return modified_time; } +#endif + + String get_path() const; GDMonoClass *get_class(const StringName &p_namespace, const StringName &p_name); GDMonoClass *get_class(MonoClass *p_mono_class); @@ -128,7 +123,7 @@ public: static GDMonoAssembly *load_from(const String &p_name, const String &p_path, bool p_refonly); - GDMonoAssembly(const String &p_name, const String &p_path = String()); + GDMonoAssembly(const String &p_name, MonoImage *p_image, MonoAssembly *p_assembly); ~GDMonoAssembly(); }; diff --git a/modules/mono/mono_gd/gd_mono_log.cpp b/modules/mono/mono_gd/gd_mono_log.cpp index 76828a66e0..4189934570 100644 --- a/modules/mono/mono_gd/gd_mono_log.cpp +++ b/modules/mono/mono_gd/gd_mono_log.cpp @@ -48,7 +48,7 @@ static CharString get_default_log_level() { GDMonoLog *GDMonoLog::singleton = NULL; -#if !defined(JAVASCRIPT_ENABLED) +#ifdef GD_MONO_LOG_ENABLED static int get_log_level_id(const char *p_log_level) { diff --git a/modules/mono/mono_gd/gd_mono_log.h b/modules/mono/mono_gd/gd_mono_log.h index ecf4c78b1a..1fc21f7df5 100644 --- a/modules/mono/mono_gd/gd_mono_log.h +++ b/modules/mono/mono_gd/gd_mono_log.h @@ -35,13 +35,18 @@ #include "core/typedefs.h" -#if !defined(JAVASCRIPT_ENABLED) +#if !defined(JAVASCRIPT_ENABLED) && !defined(IPHONE_ENABLED) +// We have custom mono log callbacks for WASM and iOS +#define GD_MONO_LOG_ENABLED +#endif + +#ifdef GD_MONO_LOG_ENABLED #include "core/os/file_access.h" #endif class GDMonoLog { -#if !defined(JAVASCRIPT_ENABLED) +#ifdef GD_MONO_LOG_ENABLED int log_level_id; FileAccess *log_file; diff --git a/modules/mono/mono_gd/gd_mono_method_thunk.h b/modules/mono/mono_gd/gd_mono_method_thunk.h index d8c9a5eb02..614ae30947 100644 --- a/modules/mono/mono_gd/gd_mono_method_thunk.h +++ b/modules/mono/mono_gd/gd_mono_method_thunk.h @@ -39,7 +39,7 @@ #include "gd_mono_method.h" #include "gd_mono_utils.h" -#if !defined(JAVASCRIPT_ENABLED) +#if !defined(JAVASCRIPT_ENABLED) && !defined(IPHONE_ENABLED) #define HAVE_METHOD_THUNKS #endif diff --git a/modules/mono/mono_gd/gd_mono_utils.cpp b/modules/mono/mono_gd/gd_mono_utils.cpp index cdb26ae61b..5a2bdffe54 100644 --- a/modules/mono/mono_gd/gd_mono_utils.cpp +++ b/modules/mono/mono_gd/gd_mono_utils.cpp @@ -129,7 +129,12 @@ void set_main_thread(MonoThread *p_thread) { MonoThread *attach_current_thread() { ERR_FAIL_COND_V(!GDMono::get_singleton()->is_runtime_initialized(), NULL); MonoDomain *scripts_domain = GDMono::get_singleton()->get_scripts_domain(); +#ifndef GD_MONO_SINGLE_APPDOMAIN MonoThread *mono_thread = mono_thread_attach(scripts_domain ? scripts_domain : mono_get_root_domain()); +#else + // The scripts domain is the root domain + MonoThread *mono_thread = mono_thread_attach(scripts_domain); +#endif ERR_FAIL_NULL_V(mono_thread, NULL); return mono_thread; } diff --git a/modules/mono/mono_gd/gd_mono_android.cpp b/modules/mono/mono_gd/support/android_support.cpp index 761368878f..222b50730d 100644..100755 --- a/modules/mono/mono_gd/gd_mono_android.cpp +++ b/modules/mono/mono_gd/support/android_support.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* gd_mono_android.cpp */ +/* android_support.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,7 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "gd_mono_android.h" +#include "android_support.h" #if defined(ANDROID_ENABLED) @@ -49,14 +49,16 @@ #include "platform/android/os_android.h" #include "platform/android/thread_jandroid.h" -#include "../utils/path_utils.h" -#include "../utils/string_utils.h" -#include "gd_mono_cache.h" -#include "gd_mono_marshal.h" +#include "../../utils/path_utils.h" +#include "../../utils/string_utils.h" +#include "../gd_mono_cache.h" +#include "../gd_mono_marshal.h" // Warning: JNI boilerplate ahead... continue at your own risk -namespace GDMonoAndroid { +namespace gdmono { +namespace android { +namespace support { template <typename T> struct ScopedLocalRef { @@ -150,11 +152,11 @@ int gd_mono_convert_dl_flags(int flags) { return lflags; } -#ifndef GD_MONO_ANDROID_SO_NAME -#define GD_MONO_ANDROID_SO_NAME "libmonosgen-2.0.so" +#ifndef GD_MONO_SO_NAME +#define GD_MONO_SO_NAME "libmonosgen-2.0.so" #endif -const char *mono_so_name = GD_MONO_ANDROID_SO_NAME; +const char *mono_so_name = GD_MONO_SO_NAME; const char *godot_so_name = "libgodot_android.so"; void *mono_dl_handle = NULL; @@ -352,6 +354,11 @@ MonoArray *_gd_mono_android_cert_store_lookup(MonoString *p_alias) { return encoded_ret; } +void register_internal_calls() { + mono_add_internal_call("Android.Runtime.AndroidEnvironment::_gd_mono_init_cert_store", (void *)_gd_mono_init_cert_store); + mono_add_internal_call("Android.Runtime.AndroidEnvironment::_gd_mono_android_cert_store_lookup", (void *)_gd_mono_android_cert_store_lookup); +} + void initialize() { // We need to set this environment variable to make the monodroid BCL use btls instead of legacy as the default provider OS::get_singleton()->set_environment("XA_TLS_PROVIDER", "btls"); @@ -364,11 +371,6 @@ void initialize() { godot_dl_handle = try_dlopen(so_path, gd_mono_convert_dl_flags(MONO_DL_LAZY)); } -void register_internal_calls() { - mono_add_internal_call("Android.Runtime.AndroidEnvironment::_gd_mono_init_cert_store", (void *)_gd_mono_init_cert_store); - mono_add_internal_call("Android.Runtime.AndroidEnvironment::_gd_mono_android_cert_store_lookup", (void *)_gd_mono_android_cert_store_lookup); -} - void cleanup() { // This is called after shutting down the Mono runtime @@ -386,9 +388,11 @@ void cleanup() { } } -} // namespace GDMonoAndroid +} // namespace support +} // namespace android +} // namespace gdmono -using namespace GDMonoAndroid; +using namespace gdmono::android::support; // The following are P/Invoke functions required by the monodroid profile of the BCL. // These are P/Invoke functions and not internal calls, hence why they use diff --git a/modules/mono/mono_gd/gd_mono_android.h b/modules/mono/mono_gd/support/android_support.h index 0e04847924..dc2e6c95ed 100644..100755 --- a/modules/mono/mono_gd/gd_mono_android.h +++ b/modules/mono/mono_gd/support/android_support.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* gd_mono_android.h */ +/* android_support.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,25 +28,28 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef GD_MONO_ANDROID_H -#define GD_MONO_ANDROID_H +#ifndef ANDROID_SUPPORT_H +#define ANDROID_SUPPORT_H #if defined(ANDROID_ENABLED) #include "core/ustring.h" -namespace GDMonoAndroid { +namespace gdmono { +namespace android { +namespace support { String get_app_native_lib_dir(); void initialize(); +void cleanup(); void register_internal_calls(); -void cleanup(); - -} // namespace GDMonoAndroid +} // namespace support +} // namespace android +} // namespace gdmono #endif // ANDROID_ENABLED -#endif // GD_MONO_ANDROID_H +#endif // ANDROID_SUPPORT_H diff --git a/modules/mono/mono_gd/support/ios_support.h b/modules/mono/mono_gd/support/ios_support.h new file mode 100755 index 0000000000..e28af120e3 --- /dev/null +++ b/modules/mono/mono_gd/support/ios_support.h @@ -0,0 +1,51 @@ +/*************************************************************************/ +/* ios_support.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#ifndef IOS_SUPPORT_H +#define IOS_SUPPORT_H + +#if defined(IPHONE_ENABLED) + +#include "core/ustring.h" + +namespace gdmono { +namespace ios { +namespace support { + +void initialize(); +void cleanup(); + +} // namespace support +} // namespace ios +} // namespace gdmono + +#endif // IPHONE_ENABLED + +#endif // IOS_SUPPORT_H diff --git a/modules/mono/mono_gd/support/ios_support.mm b/modules/mono/mono_gd/support/ios_support.mm new file mode 100755 index 0000000000..e3d1a647fd --- /dev/null +++ b/modules/mono/mono_gd/support/ios_support.mm @@ -0,0 +1,151 @@ +/*************************************************************************/ +/* ios_support.mm */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#include "ios_support.h" + +#if defined(IPHONE_ENABLED) + +#import <Foundation/Foundation.h> +#include <os/log.h> + +#include "core/ustring.h" + +#include "../gd_mono_marshal.h" + +// Implemented mostly following: https://github.com/mono/mono/blob/master/sdks/ios/app/runtime.m + +// Definition generated by the Godot exporter +extern "C" void gd_mono_setup_aot(); + +namespace gdmono { +namespace ios { +namespace support { + +void ios_mono_log_callback(const char *log_domain, const char *log_level, const char *message, mono_bool fatal, void *user_data) { + os_log_info(OS_LOG_DEFAULT, "(%s %s) %s", log_domain, log_level, message); + if (fatal) { + os_log_info(OS_LOG_DEFAULT, "Exit code: %d.", 1); + exit(1); + } +} + +void initialize() { + mono_dllmap_insert(NULL, "System.Native", NULL, "__Internal", NULL); + mono_dllmap_insert(NULL, "System.IO.Compression.Native", NULL, "__Internal", NULL); + mono_dllmap_insert(NULL, "System.Security.Cryptography.Native.Apple", NULL, "__Internal", NULL); + +#ifdef IOS_DEVICE + // This function is defined in an auto-generated source file + gd_mono_setup_aot(); +#endif + + mono_set_signal_chaining(true); + mono_set_crash_chaining(true); +} + +void cleanup() { +} + +} // namespace support +} // namespace ios +} // namespace gdmono + +// The following are P/Invoke functions required by the monotouch profile of the BCL. +// These are P/Invoke functions and not internal calls, hence why they use +// 'mono_bool' and 'const char*' instead of 'MonoBoolean' and 'MonoString*'. + +#define GD_PINVOKE_EXPORT extern "C" __attribute__((visibility("default"))) + +GD_PINVOKE_EXPORT const char *xamarin_get_locale_country_code() { + NSLocale *locale = [NSLocale currentLocale]; + NSString *countryCode = [locale objectForKey:NSLocaleCountryCode]; + if (countryCode == NULL) { + return strdup("US"); + } + return strdup([countryCode UTF8String]); +} + +GD_PINVOKE_EXPORT void xamarin_log(const uint16_t *p_unicode_message) { + int length = 0; + const uint16_t *ptr = p_unicode_message; + while (*ptr++) + length += sizeof(uint16_t); + NSString *msg = [[NSString alloc] initWithBytes:p_unicode_message length:length encoding:NSUTF16LittleEndianStringEncoding]; + + os_log_info(OS_LOG_DEFAULT, "%{public}@", msg); +} + +GD_PINVOKE_EXPORT const char *xamarin_GetFolderPath(int p_folder) { + NSSearchPathDirectory dd = (NSSearchPathDirectory)p_folder; + NSURL *url = [[[NSFileManager defaultManager] URLsForDirectory:dd inDomains:NSUserDomainMask] lastObject]; + NSString *path = [url path]; + return strdup([path UTF8String]); +} + +GD_PINVOKE_EXPORT char *xamarin_timezone_get_local_name() { + NSTimeZone *tz = nil; + tz = [NSTimeZone localTimeZone]; + NSString *name = [tz name]; + return (name != nil) ? strdup([name UTF8String]) : strdup("Local"); +} + +GD_PINVOKE_EXPORT char **xamarin_timezone_get_names(uint32_t *p_count) { + NSArray *array = [NSTimeZone knownTimeZoneNames]; + *p_count = array.count; + char **result = (char **)malloc(sizeof(char *) * (*p_count)); + for (uint32_t i = 0; i < *p_count; i++) { + NSString *s = [array objectAtIndex:i]; + result[i] = strdup(s.UTF8String); + } + return result; +} + +GD_PINVOKE_EXPORT void *xamarin_timezone_get_data(const char *p_name, uint32_t *p_size) { // FIXME: uint32_t since Dec 2019, unsigned long before + NSTimeZone *tz = nil; + if (p_name) { + NSString *n = [[NSString alloc] initWithUTF8String:p_name]; + tz = [[[NSTimeZone alloc] initWithName:n] autorelease]; + [n release]; + } else { + tz = [NSTimeZone localTimeZone]; + } + NSData *data = [tz data]; + *p_size = [data length]; + void *result = malloc(*p_size); + memcpy(result, data.bytes, *p_size); + return result; +} + +GD_PINVOKE_EXPORT void xamarin_start_wwan(const char *p_uri) { + // FIXME: What's this for? No idea how to implement. + os_log_error(OS_LOG_DEFAULT, "Not implemented: 'xamarin_start_wwan'"); +} + +#endif // IPHONE_ENABLED diff --git a/platform/iphone/export/export.cpp b/platform/iphone/export/export.cpp index 08f3c3f91f..2d190cfdc5 100644 --- a/platform/iphone/export/export.cpp +++ b/platform/iphone/export/export.cpp @@ -71,8 +71,8 @@ class EditorExportPlatformIOS : public EditorExportPlatform { String modules_buildphase; String modules_buildgrp; }; - struct ExportArchitecture { + String name; bool is_default; @@ -795,7 +795,7 @@ void EditorExportPlatformIOS::_add_assets_to_project(const Ref<EditorExportPrese String pbx_resources_refs; const String file_info_format = String("$build_id = {isa = PBXBuildFile; fileRef = $ref_id; };\n") + - "$ref_id = {isa = PBXFileReference; lastKnownFileType = $file_type; name = $name; path = \"$file_path\"; sourceTree = \"<group>\"; };\n"; + "$ref_id = {isa = PBXFileReference; lastKnownFileType = $file_type; name = \"$name\"; path = \"$file_path\"; sourceTree = \"<group>\"; };\n"; for (int i = 0; i < p_additional_assets.size(); ++i) { String build_id = (++current_id).str(); String ref_id = (++current_id).str(); @@ -925,6 +925,13 @@ Error EditorExportPlatformIOS::_export_additional_assets(const String &p_out_dir Vector<String> frameworks = export_plugins[i]->get_ios_frameworks(); Error err = _export_additional_assets(p_out_dir, frameworks, true, r_exported_assets); ERR_FAIL_COND_V(err, err); + + Vector<String> project_static_libs = export_plugins[i]->get_ios_project_static_libs(); + for (int j = 0; j < project_static_libs.size(); j++) + project_static_libs.write[j] = project_static_libs[j].get_file(); // Only the file name as it's copied to the project + err = _export_additional_assets(p_out_dir, project_static_libs, true, r_exported_assets); + ERR_FAIL_COND_V(err, err); + Vector<String> ios_bundle_files = export_plugins[i]->get_ios_bundle_files(); err = _export_additional_assets(p_out_dir, ios_bundle_files, false, r_exported_assets); ERR_FAIL_COND_V(err, err); @@ -1202,6 +1209,22 @@ Error EditorExportPlatformIOS::export_project(const Ref<EditorExportPreset> &p_p return ERR_FILE_NOT_FOUND; } + // Copy project static libs to the project + Vector<Ref<EditorExportPlugin>> export_plugins = EditorExport::get_singleton()->get_export_plugins(); + for (int i = 0; i < export_plugins.size(); i++) { + Vector<String> project_static_libs = export_plugins[i]->get_ios_project_static_libs(); + for (int j = 0; j < project_static_libs.size(); j++) { + const String &static_lib_path = project_static_libs[j]; + String dest_lib_file_path = dest_dir + static_lib_path.get_file(); + Error lib_copy_err = tmp_app_path->copy(static_lib_path, dest_lib_file_path); + if (lib_copy_err != OK) { + ERR_PRINT("Can't copy '" + static_lib_path + "'."); + memdelete(tmp_app_path); + return lib_copy_err; + } + } + } + String iconset_dir = dest_dir + binary_name + "/Images.xcassets/AppIcon.appiconset/"; err = OK; if (!tmp_app_path->dir_exists(iconset_dir)) { diff --git a/scene/gui/panel.cpp b/scene/gui/panel.cpp index ae51463a15..a17d0eb9c6 100644 --- a/scene/gui/panel.cpp +++ b/scene/gui/panel.cpp @@ -29,6 +29,7 @@ /*************************************************************************/ #include "panel.h" + #include "core/print_string.h" void Panel::_notification(int p_what) { @@ -54,7 +55,11 @@ void Panel::_bind_methods() { ClassDB::bind_method(D_METHOD("get_mode"), &Panel::get_mode); ADD_PROPERTY(PropertyInfo(Variant::INT, "mode", PROPERTY_HINT_ENUM, "Background,Foreground"), "set_mode", "get_mode"); + + BIND_ENUM_CONSTANT(MODE_BACKGROUND); + BIND_ENUM_CONSTANT(MODE_FOREGROUND); } + Panel::Panel() { // Has visible stylebox, so stop by default. set_mouse_filter(MOUSE_FILTER_STOP); diff --git a/scene/gui/panel.h b/scene/gui/panel.h index 739c64c0a6..75e266b6a6 100644 --- a/scene/gui/panel.h +++ b/scene/gui/panel.h @@ -40,7 +40,7 @@ class Panel : public Control { public: enum Mode { MODE_BACKGROUND, - MODE_FOREGROUND + MODE_FOREGROUND, }; private: @@ -59,4 +59,5 @@ public: }; VARIANT_ENUM_CAST(Panel::Mode) -#endif + +#endif // PANEL_H diff --git a/scene/main/window.h b/scene/main/window.h index be07762f20..adaa5ca3be 100644 --- a/scene/main/window.h +++ b/scene/main/window.h @@ -43,7 +43,7 @@ public: MODE_WINDOWED = DisplayServer::WINDOW_MODE_WINDOWED, MODE_MINIMIZED = DisplayServer::WINDOW_MODE_MINIMIZED, MODE_MAXIMIZED = DisplayServer::WINDOW_MODE_MAXIMIZED, - MODE_FULLSCREEN = DisplayServer::WINDOW_MODE_FULLSCREEN + MODE_FULLSCREEN = DisplayServer::WINDOW_MODE_FULLSCREEN, }; enum Flags { @@ -59,7 +59,6 @@ public: CONTENT_SCALE_MODE_DISABLED, CONTENT_SCALE_MODE_OBJECTS, CONTENT_SCALE_MODE_PIXELS, - }; enum ContentScaleAspect { @@ -68,10 +67,10 @@ public: CONTENT_SCALE_ASPECT_KEEP_WIDTH, CONTENT_SCALE_ASPECT_KEEP_HEIGHT, CONTENT_SCALE_ASPECT_EXPAND, - }; + enum { - DEFAULT_WINDOW_SIZE = 100 + DEFAULT_WINDOW_SIZE = 100, }; private: @@ -258,8 +257,8 @@ public: ~Window(); }; -VARIANT_ENUM_CAST(Window::Window::Mode); -VARIANT_ENUM_CAST(Window::Window::Flags); +VARIANT_ENUM_CAST(Window::Mode); +VARIANT_ENUM_CAST(Window::Flags); VARIANT_ENUM_CAST(Window::ContentScaleMode); VARIANT_ENUM_CAST(Window::ContentScaleAspect); diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp index e73e560656..22c000fae7 100644 --- a/scene/register_scene_types.cpp +++ b/scene/register_scene_types.cpp @@ -270,6 +270,7 @@ void register_scene_types() { ClassDB::register_virtual_class<InstancePlaceholder>(); ClassDB::register_virtual_class<Viewport>(); + ClassDB::register_class<SubViewport>(); ClassDB::register_class<ViewportTexture>(); ClassDB::register_class<HTTPRequest>(); ClassDB::register_class<Timer>(); diff --git a/servers/rendering/rasterizer_rd/rasterizer_storage_rd.cpp b/servers/rendering/rasterizer_rd/rasterizer_storage_rd.cpp index 83af15602c..b6b6b5a040 100644 --- a/servers/rendering/rasterizer_rd/rasterizer_storage_rd.cpp +++ b/servers/rendering/rasterizer_rd/rasterizer_storage_rd.cpp @@ -29,6 +29,7 @@ /*************************************************************************/ #include "rasterizer_storage_rd.h" + #include "core/engine.h" #include "core/project_settings.h" #include "servers/rendering/shader_language.h" @@ -1664,7 +1665,7 @@ void RasterizerStorageRD::MaterialData::update_textures(const Map<StringName, Va RasterizerStorageRD *singleton = (RasterizerStorageRD *)RasterizerStorage::base_singleton; #ifdef TOOLS_ENABLED Texture *roughness_detect_texture = nullptr; - RS::TextureDetectRoughnessChannel roughness_channel; + RS::TextureDetectRoughnessChannel roughness_channel = RS::TEXTURE_DETECT_ROUGNHESS_R; Texture *normal_detect_texture = nullptr; #endif diff --git a/servers/rendering_server.cpp b/servers/rendering_server.cpp index a960efb272..0bad644b95 100644 --- a/servers/rendering_server.cpp +++ b/servers/rendering_server.cpp @@ -1802,7 +1802,7 @@ void RenderingServer::_bind_methods() { ClassDB::bind_method(D_METHOD("environment_set_bg_energy", "env", "energy"), &RenderingServer::environment_set_bg_energy); ClassDB::bind_method(D_METHOD("environment_set_canvas_max_layer", "env", "max_layer"), &RenderingServer::environment_set_canvas_max_layer); ClassDB::bind_method(D_METHOD("environment_set_ambient_light", "env", "color", "ambient", "energy", "sky_contibution", "reflection_source", "ao_color"), &RenderingServer::environment_set_ambient_light, DEFVAL(RS::ENV_AMBIENT_SOURCE_BG), DEFVAL(1.0), DEFVAL(0.0), DEFVAL(RS::ENV_REFLECTION_SOURCE_BG), DEFVAL(Color())); - ClassDB::bind_method(D_METHOD("environment_set_glow", "env", "enable", "level_flags", "intensity", "strength", "mix", "bloom_threshold", "blend_mode", "hdr_bleed_threshold", "hdr_bleed_scale", "hdr_luminance_cap", "bicubic_upscale"), &RenderingServer::environment_set_glow); + ClassDB::bind_method(D_METHOD("environment_set_glow", "env", "enable", "level_flags", "intensity", "strength", "mix", "bloom_threshold", "blend_mode", "hdr_bleed_threshold", "hdr_bleed_scale", "hdr_luminance_cap"), &RenderingServer::environment_set_glow); ClassDB::bind_method(D_METHOD("environment_set_tonemap", "env", "tone_mapper", "exposure", "white", "auto_exposure", "min_luminance", "max_luminance", "auto_exp_speed", "auto_exp_grey"), &RenderingServer::environment_set_tonemap); ClassDB::bind_method(D_METHOD("environment_set_adjustment", "env", "enable", "brightness", "contrast", "saturation", "ramp"), &RenderingServer::environment_set_adjustment); ClassDB::bind_method(D_METHOD("environment_set_ssr", "env", "enable", "max_steps", "fade_in", "fade_out", "depth_tolerance", "roughness"), &RenderingServer::environment_set_ssr); |