diff options
151 files changed, 1571 insertions, 212 deletions
diff --git a/.github/workflows/linux_builds.yml b/.github/workflows/linux_builds.yml index f6d11e2efe..15bd4bc69b 100644 --- a/.github/workflows/linux_builds.yml +++ b/.github/workflows/linux_builds.yml @@ -18,13 +18,15 @@ jobs: fail-fast: false matrix: include: - - name: Editor (target=release_debug, tools=yes, tests=yes) - cache-name: linux-editor + - name: Editor w/ Mono (target=release_debug, tools=yes, tests=yes) + cache-name: linux-editor-mono target: release_debug tools: true - tests: true + tests: false # Disabled due freeze caused by mix Mono build and CI + sconsflags: module_mono_enabled=yes mono_glue=no doc-test: true - bin: "./bin/godot.linuxbsd.opt.tools.64" + bin: "./bin/godot.linuxbsd.opt.tools.64.mono" + build-mono: true artifact: true - name: Editor and sanitizers (target=debug, tools=yes, tests=yes, use_asan=yes, use_ubsan=yes) @@ -36,6 +38,7 @@ jobs: proj-test: true godot-cpp-test: true bin: "./bin/godot.linuxbsd.tools.64s" + build-mono: false # Skip 2GiB artifact speeding up action. artifact: false @@ -45,6 +48,7 @@ jobs: tools: false tests: false sconsflags: module_mono_enabled=yes mono_glue=no debug_symbols=no + build-mono: false artifact: true steps: @@ -80,11 +84,26 @@ jobs: tools: ${{ matrix.tools }} tests: ${{ matrix.tests }} + - name: Generate Mono glue + if: ${{ matrix.build-mono }} + run: | + ${{ matrix.bin }} --headless --generate-mono-glue modules/mono/glue || true + + # Rebuild with mono + - name: Compilation (mono_glue=yes) + uses: ./.github/actions/godot-build + if: ${{ matrix.build-mono }} + with: + sconsflags: ${{ env.SCONSFLAGS }} ${{ matrix.sconsflags }} mono_glue=yes + platform: linuxbsd + target: ${{ matrix.target }} + tools: ${{ matrix.tools }} + # Execute unit tests for the editor - name: Unit tests if: ${{ matrix.tests }} run: | - ${{ matrix.bin }} --test + ${{ matrix.bin }} --test --headless # Check class reference - name: Check for class reference updates diff --git a/core/debugger/remote_debugger.cpp b/core/debugger/remote_debugger.cpp index 4607bd2f3f..87e65e592a 100644 --- a/core/debugger/remote_debugger.cpp +++ b/core/debugger/remote_debugger.cpp @@ -475,7 +475,7 @@ void RemoteDebugger::_err_handler(void *p_this, const char *p_func, const char * } // send_error will lock internally. - rd->script_debugger->send_error(p_func, p_file, p_line, p_err, p_descr, p_editor_notify, p_type, si); + rd->script_debugger->send_error(String::utf8(p_func), String::utf8(p_file), p_line, String::utf8(p_err), String::utf8(p_descr), p_editor_notify, p_type, si); } void RemoteDebugger::_print_handler(void *p_this, const String &p_string, bool p_error) { diff --git a/doc/classes/FontData.xml b/doc/classes/FontData.xml index 04932ddd2d..ccfe861c92 100644 --- a/doc/classes/FontData.xml +++ b/doc/classes/FontData.xml @@ -93,6 +93,24 @@ Returns font descent (number of pixels below the baseline). </description> </method> + <method name="get_font_name" qualifiers="const"> + <return type="String" /> + <description> + Returns font family name. + </description> + </method> + <method name="get_font_style" qualifiers="const"> + <return type="int" /> + <description> + Returns font style flags, see [enum TextServer.FontStyle]. + </description> + </method> + <method name="get_font_style_name" qualifiers="const"> + <return type="String" /> + <description> + Returns font style name. + </description> + </method> <method name="get_glyph_advance" qualifiers="const"> <return type="Vector2" /> <argument index="0" name="cache_index" type="int" /> @@ -463,6 +481,27 @@ Sets the font descent (number of pixels below the baseline). </description> </method> + <method name="set_font_name"> + <return type="void" /> + <argument index="0" name="name" type="String" /> + <description> + Sets the font family name. + </description> + </method> + <method name="set_font_style"> + <return type="void" /> + <argument index="0" name="style" type="int" /> + <description> + Sets the font style flags, see [enum TextServer.FontStyle]. + </description> + </method> + <method name="set_font_style_name"> + <return type="void" /> + <argument index="0" name="name" type="String" /> + <description> + Sets the font style name. + </description> + </method> <method name="set_force_autohinter"> <return type="void" /> <argument index="0" name="force_autohinter" type="bool" /> diff --git a/doc/classes/Gradient.xml b/doc/classes/Gradient.xml index 93cef07b79..baba71b453 100644 --- a/doc/classes/Gradient.xml +++ b/doc/classes/Gradient.xml @@ -51,6 +51,12 @@ Removes the color at the index [code]point[/code]. </description> </method> + <method name="reverse"> + <return type="void" /> + <description> + Reverses/mirrors the gradient. + </description> + </method> <method name="set_color"> <return type="void" /> <argument index="0" name="point" type="int" /> @@ -72,8 +78,22 @@ <member name="colors" type="PackedColorArray" setter="set_colors" getter="get_colors" default="PackedColorArray(0, 0, 0, 1, 1, 1, 1, 1)"> Gradient's colors returned as a [PackedColorArray]. </member> + <member name="interpolation_mode" type="int" setter="set_interpolation_mode" getter="get_interpolation_mode" enum="Gradient.InterpolationMode" default="0"> + Defines how the colors between points of the gradient are interpolated. See [enum InterpolationMode] for available modes. + </member> <member name="offsets" type="PackedFloat32Array" setter="set_offsets" getter="get_offsets" default="PackedFloat32Array(0, 1)"> Gradient's offsets returned as a [PackedFloat32Array]. </member> </members> + <constants> + <constant name="GRADIENT_INTERPOLATE_LINEAR" value="0" enum="InterpolationMode"> + Linear interpolation. + </constant> + <constant name="GRADIENT_INTERPOLATE_CONSTANT" value="1" enum="InterpolationMode"> + Constant interpolation, color changes abruptly at each point and stays uniform between. This might cause visible aliasing when used for a gradient texture in some cases. + </constant> + <constant name="GRADIENT_INTERPOLATE_CUBIC" value="2" enum="InterpolationMode"> + Cubic interpolation. + </constant> + </constants> </class> diff --git a/doc/classes/Label.xml b/doc/classes/Label.xml index 3c349e052f..24ebf08c36 100644 --- a/doc/classes/Label.xml +++ b/doc/classes/Label.xml @@ -194,7 +194,7 @@ The vertical offset of the text's shadow. </theme_item> <theme_item name="shadow_outline_size" data_type="constant" type="int" default="1"> - Shadow outline size. If set to 1 or greater, the shadow will be displayed around the whole text as an outline. + The size of the shadow outline. </theme_item> </theme_items> </class> diff --git a/doc/classes/LineEdit.xml b/doc/classes/LineEdit.xml index f79ba5a16f..a75bd2f704 100644 --- a/doc/classes/LineEdit.xml +++ b/doc/classes/LineEdit.xml @@ -196,6 +196,9 @@ <member name="expand_to_text_length" type="bool" setter="set_expand_to_text_length_enabled" getter="is_expand_to_text_length_enabled" default="false"> If [code]true[/code], the [LineEdit] width will increase to stay longer than the [member text]. It will [b]not[/b] compress if the [member text] is shortened. </member> + <member name="flat" type="bool" setter="set_flat" getter="is_flat" default="false"> + If [code]true[/code], the [LineEdit] don't display decoration. + </member> <member name="focus_mode" type="int" setter="set_focus_mode" getter="get_focus_mode" override="true" enum="Control.FocusMode" default="2" /> <member name="language" type="String" setter="set_language" getter="get_language" default=""""> Language code used for line-breaking and text shaping algorithms, if left empty current locale is used instead. diff --git a/doc/classes/PhysicsDirectBodyState2D.xml b/doc/classes/PhysicsDirectBodyState2D.xml index aa189f17f4..3fe9cd776c 100644 --- a/doc/classes/PhysicsDirectBodyState2D.xml +++ b/doc/classes/PhysicsDirectBodyState2D.xml @@ -150,7 +150,10 @@ The body's rotational velocity. </member> <member name="center_of_mass" type="Vector2" setter="" getter="get_center_of_mass"> - The body's center of mass. + The body's center of mass position relative to the body's center in the global coordinate system. + </member> + <member name="center_of_mass_local" type="Vector2" setter="" getter="get_center_of_mass_local"> + The body's center of mass position in the body's local coordinate system. </member> <member name="inverse_inertia" type="float" setter="" getter="get_inverse_inertia"> The inverse of the inertia of the body. diff --git a/doc/classes/PhysicsDirectBodyState3D.xml b/doc/classes/PhysicsDirectBodyState3D.xml index 9bc5dbd6b9..efa9eb9cd6 100644 --- a/doc/classes/PhysicsDirectBodyState3D.xml +++ b/doc/classes/PhysicsDirectBodyState3D.xml @@ -159,7 +159,10 @@ The body's rotational velocity. </member> <member name="center_of_mass" type="Vector3" setter="" getter="get_center_of_mass"> - The body's center of mass. + The body's center of mass position relative to the body's center in the global coordinate system. + </member> + <member name="center_of_mass_local" type="Vector3" setter="" getter="get_center_of_mass_local"> + The body's center of mass position in the body's local coordinate system. </member> <member name="inverse_inertia" type="Vector3" setter="" getter="get_inverse_inertia"> The inverse of the inertia of the body. diff --git a/doc/classes/PhysicsServer2D.xml b/doc/classes/PhysicsServer2D.xml index e44bf71e8d..7368fe06ab 100644 --- a/doc/classes/PhysicsServer2D.xml +++ b/doc/classes/PhysicsServer2D.xml @@ -919,7 +919,7 @@ Constant to set/get a body's inertia. </constant> <constant name="BODY_PARAM_CENTER_OF_MASS" value="4" enum="BodyParameter"> - Constant to set/get a body's center of mass. + Constant to set/get a body's center of mass position in the body's local coordinate system. </constant> <constant name="BODY_PARAM_GRAVITY_SCALE" value="5" enum="BodyParameter"> Constant to set/get a body's gravity multiplier. diff --git a/doc/classes/PhysicsServer3D.xml b/doc/classes/PhysicsServer3D.xml index 0c34cf8092..0f02cdf92f 100644 --- a/doc/classes/PhysicsServer3D.xml +++ b/doc/classes/PhysicsServer3D.xml @@ -1287,7 +1287,7 @@ Constant to set/get a body's inertia. </constant> <constant name="BODY_PARAM_CENTER_OF_MASS" value="4" enum="BodyParameter"> - Constant to set/get a body's center of mass. + Constant to set/get a body's center of mass position in the body's local coordinate system. </constant> <constant name="BODY_PARAM_GRAVITY_SCALE" value="5" enum="BodyParameter"> Constant to set/get a body's gravity multiplier. diff --git a/doc/classes/ProjectSettings.xml b/doc/classes/ProjectSettings.xml index 30409814d2..205987f5be 100644 --- a/doc/classes/ProjectSettings.xml +++ b/doc/classes/ProjectSettings.xml @@ -1315,8 +1315,6 @@ </member> <member name="mono/profiler/enabled" type="bool" setter="" getter="" default="false"> </member> - <member name="mono/project/auto_update_project" type="bool" setter="" getter="" default="true"> - </member> <member name="mono/unhandled_exception_policy" type="int" setter="" getter="" default="0"> </member> <member name="navigation/2d/default_cell_size" type="int" setter="" getter="" default="10"> diff --git a/doc/classes/RichTextLabel.xml b/doc/classes/RichTextLabel.xml index 0fd25615ba..3255c748b7 100644 --- a/doc/classes/RichTextLabel.xml +++ b/doc/classes/RichTextLabel.xml @@ -586,15 +586,15 @@ <theme_item name="selection_color" data_type="color" type="Color" default="Color(0.1, 0.1, 1, 0.8)"> The color of the selection box. </theme_item> - <theme_item name="shadow_as_outline" data_type="constant" type="int" default="0"> - Boolean value. If 1 ([code]true[/code]), the shadow will be displayed around the whole text as an outline. - </theme_item> <theme_item name="shadow_offset_x" data_type="constant" type="int" default="1"> The horizontal offset of the font's shadow. </theme_item> <theme_item name="shadow_offset_y" data_type="constant" type="int" default="1"> The vertical offset of the font's shadow. </theme_item> + <theme_item name="shadow_outline_size" data_type="constant" type="int" default="1"> + The size of the shadow outline. + </theme_item> <theme_item name="table_border" data_type="color" type="Color" default="Color(0, 0, 0, 0)"> The default cell border color. </theme_item> diff --git a/doc/classes/TextParagraph.xml b/doc/classes/TextParagraph.xml index 5bd6b0572c..a7122b827e 100644 --- a/doc/classes/TextParagraph.xml +++ b/doc/classes/TextParagraph.xml @@ -278,6 +278,9 @@ <member name="align" type="int" setter="set_align" getter="get_align" enum="HAlign" default="0"> Paragraph horizontal alignment. </member> + <member name="custom_punctuation" type="String" setter="set_custom_punctuation" getter="get_custom_punctuation" default=""""> + Custom punctuation character list, used for word breaking. If set to empty string, server defaults are used. + </member> <member name="direction" type="int" setter="set_direction" getter="get_direction" enum="TextServer.Direction" default="0"> Text writing direction. </member> diff --git a/doc/classes/TextServer.xml b/doc/classes/TextServer.xml index 3e32afe370..e1c05165de 100644 --- a/doc/classes/TextServer.xml +++ b/doc/classes/TextServer.xml @@ -254,6 +254,13 @@ Returns source font size used to generate MSDF textures. </description> </method> + <method name="font_get_name" qualifiers="const"> + <return type="String" /> + <argument index="0" name="font_rid" type="RID" /> + <description> + Returns font family name. + </description> + </method> <method name="font_get_oversampling" qualifiers="const"> <return type="float" /> <argument index="0" name="font_rid" type="RID" /> @@ -300,6 +307,20 @@ Returns extra spacing added between glyphs in pixels. </description> </method> + <method name="font_get_style" qualifiers="const"> + <return type="int" /> + <argument index="0" name="font_rid" type="RID" /> + <description> + Returns font style flags, see [enum FontStyle]. + </description> + </method> + <method name="font_get_style_name" qualifiers="const"> + <return type="String" /> + <argument index="0" name="font_rid" type="RID" /> + <description> + Returns font style name. + </description> + </method> <method name="font_get_supported_chars" qualifiers="const"> <return type="String" /> <argument index="0" name="font_rid" type="RID" /> @@ -634,6 +655,14 @@ [b]Note:[/b] MSDF font rendering does not render glyphs with overlapping shapes correctly. Overlapping shapes are not valid per the OpenType standard, but are still commonly found in many font files, especially those converted by Google Fonts. To avoid issues with overlapping glyphs, consider downloading the font file directly from the type foundry instead of relying on Google Fonts. </description> </method> + <method name="font_set_name"> + <return type="void" /> + <argument index="0" name="font_rid" type="RID" /> + <argument index="1" name="name" type="String" /> + <description> + Sets the font family name. + </description> + </method> <method name="font_set_oversampling"> <return type="void" /> <argument index="0" name="font_rid" type="RID" /> @@ -670,6 +699,22 @@ Sets extra spacing added between glyphs in pixels. </description> </method> + <method name="font_set_style"> + <return type="void" /> + <argument index="0" name="font_rid" type="RID" /> + <argument index="1" name="style" type="int" /> + <description> + Sets the font style flags, see [enum FontStyle]. + </description> + </method> + <method name="font_set_style_name"> + <return type="void" /> + <argument index="0" name="font_rid" type="RID" /> + <argument index="1" name="name" type="String" /> + <description> + Set the font style name. + </description> + </method> <method name="font_set_texture_image"> <return type="void" /> <argument index="0" name="font_rid" type="RID" /> @@ -917,6 +962,13 @@ Returns shapes of the carets corresponding to the character offset [code]position[/code] in the text. Returned caret shape is 1 pixel wide rectangle. </description> </method> + <method name="shaped_text_get_custom_punctuation" qualifiers="const"> + <return type="String" /> + <argument index="0" name="shaped" type="RID" /> + <description> + Returns custom punctuation character list, used for word breaking. If set to empty string, server defaults are used. + </description> + </method> <method name="shaped_text_get_descent" qualifiers="const"> <return type="float" /> <argument index="0" name="shaped" type="RID" /> @@ -1167,6 +1219,14 @@ Override ranges should cover full source text without overlaps. BiDi algorithm will be used on each range separately. </description> </method> + <method name="shaped_text_set_custom_punctuation"> + <return type="void" /> + <argument index="0" name="shaped" type="RID" /> + <argument index="1" name="punct" type="String" /> + <description> + Sets custom punctuation character list, used for word breaking. If set to empty string, server defaults are used. + </description> + </method> <method name="shaped_text_set_direction"> <return type="void" /> <argument index="0" name="shaped" type="RID" /> @@ -1402,5 +1462,14 @@ <constant name="SPACING_BOTTOM" value="3" enum="SpacingType"> Spacing at the bottom of the line. </constant> + <constant name="FONT_BOLD" value="1" enum="FontStyle"> + Font is bold. + </constant> + <constant name="FONT_ITALIC" value="2" enum="FontStyle"> + Font is italic or oblique. + </constant> + <constant name="FONT_FIXED_WIDTH" value="4" enum="FontStyle"> + Font have fixed-width characters. + </constant> </constants> </class> diff --git a/doc/classes/TextServerExtension.xml b/doc/classes/TextServerExtension.xml index 99382d5463..684a1aa755 100644 --- a/doc/classes/TextServerExtension.xml +++ b/doc/classes/TextServerExtension.xml @@ -254,6 +254,13 @@ Returns source font size used to generate MSDF textures. </description> </method> + <method name="_font_get_name" qualifiers="virtual const"> + <return type="String" /> + <argument index="0" name="font_rid" type="RID" /> + <description> + Returns font family name. + </description> + </method> <method name="_font_get_oversampling" qualifiers="virtual const"> <return type="float" /> <argument index="0" name="font_rid" type="RID" /> @@ -300,6 +307,20 @@ Returns extra spacing added between glyphs in pixels. </description> </method> + <method name="_font_get_style" qualifiers="virtual const"> + <return type="int" /> + <argument index="0" name="font_rid" type="RID" /> + <description> + Returns font style flags, see [enum TextServer.FontStyle]. + </description> + </method> + <method name="_font_get_style_name" qualifiers="virtual const"> + <return type="String" /> + <argument index="0" name="font_rid" type="RID" /> + <description> + Returns font style name. + </description> + </method> <method name="_font_get_supported_chars" qualifiers="virtual const"> <return type="String" /> <argument index="0" name="font_rid" type="RID" /> @@ -641,6 +662,14 @@ If set to [code]true[/code], glyphs of all sizes are rendered using single multichannel signed distance field generated from the dynamic font vector data. </description> </method> + <method name="_font_set_name" qualifiers="virtual"> + <return type="void" /> + <argument index="0" name="font_rid" type="RID" /> + <argument index="1" name="name" type="String" /> + <description> + Sets the font family name. + </description> + </method> <method name="_font_set_oversampling" qualifiers="virtual"> <return type="void" /> <argument index="0" name="font_rid" type="RID" /> @@ -677,6 +706,22 @@ Sets extra spacing added between glyphs in pixels. </description> </method> + <method name="_font_set_style" qualifiers="virtual"> + <return type="void" /> + <argument index="0" name="font_rid" type="RID" /> + <argument index="1" name="style" type="int" /> + <description> + Sets the font style flags, see [enum TextServer.FontStyle]. + </description> + </method> + <method name="_font_set_style_name" qualifiers="virtual"> + <return type="void" /> + <argument index="0" name="font_rid" type="RID" /> + <argument index="1" name="name_style" type="String" /> + <description> + Sets the font style name. + </description> + </method> <method name="_font_set_texture_image" qualifiers="virtual"> <return type="void" /> <argument index="0" name="font_rid" type="RID" /> @@ -924,6 +969,13 @@ Returns shapes of the carets corresponding to the character offset [code]position[/code] in the text. Returned caret shape is 1 pixel wide rectangle. </description> </method> + <method name="_shaped_text_get_custom_punctuation" qualifiers="virtual const"> + <return type="String" /> + <argument index="0" name="shaped" type="RID" /> + <description> + Returns custom punctuation character list, used for word breaking. If set to empty string, server defaults are used. + </description> + </method> <method name="_shaped_text_get_descent" qualifiers="virtual const"> <return type="float" /> <argument index="0" name="shaped" type="RID" /> @@ -1176,6 +1228,14 @@ Override ranges should cover full source text without overlaps. BiDi algorithm will be used on each range separately. </description> </method> + <method name="_shaped_text_set_custom_punctuation" qualifiers="virtual"> + <return type="void" /> + <argument index="0" name="shaped" type="RID" /> + <argument index="1" name="punct" type="String" /> + <description> + Sets custom punctuation character list, used for word breaking. If set to empty string, server defaults are used. + </description> + </method> <method name="_shaped_text_set_direction" qualifiers="virtual"> <return type="void" /> <argument index="0" name="shaped" type="RID" /> diff --git a/drivers/pulseaudio/audio_driver_pulseaudio.cpp b/drivers/pulseaudio/audio_driver_pulseaudio.cpp index 1233f0f632..06058f2d39 100644 --- a/drivers/pulseaudio/audio_driver_pulseaudio.cpp +++ b/drivers/pulseaudio/audio_driver_pulseaudio.cpp @@ -192,7 +192,7 @@ Error AudioDriverPulseAudio::init_device() { Error err = detect_channels(); if (err != OK) { // This most likely means there are no sinks. - ERR_PRINT("PulseAudio: init device failed to detect number of channels"); + ERR_PRINT("PulseAudio: init device failed to detect number of output channels"); return err; } @@ -212,7 +212,7 @@ Error AudioDriverPulseAudio::init_device() { break; default: - WARN_PRINT("PulseAudio: Unsupported number of channels: " + itos(pa_map.channels)); + WARN_PRINT("PulseAudio: Unsupported number of output channels: " + itos(pa_map.channels)); pa_channel_map_init_stereo(&pa_map); channels = 2; break; @@ -222,8 +222,8 @@ Error AudioDriverPulseAudio::init_device() { buffer_frames = closest_power_of_2(latency * mix_rate / 1000); pa_buffer_size = buffer_frames * pa_map.channels; - print_verbose("PulseAudio: detected " + itos(pa_map.channels) + " channels"); - print_verbose("PulseAudio: audio buffer frames: " + itos(buffer_frames) + " calculated latency: " + itos(buffer_frames * 1000 / mix_rate) + "ms"); + print_verbose("PulseAudio: detected " + itos(pa_map.channels) + " output channels"); + print_verbose("PulseAudio: audio buffer frames: " + itos(buffer_frames) + " calculated output latency: " + itos(buffer_frames * 1000 / mix_rate) + "ms"); pa_sample_spec spec; spec.format = PA_SAMPLE_S16LE; @@ -700,6 +700,8 @@ Error AudioDriverPulseAudio::capture_init_device() { break; } + print_verbose("PulseAudio: detected " + itos(pa_rec_map.channels) + " input channels"); + pa_sample_spec spec; spec.format = PA_SAMPLE_S16LE; diff --git a/editor/editor_log.cpp b/editor/editor_log.cpp index 251e1c2385..5f2f8e91c9 100644 --- a/editor/editor_log.cpp +++ b/editor/editor_log.cpp @@ -45,9 +45,9 @@ void EditorLog::_error_handler(void *p_self, const char *p_func, const char *p_f String err_str; if (p_errorexp && p_errorexp[0]) { - err_str = p_errorexp; + err_str = String::utf8(p_errorexp); } else { - err_str = String(p_file) + ":" + itos(p_line) + " - " + String(p_error); + err_str = String::utf8(p_file) + ":" + itos(p_line) + " - " + String::utf8(p_error); } if (p_editor_notify) { diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index ffbb845fb0..4af7763caa 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -174,6 +174,7 @@ #include "editor/plugins/sprite_frames_editor_plugin.h" #include "editor/plugins/style_box_editor_plugin.h" #include "editor/plugins/sub_viewport_preview_editor_plugin.h" +#include "editor/plugins/text_control_editor_plugin.h" #include "editor/plugins/text_editor.h" #include "editor/plugins/texture_3d_editor_plugin.h" #include "editor/plugins/texture_editor_plugin.h" @@ -7010,6 +7011,7 @@ EditorNode::EditorNode() { add_editor_plugin(memnew(GPUParticlesCollisionSDFEditorPlugin(this))); add_editor_plugin(memnew(InputEventEditorPlugin(this))); add_editor_plugin(memnew(SubViewportPreviewEditorPlugin(this))); + add_editor_plugin(memnew(TextControlEditorPlugin(this))); for (int i = 0; i < EditorPlugins::get_plugin_count(); i++) { add_editor_plugin(EditorPlugins::create(i, this)); diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index 06c39a957c..8e8437f1b2 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -1207,7 +1207,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_color("font_shadow_color", "RichTextLabel", Color(0, 0, 0, 0)); theme->set_constant("shadow_offset_x", "RichTextLabel", 1 * EDSCALE); theme->set_constant("shadow_offset_y", "RichTextLabel", 1 * EDSCALE); - theme->set_constant("shadow_as_outline", "RichTextLabel", 0 * EDSCALE); + theme->set_constant("shadow_outline_size", "RichTextLabel", 1 * EDSCALE); theme->set_stylebox("focus", "RichTextLabel", make_empty_stylebox()); theme->set_stylebox("normal", "RichTextLabel", style_tree_bg); @@ -1223,7 +1223,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_color("font_shadow_color", "Label", Color(0, 0, 0, 0)); theme->set_constant("shadow_offset_x", "Label", 1 * EDSCALE); theme->set_constant("shadow_offset_y", "Label", 1 * EDSCALE); - theme->set_constant("shadow_as_outline", "Label", 0 * EDSCALE); + theme->set_constant("shadow_outline_size", "Label", 1 * EDSCALE); theme->set_constant("line_spacing", "Label", 3 * EDSCALE); // LinkButton diff --git a/editor/editor_toaster.cpp b/editor/editor_toaster.cpp index 22da12b59b..0d9a546b8e 100644 --- a/editor/editor_toaster.cpp +++ b/editor/editor_toaster.cpp @@ -158,11 +158,11 @@ void EditorToaster::_error_handler(void *p_self, const char *p_func, const char if (p_editor_notify || (show_all_setting == 0 && in_dev) || show_all_setting == 1) { String err_str; if (p_errorexp && p_errorexp[0]) { - err_str = p_errorexp; + err_str = String::utf8(p_errorexp); } else { - err_str = String(p_error); + err_str = String::utf8(p_error); } - String tooltip_str = String(p_file) + ":" + itos(p_line); + String tooltip_str = String::utf8(p_file) + ":" + itos(p_line); if (!p_editor_notify) { if (p_type == ERR_HANDLER_WARNING) { diff --git a/editor/icons/ReverseGradient.svg b/editor/icons/ReverseGradient.svg new file mode 100644 index 0000000000..12f80d12dd --- /dev/null +++ b/editor/icons/ReverseGradient.svg @@ -0,0 +1 @@ +<?xml version="1.0" encoding="UTF-8"?><svg version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><defs><linearGradient id="b" x1=".26458" x2="3.9688" y1=".79375" y2=".79375" gradientTransform="scale(3.7795)" gradientUnits="userSpaceOnUse"><stop stop-color="#ccc" offset="0"/><stop stop-color="#ccc" stop-opacity="0" offset="1"/></linearGradient><linearGradient id="a" x1=".26458" x2="3.9688" y1="3.4396" y2="3.4396" gradientTransform="matrix(3.7795 0 0 3.7795 -16 -1.1865e-7)" gradientUnits="userSpaceOnUse"><stop stop-color="#ccc" offset="0"/><stop stop-color="#ccc" stop-opacity="0" offset="1"/></linearGradient></defs><g><rect x="1" y="1" width="14" height="4" ry="1" fill="url(#b)"/><rect transform="scale(-1,1)" x="-15" y="11" width="14" height="4" ry="1" fill="url(#a)" stroke-linecap="round" stroke-linejoin="round" stroke-width="3.7795"/><path d="m6 6 2 4 2-4z" fill="#ccc"/></g></svg> diff --git a/editor/import/resource_importer_bmfont.cpp b/editor/import/resource_importer_bmfont.cpp index 2e7ef1402b..a64be54f2d 100644 --- a/editor/import/resource_importer_bmfont.cpp +++ b/editor/import/resource_importer_bmfont.cpp @@ -359,6 +359,8 @@ Error ResourceImporterBMFont::import(const String &p_source_file, const String & int height = 0; int ascent = 0; int outline = 0; + uint32_t st_flags = 0; + String font_name; bool packed = false; uint8_t ch[4] = { 0, 0, 0, 0 }; // RGBA @@ -382,13 +384,23 @@ Error ResourceImporterBMFont::import(const String &p_source_file, const String & base_size = f->get_16(); uint8_t flags = f->get_8(); ERR_FAIL_COND_V_MSG(flags & 0x02, ERR_CANT_CREATE, TTR("Non-unicode version of BMFont is not supported.")); + if (flags & (1 << 3)) { + st_flags |= TextServer::FONT_BOLD; + } + if (flags & (1 << 2)) { + st_flags |= TextServer::FONT_ITALIC; + } f->get_8(); // non-unicode charset, skip f->get_16(); // stretch_h, skip f->get_8(); // aa, skip f->get_32(); // padding, skip f->get_16(); // spacing, skip outline = f->get_8(); - // font name, skip + // font name + PackedByteArray name_data; + name_data.resize(block_size - 14); + f->get_buffer(name_data.ptrw(), block_size - 14); + font_name = String::utf8((const char *)name_data.ptr(), block_size - 14); font->set_fixed_size(base_size); } break; case 2: /* common */ { @@ -601,6 +613,19 @@ Error ResourceImporterBMFont::import(const String &p_source_file, const String & if (keys.has("outline")) { outline = keys["outline"].to_int(); } + if (keys.has("bold")) { + if (keys["bold"].to_int()) { + st_flags |= TextServer::FONT_BOLD; + } + } + if (keys.has("italic")) { + if (keys["italic"].to_int()) { + st_flags |= TextServer::FONT_ITALIC; + } + } + if (keys.has("face")) { + font_name = keys["face"]; + } ERR_FAIL_COND_V_MSG((!keys.has("unicode") || keys["unicode"].to_int() != 1), ERR_CANT_CREATE, TTR("Non-unicode version of BMFont is not supported.")); } else if (type == "common") { if (keys.has("lineHeight")) { @@ -778,6 +803,8 @@ Error ResourceImporterBMFont::import(const String &p_source_file, const String & } } + font->set_font_name(font_name); + font->set_font_style(st_flags); font->set_ascent(0, base_size, ascent); font->set_descent(0, base_size, height - ascent); diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 376c7d3f07..061483decf 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -6192,14 +6192,14 @@ CanvasItemEditorViewport::CanvasItemEditorViewport(EditorNode *p_node, CanvasIte label = memnew(Label); label->add_theme_color_override("font_shadow_color", Color(0, 0, 0, 1)); - label->add_theme_constant_override("shadow_as_outline", 1 * EDSCALE); + label->add_theme_constant_override("shadow_outline_size", 1 * EDSCALE); label->hide(); canvas_item_editor->get_controls_container()->add_child(label); label_desc = memnew(Label); label_desc->add_theme_color_override("font_color", Color(0.6f, 0.6f, 0.6f, 1)); label_desc->add_theme_color_override("font_shadow_color", Color(0.2f, 0.2f, 0.2f, 1)); - label_desc->add_theme_constant_override("shadow_as_outline", 1 * EDSCALE); + label_desc->add_theme_constant_override("shadow_outline_size", 1 * EDSCALE); label_desc->add_theme_constant_override("line_spacing", 0); label_desc->hide(); canvas_item_editor->get_controls_container()->add_child(label_desc); diff --git a/editor/plugins/gradient_editor_plugin.cpp b/editor/plugins/gradient_editor_plugin.cpp index 355bdb69d8..da050abc02 100644 --- a/editor/plugins/gradient_editor_plugin.cpp +++ b/editor/plugins/gradient_editor_plugin.cpp @@ -46,6 +46,8 @@ void GradientEditor::_gradient_changed() { editing = true; Vector<Gradient::Point> points = gradient->get_points(); set_points(points); + set_interpolation_mode(gradient->get_interpolation_mode()); + update(); editing = false; } @@ -55,8 +57,10 @@ void GradientEditor::_ramp_changed() { undo_redo->create_action(TTR("Gradient Edited")); undo_redo->add_do_method(gradient.ptr(), "set_offsets", get_offsets()); undo_redo->add_do_method(gradient.ptr(), "set_colors", get_colors()); + undo_redo->add_do_method(gradient.ptr(), "set_interpolation_mode", get_interpolation_mode()); undo_redo->add_undo_method(gradient.ptr(), "set_offsets", gradient->get_offsets()); undo_redo->add_undo_method(gradient.ptr(), "set_colors", gradient->get_colors()); + undo_redo->add_undo_method(gradient.ptr(), "set_interpolation_mode", gradient->get_interpolation_mode()); undo_redo->commit_action(); editing = false; } @@ -69,6 +73,14 @@ void GradientEditor::set_gradient(const Ref<Gradient> &p_gradient) { connect("ramp_changed", callable_mp(this, &GradientEditor::_ramp_changed)); gradient->connect("changed", callable_mp(this, &GradientEditor::_gradient_changed)); set_points(gradient->get_points()); + set_interpolation_mode(gradient->get_interpolation_mode()); +} + +void GradientEditor::reverse_gradient() { + gradient->reverse(); + set_points(gradient->get_points()); + emit_signal(SNAME("ramp_changed")); + update(); } GradientEditor::GradientEditor() { @@ -77,6 +89,23 @@ GradientEditor::GradientEditor() { /////////////////////// +void GradientReverseButton::_notification(int p_what) { + if (p_what == NOTIFICATION_DRAW) { + Ref<Texture2D> icon = get_theme_icon(SNAME("ReverseGradient"), SNAME("EditorIcons")); + if (is_pressed()) { + draw_texture_rect(icon, Rect2(margin, margin, icon->get_width(), icon->get_height()), false, get_theme_color(SNAME("icon_pressed_color"), SNAME("Button"))); + } else { + draw_texture_rect(icon, Rect2(margin, margin, icon->get_width(), icon->get_height())); + } + } +} + +Size2 GradientReverseButton::get_minimum_size() const { + return (get_theme_icon(SNAME("ReverseGradient"), SNAME("EditorIcons"))->get_size() + Size2(margin * 2, margin * 2)); +} + +/////////////////////// + bool EditorInspectorPluginGradient::can_handle(Object *p_object) { return Object::cast_to<Gradient>(p_object) != nullptr; } @@ -85,9 +114,23 @@ void EditorInspectorPluginGradient::parse_begin(Object *p_object) { Gradient *gradient = Object::cast_to<Gradient>(p_object); Ref<Gradient> g(gradient); - GradientEditor *editor = memnew(GradientEditor); + editor = memnew(GradientEditor); editor->set_gradient(g); add_custom_control(editor); + + reverse_btn = memnew(GradientReverseButton); + + gradient_tools_hbox = memnew(HBoxContainer); + gradient_tools_hbox->add_child(reverse_btn); + + add_custom_control(gradient_tools_hbox); + + reverse_btn->connect("pressed", callable_mp(this, &EditorInspectorPluginGradient::_reverse_button_pressed)); + reverse_btn->set_tooltip(TTR("Reverse/mirror gradient.")); +} + +void EditorInspectorPluginGradient::_reverse_button_pressed() { + editor->reverse_gradient(); } GradientEditorPlugin::GradientEditorPlugin(EditorNode *p_node) { diff --git a/editor/plugins/gradient_editor_plugin.h b/editor/plugins/gradient_editor_plugin.h index bcbb86e422..95b7b466c9 100644 --- a/editor/plugins/gradient_editor_plugin.h +++ b/editor/plugins/gradient_editor_plugin.h @@ -50,12 +50,28 @@ protected: public: virtual Size2 get_minimum_size() const override; void set_gradient(const Ref<Gradient> &p_gradient); + void reverse_gradient(); GradientEditor(); }; +class GradientReverseButton : public BaseButton { + GDCLASS(GradientReverseButton, BaseButton); + + int margin = 2; + + void _notification(int p_what); + virtual Size2 get_minimum_size() const override; +}; + class EditorInspectorPluginGradient : public EditorInspectorPlugin { GDCLASS(EditorInspectorPluginGradient, EditorInspectorPlugin); + GradientEditor *editor; + HBoxContainer *gradient_tools_hbox; + GradientReverseButton *reverse_btn; + + void _reverse_button_pressed(); + public: virtual bool can_handle(Object *p_object) override; virtual void parse_begin(Object *p_object) override; diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index fa5381bb10..e4bc9ef690 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -2245,12 +2245,14 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { _menu_option(VIEW_RIGHT); } if (ED_IS_SHORTCUT("spatial_editor/orbit_view_down", p_event)) { - cursor.x_rot -= Math_PI / 12.0; + // Clamp rotation to roughly -90..90 degrees so the user can't look upside-down and end up disoriented. + cursor.x_rot = CLAMP(cursor.x_rot - Math_PI / 12.0, -1.57, 1.57); view_type = VIEW_TYPE_USER; _update_name(); } if (ED_IS_SHORTCUT("spatial_editor/orbit_view_up", p_event)) { - cursor.x_rot += Math_PI / 12.0; + // Clamp rotation to roughly -90..90 degrees so the user can't look upside-down and end up disoriented. + cursor.x_rot = CLAMP(cursor.x_rot + Math_PI / 12.0, -1.57, 1.57); view_type = VIEW_TYPE_USER; _update_name(); } diff --git a/editor/plugins/text_control_editor_plugin.cpp b/editor/plugins/text_control_editor_plugin.cpp new file mode 100644 index 0000000000..c878c83430 --- /dev/null +++ b/editor/plugins/text_control_editor_plugin.cpp @@ -0,0 +1,375 @@ +/*************************************************************************/ +/* text_control_editor_plugin.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 "text_control_editor_plugin.h" + +#include "editor/editor_scale.h" + +void TextControlEditor::_notification(int p_notification) { + switch (p_notification) { + case NOTIFICATION_ENTER_TREE: { + if (!EditorFileSystem::get_singleton()->is_connected("filesystem_changed", callable_mp(this, &TextControlEditor::_reload_fonts))) { + EditorFileSystem::get_singleton()->connect("filesystem_changed", callable_mp(this, &TextControlEditor::_reload_fonts), make_binds("")); + } + [[fallthrough]]; + } + case NOTIFICATION_THEME_CHANGED: { + clear_formatting->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); + } break; + case NOTIFICATION_EXIT_TREE: { + if (EditorFileSystem::get_singleton()->is_connected("filesystem_changed", callable_mp(this, &TextControlEditor::_reload_fonts))) { + EditorFileSystem::get_singleton()->disconnect("filesystem_changed", callable_mp(this, &TextControlEditor::_reload_fonts)); + } + } break; + default: + break; + } +} + +void TextControlEditor::_find_resources(EditorFileSystemDirectory *p_dir) { + for (int i = 0; i < p_dir->get_subdir_count(); i++) { + _find_resources(p_dir->get_subdir(i)); + } + + for (int i = 0; i < p_dir->get_file_count(); i++) { + if (p_dir->get_file_type(i) == "FontData") { + Ref<FontData> fd = ResourceLoader::load(p_dir->get_file_path(i)); + if (fd.is_valid()) { + String name = fd->get_font_name(); + String sty = fd->get_font_style_name(); + if (sty.is_empty()) { + sty = "Default"; + } + fonts[name][sty] = p_dir->get_file_path(i); + } + } + } +} + +void TextControlEditor::_reload_fonts(const String &p_path) { + fonts.clear(); + _find_resources(EditorFileSystem::get_singleton()->get_filesystem()); + _update_control(); +} + +void TextControlEditor::_update_fonts_menu() { + font_list->clear(); + font_list->add_item(TTR("[Theme Default]"), FONT_INFO_THEME_DEFAULT); + if (custom_font.is_valid()) { + font_list->add_item(TTR("[Custom Font]"), FONT_INFO_USER_CUSTOM); + } + + int id = FONT_INFO_ID; + for (Map<String, Map<String, String>>::Element *E = fonts.front(); E; E = E->next()) { + font_list->add_item(E->key(), id++); + } + + if (font_list->get_item_count() > 1) { + font_list->show(); + } else { + font_list->hide(); + } +} + +void TextControlEditor::_update_styles_menu() { + font_style_list->clear(); + if ((font_list->get_selected_id() >= FONT_INFO_ID)) { + const String &name = font_list->get_item_text(font_list->get_selected()); + for (Map<String, String>::Element *E = fonts[name].front(); E; E = E->next()) { + font_style_list->add_item(E->key()); + } + } else { + font_style_list->add_item("Default"); + } + + if (font_style_list->get_item_count() > 1) { + font_style_list->show(); + } else { + font_style_list->hide(); + } +} + +void TextControlEditor::_update_control() { + if (edited_control) { + // Get override names. + if (edited_control->is_class("RichTextLabel")) { + edited_color = "default_color"; + edited_font = "normal_font"; + edited_font_size = "normal_font_size"; + } else { + edited_color = "font_color"; + edited_font = "font"; + edited_font_size = "font_size"; + } + + // Get font override. + Ref<Font> font; + if (edited_control->has_theme_font_override(edited_font)) { + font = edited_control->get_theme_font(edited_font); + } + if (font.is_valid()) { + if (font->get_data_count() != 1) { + // Composite font, save it to "custom_font" to allow undoing font change. + custom_font = font; + _update_fonts_menu(); + font_list->select(FONT_INFO_USER_CUSTOM); + _update_styles_menu(); + font_style_list->select(0); + } else { + // Single face font, search for the font with matching name and style. + String name = font->get_data(0)->get_font_name(); + String style = font->get_data(0)->get_font_style_name(); + if (fonts.has(name) && fonts[name].has(style)) { + _update_fonts_menu(); + for (int i = 0; i < font_list->get_item_count(); i++) { + if (font_list->get_item_text(i) == name) { + font_list->select(i); + break; + } + } + _update_styles_menu(); + for (int i = 0; i < font_style_list->get_item_count(); i++) { + if (font_style_list->get_item_text(i) == style) { + font_style_list->select(i); + break; + } + } + } else { + // Unknown font, save it to "custom_font" to allow undoing font change. + custom_font = font; + _update_fonts_menu(); + font_list->select(FONT_INFO_USER_CUSTOM); + _update_styles_menu(); + font_style_list->select(0); + } + } + } else { + // No font override, select "Theme Default". + _update_fonts_menu(); + font_list->select(FONT_INFO_THEME_DEFAULT); + _update_styles_menu(); + font_style_list->select(0); + } + + // Get other theme overrides. + font_size_list->set_value(edited_control->get_theme_font_size(edited_font_size)); + outline_size_list->set_value(edited_control->get_theme_constant("outline_size")); + + font_color_picker->set_pick_color(edited_control->get_theme_color(edited_color)); + outline_color_picker->set_pick_color(edited_control->get_theme_color("font_outline_color")); + } +} + +void TextControlEditor::_font_selected(int p_id) { + _update_styles_menu(); + _set_font(); +} + +void TextControlEditor::_font_style_selected(int p_id) { + _set_font(); +} + +void TextControlEditor::_set_font() { + if (edited_control) { + if (font_list->get_selected_id() == FONT_INFO_THEME_DEFAULT) { + // Remove font override. + edited_control->remove_theme_font_override(edited_font); + return; + } else if (font_list->get_selected_id() == FONT_INFO_USER_CUSTOM) { + // Restore "custom_font". + edited_control->add_theme_font_override(edited_font, custom_font); + return; + } else { + // Load new font resource using selected name and style. + String name = font_list->get_item_text(font_list->get_selected()); + String sty = font_style_list->get_item_text(font_style_list->get_selected()); + if (sty.is_empty()) { + sty = "Default"; + } + if (fonts.has(name)) { + Ref<FontData> fd = ResourceLoader::load(fonts[name][sty]); + if (fd.is_valid()) { + Ref<Font> f; + f.instantiate(); + f->add_data(fd); + edited_control->add_theme_font_override(edited_font, f); + } + } + } + } +} + +void TextControlEditor::_font_size_selected(double p_size) { + if (edited_control) { + edited_control->add_theme_font_size_override(edited_font_size, p_size); + } +} + +void TextControlEditor::_outline_size_selected(double p_size) { + if (edited_control) { + edited_control->add_theme_constant_override("outline_size", p_size); + } +} + +void TextControlEditor::_font_color_changed(const Color &p_color) { + if (edited_control) { + edited_control->add_theme_color_override(edited_color, p_color); + } +} + +void TextControlEditor::_outline_color_changed(const Color &p_color) { + if (edited_control) { + edited_control->add_theme_color_override("font_outline_color", p_color); + } +} + +void TextControlEditor::_clear_formatting() { + if (edited_control) { + edited_control->begin_bulk_theme_override(); + edited_control->remove_theme_font_override(edited_font); + edited_control->remove_theme_font_size_override(edited_font_size); + edited_control->remove_theme_color_override(edited_color); + edited_control->remove_theme_color_override("font_outline_color"); + edited_control->remove_theme_constant_override("outline_size"); + edited_control->end_bulk_theme_override(); + _update_control(); + } +} + +void TextControlEditor::edit(Object *p_object) { + Control *ctrl = Object::cast_to<Control>(p_object); + if (!ctrl) { + edited_control = nullptr; + custom_font = Ref<Font>(); + } else { + edited_control = ctrl; + custom_font = Ref<Font>(); + _update_control(); + } +} + +bool TextControlEditor::handles(Object *p_object) const { + Control *ctrl = Object::cast_to<Control>(p_object); + if (!ctrl) { + return false; + } else { + bool valid = false; + ctrl->get("text", &valid); + return valid; + } +} + +TextControlEditor::TextControlEditor() { + add_child(memnew(VSeparator)); + + font_list = memnew(OptionButton); + font_list->set_flat(true); + font_list->set_tooltip(TTR("Font")); + add_child(font_list); + font_list->connect("item_selected", callable_mp(this, &TextControlEditor::_font_selected)); + + font_style_list = memnew(OptionButton); + font_style_list->set_flat(true); + font_style_list->set_tooltip(TTR("Font style")); + font_style_list->set_toggle_mode(true); + add_child(font_style_list); + font_style_list->connect("item_selected", callable_mp(this, &TextControlEditor::_font_style_selected)); + + font_size_list = memnew(SpinBox); + font_size_list->set_tooltip(TTR("Font Size")); + font_size_list->get_line_edit()->add_theme_constant_override("minimum_character_width", 2); + font_size_list->set_min(6); + font_size_list->set_step(1); + font_size_list->set_max(96); + font_size_list->get_line_edit()->set_flat(true); + add_child(font_size_list); + font_size_list->connect("value_changed", callable_mp(this, &TextControlEditor::_font_size_selected)); + + font_color_picker = memnew(ColorPickerButton); + font_color_picker->set_custom_minimum_size(Size2(20, 0) * EDSCALE); + font_color_picker->set_flat(true); + font_color_picker->set_tooltip(TTR("Text Color")); + add_child(font_color_picker); + font_color_picker->connect("color_changed", callable_mp(this, &TextControlEditor::_font_color_changed)); + + add_child(memnew(VSeparator)); + + outline_size_list = memnew(SpinBox); + outline_size_list->set_tooltip(TTR("Outline Size")); + outline_size_list->get_line_edit()->add_theme_constant_override("minimum_character_width", 2); + outline_size_list->set_min(0); + outline_size_list->set_step(1); + outline_size_list->set_max(96); + outline_size_list->get_line_edit()->set_flat(true); + add_child(outline_size_list); + outline_size_list->connect("value_changed", callable_mp(this, &TextControlEditor::_outline_size_selected)); + + outline_color_picker = memnew(ColorPickerButton); + outline_color_picker->set_custom_minimum_size(Size2(20, 0) * EDSCALE); + outline_color_picker->set_flat(true); + outline_color_picker->set_tooltip(TTR("Outline Color")); + add_child(outline_color_picker); + outline_color_picker->connect("color_changed", callable_mp(this, &TextControlEditor::_outline_color_changed)); + + add_child(memnew(VSeparator)); + + clear_formatting = memnew(Button); + clear_formatting->set_flat(true); + clear_formatting->set_tooltip(TTR("Clear Formatting")); + add_child(clear_formatting); + clear_formatting->connect("pressed", callable_mp(this, &TextControlEditor::_clear_formatting)); +} + +/*************************************************************************/ + +void TextControlEditorPlugin::edit(Object *p_object) { + text_ctl_editor->edit(p_object); +} + +bool TextControlEditorPlugin::handles(Object *p_object) const { + return text_ctl_editor->handles(p_object); +} + +void TextControlEditorPlugin::make_visible(bool p_visible) { + if (p_visible) { + text_ctl_editor->show(); + } else { + text_ctl_editor->hide(); + text_ctl_editor->edit(nullptr); + } +} + +TextControlEditorPlugin::TextControlEditorPlugin(EditorNode *p_node) { + editor = p_node; + text_ctl_editor = memnew(TextControlEditor); + CanvasItemEditor::get_singleton()->add_control_to_menu_panel(text_ctl_editor); + + text_ctl_editor->hide(); +} diff --git a/editor/plugins/text_control_editor_plugin.h b/editor/plugins/text_control_editor_plugin.h new file mode 100644 index 0000000000..7f4aa3754c --- /dev/null +++ b/editor/plugins/text_control_editor_plugin.h @@ -0,0 +1,119 @@ +/*************************************************************************/ +/* text_control_editor_plugin.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 TEXT_CONTROL_EDITOR_PLUGIN_H +#define TEXT_CONTROL_EDITOR_PLUGIN_H + +#include "canvas_item_editor_plugin.h" +#include "editor/editor_file_system.h" +#include "editor/editor_inspector.h" +#include "editor/editor_node.h" +#include "editor/editor_plugin.h" +#include "scene/gui/color_rect.h" +#include "scene/gui/menu_button.h" +#include "scene/gui/option_button.h" +#include "scene/gui/popup_menu.h" + +/*************************************************************************/ + +class TextControlEditor : public HBoxContainer { + GDCLASS(TextControlEditor, HBoxContainer); + + enum FontInfoID { + FONT_INFO_THEME_DEFAULT = 0, + FONT_INFO_USER_CUSTOM = 1, + FONT_INFO_ID = 100, + }; + + Map<String, Map<String, String>> fonts; + + OptionButton *font_list = nullptr; + SpinBox *font_size_list = nullptr; + OptionButton *font_style_list = nullptr; + ColorPickerButton *font_color_picker = nullptr; + SpinBox *outline_size_list = nullptr; + ColorPickerButton *outline_color_picker = nullptr; + Button *clear_formatting = nullptr; + + Control *edited_control = nullptr; + String edited_color; + String edited_font; + String edited_font_size; + Ref<Font> custom_font; + +protected: + void _notification(int p_notification); + static void _bind_methods(){}; + + void _find_resources(EditorFileSystemDirectory *p_dir); + void _reload_fonts(const String &p_path); + + void _update_fonts_menu(); + void _update_styles_menu(); + void _update_control(); + + void _font_selected(int p_id); + void _font_style_selected(int p_id); + void _set_font(); + + void _font_size_selected(double p_size); + void _outline_size_selected(double p_size); + + void _font_color_changed(const Color &p_color); + void _outline_color_changed(const Color &p_color); + + void _clear_formatting(); + +public: + void edit(Object *p_object); + bool handles(Object *p_object) const; + + TextControlEditor(); +}; + +/*************************************************************************/ + +class TextControlEditorPlugin : public EditorPlugin { + GDCLASS(TextControlEditorPlugin, EditorPlugin); + + TextControlEditor *text_ctl_editor; + EditorNode *editor; + +public: + virtual String get_name() const override { return "TextControlFontEditor"; } + bool has_main_screen() const override { return false; } + virtual void edit(Object *p_object) override; + virtual bool handles(Object *p_object) const override; + virtual void make_visible(bool p_visible) override; + + TextControlEditorPlugin(EditorNode *p_node); +}; + +#endif // TEXT_CONTROL_EDITOR_PLUGIN_H diff --git a/editor/plugins/texture_3d_editor_plugin.cpp b/editor/plugins/texture_3d_editor_plugin.cpp index bd1923f4ab..b4e394a1c0 100644 --- a/editor/plugins/texture_3d_editor_plugin.cpp +++ b/editor/plugins/texture_3d_editor_plugin.cpp @@ -173,7 +173,7 @@ Texture3DEditor::Texture3DEditor() { info->set_v_grow_direction(GROW_DIRECTION_BEGIN); info->add_theme_color_override("font_color", Color(1, 1, 1, 1)); info->add_theme_color_override("font_shadow_color", Color(0, 0, 0, 0.5)); - info->add_theme_constant_override("shadow_as_outline", 1); + info->add_theme_constant_override("shadow_outline_size", 1); info->add_theme_constant_override("shadow_offset_x", 2); info->add_theme_constant_override("shadow_offset_y", 2); diff --git a/editor/plugins/texture_editor_plugin.cpp b/editor/plugins/texture_editor_plugin.cpp index b9ec6bf5ab..e25b0270b4 100644 --- a/editor/plugins/texture_editor_plugin.cpp +++ b/editor/plugins/texture_editor_plugin.cpp @@ -101,7 +101,7 @@ TexturePreview::TexturePreview(Ref<Texture2D> p_texture, bool p_show_metadata) { metadata_label->add_theme_color_override("font_outline_color", Color::named("black")); metadata_label->add_theme_constant_override("outline_size", 2 * EDSCALE); - metadata_label->add_theme_constant_override("shadow_as_outline", 1); + metadata_label->add_theme_constant_override("shadow_outline_size", 1); metadata_label->set_h_size_flags(Control::SIZE_SHRINK_END); metadata_label->set_v_size_flags(Control::SIZE_SHRINK_END); diff --git a/editor/plugins/texture_layered_editor_plugin.cpp b/editor/plugins/texture_layered_editor_plugin.cpp index 424e018a47..ee62138d12 100644 --- a/editor/plugins/texture_layered_editor_plugin.cpp +++ b/editor/plugins/texture_layered_editor_plugin.cpp @@ -249,7 +249,7 @@ TextureLayeredEditor::TextureLayeredEditor() { info->set_v_grow_direction(GROW_DIRECTION_BEGIN); info->add_theme_color_override("font_color", Color(1, 1, 1, 1)); info->add_theme_color_override("font_shadow_color", Color(0, 0, 0, 0.5)); - info->add_theme_constant_override("shadow_as_outline", 1); + info->add_theme_constant_override("shadow_outline_size", 1); info->add_theme_constant_override("shadow_offset_x", 2); info->add_theme_constant_override("shadow_offset_y", 2); diff --git a/editor/rename_dialog.cpp b/editor/rename_dialog.cpp index 2792c193d9..f5b70504fa 100644 --- a/editor/rename_dialog.cpp +++ b/editor/rename_dialog.cpp @@ -461,7 +461,7 @@ String RenameDialog::_substitute(const String &subject, const Node *node, int co void RenameDialog::_error_handler(void *p_self, const char *p_func, const char *p_file, int p_line, const char *p_error, const char *p_errorexp, bool p_editor_notify, ErrorHandlerType p_type) { RenameDialog *self = (RenameDialog *)p_self; - String source_file(p_file); + String source_file = String::utf8(p_file); // Only show first error that is related to "regex" if (self->has_errors || source_file.find("regex") < 0) { @@ -470,9 +470,9 @@ void RenameDialog::_error_handler(void *p_self, const char *p_func, const char * String err_str; if (p_errorexp && p_errorexp[0]) { - err_str = p_errorexp; + err_str = String::utf8(p_errorexp); } else { - err_str = p_error; + err_str = String::utf8(p_error); } self->has_errors = true; diff --git a/main/main.cpp b/main/main.cpp index 863ffccfae..0cf805f94a 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -2051,8 +2051,6 @@ bool Main::start() { GLOBAL_DEF("mono/profiler/args", "log:calls,alloc,sample,output=output.mlpd"); GLOBAL_DEF("mono/profiler/enabled", false); GLOBAL_DEF("mono/unhandled_exception_policy", 0); - // From editor/csharp_project.cpp. - GLOBAL_DEF("mono/project/auto_update_project", true); #endif DocTools doc; diff --git a/misc/dist/osx_tools.app/Contents/Resources/af.lproj/InfoPlist.strings b/misc/dist/osx_tools.app/Contents/Resources/af.lproj/InfoPlist.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/misc/dist/osx_tools.app/Contents/Resources/af.lproj/InfoPlist.strings diff --git a/misc/dist/osx_tools.app/Contents/Resources/ar.lproj/InfoPlist.strings b/misc/dist/osx_tools.app/Contents/Resources/ar.lproj/InfoPlist.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/misc/dist/osx_tools.app/Contents/Resources/ar.lproj/InfoPlist.strings diff --git a/misc/dist/osx_tools.app/Contents/Resources/az.lproj/InfoPlist.strings b/misc/dist/osx_tools.app/Contents/Resources/az.lproj/InfoPlist.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/misc/dist/osx_tools.app/Contents/Resources/az.lproj/InfoPlist.strings diff --git a/misc/dist/osx_tools.app/Contents/Resources/bg.lproj/InfoPlist.strings b/misc/dist/osx_tools.app/Contents/Resources/bg.lproj/InfoPlist.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/misc/dist/osx_tools.app/Contents/Resources/bg.lproj/InfoPlist.strings diff --git a/misc/dist/osx_tools.app/Contents/Resources/bn.lproj/InfoPlist.strings b/misc/dist/osx_tools.app/Contents/Resources/bn.lproj/InfoPlist.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/misc/dist/osx_tools.app/Contents/Resources/bn.lproj/InfoPlist.strings diff --git a/misc/dist/osx_tools.app/Contents/Resources/br.lproj/InfoPlist.strings b/misc/dist/osx_tools.app/Contents/Resources/br.lproj/InfoPlist.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/misc/dist/osx_tools.app/Contents/Resources/br.lproj/InfoPlist.strings diff --git a/misc/dist/osx_tools.app/Contents/Resources/ca.lproj/InfoPlist.strings b/misc/dist/osx_tools.app/Contents/Resources/ca.lproj/InfoPlist.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/misc/dist/osx_tools.app/Contents/Resources/ca.lproj/InfoPlist.strings diff --git a/misc/dist/osx_tools.app/Contents/Resources/cs.lproj/InfoPlist.strings b/misc/dist/osx_tools.app/Contents/Resources/cs.lproj/InfoPlist.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/misc/dist/osx_tools.app/Contents/Resources/cs.lproj/InfoPlist.strings diff --git a/misc/dist/osx_tools.app/Contents/Resources/da.lproj/InfoPlist.strings b/misc/dist/osx_tools.app/Contents/Resources/da.lproj/InfoPlist.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/misc/dist/osx_tools.app/Contents/Resources/da.lproj/InfoPlist.strings diff --git a/misc/dist/osx_tools.app/Contents/Resources/de.lproj/InfoPlist.strings b/misc/dist/osx_tools.app/Contents/Resources/de.lproj/InfoPlist.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/misc/dist/osx_tools.app/Contents/Resources/de.lproj/InfoPlist.strings diff --git a/misc/dist/osx_tools.app/Contents/Resources/el.lproj/InfoPlist.strings b/misc/dist/osx_tools.app/Contents/Resources/el.lproj/InfoPlist.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/misc/dist/osx_tools.app/Contents/Resources/el.lproj/InfoPlist.strings diff --git a/misc/dist/osx_tools.app/Contents/Resources/eo.lproj/InfoPlist.strings b/misc/dist/osx_tools.app/Contents/Resources/eo.lproj/InfoPlist.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/misc/dist/osx_tools.app/Contents/Resources/eo.lproj/InfoPlist.strings diff --git a/misc/dist/osx_tools.app/Contents/Resources/es.lproj/InfoPlist.strings b/misc/dist/osx_tools.app/Contents/Resources/es.lproj/InfoPlist.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/misc/dist/osx_tools.app/Contents/Resources/es.lproj/InfoPlist.strings diff --git a/misc/dist/osx_tools.app/Contents/Resources/es_AR.lproj/InfoPlist.strings b/misc/dist/osx_tools.app/Contents/Resources/es_AR.lproj/InfoPlist.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/misc/dist/osx_tools.app/Contents/Resources/es_AR.lproj/InfoPlist.strings diff --git a/misc/dist/osx_tools.app/Contents/Resources/et.lproj/InfoPlist.strings b/misc/dist/osx_tools.app/Contents/Resources/et.lproj/InfoPlist.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/misc/dist/osx_tools.app/Contents/Resources/et.lproj/InfoPlist.strings diff --git a/misc/dist/osx_tools.app/Contents/Resources/eu.lproj/InfoPlist.strings b/misc/dist/osx_tools.app/Contents/Resources/eu.lproj/InfoPlist.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/misc/dist/osx_tools.app/Contents/Resources/eu.lproj/InfoPlist.strings diff --git a/misc/dist/osx_tools.app/Contents/Resources/fa.lproj/InfoPlist.strings b/misc/dist/osx_tools.app/Contents/Resources/fa.lproj/InfoPlist.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/misc/dist/osx_tools.app/Contents/Resources/fa.lproj/InfoPlist.strings diff --git a/misc/dist/osx_tools.app/Contents/Resources/fi.lproj/InfoPlist.strings b/misc/dist/osx_tools.app/Contents/Resources/fi.lproj/InfoPlist.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/misc/dist/osx_tools.app/Contents/Resources/fi.lproj/InfoPlist.strings diff --git a/misc/dist/osx_tools.app/Contents/Resources/fil.lproj/InfoPlist.strings b/misc/dist/osx_tools.app/Contents/Resources/fil.lproj/InfoPlist.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/misc/dist/osx_tools.app/Contents/Resources/fil.lproj/InfoPlist.strings diff --git a/misc/dist/osx_tools.app/Contents/Resources/fr.lproj/InfoPlist.strings b/misc/dist/osx_tools.app/Contents/Resources/fr.lproj/InfoPlist.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/misc/dist/osx_tools.app/Contents/Resources/fr.lproj/InfoPlist.strings diff --git a/misc/dist/osx_tools.app/Contents/Resources/ga.lproj/InfoPlist.strings b/misc/dist/osx_tools.app/Contents/Resources/ga.lproj/InfoPlist.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/misc/dist/osx_tools.app/Contents/Resources/ga.lproj/InfoPlist.strings diff --git a/misc/dist/osx_tools.app/Contents/Resources/gl.lproj/InfoPlist.strings b/misc/dist/osx_tools.app/Contents/Resources/gl.lproj/InfoPlist.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/misc/dist/osx_tools.app/Contents/Resources/gl.lproj/InfoPlist.strings diff --git a/misc/dist/osx_tools.app/Contents/Resources/he.lproj/InfoPlist.strings b/misc/dist/osx_tools.app/Contents/Resources/he.lproj/InfoPlist.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/misc/dist/osx_tools.app/Contents/Resources/he.lproj/InfoPlist.strings diff --git a/misc/dist/osx_tools.app/Contents/Resources/hi.lproj/InfoPlist.strings b/misc/dist/osx_tools.app/Contents/Resources/hi.lproj/InfoPlist.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/misc/dist/osx_tools.app/Contents/Resources/hi.lproj/InfoPlist.strings diff --git a/misc/dist/osx_tools.app/Contents/Resources/hr.lproj/InfoPlist.strings b/misc/dist/osx_tools.app/Contents/Resources/hr.lproj/InfoPlist.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/misc/dist/osx_tools.app/Contents/Resources/hr.lproj/InfoPlist.strings diff --git a/misc/dist/osx_tools.app/Contents/Resources/hu.lproj/InfoPlist.strings b/misc/dist/osx_tools.app/Contents/Resources/hu.lproj/InfoPlist.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/misc/dist/osx_tools.app/Contents/Resources/hu.lproj/InfoPlist.strings diff --git a/misc/dist/osx_tools.app/Contents/Resources/id.lproj/InfoPlist.strings b/misc/dist/osx_tools.app/Contents/Resources/id.lproj/InfoPlist.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/misc/dist/osx_tools.app/Contents/Resources/id.lproj/InfoPlist.strings diff --git a/misc/dist/osx_tools.app/Contents/Resources/is.lproj/InfoPlist.strings b/misc/dist/osx_tools.app/Contents/Resources/is.lproj/InfoPlist.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/misc/dist/osx_tools.app/Contents/Resources/is.lproj/InfoPlist.strings diff --git a/misc/dist/osx_tools.app/Contents/Resources/it.lproj/InfoPlist.strings b/misc/dist/osx_tools.app/Contents/Resources/it.lproj/InfoPlist.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/misc/dist/osx_tools.app/Contents/Resources/it.lproj/InfoPlist.strings diff --git a/misc/dist/osx_tools.app/Contents/Resources/ja.lproj/InfoPlist.strings b/misc/dist/osx_tools.app/Contents/Resources/ja.lproj/InfoPlist.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/misc/dist/osx_tools.app/Contents/Resources/ja.lproj/InfoPlist.strings diff --git a/misc/dist/osx_tools.app/Contents/Resources/ka.lproj/InfoPlist.strings b/misc/dist/osx_tools.app/Contents/Resources/ka.lproj/InfoPlist.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/misc/dist/osx_tools.app/Contents/Resources/ka.lproj/InfoPlist.strings diff --git a/misc/dist/osx_tools.app/Contents/Resources/km.lproj/InfoPlist.strings b/misc/dist/osx_tools.app/Contents/Resources/km.lproj/InfoPlist.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/misc/dist/osx_tools.app/Contents/Resources/km.lproj/InfoPlist.strings diff --git a/misc/dist/osx_tools.app/Contents/Resources/ko.lproj/InfoPlist.strings b/misc/dist/osx_tools.app/Contents/Resources/ko.lproj/InfoPlist.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/misc/dist/osx_tools.app/Contents/Resources/ko.lproj/InfoPlist.strings diff --git a/misc/dist/osx_tools.app/Contents/Resources/lt.lproj/InfoPlist.strings b/misc/dist/osx_tools.app/Contents/Resources/lt.lproj/InfoPlist.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/misc/dist/osx_tools.app/Contents/Resources/lt.lproj/InfoPlist.strings diff --git a/misc/dist/osx_tools.app/Contents/Resources/lv.lproj/InfoPlist.strings b/misc/dist/osx_tools.app/Contents/Resources/lv.lproj/InfoPlist.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/misc/dist/osx_tools.app/Contents/Resources/lv.lproj/InfoPlist.strings diff --git a/misc/dist/osx_tools.app/Contents/Resources/mi.lproj/InfoPlist.strings b/misc/dist/osx_tools.app/Contents/Resources/mi.lproj/InfoPlist.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/misc/dist/osx_tools.app/Contents/Resources/mi.lproj/InfoPlist.strings diff --git a/misc/dist/osx_tools.app/Contents/Resources/mk.lproj/InfoPlist.strings b/misc/dist/osx_tools.app/Contents/Resources/mk.lproj/InfoPlist.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/misc/dist/osx_tools.app/Contents/Resources/mk.lproj/InfoPlist.strings diff --git a/misc/dist/osx_tools.app/Contents/Resources/ml.lproj/InfoPlist.strings b/misc/dist/osx_tools.app/Contents/Resources/ml.lproj/InfoPlist.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/misc/dist/osx_tools.app/Contents/Resources/ml.lproj/InfoPlist.strings diff --git a/misc/dist/osx_tools.app/Contents/Resources/mr.lproj/InfoPlist.strings b/misc/dist/osx_tools.app/Contents/Resources/mr.lproj/InfoPlist.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/misc/dist/osx_tools.app/Contents/Resources/mr.lproj/InfoPlist.strings diff --git a/misc/dist/osx_tools.app/Contents/Resources/ms.lproj/InfoPlist.strings b/misc/dist/osx_tools.app/Contents/Resources/ms.lproj/InfoPlist.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/misc/dist/osx_tools.app/Contents/Resources/ms.lproj/InfoPlist.strings diff --git a/misc/dist/osx_tools.app/Contents/Resources/nb.lproj/InfoPlist.strings b/misc/dist/osx_tools.app/Contents/Resources/nb.lproj/InfoPlist.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/misc/dist/osx_tools.app/Contents/Resources/nb.lproj/InfoPlist.strings diff --git a/misc/dist/osx_tools.app/Contents/Resources/nl.lproj/InfoPlist.strings b/misc/dist/osx_tools.app/Contents/Resources/nl.lproj/InfoPlist.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/misc/dist/osx_tools.app/Contents/Resources/nl.lproj/InfoPlist.strings diff --git a/misc/dist/osx_tools.app/Contents/Resources/or.lproj/InfoPlist.strings b/misc/dist/osx_tools.app/Contents/Resources/or.lproj/InfoPlist.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/misc/dist/osx_tools.app/Contents/Resources/or.lproj/InfoPlist.strings diff --git a/misc/dist/osx_tools.app/Contents/Resources/pl.lproj/InfoPlist.strings b/misc/dist/osx_tools.app/Contents/Resources/pl.lproj/InfoPlist.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/misc/dist/osx_tools.app/Contents/Resources/pl.lproj/InfoPlist.strings diff --git a/misc/dist/osx_tools.app/Contents/Resources/pt.lproj/InfoPlist.strings b/misc/dist/osx_tools.app/Contents/Resources/pt.lproj/InfoPlist.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/misc/dist/osx_tools.app/Contents/Resources/pt.lproj/InfoPlist.strings diff --git a/misc/dist/osx_tools.app/Contents/Resources/pt_BR.lproj/InfoPlist.strings b/misc/dist/osx_tools.app/Contents/Resources/pt_BR.lproj/InfoPlist.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/misc/dist/osx_tools.app/Contents/Resources/pt_BR.lproj/InfoPlist.strings diff --git a/misc/dist/osx_tools.app/Contents/Resources/ro.lproj/InfoPlist.strings b/misc/dist/osx_tools.app/Contents/Resources/ro.lproj/InfoPlist.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/misc/dist/osx_tools.app/Contents/Resources/ro.lproj/InfoPlist.strings diff --git a/misc/dist/osx_tools.app/Contents/Resources/ru.lproj/InfoPlist.strings b/misc/dist/osx_tools.app/Contents/Resources/ru.lproj/InfoPlist.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/misc/dist/osx_tools.app/Contents/Resources/ru.lproj/InfoPlist.strings diff --git a/misc/dist/osx_tools.app/Contents/Resources/si.lproj/InfoPlist.strings b/misc/dist/osx_tools.app/Contents/Resources/si.lproj/InfoPlist.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/misc/dist/osx_tools.app/Contents/Resources/si.lproj/InfoPlist.strings diff --git a/misc/dist/osx_tools.app/Contents/Resources/sk.lproj/InfoPlist.strings b/misc/dist/osx_tools.app/Contents/Resources/sk.lproj/InfoPlist.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/misc/dist/osx_tools.app/Contents/Resources/sk.lproj/InfoPlist.strings diff --git a/misc/dist/osx_tools.app/Contents/Resources/sl.lproj/InfoPlist.strings b/misc/dist/osx_tools.app/Contents/Resources/sl.lproj/InfoPlist.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/misc/dist/osx_tools.app/Contents/Resources/sl.lproj/InfoPlist.strings diff --git a/misc/dist/osx_tools.app/Contents/Resources/sq.lproj/InfoPlist.strings b/misc/dist/osx_tools.app/Contents/Resources/sq.lproj/InfoPlist.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/misc/dist/osx_tools.app/Contents/Resources/sq.lproj/InfoPlist.strings diff --git a/misc/dist/osx_tools.app/Contents/Resources/sr-Cyrl.lproj/InfoPlist.strings b/misc/dist/osx_tools.app/Contents/Resources/sr-Cyrl.lproj/InfoPlist.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/misc/dist/osx_tools.app/Contents/Resources/sr-Cyrl.lproj/InfoPlist.strings diff --git a/misc/dist/osx_tools.app/Contents/Resources/sr-Latn.lproj/InfoPlist.strings b/misc/dist/osx_tools.app/Contents/Resources/sr-Latn.lproj/InfoPlist.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/misc/dist/osx_tools.app/Contents/Resources/sr-Latn.lproj/InfoPlist.strings diff --git a/misc/dist/osx_tools.app/Contents/Resources/sv.lproj/InfoPlist.strings b/misc/dist/osx_tools.app/Contents/Resources/sv.lproj/InfoPlist.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/misc/dist/osx_tools.app/Contents/Resources/sv.lproj/InfoPlist.strings diff --git a/misc/dist/osx_tools.app/Contents/Resources/ta.lproj/InfoPlist.strings b/misc/dist/osx_tools.app/Contents/Resources/ta.lproj/InfoPlist.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/misc/dist/osx_tools.app/Contents/Resources/ta.lproj/InfoPlist.strings diff --git a/misc/dist/osx_tools.app/Contents/Resources/te.lproj/InfoPlist.strings b/misc/dist/osx_tools.app/Contents/Resources/te.lproj/InfoPlist.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/misc/dist/osx_tools.app/Contents/Resources/te.lproj/InfoPlist.strings diff --git a/misc/dist/osx_tools.app/Contents/Resources/th.lproj/InfoPlist.strings b/misc/dist/osx_tools.app/Contents/Resources/th.lproj/InfoPlist.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/misc/dist/osx_tools.app/Contents/Resources/th.lproj/InfoPlist.strings diff --git a/misc/dist/osx_tools.app/Contents/Resources/tr.lproj/InfoPlist.strings b/misc/dist/osx_tools.app/Contents/Resources/tr.lproj/InfoPlist.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/misc/dist/osx_tools.app/Contents/Resources/tr.lproj/InfoPlist.strings diff --git a/misc/dist/osx_tools.app/Contents/Resources/tt.lproj/InfoPlist.strings b/misc/dist/osx_tools.app/Contents/Resources/tt.lproj/InfoPlist.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/misc/dist/osx_tools.app/Contents/Resources/tt.lproj/InfoPlist.strings diff --git a/misc/dist/osx_tools.app/Contents/Resources/tzm.lproj/InfoPlist.strings b/misc/dist/osx_tools.app/Contents/Resources/tzm.lproj/InfoPlist.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/misc/dist/osx_tools.app/Contents/Resources/tzm.lproj/InfoPlist.strings diff --git a/misc/dist/osx_tools.app/Contents/Resources/uk.lproj/InfoPlist.strings b/misc/dist/osx_tools.app/Contents/Resources/uk.lproj/InfoPlist.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/misc/dist/osx_tools.app/Contents/Resources/uk.lproj/InfoPlist.strings diff --git a/misc/dist/osx_tools.app/Contents/Resources/ur_PK.lproj/InfoPlist.strings b/misc/dist/osx_tools.app/Contents/Resources/ur_PK.lproj/InfoPlist.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/misc/dist/osx_tools.app/Contents/Resources/ur_PK.lproj/InfoPlist.strings diff --git a/misc/dist/osx_tools.app/Contents/Resources/vi.lproj/InfoPlist.strings b/misc/dist/osx_tools.app/Contents/Resources/vi.lproj/InfoPlist.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/misc/dist/osx_tools.app/Contents/Resources/vi.lproj/InfoPlist.strings diff --git a/misc/dist/osx_tools.app/Contents/Resources/zh_CN.lproj/InfoPlist.strings b/misc/dist/osx_tools.app/Contents/Resources/zh_CN.lproj/InfoPlist.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/misc/dist/osx_tools.app/Contents/Resources/zh_CN.lproj/InfoPlist.strings diff --git a/misc/dist/osx_tools.app/Contents/Resources/zh_HK.lproj/InfoPlist.strings b/misc/dist/osx_tools.app/Contents/Resources/zh_HK.lproj/InfoPlist.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/misc/dist/osx_tools.app/Contents/Resources/zh_HK.lproj/InfoPlist.strings diff --git a/misc/dist/osx_tools.app/Contents/Resources/zh_TW.lproj/InfoPlist.strings b/misc/dist/osx_tools.app/Contents/Resources/zh_TW.lproj/InfoPlist.strings new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/misc/dist/osx_tools.app/Contents/Resources/zh_TW.lproj/InfoPlist.strings diff --git a/modules/gdscript/gdscript_vm.cpp b/modules/gdscript/gdscript_vm.cpp index a1cc2246d6..6dd8c3e0dd 100644 --- a/modules/gdscript/gdscript_vm.cpp +++ b/modules/gdscript/gdscript_vm.cpp @@ -3309,7 +3309,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a } int err_line = line; if (err_text == "") { - err_text = "Internal Script Error! - opcode #" + itos(last_opcode) + " (report please)."; + err_text = "Internal script error! Opcode: " + itos(last_opcode) + " (please report)."; } if (!GDScriptLanguage::get_singleton()->debug_break(err_text, false)) { diff --git a/modules/mono/doc_classes/CSharpScript.xml b/modules/mono/doc_classes/CSharpScript.xml index abd860a55f..2bca8bc24e 100644 --- a/modules/mono/doc_classes/CSharpScript.xml +++ b/modules/mono/doc_classes/CSharpScript.xml @@ -12,13 +12,10 @@ </tutorials> <methods> <method name="new" qualifiers="vararg"> - <return type="Variant"> - </return> + <return type="Variant" /> <description> Returns a new instance of the script. </description> </method> </methods> - <constants> - </constants> </class> diff --git a/modules/mono/doc_classes/GodotSharp.xml b/modules/mono/doc_classes/GodotSharp.xml index 417f8ac704..a148072245 100644 --- a/modules/mono/doc_classes/GodotSharp.xml +++ b/modules/mono/doc_classes/GodotSharp.xml @@ -11,66 +11,55 @@ </tutorials> <methods> <method name="attach_thread"> - <return type="void"> - </return> + <return type="void" /> <description> Attaches the current thread to the Mono runtime. </description> </method> <method name="detach_thread"> - <return type="void"> - </return> + <return type="void" /> <description> Detaches the current thread from the Mono runtime. </description> </method> <method name="get_domain_id"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the current MonoDomain ID. [b]Note:[/b] The Mono runtime must be initialized for this method to work (use [method is_runtime_initialized] to check). If the Mono runtime isn't initialized at the time this method is called, the engine will crash. </description> </method> <method name="get_scripts_domain_id"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the scripts MonoDomain's ID. This will be the same MonoDomain ID as [method get_domain_id], unless the scripts domain isn't loaded. [b]Note:[/b] The Mono runtime must be initialized for this method to work (use [method is_runtime_initialized] to check). If the Mono runtime isn't initialized at the time this method is called, the engine will crash. </description> </method> <method name="is_domain_finalizing_for_unload"> - <return type="bool"> - </return> - <argument index="0" name="domain_id" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="domain_id" type="int" /> <description> Returns [code]true[/code] if the domain is being finalized, [code]false[/code] otherwise. </description> </method> <method name="is_runtime_initialized"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the Mono runtime is initialized, [code]false[/code] otherwise. </description> </method> <method name="is_runtime_shutting_down"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the Mono runtime is shutting down, [code]false[/code] otherwise. </description> </method> <method name="is_scripts_domain_loaded"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the scripts domain is loaded, [code]false[/code] otherwise. </description> </method> </methods> - <constants> - </constants> </class> diff --git a/modules/text_server_adv/text_server_adv.cpp b/modules/text_server_adv/text_server_adv.cpp index 129bc6af0b..1a0b0e357d 100644 --- a/modules/text_server_adv/text_server_adv.cpp +++ b/modules/text_server_adv/text_server_adv.cpp @@ -1279,6 +1279,23 @@ _FORCE_INLINE_ bool TextServerAdvanced::_ensure_cache_for_size(FontDataAdvanced fd->underline_thickness = (FT_MulFix(fd->face->underline_thickness, fd->face->size->metrics.y_scale) / 64.0) / fd->oversampling * fd->scale; if (!p_font_data->face_init) { + // Get style flags and name. + if (fd->face->family_name != nullptr) { + p_font_data->font_name = String::utf8((const char *)fd->face->family_name); + } + if (fd->face->style_name != nullptr) { + p_font_data->style_name = String::utf8((const char *)fd->face->style_name); + } + p_font_data->style_flags = 0; + if (fd->face->style_flags & FT_STYLE_FLAG_BOLD) { + p_font_data->style_flags |= FONT_BOLD; + } + if (fd->face->style_flags & FT_STYLE_FLAG_ITALIC) { + p_font_data->style_flags |= FONT_ITALIC; + } + if (fd->face->face_flags & FT_FACE_FLAG_FIXED_WIDTH) { + p_font_data->style_flags |= FONT_FIXED_WIDTH; + } // Get supported scripts from OpenType font data. p_font_data->supported_scripts.clear(); unsigned int count = hb_ot_layout_table_get_script_tags(hb_font_get_face(fd->hb_handle), HB_OT_TAG_GSUB, 0, nullptr, nullptr); @@ -1648,6 +1665,66 @@ void TextServerAdvanced::font_set_data_ptr(RID p_font_rid, const uint8_t *p_data fd->data_size = p_data_size; } +void TextServerAdvanced::font_set_style(RID p_font_rid, uint32_t /*FontStyle*/ p_style) { + FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); + ERR_FAIL_COND(!fd); + + MutexLock lock(fd->mutex); + Vector2i size = _get_size(fd, 16); + ERR_FAIL_COND(!_ensure_cache_for_size(fd, size)); + fd->style_flags = p_style; +} + +uint32_t /*FontStyle*/ TextServerAdvanced::font_get_style(RID p_font_rid) const { + FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); + ERR_FAIL_COND_V(!fd, 0); + + MutexLock lock(fd->mutex); + Vector2i size = _get_size(fd, 16); + ERR_FAIL_COND_V(!_ensure_cache_for_size(fd, size), 0); + return fd->style_flags; +} + +void TextServerAdvanced::font_set_style_name(RID p_font_rid, const String &p_name) { + FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); + ERR_FAIL_COND(!fd); + + MutexLock lock(fd->mutex); + Vector2i size = _get_size(fd, 16); + ERR_FAIL_COND(!_ensure_cache_for_size(fd, size)); + fd->style_name = p_name; +} + +String TextServerAdvanced::font_get_style_name(RID p_font_rid) const { + FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); + ERR_FAIL_COND_V(!fd, String()); + + MutexLock lock(fd->mutex); + Vector2i size = _get_size(fd, 16); + ERR_FAIL_COND_V(!_ensure_cache_for_size(fd, size), String()); + return fd->style_name; +} + +void TextServerAdvanced::font_set_name(RID p_font_rid, const String &p_name) { + FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); + ERR_FAIL_COND(!fd); + + MutexLock lock(fd->mutex); + Vector2i size = _get_size(fd, 16); + ERR_FAIL_COND(!_ensure_cache_for_size(fd, size)); + fd->font_name = p_name; +} + +String TextServerAdvanced::font_get_name(RID p_font_rid) const { + FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); + ERR_FAIL_COND_V(!fd, String()); + + MutexLock lock(fd->mutex); + Vector2i size = _get_size(fd, 16); + ERR_FAIL_COND_V(!_ensure_cache_for_size(fd, size), String()); + return fd->font_name; +} + void TextServerAdvanced::font_set_antialiased(RID p_font_rid, bool p_antialiased) { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -2931,6 +3008,27 @@ TextServer::Direction TextServerAdvanced::shaped_text_get_direction(RID p_shaped return sd->direction; } +void TextServerAdvanced::shaped_text_set_custom_punctuation(RID p_shaped, const String &p_punct) { + _THREAD_SAFE_METHOD_ + ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); + ERR_FAIL_COND(!sd); + + if (sd->custom_punct != p_punct) { + if (sd->parent != RID()) { + full_copy(sd); + } + sd->custom_punct = p_punct; + invalidate(sd); + } +} + +String TextServerAdvanced::shaped_text_get_custom_punctuation(RID p_shaped) const { + _THREAD_SAFE_METHOD_ + const ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); + ERR_FAIL_COND_V(!sd, String()); + return sd->custom_punct; +} + void TextServerAdvanced::shaped_text_set_bidi_override(RID p_shaped, const Array &p_override) { ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND(!sd); @@ -3230,6 +3328,7 @@ RID TextServerAdvanced::shaped_text_substr(RID p_shaped, int p_start, int p_leng new_sd->orientation = sd->orientation; new_sd->direction = sd->direction; + new_sd->custom_punct = sd->custom_punct; new_sd->para_direction = sd->para_direction; new_sd->line_breaks_valid = sd->line_breaks_valid; new_sd->justification_ops_valid = sd->justification_ops_valid; @@ -3810,6 +3909,9 @@ bool TextServerAdvanced::shaped_text_update_breaks(RID p_shaped) { const char32_t *ch = sd->text.ptr(); Glyph *sd_glyphs = sd->glyphs.ptrw(); + int c_punct_size = sd->custom_punct.length(); + const char32_t *c_punct = sd->custom_punct.ptr(); + for (i = 0; i < sd_size; i++) { if (sd_glyphs[i].count > 0) { char32_t c = ch[sd_glyphs[i].start - sd->start]; @@ -3822,12 +3924,21 @@ bool TextServerAdvanced::shaped_text_update_breaks(RID p_shaped) { if (is_whitespace(c)) { sd_glyphs[i].flags |= GRAPHEME_IS_SPACE; } + if (c_punct_size == 0) { + if (u_ispunct(c) && c != 0x005F) { + sd_glyphs[i].flags |= GRAPHEME_IS_PUNCTUATION; + } + } else { + for (int j = 0; j < c_punct_size; j++) { + if (c_punct[j] == c) { + sd_glyphs[i].flags |= GRAPHEME_IS_PUNCTUATION; + break; + } + } + } if (is_underscore(c)) { sd_glyphs[i].flags |= GRAPHEME_IS_UNDERSCORE; } - if (u_ispunct(c) && c != 0x005F) { - sd_glyphs[i].flags |= GRAPHEME_IS_PUNCTUATION; - } if (breaks.has(sd->glyphs[i].start)) { if (breaks[sd->glyphs[i].start]) { sd_glyphs[i].flags |= GRAPHEME_IS_BREAK_HARD; diff --git a/modules/text_server_adv/text_server_adv.h b/modules/text_server_adv/text_server_adv.h index 15f3a7f1a9..eb8316b200 100644 --- a/modules/text_server_adv/text_server_adv.h +++ b/modules/text_server_adv/text_server_adv.h @@ -177,6 +177,10 @@ class TextServerAdvanced : public TextServer { Dictionary variation_coordinates; float oversampling = 0.f; + uint32_t style_flags = 0; + String font_name; + String style_name; + Map<Vector2i, FontDataForSizeAdvanced *> cache; bool face_init = false; @@ -321,6 +325,15 @@ public: virtual void font_set_data(RID p_font_rid, const PackedByteArray &p_data) override; virtual void font_set_data_ptr(RID p_font_rid, const uint8_t *p_data_ptr, size_t p_data_size) override; + virtual void font_set_style(RID p_font_rid, uint32_t /*FontStyle*/ p_style) override; + virtual uint32_t /*FontStyle*/ font_get_style(RID p_font_rid) const override; + + virtual void font_set_style_name(RID p_font_rid, const String &p_name) override; + virtual String font_get_style_name(RID p_font_rid) const override; + + virtual void font_set_name(RID p_font_rid, const String &p_name) override; + virtual String font_get_name(RID p_font_rid) const override; + virtual void font_set_antialiased(RID p_font_rid, bool p_antialiased) override; virtual bool font_is_antialiased(RID p_font_rid) const override; @@ -450,6 +463,9 @@ public: virtual void shaped_text_set_bidi_override(RID p_shaped, const Array &p_override) override; + virtual void shaped_text_set_custom_punctuation(RID p_shaped, const String &p_punct) override; + virtual String shaped_text_get_custom_punctuation(RID p_shaped) const override; + virtual void shaped_text_set_orientation(RID p_shaped, Orientation p_orientation = ORIENTATION_HORIZONTAL) override; virtual Orientation shaped_text_get_orientation(RID p_shaped) const override; diff --git a/modules/text_server_fb/text_server_fb.cpp b/modules/text_server_fb/text_server_fb.cpp index e0e77ff753..43a636e484 100644 --- a/modules/text_server_fb/text_server_fb.cpp +++ b/modules/text_server_fb/text_server_fb.cpp @@ -736,6 +736,23 @@ _FORCE_INLINE_ bool TextServerFallback::_ensure_cache_for_size(FontDataFallback fd->underline_thickness = (FT_MulFix(fd->face->underline_thickness, fd->face->size->metrics.y_scale) / 64.0) / fd->oversampling * fd->scale; if (!p_font_data->face_init) { + // Get style flags and name. + if (fd->face->family_name != nullptr) { + p_font_data->font_name = String::utf8((const char *)fd->face->family_name); + } + if (fd->face->style_name != nullptr) { + p_font_data->style_name = String::utf8((const char *)fd->face->style_name); + } + p_font_data->style_flags = 0; + if (fd->face->style_flags & FT_STYLE_FLAG_BOLD) { + p_font_data->style_flags |= FONT_BOLD; + } + if (fd->face->style_flags & FT_STYLE_FLAG_ITALIC) { + p_font_data->style_flags |= FONT_ITALIC; + } + if (fd->face->face_flags & FT_FACE_FLAG_FIXED_WIDTH) { + p_font_data->style_flags |= FONT_FIXED_WIDTH; + } // Read OpenType variations. p_font_data->supported_varaitions.clear(); if (fd->face->face_flags & FT_FACE_FLAG_MULTIPLE_MASTERS) { @@ -826,6 +843,66 @@ void TextServerFallback::font_set_data_ptr(RID p_font_rid, const uint8_t *p_data fd->data_size = p_data_size; } +void TextServerFallback::font_set_style(RID p_font_rid, uint32_t /*FontStyle*/ p_style) { + FontDataFallback *fd = font_owner.get_or_null(p_font_rid); + ERR_FAIL_COND(!fd); + + MutexLock lock(fd->mutex); + Vector2i size = _get_size(fd, 16); + ERR_FAIL_COND(!_ensure_cache_for_size(fd, size)); + fd->style_flags = p_style; +} + +uint32_t /*FontStyle*/ TextServerFallback::font_get_style(RID p_font_rid) const { + FontDataFallback *fd = font_owner.get_or_null(p_font_rid); + ERR_FAIL_COND_V(!fd, 0); + + MutexLock lock(fd->mutex); + Vector2i size = _get_size(fd, 16); + ERR_FAIL_COND_V(!_ensure_cache_for_size(fd, size), 0); + return fd->style_flags; +} + +void TextServerFallback::font_set_style_name(RID p_font_rid, const String &p_name) { + FontDataFallback *fd = font_owner.get_or_null(p_font_rid); + ERR_FAIL_COND(!fd); + + MutexLock lock(fd->mutex); + Vector2i size = _get_size(fd, 16); + ERR_FAIL_COND(!_ensure_cache_for_size(fd, size)); + fd->style_name = p_name; +} + +String TextServerFallback::font_get_style_name(RID p_font_rid) const { + FontDataFallback *fd = font_owner.get_or_null(p_font_rid); + ERR_FAIL_COND_V(!fd, String()); + + MutexLock lock(fd->mutex); + Vector2i size = _get_size(fd, 16); + ERR_FAIL_COND_V(!_ensure_cache_for_size(fd, size), String()); + return fd->style_name; +} + +void TextServerFallback::font_set_name(RID p_font_rid, const String &p_name) { + FontDataFallback *fd = font_owner.get_or_null(p_font_rid); + ERR_FAIL_COND(!fd); + + MutexLock lock(fd->mutex); + Vector2i size = _get_size(fd, 16); + ERR_FAIL_COND(!_ensure_cache_for_size(fd, size)); + fd->font_name = p_name; +} + +String TextServerFallback::font_get_name(RID p_font_rid) const { + FontDataFallback *fd = font_owner.get_or_null(p_font_rid); + ERR_FAIL_COND_V(!fd, String()); + + MutexLock lock(fd->mutex); + Vector2i size = _get_size(fd, 16); + ERR_FAIL_COND_V(!_ensure_cache_for_size(fd, size), String()); + return fd->font_name; +} + void TextServerFallback::font_set_antialiased(RID p_font_rid, bool p_antialiased) { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -2030,6 +2107,27 @@ TextServer::Direction TextServerFallback::shaped_text_get_direction(RID p_shaped return TextServer::DIRECTION_LTR; } +void TextServerFallback::shaped_text_set_custom_punctuation(RID p_shaped, const String &p_punct) { + _THREAD_SAFE_METHOD_ + ShapedTextData *sd = shaped_owner.get_or_null(p_shaped); + ERR_FAIL_COND(!sd); + + if (sd->custom_punct != p_punct) { + if (sd->parent != RID()) { + full_copy(sd); + } + sd->custom_punct = p_punct; + invalidate(sd); + } +} + +String TextServerFallback::shaped_text_get_custom_punctuation(RID p_shaped) const { + _THREAD_SAFE_METHOD_ + const ShapedTextData *sd = shaped_owner.get_or_null(p_shaped); + ERR_FAIL_COND_V(!sd, String()); + return sd->custom_punct; +} + void TextServerFallback::shaped_text_set_orientation(RID p_shaped, TextServer::Orientation p_orientation) { ShapedTextData *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND(!sd); @@ -2332,6 +2430,7 @@ RID TextServerFallback::shaped_text_substr(RID p_shaped, int p_start, int p_leng new_sd->orientation = sd->orientation; new_sd->direction = sd->direction; + new_sd->custom_punct = sd->custom_punct; new_sd->para_direction = sd->para_direction; new_sd->line_breaks_valid = sd->line_breaks_valid; new_sd->justification_ops_valid = sd->justification_ops_valid; @@ -2615,27 +2714,41 @@ bool TextServerFallback::shaped_text_update_breaks(RID p_shaped) { } int sd_size = sd->glyphs.size(); + Glyph *sd_glyphs = sd->glyphs.ptrw(); + + int c_punct_size = sd->custom_punct.length(); + const char32_t *c_punct = sd->custom_punct.ptr(); + for (int i = 0; i < sd_size; i++) { - if (sd->glyphs[i].count > 0) { - char32_t c = sd->text[sd->glyphs[i].start]; - if (is_punct(c)) { - sd->glyphs.write[i].flags |= GRAPHEME_IS_PUNCTUATION; + if (sd_glyphs[i].count > 0) { + char32_t c = sd->text[sd_glyphs[i].start]; + if (c_punct_size == 0) { + if (is_punct(c)) { + sd_glyphs[i].flags |= GRAPHEME_IS_PUNCTUATION; + } + } else { + for (int j = 0; j < c_punct_size; j++) { + if (c_punct[j] == c) { + sd_glyphs[i].flags |= GRAPHEME_IS_PUNCTUATION; + break; + } + } } if (is_underscore(c)) { sd->glyphs.write[i].flags |= GRAPHEME_IS_UNDERSCORE; } if (is_whitespace(c) && !is_linebreak(c)) { - sd->glyphs.write[i].flags |= GRAPHEME_IS_SPACE; - sd->glyphs.write[i].flags |= GRAPHEME_IS_BREAK_SOFT; + sd_glyphs[i].flags |= GRAPHEME_IS_SPACE; + sd_glyphs[i].flags |= GRAPHEME_IS_BREAK_SOFT; } if (is_linebreak(c)) { - sd->glyphs.write[i].flags |= GRAPHEME_IS_BREAK_HARD; + sd_glyphs[i].flags |= GRAPHEME_IS_BREAK_HARD; } if (c == 0x0009 || c == 0x000b) { - sd->glyphs.write[i].flags |= GRAPHEME_IS_TAB; + sd_glyphs[i].flags |= GRAPHEME_IS_TAB; } - i += (sd->glyphs[i].count - 1); + i += (sd_glyphs[i].count - 1); } } sd->line_breaks_valid = true; diff --git a/modules/text_server_fb/text_server_fb.h b/modules/text_server_fb/text_server_fb.h index fb7de8f443..2f495115e0 100644 --- a/modules/text_server_fb/text_server_fb.h +++ b/modules/text_server_fb/text_server_fb.h @@ -142,6 +142,10 @@ class TextServerFallback : public TextServer { Dictionary variation_coordinates; float oversampling = 0.f; + uint32_t style_flags = 0; + String font_name; + String style_name; + Map<Vector2i, FontDataForSizeFallback *> cache; bool face_init = false; @@ -234,6 +238,15 @@ public: virtual void font_set_data(RID p_font_rid, const PackedByteArray &p_data) override; virtual void font_set_data_ptr(RID p_font_rid, const uint8_t *p_data_ptr, size_t p_data_size) override; + virtual void font_set_style(RID p_font_rid, uint32_t /*FontStyle*/ p_style) override; + virtual uint32_t /*FontStyle*/ font_get_style(RID p_font_rid) const override; + + virtual void font_set_style_name(RID p_font_rid, const String &p_name) override; + virtual String font_get_style_name(RID p_font_rid) const override; + + virtual void font_set_name(RID p_font_rid, const String &p_name) override; + virtual String font_get_name(RID p_font_rid) const override; + virtual void font_set_antialiased(RID p_font_rid, bool p_antialiased) override; virtual bool font_is_antialiased(RID p_font_rid) const override; @@ -361,6 +374,9 @@ public: virtual void shaped_text_set_bidi_override(RID p_shaped, const Array &p_override) override; + virtual void shaped_text_set_custom_punctuation(RID p_shaped, const String &p_punct) override; + virtual String shaped_text_get_custom_punctuation(RID p_shaped) const override; + virtual void shaped_text_set_orientation(RID p_shaped, Orientation p_orientation = ORIENTATION_HORIZONTAL) override; virtual Orientation shaped_text_get_orientation(RID p_shaped) const override; diff --git a/platform/android/export/export_plugin.cpp b/platform/android/export/export_plugin.cpp index 5bd5648b6e..4c45be5210 100644 --- a/platform/android/export/export_plugin.cpp +++ b/platform/android/export/export_plugin.cpp @@ -1667,7 +1667,7 @@ void EditorExportPlatformAndroid::get_export_options(List<ExportOption> *r_optio r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, launcher_adaptive_icon_foreground_option, PROPERTY_HINT_FILE, "*.png"), "")); r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, launcher_adaptive_icon_background_option, PROPERTY_HINT_FILE, "*.png"), "")); - r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "graphics/32_bits_framebuffer"), true)); + r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "graphics/depth_buffer_bits", PROPERTY_HINT_ENUM, "16 bits,24 bits [default],32 bits"), 1)); r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "graphics/opengl_debug"), false)); r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "xr_features/xr_mode", PROPERTY_HINT_ENUM, "Regular,Oculus Mobile VR"), 0)); @@ -2209,9 +2209,10 @@ void EditorExportPlatformAndroid::get_command_line_flags(const Ref<EditorExportP command_line_strings.push_back("--xr_mode_regular"); } - bool use_32_bit_framebuffer = p_preset->get("graphics/32_bits_framebuffer"); - if (use_32_bit_framebuffer) { - command_line_strings.push_back("--use_depth_32"); + int depth_buffer_bits_index = p_preset->get("graphics/depth_buffer_bits"); + if (depth_buffer_bits_index >= 0 && depth_buffer_bits_index <= 2) { + int depth_buffer_bits = 16 + depth_buffer_bits_index * 8; + command_line_strings.push_back(vformat("--use_depth=%d", depth_buffer_bits)); } bool immersive = p_preset->get("screen/immersive_mode"); diff --git a/platform/android/java/lib/src/org/godotengine/godot/Godot.java b/platform/android/java/lib/src/org/godotengine/godot/Godot.java index d39ab30cda..d872d5ed8a 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/Godot.java +++ b/platform/android/java/lib/src/org/godotengine/godot/Godot.java @@ -119,7 +119,7 @@ public class Godot extends Fragment implements SensorEventListener, IDownloaderC private Button mWiFiSettingsButton; private XRMode xrMode = XRMode.REGULAR; - private boolean use_32_bits = false; + private int depth_buffer_bits = 24; private boolean use_immersive = false; private boolean use_debug_opengl = false; private boolean mStatePaused; @@ -266,7 +266,7 @@ public class Godot extends Fragment implements SensorEventListener, IDownloaderC if (videoDriver.equals("vulkan")) { mRenderView = new GodotVulkanRenderView(activity, this); } else { - mRenderView = new GodotGLRenderView(activity, this, xrMode, use_32_bits, + mRenderView = new GodotGLRenderView(activity, this, xrMode, depth_buffer_bits, use_debug_opengl); } @@ -506,8 +506,12 @@ public class Godot extends Fragment implements SensorEventListener, IDownloaderC xrMode = XRMode.REGULAR; } else if (command_line[i].equals(XRMode.OVR.cmdLineArg)) { xrMode = XRMode.OVR; - } else if (command_line[i].equals("--use_depth_32")) { - use_32_bits = true; + } else if (command_line[i].startsWith("--use_depth=")) { + try { + depth_buffer_bits = Integer.parseInt(command_line[i].split("=")[1]); + } catch (Exception e) { + e.printStackTrace(); + } } else if (command_line[i].equals("--debug_opengl")) { use_debug_opengl = true; } else if (command_line[i].equals("--use_immersive")) { diff --git a/platform/android/java/lib/src/org/godotengine/godot/GodotGLRenderView.java b/platform/android/java/lib/src/org/godotengine/godot/GodotGLRenderView.java index 32aad8dc4f..8b77302491 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/GodotGLRenderView.java +++ b/platform/android/java/lib/src/org/godotengine/godot/GodotGLRenderView.java @@ -78,10 +78,10 @@ public class GodotGLRenderView extends GLSurfaceView implements GodotRenderView private final GodotRenderer godotRenderer; private PointerIcon pointerIcon; - public GodotGLRenderView(Context context, Godot godot, XRMode xrMode, boolean p_use_32_bits, + public GodotGLRenderView(Context context, Godot godot, XRMode xrMode, int p_depth_buffer_bits, boolean p_use_debug_opengl) { super(context); - GLUtils.use_32 = p_use_32_bits; + GLUtils.depth_buffer_bits = p_depth_buffer_bits; GLUtils.use_debug_opengl = p_use_debug_opengl; this.godot = godot; @@ -209,18 +209,16 @@ public class GodotGLRenderView extends GLSurfaceView implements GodotRenderView * below. */ - if (GLUtils.use_32) { - setEGLConfigChooser(translucent - ? new RegularFallbackConfigChooser(8, 8, 8, 8, 24, stencil, - new RegularConfigChooser(8, 8, 8, 8, 16, stencil)) - : new RegularFallbackConfigChooser(8, 8, 8, 8, 24, stencil, - new RegularConfigChooser(5, 6, 5, 0, 16, stencil))); - - } else { - setEGLConfigChooser(translucent - ? new RegularConfigChooser(8, 8, 8, 8, 16, stencil) - : new RegularConfigChooser(5, 6, 5, 0, 16, stencil)); + RegularConfigChooser configChooser = + new RegularFallbackConfigChooser(8, 8, 8, 8, 16, stencil, + new RegularConfigChooser(5, 6, 5, 0, 16, stencil)); + if (GLUtils.depth_buffer_bits >= 24) { + configChooser = new RegularFallbackConfigChooser(8, 8, 8, 8, 24, stencil, configChooser); + if (GLUtils.depth_buffer_bits >= 32) { + configChooser = new RegularFallbackConfigChooser(8, 8, 8, 8, 32, stencil, configChooser); + } } + setEGLConfigChooser(configChooser); break; } diff --git a/platform/android/java/lib/src/org/godotengine/godot/GodotLib.java b/platform/android/java/lib/src/org/godotengine/godot/GodotLib.java index 95870acda1..a23d030d4c 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/GodotLib.java +++ b/platform/android/java/lib/src/org/godotengine/godot/GodotLib.java @@ -75,9 +75,8 @@ public class GodotLib { /** * Invoked on the render thread when the underlying Android surface is created or recreated. * @param p_surface - * @param p_32_bits */ - public static native void newcontext(Surface p_surface, boolean p_32_bits); + public static native void newcontext(Surface p_surface); /** * Forward {@link Activity#onBackPressed()} event from the main thread to the GL thread. diff --git a/platform/android/java/lib/src/org/godotengine/godot/GodotRenderer.java b/platform/android/java/lib/src/org/godotengine/godot/GodotRenderer.java index 878a119c5c..12e452fc99 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/GodotRenderer.java +++ b/platform/android/java/lib/src/org/godotengine/godot/GodotRenderer.java @@ -70,7 +70,7 @@ class GodotRenderer implements GLSurfaceView.Renderer { } public void onSurfaceCreated(GL10 gl, EGLConfig config) { - GodotLib.newcontext(null, GLUtils.use_32); + GodotLib.newcontext(null); for (GodotPlugin plugin : pluginRegistry.getAllPlugins()) { plugin.onGLSurfaceCreated(gl, config); } diff --git a/platform/android/java/lib/src/org/godotengine/godot/utils/GLUtils.java b/platform/android/java/lib/src/org/godotengine/godot/utils/GLUtils.java index 19588f8465..0d581785ab 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/utils/GLUtils.java +++ b/platform/android/java/lib/src/org/godotengine/godot/utils/GLUtils.java @@ -44,7 +44,7 @@ public class GLUtils { public static final boolean DEBUG = false; - public static boolean use_32 = false; + public static int depth_buffer_bits; // No need to reiterate the default here public static boolean use_debug_opengl = false; private static final String[] ATTRIBUTES_NAMES = new String[] { diff --git a/platform/android/java/lib/src/org/godotengine/godot/vulkan/VkRenderer.kt b/platform/android/java/lib/src/org/godotengine/godot/vulkan/VkRenderer.kt index a35f6ec5a7..b13f9bfeab 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/vulkan/VkRenderer.kt +++ b/platform/android/java/lib/src/org/godotengine/godot/vulkan/VkRenderer.kt @@ -58,7 +58,7 @@ internal class VkRenderer { * Called when the surface is created and signals the beginning of rendering. */ fun onVkSurfaceCreated(surface: Surface) { - GodotLib.newcontext(surface, false) + GodotLib.newcontext(surface) for (plugin in pluginRegistry.getAllPlugins()) { plugin.onVkSurfaceCreated(surface) diff --git a/platform/android/java/lib/src/org/godotengine/godot/xr/regular/RegularFallbackConfigChooser.java b/platform/android/java/lib/src/org/godotengine/godot/xr/regular/RegularFallbackConfigChooser.java index e690c5b695..63c5381994 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/xr/regular/RegularFallbackConfigChooser.java +++ b/platform/android/java/lib/src/org/godotengine/godot/xr/regular/RegularFallbackConfigChooser.java @@ -38,7 +38,7 @@ import javax.microedition.khronos.egl.EGL10; import javax.microedition.khronos.egl.EGLConfig; import javax.microedition.khronos.egl.EGLDisplay; -/* Fallback if 32bit View is not supported*/ +/* Fallback if the requested configuration is not supported */ public class RegularFallbackConfigChooser extends RegularConfigChooser { private static final String TAG = RegularFallbackConfigChooser.class.getSimpleName(); @@ -55,7 +55,6 @@ public class RegularFallbackConfigChooser extends RegularConfigChooser { if (ec == null) { Log.w(TAG, "Trying ConfigChooser fallback"); ec = fallback.chooseConfig(egl, display, configs); - GLUtils.use_32 = false; } return ec; } diff --git a/platform/android/java_godot_lib_jni.cpp b/platform/android/java_godot_lib_jni.cpp index d971727269..c7f19e4be2 100644 --- a/platform/android/java_godot_lib_jni.cpp +++ b/platform/android/java_godot_lib_jni.cpp @@ -182,11 +182,10 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_resize(JNIEnv *env, j } } -JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_newcontext(JNIEnv *env, jclass clazz, jobject p_surface, jboolean p_32_bits) { +JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_newcontext(JNIEnv *env, jclass clazz, jobject p_surface) { if (os_android) { if (step.get() == 0) { // During startup - os_android->set_context_is_16_bits(!p_32_bits); if (p_surface) { ANativeWindow *native_window = ANativeWindow_fromSurface(env, p_surface); os_android->set_native_window(native_window); diff --git a/platform/android/java_godot_lib_jni.h b/platform/android/java_godot_lib_jni.h index 63e9e6d8e5..7ea74480cb 100644 --- a/platform/android/java_godot_lib_jni.h +++ b/platform/android/java_godot_lib_jni.h @@ -41,7 +41,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_initialize(JNIEnv *en JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_ondestroy(JNIEnv *env, jclass clazz); JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_setup(JNIEnv *env, jclass clazz, jobjectArray p_cmdline); JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_resize(JNIEnv *env, jclass clazz, jobject p_surface, jint p_width, jint p_height); -JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_newcontext(JNIEnv *env, jclass clazz, jobject p_surface, jboolean p_32_bits); +JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_newcontext(JNIEnv *env, jclass clazz, jobject p_surface); JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_step(JNIEnv *env, jclass clazz); JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_back(JNIEnv *env, jclass clazz); void touch_preprocessing(JNIEnv *env, jclass clazz, jint input_device, jint ev, jint pointer, jint pointer_count, jfloatArray positions, jint buttons_mask = 0, jfloat vertical_factor = 0, jfloat horizontal_factor = 0); diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp index 1a4c5ec00f..0e5e10bc0a 100644 --- a/platform/android/os_android.cpp +++ b/platform/android/os_android.cpp @@ -261,13 +261,6 @@ Size2i OS_Android::get_display_size() const { return display_size; } -void OS_Android::set_context_is_16_bits(bool p_is_16) { -#if defined(GLES3_ENABLED) - //if (rasterizer) - // rasterizer->set_force_16_bits_fbo(p_is_16); -#endif -} - void OS_Android::set_opengl_extensions(const char *p_gl_extensions) { #if defined(GLES3_ENABLED) ERR_FAIL_COND(!p_gl_extensions); diff --git a/platform/android/os_android.h b/platform/android/os_android.h index d2e0e7d1e9..a62f79952c 100644 --- a/platform/android/os_android.h +++ b/platform/android/os_android.h @@ -102,7 +102,6 @@ public: void set_display_size(const Size2i &p_size); Size2i get_display_size() const; - void set_context_is_16_bits(bool p_is_16); void set_opengl_extensions(const char *p_gl_extensions); void set_native_window(ANativeWindow *p_native_window); diff --git a/platform/linuxbsd/display_server_x11.cpp b/platform/linuxbsd/display_server_x11.cpp index c4e828bdb2..9349d378d0 100644 --- a/platform/linuxbsd/display_server_x11.cpp +++ b/platform/linuxbsd/display_server_x11.cpp @@ -3685,11 +3685,18 @@ void DisplayServerX11::process_events() { } break; case KeyPress: case KeyRelease: { +#ifdef DISPLAY_SERVER_X11_DEBUG_LOGS_ENABLED + if (event.type == KeyPress) { + DEBUG_LOG_X11("[%u] KeyPress window=%lu (%u), keycode=%u, time=%lu \n", frame, event.xkey.window, window_id, event.xkey.keycode, event.xkey.time); + } else { + DEBUG_LOG_X11("[%u] KeyRelease window=%lu (%u), keycode=%u, time=%lu \n", frame, event.xkey.window, window_id, event.xkey.keycode, event.xkey.time); + } +#endif last_timestamp = event.xkey.time; // key event is a little complex, so // it will be handled in its own function. - _handle_key_event(window_id, (XKeyEvent *)&event, events, event_index); + _handle_key_event(window_id, &event.xkey, events, event_index); } break; case SelectionNotify: diff --git a/scene/gui/gradient_edit.cpp b/scene/gui/gradient_edit.cpp index 5d024d3be7..e5b23d8006 100644 --- a/scene/gui/gradient_edit.cpp +++ b/scene/gui/gradient_edit.cpp @@ -39,6 +39,10 @@ GradientEdit::GradientEdit() { picker = memnew(ColorPicker); popup->add_child(picker); + gradient_cache.instantiate(); + preview_texture.instantiate(); + + preview_texture->set_width(1024); add_child(popup, false, INTERNAL_MODE_FRONT); } @@ -47,7 +51,7 @@ int GradientEdit::_get_point_from_pos(int x) { int total_w = get_size().width - get_size().height - draw_spacing; float min_distance = 1e20; for (int i = 0; i < points.size(); i++) { - //Check if we clicked at point + // Check if we clicked at point. float distance = ABS(x - points[i].offset * total_w); float min = (draw_point_width / 2 * 1.7); //make it easier to grab if (distance <= min && distance < min_distance) { @@ -94,14 +98,14 @@ void GradientEdit::gui_input(const Ref<InputEvent> &p_event) { } Ref<InputEventMouseButton> mb = p_event; - //Show color picker on double click. + // Show color picker on double click. if (mb.is_valid() && mb->get_button_index() == 1 && mb->is_double_click() && mb->is_pressed()) { grabbed = _get_point_from_pos(mb->get_position().x); _show_color_picker(); accept_event(); } - //Delete point on right click + // Delete point on right click. if (mb.is_valid() && mb->get_button_index() == 2 && mb->is_pressed()) { grabbed = _get_point_from_pos(mb->get_position().x); if (grabbed != -1) { @@ -114,20 +118,20 @@ void GradientEdit::gui_input(const Ref<InputEvent> &p_event) { } } - //Hold alt key to duplicate selected color + // Hold alt key to duplicate selected color. if (mb.is_valid() && mb->get_button_index() == 1 && mb->is_pressed() && mb->is_alt_pressed()) { int x = mb->get_position().x; grabbed = _get_point_from_pos(x); if (grabbed != -1) { int total_w = get_size().width - get_size().height - draw_spacing; - Gradient::Point newPoint = points[grabbed]; - newPoint.offset = CLAMP(x / float(total_w), 0, 1); + Gradient::Point new_point = points[grabbed]; + new_point.offset = CLAMP(x / float(total_w), 0, 1); - points.push_back(newPoint); + points.push_back(new_point); points.sort(); for (int i = 0; i < points.size(); ++i) { - if (points[i].offset == newPoint.offset) { + if (points[i].offset == new_point.offset) { grabbed = i; break; } @@ -138,7 +142,7 @@ void GradientEdit::gui_input(const Ref<InputEvent> &p_event) { } } - //select + // Select. if (mb.is_valid() && mb->get_button_index() == 1 && mb->is_pressed()) { update(); int x = mb->get_position().x; @@ -158,16 +162,16 @@ void GradientEdit::gui_input(const Ref<InputEvent> &p_event) { return; } - //insert - Gradient::Point newPoint; - newPoint.offset = CLAMP(x / float(total_w), 0, 1); + // Insert point. + Gradient::Point new_point; + new_point.offset = CLAMP(x / float(total_w), 0, 1); Gradient::Point prev; Gradient::Point next; int pos = -1; for (int i = 0; i < points.size(); i++) { - if (points[i].offset < newPoint.offset) { + if (points[i].offset < new_point.offset) { pos = i; } } @@ -191,12 +195,12 @@ void GradientEdit::gui_input(const Ref<InputEvent> &p_event) { prev = points[pos]; } - newPoint.color = prev.color.lerp(next.color, (newPoint.offset - prev.offset) / (next.offset - prev.offset)); + new_point.color = prev.color.lerp(next.color, (new_point.offset - prev.offset) / (next.offset - prev.offset)); - points.push_back(newPoint); + points.push_back(new_point); points.sort(); for (int i = 0; i < points.size(); i++) { - if (points[i].offset == newPoint.offset) { + if (points[i].offset == new_point.offset) { grabbed = i; break; } @@ -223,7 +227,7 @@ void GradientEdit::gui_input(const Ref<InputEvent> &p_event) { float newofs = CLAMP(x / float(total_w), 0, 1); // Snap to "round" coordinates if holding Ctrl. - // Be more precise if holding Shift as well + // Be more precise if holding Shift as well. if (mm->is_ctrl_pressed()) { newofs = Math::snapped(newofs, mm->is_shift_pressed() ? 0.025 : 0.1); } else if (mm->is_shift_pressed()) { @@ -299,57 +303,22 @@ void GradientEdit::_notification(int p_what) { int h = get_size().y; if (w == 0 || h == 0) { - return; //Safety check. We have division by 'h'. And in any case there is nothing to draw with such size + return; // Safety check. We have division by 'h'. And in any case there is nothing to draw with such size. } int total_w = get_size().width - get_size().height - draw_spacing; - //Draw checker pattern for ramp + // Draw checker pattern for ramp. draw_texture_rect(get_theme_icon(SNAME("GuiMiniCheckerboard"), SNAME("EditorIcons")), Rect2(0, 0, total_w, h), true); - //Draw color ramp - Gradient::Point prev; - prev.offset = 0; - if (points.size() == 0) { - prev.color = Color(0, 0, 0); //Draw black rectangle if we have no points - } else { - prev.color = points[0].color; //Extend color of first point to the beginning. - } + // Draw color ramp. - for (int i = -1; i < points.size(); i++) { - Gradient::Point next; - //If there is no next point - if (i + 1 == points.size()) { - if (points.size() == 0) { - next.color = Color(0, 0, 0); //Draw black rectangle if we have no points - } else { - next.color = points[i].color; //Extend color of last point to the end. - } - next.offset = 1; - } else { - next = points[i + 1]; - } + gradient_cache->set_points(points); + gradient_cache->set_interpolation_mode(interpolation_mode); + preview_texture->set_gradient(gradient_cache); + draw_texture_rect(preview_texture, Rect2(0, 0, total_w, h)); - if (prev.offset == next.offset) { - prev = next; - continue; - } - - Vector<Vector2> points; - Vector<Color> colors; - points.push_back(Vector2(prev.offset * total_w, h)); - points.push_back(Vector2(prev.offset * total_w, 0)); - points.push_back(Vector2(next.offset * total_w, 0)); - points.push_back(Vector2(next.offset * total_w, h)); - colors.push_back(prev.color); - colors.push_back(prev.color); - colors.push_back(next.color); - colors.push_back(next.color); - draw_primitive(points, colors, Vector<Point2>()); - prev = next; - } - - //Draw point markers + // Draw point markers. for (int i = 0; i < points.size(); i++) { Color col = points[i].color.inverted(); col.a = 0.9; @@ -383,7 +352,7 @@ void GradientEdit::_notification(int p_what) { draw_line(Vector2(total_w + draw_spacing, h), Vector2(total_w + draw_spacing + h, 0), Color(1, 1, 1, 0.6)); } - //Draw borders around color ramp if in focus + // Draw borders around color ramp if in focus. if (has_focus()) { draw_line(Vector2(-1, -1), Vector2(total_w + 1, -1), Color(1, 1, 1, 0.6)); draw_line(Vector2(total_w + 1, -1), Vector2(total_w + 1, h + 1), Color(1, 1, 1, 0.6)); @@ -448,12 +417,21 @@ void GradientEdit::set_points(Vector<Gradient::Point> &p_points) { } points.clear(); points = p_points; + points.sort(); } Vector<Gradient::Point> &GradientEdit::get_points() { return points; } +void GradientEdit::set_interpolation_mode(Gradient::InterpolationMode p_interp_mode) { + interpolation_mode = p_interp_mode; +} + +Gradient::InterpolationMode GradientEdit::get_interpolation_mode() { + return interpolation_mode; +} + void GradientEdit::_bind_methods() { ADD_SIGNAL(MethodInfo("ramp_changed")); } diff --git a/scene/gui/gradient_edit.h b/scene/gui/gradient_edit.h index f3a39daaf6..66b60d87c7 100644 --- a/scene/gui/gradient_edit.h +++ b/scene/gui/gradient_edit.h @@ -45,6 +45,10 @@ class GradientEdit : public Control { bool grabbing = false; int grabbed = -1; Vector<Gradient::Point> points; + Gradient::InterpolationMode interpolation_mode = Gradient::GRADIENT_INTERPOLATE_LINEAR; + + Ref<Gradient> gradient_cache; + Ref<GradientTexture1D> preview_texture; // Make sure to use the scaled value below. const int BASE_SPACING = 3; @@ -69,6 +73,9 @@ public: Vector<Color> get_colors() const; void set_points(Vector<Gradient::Point> &p_points); Vector<Gradient::Point> &get_points(); + void set_interpolation_mode(Gradient::InterpolationMode p_interp_mode); + Gradient::InterpolationMode get_interpolation_mode(); + virtual Size2 get_minimum_size() const override; GradientEdit(); diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp index b8cb618171..50908f6a77 100644 --- a/scene/gui/label.cpp +++ b/scene/gui/label.cpp @@ -243,11 +243,9 @@ inline void draw_glyph_outline(const Glyph &p_gl, const RID &p_canvas, const Col if (p_gl.font_rid != RID()) { if (p_font_shadow_color.a > 0) { TS->font_draw_glyph(p_gl.font_rid, p_canvas, p_gl.font_size, p_ofs + Vector2(p_gl.x_off, p_gl.y_off) + shadow_ofs, p_gl.index, p_font_shadow_color); - if (p_shadow_outline_size > 0) { - TS->font_draw_glyph_outline(p_gl.font_rid, p_canvas, p_gl.font_size, p_shadow_outline_size, p_ofs + Vector2(p_gl.x_off, p_gl.y_off) + Vector2(-shadow_ofs.x, shadow_ofs.y), p_gl.index, p_font_shadow_color); - TS->font_draw_glyph_outline(p_gl.font_rid, p_canvas, p_gl.font_size, p_shadow_outline_size, p_ofs + Vector2(p_gl.x_off, p_gl.y_off) + Vector2(shadow_ofs.x, -shadow_ofs.y), p_gl.index, p_font_shadow_color); - TS->font_draw_glyph_outline(p_gl.font_rid, p_canvas, p_gl.font_size, p_shadow_outline_size, p_ofs + Vector2(p_gl.x_off, p_gl.y_off) + Vector2(-shadow_ofs.x, -shadow_ofs.y), p_gl.index, p_font_shadow_color); - } + } + if (p_font_shadow_color.a > 0 && p_shadow_outline_size > 0) { + TS->font_draw_glyph_outline(p_gl.font_rid, p_canvas, p_gl.font_size, p_shadow_outline_size, p_ofs + Vector2(p_gl.x_off, p_gl.y_off) + shadow_ofs, p_gl.index, p_font_shadow_color); } if (p_font_outline_color.a != 0.0 && p_outline_size > 0) { TS->font_draw_glyph_outline(p_gl.font_rid, p_canvas, p_gl.font_size, p_outline_size, p_ofs + Vector2(p_gl.x_off, p_gl.y_off), p_gl.index, p_font_outline_color); @@ -397,7 +395,7 @@ void Label::_notification(int p_what) { int ellipsis_gl_size = TS->shaped_text_get_ellipsis_glyph_count(lines_rid[i]); // Draw outline. Note: Do not merge this into the single loop with the main text, to prevent overlaps. - if (font_shadow_color.a > 0 || (font_outline_color.a != 0.0 && outline_size > 0)) { + if ((outline_size > 0 && font_outline_color.a != 0) || (font_shadow_color.a != 0)) { Vector2 offset = ofs; // Draw RTL ellipsis string when necessary. if (rtl && ellipsis_pos >= 0) { diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index 0b85b4d3d2..15fd22ced5 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -664,7 +664,9 @@ void LineEdit::_notification(int p_what) { } Ref<Font> font = get_theme_font(SNAME("font")); - style->draw(ci, Rect2(Point2(), size)); + if (!flat) { + style->draw(ci, Rect2(Point2(), size)); + } if (has_focus()) { get_theme_stylebox(SNAME("focus"))->draw(ci, Rect2(Point2(), size)); @@ -1966,6 +1968,17 @@ Ref<Texture2D> LineEdit::get_right_icon() { return right_icon; } +void LineEdit::set_flat(bool p_enabled) { + if (flat != p_enabled) { + flat = p_enabled; + update(); + } +} + +bool LineEdit::is_flat() const { + return flat; +} + void LineEdit::_text_changed() { _emit_text_change(); _clear_redo(); @@ -2214,6 +2227,8 @@ void LineEdit::_bind_methods() { ClassDB::bind_method(D_METHOD("is_deselect_on_focus_loss_enabled"), &LineEdit::is_deselect_on_focus_loss_enabled); ClassDB::bind_method(D_METHOD("set_right_icon", "icon"), &LineEdit::set_right_icon); ClassDB::bind_method(D_METHOD("get_right_icon"), &LineEdit::get_right_icon); + ClassDB::bind_method(D_METHOD("set_flat", "enabled"), &LineEdit::set_flat); + ClassDB::bind_method(D_METHOD("is_flat"), &LineEdit::is_flat); ADD_SIGNAL(MethodInfo("text_changed", PropertyInfo(Variant::STRING, "new_text"))); ADD_SIGNAL(MethodInfo("text_change_rejected", PropertyInfo(Variant::STRING, "rejected_substring"))); @@ -2269,6 +2284,7 @@ void LineEdit::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "selecting_enabled"), "set_selecting_enabled", "is_selecting_enabled"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "deselect_on_focus_loss_enabled"), "set_deselect_on_focus_loss_enabled", "is_deselect_on_focus_loss_enabled"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "right_icon", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_right_icon", "get_right_icon"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "flat"), "set_flat", "is_flat"); ADD_PROPERTY(PropertyInfo(Variant::INT, "text_direction", PROPERTY_HINT_ENUM, "Auto,Left-to-Right,Right-to-Left,Inherited"), "set_text_direction", "get_text_direction"); ADD_PROPERTY(PropertyInfo(Variant::STRING, "language"), "set_language", "get_language"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "draw_control_chars"), "set_draw_control_chars", "get_draw_control_chars"); diff --git a/scene/gui/line_edit.h b/scene/gui/line_edit.h index 3364e02e01..2ec7f08865 100644 --- a/scene/gui/line_edit.h +++ b/scene/gui/line_edit.h @@ -130,6 +130,7 @@ private: bool middle_mouse_paste_enabled = true; Ref<Texture2D> right_icon; + bool flat = false; struct Selection { int begin = 0; @@ -332,6 +333,9 @@ public: void set_right_icon(const Ref<Texture2D> &p_icon); Ref<Texture2D> get_right_icon(); + void set_flat(bool p_enabled); + bool is_flat() const; + virtual bool is_text_field() const override; void show_virtual_keyboard(); diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index f1efbbda98..308880ef18 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -621,7 +621,7 @@ void RichTextLabel::_shape_line(ItemFrame *p_frame, int p_line, const Ref<Font> } } -int RichTextLabel::_draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_ofs, int p_width, const Color &p_base_color, int p_outline_size, const Color &p_outline_color, const Color &p_font_shadow_color, bool p_shadow_as_outline, const Point2 &p_shadow_ofs) { +int RichTextLabel::_draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_ofs, int p_width, const Color &p_base_color, int p_outline_size, const Color &p_outline_color, const Color &p_font_shadow_color, int p_shadow_outline_size, const Point2 &p_shadow_ofs) { Vector2 off; ERR_FAIL_COND_V(p_frame == nullptr, 0); @@ -804,7 +804,7 @@ int RichTextLabel::_draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_o } for (int j = 0; j < frame->lines.size(); j++) { - _draw_line(frame, j, p_ofs + rect.position + off + Vector2(0, frame->lines[j].offset.y), rect.size.x, p_base_color, p_outline_size, p_outline_color, p_font_shadow_color, p_shadow_as_outline, p_shadow_ofs); + _draw_line(frame, j, p_ofs + rect.position + off + Vector2(0, frame->lines[j].offset.y), rect.size.x, p_base_color, p_outline_size, p_outline_color, p_font_shadow_color, p_shadow_outline_size, p_shadow_ofs); } idx++; } @@ -824,7 +824,8 @@ int RichTextLabel::_draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_o Item *it = _get_item_at_pos(it_from, it_to, glyphs[i].start); int size = _find_outline_size(it, p_outline_size); Color font_color = _find_outline_color(it, p_outline_color); - if (size <= 0) { + Color font_shadow_color = p_font_shadow_color; + if ((size <= 0 || font_color.a == 0) && (font_shadow_color.a == 0)) { gloff.x += glyphs[i].advance; continue; } @@ -871,9 +872,10 @@ int RichTextLabel::_draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_o faded_visibility = faded_visibility < 0.0f ? 0.0f : faded_visibility; } font_color.a = faded_visibility; + font_shadow_color.a = faded_visibility; } - bool visible = (font_color.a != 0); + bool visible = (font_color.a != 0) || (font_shadow_color.a != 0); for (int j = 0; j < fx_stack.size(); j++) { ItemFX *item_fx = fx_stack[j]; @@ -942,18 +944,19 @@ int RichTextLabel::_draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_o } } - Point2 shadow_ofs(get_theme_constant(SNAME("shadow_offset_x")), get_theme_constant(SNAME("shadow_offset_y"))); - // Draw glyph outlines. for (int j = 0; j < glyphs[i].repeat; j++) { if (visible) { if (frid != RID()) { - if (p_shadow_as_outline) { - TS->font_draw_glyph_outline(frid, ci, glyphs[i].font_size, size, p_ofs + fx_offset + gloff + Vector2(-shadow_ofs.x, shadow_ofs.y), gl, p_font_shadow_color); - TS->font_draw_glyph_outline(frid, ci, glyphs[i].font_size, size, p_ofs + fx_offset + gloff + Vector2(shadow_ofs.x, -shadow_ofs.y), gl, p_font_shadow_color); - TS->font_draw_glyph_outline(frid, ci, glyphs[i].font_size, size, p_ofs + fx_offset + gloff + Vector2(-shadow_ofs.x, -shadow_ofs.y), gl, p_font_shadow_color); + if (font_shadow_color.a > 0) { + TS->font_draw_glyph(frid, ci, glyphs[i].font_size, p_ofs + fx_offset + gloff + p_shadow_ofs, gl, font_shadow_color); + } + if (font_shadow_color.a > 0 && p_shadow_outline_size > 0) { + TS->font_draw_glyph_outline(frid, ci, glyphs[i].font_size, p_shadow_outline_size, p_ofs + fx_offset + gloff + p_shadow_ofs, gl, font_shadow_color); + } + if (font_color.a != 0.0 && size > 0) { + TS->font_draw_glyph_outline(frid, ci, glyphs[i].font_size, size, p_ofs + fx_offset + gloff, gl, font_color); } - TS->font_draw_glyph_outline(frid, ci, glyphs[i].font_size, size, p_ofs + fx_offset + gloff, gl, font_color); } } gloff.x += glyphs[i].advance; @@ -1470,7 +1473,7 @@ void RichTextLabel::_notification(int p_what) { Color outline_color = get_theme_color(SNAME("font_outline_color")); int outline_size = get_theme_constant(SNAME("outline_size")); Color font_shadow_color = get_theme_color(SNAME("font_shadow_color")); - bool use_outline = get_theme_constant(SNAME("shadow_as_outline")); + int shadow_outline_size = get_theme_constant(SNAME("shadow_outline_size")); Point2 shadow_ofs(get_theme_constant(SNAME("shadow_offset_x")), get_theme_constant(SNAME("shadow_offset_y"))); visible_paragraph_count = 0; @@ -1480,7 +1483,7 @@ void RichTextLabel::_notification(int p_what) { Point2 ofs = text_rect.get_position() + Vector2(0, main->lines[from_line].offset.y - vofs); while (ofs.y < size.height && from_line < main->lines.size()) { visible_paragraph_count++; - visible_line_count += _draw_line(main, from_line, ofs, text_rect.size.x, base_color, outline_size, outline_color, font_shadow_color, use_outline, shadow_ofs); + visible_line_count += _draw_line(main, from_line, ofs, text_rect.size.x, base_color, outline_size, outline_color, font_shadow_color, shadow_outline_size, shadow_ofs); ofs.y += main->lines[from_line].text_buf->get_size().y + get_theme_constant(SNAME("line_separation")); from_line++; } diff --git a/scene/gui/rich_text_label.h b/scene/gui/rich_text_label.h index f3c4c11cc8..5b58f14d96 100644 --- a/scene/gui/rich_text_label.h +++ b/scene/gui/rich_text_label.h @@ -412,7 +412,7 @@ private: void _shape_line(ItemFrame *p_frame, int p_line, const Ref<Font> &p_base_font, int p_base_font_size, int p_width, int *r_char_offset); void _resize_line(ItemFrame *p_frame, int p_line, const Ref<Font> &p_base_font, int p_base_font_size, int p_width); - int _draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_ofs, int p_width, const Color &p_base_color, int p_outline_size, const Color &p_outline_color, const Color &p_font_shadow_color, bool p_shadow_as_outline, const Point2 &shadow_ofs); + int _draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_ofs, int p_width, const Color &p_base_color, int p_outline_size, const Color &p_outline_color, const Color &p_font_shadow_color, int p_shadow_outline_size, const Point2 &p_shadow_ofs); float _find_click_in_line(ItemFrame *p_frame, int p_line, const Vector2 &p_ofs, int p_width, const Point2i &p_click, ItemFrame **r_click_frame = nullptr, int *r_click_line = nullptr, Item **r_click_item = nullptr, int *r_click_char = nullptr); String _roman(int p_num, bool p_capitalize) const; diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp index f21a070133..a1d76ef352 100644 --- a/scene/resources/default_theme/default_theme.cpp +++ b/scene/resources/default_theme/default_theme.cpp @@ -940,7 +940,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const theme->set_constant("shadow_offset_x", "RichTextLabel", 1 * scale); theme->set_constant("shadow_offset_y", "RichTextLabel", 1 * scale); - theme->set_constant("shadow_as_outline", "RichTextLabel", 0 * scale); + theme->set_constant("shadow_outline_size", "RichTextLabel", 1 * scale); theme->set_constant("line_separation", "RichTextLabel", 0 * scale); theme->set_constant("table_hseparation", "RichTextLabel", 3 * scale); diff --git a/scene/resources/font.cpp b/scene/resources/font.cpp index 819ae95715..d9de47afc7 100644 --- a/scene/resources/font.cpp +++ b/scene/resources/font.cpp @@ -70,6 +70,15 @@ void FontData::_bind_methods() { ClassDB::bind_method(D_METHOD("set_antialiased", "antialiased"), &FontData::set_antialiased); ClassDB::bind_method(D_METHOD("is_antialiased"), &FontData::is_antialiased); + ClassDB::bind_method(D_METHOD("set_font_name", "name"), &FontData::set_font_name); + ClassDB::bind_method(D_METHOD("get_font_name"), &FontData::get_font_name); + + ClassDB::bind_method(D_METHOD("set_font_style_name", "name"), &FontData::set_font_style_name); + ClassDB::bind_method(D_METHOD("get_font_style_name"), &FontData::get_font_style_name); + + ClassDB::bind_method(D_METHOD("set_font_style", "style"), &FontData::set_font_style); + ClassDB::bind_method(D_METHOD("get_font_style"), &FontData::get_font_style); + ClassDB::bind_method(D_METHOD("set_multichannel_signed_distance_field", "msdf"), &FontData::set_multichannel_signed_distance_field); ClassDB::bind_method(D_METHOD("is_multichannel_signed_distance_field"), &FontData::is_multichannel_signed_distance_field); @@ -190,6 +199,15 @@ bool FontData::_set(const StringName &p_name, const Variant &p_value) { } else if (tokens[0] == "antialiased") { set_antialiased(p_value); return true; + } else if (tokens[0] == "font_name") { + set_font_name(p_value); + return true; + } else if (tokens[0] == "style_name") { + set_font_style_name(p_value); + return true; + } else if (tokens[0] == "font_style") { + set_font_style(p_value); + return true; } else if (tokens[0] == "multichannel_signed_distance_field") { set_multichannel_signed_distance_field(p_value); return true; @@ -295,6 +313,15 @@ bool FontData::_get(const StringName &p_name, Variant &r_ret) const { } else if (tokens[0] == "antialiased") { r_ret = is_antialiased(); return true; + } else if (tokens[0] == "font_name") { + r_ret = get_font_name(); + return true; + } else if (tokens[0] == "style_name") { + r_ret = get_font_style_name(); + return true; + } else if (tokens[0] == "font_style") { + r_ret = get_font_style(); + return true; } else if (tokens[0] == "multichannel_signed_distance_field") { r_ret = is_multichannel_signed_distance_field(); return true; @@ -394,6 +421,9 @@ bool FontData::_get(const StringName &p_name, Variant &r_ret) const { void FontData::_get_property_list(List<PropertyInfo> *p_list) const { p_list->push_back(PropertyInfo(Variant::PACKED_BYTE_ARRAY, "data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE)); + p_list->push_back(PropertyInfo(Variant::STRING, "font_name", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE)); + p_list->push_back(PropertyInfo(Variant::STRING, "style_name", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE)); + p_list->push_back(PropertyInfo(Variant::INT, "font_style", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE)); p_list->push_back(PropertyInfo(Variant::BOOL, "antialiased", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE)); p_list->push_back(PropertyInfo(Variant::BOOL, "multichannel_signed_distance_field", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE)); p_list->push_back(PropertyInfo(Variant::INT, "msdf_pixel_range", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE)); @@ -510,6 +540,36 @@ PackedByteArray FontData::get_data() const { return data; } +void FontData::set_font_name(const String &p_name) { + _ensure_rid(0); + TS->font_set_name(cache[0], p_name); +} + +String FontData::get_font_name() const { + _ensure_rid(0); + return TS->font_get_name(cache[0]); +} + +void FontData::set_font_style_name(const String &p_name) { + _ensure_rid(0); + TS->font_set_style_name(cache[0], p_name); +} + +String FontData::get_font_style_name() const { + _ensure_rid(0); + return TS->font_get_style_name(cache[0]); +} + +void FontData::set_font_style(uint32_t p_style) { + _ensure_rid(0); + TS->font_set_style(cache[0], p_style); +} + +uint32_t FontData::get_font_style() const { + _ensure_rid(0); + return TS->font_get_style(cache[0]); +} + void FontData::set_antialiased(bool p_antialiased) { if (antialiased != p_antialiased) { antialiased = p_antialiased; diff --git a/scene/resources/font.h b/scene/resources/font.h index e1f1f6d742..4d9ee72c84 100644 --- a/scene/resources/font.h +++ b/scene/resources/font.h @@ -79,6 +79,15 @@ public: virtual PackedByteArray get_data() const; // Common properties. + virtual void set_font_name(const String &p_name); + virtual String get_font_name() const; + + virtual void set_font_style_name(const String &p_name); + virtual String get_font_style_name() const; + + virtual void set_font_style(uint32_t p_style); + virtual uint32_t get_font_style() const; + virtual void set_antialiased(bool p_antialiased); virtual bool is_antialiased() const; diff --git a/scene/resources/gradient.cpp b/scene/resources/gradient.cpp index 7b9b942142..4559b4ce0a 100644 --- a/scene/resources/gradient.cpp +++ b/scene/resources/gradient.cpp @@ -51,6 +51,8 @@ void Gradient::_bind_methods() { ClassDB::bind_method(D_METHOD("set_offset", "point", "offset"), &Gradient::set_offset); ClassDB::bind_method(D_METHOD("get_offset", "point"), &Gradient::get_offset); + ClassDB::bind_method(D_METHOD("reverse"), &Gradient::reverse); + ClassDB::bind_method(D_METHOD("set_color", "point", "color"), &Gradient::set_color); ClassDB::bind_method(D_METHOD("get_color", "point"), &Gradient::get_color); @@ -64,8 +66,18 @@ void Gradient::_bind_methods() { ClassDB::bind_method(D_METHOD("set_colors", "colors"), &Gradient::set_colors); ClassDB::bind_method(D_METHOD("get_colors"), &Gradient::get_colors); + ClassDB::bind_method(D_METHOD("set_interpolation_mode", "interpolation_mode"), &Gradient::set_interpolation_mode); + ClassDB::bind_method(D_METHOD("get_interpolation_mode"), &Gradient::get_interpolation_mode); + + ADD_PROPERTY(PropertyInfo(Variant::INT, "interpolation_mode", PROPERTY_HINT_ENUM, "Linear,Constant,Cubic"), "set_interpolation_mode", "get_interpolation_mode"); + + ADD_GROUP("Raw data", ""); ADD_PROPERTY(PropertyInfo(Variant::PACKED_FLOAT32_ARRAY, "offsets"), "set_offsets", "get_offsets"); ADD_PROPERTY(PropertyInfo(Variant::PACKED_COLOR_ARRAY, "colors"), "set_colors", "get_colors"); + + BIND_ENUM_CONSTANT(GRADIENT_INTERPOLATE_LINEAR); + BIND_ENUM_CONSTANT(GRADIENT_INTERPOLATE_CONSTANT); + BIND_ENUM_CONSTANT(GRADIENT_INTERPOLATE_CUBIC); } Vector<float> Gradient::get_offsets() const { @@ -86,6 +98,15 @@ Vector<Color> Gradient::get_colors() const { return colors; } +void Gradient::set_interpolation_mode(Gradient::InterpolationMode p_interp_mode) { + interpolation_mode = p_interp_mode; + emit_signal(CoreStringNames::get_singleton()->changed); +} + +Gradient::InterpolationMode Gradient::get_interpolation_mode() { + return interpolation_mode; +} + void Gradient::set_offsets(const Vector<float> &p_offsets) { points.resize(p_offsets.size()); for (int i = 0; i < points.size(); i++) { @@ -127,6 +148,15 @@ void Gradient::remove_point(int p_index) { emit_signal(CoreStringNames::get_singleton()->changed); } +void Gradient::reverse() { + for (int i = 0; i < points.size(); i++) { + points.write[i].offset = 1.0 - points[i].offset; + } + + _update_sorting(); + emit_signal(CoreStringNames::get_singleton()->changed); +} + void Gradient::set_points(Vector<Gradient::Point> &p_points) { points = p_points; is_sorted = false; diff --git a/scene/resources/gradient.h b/scene/resources/gradient.h index cf5b179c45..eb438d0bba 100644 --- a/scene/resources/gradient.h +++ b/scene/resources/gradient.h @@ -38,6 +38,12 @@ class Gradient : public Resource { OBJ_SAVE_TYPE(Gradient); public: + enum InterpolationMode { + GRADIENT_INTERPOLATE_LINEAR, + GRADIENT_INTERPOLATE_CONSTANT, + GRADIENT_INTERPOLATE_CUBIC, + }; + struct Point { float offset = 0.0; Color color; @@ -49,6 +55,8 @@ public: private: Vector<Point> points; bool is_sorted = true; + InterpolationMode interpolation_mode = GRADIENT_INTERPOLATE_LINEAR; + _FORCE_INLINE_ void _update_sorting() { if (!is_sorted) { points.sort(); @@ -65,9 +73,9 @@ public: void add_point(float p_offset, const Color &p_color); void remove_point(int p_index); - void set_points(Vector<Point> &p_points); Vector<Point> &get_points(); + void reverse(); void set_offset(int pos, const float offset); float get_offset(int pos); @@ -81,6 +89,13 @@ public: void set_colors(const Vector<Color> &p_colors); Vector<Color> get_colors() const; + void set_interpolation_mode(InterpolationMode p_interp_mode); + InterpolationMode get_interpolation_mode(); + + _FORCE_INLINE_ float cubic_interpolate(float p0, float p1, float p2, float p3, float x) { + return p1 + 0.5 * x * (p2 - p0 + x * (2.0 * p0 - 5.0 * p1 + 4.0 * p2 - p3 + x * (3.0 * (p1 - p2) + p3 - p0))); + } + _FORCE_INLINE_ Color get_color_at_offset(float p_offset) { if (points.is_empty()) { return Color(0, 0, 0, 1); @@ -88,7 +103,7 @@ public: _update_sorting(); - //binary search + // Binary search. int low = 0; int high = points.size() - 1; int middle = 0; @@ -111,7 +126,7 @@ public: } } - //return interpolated value + // Return interpolated value. if (points[middle].offset > p_offset) { middle--; } @@ -125,10 +140,44 @@ public: } const Point &pointFirst = points[first]; const Point &pointSecond = points[second]; - return pointFirst.color.lerp(pointSecond.color, (p_offset - pointFirst.offset) / (pointSecond.offset - pointFirst.offset)); + + switch (interpolation_mode) { + case GRADIENT_INTERPOLATE_LINEAR: { + return pointFirst.color.lerp(pointSecond.color, (p_offset - pointFirst.offset) / (pointSecond.offset - pointFirst.offset)); + } break; + case GRADIENT_INTERPOLATE_CONSTANT: { + return pointFirst.color; + } break; + case GRADIENT_INTERPOLATE_CUBIC: { + int p0 = first - 1; + int p3 = second + 1; + if (p3 >= points.size()) { + p3 = second; + } + if (p0 < 0) { + p0 = first; + } + const Point &pointP0 = points[p0]; + const Point &pointP3 = points[p3]; + + float x = (p_offset - pointFirst.offset) / (pointSecond.offset - pointFirst.offset); + float r = cubic_interpolate(pointP0.color.r, pointFirst.color.r, pointSecond.color.r, pointP3.color.r, x); + float g = cubic_interpolate(pointP0.color.g, pointFirst.color.g, pointSecond.color.g, pointP3.color.g, x); + float b = cubic_interpolate(pointP0.color.b, pointFirst.color.b, pointSecond.color.b, pointP3.color.b, x); + float a = cubic_interpolate(pointP0.color.a, pointFirst.color.a, pointSecond.color.a, pointP3.color.a, x); + + return Color(r, g, b, a); + } break; + default: { + // Fallback to linear interpolation. + return pointFirst.color.lerp(pointSecond.color, (p_offset - pointFirst.offset) / (pointSecond.offset - pointFirst.offset)); + } + } } int get_points_count() const; }; +VARIANT_ENUM_CAST(Gradient::InterpolationMode); + #endif // GRADIENT_H diff --git a/scene/resources/text_paragraph.cpp b/scene/resources/text_paragraph.cpp index fae1de94d3..1b7fc64267 100644 --- a/scene/resources/text_paragraph.cpp +++ b/scene/resources/text_paragraph.cpp @@ -38,6 +38,11 @@ void TextParagraph::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "direction", PROPERTY_HINT_ENUM, "Auto,Light-to-right,Right-to-left"), "set_direction", "get_direction"); + ClassDB::bind_method(D_METHOD("set_custom_punctuation", "custom_punctuation"), &TextParagraph::set_custom_punctuation); + ClassDB::bind_method(D_METHOD("get_custom_punctuation"), &TextParagraph::get_custom_punctuation); + + ADD_PROPERTY(PropertyInfo(Variant::STRING, "custom_punctuation"), "set_custom_punctuation", "get_custom_punctuation"); + ClassDB::bind_method(D_METHOD("set_orientation", "orientation"), &TextParagraph::set_orientation); ClassDB::bind_method(D_METHOD("get_orientation"), &TextParagraph::get_orientation); @@ -304,6 +309,15 @@ TextServer::Direction TextParagraph::get_direction() const { return TS->shaped_text_get_direction(rid); } +void TextParagraph::set_custom_punctuation(const String &p_punct) { + TS->shaped_text_set_custom_punctuation(rid, p_punct); + lines_dirty = true; +} + +String TextParagraph::get_custom_punctuation() const { + return TS->shaped_text_get_custom_punctuation(rid); +} + void TextParagraph::set_orientation(TextServer::Orientation p_orientation) { TS->shaped_text_set_orientation(rid, p_orientation); TS->shaped_text_set_orientation(dropcap_rid, p_orientation); diff --git a/scene/resources/text_paragraph.h b/scene/resources/text_paragraph.h index 701c9a17cd..4c4af43d14 100644 --- a/scene/resources/text_paragraph.h +++ b/scene/resources/text_paragraph.h @@ -96,6 +96,9 @@ public: void set_bidi_override(const Array &p_override); + void set_custom_punctuation(const String &p_punct); + String get_custom_punctuation() const; + bool set_dropcap(const String &p_text, const Ref<Font> &p_fonts, int p_size, const Rect2 &p_dropcap_margins = Rect2(), const Dictionary &p_opentype_features = Dictionary(), const String &p_language = ""); void clear_dropcap(); diff --git a/servers/physics_2d/godot_body_2d.cpp b/servers/physics_2d/godot_body_2d.cpp index 109914d585..442c580920 100644 --- a/servers/physics_2d/godot_body_2d.cpp +++ b/servers/physics_2d/godot_body_2d.cpp @@ -221,7 +221,7 @@ Variant GodotBody2D::get_param(PhysicsServer2D::BodyParameter p_param) const { return inertia; } case PhysicsServer2D::BODY_PARAM_CENTER_OF_MASS: { - return center_of_mass; + return center_of_mass_local; } case PhysicsServer2D::BODY_PARAM_GRAVITY_SCALE: { return gravity_scale; diff --git a/servers/physics_2d/godot_body_2d.h b/servers/physics_2d/godot_body_2d.h index 817d5f1b0d..7b11b50739 100644 --- a/servers/physics_2d/godot_body_2d.h +++ b/servers/physics_2d/godot_body_2d.h @@ -282,6 +282,7 @@ public: void reset_mass_properties(); _FORCE_INLINE_ const Vector2 &get_center_of_mass() const { return center_of_mass; } + _FORCE_INLINE_ const Vector2 &get_center_of_mass_local() const { return center_of_mass_local; } _FORCE_INLINE_ real_t get_inv_mass() const { return _inv_mass; } _FORCE_INLINE_ real_t get_inv_inertia() const { return _inv_inertia; } _FORCE_INLINE_ real_t get_friction() const { return friction; } diff --git a/servers/physics_2d/godot_body_direct_state_2d.cpp b/servers/physics_2d/godot_body_direct_state_2d.cpp index deebc57f37..9c9bd56268 100644 --- a/servers/physics_2d/godot_body_direct_state_2d.cpp +++ b/servers/physics_2d/godot_body_direct_state_2d.cpp @@ -50,6 +50,10 @@ Vector2 GodotPhysicsDirectBodyState2D::get_center_of_mass() const { return body->get_center_of_mass(); } +Vector2 GodotPhysicsDirectBodyState2D::get_center_of_mass_local() const { + return body->get_center_of_mass_local(); +} + real_t GodotPhysicsDirectBodyState2D::get_inverse_mass() const { return body->get_inv_mass(); } diff --git a/servers/physics_2d/godot_body_direct_state_2d.h b/servers/physics_2d/godot_body_direct_state_2d.h index 2f3e8e5095..ff25205d52 100644 --- a/servers/physics_2d/godot_body_direct_state_2d.h +++ b/servers/physics_2d/godot_body_direct_state_2d.h @@ -46,6 +46,7 @@ public: virtual real_t get_total_linear_damp() const override; virtual Vector2 get_center_of_mass() const override; + virtual Vector2 get_center_of_mass_local() const override; virtual real_t get_inverse_mass() const override; virtual real_t get_inverse_inertia() const override; diff --git a/servers/physics_3d/godot_body_3d.cpp b/servers/physics_3d/godot_body_3d.cpp index 768c9e6572..acf60d61c2 100644 --- a/servers/physics_3d/godot_body_3d.cpp +++ b/servers/physics_3d/godot_body_3d.cpp @@ -267,7 +267,7 @@ Variant GodotBody3D::get_param(PhysicsServer3D::BodyParameter p_param) const { } } break; case PhysicsServer3D::BODY_PARAM_CENTER_OF_MASS: { - return center_of_mass; + return center_of_mass_local; } break; case PhysicsServer3D::BODY_PARAM_GRAVITY_SCALE: { return gravity_scale; diff --git a/servers/physics_3d/godot_body_3d.h b/servers/physics_3d/godot_body_3d.h index 4993ea6a1b..7fc2f58168 100644 --- a/servers/physics_3d/godot_body_3d.h +++ b/servers/physics_3d/godot_body_3d.h @@ -200,6 +200,7 @@ public: _FORCE_INLINE_ Basis get_principal_inertia_axes() const { return principal_inertia_axes; } _FORCE_INLINE_ Vector3 get_center_of_mass() const { return center_of_mass; } + _FORCE_INLINE_ Vector3 get_center_of_mass_local() const { return center_of_mass_local; } _FORCE_INLINE_ Vector3 xform_local_to_principal(const Vector3 &p_pos) const { return principal_inertia_axes_local.xform(p_pos - center_of_mass_local); } _FORCE_INLINE_ void set_linear_velocity(const Vector3 &p_velocity) { linear_velocity = p_velocity; } diff --git a/servers/physics_3d/godot_body_direct_state_3d.cpp b/servers/physics_3d/godot_body_direct_state_3d.cpp index 9c234a5752..a929cab6f9 100644 --- a/servers/physics_3d/godot_body_direct_state_3d.cpp +++ b/servers/physics_3d/godot_body_direct_state_3d.cpp @@ -49,6 +49,10 @@ Vector3 GodotPhysicsDirectBodyState3D::get_center_of_mass() const { return body->get_center_of_mass(); } +Vector3 GodotPhysicsDirectBodyState3D::get_center_of_mass_local() const { + return body->get_center_of_mass_local(); +} + Basis GodotPhysicsDirectBodyState3D::get_principal_inertia_axes() const { return body->get_principal_inertia_axes(); } diff --git a/servers/physics_3d/godot_body_direct_state_3d.h b/servers/physics_3d/godot_body_direct_state_3d.h index 6c584a2634..35fd1543b0 100644 --- a/servers/physics_3d/godot_body_direct_state_3d.h +++ b/servers/physics_3d/godot_body_direct_state_3d.h @@ -46,6 +46,7 @@ public: virtual real_t get_total_linear_damp() const override; virtual Vector3 get_center_of_mass() const override; + virtual Vector3 get_center_of_mass_local() const override; virtual Basis get_principal_inertia_axes() const override; virtual real_t get_inverse_mass() const override; diff --git a/servers/physics_server_2d.cpp b/servers/physics_server_2d.cpp index 466558c9db..fa89ccec65 100644 --- a/servers/physics_server_2d.cpp +++ b/servers/physics_server_2d.cpp @@ -78,6 +78,7 @@ void PhysicsDirectBodyState2D::_bind_methods() { ClassDB::bind_method(D_METHOD("get_total_angular_damp"), &PhysicsDirectBodyState2D::get_total_angular_damp); ClassDB::bind_method(D_METHOD("get_center_of_mass"), &PhysicsDirectBodyState2D::get_center_of_mass); + ClassDB::bind_method(D_METHOD("get_center_of_mass_local"), &PhysicsDirectBodyState2D::get_center_of_mass_local); ClassDB::bind_method(D_METHOD("get_inverse_mass"), &PhysicsDirectBodyState2D::get_inverse_mass); ClassDB::bind_method(D_METHOD("get_inverse_inertia"), &PhysicsDirectBodyState2D::get_inverse_inertia); @@ -124,6 +125,7 @@ void PhysicsDirectBodyState2D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "total_linear_damp"), "", "get_total_linear_damp"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "total_gravity"), "", "get_total_gravity"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "center_of_mass"), "", "get_center_of_mass"); + ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "center_of_mass_local"), "", "get_center_of_mass_local"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "angular_velocity"), "set_angular_velocity", "get_angular_velocity"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "linear_velocity"), "set_linear_velocity", "get_linear_velocity"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "sleeping"), "set_sleep_state", "is_sleeping"); diff --git a/servers/physics_server_2d.h b/servers/physics_server_2d.h index 55ac7e1fdc..fec03a8111 100644 --- a/servers/physics_server_2d.h +++ b/servers/physics_server_2d.h @@ -49,6 +49,7 @@ public: virtual real_t get_total_angular_damp() const = 0; // get density of this body space/area virtual Vector2 get_center_of_mass() const = 0; + virtual Vector2 get_center_of_mass_local() const = 0; virtual real_t get_inverse_mass() const = 0; // get the mass virtual real_t get_inverse_inertia() const = 0; // get density of this body space diff --git a/servers/physics_server_3d.cpp b/servers/physics_server_3d.cpp index a354b69a29..eb52cbfe5a 100644 --- a/servers/physics_server_3d.cpp +++ b/servers/physics_server_3d.cpp @@ -77,6 +77,7 @@ void PhysicsDirectBodyState3D::_bind_methods() { ClassDB::bind_method(D_METHOD("get_total_angular_damp"), &PhysicsDirectBodyState3D::get_total_angular_damp); ClassDB::bind_method(D_METHOD("get_center_of_mass"), &PhysicsDirectBodyState3D::get_center_of_mass); + ClassDB::bind_method(D_METHOD("get_center_of_mass_local"), &PhysicsDirectBodyState3D::get_center_of_mass_local); ClassDB::bind_method(D_METHOD("get_principal_inertia_axes"), &PhysicsDirectBodyState3D::get_principal_inertia_axes); ClassDB::bind_method(D_METHOD("get_inverse_mass"), &PhysicsDirectBodyState3D::get_inverse_mass); @@ -126,6 +127,7 @@ void PhysicsDirectBodyState3D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "inverse_inertia"), "", "get_inverse_inertia"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "total_gravity"), "", "get_total_gravity"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "center_of_mass"), "", "get_center_of_mass"); + ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "center_of_mass_local"), "", "get_center_of_mass_local"); ADD_PROPERTY(PropertyInfo(Variant::BASIS, "principal_inertia_axes"), "", "get_principal_inertia_axes"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "angular_velocity"), "set_angular_velocity", "get_angular_velocity"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "linear_velocity"), "set_linear_velocity", "get_linear_velocity"); diff --git a/servers/physics_server_3d.h b/servers/physics_server_3d.h index 8883443e34..b5113fd35f 100644 --- a/servers/physics_server_3d.h +++ b/servers/physics_server_3d.h @@ -48,6 +48,7 @@ public: virtual real_t get_total_linear_damp() const = 0; virtual Vector3 get_center_of_mass() const = 0; + virtual Vector3 get_center_of_mass_local() const = 0; virtual Basis get_principal_inertia_axes() const = 0; virtual real_t get_inverse_mass() const = 0; // get the mass virtual Vector3 get_inverse_inertia() const = 0; // get density of this body space diff --git a/servers/rendering/shader_language.cpp b/servers/rendering/shader_language.cpp index 04cc844483..d803d5fcf8 100644 --- a/servers/rendering/shader_language.cpp +++ b/servers/rendering/shader_language.cpp @@ -7439,7 +7439,6 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct int texture_uniforms = 0; int texture_binding = 0; - int uniforms = 0; int instance_index = 0; ShaderNode::Uniform::Scope uniform_scope = ShaderNode::Uniform::SCOPE_LOCAL; @@ -7790,9 +7789,6 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct return ERR_PARSE_ERROR; } uniform2.texture_order = -1; - if (uniform_scope != ShaderNode::Uniform::SCOPE_INSTANCE) { - uniform2.order = uniforms++; - } } if (uniform2.array_size > 0) { @@ -8771,6 +8767,20 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct tk = _get_token(); } + int uniforms = 0; + + // Need to push arrays to first place in a uniform buffer in order to correct work. + for (Map<StringName, ShaderNode::Uniform>::Element *E = shader->uniforms.front(); E; E = E->next()) { + if (E->get().texture_order == -1 && E->get().scope != ShaderNode::Uniform::SCOPE_INSTANCE && E->get().array_size > 0) { + E->get().order = uniforms++; + } + } + for (Map<StringName, ShaderNode::Uniform>::Element *E = shader->uniforms.front(); E; E = E->next()) { + if (E->get().texture_order == -1 && E->get().scope != ShaderNode::Uniform::SCOPE_INSTANCE && E->get().array_size == 0) { + E->get().order = uniforms++; + } + } + int error_line; String error_message; if (!_check_varying_usages(&error_line, &error_message)) { diff --git a/servers/text/text_server_extension.cpp b/servers/text/text_server_extension.cpp index a44fee7c95..0a7523e33a 100644 --- a/servers/text/text_server_extension.cpp +++ b/servers/text/text_server_extension.cpp @@ -55,6 +55,15 @@ void TextServerExtension::_bind_methods() { GDVIRTUAL_BIND(_font_set_data, "font_rid", "data"); GDVIRTUAL_BIND(_font_set_data_ptr, "font_rid", "data_ptr", "data_size"); + GDVIRTUAL_BIND(_font_set_style, "font_rid", "style"); + GDVIRTUAL_BIND(_font_get_style, "font_rid"); + + GDVIRTUAL_BIND(_font_set_name, "font_rid", "name"); + GDVIRTUAL_BIND(_font_get_name, "font_rid"); + + GDVIRTUAL_BIND(_font_set_style_name, "font_rid", "name_style"); + GDVIRTUAL_BIND(_font_get_style_name, "font_rid"); + GDVIRTUAL_BIND(_font_set_antialiased, "font_rid", "antialiased"); GDVIRTUAL_BIND(_font_is_antialiased, "font_rid"); @@ -185,6 +194,9 @@ void TextServerExtension::_bind_methods() { GDVIRTUAL_BIND(_shaped_text_set_bidi_override, "shaped", "override"); + GDVIRTUAL_BIND(_shaped_text_set_custom_punctuation, "shaped", "punct"); + GDVIRTUAL_BIND(_shaped_text_get_custom_punctuation, "shaped"); + GDVIRTUAL_BIND(_shaped_text_set_orientation, "shaped", "orientation"); GDVIRTUAL_BIND(_shaped_text_get_orientation, "shaped"); @@ -368,6 +380,42 @@ void TextServerExtension::font_set_data_ptr(RID p_font_rid, const uint8_t *p_dat GDVIRTUAL_CALL(_font_set_data_ptr, p_font_rid, p_data_ptr, p_data_size); } +void TextServerExtension::font_set_style(RID p_font_rid, uint32_t /*FontStyle*/ p_style) { + GDVIRTUAL_CALL(_font_set_style, p_font_rid, p_style); +} + +uint32_t /*FontStyle*/ TextServerExtension::font_get_style(RID p_font_rid) const { + uint32_t ret; + if (GDVIRTUAL_CALL(_font_get_style, p_font_rid, ret)) { + return ret; + } + return 0; +} + +void TextServerExtension::font_set_style_name(RID p_font_rid, const String &p_name) { + GDVIRTUAL_CALL(_font_set_style_name, p_font_rid, p_name); +} + +String TextServerExtension::font_get_style_name(RID p_font_rid) const { + String ret; + if (GDVIRTUAL_CALL(_font_get_style_name, p_font_rid, ret)) { + return ret; + } + return String(); +} + +void TextServerExtension::font_set_name(RID p_font_rid, const String &p_name) { + GDVIRTUAL_CALL(_font_set_name, p_font_rid, p_name); +} + +String TextServerExtension::font_get_name(RID p_font_rid) const { + String ret; + if (GDVIRTUAL_CALL(_font_get_name, p_font_rid, ret)) { + return ret; + } + return String(); +} + void TextServerExtension::font_set_antialiased(RID p_font_rid, bool p_antialiased) { GDVIRTUAL_CALL(_font_set_antialiased, p_font_rid, p_antialiased); } @@ -906,6 +954,18 @@ void TextServerExtension::shaped_text_set_bidi_override(RID p_shaped, const Arra GDVIRTUAL_CALL(_shaped_text_set_bidi_override, p_shaped, p_override); } +void TextServerExtension::shaped_text_set_custom_punctuation(RID p_shaped, const String &p_punct) { + GDVIRTUAL_CALL(_shaped_text_set_custom_punctuation, p_shaped, p_punct); +} + +String TextServerExtension::shaped_text_get_custom_punctuation(RID p_shaped) const { + String ret; + if (GDVIRTUAL_CALL(_shaped_text_get_custom_punctuation, p_shaped, ret)) { + return ret; + } + return String(); +} + void TextServerExtension::shaped_text_set_preserve_invalid(RID p_shaped, bool p_enabled) { GDVIRTUAL_CALL(_shaped_text_set_preserve_invalid, p_shaped, p_enabled); } diff --git a/servers/text/text_server_extension.h b/servers/text/text_server_extension.h index 954b2cf660..e419b4055d 100644 --- a/servers/text/text_server_extension.h +++ b/servers/text/text_server_extension.h @@ -84,6 +84,21 @@ public: GDVIRTUAL2(_font_set_data, RID, const PackedByteArray &); GDVIRTUAL3(_font_set_data_ptr, RID, GDNativeConstPtr<const uint8_t>, uint64_t); + virtual void font_set_style(RID p_font_rid, uint32_t /*FontStyle*/ p_style) override; + virtual uint32_t /*FontStyle*/ font_get_style(RID p_font_rid) const override; + GDVIRTUAL2(_font_set_style, RID, uint32_t); + GDVIRTUAL1RC(uint32_t, _font_get_style, RID); + + virtual void font_set_name(RID p_font_rid, const String &p_name) override; + virtual String font_get_name(RID p_font_rid) const override; + GDVIRTUAL2(_font_set_name, RID, const String &); + GDVIRTUAL1RC(String, _font_get_name, RID); + + virtual void font_set_style_name(RID p_font_rid, const String &p_name) override; + virtual String font_get_style_name(RID p_font_rid) const override; + GDVIRTUAL2(_font_set_style_name, RID, const String &); + GDVIRTUAL1RC(String, _font_get_style_name, RID); + virtual void font_set_antialiased(RID p_font_rid, bool p_antialiased) override; virtual bool font_is_antialiased(RID p_font_rid) const override; GDVIRTUAL2(_font_set_antialiased, RID, bool); @@ -301,6 +316,11 @@ public: virtual void shaped_text_set_bidi_override(RID p_shaped, const Array &p_override) override; GDVIRTUAL2(_shaped_text_set_bidi_override, RID, const Array &); + virtual void shaped_text_set_custom_punctuation(RID p_shaped, const String &p_punct) override; + virtual String shaped_text_get_custom_punctuation(RID p_shaped) const override; + GDVIRTUAL2(_shaped_text_set_custom_punctuation, RID, String); + GDVIRTUAL1RC(String, _shaped_text_get_custom_punctuation, RID); + virtual void shaped_text_set_orientation(RID p_shaped, Orientation p_orientation = ORIENTATION_HORIZONTAL) override; virtual Orientation shaped_text_get_orientation(RID p_shaped) const override; GDVIRTUAL2(_shaped_text_set_orientation, RID, Orientation); diff --git a/servers/text_server.cpp b/servers/text_server.cpp index af4718678e..9034239fe0 100644 --- a/servers/text_server.cpp +++ b/servers/text_server.cpp @@ -208,6 +208,15 @@ void TextServer::_bind_methods() { ClassDB::bind_method(D_METHOD("font_set_data", "font_rid", "data"), &TextServer::font_set_data); + ClassDB::bind_method(D_METHOD("font_set_style", "font_rid", "style"), &TextServer::font_set_style); + ClassDB::bind_method(D_METHOD("font_get_style", "font_rid"), &TextServer::font_get_style); + + ClassDB::bind_method(D_METHOD("font_set_name", "font_rid", "name"), &TextServer::font_set_name); + ClassDB::bind_method(D_METHOD("font_get_name", "font_rid"), &TextServer::font_get_name); + + ClassDB::bind_method(D_METHOD("font_set_style_name", "font_rid", "name"), &TextServer::font_set_style_name); + ClassDB::bind_method(D_METHOD("font_get_style_name", "font_rid"), &TextServer::font_get_style_name); + ClassDB::bind_method(D_METHOD("font_set_antialiased", "font_rid", "antialiased"), &TextServer::font_set_antialiased); ClassDB::bind_method(D_METHOD("font_is_antialiased", "font_rid"), &TextServer::font_is_antialiased); @@ -338,6 +347,9 @@ void TextServer::_bind_methods() { ClassDB::bind_method(D_METHOD("shaped_text_set_bidi_override", "shaped", "override"), &TextServer::shaped_text_set_bidi_override); + ClassDB::bind_method(D_METHOD("shaped_text_set_custom_punctuation", "shaped", "punct"), &TextServer::shaped_text_set_custom_punctuation); + ClassDB::bind_method(D_METHOD("shaped_text_get_custom_punctuation", "shaped"), &TextServer::shaped_text_get_custom_punctuation); + ClassDB::bind_method(D_METHOD("shaped_text_set_orientation", "shaped", "orientation"), &TextServer::shaped_text_set_orientation, DEFVAL(ORIENTATION_HORIZONTAL)); ClassDB::bind_method(D_METHOD("shaped_text_get_orientation", "shaped"), &TextServer::shaped_text_get_orientation); @@ -470,11 +482,16 @@ void TextServer::_bind_methods() { BIND_ENUM_CONSTANT(CONTOUR_CURVE_TAG_OFF_CONIC); BIND_ENUM_CONSTANT(CONTOUR_CURVE_TAG_OFF_CUBIC); - /* Font Spacing*/ + /* Font Spacing */ BIND_ENUM_CONSTANT(SPACING_GLYPH); BIND_ENUM_CONSTANT(SPACING_SPACE); BIND_ENUM_CONSTANT(SPACING_TOP); BIND_ENUM_CONSTANT(SPACING_BOTTOM); + + /* Font Style */ + BIND_ENUM_CONSTANT(FONT_BOLD); + BIND_ENUM_CONSTANT(FONT_ITALIC); + BIND_ENUM_CONSTANT(FONT_FIXED_WIDTH); } Vector2 TextServer::get_hex_code_box_size(int p_size, char32_t p_index) const { diff --git a/servers/text_server.h b/servers/text_server.h index a5484d8fbd..4f55f881e6 100644 --- a/servers/text_server.h +++ b/servers/text_server.h @@ -125,6 +125,12 @@ public: SPACING_BOTTOM, }; + enum FontStyle { + FONT_BOLD = 1 << 0, + FONT_ITALIC = 1 << 1, + FONT_FIXED_WIDTH = 1 << 2, + }; + void _draw_hex_code_box_number(RID p_canvas, int p_size, const Vector2 &p_pos, uint8_t p_index, const Color &p_color) const; protected: @@ -144,6 +150,7 @@ protected: int end = 0; // Substring end offset in the parent string. String text; + String custom_punct; TextServer::Direction direction = DIRECTION_LTR; // Desired text direction. TextServer::Orientation orientation = ORIENTATION_HORIZONTAL; @@ -224,6 +231,15 @@ public: virtual void font_set_data(RID p_font_rid, const PackedByteArray &p_data) = 0; virtual void font_set_data_ptr(RID p_font_rid, const uint8_t *p_data_ptr, size_t p_data_size) = 0; + virtual void font_set_style(RID p_font_rid, uint32_t /*FontStyle*/ p_style) = 0; + virtual uint32_t /*FontStyle*/ font_get_style(RID p_font_rid) const = 0; + + virtual void font_set_name(RID p_font_rid, const String &p_name) = 0; + virtual String font_get_name(RID p_font_rid) const = 0; + + virtual void font_set_style_name(RID p_font_rid, const String &p_name) = 0; + virtual String font_get_style_name(RID p_font_rid) const = 0; + virtual void font_set_antialiased(RID p_font_rid, bool p_antialiased) = 0; virtual bool font_is_antialiased(RID p_font_rid) const = 0; @@ -354,6 +370,9 @@ public: virtual void shaped_text_set_bidi_override(RID p_shaped, const Array &p_override) = 0; + virtual void shaped_text_set_custom_punctuation(RID p_shaped, const String &p_punct) = 0; + virtual String shaped_text_get_custom_punctuation(RID p_shaped) const = 0; + virtual void shaped_text_set_orientation(RID p_shaped, Orientation p_orientation = ORIENTATION_HORIZONTAL) = 0; virtual Orientation shaped_text_get_orientation(RID p_shaped) const = 0; @@ -535,6 +554,7 @@ VARIANT_ENUM_CAST(TextServer::Hinting); VARIANT_ENUM_CAST(TextServer::Feature); VARIANT_ENUM_CAST(TextServer::ContourPointTag); VARIANT_ENUM_CAST(TextServer::SpacingType); +VARIANT_ENUM_CAST(TextServer::FontStyle); GDVIRTUAL_NATIVE_PTR(Glyph); GDVIRTUAL_NATIVE_PTR(Glyph *); |