diff options
65 files changed, 435 insertions, 196 deletions
diff --git a/core/math/math_funcs.h b/core/math/math_funcs.h index d5135fe414..bc0b3717ed 100644 --- a/core/math/math_funcs.h +++ b/core/math/math_funcs.h @@ -39,6 +39,7 @@ #include <math.h> #define Math_PI 3.14159265358979323846 +#define Math_TAU 6.28318530717958647692 #define Math_SQRT12 0.7071067811865475244008443621048490 #define Math_LN2 0.693147180559945309417 #define Math_INF INFINITY diff --git a/doc/classes/@GDScript.xml b/doc/classes/@GDScript.xml index 9c1d9a1aa2..3c794a4c4c 100644 --- a/doc/classes/@GDScript.xml +++ b/doc/classes/@GDScript.xml @@ -1117,7 +1117,10 @@ </methods> <constants> <constant name="PI" value="3.141593" enum=""> - Constant that represents how many times the diameter of a circumference fits around its perimeter. + Constant that represents how many times the diameter of a circle fits around its perimeter. + </constant> + <constant name="TAU" value="6.2831853" enum=""> + The circle constant, the circumference of the unit circle. </constant> <constant name="INF" value="inf" enum=""> A positive infinity. (For negative infinity, use -INF). diff --git a/doc/classes/CanvasLayer.xml b/doc/classes/CanvasLayer.xml index c3f2e43892..f89c4ea754 100644 --- a/doc/classes/CanvasLayer.xml +++ b/doc/classes/CanvasLayer.xml @@ -38,7 +38,7 @@ Return the base rotation for this layer in radians (helper). </description> </method> - <method name="get_rotationd" qualifiers="const"> + <method name="get_rotation_degrees" qualifiers="const"> <return type="float"> </return> <description> @@ -101,7 +101,7 @@ Set the base rotation for this layer in radians (helper). </description> </method> - <method name="set_rotationd"> + <method name="set_rotation_degrees"> <return type="void"> </return> <argument index="0" name="degrees" type="float"> @@ -136,7 +136,7 @@ <member name="offset" type="Vector2" setter="set_offset" getter="get_offset"> The layer's base offset. </member> - <member name="rotation" type="float" setter="set_rotationd" getter="get_rotationd"> + <member name="rotation" type="float" setter="set_rotation_degrees" getter="get_rotation_degrees"> The layer's rotation in degrees. </member> <member name="scale" type="Vector2" setter="set_scale" getter="get_scale"> diff --git a/doc/classes/Control.xml b/doc/classes/Control.xml index e3d29c2e93..b5765ac948 100644 --- a/doc/classes/Control.xml +++ b/doc/classes/Control.xml @@ -347,7 +347,7 @@ Return the rotation (in radians) </description> </method> - <method name="get_rotation_deg" qualifiers="const"> + <method name="get_rotation_degrees" qualifiers="const"> <return type="float"> </return> <description> @@ -763,7 +763,7 @@ Set the rotation (in radians). </description> </method> - <method name="set_rotation_deg"> + <method name="set_rotation_degrees"> <return type="void"> </return> <argument index="0" name="degrees" type="float"> @@ -910,7 +910,7 @@ <member name="rect_position" type="Vector2" setter="set_position" getter="get_position"> The node's position, relative to its parent. It corresponds to the rectangle's top-left corner. The property is not affected by [member rect_pivot_offset]. </member> - <member name="rect_rotation" type="float" setter="set_rotation_deg" getter="get_rotation_deg"> + <member name="rect_rotation" type="float" setter="set_rotation_degrees" getter="get_rotation_degrees"> The node's rotation around its pivot, in degrees. See [member rect_pivot_offset] to change the pivot's position. </member> <member name="rect_scale" type="Vector2" setter="set_scale" getter="get_scale"> diff --git a/doc/classes/LineEdit.xml b/doc/classes/LineEdit.xml index 850f724714..bf81d90efe 100644 --- a/doc/classes/LineEdit.xml +++ b/doc/classes/LineEdit.xml @@ -114,6 +114,13 @@ Return the text in the [code]LineEdit[/code]. </description> </method> + <method name="is_context_menu_enabled" qualifiers="const"> + <return type="bool"> + </return> + <description> + Returns true if the context menu is enabled. + </description> + </method> <method name="is_editable" qualifiers="const"> <return type="bool"> </return> @@ -170,6 +177,15 @@ Set text alignment of the [code]LineEdit[/code]. </description> </method> + <method name="set_context_menu_enabled"> + <return type="void"> + </return> + <argument index="0" name="enabled" type="bool"> + </argument> + <description> + Set the status of the context menu. When enabled, the context menu will appear when the [code]LineEdit[/code] is right clicked. + </description> + </method> <method name="set_cursor_position"> <return type="void"> </return> @@ -276,6 +292,9 @@ <member name="text" type="String" setter="set_text" getter="get_text"> String value of the [LineEdit]. </member> + <member name="context_menu_enabled" type="bool" setter="set_context_menu_enabled" getter="is_context_menu_enabled"> + If [code]true[/code] the context menu will appear when right clicked. + </member> </members> <signals> <signal name="text_changed"> diff --git a/doc/classes/Node2D.xml b/doc/classes/Node2D.xml index 669a0fb9ff..2fdc6bf440 100644 --- a/doc/classes/Node2D.xml +++ b/doc/classes/Node2D.xml @@ -52,7 +52,7 @@ Returns the node's global rotation in radians. </description> </method> - <method name="get_global_rotation_in_degrees" qualifiers="const"> + <method name="get_global_rotation_degrees" qualifiers="const"> <return type="float"> </return> <description> @@ -89,7 +89,7 @@ Returns the node's rotation in radians. </description> </method> - <method name="get_rotation_in_degrees" qualifiers="const"> + <method name="get_rotation_degrees" qualifiers="const"> <return type="float"> </return> <description> @@ -184,7 +184,7 @@ Sets the node's global rotation in radians. </description> </method> - <method name="set_global_rotation_in_degrees"> + <method name="set_global_rotation_degrees"> <return type="void"> </return> <argument index="0" name="degrees" type="float"> @@ -229,7 +229,7 @@ Sets the node's rotation in radians. </description> </method> - <method name="set_rotation_in_degrees"> + <method name="set_rotation_degrees"> <return type="void"> </return> <argument index="0" name="degrees" type="float"> @@ -309,7 +309,7 @@ <member name="global_rotation" type="float" setter="set_global_rotation" getter="get_global_rotation"> Global rotation in radians. </member> - <member name="global_rotation_deg" type="float" setter="set_global_rotation_in_degrees" getter="get_global_rotation_in_degrees"> + <member name="global_rotation_degrees" type="float" setter="set_global_rotation_degrees" getter="get_global_rotation_degrees"> Global rotation in degrees. </member> <member name="global_scale" type="Vector2" setter="set_global_scale" getter="get_global_scale"> @@ -324,7 +324,7 @@ <member name="rotation" type="float" setter="set_rotation" getter="get_rotation"> Rotation in radians, relative to the node's parent. </member> - <member name="rotation_deg" type="float" setter="set_rotation_in_degrees" getter="get_rotation_in_degrees"> + <member name="rotation_degrees" type="float" setter="set_rotation_degrees" getter="get_rotation_degrees"> Rotation in degrees, relative to the node's parent. </member> <member name="scale" type="Vector2" setter="set_scale" getter="get_scale"> diff --git a/doc/classes/Polygon2D.xml b/doc/classes/Polygon2D.xml index 23cb9bd91b..5aa7146ff7 100644 --- a/doc/classes/Polygon2D.xml +++ b/doc/classes/Polygon2D.xml @@ -227,7 +227,7 @@ <member name="texture_offset" type="Vector2" setter="set_texture_offset" getter="get_texture_offset"> Amount to offset the polygon's [code]texture[/code]. If [code](0, 0)[/code] the texture's origin (its top-left corner) will be placed at the polygon's [code]position[/code]. </member> - <member name="texture_rotation" type="float" setter="_set_texture_rotationd" getter="_get_texture_rotationd"> + <member name="texture_rotation" type="float" setter="set_texture_rotation_degrees" getter="get_texture_rotation_degrees"> The texture's rotation in degrees. </member> <member name="texture_scale" type="Vector2" setter="set_texture_scale" getter="get_texture_scale"> diff --git a/doc/classes/Spatial.xml b/doc/classes/Spatial.xml index 38e971b6bd..07f5ea5301 100644 --- a/doc/classes/Spatial.xml +++ b/doc/classes/Spatial.xml @@ -39,7 +39,7 @@ Returns the rotation (in radians). </description> </method> - <method name="get_rotation_deg" qualifiers="const"> + <method name="get_rotation_degrees" qualifiers="const"> <return type="Vector3"> </return> <description> @@ -267,16 +267,16 @@ <method name="set_rotation"> <return type="void"> </return> - <argument index="0" name="rotation_rad" type="Vector3"> + <argument index="0" name="radians" type="Vector3"> </argument> <description> Set the rotation (in radians). </description> </method> - <method name="set_rotation_deg"> + <method name="set_rotation_degrees"> <return type="void"> </return> - <argument index="0" name="rotation_deg" type="Vector3"> + <argument index="0" name="degrees" type="Vector3"> </argument> <description> Set the rotation (in degrees). @@ -365,7 +365,7 @@ <member name="rotation" type="Vector3" setter="set_rotation" getter="get_rotation"> Local euler rotation in radians of this node. </member> - <member name="rotation_deg" type="Vector3" setter="set_rotation_deg" getter="get_rotation_deg"> + <member name="rotation_degrees" type="Vector3" setter="set_rotation_degrees" getter="get_rotation_degrees"> Local euler rotation in degrees of this node. </member> <member name="scale" type="Vector3" setter="set_scale" getter="get_scale"> diff --git a/doc/classes/TextEdit.xml b/doc/classes/TextEdit.xml index 43e5158515..0af11eec31 100644 --- a/doc/classes/TextEdit.xml +++ b/doc/classes/TextEdit.xml @@ -239,6 +239,14 @@ Returns true if highlight all occurrences is enabled. </description> </method> + </method> + <method name="is_context_menu_enabled" qualifiers="const"> + <return type="bool"> + </return> + <description> + Returns true if the context menu is enabled. + </description> + </method> <method name="is_highlight_current_line_enabled" qualifiers="const"> <return type="bool"> </return> @@ -251,6 +259,13 @@ <description> </description> </method> + <method name="is_readonly" qualifiers="const"> ++ <return type="bool"> ++ </return> ++ <description> ++ Return true if the text editor is in read-only mode (see [method set_readonly]). ++ </description> ++ </method> <method name="is_selection_active" qualifiers="const"> <return type="bool"> </return> @@ -337,6 +352,15 @@ Select all the text. </description> </method> + <method name="set_context_menu_enabled"> + <return type="void"> + </return> + <argument index="0" name="enabled" type="bool"> + </argument> + <description> + Set the status of the context menu. When enabled, the context menu will appear when the [code]TextEdit[/code] is right clicked. + </description> + </method> <method name="set_highlight_all_occurrences"> <return type="void"> </return> @@ -441,6 +465,9 @@ </method> </methods> <members> + <member name="readonly" type="bool" setter="set_readonly" getter="is_readonly"> + If [code]true[/code] read-only mode is enabled. Existing text cannot be modified and new text cannot be added. + </member> <member name="caret_blink" type="bool" setter="cursor_set_blink_enabled" getter="cursor_get_blink_enabled"> </member> <member name="caret_blink_speed" type="float" setter="cursor_set_blink_speed" getter="cursor_get_blink_speed"> @@ -455,6 +482,8 @@ </member> <member name="show_line_numbers" type="bool" setter="set_show_line_numbers" getter="is_show_line_numbers_enabled"> </member> + <member name="context_menu_enabled" type="bool" setter="set_context_menu_enabled" getter="is_context_menu_enabled"> + </member> <member name="smooth_scrolling" type="bool" setter="set_smooth_scroll_enable" getter="is_smooth_scroll_enabled"> </member> <member name="syntax_highlighting" type="bool" setter="set_syntax_coloring" getter="is_syntax_coloring_enabled"> diff --git a/doc/classes/VisualScriptMathConstant.xml b/doc/classes/VisualScriptMathConstant.xml index 86744e5caf..c753c16218 100644 --- a/doc/classes/VisualScriptMathConstant.xml +++ b/doc/classes/VisualScriptMathConstant.xml @@ -42,12 +42,12 @@ <constant name="MATH_CONSTANT_PI" value="1"> Pi: [code]3.141593[/code] </constant> - <constant name="MATH_CONSTANT_2PI" value="2"> - Pi times two: [code]6.283185[/code] - </constant> - <constant name="MATH_CONSTANT_HALF_PI" value="3"> + <constant name="MATH_CONSTANT_HALF_PI" value="2"> Pi divided by two: [code]1.570796[/code] </constant> + <constant name="MATH_CONSTANT_TAU" value="3"> + Tau: [code]6.283185[/code] + </constant> <constant name="MATH_CONSTANT_E" value="4"> Natural log: [code]2.718282[/code] </constant> diff --git a/drivers/gles3/shaders/canvas.glsl b/drivers/gles3/shaders/canvas.glsl index 731d6968ce..4bbb18ce42 100644 --- a/drivers/gles3/shaders/canvas.glsl +++ b/drivers/gles3/shaders/canvas.glsl @@ -381,8 +381,7 @@ void main() { if (clip_rect_uv) { - vec2 half_texpixel = color_texpixel_size * 0.5; - uv = clamp(uv,src_rect.xy+half_texpixel,src_rect.xy+abs(src_rect.zw)-color_texpixel_size); + uv = clamp(uv,src_rect.xy,src_rect.xy+abs(src_rect.zw)); } #endif diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 740dd360ae..9931f75314 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -284,9 +284,10 @@ void EditorNode::_notification(int p_what) { if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) { scene_tabs->set_tab_close_display_policy((bool(EDITOR_DEF("interface/editor/always_show_close_button_in_scene_tabs", false)) ? Tabs::CLOSE_BUTTON_SHOW_ALWAYS : Tabs::CLOSE_BUTTON_SHOW_ACTIVE_ONLY)); property_editor->set_enable_capitalize_paths(bool(EDITOR_DEF("interface/editor/capitalize_properties", true))); - Ref<Theme> theme = create_editor_theme(theme_base->get_theme()); + Ref<Theme> theme = create_custom_theme(theme_base->get_theme()); theme_base->set_theme(theme); + gui_base->set_theme(theme); gui_base->add_style_override("panel", gui_base->get_stylebox("Background", "EditorStyles")); play_button_panel->add_style_override("panel", gui_base->get_stylebox("PlayButtonPanel", "EditorStyles")); @@ -4691,9 +4692,9 @@ EditorNode::EditorNode() { theme_base->add_child(gui_base); gui_base->set_anchors_and_margins_preset(Control::PRESET_WIDE); - Ref<Theme> theme = create_editor_theme(); + Ref<Theme> theme = create_custom_theme(); theme_base->set_theme(theme); - gui_base->set_theme(create_custom_theme()); + gui_base->set_theme(theme); gui_base->add_style_override("panel", gui_base->get_stylebox("Background", "EditorStyles")); resource_preview = memnew(EditorResourcePreview); @@ -5388,12 +5389,12 @@ EditorNode::EditorNode() { save_confirmation->connect("confirmed", this, "_menu_confirm_current"); save_confirmation->connect("custom_action", this, "_discard_changes"); - file_templates = memnew(FileDialog); + file_templates = memnew(EditorFileDialog); file_templates->set_title(TTR("Import Templates From ZIP File")); gui_base->add_child(file_templates); - file_templates->set_mode(FileDialog::MODE_OPEN_FILE); - file_templates->set_access(FileDialog::ACCESS_FILESYSTEM); + file_templates->set_mode(EditorFileDialog::MODE_OPEN_FILE); + file_templates->set_access(EditorFileDialog::ACCESS_FILESYSTEM); file_templates->clear_filters(); file_templates->add_filter("*.tpz ; Template Package"); @@ -5401,15 +5402,15 @@ EditorNode::EditorNode() { gui_base->add_child(file); file->set_current_dir("res://"); - file_export = memnew(FileDialog); - file_export->set_access(FileDialog::ACCESS_FILESYSTEM); + file_export = memnew(EditorFileDialog); + file_export->set_access(EditorFileDialog::ACCESS_FILESYSTEM); gui_base->add_child(file_export); file_export->set_title(TTR("Export Project")); file_export->connect("file_selected", this, "_dialog_action"); - file_export_lib = memnew(FileDialog); + file_export_lib = memnew(EditorFileDialog); file_export_lib->set_title(TTR("Export Library")); - file_export_lib->set_mode(FileDialog::MODE_SAVE_FILE); + file_export_lib->set_mode(EditorFileDialog::MODE_SAVE_FILE); file_export_lib->connect("file_selected", this, "_dialog_action"); file_export_lib_merge = memnew(CheckButton); file_export_lib_merge->set_text(TTR("Merge With Existing")); @@ -5422,10 +5423,10 @@ EditorNode::EditorNode() { file_export_password->set_editable(false); file_export->get_vbox()->add_margin_child(TTR("Password:"), file_export_password); - file_script = memnew(FileDialog); + file_script = memnew(EditorFileDialog); file_script->set_title(TTR("Open & Run a Script")); - file_script->set_access(FileDialog::ACCESS_FILESYSTEM); - file_script->set_mode(FileDialog::MODE_OPEN_FILE); + file_script->set_access(EditorFileDialog::ACCESS_FILESYSTEM); + file_script->set_mode(EditorFileDialog::MODE_OPEN_FILE); List<String> sexts; ResourceLoader::get_recognized_extensions_for_type("Script", &sexts); for (List<String>::Element *E = sexts.front(); E; E = E->next()) { diff --git a/editor/editor_node.h b/editor/editor_node.h index 6e0117a4ac..7d0649cef3 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -294,10 +294,10 @@ private: ProjectSettingsEditor *project_settings; EditorFileDialog *file; ExportTemplateManager *export_template_manager; - FileDialog *file_templates; - FileDialog *file_export; - FileDialog *file_export_lib; - FileDialog *file_script; + EditorFileDialog *file_templates; + EditorFileDialog *file_export; + EditorFileDialog *file_export_lib; + EditorFileDialog *file_script; CheckButton *file_export_lib_merge; LineEdit *file_export_password; String current_path; diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index de0c3f55cc..0f9f50095d 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -568,6 +568,11 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_constant("modulate_arrow", "OptionButton", true); // CheckButton + theme->set_stylebox("normal", "CheckButton", style_menu); + theme->set_stylebox("pressed", "CheckButton", style_menu); + theme->set_stylebox("disabled", "CheckButton", style_menu); + theme->set_stylebox("hover", "CheckButton", style_menu); + theme->set_icon("on", "CheckButton", theme->get_icon("GuiToggleOn", "EditorIcons")); theme->set_icon("off", "CheckButton", theme->get_icon("GuiToggleOff", "EditorIcons")); @@ -577,7 +582,22 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_color("font_color_disabled", "CheckButton", font_color_disabled); theme->set_color("icon_color_hover", "CheckButton", font_color_hl); + theme->set_constant("hseparation", "CheckButton", 4 * EDSCALE); + theme->set_constant("check_vadjust", "CheckButton", 0 * EDSCALE); + // Checkbox + Ref<StyleBoxFlat> sb_checkbox = style_menu->duplicate(); + // HACK, in reality, the checkbox draws the text over the icon by default, so the margin compensates that. + const int cb_w = theme->get_icon("GuiChecked", "EditorIcons")->get_width() + default_margin_size; + sb_checkbox->set_default_margin(MARGIN_LEFT, cb_w * EDSCALE); + sb_checkbox->set_default_margin(MARGIN_RIGHT, default_margin_size * EDSCALE); + sb_checkbox->set_default_margin(MARGIN_TOP, default_margin_size * EDSCALE); + sb_checkbox->set_default_margin(MARGIN_BOTTOM, default_margin_size * EDSCALE); + + theme->set_stylebox("normal", "CheckBox", sb_checkbox); + theme->set_stylebox("pressed", "CheckBox", sb_checkbox); + theme->set_stylebox("disabled", "CheckBox", sb_checkbox); + theme->set_stylebox("hover", "CheckBox", sb_checkbox); theme->set_icon("checked", "CheckBox", theme->get_icon("GuiChecked", "EditorIcons")); theme->set_icon("unchecked", "CheckBox", theme->get_icon("GuiUnchecked", "EditorIcons")); theme->set_icon("radio_checked", "CheckBox", theme->get_icon("GuiRadioChecked", "EditorIcons")); @@ -589,6 +609,9 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_color("font_color_disabled", "CheckBox", font_color_disabled); theme->set_color("icon_color_hover", "CheckBox", font_color_hl); + theme->set_constant("hseparation", "CheckBox", 4 * EDSCALE); + theme->set_constant("check_vadjust", "CheckBox", 0 * EDSCALE); + // PopupMenu Ref<StyleBoxFlat> style_popup_menu = style_popup; theme->set_stylebox("panel", "PopupMenu", style_popup_menu); @@ -1044,12 +1067,14 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { return theme; } -Ref<Theme> create_custom_theme() { - Ref<Theme> theme = create_editor_theme(); +Ref<Theme> create_custom_theme(const Ref<Theme> p_theme) { + Ref<Theme> theme; String custom_theme = EditorSettings::get_singleton()->get("interface/theme/custom_theme"); if (custom_theme != "") { theme = ResourceLoader::load(custom_theme); + } else { + theme = create_editor_theme(p_theme); } String global_font = EditorSettings::get_singleton()->get("interface/editor/custom_font"); diff --git a/editor/editor_themes.h b/editor/editor_themes.h index a644c5936f..6f3b83e0b0 100644 --- a/editor/editor_themes.h +++ b/editor/editor_themes.h @@ -34,6 +34,6 @@ Ref<Theme> create_editor_theme(Ref<Theme> p_theme = NULL); -Ref<Theme> create_custom_theme(); +Ref<Theme> create_custom_theme(Ref<Theme> p_theme = NULL); #endif diff --git a/editor/icons/icon_GUI_toggle_off.svg b/editor/icons/icon_GUI_toggle_off.svg index 0d43b158b5..aea0f85f96 100644 --- a/editor/icons/icon_GUI_toggle_off.svg +++ b/editor/icons/icon_GUI_toggle_off.svg @@ -1,5 +1,5 @@ -<svg width="64" height="32" version="1.1" viewBox="0 0 64 31.999998" xmlns="http://www.w3.org/2000/svg"> -<g transform="translate(0 -1020.4)"> -<path transform="translate(0 1020.4)" d="m24 4.002c-6.6307 0-12 5.3654-12 11.996v0.003906c0 6.6307 5.3693 12 12 12h16c6.6307 0 12-5.3693 12-12v-0.003906c0-6.6307-5.3693-11.996-12-11.996h-16zm0 2h16c5.5573 0 10 4.4388 10 9.9961v0.003906c0 5.5573-4.4427 10-10 10h-16c-5.5573 0-10-4.4427-10-10v-0.003906c0-5.5573 4.4427-9.9961 10-9.9961zm7 4.9961a1.0001 1.0001 0 0 0 -1 1v8a1 1 0 0 0 1 1 1 1 0 0 0 1 -1v-3h2a1 1 0 0 0 1 -1 1 1 0 0 0 -1 -1h-2v-2h4a1 1 0 0 0 1 -1 1 1 0 0 0 -1 -1h-5zm9 0a1.0001 1.0001 0 0 0 -1 1v4 4a1 1 0 0 0 1 1 1 1 0 0 0 1 -1v-3h2a1 1 0 0 0 1 -1 1 1 0 0 0 -1 -1h-2v-2h4a1 1 0 0 0 1 -1 1 1 0 0 0 -1 -1h-5zm-17 0.003906c-2.7496 0-5 2.2504-5 5s2.2504 5 5 5 5-2.2504 5-5-2.2504-5-5-5zm0 2c1.6687 0 3 1.3313 3 3s-1.3313 3-3 3-3-1.3313-3-3 1.3313-3 3-3z" color="#000000" color-rendering="auto" dominant-baseline="auto" fill="#e0e0e0" fill-opacity=".78431" image-rendering="auto" shape-rendering="auto" solid-color="#000000" style="filter-blend-mode:normal;filter-gaussianBlur-deviation:0;font-feature-settings:normal;font-variant-alternates:normal;font-variant-caps:normal;font-variant-east-asian:normal;font-variant-ligatures:normal;font-variant-numeric:normal;font-variant-position:normal;isolation:auto;mix-blend-mode:normal;shape-padding:0;text-decoration-color:#000000;text-decoration-line:none;text-decoration-style:solid;text-indent:0;text-orientation:mixed;text-transform:none;white-space:normal"/> +<svg width="42" height="26" version="1.1" viewBox="0 0 42 25.999998" xmlns="http://www.w3.org/2000/svg"> +<g transform="translate(0 -1026.4)"> +<path d="m13 1027.4c-6.6307 0-12 5.3663-12 11.998 0 6.6318 5.3693 12.002 12 12.002h16c6.6307 0 12-5.3702 12-12.002 0-6.6317-5.3693-11.998-12-11.998zm0 2.0003h16c5.5573 0 10 4.4395 10 9.9977 0 5.5583-4.4427 10.002-10 10.002h-16c-5.5573 0-10-4.4434-10-10.002 0-5.5582 4.4427-9.9977 10-9.9977zm7 4.9969a1.0001 1.0003 0 0 0 -1 1.0002v8.0013a1 1.0002 0 0 0 1 1.0002 1 1.0002 0 0 0 1 -1.0002v-3.0005h2a1 1.0002 0 0 0 1 -1.0002 1 1.0002 0 0 0 -1 -1.0001h-2v-2.0003h4a1 1.0002 0 0 0 1 -1.0002 1 1.0002 0 0 0 -1 -1.0002zm9 0a1.0001 1.0003 0 0 0 -1 1.0002v8.0013a1 1.0002 0 0 0 1 1.0002 1 1.0002 0 0 0 1 -1.0002v-3.0005h2a1 1.0002 0 0 0 1 -1.0002 1 1.0002 0 0 0 -1 -1.0001h-2v-2.0003h4a1 1.0002 0 0 0 1 -1.0002 1 1.0002 0 0 0 -1 -1.0002zm-17 0c-2.7496 0-5 2.2508-5 5.0008 0 2.7501 2.2504 5.0009 5 5.0009s5-2.2508 5-5.0009c0-2.75-2.2504-5.0008-5-5.0008zm0 2.0004c1.6687 0 3 1.3315 3 3.0004 0 1.669-1.3313 3.0005-3 3.0005s-3-1.3315-3-3.0005c0-1.6689 1.3313-3.0004 3-3.0004z" color="#000000" color-rendering="auto" dominant-baseline="auto" fill="#e0e0e0" fill-opacity=".78431" image-rendering="auto" shape-rendering="auto" solid-color="#000000" style="font-feature-settings:normal;font-variant-alternates:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal;font-variant-position:normal;isolation:auto;mix-blend-mode:normal;shape-padding:0;text-decoration-color:#000000;text-decoration-line:none;text-decoration-style:solid;text-indent:0;text-orientation:mixed;text-transform:none;white-space:normal"/> </g> </svg> diff --git a/editor/icons/icon_GUI_toggle_on.svg b/editor/icons/icon_GUI_toggle_on.svg index fd2b915fc3..c0a11810d4 100644 --- a/editor/icons/icon_GUI_toggle_on.svg +++ b/editor/icons/icon_GUI_toggle_on.svg @@ -1,5 +1,5 @@ -<svg width="64" height="32" version="1.1" viewBox="0 0 64 31.999998" xmlns="http://www.w3.org/2000/svg"> -<g transform="translate(0 -1020.4)"> -<path transform="translate(0 1020.4)" d="m24 4.002c-6.6307 0-12 5.3654-12 11.996 0 6.6307 5.3693 12 12 12h16c6.6307 0 12-5.3693 12-12 0-6.6307-5.3693-11.996-12-11.996h-16zm17 6.9961a1 1 0 0 1 1 1v8a1.0001 1.0001 0 0 1 -1.752 0.66211l-5.248-6v5.3379a1 1 0 0 1 -1 1 1 1 0 0 1 -1 -1v-8a1.0001 1.0001 0 0 1 1.752 -0.6582l5.248 6v-5.3418a1 1 0 0 1 1 -1zm-15 0.003906c2.7496 0 5 2.2504 5 5s-2.2504 5-5 5-5-2.2504-5-5 2.2504-5 5-5zm0 2c-1.6687 0-3 1.3313-3 3s1.3313 3 3 3 3-1.3313 3-3-1.3313-3-3-3z" color="#000000" color-rendering="auto" dominant-baseline="auto" fill="#e0e0e0" fill-opacity=".78431" image-rendering="auto" shape-rendering="auto" solid-color="#000000" style="font-feature-settings:normal;font-variant-alternates:normal;font-variant-caps:normal;font-variant-east-asian:normal;font-variant-ligatures:normal;font-variant-numeric:normal;font-variant-position:normal;isolation:auto;mix-blend-mode:normal;shape-padding:0;text-decoration-color:#000000;text-decoration-line:none;text-decoration-style:solid;text-indent:0;text-orientation:mixed;text-transform:none;white-space:normal"/> +<svg width="42" height="26" version="1.1" viewBox="0 0 42 25.999998" xmlns="http://www.w3.org/2000/svg"> +<g transform="translate(0 -1026.4)"> +<path d="m13 1027.4c-6.6307 0-12 5.3662-12 11.998s5.3693 12.002 12 12.002h16c6.6307 0 12-5.3702 12-12.002s-5.3693-11.998-12-11.998zm17 6.9972a1 1.0002 0 0 1 1 1.0001v8.0014a1.0001 1.0003 0 0 1 -1.752 0.6623l-5.248-6.001v5.3387a1 1.0002 0 0 1 -1 1.0001 1 1.0002 0 0 1 -1 -1.0001v-8.0014a1.0001 1.0003 0 0 1 1.752 -0.6583l5.248 6.001v-5.3427a1 1.0002 0 0 1 1 -1.0001zm-15 0c2.7496 0 5 2.2507 5 5.0008s-2.2504 5.0008-5 5.0008-5-2.2507-5-5.0008 2.2504-5.0008 5-5.0008zm0 2.0003c-1.6687 0-3 1.3315-3 3.0005s1.3313 3.0005 3 3.0005 3-1.3315 3-3.0005-1.3313-3.0005-3-3.0005z" color="#000000" color-rendering="auto" dominant-baseline="auto" fill="#e0e0e0" fill-opacity=".78431" image-rendering="auto" shape-rendering="auto" solid-color="#000000" style="font-feature-settings:normal;font-variant-alternates:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal;font-variant-position:normal;isolation:auto;mix-blend-mode:normal;shape-padding:0;text-decoration-color:#000000;text-decoration-line:none;text-decoration-style:solid;text-indent:0;text-orientation:mixed;text-transform:none;white-space:normal"/> </g> </svg> diff --git a/editor/import_dock.cpp b/editor/import_dock.cpp index e52f3bab72..df4254e2a3 100644 --- a/editor/import_dock.cpp +++ b/editor/import_dock.cpp @@ -263,6 +263,14 @@ void ImportDock::set_edit_multiple_paths(const Vector<String> &p_paths) { imported->set_text(itos(p_paths.size()) + TTR(" Files")); } +void ImportDock::_importer_selected(int i_idx) { + String name = import_as->get_selected_metadata(); + Ref<ResourceImporter> importer = ResourceFormatImporter::get_singleton()->get_importer_by_name(name); + ERR_FAIL_COND(importer.is_null()); + + params->importer = importer; +} + void ImportDock::_preset_selected(int p_idx) { int item_id = preset->get_popup()->get_item_id(p_idx); @@ -336,6 +344,7 @@ void ImportDock::_reimport() { Error err = config->load(params->paths[i] + ".import"); ERR_CONTINUE(err != OK); + config->set_value("remap", "importer", params->importer->get_importer_name()); config->erase_section("params"); for (List<PropertyInfo>::Element *E = params->properties.front(); E; E = E->next()) { @@ -367,6 +376,7 @@ void ImportDock::_bind_methods() { ClassDB::bind_method(D_METHOD("_reimport"), &ImportDock::_reimport); ClassDB::bind_method(D_METHOD("_preset_selected"), &ImportDock::_preset_selected); + ClassDB::bind_method(D_METHOD("_importer_selected"), &ImportDock::_importer_selected); } void ImportDock::initialize_import_options() const { @@ -384,6 +394,7 @@ ImportDock::ImportDock() { HBoxContainer *hb = memnew(HBoxContainer); add_margin_child(TTR("Import As:"), hb); import_as = memnew(OptionButton); + import_as->connect("item_selected", this, "_importer_selected"); hb->add_child(import_as); import_as->set_h_size_flags(SIZE_EXPAND_FILL); preset = memnew(MenuButton); diff --git a/editor/import_dock.h b/editor/import_dock.h index 029c458320..a9bb22e568 100644 --- a/editor/import_dock.h +++ b/editor/import_dock.h @@ -54,6 +54,7 @@ class ImportDock : public VBoxContainer { ImportDockParameters *params; void _preset_selected(int p_idx); + void _importer_selected(int i_idx); void _reimport(); diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 3807c8961a..38467369db 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -3623,7 +3623,7 @@ void CanvasItemEditor::_popup_callback(int p_op) { if (key_pos) AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(n2d, "position", n2d->get_position(), existing); if (key_rot) - AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(n2d, "rotation_deg", Math::rad2deg(n2d->get_rotation()), existing); + AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(n2d, "rotation_degrees", Math::rad2deg(n2d->get_rotation()), existing); if (key_scale) AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(n2d, "scale", n2d->get_scale(), existing); @@ -3654,7 +3654,7 @@ void CanvasItemEditor::_popup_callback(int p_op) { if (key_pos) AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(F->get(), "position", F->get()->get_position(), existing); if (key_rot) - AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(F->get(), "rotation_deg", Math::rad2deg(F->get()->get_rotation()), existing); + AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(F->get(), "rotation_degrees", Math::rad2deg(F->get()->get_rotation()), existing); if (key_scale) AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(F->get(), "scale", F->get()->get_scale(), existing); } @@ -3668,7 +3668,7 @@ void CanvasItemEditor::_popup_callback(int p_op) { if (key_pos) AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(ctrl, "rect_position", ctrl->get_position(), existing); if (key_rot) - AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(ctrl, "rect_rotation", ctrl->get_rotation_deg(), existing); + AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(ctrl, "rect_rotation", ctrl->get_rotation_degrees(), existing); if (key_scale) AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(ctrl, "rect_size", ctrl->get_size(), existing); } @@ -4373,11 +4373,11 @@ void CanvasItemEditorViewport::_on_mouse_exit() { void CanvasItemEditorViewport::_on_select_type(Object *selected) { CheckBox *check = Object::cast_to<CheckBox>(selected); String type = check->get_text(); - selector_label->set_text(vformat(TTR("Add %s"), type)); + selector->set_title(vformat(TTR("Add %s"), type)); label->set_text(vformat(TTR("Adding %s..."), type)); } -void CanvasItemEditorViewport::_on_change_type() { +void CanvasItemEditorViewport::_on_change_type_confirmed() { if (!button_group->get_pressed_button()) return; @@ -4387,6 +4387,11 @@ void CanvasItemEditorViewport::_on_change_type() { selector->hide(); } +void CanvasItemEditorViewport::_on_change_type_closed() { + + _remove_preview(); +} + void CanvasItemEditorViewport::_create_preview(const Vector<String> &files) const { label->set_position(get_global_position() + Point2(14, 14) * EDSCALE); label_desc->set_position(label->get_position() + Point2(0, label->get_size().height)); @@ -4698,7 +4703,7 @@ void CanvasItemEditorViewport::drop_data(const Point2 &p_point, const Variant &p CheckBox *check = Object::cast_to<CheckBox>(btn_list[i]); check->set_pressed(check->get_text() == default_type); } - selector_label->set_text(vformat(TTR("Add %s"), default_type)); + selector->set_title(vformat(TTR("Add %s"), default_type)); selector->popup_centered_minsize(); } else { _perform_drop_data(); @@ -4721,7 +4726,8 @@ void CanvasItemEditorViewport::_notification(int p_what) { void CanvasItemEditorViewport::_bind_methods() { ClassDB::bind_method(D_METHOD("_on_select_type"), &CanvasItemEditorViewport::_on_select_type); - ClassDB::bind_method(D_METHOD("_on_change_type"), &CanvasItemEditorViewport::_on_change_type); + ClassDB::bind_method(D_METHOD("_on_change_type_confirmed"), &CanvasItemEditorViewport::_on_change_type_confirmed); + ClassDB::bind_method(D_METHOD("_on_change_type_closed"), &CanvasItemEditorViewport::_on_change_type_closed); ClassDB::bind_method(D_METHOD("_on_mouse_exit"), &CanvasItemEditorViewport::_on_mouse_exit); } @@ -4749,7 +4755,8 @@ CanvasItemEditorViewport::CanvasItemEditorViewport(EditorNode *p_node, CanvasIte selector = memnew(AcceptDialog); editor->get_gui_base()->add_child(selector); selector->set_title(TTR("Change default type")); - selector->connect("confirmed", this, "_on_change_type"); + selector->connect("confirmed", this, "_on_change_type_confirmed"); + selector->connect("popup_hide", this, "_on_change_type_closed"); VBoxContainer *vbc = memnew(VBoxContainer); selector->add_child(vbc); @@ -4757,12 +4764,6 @@ CanvasItemEditorViewport::CanvasItemEditorViewport(EditorNode *p_node, CanvasIte vbc->set_v_size_flags(SIZE_EXPAND_FILL); vbc->set_custom_minimum_size(Size2(200, 260) * EDSCALE); - selector_label = memnew(Label); - vbc->add_child(selector_label); - selector_label->set_align(Label::ALIGN_CENTER); - selector_label->set_valign(Label::VALIGN_BOTTOM); - selector_label->set_custom_minimum_size(Size2(0, 30) * EDSCALE); - btn_group = memnew(VBoxContainer); vbc->add_child(btn_group); btn_group->set_h_size_flags(0); diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h index 97e3b03569..457833e1a7 100644 --- a/editor/plugins/canvas_item_editor_plugin.h +++ b/editor/plugins/canvas_item_editor_plugin.h @@ -568,7 +568,8 @@ class CanvasItemEditorViewport : public Control { void _on_mouse_exit(); void _on_select_type(Object *selected); - void _on_change_type(); + void _on_change_type_confirmed(); + void _on_change_type_closed(); void _create_preview(const Vector<String> &files) const; void _remove_preview(); diff --git a/editor/plugins/resource_preloader_editor_plugin.cpp b/editor/plugins/resource_preloader_editor_plugin.cpp index d421b3798b..3210af1433 100644 --- a/editor/plugins/resource_preloader_editor_plugin.cpp +++ b/editor/plugins/resource_preloader_editor_plugin.cpp @@ -43,7 +43,7 @@ void ResourcePreloaderEditor::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE) { load->set_icon(get_icon("Folder", "EditorIcons")); - _delete->set_icon(get_icon("Del", "EditorIcons")); + _delete->set_icon(get_icon("Remove", "EditorIcons")); } if (p_what == NOTIFICATION_READY) { diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp index e8714cece6..cc144344a6 100644 --- a/editor/plugins/spatial_editor_plugin.cpp +++ b/editor/plugins/spatial_editor_plugin.cpp @@ -2917,7 +2917,9 @@ bool SpatialEditorViewport::_create_instance(Node *parent, String &path, const P } } - instanced_scene->set_filename(ProjectSettings::get_singleton()->localize_path(path)); + if (scene != NULL) { + instanced_scene->set_filename(ProjectSettings::get_singleton()->localize_path(path)); + } editor_data->get_undo_redo().add_do_method(parent, "add_child", instanced_scene); editor_data->get_undo_redo().add_do_method(instanced_scene, "set_owner", editor->get_edited_scene()); diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp index b21c176543..926f26af14 100644 --- a/editor/project_settings_editor.cpp +++ b/editor/project_settings_editor.cpp @@ -1318,7 +1318,7 @@ void ProjectSettingsEditor::_update_translations() { t->set_text(0, translations[i].replace_first("res://", "")); t->set_tooltip(0, translations[i]); t->set_metadata(0, i); - t->add_button(0, get_icon("Del", "EditorIcons"), 0, false, TTR("Remove")); + t->add_button(0, get_icon("Remove", "EditorIcons"), 0, false, TTR("Remove")); } } @@ -1436,7 +1436,7 @@ void ProjectSettingsEditor::_update_translations() { t->set_text(0, keys[i].replace_first("res://", "")); t->set_tooltip(0, keys[i]); t->set_metadata(0, keys[i]); - t->add_button(0, get_icon("Del", "EditorIcons"), 0, false, TTR("Remove")); + t->add_button(0, get_icon("Remove", "EditorIcons"), 0, false, TTR("Remove")); if (keys[i] == remap_selected) { t->select(0); translation_res_option_add_button->set_disabled(false); @@ -1454,7 +1454,7 @@ void ProjectSettingsEditor::_update_translations() { t2->set_text(0, path.replace_first("res://", "")); t2->set_tooltip(0, path); t2->set_metadata(0, j); - t2->add_button(0, get_icon("Del", "EditorIcons"), 0, false, TTR("Remove")); + t2->add_button(0, get_icon("Remove", "EditorIcons"), 0, false, TTR("Remove")); t2->set_cell_mode(1, TreeItem::CELL_MODE_RANGE); t2->set_text(1, langnames); t2->set_editable(1, true); @@ -1782,6 +1782,7 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) { tab_container->add_child(translations); //remap for properly select language in popup translation_locales_idxs_remap = Vector<int>(); + translation_locales_list_created = false; { diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp index c19b80e649..0f1712c224 100644 --- a/editor/script_create_dialog.cpp +++ b/editor/script_create_dialog.cpp @@ -703,9 +703,7 @@ ScriptCreateDialog::ScriptCreateDialog() { internal = memnew(CheckButton); internal->connect("pressed", this, "_built_in_pressed"); hb = memnew(HBoxContainer); - Control *empty = memnew(Control); hb->add_child(internal); - hb->add_child(empty); l = memnew(Label); l->set_text(TTR("Built-in Script")); l->set_align(Label::ALIGN_RIGHT); diff --git a/modules/gdscript/gd_editor.cpp b/modules/gdscript/gd_editor.cpp index de8e35c406..346b7d326a 100644 --- a/modules/gdscript/gd_editor.cpp +++ b/modules/gdscript/gd_editor.cpp @@ -337,6 +337,11 @@ void GDScriptLanguage::get_public_constants(List<Pair<String, Variant> > *p_cons pi.second = Math_PI; p_constants->push_back(pi); + Pair<String, Variant> tau; + tau.first = "TAU"; + tau.second = Math_TAU; + p_constants->push_back(tau); + Pair<String, Variant> infinity; infinity.first = "INF"; infinity.second = Math_INF; @@ -2771,31 +2776,31 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol } //global - for (Map<StringName, int>::Element *E = GDScriptLanguage::get_singleton()->get_global_map().front(); E; E = E->next()) { - if (E->key() == p_symbol) { - - Variant value = GDScriptLanguage::get_singleton()->get_global_array()[E->get()]; - if (value.get_type() == Variant::OBJECT) { - Object *obj = value; - if (obj) { - - if (Object::cast_to<GDNativeClass>(obj)) { - r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS; - r_result.class_name = Object::cast_to<GDNativeClass>(obj)->get_name(); - - } else { - r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS; - r_result.class_name = obj->get_class(); - } - return OK; + Map<StringName, int> classes = GDScriptLanguage::get_singleton()->get_global_map(); + if (classes.has(p_symbol)) { + Variant value = GDScriptLanguage::get_singleton()->get_global_array()[classes[p_symbol]]; + if (value.get_type() == Variant::OBJECT) { + Object *obj = value; + if (obj) { + if (Object::cast_to<GDNativeClass>(obj)) { + r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS; + r_result.class_name = Object::cast_to<GDNativeClass>(obj)->get_name(); + } else { + r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS; + r_result.class_name = obj->get_class(); } - } else { - r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS_CONSTANT; - r_result.class_name = "@Global Scope"; - r_result.class_member = p_symbol; + // proxy class remove the underscore. + if (r_result.class_name.begins_with("_")) { + r_result.class_name = r_result.class_name.right(1); + } return OK; } + } else { + r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS_CONSTANT; + r_result.class_name = "@Global Scope"; + r_result.class_member = p_symbol; + return OK; } } } diff --git a/modules/gdscript/gd_parser.cpp b/modules/gdscript/gd_parser.cpp index 94385dc0d0..d7e83c3a33 100644 --- a/modules/gdscript/gd_parser.cpp +++ b/modules/gdscript/gd_parser.cpp @@ -362,6 +362,13 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool constant->value = Math_PI; tokenizer->advance(); expr = constant; + } else if (tokenizer->get_token() == GDTokenizer::TK_CONST_TAU) { + + //constant defined by tokenizer + ConstantNode *constant = alloc_node<ConstantNode>(); + constant->value = Math_TAU; + tokenizer->advance(); + expr = constant; } else if (tokenizer->get_token() == GDTokenizer::TK_CONST_INF) { //constant defined by tokenizer diff --git a/modules/gdscript/gd_script.cpp b/modules/gdscript/gd_script.cpp index 3f3818ffb9..e5016c59bd 100644 --- a/modules/gdscript/gd_script.cpp +++ b/modules/gdscript/gd_script.cpp @@ -1324,6 +1324,7 @@ void GDScriptLanguage::init() { } _add_global(StaticCString::create("PI"), Math_PI); + _add_global(StaticCString::create("TAU"), Math_TAU); _add_global(StaticCString::create("INF"), Math_INF); _add_global(StaticCString::create("NAN"), Math_NAN); @@ -1700,6 +1701,7 @@ void GDScriptLanguage::get_reserved_words(List<String> *p_words) const { "bool", "null", "PI", + "TAU", "INF", "NAN", "self", diff --git a/modules/gdscript/gd_tokenizer.cpp b/modules/gdscript/gd_tokenizer.cpp index 5f85158232..98ac0f473d 100644 --- a/modules/gdscript/gd_tokenizer.cpp +++ b/modules/gdscript/gd_tokenizer.cpp @@ -123,6 +123,7 @@ const char *GDTokenizer::token_names[TK_MAX] = { "'$'", "'\\n'", "PI", + "TAU", "_", "INF", "NAN", @@ -217,6 +218,7 @@ static const _kws _keyword_list[] = { { GDTokenizer::TK_CF_PASS, "pass" }, { GDTokenizer::TK_SELF, "self" }, { GDTokenizer::TK_CONST_PI, "PI" }, + { GDTokenizer::TK_CONST_TAU, "TAU" }, { GDTokenizer::TK_WILDCARD, "_" }, { GDTokenizer::TK_CONST_INF, "INF" }, { GDTokenizer::TK_CONST_NAN, "NAN" }, @@ -280,6 +282,7 @@ bool GDTokenizer::is_token_literal(int p_offset, bool variable_safe) const { case TK_CF_PASS: case TK_SELF: case TK_CONST_PI: + case TK_CONST_TAU: case TK_WILDCARD: case TK_CONST_INF: case TK_CONST_NAN: diff --git a/modules/gdscript/gd_tokenizer.h b/modules/gdscript/gd_tokenizer.h index c935ce45a1..f4b579def4 100644 --- a/modules/gdscript/gd_tokenizer.h +++ b/modules/gdscript/gd_tokenizer.h @@ -128,6 +128,7 @@ public: TK_DOLLAR, TK_NEWLINE, TK_CONST_PI, + TK_CONST_TAU, TK_WILDCARD, TK_CONST_INF, TK_CONST_NAN, diff --git a/modules/mobile_vr/mobile_interface.cpp b/modules/mobile_vr/mobile_interface.cpp index 93d5c22ef8..dccdcd3070 100644 --- a/modules/mobile_vr/mobile_interface.cpp +++ b/modules/mobile_vr/mobile_interface.cpp @@ -156,17 +156,6 @@ void MobileVRInterface::set_position_from_sensors() { has_gyro = true; }; -#ifdef ANDROID_ENABLED - ///@TODO needs testing, i don't have a gyro, potentially can be removed depending on what comes out of issue #8101 - // On Android x and z axis seem inverted - gyro.x = -gyro.x; - gyro.z = -gyro.z; - grav.x = -grav.x; - grav.z = -grav.z; - magneto.x = -magneto.x; - magneto.z = -magneto.z; -#endif - if (has_gyro) { // start with applying our gyro (do NOT smooth our gyro!) Basis rotate; diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp index 03015df844..15e20effc0 100644 --- a/modules/visual_script/visual_script_editor.cpp +++ b/modules/visual_script/visual_script_editor.cpp @@ -2764,6 +2764,23 @@ void VisualScriptEditor::_default_value_edited(Node *p_button, int p_id, int p_i default_value_edit->set_position(Object::cast_to<Control>(p_button)->get_global_position() + Vector2(0, Object::cast_to<Control>(p_button)->get_size().y)); default_value_edit->set_size(Size2(1, 1)); + + if (pinfo.type == Variant::NODE_PATH) { + + Node *edited_scene = get_tree()->get_edited_scene_root(); + Node *script_node = _find_script_node(edited_scene, edited_scene, script); + + if (script_node) { + //pick a node relative to the script, IF the script exists + pinfo.hint = PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE; + pinfo.hint_string = script_node->get_path(); + } else { + //pick a path relative to edited scene + pinfo.hint = PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE; + pinfo.hint_string = get_tree()->get_edited_scene_root()->get_path(); + } + } + if (default_value_edit->edit(NULL, pinfo.name, pinfo.type, existing, pinfo.hint, pinfo.hint_string)) { if (pinfo.hint == PROPERTY_HINT_MULTILINE_TEXT) default_value_edit->popup_centered_ratio(); diff --git a/modules/visual_script/visual_script_expression.cpp b/modules/visual_script/visual_script_expression.cpp index 897e910f20..07dca4b904 100644 --- a/modules/visual_script/visual_script_expression.cpp +++ b/modules/visual_script/visual_script_expression.cpp @@ -564,6 +564,9 @@ Error VisualScriptExpression::_get_token(Token &r_token) { } else if (id == "PI") { r_token.type = TK_CONSTANT; r_token.value = Math_PI; + } else if (id == "TAU") { + r_token.type = TK_CONSTANT; + r_token.value = Math_TAU; } else if (id == "INF") { r_token.type = TK_CONSTANT; r_token.value = Math_INF; diff --git a/modules/visual_script/visual_script_nodes.cpp b/modules/visual_script/visual_script_nodes.cpp index d3cd839cf3..3863fa7e1c 100644 --- a/modules/visual_script/visual_script_nodes.cpp +++ b/modules/visual_script/visual_script_nodes.cpp @@ -1776,8 +1776,8 @@ VisualScriptBasicTypeConstant::VisualScriptBasicTypeConstant() { const char *VisualScriptMathConstant::const_name[MATH_CONSTANT_MAX] = { "One", "PI", - "PIx2", "PI/2", + "TAU", "E", "Sqrt2", "INF", @@ -1787,8 +1787,8 @@ const char *VisualScriptMathConstant::const_name[MATH_CONSTANT_MAX] = { double VisualScriptMathConstant::const_value[MATH_CONSTANT_MAX] = { 1.0, Math_PI, - Math_PI * 2, Math_PI * 0.5, + Math_TAU, 2.71828182845904523536, Math::sqrt(2.0), Math_INF, @@ -1886,8 +1886,8 @@ void VisualScriptMathConstant::_bind_methods() { BIND_ENUM_CONSTANT(MATH_CONSTANT_ONE); BIND_ENUM_CONSTANT(MATH_CONSTANT_PI); - BIND_ENUM_CONSTANT(MATH_CONSTANT_2PI); BIND_ENUM_CONSTANT(MATH_CONSTANT_HALF_PI); + BIND_ENUM_CONSTANT(MATH_CONSTANT_TAU); BIND_ENUM_CONSTANT(MATH_CONSTANT_E); BIND_ENUM_CONSTANT(MATH_CONSTANT_SQRT2); BIND_ENUM_CONSTANT(MATH_CONSTANT_INF); diff --git a/modules/visual_script/visual_script_nodes.h b/modules/visual_script/visual_script_nodes.h index 421409b265..6648f57e7b 100644 --- a/modules/visual_script/visual_script_nodes.h +++ b/modules/visual_script/visual_script_nodes.h @@ -474,8 +474,8 @@ public: enum MathConstant { MATH_CONSTANT_ONE, MATH_CONSTANT_PI, - MATH_CONSTANT_2PI, MATH_CONSTANT_HALF_PI, + MATH_CONSTANT_TAU, MATH_CONSTANT_E, MATH_CONSTANT_SQRT2, MATH_CONSTANT_INF, diff --git a/platform/android/godot_android.cpp b/platform/android/godot_android.cpp index 8235683496..abe5e3b77a 100644 --- a/platform/android/godot_android.cpp +++ b/platform/android/godot_android.cpp @@ -669,6 +669,14 @@ static void engine_handle_cmd(struct android_app *app, int32_t cmd) { ASensorEventQueue_setEventRate(engine->sensorEventQueue, engine->accelerometerSensor, (1000L / 60) * 1000); } + // start monitoring gravity + if (engine->gravitySensor != NULL) { + ASensorEventQueue_enableSensor(engine->sensorEventQueue, + engine->gravitySensor); + // We'd like to get 60 events per second (in us). + ASensorEventQueue_setEventRate(engine->sensorEventQueue, + engine->gravitySensor, (1000L / 60) * 1000); + } // Also start monitoring the magnetometer. if (engine->magnetometerSensor != NULL) { ASensorEventQueue_enableSensor(engine->sensorEventQueue, @@ -694,6 +702,10 @@ static void engine_handle_cmd(struct android_app *app, int32_t cmd) { ASensorEventQueue_disableSensor(engine->sensorEventQueue, engine->accelerometerSensor); } + if (engine->gravitySensor != NULL) { + ASensorEventQueue_disableSensor(engine->sensorEventQueue, + engine->gravitySensor); + } if (engine->magnetometerSensor != NULL) { ASensorEventQueue_disableSensor(engine->sensorEventQueue, engine->magnetometerSensor); @@ -729,6 +741,8 @@ void android_main(struct android_app *app) { engine.sensorManager = ASensorManager_getInstance(); engine.accelerometerSensor = ASensorManager_getDefaultSensor(engine.sensorManager, ASENSOR_TYPE_ACCELEROMETER); + engine.gravitySensor = ASensorManager_getDefaultSensor(engine.sensorManager, + ASENSOR_TYPE_GRAVITY); engine.magnetometerSensor = ASensorManager_getDefaultSensor(engine.sensorManager, ASENSOR_TYPE_MAGNETIC_FIELD); engine.gyroscopeSensor = ASensorManager_getDefaultSensor(engine.sensorManager, diff --git a/platform/android/java/src/org/godotengine/godot/Godot.java b/platform/android/java/src/org/godotengine/godot/Godot.java index 59fefc498f..41dcba5c2c 100644 --- a/platform/android/java/src/org/godotengine/godot/Godot.java +++ b/platform/android/java/src/org/godotengine/godot/Godot.java @@ -219,6 +219,7 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC private SensorManager mSensorManager; private Sensor mAccelerometer; + private Sensor mGravity; private Sensor mMagnetometer; private Sensor mGyroscope; @@ -435,6 +436,8 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_GAME); + mGravity = mSensorManager.getDefaultSensor(Sensor.TYPE_GRAVITY); + mSensorManager.registerListener(this, mGravity, SensorManager.SENSOR_DELAY_GAME); mMagnetometer = mSensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD); mSensorManager.registerListener(this, mMagnetometer, SensorManager.SENSOR_DELAY_GAME); mGyroscope = mSensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE); @@ -667,6 +670,7 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC } }); mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_GAME); + mSensorManager.registerListener(this, mGravity, SensorManager.SENSOR_DELAY_GAME); mSensorManager.registerListener(this, mMagnetometer, SensorManager.SENSOR_DELAY_GAME); mSensorManager.registerListener(this, mGyroscope, SensorManager.SENSOR_DELAY_GAME); @@ -734,13 +738,16 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC @Override public void run() { if (typeOfSensor == Sensor.TYPE_ACCELEROMETER) { - GodotLib.accelerometer(x,y,z); + GodotLib.accelerometer(-x,y,-z); + } + if (typeOfSensor == Sensor.TYPE_GRAVITY) { + GodotLib.gravity(-x,y,-z); } if (typeOfSensor == Sensor.TYPE_MAGNETIC_FIELD) { - GodotLib.magnetometer(x,y,z); + GodotLib.magnetometer(-x,y,-z); } if (typeOfSensor == Sensor.TYPE_GYROSCOPE) { - GodotLib.gyroscope(x,y,z); + GodotLib.gyroscope(x,-y,z); } } }); diff --git a/platform/android/java/src/org/godotengine/godot/GodotLib.java b/platform/android/java/src/org/godotengine/godot/GodotLib.java index e0ed4cd38c..6b84ad6555 100644 --- a/platform/android/java/src/org/godotengine/godot/GodotLib.java +++ b/platform/android/java/src/org/godotengine/godot/GodotLib.java @@ -53,6 +53,7 @@ public class GodotLib { public static native void step(); public static native void touch(int what,int pointer,int howmany, int[] arr); public static native void accelerometer(float x, float y, float z); + public static native void gravity(float x, float y, float z); public static native void magnetometer(float x, float y, float z); public static native void gyroscope(float x, float y, float z); public static native void key(int p_scancode, int p_unicode_char, boolean p_pressed); diff --git a/platform/android/java_glue.cpp b/platform/android/java_glue.cpp index 0b193f5882..87f20bee91 100644 --- a/platform/android/java_glue.cpp +++ b/platform/android/java_glue.cpp @@ -608,6 +608,7 @@ static bool resized = false; static bool resized_reload = false; static Size2 new_size; static Vector3 accelerometer; +static Vector3 gravity; static Vector3 magnetometer; static Vector3 gyroscope; static HashMap<String, JNISingleton *> jni_singletons; @@ -1012,6 +1013,8 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_step(JNIEnv *env, job os_android->process_accelerometer(accelerometer); + os_android->process_gravity(gravity); + os_android->process_magnetometer(magnetometer); os_android->process_gyroscope(gyroscope); @@ -1386,6 +1389,10 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_accelerometer(JNIEnv accelerometer = Vector3(x, y, z); } +JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_gravity(JNIEnv *env, jobject obj, jfloat x, jfloat y, jfloat z) { + gravity = Vector3(x, y, z); +} + JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_magnetometer(JNIEnv *env, jobject obj, jfloat x, jfloat y, jfloat z) { magnetometer = Vector3(x, y, z); } diff --git a/platform/android/java_glue.h b/platform/android/java_glue.h index 0aa2489813..4790c65617 100644 --- a/platform/android/java_glue.h +++ b/platform/android/java_glue.h @@ -50,6 +50,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joyhat(JNIEnv *env, j JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joyconnectionchanged(JNIEnv *env, jobject obj, jint p_device, jboolean p_connected, jstring p_name); JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_audio(JNIEnv *env, jobject obj); JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_accelerometer(JNIEnv *env, jobject obj, jfloat x, jfloat y, jfloat z); +JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_gravity(JNIEnv *env, jobject obj, jfloat x, jfloat y, jfloat z); JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_magnetometer(JNIEnv *env, jobject obj, jfloat x, jfloat y, jfloat z); JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_gyroscope(JNIEnv *env, jobject obj, jfloat x, jfloat y, jfloat z); JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_focusin(JNIEnv *env, jobject obj); diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp index 970e0cdf68..a36df0675c 100644 --- a/platform/android/os_android.cpp +++ b/platform/android/os_android.cpp @@ -490,6 +490,11 @@ void OS_Android::process_accelerometer(const Vector3 &p_accelerometer) { input->set_accelerometer(p_accelerometer); } +void OS_Android::process_gravity(const Vector3 &p_gravity) { + + input->set_gravity(p_gravity); +} + void OS_Android::process_magnetometer(const Vector3 &p_magnetometer) { input->set_magnetometer(p_magnetometer); diff --git a/platform/android/os_android.h b/platform/android/os_android.h index fee91b9a55..750afa7a14 100644 --- a/platform/android/os_android.h +++ b/platform/android/os_android.h @@ -219,6 +219,7 @@ public: virtual String get_system_dir(SystemDir p_dir) const; void process_accelerometer(const Vector3 &p_accelerometer); + void process_gravity(const Vector3 &p_gravity); void process_magnetometer(const Vector3 &p_magnetometer); void process_gyroscope(const Vector3 &p_gyroscope); void process_touch(int p_what, int p_pointer, const Vector<TouchPos> &p_points); diff --git a/scene/2d/node_2d.cpp b/scene/2d/node_2d.cpp index b6111e9765..c562a4652d 100644 --- a/scene/2d/node_2d.cpp +++ b/scene/2d/node_2d.cpp @@ -65,7 +65,7 @@ void Node2D::edit_set_state(const Variant &p_state) { _scale = state[2]; _update_transform(); _change_notify("rotation"); - _change_notify("rotation_deg"); + _change_notify("rotation_degrees"); _change_notify("scale"); _change_notify("position"); } @@ -106,7 +106,7 @@ void Node2D::edit_rotate(float p_rot) { angle += p_rot; _update_transform(); _change_notify("rotation"); - _change_notify("rotation_deg"); + _change_notify("rotation_degrees"); } void Node2D::_update_xform_values() { @@ -147,10 +147,10 @@ void Node2D::set_rotation(float p_radians) { angle = p_radians; _update_transform(); _change_notify("rotation"); - _change_notify("rotation_deg"); + _change_notify("rotation_degrees"); } -void Node2D::set_rotation_in_degrees(float p_degrees) { +void Node2D::set_rotation_degrees(float p_degrees) { set_rotation(Math::deg2rad(p_degrees)); } @@ -182,7 +182,7 @@ float Node2D::get_rotation() const { return angle; } -float Node2D::get_rotation_in_degrees() const { +float Node2D::get_rotation_degrees() const { return Math::rad2deg(get_rotation()); } @@ -287,12 +287,12 @@ void Node2D::set_global_rotation(float p_radians) { } } -float Node2D::get_global_rotation_in_degrees() const { +float Node2D::get_global_rotation_degrees() const { return Math::rad2deg(get_global_rotation()); } -void Node2D::set_global_rotation_in_degrees(float p_degrees) { +void Node2D::set_global_rotation_degrees(float p_degrees) { set_global_rotation(Math::deg2rad(p_degrees)); } @@ -400,12 +400,12 @@ void Node2D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_position", "position"), &Node2D::set_position); ClassDB::bind_method(D_METHOD("set_rotation", "radians"), &Node2D::set_rotation); - ClassDB::bind_method(D_METHOD("set_rotation_in_degrees", "degrees"), &Node2D::set_rotation_in_degrees); + ClassDB::bind_method(D_METHOD("set_rotation_degrees", "degrees"), &Node2D::set_rotation_degrees); ClassDB::bind_method(D_METHOD("set_scale", "scale"), &Node2D::set_scale); ClassDB::bind_method(D_METHOD("get_position"), &Node2D::get_position); ClassDB::bind_method(D_METHOD("get_rotation"), &Node2D::get_rotation); - ClassDB::bind_method(D_METHOD("get_rotation_in_degrees"), &Node2D::get_rotation_in_degrees); + ClassDB::bind_method(D_METHOD("get_rotation_degrees"), &Node2D::get_rotation_degrees); ClassDB::bind_method(D_METHOD("get_scale"), &Node2D::get_scale); ClassDB::bind_method(D_METHOD("rotate", "radians"), &Node2D::rotate); @@ -419,8 +419,8 @@ void Node2D::_bind_methods() { ClassDB::bind_method(D_METHOD("get_global_position"), &Node2D::get_global_position); ClassDB::bind_method(D_METHOD("set_global_rotation", "radians"), &Node2D::set_global_rotation); ClassDB::bind_method(D_METHOD("get_global_rotation"), &Node2D::get_global_rotation); - ClassDB::bind_method(D_METHOD("set_global_rotation_in_degrees", "degrees"), &Node2D::set_global_rotation_in_degrees); - ClassDB::bind_method(D_METHOD("get_global_rotation_in_degrees"), &Node2D::get_global_rotation_in_degrees); + ClassDB::bind_method(D_METHOD("set_global_rotation_degrees", "degrees"), &Node2D::set_global_rotation_degrees); + ClassDB::bind_method(D_METHOD("get_global_rotation_degrees"), &Node2D::get_global_rotation_degrees); ClassDB::bind_method(D_METHOD("set_global_scale", "scale"), &Node2D::set_global_scale); ClassDB::bind_method(D_METHOD("get_global_scale"), &Node2D::get_global_scale); @@ -446,13 +446,13 @@ void Node2D::_bind_methods() { ADD_GROUP("Transform", ""); ADD_PROPERTYNZ(PropertyInfo(Variant::VECTOR2, "position"), "set_position", "get_position"); ADD_PROPERTYNZ(PropertyInfo(Variant::REAL, "rotation", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_rotation", "get_rotation"); - ADD_PROPERTYNZ(PropertyInfo(Variant::REAL, "rotation_deg", PROPERTY_HINT_RANGE, "-1440,1440,0.1", PROPERTY_USAGE_EDITOR), "set_rotation_in_degrees", "get_rotation_in_degrees"); + ADD_PROPERTYNZ(PropertyInfo(Variant::REAL, "rotation_degrees", PROPERTY_HINT_RANGE, "-1440,1440,0.1", PROPERTY_USAGE_EDITOR), "set_rotation_degrees", "get_rotation_degrees"); ADD_PROPERTYNO(PropertyInfo(Variant::VECTOR2, "scale"), "set_scale", "get_scale"); ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM2D, "transform", PROPERTY_HINT_NONE, "", 0), "set_transform", "get_transform"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "global_position", PROPERTY_HINT_NONE, "", 0), "set_global_position", "get_global_position"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "global_rotation", PROPERTY_HINT_NONE, "", 0), "set_global_rotation", "get_global_rotation"); - ADD_PROPERTY(PropertyInfo(Variant::REAL, "global_rotation_deg", PROPERTY_HINT_NONE, "", 0), "set_global_rotation_in_degrees", "get_global_rotation_in_degrees"); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "global_rotation_degrees", PROPERTY_HINT_NONE, "", 0), "set_global_rotation_degrees", "get_global_rotation_degrees"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "global_scale", PROPERTY_HINT_NONE, "", 0), "set_global_scale", "get_global_scale"); ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM2D, "global_transform", PROPERTY_HINT_NONE, "", 0), "set_global_transform", "get_global_transform"); diff --git a/scene/2d/node_2d.h b/scene/2d/node_2d.h index 8890c829f8..eca1e96c82 100644 --- a/scene/2d/node_2d.h +++ b/scene/2d/node_2d.h @@ -66,7 +66,7 @@ public: void set_position(const Point2 &p_pos); void set_rotation(float p_radians); - void set_rotation_in_degrees(float p_degrees); + void set_rotation_degrees(float p_degrees); void set_scale(const Size2 &p_scale); void rotate(float p_radians); @@ -78,12 +78,12 @@ public: Point2 get_position() const; float get_rotation() const; - float get_rotation_in_degrees() const; + float get_rotation_degrees() const; Size2 get_scale() const; Point2 get_global_position() const; float get_global_rotation() const; - float get_global_rotation_in_degrees() const; + float get_global_rotation_degrees() const; Size2 get_global_scale() const; virtual Rect2 get_item_rect() const; @@ -91,7 +91,7 @@ public: void set_global_transform(const Transform2D &p_transform); void set_global_position(const Point2 &p_pos); void set_global_rotation(float p_radians); - void set_global_rotation_in_degrees(float p_degrees); + void set_global_rotation_degrees(float p_degrees); void set_global_scale(const Size2 &p_scale); void set_z(int p_z); diff --git a/scene/2d/polygon_2d.cpp b/scene/2d/polygon_2d.cpp index 197c74352e..b5b5445684 100644 --- a/scene/2d/polygon_2d.cpp +++ b/scene/2d/polygon_2d.cpp @@ -264,11 +264,11 @@ float Polygon2D::get_texture_rotation() const { return tex_rot; } -void Polygon2D::_set_texture_rotationd(float p_rot) { +void Polygon2D::set_texture_rotation_degrees(float p_rot) { set_texture_rotation(Math::deg2rad(p_rot)); } -float Polygon2D::_get_texture_rotationd() const { +float Polygon2D::get_texture_rotation_degrees() const { return Math::rad2deg(get_texture_rotation()); } @@ -348,8 +348,8 @@ void Polygon2D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_texture_rotation", "texture_rotation"), &Polygon2D::set_texture_rotation); ClassDB::bind_method(D_METHOD("get_texture_rotation"), &Polygon2D::get_texture_rotation); - ClassDB::bind_method(D_METHOD("_set_texture_rotationd", "texture_rotation"), &Polygon2D::_set_texture_rotationd); - ClassDB::bind_method(D_METHOD("_get_texture_rotationd"), &Polygon2D::_get_texture_rotationd); + ClassDB::bind_method(D_METHOD("set_texture_rotation_degrees", "texture_rotation"), &Polygon2D::set_texture_rotation_degrees); + ClassDB::bind_method(D_METHOD("get_texture_rotation_degrees"), &Polygon2D::get_texture_rotation_degrees); ClassDB::bind_method(D_METHOD("set_texture_scale", "texture_scale"), &Polygon2D::set_texture_scale); ClassDB::bind_method(D_METHOD("get_texture_scale"), &Polygon2D::get_texture_scale); @@ -377,7 +377,7 @@ void Polygon2D::_bind_methods() { ADD_GROUP("Texture", "texture_"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "texture_offset"), "set_texture_offset", "get_texture_offset"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "texture_scale"), "set_texture_scale", "get_texture_scale"); - ADD_PROPERTY(PropertyInfo(Variant::REAL, "texture_rotation", PROPERTY_HINT_RANGE, "-1440,1440,0.1"), "_set_texture_rotationd", "_get_texture_rotationd"); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "texture_rotation", PROPERTY_HINT_RANGE, "-1440,1440,0.1"), "set_texture_rotation_degrees", "get_texture_rotation_degrees"); ADD_GROUP("Invert", "invert_"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "invert_enable"), "set_invert", "get_invert"); diff --git a/scene/2d/polygon_2d.h b/scene/2d/polygon_2d.h index 20c3324a50..0c2c049c18 100644 --- a/scene/2d/polygon_2d.h +++ b/scene/2d/polygon_2d.h @@ -53,9 +53,6 @@ class Polygon2D : public Node2D { mutable bool rect_cache_dirty; mutable Rect2 item_rect; - void _set_texture_rotationd(float p_rot); - float _get_texture_rotationd() const; - protected: void _notification(int p_what); static void _bind_methods(); @@ -82,6 +79,9 @@ public: void set_texture_rotation(float p_rot); float get_texture_rotation() const; + void set_texture_rotation_degrees(float p_rot); + float get_texture_rotation_degrees() const; + void set_texture_scale(const Size2 &p_scale); Size2 get_texture_scale() const; diff --git a/scene/3d/particles.cpp b/scene/3d/particles.cpp index 040266843d..6ac6e52367 100644 --- a/scene/3d/particles.cpp +++ b/scene/3d/particles.cpp @@ -761,11 +761,11 @@ void ParticlesMaterial::_update_shader() { code += " force += length(diff) > 0.0 ? normalize(diff) * (radial_accel+tex_radial_accel)*mix(1.0,rand_from_seed(alt_seed),radial_accel_random) : vec3(0.0);\n"; code += " //apply tangential acceleration;\n"; if (flags[FLAG_DISABLE_Z]) { - code += " force += length(diff.yx) > 0.0 ? vec3(normalize(diff.yx * vec2(-1.0,1.0)),0.0) * ((tangent_accel+tex_tangent_accel)*mix(1.0,rand_from_seed(alt_seed),radial_accel_random)) : vec3(0.0);\n"; + code += " force += length(diff.yx) > 0.0 ? vec3(normalize(diff.yx * vec2(-1.0,1.0)),0.0) * ((tangent_accel+tex_tangent_accel)*mix(1.0,rand_from_seed(alt_seed),tangent_accel_random)) : vec3(0.0);\n"; } else { code += " vec3 crossDiff = cross(normalize(diff),normalize(gravity));\n"; - code += " force += length(crossDiff) > 0.0 ? normalize(crossDiff) * ((tangent_accel+tex_tangent_accel)*mix(1.0,rand_from_seed(alt_seed),radial_accel_random)) : vec3(0.0);\n"; + code += " force += length(crossDiff) > 0.0 ? normalize(crossDiff) * ((tangent_accel+tex_tangent_accel)*mix(1.0,rand_from_seed(alt_seed),tangent_accel_random)) : vec3(0.0);\n"; } code += " //apply attractor forces\n"; code += " VELOCITY += force * DELTA;\n"; diff --git a/scene/3d/spatial.cpp b/scene/3d/spatial.cpp index bc306481ce..588aa2881a 100644 --- a/scene/3d/spatial.cpp +++ b/scene/3d/spatial.cpp @@ -233,7 +233,7 @@ void Spatial::set_transform(const Transform &p_transform) { data.dirty |= DIRTY_VECTORS; _change_notify("translation"); _change_notify("rotation"); - _change_notify("rotation_deg"); + _change_notify("rotation_degrees"); _change_notify("scale"); _propagate_transform_changed(this); if (data.notify_local_transform) { @@ -327,7 +327,7 @@ void Spatial::set_rotation(const Vector3 &p_euler_rad) { } } -void Spatial::set_rotation_in_degrees(const Vector3 &p_euler_deg) { +void Spatial::set_rotation_degrees(const Vector3 &p_euler_deg) { set_rotation(p_euler_deg * Math_PI / 180.0); } @@ -364,7 +364,7 @@ Vector3 Spatial::get_rotation() const { return data.rotation; } -Vector3 Spatial::get_rotation_in_degrees() const { +Vector3 Spatial::get_rotation_degrees() const { return get_rotation() * 180.0 / Math_PI; } @@ -677,10 +677,10 @@ void Spatial::_bind_methods() { ClassDB::bind_method(D_METHOD("get_transform"), &Spatial::get_transform); ClassDB::bind_method(D_METHOD("set_translation", "translation"), &Spatial::set_translation); ClassDB::bind_method(D_METHOD("get_translation"), &Spatial::get_translation); - ClassDB::bind_method(D_METHOD("set_rotation", "rotation_rad"), &Spatial::set_rotation); + ClassDB::bind_method(D_METHOD("set_rotation", "radians"), &Spatial::set_rotation); ClassDB::bind_method(D_METHOD("get_rotation"), &Spatial::get_rotation); - ClassDB::bind_method(D_METHOD("set_rotation_deg", "rotation_deg"), &Spatial::set_rotation_in_degrees); - ClassDB::bind_method(D_METHOD("get_rotation_deg"), &Spatial::get_rotation_in_degrees); + ClassDB::bind_method(D_METHOD("set_rotation_degrees", "degrees"), &Spatial::set_rotation_degrees); + ClassDB::bind_method(D_METHOD("get_rotation_degrees"), &Spatial::get_rotation_degrees); ClassDB::bind_method(D_METHOD("set_scale", "scale"), &Spatial::set_scale); ClassDB::bind_method(D_METHOD("get_scale"), &Spatial::get_scale); ClassDB::bind_method(D_METHOD("set_global_transform", "global"), &Spatial::set_global_transform); @@ -746,7 +746,7 @@ void Spatial::_bind_methods() { ADD_PROPERTYNZ(PropertyInfo(Variant::TRANSFORM, "transform", PROPERTY_HINT_NONE, ""), "set_transform", "get_transform"); ADD_PROPERTYNZ(PropertyInfo(Variant::TRANSFORM, "global_transform", PROPERTY_HINT_NONE, "", 0), "set_global_transform", "get_global_transform"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "translation", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "set_translation", "get_translation"); - ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "rotation_deg", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "set_rotation_deg", "get_rotation_deg"); + ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "rotation_degrees", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "set_rotation_degrees", "get_rotation_degrees"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "rotation", PROPERTY_HINT_NONE, "", 0), "set_rotation", "get_rotation"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "scale", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "set_scale", "get_scale"); ADD_GROUP("Visibility", ""); diff --git a/scene/3d/spatial.h b/scene/3d/spatial.h index afac855de0..8f53b4a066 100644 --- a/scene/3d/spatial.h +++ b/scene/3d/spatial.h @@ -132,12 +132,12 @@ public: void set_translation(const Vector3 &p_translation); void set_rotation(const Vector3 &p_euler_rad); - void set_rotation_in_degrees(const Vector3 &p_euler_deg); + void set_rotation_degrees(const Vector3 &p_euler_deg); void set_scale(const Vector3 &p_scale); Vector3 get_translation() const; Vector3 get_rotation() const; - Vector3 get_rotation_in_degrees() const; + Vector3 get_rotation_degrees() const; Vector3 get_scale() const; void set_transform(const Transform &p_transform); diff --git a/scene/audio/audio_player.cpp b/scene/audio/audio_player.cpp index 058b162e83..08b01c6a4c 100644 --- a/scene/audio/audio_player.cpp +++ b/scene/audio/audio_player.cpp @@ -31,20 +31,7 @@ #include "engine.h" -void AudioStreamPlayer::_mix_audio() { - - if (!stream_playback.is_valid()) { - return; - } - - if (!active) { - return; - } - - if (setseek >= 0.0) { - stream_playback->start(setseek); - setseek = -1.0; //reset seek - } +void AudioStreamPlayer::_mix_internal(bool p_fadeout) { int bus_index = AudioServer::get_singleton()->thread_find_bus_index(bus); @@ -52,19 +39,24 @@ void AudioStreamPlayer::_mix_audio() { AudioFrame *buffer = mix_buffer.ptr(); int buffer_size = mix_buffer.size(); + if (p_fadeout) { + buffer_size = MIN(buffer_size, 16); //short fadeout ramp + } + //mix stream_playback->mix(buffer, 1.0, buffer_size); //multiply volume interpolating to avoid clicks if this changes + float target_volume = p_fadeout ? -80.0 : volume_db; float vol = Math::db2linear(mix_volume_db); - float vol_inc = (Math::db2linear(volume_db) - vol) / float(buffer_size); + float vol_inc = (Math::db2linear(target_volume) - vol) / float(buffer_size); for (int i = 0; i < buffer_size; i++) { buffer[i] *= vol; vol += vol_inc; } //set volume for next mix - mix_volume_db = volume_db; + mix_volume_db = target_volume; AudioFrame *targets[4] = { NULL, NULL, NULL, NULL }; @@ -95,6 +87,30 @@ void AudioStreamPlayer::_mix_audio() { } } +void AudioStreamPlayer::_mix_audio() { + + if (!stream_playback.is_valid()) { + return; + } + + if (!active) { + return; + } + + if (setseek >= 0.0) { + if (stream_playback->is_playing()) { + + //fade out to avoid pops + _mix_internal(true); + } + stream_playback->start(setseek); + setseek = -1.0; //reset seek + mix_volume_db = volume_db; //reset ramp + } + + _mix_internal(false); +} + void AudioStreamPlayer::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE) { @@ -163,7 +179,7 @@ float AudioStreamPlayer::get_volume_db() const { void AudioStreamPlayer::play(float p_from_pos) { if (stream_playback.is_valid()) { - mix_volume_db = volume_db; //reset volume ramp + //mix_volume_db = volume_db; do not reset volume ramp here, can cause clicks setseek = p_from_pos; active = true; set_process_internal(true); diff --git a/scene/audio/audio_player.h b/scene/audio/audio_player.h index 4bfc44730d..6e9d623433 100644 --- a/scene/audio/audio_player.h +++ b/scene/audio/audio_player.h @@ -59,6 +59,7 @@ private: MixTarget mix_target; + void _mix_internal(bool p_fadeout); void _mix_audio(); static void _mix_audios(void *self) { reinterpret_cast<AudioStreamPlayer *>(self)->_mix_audio(); } diff --git a/scene/gui/check_button.cpp b/scene/gui/check_button.cpp index e68159e27f..77fdedd5e5 100644 --- a/scene/gui/check_button.cpp +++ b/scene/gui/check_button.cpp @@ -32,6 +32,23 @@ #include "print_string.h" #include "servers/visual_server.h" +Size2 CheckButton::get_minimum_size() const { + + Size2 minsize = Button::get_minimum_size(); + + Ref<Texture> on = Control::get_icon("on"); + Ref<Texture> off = Control::get_icon("off"); + Size2 tex_size = Size2(0, 0); + if (!on.is_null()) + tex_size = Size2(on->get_width(), on->get_height()); + if (!off.is_null()) + tex_size = Size2(MAX(tex_size.width, off->get_width()), MAX(tex_size.height, off->get_height())); + minsize += Size2(tex_size.width + get_constant("hseparation"), 0); + minsize.height = MAX(minsize.height, tex_size.height); + + return get_stylebox("normal")->get_minimum_size() + minsize; +} + void CheckButton::_notification(int p_what) { if (p_what == NOTIFICATION_DRAW) { @@ -41,9 +58,11 @@ void CheckButton::_notification(int p_what) { Ref<Texture> on = Control::get_icon("on"); Ref<Texture> off = Control::get_icon("off"); + Ref<StyleBox> sb = get_stylebox("normal"); + Size2 sb_ofs = Size2(sb->get_margin(MARGIN_RIGHT), sb->get_margin(MARGIN_TOP)); Vector2 ofs; - ofs.x = get_size().width - on->get_width(); - ofs.y = int((get_size().height - on->get_height()) / 2); + ofs.x = get_minimum_size().width - (on->get_width() + sb_ofs.width); + ofs.y = sb_ofs.height; if (is_pressed()) on->draw(ci, ofs); diff --git a/scene/gui/check_button.h b/scene/gui/check_button.h index af3b80fe04..eb68943fe7 100644 --- a/scene/gui/check_button.h +++ b/scene/gui/check_button.h @@ -39,6 +39,7 @@ class CheckButton : public Button { GDCLASS(CheckButton, Button); protected: + virtual Size2 get_minimum_size() const; void _notification(int p_what); public: diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index 1f230e95c7..e73ada9f31 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -2416,11 +2416,11 @@ float Control::get_rotation() const { return data.rotation; } -void Control::set_rotation_deg(float p_degrees) { +void Control::set_rotation_degrees(float p_degrees) { set_rotation(Math::deg2rad(p_degrees)); } -float Control::get_rotation_deg() const { +float Control::get_rotation_degrees() const { return Math::rad2deg(get_rotation()); } @@ -2596,7 +2596,7 @@ void Control::_bind_methods() { ClassDB::bind_method(D_METHOD("set_custom_minimum_size", "size"), &Control::set_custom_minimum_size); ClassDB::bind_method(D_METHOD("set_global_position", "position"), &Control::set_global_position); ClassDB::bind_method(D_METHOD("set_rotation", "radians"), &Control::set_rotation); - ClassDB::bind_method(D_METHOD("set_rotation_deg", "degrees"), &Control::set_rotation_deg); + ClassDB::bind_method(D_METHOD("set_rotation_degrees", "degrees"), &Control::set_rotation_degrees); ClassDB::bind_method(D_METHOD("set_scale", "scale"), &Control::set_scale); ClassDB::bind_method(D_METHOD("set_pivot_offset", "pivot_offset"), &Control::set_pivot_offset); ClassDB::bind_method(D_METHOD("get_margin", "margin"), &Control::get_margin); @@ -2605,7 +2605,7 @@ void Control::_bind_methods() { ClassDB::bind_method(D_METHOD("get_position"), &Control::get_position); ClassDB::bind_method(D_METHOD("get_size"), &Control::get_size); ClassDB::bind_method(D_METHOD("get_rotation"), &Control::get_rotation); - ClassDB::bind_method(D_METHOD("get_rotation_deg"), &Control::get_rotation_deg); + ClassDB::bind_method(D_METHOD("get_rotation_degrees"), &Control::get_rotation_degrees); ClassDB::bind_method(D_METHOD("get_scale"), &Control::get_scale); ClassDB::bind_method(D_METHOD("get_pivot_offset"), &Control::get_pivot_offset); ClassDB::bind_method(D_METHOD("get_custom_minimum_size"), &Control::get_custom_minimum_size); @@ -2724,7 +2724,7 @@ void Control::_bind_methods() { ADD_PROPERTYNZ(PropertyInfo(Variant::VECTOR2, "rect_position", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "set_position", "get_position"); ADD_PROPERTYNZ(PropertyInfo(Variant::VECTOR2, "rect_size", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "set_size", "get_size"); ADD_PROPERTYNZ(PropertyInfo(Variant::VECTOR2, "rect_min_size"), "set_custom_minimum_size", "get_custom_minimum_size"); - ADD_PROPERTYNZ(PropertyInfo(Variant::REAL, "rect_rotation", PROPERTY_HINT_RANGE, "-1080,1080,0.01"), "set_rotation_deg", "get_rotation_deg"); + ADD_PROPERTYNZ(PropertyInfo(Variant::REAL, "rect_rotation", PROPERTY_HINT_RANGE, "-1080,1080,0.01"), "set_rotation_degrees", "get_rotation_degrees"); ADD_PROPERTYNO(PropertyInfo(Variant::VECTOR2, "rect_scale"), "set_scale", "get_scale"); ADD_PROPERTYNO(PropertyInfo(Variant::VECTOR2, "rect_pivot_offset"), "set_pivot_offset", "get_pivot_offset"); ADD_PROPERTYNO(PropertyInfo(Variant::BOOL, "rect_clip_content"), "set_clip_contents", "is_clipping_contents"); diff --git a/scene/gui/control.h b/scene/gui/control.h index 8c1df6784a..4d0e3934ad 100644 --- a/scene/gui/control.h +++ b/scene/gui/control.h @@ -328,9 +328,9 @@ public: Rect2 get_window_rect() const; ///< use with care, as it blocks waiting for the visual server void set_rotation(float p_radians); - void set_rotation_deg(float p_degrees); + void set_rotation_degrees(float p_degrees); float get_rotation() const; - float get_rotation_deg() const; + float get_rotation_degrees() const; void set_h_grow_direction(GrowDirection p_direction); GrowDirection get_h_grow_direction() const; diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index 40e2dba6c2..5d3e5ec0e8 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -48,7 +48,7 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) { if (b.is_valid()) { - if (b->is_pressed() && b->get_button_index() == BUTTON_RIGHT) { + if (b->is_pressed() && b->get_button_index() == BUTTON_RIGHT && context_menu_enabled) { menu->set_position(get_global_transform().xform(get_local_mouse_position())); menu->set_size(Vector2(1, 1)); menu->popup(); @@ -1286,6 +1286,14 @@ void LineEdit::menu_option(int p_option) { } } +void LineEdit::set_context_menu_enabled(bool p_enable) { + context_menu_enabled = p_enable; +} + +bool LineEdit::is_context_menu_enabled() { + return context_menu_enabled; +} + PopupMenu *LineEdit::get_menu() const { return menu; } @@ -1395,6 +1403,8 @@ void LineEdit::_bind_methods() { ClassDB::bind_method(D_METHOD("select", "from", "to"), &LineEdit::select, DEFVAL(0), DEFVAL(-1)); ClassDB::bind_method(D_METHOD("menu_option", "option"), &LineEdit::menu_option); ClassDB::bind_method(D_METHOD("get_menu"), &LineEdit::get_menu); + ClassDB::bind_method(D_METHOD("set_context_menu_enabled", "enable"), &LineEdit::set_context_menu_enabled); + ClassDB::bind_method(D_METHOD("is_context_menu_enabled"), &LineEdit::is_context_menu_enabled); ADD_SIGNAL(MethodInfo("text_changed", PropertyInfo(Variant::STRING, "text"))); ADD_SIGNAL(MethodInfo("text_entered", PropertyInfo(Variant::STRING, "text"))); @@ -1426,6 +1436,7 @@ void LineEdit::_bind_methods() { ADD_GROUP("Caret", "caret_"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "caret_blink"), "cursor_set_blink_enabled", "cursor_get_blink_enabled"); ADD_PROPERTYNZ(PropertyInfo(Variant::REAL, "caret_blink_speed", PROPERTY_HINT_RANGE, "0.1,10,0.1"), "cursor_set_blink_speed", "cursor_get_blink_speed"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "context_menu_enabled"), "set_context_menu_enabled", "is_context_menu_enabled"); } LineEdit::LineEdit() { @@ -1455,6 +1466,7 @@ LineEdit::LineEdit() { caret_blink_timer->connect("timeout", this, "_toggle_draw_caret"); cursor_set_blink_enabled(false); + context_menu_enabled = true; menu = memnew(PopupMenu); add_child(menu); menu->add_item(TTR("Cut"), MENU_CUT, KEY_MASK_CMD | KEY_X); diff --git a/scene/gui/line_edit.h b/scene/gui/line_edit.h index bece29a37d..c3a299c2f5 100644 --- a/scene/gui/line_edit.h +++ b/scene/gui/line_edit.h @@ -74,6 +74,7 @@ private: String ime_text; Point2 ime_selection; + bool context_menu_enabled; PopupMenu *menu; int cursor_pos; @@ -150,6 +151,8 @@ public: virtual void drop_data(const Point2 &p_point, const Variant &p_data); void menu_option(int p_option); + void set_context_menu_enabled(bool p_enable); + bool is_context_menu_enabled(); PopupMenu *get_menu() const; void select_all(); diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 7d200a799b..a568b6fab0 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -3668,6 +3668,11 @@ void TextEdit::set_readonly(bool p_readonly) { readonly = p_readonly; } +bool TextEdit::is_readonly() const { + + return readonly; +} + void TextEdit::set_wrap(bool p_wrap) { wrap = p_wrap; @@ -4866,6 +4871,10 @@ void TextEdit::set_context_menu_enabled(bool p_enable) { context_menu_enabled = p_enable; } +bool TextEdit::is_context_menu_enabled() { + return context_menu_enabled; +} + PopupMenu *TextEdit::get_menu() const { return menu; } @@ -4910,8 +4919,12 @@ void TextEdit::_bind_methods() { ClassDB::bind_method(D_METHOD("cursor_is_block_mode"), &TextEdit::cursor_is_block_mode); ClassDB::bind_method(D_METHOD("set_readonly", "enable"), &TextEdit::set_readonly); + ClassDB::bind_method(D_METHOD("is_readonly"), &TextEdit::is_readonly); + ClassDB::bind_method(D_METHOD("set_wrap", "enable"), &TextEdit::set_wrap); ClassDB::bind_method(D_METHOD("set_max_chars", "amount"), &TextEdit::set_max_chars); + ClassDB::bind_method(D_METHOD("set_context_menu_enabled", "enable"), &TextEdit::set_context_menu_enabled); + ClassDB::bind_method(D_METHOD("is_context_menu_enabled"), &TextEdit::is_context_menu_enabled); ClassDB::bind_method(D_METHOD("cut"), &TextEdit::cut); ClassDB::bind_method(D_METHOD("copy"), &TextEdit::copy); @@ -4958,11 +4971,13 @@ void TextEdit::_bind_methods() { ClassDB::bind_method(D_METHOD("menu_option", "option"), &TextEdit::menu_option); ClassDB::bind_method(D_METHOD("get_menu"), &TextEdit::get_menu); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "readonly"), "set_readonly", "is_readonly"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "highlight_current_line"), "set_highlight_current_line", "is_highlight_current_line_enabled"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "syntax_highlighting"), "set_syntax_coloring", "is_syntax_coloring_enabled"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "show_line_numbers"), "set_show_line_numbers", "is_show_line_numbers_enabled"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "highlight_all_occurrences"), "set_highlight_all_occurrences", "is_highlight_all_occurrences_enabled"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "override_selected_font_color"), "set_override_selected_font_color", "is_overriding_selected_font_color"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "context_menu_enabled"), "set_context_menu_enabled", "is_context_menu_enabled"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "smooth_scrolling"), "set_smooth_scroll_enable", "is_smooth_scroll_enabled"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "v_scroll_speed"), "set_v_scroll_speed", "get_v_scroll_speed"); diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h index 81310b7c10..b90571e0ab 100644 --- a/scene/gui/text_edit.h +++ b/scene/gui/text_edit.h @@ -448,6 +448,7 @@ public: bool cursor_is_block_mode() const; void set_readonly(bool p_readonly); + bool is_readonly() const; void set_max_chars(int p_max_chars); void set_wrap(bool p_wrap); @@ -547,6 +548,8 @@ public: bool is_selecting_identifiers_on_hover_enabled() const; void set_context_menu_enabled(bool p_enable); + bool is_context_menu_enabled(); + PopupMenu *get_menu() const; String get_text_for_completion(); diff --git a/scene/main/canvas_layer.cpp b/scene/main/canvas_layer.cpp index f626c567a9..5a3814ef35 100644 --- a/scene/main/canvas_layer.cpp +++ b/scene/main/canvas_layer.cpp @@ -105,12 +105,12 @@ real_t CanvasLayer::get_rotation() const { return rot; } -void CanvasLayer::set_rotationd(real_t p_degrees) { +void CanvasLayer::set_rotation_degrees(real_t p_degrees) { set_rotation(Math::deg2rad(p_degrees)); } -real_t CanvasLayer::get_rotationd() const { +real_t CanvasLayer::get_rotation_degrees() const { return Math::rad2deg(get_rotation()); } @@ -238,8 +238,8 @@ void CanvasLayer::_bind_methods() { ClassDB::bind_method(D_METHOD("set_rotation", "radians"), &CanvasLayer::set_rotation); ClassDB::bind_method(D_METHOD("get_rotation"), &CanvasLayer::get_rotation); - ClassDB::bind_method(D_METHOD("set_rotationd", "degrees"), &CanvasLayer::set_rotationd); - ClassDB::bind_method(D_METHOD("get_rotationd"), &CanvasLayer::get_rotationd); + ClassDB::bind_method(D_METHOD("set_rotation_degrees", "degrees"), &CanvasLayer::set_rotation_degrees); + ClassDB::bind_method(D_METHOD("get_rotation_degrees"), &CanvasLayer::get_rotation_degrees); ClassDB::bind_method(D_METHOD("set_scale", "scale"), &CanvasLayer::set_scale); ClassDB::bind_method(D_METHOD("get_scale"), &CanvasLayer::get_scale); @@ -253,7 +253,7 @@ void CanvasLayer::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "layer", PROPERTY_HINT_RANGE, "-128,128,1"), "set_layer", "get_layer"); //ADD_PROPERTY( PropertyInfo(Variant::MATRIX32,"transform",PROPERTY_HINT_RANGE),"set_transform","get_transform") ; ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "offset"), "set_offset", "get_offset"); - ADD_PROPERTY(PropertyInfo(Variant::REAL, "rotation"), "set_rotationd", "get_rotationd"); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "rotation"), "set_rotation_degrees", "get_rotation_degrees"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "scale"), "set_scale", "get_scale"); } diff --git a/scene/main/canvas_layer.h b/scene/main/canvas_layer.h index bb7692de0f..db2c8e1273 100644 --- a/scene/main/canvas_layer.h +++ b/scene/main/canvas_layer.h @@ -74,8 +74,8 @@ public: void set_rotation(real_t p_radians); real_t get_rotation() const; - void set_rotationd(real_t p_degrees); - real_t get_rotationd() const; + void set_rotation_degrees(real_t p_degrees); + real_t get_rotation_degrees() const; void set_scale(const Size2 &p_scale); Size2 get_scale() const; diff --git a/scene/resources/audio_stream_sample.cpp b/scene/resources/audio_stream_sample.cpp index fdc3b79db6..f81f460521 100644 --- a/scene/resources/audio_stream_sample.cpp +++ b/scene/resources/audio_stream_sample.cpp @@ -31,17 +31,23 @@ void AudioStreamPlaybackSample::start(float p_from_pos) { - for (int i = 0; i < 2; i++) { - ima_adpcm[i].step_index = 0; - ima_adpcm[i].predictor = 0; - ima_adpcm[i].loop_step_index = 0; - ima_adpcm[i].loop_predictor = 0; - ima_adpcm[i].last_nibble = -1; - ima_adpcm[i].loop_pos = 0x7FFFFFFF; - ima_adpcm[i].window_ofs = 0; + if (base->format == AudioStreamSample::FORMAT_IMA_ADPCM) { + //no seeking in IMA_ADPCM + for (int i = 0; i < 2; i++) { + ima_adpcm[i].step_index = 0; + ima_adpcm[i].predictor = 0; + ima_adpcm[i].loop_step_index = 0; + ima_adpcm[i].loop_predictor = 0; + ima_adpcm[i].last_nibble = -1; + ima_adpcm[i].loop_pos = 0x7FFFFFFF; + ima_adpcm[i].window_ofs = 0; + } + + offset = 0; + } else { + seek(p_from_pos); } - seek(p_from_pos); sign = 1; active = true; } @@ -373,6 +379,14 @@ void AudioStreamPlaybackSample::mix(AudioFrame *p_buffer, float p_rate_scale, in dst_buff += target; } + + if (todo) { + //bit was missing from mix + int todo_ofs = p_frames - todo; + for (int i = todo_ofs; i < p_frames; i++) { + p_buffer[i] = AudioFrame(0, 0); + } + } } float AudioStreamPlaybackSample::get_length() const { diff --git a/scene/resources/dynamic_font_stb.cpp b/scene/resources/dynamic_font_stb.cpp index 91263fb125..4aa47cb664 100644 --- a/scene/resources/dynamic_font_stb.cpp +++ b/scene/resources/dynamic_font_stb.cpp @@ -333,8 +333,7 @@ void DynamicFontAtSize::_update_char(CharType p_char) { //blit to image and texture { - - Image img(tex.texture_size, tex.texture_size, 0, Image::FORMAT_LA8, tex.imgdata); + Ref<Image> img = memnew(Image(tex.texture_size, tex.texture_size, 0, Image::FORMAT_LA8, tex.imgdata)); if (tex.texture.is_null()) { tex.texture.instance(); @@ -518,7 +517,7 @@ bool ResourceFormatLoaderDynamicFont::handles_type(const String &p_type) const { String ResourceFormatLoaderDynamicFont::get_resource_type(const String &p_path) const { - String el = p_path.extension().to_lower(); + String el = p_path.get_extension().to_lower(); if (el == "ttf") return "DynamicFontData"; return ""; diff --git a/scene/resources/environment.cpp b/scene/resources/environment.cpp index 232f690074..fe59450f2e 100644 --- a/scene/resources/environment.cpp +++ b/scene/resources/environment.cpp @@ -1184,7 +1184,8 @@ Environment::Environment() { bg_energy = 1.0; bg_canvas_max_layer = 0; ambient_energy = 1.0; - ambient_sky_contribution = 1.0; + //ambient_sky_contribution = 1.0; + set_ambient_light_sky_contribution(1.0); tone_mapper = TONE_MAPPER_LINEAR; tonemap_exposure = 1.0; diff --git a/scene/scene_string_names.cpp b/scene/scene_string_names.cpp index d9770ec3f3..52b8e35d5e 100644 --- a/scene/scene_string_names.cpp +++ b/scene/scene_string_names.cpp @@ -143,7 +143,7 @@ SceneStringNames::SceneStringNames() { v_offset = StaticCString::create("v_offset"); transform_pos = StaticCString::create("position"); - transform_rot = StaticCString::create("rotation_deg"); + transform_rot = StaticCString::create("rotation_degrees"); transform_scale = StaticCString::create("scale"); _update_remote = StaticCString::create("_update_remote"); |