diff options
55 files changed, 625 insertions, 222 deletions
diff --git a/ISSUE_TEMPLATE.md b/ISSUE_TEMPLATE.md index ef9894bcdb..2a3c298633 100644 --- a/ISSUE_TEMPLATE.md +++ b/ISSUE_TEMPLATE.md @@ -1,4 +1,4 @@ -**Operating system or device - Godot version:** +**Operating system or device, Godot version, GPU Model and driver (if graphics related):** **Issue description:** diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index c69fe17049..5f534f63a8 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -978,9 +978,9 @@ void _OS::_bind_methods() { ClassDB::bind_method(D_METHOD("get_screen_count"), &_OS::get_screen_count); ClassDB::bind_method(D_METHOD("get_current_screen"), &_OS::get_current_screen); ClassDB::bind_method(D_METHOD("set_current_screen", "screen"), &_OS::set_current_screen); - ClassDB::bind_method(D_METHOD("get_screen_position", "screen"), &_OS::get_screen_position, DEFVAL(0)); - ClassDB::bind_method(D_METHOD("get_screen_size", "screen"), &_OS::get_screen_size, DEFVAL(0)); - ClassDB::bind_method(D_METHOD("get_screen_dpi", "screen"), &_OS::get_screen_dpi, DEFVAL(0)); + ClassDB::bind_method(D_METHOD("get_screen_position", "screen"), &_OS::get_screen_position, DEFVAL(-1)); + ClassDB::bind_method(D_METHOD("get_screen_size", "screen"), &_OS::get_screen_size, DEFVAL(-1)); + ClassDB::bind_method(D_METHOD("get_screen_dpi", "screen"), &_OS::get_screen_dpi, DEFVAL(-1)); ClassDB::bind_method(D_METHOD("get_window_position"), &_OS::get_window_position); ClassDB::bind_method(D_METHOD("set_window_position", "position"), &_OS::set_window_position); ClassDB::bind_method(D_METHOD("get_window_size"), &_OS::get_window_size); diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index 41653c8846..fc280bd7ef 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -140,9 +140,9 @@ public: virtual int get_screen_count() const; virtual int get_current_screen() const; virtual void set_current_screen(int p_screen); - virtual Point2 get_screen_position(int p_screen = 0) const; - virtual Size2 get_screen_size(int p_screen = 0) const; - virtual int get_screen_dpi(int p_screen = 0) const; + virtual Point2 get_screen_position(int p_screen = -1) const; + virtual Size2 get_screen_size(int p_screen = -1) const; + virtual int get_screen_dpi(int p_screen = -1) const; virtual Point2 get_window_position() const; virtual void set_window_position(const Point2 &p_position); virtual Size2 get_window_size() const; diff --git a/core/global_constants.cpp b/core/global_constants.cpp index d296b678b9..cd9a302ba6 100644 --- a/core/global_constants.cpp +++ b/core/global_constants.cpp @@ -45,15 +45,15 @@ struct _GlobalConstant { _GlobalConstant() {} #ifdef DEBUG_METHODS_ENABLED - _GlobalConstant(const StringName &p_enum_name, const char *p_name, int p_value) { - enum_name = p_enum_name; - name = p_name; - value = p_value; + _GlobalConstant(const StringName &p_enum_name, const char *p_name, int p_value) + : enum_name(p_enum_name), + name(p_name), + value(p_value) { } #else - _GlobalConstant(const char *p_name, int p_value) { - name = p_name; - value = p_value; + _GlobalConstant(const char *p_name, int p_value) + : name(p_name), + value(p_value) { } #endif }; diff --git a/core/os/os.h b/core/os/os.h index 4d64e4a9f0..0fcf465655 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -164,9 +164,9 @@ public: virtual int get_screen_count() const { return 1; } virtual int get_current_screen() const { return 0; } virtual void set_current_screen(int p_screen) {} - virtual Point2 get_screen_position(int p_screen = 0) const { return Point2(); } - virtual Size2 get_screen_size(int p_screen = 0) const { return get_window_size(); } - virtual int get_screen_dpi(int p_screen = 0) const { return 72; } + virtual Point2 get_screen_position(int p_screen = -1) const { return Point2(); } + virtual Size2 get_screen_size(int p_screen = -1) const { return get_window_size(); } + virtual int get_screen_dpi(int p_screen = -1) const { return 72; } virtual Point2 get_window_position() const { return Vector2(); } virtual void set_window_position(const Point2 &p_position) {} virtual Size2 get_window_size() const = 0; diff --git a/core/variant_parser.cpp b/core/variant_parser.cpp index 398f20caf3..5aa71f6704 100644 --- a/core/variant_parser.cpp +++ b/core/variant_parser.cpp @@ -326,6 +326,7 @@ Error VariantParser::get_token(Stream *p_stream, Token &r_token, int &line, Stri is_float = true; } else if (c == 'e') { reading = READING_EXP; + is_float = true; } else { reading = READING_DONE; } @@ -337,7 +338,6 @@ Error VariantParser::get_token(Stream *p_stream, Token &r_token, int &line, Stri } else if (c == 'e') { reading = READING_EXP; - } else { reading = READING_DONE; } @@ -349,8 +349,6 @@ Error VariantParser::get_token(Stream *p_stream, Token &r_token, int &line, Stri exp_beg = true; } else if ((c == '-' || c == '+') && !exp_sign && !exp_beg) { - if (c == '-') - is_float = true; exp_sign = true; } else { diff --git a/doc/base/classes.xml b/doc/base/classes.xml index 570d90f81e..26c0b81428 100644 --- a/doc/base/classes.xml +++ b/doc/base/classes.xml @@ -46114,6 +46114,13 @@ <description> </description> </method> + <method name="get_nine_patch_stretch"> + <return type="bool"> + </return> + <description> + Returns true if textures are stretched as nine-patches or false otherwise. + </description> + </method> <method name="get_over_texture" qualifiers="const"> <return type="Object"> </return> @@ -46138,6 +46145,15 @@ <description> </description> </method> + <method name="get_stretch_margin" qualifiers="const"> + <return type="int"> + </return> + <argument index="0" name="margin" type="int"> + </argument> + <description> + Return nine-patch texture offset for a given margin (MARGIN_LEFT, MARGIN_TOP, MARGIN_RIGHT, MARGIN_BOTTOM). + </description> + </method> <method name="get_under_texture" qualifiers="const"> <return type="Object"> </return> @@ -46156,6 +46172,13 @@ <description> </description> </method> + <method name="set_nine_patch_stretch"> + <argument index="0" name="stretch" type="bool"> + </argument> + <description> + Set if textures should be stretched as nine-patches. + </description> + </method> <method name="set_over_texture"> <argument index="0" name="tex" type="Object"> </argument> @@ -46180,6 +46203,15 @@ <description> </description> </method> + <method name="set_stretch_margin"> + <argument index="0" name="margin" type="int"> + </argument> + <argument index="1" name="size" type="int"> + </argument> + <description> + Set nine-patch texture offset for a given margin (MARGIN_LEFT, MARGIN_TOP, MARGIN_RIGHT, MARGIN_BOTTOM). + </description> + </method> <method name="set_under_texture"> <argument index="0" name="tex" type="Object"> </argument> @@ -46202,6 +46234,16 @@ </member> <member name="texture_under" type="Texture" setter="set_under_texture" getter="get_under_texture" brief=""> </member> + <member name="nine_patch_stretch" type="bool" setter="set_nine_patch_stretch" getter="get_nine_patch_stretch" brief=""> + </member> + <member name="stretch_margin_left" type="int" setter="set_stretch_margin" getter="get_stretch_margin" brief=""> + </member> + <member name="stretch_margin_top" type="int" setter="set_stretch_margin" getter="get_stretch_margin" brief=""> + </member> + <member name="stretch_margin_right" type="int" setter="set_stretch_margin" getter="get_stretch_margin" brief=""> + </member> + <member name="stretch_margin_bottom" type="int" setter="set_stretch_margin" getter="get_stretch_margin" brief=""> + </member> </members> <constants> <constant name="FILL_LEFT_TO_RIGHT" value="0"> diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp index 52c7327baf..05cfba726c 100644 --- a/drivers/gles3/rasterizer_scene_gles3.cpp +++ b/drivers/gles3/rasterizer_scene_gles3.cpp @@ -2186,7 +2186,7 @@ void RasterizerSceneGLES3::_add_geometry(RasterizerStorageGLES3::Geometry *p_geo while (m->next_pass.is_valid()) { m = storage->material_owner.getornull(m->next_pass); - if (!m) + if (!m || !m->shader || !m->shader->valid) break; _add_geometry_with_material(p_geometry, p_instance, p_owner, m, p_shadow); } @@ -3302,6 +3302,10 @@ void RasterizerSceneGLES3::_render_mrts(Environment *env, const CameraMatrix &p_ if (state.used_sss) { //sss enabled //copy diffuse while performing sss + Plane p = p_cam_projection.xform4(Plane(1, 0, -1, 1)); + p.normal /= p.d; + float unit_size = p.normal.x; + //copy normal and roughness to effect buffer glBindFramebuffer(GL_READ_FRAMEBUFFER, storage->frame.current_rt->buffers.fbo); glReadBuffer(GL_COLOR_ATTACHMENT3); @@ -3312,9 +3316,10 @@ void RasterizerSceneGLES3::_render_mrts(Environment *env, const CameraMatrix &p_ state.sss_shader.set_conditional(SubsurfScatteringShaderGLES3::USE_17_SAMPLES, subsurface_scatter_quality == SSS_QUALITY_MEDIUM); state.sss_shader.set_conditional(SubsurfScatteringShaderGLES3::USE_25_SAMPLES, subsurface_scatter_quality == SSS_QUALITY_HIGH); state.sss_shader.set_conditional(SubsurfScatteringShaderGLES3::ENABLE_FOLLOW_SURFACE, subsurface_scatter_follow_surface); + state.sss_shader.set_conditional(SubsurfScatteringShaderGLES3::ENABLE_STRENGTH_WEIGHTING, subsurface_scatter_weight_samples); state.sss_shader.bind(); state.sss_shader.set_uniform(SubsurfScatteringShaderGLES3::MAX_RADIUS, subsurface_scatter_size); - state.sss_shader.set_uniform(SubsurfScatteringShaderGLES3::FOVY, p_cam_projection.get_fov()); + state.sss_shader.set_uniform(SubsurfScatteringShaderGLES3::UNIT_SIZE, unit_size); state.sss_shader.set_uniform(SubsurfScatteringShaderGLES3::CAMERA_Z_NEAR, p_cam_projection.get_z_near()); state.sss_shader.set_uniform(SubsurfScatteringShaderGLES3::CAMERA_Z_FAR, p_cam_projection.get_z_far()); state.sss_shader.set_uniform(SubsurfScatteringShaderGLES3::DIR, Vector2(1, 0)); @@ -3329,14 +3334,13 @@ void RasterizerSceneGLES3::_render_mrts(Environment *env, const CameraMatrix &p_ glBindTexture(GL_TEXTURE_2D, storage->frame.current_rt->effects.ssao.blur_red[0]); glActiveTexture(GL_TEXTURE2); glBindTexture(GL_TEXTURE_2D, storage->frame.current_rt->depth); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_NONE); + //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_NONE); glBindFramebuffer(GL_FRAMEBUFFER, storage->frame.current_rt->fbo); //copy to front first _copy_screen(true); glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, storage->frame.current_rt->color); state.sss_shader.set_uniform(SubsurfScatteringShaderGLES3::DIR, Vector2(0, 1)); glBindFramebuffer(GL_FRAMEBUFFER, storage->frame.current_rt->effects.mip_maps[0].sizes[0].fbo); // copy to base level @@ -4955,6 +4959,7 @@ void RasterizerSceneGLES3::initialize() { GLOBAL_DEF("rendering/quality/subsurface_scattering/scale", 1.0); ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/subsurface_scattering/scale", PropertyInfo(Variant::INT, "rendering/quality/subsurface_scattering/scale", PROPERTY_HINT_RANGE, "0.01,8,0.01")); GLOBAL_DEF("rendering/quality/subsurface_scattering/follow_surface", false); + GLOBAL_DEF("rendering/quality/subsurface_scattering/weight_samples", true); GLOBAL_DEF("rendering/quality/voxel_cone_tracing/high_quality", true); } @@ -4997,6 +5002,7 @@ void RasterizerSceneGLES3::iteration() { shadow_filter_mode = ShadowFilterMode(int(ProjectSettings::get_singleton()->get("rendering/quality/shadows/filter_mode"))); subsurface_scatter_follow_surface = ProjectSettings::get_singleton()->get("rendering/quality/subsurface_scattering/follow_surface"); + subsurface_scatter_weight_samples = ProjectSettings::get_singleton()->get("rendering/quality/subsurface_scattering/weight_samples"); subsurface_scatter_quality = SubSurfaceScatterQuality(int(ProjectSettings::get_singleton()->get("rendering/quality/subsurface_scattering/quality"))); subsurface_scatter_size = ProjectSettings::get_singleton()->get("rendering/quality/subsurface_scattering/scale"); diff --git a/drivers/gles3/rasterizer_scene_gles3.h b/drivers/gles3/rasterizer_scene_gles3.h index 740d277a3a..94781c53e8 100644 --- a/drivers/gles3/rasterizer_scene_gles3.h +++ b/drivers/gles3/rasterizer_scene_gles3.h @@ -66,6 +66,7 @@ public: SubSurfaceScatterQuality subsurface_scatter_quality; float subsurface_scatter_size; bool subsurface_scatter_follow_surface; + bool subsurface_scatter_weight_samples; uint64_t render_pass; uint64_t scene_pass; diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp index dc9006a4e1..68731308a9 100644 --- a/drivers/gles3/rasterizer_storage_gles3.cpp +++ b/drivers/gles3/rasterizer_storage_gles3.cpp @@ -6253,7 +6253,7 @@ void RasterizerStorageGLES3::_render_target_allocate(RenderTarget *rt) { glBindFramebuffer(GL_FRAMEBUFFER, mm.fbo); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, rt->effects.mip_maps[i].color, j); bool used_depth = false; - if (j == 0 && i == 0 && rt->buffers.active == false && !rt->flags[RENDER_TARGET_NO_3D]) { //will use this one for rendering 3D + if (j == 0 && i == 0) { //use always glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, rt->depth, 0); used_depth = true; } diff --git a/drivers/gles3/shaders/scene.glsl b/drivers/gles3/shaders/scene.glsl index 3f0498746b..e6476bd6b6 100644 --- a/drivers/gles3/shaders/scene.glsl +++ b/drivers/gles3/shaders/scene.glsl @@ -1694,6 +1694,7 @@ FRAGMENT_SHADER_CODE if (gl_FragCoord.w > shadow_split_offsets.w) { vec3 pssm_coord; + float pssm_fade=0.0; #ifdef LIGHT_USE_PSSM_BLEND float pssm_blend; @@ -1751,6 +1752,7 @@ FRAGMENT_SHADER_CODE } else { highp vec4 splane=(shadow_matrix4 * vec4(vertex,1.0)); pssm_coord=splane.xyz/splane.w; + pssm_fade = smoothstep(shadow_split_offsets.z,shadow_split_offsets.w,gl_FragCoord.w); #if defined(LIGHT_USE_PSSM_BLEND) use_blend=false; @@ -1782,6 +1784,7 @@ FRAGMENT_SHADER_CODE } else { highp vec4 splane=(shadow_matrix2 * vec4(vertex,1.0)); pssm_coord=splane.xyz/splane.w; + pssm_fade = smoothstep(shadow_split_offsets.x,shadow_split_offsets.y,gl_FragCoord.w); #if defined(LIGHT_USE_PSSM_BLEND) use_blend=false; @@ -1818,7 +1821,7 @@ FRAGMENT_SHADER_CODE } #endif - light_attenuation=mix(shadow_color_contact.rgb,vec3(1.0),shadow); + light_attenuation=mix(mix(shadow_color_contact.rgb,vec3(1.0),shadow),vec3(1.0),pssm_fade); } diff --git a/drivers/gles3/shaders/ssao.glsl b/drivers/gles3/shaders/ssao.glsl index d8302bd46e..0e8fc89d6c 100644 --- a/drivers/gles3/shaders/ssao.glsl +++ b/drivers/gles3/shaders/ssao.glsl @@ -11,6 +11,7 @@ void main() { [fragment] +#define TWO_PI 6.283185307179586476925286766559 #define NUM_SAMPLES (15) @@ -205,7 +206,7 @@ void main() { // Hash function used in the HPG12 AlchemyAO paper - float randomPatternRotationAngle = float((3 * ssC.x ^ ssC.y + ssC.x * ssC.y) * 10); + float randomPatternRotationAngle = mod(float((3 * ssC.x ^ ssC.y + ssC.x * ssC.y) * 10), TWO_PI); // Reconstruct normals from positions. These will lead to 1-pixel black lines // at depth discontinuities, however the blur will wipe those out so they are not visible @@ -225,7 +226,7 @@ void main() { #ifdef ENABLE_RADIUS2 //go again for radius2 - randomPatternRotationAngle = float((5 * ssC.x ^ ssC.y + ssC.x * ssC.y) * 11); + randomPatternRotationAngle = mod(float((5 * ssC.x ^ ssC.y + ssC.x * ssC.y) * 11), TWO_PI); // Reconstruct normals from positions. These will lead to 1-pixel black lines // at depth discontinuities, however the blur will wipe those out so they are not visible diff --git a/drivers/gles3/shaders/subsurf_scattering.glsl b/drivers/gles3/shaders/subsurf_scattering.glsl index 569be6c5fe..8873443727 100644 --- a/drivers/gles3/shaders/subsurf_scattering.glsl +++ b/drivers/gles3/shaders/subsurf_scattering.glsl @@ -17,36 +17,36 @@ void main() { //#define QUALIFIER uniform // some guy on the interweb says it may be faster with this #define QUALIFIER const - #ifdef USE_25_SAMPLES const int kernel_size=25; -QUALIFIER vec4 kernel[25] = vec4[] ( - vec4(0.530605, 0.613514, 0.739601, 0.0), - vec4(0.000973794, 1.11862e-005, 9.43437e-007, -3.0), - vec4(0.00333804, 7.85443e-005, 1.2945e-005, -2.52083), - vec4(0.00500364, 0.00020094, 5.28848e-005, -2.08333), - vec4(0.00700976, 0.00049366, 0.000151938, -1.6875), - vec4(0.0094389, 0.00139119, 0.000416598, -1.33333), - vec4(0.0128496, 0.00356329, 0.00132016, -1.02083), - vec4(0.017924, 0.00711691, 0.00347194, -0.75), - vec4(0.0263642, 0.0119715, 0.00684598, -0.520833), - vec4(0.0410172, 0.0199899, 0.0118481, -0.333333), - vec4(0.0493588, 0.0367726, 0.0219485, -0.1875), - vec4(0.0402784, 0.0657244, 0.04631, -0.0833333), - vec4(0.0211412, 0.0459286, 0.0378196, -0.0208333), - vec4(0.0211412, 0.0459286, 0.0378196, 0.0208333), - vec4(0.0402784, 0.0657244, 0.04631, 0.0833333), - vec4(0.0493588, 0.0367726, 0.0219485, 0.1875), - vec4(0.0410172, 0.0199899, 0.0118481, 0.333333), - vec4(0.0263642, 0.0119715, 0.00684598, 0.520833), - vec4(0.017924, 0.00711691, 0.00347194, 0.75), - vec4(0.0128496, 0.00356329, 0.00132016, 1.02083), - vec4(0.0094389, 0.00139119, 0.000416598, 1.33333), - vec4(0.00700976, 0.00049366, 0.000151938, 1.6875), - vec4(0.00500364, 0.00020094, 5.28848e-005, 2.08333), - vec4(0.00333804, 7.85443e-005, 1.2945e-005, 2.52083), - vec4(0.000973794, 1.11862e-005, 9.43437e-007, 3.0) + +QUALIFIER vec2 kernel[25] = vec2[] ( +vec2(0.099654,0.0), +vec2(0.001133,-3.0), +vec2(0.002316,-2.52083), +vec2(0.00445,-2.08333), +vec2(0.008033,-1.6875), +vec2(0.013627,-1.33333), +vec2(0.021724,-1.02083), +vec2(0.032542,-0.75), +vec2(0.04581,-0.520833), +vec2(0.0606,-0.333333), +vec2(0.075333,-0.1875), +vec2(0.088001,-0.0833333), +vec2(0.096603,-0.0208333), +vec2(0.096603,0.0208333), +vec2(0.088001,0.0833333), +vec2(0.075333,0.1875), +vec2(0.0606,0.333333), +vec2(0.04581,0.520833), +vec2(0.032542,0.75), +vec2(0.021724,1.02083), +vec2(0.013627,1.33333), +vec2(0.008033,1.6875), +vec2(0.00445,2.08333), +vec2(0.002316,2.52), +vec2(0.001133,3.0) ); #endif //USE_25_SAMPLES @@ -55,24 +55,24 @@ QUALIFIER vec4 kernel[25] = vec4[] ( const int kernel_size=17; -QUALIFIER vec4 kernel[17] = vec4[]( - vec4(0.536343, 0.624624, 0.748867, 0.0), - vec4(0.00317394, 0.000134823, 3.77269e-005, -2.0), - vec4(0.0100386, 0.000914679, 0.000275702, -1.53125), - vec4(0.0144609, 0.00317269, 0.00106399, -1.125), - vec4(0.0216301, 0.00794618, 0.00376991, -0.78125), - vec4(0.0347317, 0.0151085, 0.00871983, -0.5), - vec4(0.0571056, 0.0287432, 0.0172844, -0.28125), - vec4(0.0582416, 0.0659959, 0.0411329, -0.125), - vec4(0.0324462, 0.0656718, 0.0532821, -0.03125), - vec4(0.0324462, 0.0656718, 0.0532821, 0.03125), - vec4(0.0582416, 0.0659959, 0.0411329, 0.125), - vec4(0.0571056, 0.0287432, 0.0172844, 0.28125), - vec4(0.0347317, 0.0151085, 0.00871983, 0.5), - vec4(0.0216301, 0.00794618, 0.00376991, 0.78125), - vec4(0.0144609, 0.00317269, 0.00106399, 1.125), - vec4(0.0100386, 0.000914679, 0.000275702, 1.53125), - vec4(0.00317394, 0.000134823, 3.77269e-005, 2.0) +QUALIFIER vec2 kernel[17] = vec2[]( +vec2(0.197417,0.0), +vec2(0.000078,-2.0), +vec2(0.000489,-1.53125), +vec2(0.002403,-1.125), +vec2(0.009245,-0.78125), +vec2(0.027835,-0.5), +vec2(0.065592,-0.28125), +vec2(0.12098,-0.125), +vec2(0.17467,-0.03125), +vec2(0.17467,0.03125), +vec2(0.12098,0.125), +vec2(0.065592,0.28125), +vec2(0.027835,0.5), +vec2(0.009245,0.78125), +vec2(0.002403,1.125), +vec2(0.000489,1.53125), +vec2(0.000078,2.0) ); #endif //USE_17_SAMPLES @@ -82,27 +82,27 @@ QUALIFIER vec4 kernel[17] = vec4[]( const int kernel_size=11; -QUALIFIER vec4 kernel[11] = vec4[]( - vec4(0.560479, 0.669086, 0.784728, 0.0), - vec4(0.00471691, 0.000184771, 5.07566e-005, -2.0), - vec4(0.0192831, 0.00282018, 0.00084214, -1.28), - vec4(0.03639, 0.0130999, 0.00643685, -0.72), - vec4(0.0821904, 0.0358608, 0.0209261, -0.32), - vec4(0.0771802, 0.113491, 0.0793803, -0.08), - vec4(0.0771802, 0.113491, 0.0793803, 0.08), - vec4(0.0821904, 0.0358608, 0.0209261, 0.32), - vec4(0.03639, 0.0130999, 0.00643685, 0.72), - vec4(0.0192831, 0.00282018, 0.00084214, 1.28), - vec4(0.00471691, 0.000184771, 5.07565e-005, 2.0) +QUALIFIER vec2 kernel[kernel_size] = vec2[]( +vec2(0.198596,0.0), +vec2(0.0093,-2.0), +vec2(0.028002,-1.28), +vec2(0.065984,-0.72), +vec2(0.121703,-0.32), +vec2(0.175713,-0.08), +vec2(0.175713,0.08), +vec2(0.121703,0.32), +vec2(0.065984,0.72), +vec2(0.028002,1.28), +vec2(0.0093,2.0) ); #endif //USE_11_SAMPLES uniform float max_radius; -uniform float fovy; uniform float camera_z_far; uniform float camera_z_near; +uniform float unit_size; uniform vec2 dir; in vec2 uv_interp; @@ -120,19 +120,17 @@ void main() { // Fetch color of current pixel: vec4 base_color = texture(source_diffuse, uv_interp); + if (strength>0.0) { // Fetch linear depth of current pixel: float depth = texture(source_depth, uv_interp).r * 2.0 - 1.0; depth = 2.0 * camera_z_near * camera_z_far / (camera_z_far + camera_z_near - depth * (camera_z_far - camera_z_near)); - depth=-depth; - // Calculate the radius scale (1.0 for a unit plane sitting on the - // projection window): - float distance = 1.0 / tan(0.5 * fovy); - float scale = distance / -depth; //remember depth is negative by default in OpenGL + + float scale = unit_size / depth; //remember depth is negative by default in OpenGL // Calculate the final step to fetch the surrounding pixels: vec2 step = max_radius * scale * dir; @@ -141,19 +139,21 @@ void main() { // Accumulate the center sample: vec3 color_accum = base_color.rgb; - color_accum *= kernel[0].rgb; + color_accum *= kernel[0].x; +#ifdef ENABLE_STRENGTH_WEIGHTING + float color_weight = kernel[0].x; +#endif // Accumulate the other samples: for (int i = 1; i < kernel_size; i++) { // Fetch color and depth for current sample: - vec2 offset = uv_interp + kernel[i].a * step; + vec2 offset = uv_interp + kernel[i].y * step; vec3 color = texture(source_diffuse, offset).rgb; #ifdef ENABLE_FOLLOW_SURFACE // If the difference in depth is huge, we lerp color back to "colorM": float depth_cmp = texture(source_depth, offset).r *2.0 - 1.0; depth_cmp = 2.0 * camera_z_near * camera_z_far / (camera_z_far + camera_z_near - depth_cmp * (camera_z_far - camera_z_near)); - depth_cmp=-depth_cmp; float s = clamp(300.0f * distance * max_radius * abs(depth - depth_cmp),0.0,1.0); @@ -161,9 +161,20 @@ void main() { #endif // Accumulate: - color_accum += kernel[i].rgb * color; + color*=kernel[i].x; + +#ifdef ENABLE_STRENGTH_WEIGHTING + float color_s = texture(source_sss, offset).r; + color_weight+=color_s * kernel[i].x; + color*=color_s; +#endif + color_accum += color; + } +#ifdef ENABLE_STRENGTH_WEIGHTING + color_accum/=color_weight; +#endif frag_color = vec4(color_accum,base_color.a); //keep alpha (used for SSAO) } else { frag_color = base_color; diff --git a/drivers/gles3/shaders/tonemap.glsl b/drivers/gles3/shaders/tonemap.glsl index 988e31d1ea..73dec4f90c 100644 --- a/drivers/gles3/shaders/tonemap.glsl +++ b/drivers/gles3/shaders/tonemap.glsl @@ -170,7 +170,7 @@ vec3 tonemap_aces(vec3 color) { return color = clamp((color*(a*color+b))/(color*(c*color+d)+e),vec3(0.0),vec3(1.0)); } -vec3 tonemap_reindhart(vec3 color,vec3 white) { +vec3 tonemap_reindhart(vec3 color,float white) { return ( color * ( 1.0 + ( color / ( white) ) ) ) / ( 1.0 + color ); } diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 5c8e166730..358d575764 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -593,6 +593,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { hints["text_editor/theme/color_theme"] = PropertyInfo(Variant::STRING, "text_editor/theme/color_theme", PROPERTY_HINT_ENUM, "Default"); set("text_editor/theme/line_spacing", 4); + set("text_editor/theme/adapted_code_editor_background_color", true); _load_default_text_editor_theme(); diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index 9f6416f4e6..f628a23d5f 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -86,19 +86,6 @@ static Ref<StyleBoxFlat> change_border_color(Ref<StyleBoxFlat> p_style, Color p_ return style; } -static Ref<StyleBoxFlat> add_additional_border(Ref<StyleBoxFlat> p_style, int p_left, int p_top, int p_right, int p_bottom) { - Ref<StyleBoxFlat> style = p_style->duplicate(); - style->set_border_width(MARGIN_LEFT, p_left * EDSCALE + style->get_border_width(MARGIN_LEFT)); - style->set_border_width(MARGIN_RIGHT, p_right * EDSCALE + style->get_border_width(MARGIN_RIGHT)); - style->set_border_width(MARGIN_TOP, p_top * EDSCALE + style->get_border_width(MARGIN_TOP)); - style->set_border_width(MARGIN_BOTTOM, p_bottom * EDSCALE + style->get_border_width(MARGIN_BOTTOM)); - style->set_expand_margin_size(MARGIN_LEFT, p_left * EDSCALE); - style->set_expand_margin_size(MARGIN_RIGHT, p_right * EDSCALE); - style->set_expand_margin_size(MARGIN_TOP, p_top * EDSCALE); - style->set_expand_margin_size(MARGIN_BOTTOM, p_bottom * EDSCALE); - return style; -} - #define HIGHLIGHT_COLOR_LIGHT highlight_color.linear_interpolate(Color(1, 1, 1, 1), 0.3) #define HIGHLIGHT_COLOR_DARK highlight_color.linear_interpolate(Color(0, 0, 0, 1), 0.5) @@ -424,6 +411,8 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_stylebox("SceneTabFG", "EditorStyles", make_flat_stylebox(title_color_hl, 10, 5, 10, 5)); theme->set_stylebox("SceneTabBG", "EditorStyles", make_empty_stylebox(6, 5, 6, 5)); theme->set_icon("close", "Tabs", theme->get_icon("GuiClose", "EditorIcons")); + theme->set_stylebox("button_pressed", "Tabs", style_menu); + theme->set_stylebox("button", "Tabs", style_menu); // Separators (no separators) theme->set_stylebox("separator", "HSeparator", make_line_stylebox(separator_color, border_width)); @@ -537,7 +526,8 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { // PopupPanel Ref<StyleBoxFlat> style_dock_select = make_flat_stylebox(base_color); style_dock_select->set_border_color_all(light_color_1); - style_dock_select = add_additional_border(style_dock_select, 2, 2, 2, 2); + style_dock_select->set_expand_margin_size_all(2); + style_dock_select->set_border_width_all(2); theme->set_stylebox("panel", "PopupPanel", style_dock_select); // SpinBox diff --git a/editor/icons/SCsub b/editor/icons/SCsub index 564188f315..86c51a50f3 100644 --- a/editor/icons/SCsub +++ b/editor/icons/SCsub @@ -88,5 +88,4 @@ make_editor_icons_builder = Builder(action=make_editor_icons_action, env['BUILDERS']['MakeEditorIconsBuilder'] = make_editor_icons_builder env.Alias('editor_icons', [env.MakeEditorIconsBuilder('#editor/editor_icons.gen.h', Glob("*.svg"))]) -env.editor_sources.append("#editor/editor_icons.gen.h") Export('env') diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 6db732ba5d..e8770febd9 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -2072,7 +2072,10 @@ void ScriptEditor::_update_selected_editor_menu() { } } - EditorHelp *eh = tab_container->get_current_tab_control()->cast_to<EditorHelp>(); + EditorHelp *eh = NULL; + if (tab_container->get_current_tab_control()) + eh = tab_container->get_current_tab_control()->cast_to<EditorHelp>(); + if (eh) { script_search_menu->show(); } else { @@ -2349,7 +2352,6 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { debug_menu = memnew(MenuButton); menu_hb->add_child(debug_menu); debug_menu->set_text(TTR("Debug")); - debug_menu->get_popup()->add_separator(); debug_menu->get_popup()->add_shortcut(ED_SHORTCUT("debugger/step_over", TTR("Step Over"), KEY_F10), DEBUG_NEXT); debug_menu->get_popup()->add_shortcut(ED_SHORTCUT("debugger/step_into", TTR("Step Into"), KEY_F11), DEBUG_STEP); debug_menu->get_popup()->add_separator(); diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index 1a3092b6e4..e69fa6da88 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -75,9 +75,14 @@ void ScriptTextEditor::_load_theme_settings() { text_edit->clear_colors(); - /* keyword color */ + /* color from color_theme or from editor color */ + + Color background_color = EDITOR_DEF("text_editor/highlighting/background_color", Color(0, 0, 0, 0)); + if (EDITOR_DEF("text_editor/theme/adapted_code_editor_background_color", false)) + background_color = get_color("dark_color_1", "Editor"); - text_edit->add_color_override("background_color", EDITOR_DEF("text_editor/highlighting/background_color", Color(0, 0, 0, 0))); + /* keyword color */ + text_edit->add_color_override("background_color", background_color); text_edit->add_color_override("completion_background_color", EDITOR_DEF("text_editor/highlighting/completion_background_color", Color(0, 0, 0, 0))); text_edit->add_color_override("completion_selected_color", EDITOR_DEF("text_editor/highlighting/completion_selected_color", Color::html("434244"))); text_edit->add_color_override("completion_existing_color", EDITOR_DEF("text_editor/highlighting/completion_existing_color", Color::html("21dfdfdf"))); @@ -972,16 +977,27 @@ void ScriptTextEditor::_edit_option(int p_op) { Ref<Script> scr = get_edited_script(); if (scr.is_null()) return; + + te->begin_complex_operation(); int begin, end; if (te->is_selection_active()) { begin = te->get_selection_from_line(); end = te->get_selection_to_line(); + // ignore if the cursor is not past the first column + if (te->get_selection_to_column() == 0) { + end--; + } } else { begin = 0; end = te->get_line_count() - 1; } scr->get_language()->auto_indent_code(text, begin, end); - te->set_text(text); + Vector<String> lines = text.split("\n"); + for (int i = begin; i <= end; ++i) { + te->set_line(i, lines[i]); + } + + te->end_complex_operation(); } break; case EDIT_TRIM_TRAILING_WHITESAPCE: { diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp index bca1f254b0..1d25f9e56b 100644 --- a/editor/plugins/spatial_editor_plugin.cpp +++ b/editor/plugins/spatial_editor_plugin.cpp @@ -1756,7 +1756,11 @@ void SpatialEditorViewport::_notification(int p_what) { Transform t = sp->get_global_transform(); t.translate(se->aabb.position); - t.basis.scale(se->aabb.size); + + // apply AABB scaling before item's global transform + Basis aabb_s; + aabb_s.scale(se->aabb.size); + t.basis = t.basis * aabb_s; exist = true; if (se->last_xform == t) diff --git a/editor/script_editor_debugger.cpp b/editor/script_editor_debugger.cpp index fee67df9c9..d1ad503542 100644 --- a/editor/script_editor_debugger.cpp +++ b/editor/script_editor_debugger.cpp @@ -306,8 +306,7 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da String error = p_data[1]; step->set_disabled(!can_continue); next->set_disabled(!can_continue); - reason->set_text(error); - reason->set_tooltip(error); + _set_reason_text(error, MESSAGE_ERROR); breaked = true; dobreak->set_disabled(true); docontinue->set_disabled(false); @@ -761,6 +760,21 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da } } +void ScriptEditorDebugger::_set_reason_text(const String &p_reason, MessageType p_type) { + switch (p_type) { + case MESSAGE_ERROR: + reason->add_color_override("font_color", get_color("error_color", "Editor")); + break; + case MESSAGE_WARNING: + reason->add_color_override("font_color", get_color("warning_color", "Editor")); + break; + default: + reason->add_color_override("font_color", get_color("success_color", "Editor")); + } + reason->set_text(p_reason); + reason->set_tooltip(p_reason); +} + void ScriptEditorDebugger::_performance_select(Object *, int, bool) { perf_draw->update(); @@ -921,8 +935,7 @@ void ScriptEditorDebugger::_notification(int p_what) { dobreak->set_disabled(false); tabs->set_current_tab(0); - reason->set_text(TTR("Child Process Connected")); - reason->set_tooltip(TTR("Child Process Connected")); + _set_reason_text(TTR("Child Process Connected"), MESSAGE_SUCCESS); profiler->clear(); inspect_scene_tree->clear(); diff --git a/editor/script_editor_debugger.h b/editor/script_editor_debugger.h index d255d73167..bee49bf15c 100644 --- a/editor/script_editor_debugger.h +++ b/editor/script_editor_debugger.h @@ -56,6 +56,12 @@ class ScriptEditorDebugger : public Control { GDCLASS(ScriptEditorDebugger, Control); + enum MessageType { + MESSAGE_ERROR, + MESSAGE_WARNING, + MESSAGE_SUCCESS, + }; + AcceptDialog *msgdialog; Button *debugger_button; @@ -144,6 +150,7 @@ class ScriptEditorDebugger : public Control { void _scene_tree_selected(); void _scene_tree_request(); void _parse_message(const String &p_msg, const Array &p_data); + void _set_reason_text(const String &p_msg, MessageType p_type); void _scene_tree_property_select_object(ObjectID p_object); void _scene_tree_property_value_edited(const String &p_prop, const Variant &p_value); diff --git a/main/tests/test_shader_lang.cpp b/main/tests/test_shader_lang.cpp index dc581a71e2..f9516dad99 100644 --- a/main/tests/test_shader_lang.cpp +++ b/main/tests/test_shader_lang.cpp @@ -56,8 +56,6 @@ static String _mktab(int p_level) { static String _typestr(SL::DataType p_type) { return ShaderLanguage::get_datatype_name(p_type); - - return ""; } static String _prestr(SL::DataPrecision p_pres) { diff --git a/modules/gdscript/gd_function.h b/modules/gdscript/gd_function.h index 6d20b19777..661de0acce 100644 --- a/modules/gdscript/gd_function.h +++ b/modules/gdscript/gd_function.h @@ -210,8 +210,9 @@ public: #ifdef TOOLS_ENABLED ERR_FAIL_INDEX_V(p_idx, arg_names.size(), StringName()); return arg_names[p_idx]; -#endif +#else return StringName(); +#endif } Variant get_default_argument(int p_idx) const { ERR_FAIL_INDEX_V(p_idx, default_arguments.size(), Variant()); diff --git a/modules/gdscript/gd_parser.cpp b/modules/gdscript/gd_parser.cpp index 7d3857266e..b349b6b9a8 100644 --- a/modules/gdscript/gd_parser.cpp +++ b/modules/gdscript/gd_parser.cpp @@ -1894,7 +1894,26 @@ GDParser::PatternNode *GDParser::_parse_pattern(bool p_static) { return NULL; } - if (value->type != Node::TYPE_IDENTIFIER && value->type != Node::TYPE_CONSTANT) { + if (value->type == Node::TYPE_OPERATOR) { + // Maybe it's SomeEnum.VALUE + Node *current_value = value; + + while (current_value->type == Node::TYPE_OPERATOR) { + OperatorNode *op_node = static_cast<OperatorNode *>(current_value); + + if (op_node->op != OperatorNode::OP_INDEX_NAMED) { + _set_error("Invalid operator in pattern. Only index (`A.B`) is allowed"); + return NULL; + } + current_value = op_node->arguments[0]; + } + + if (current_value->type != Node::TYPE_IDENTIFIER) { + _set_error("Only constant expression or variables allowed in a pattern"); + return NULL; + } + + } else if (value->type != Node::TYPE_IDENTIFIER && value->type != Node::TYPE_CONSTANT) { _set_error("Only constant expressions or variables allowed in a pattern"); return NULL; } diff --git a/modules/gdscript/gd_script.cpp b/modules/gdscript/gd_script.cpp index 2d06c0f5d2..23201dc1b0 100644 --- a/modules/gdscript/gd_script.cpp +++ b/modules/gdscript/gd_script.cpp @@ -559,8 +559,9 @@ bool GDScript::_update_exports() { return changed; -#endif +#else return false; +#endif } void GDScript::update_exports() { diff --git a/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp b/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp index 7b8b2abebb..5ad16c7337 100644 --- a/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp +++ b/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp @@ -49,7 +49,7 @@ void AudioStreamPlaybackOGGVorbis::_mix_internal(AudioFrame *p_buffer, int p_fra //end of file! if (vorbis_stream->loop) { //loop - seek_pos(0); + seek_pos(vorbis_stream->loop_offset); loops++; } else { for (int i = mixed; i < p_frames; i++) { @@ -227,6 +227,14 @@ bool AudioStreamOGGVorbis::has_loop() const { return loop; } +void AudioStreamOGGVorbis::set_loop_offset(float p_seconds) { + loop_offset = p_seconds; +} + +float AudioStreamOGGVorbis::get_loop_offset() const { + return loop_offset; +} + void AudioStreamOGGVorbis::_bind_methods() { ClassDB::bind_method(D_METHOD("set_data", "data"), &AudioStreamOGGVorbis::set_data); @@ -235,8 +243,12 @@ void AudioStreamOGGVorbis::_bind_methods() { ClassDB::bind_method(D_METHOD("set_loop", "enable"), &AudioStreamOGGVorbis::set_loop); ClassDB::bind_method(D_METHOD("has_loop"), &AudioStreamOGGVorbis::has_loop); + ClassDB::bind_method(D_METHOD("set_loop_offset", "seconds"), &AudioStreamOGGVorbis::set_loop_offset); + ClassDB::bind_method(D_METHOD("get_loop_offset"), &AudioStreamOGGVorbis::get_loop_offset); + ADD_PROPERTY(PropertyInfo(Variant::POOL_BYTE_ARRAY, "data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_data", "get_data"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "loop", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_loop", "has_loop"); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "loop_offset", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_loop_offset", "get_loop_offset"); } AudioStreamOGGVorbis::AudioStreamOGGVorbis() { @@ -245,6 +257,7 @@ AudioStreamOGGVorbis::AudioStreamOGGVorbis() { length = 0; sample_rate = 1; channels = 1; + loop_offset = 0; decode_mem_size = 0; loop = false; } diff --git a/modules/stb_vorbis/audio_stream_ogg_vorbis.h b/modules/stb_vorbis/audio_stream_ogg_vorbis.h index 46cdfd3f2d..56bfe398c0 100644 --- a/modules/stb_vorbis/audio_stream_ogg_vorbis.h +++ b/modules/stb_vorbis/audio_stream_ogg_vorbis.h @@ -89,6 +89,7 @@ class AudioStreamOGGVorbis : public AudioStream { int channels; float length; bool loop; + float loop_offset; protected: static void _bind_methods(); @@ -97,6 +98,9 @@ public: void set_loop(bool p_enable); bool has_loop() const; + void set_loop_offset(float p_seconds); + float get_loop_offset() const; + virtual Ref<AudioStreamPlayback> instance_playback(); virtual String get_stream_name() const; diff --git a/modules/stb_vorbis/resource_importer_ogg_vorbis.cpp b/modules/stb_vorbis/resource_importer_ogg_vorbis.cpp index f0a7ee1ec6..5a1157bf9c 100644 --- a/modules/stb_vorbis/resource_importer_ogg_vorbis.cpp +++ b/modules/stb_vorbis/resource_importer_ogg_vorbis.cpp @@ -72,11 +72,13 @@ String ResourceImporterOGGVorbis::get_preset_name(int p_idx) const { void ResourceImporterOGGVorbis::get_import_options(List<ImportOption> *r_options, int p_preset) const { r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "loop"), true)); + r_options->push_back(ImportOption(PropertyInfo(Variant::REAL, "loop_offset"), 0)); } Error ResourceImporterOGGVorbis::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files) { bool loop = p_options["loop"]; + float loop_offset = p_options["loop_offset"]; FileAccess *f = FileAccess::open(p_source_file, FileAccess::READ); if (!f) { @@ -98,6 +100,7 @@ Error ResourceImporterOGGVorbis::import(const String &p_source_file, const Strin ogg_stream->set_data(data); ogg_stream->set_loop(loop); + ogg_stream->set_loop_offset(loop_offset); return ResourceSaver::save(p_save_path + ".oggstr", ogg_stream); } diff --git a/modules/svg/image_loader_svg.cpp b/modules/svg/image_loader_svg.cpp index 46931fb0f6..c74188d9ea 100644 --- a/modules/svg/image_loader_svg.cpp +++ b/modules/svg/image_loader_svg.cpp @@ -82,9 +82,9 @@ Error ImageLoaderSVG::create_image_from_string(Ref<Image> p_image, const char *s size_t str_len = strlen(svg_str); PoolVector<uint8_t> src_data; - src_data.resize(str_len); + src_data.resize(str_len + 1); PoolVector<uint8_t>::Write src_w = src_data.write(); - memcpy(src_w.ptr(), svg_str, str_len); + memcpy(src_w.ptr(), svg_str, str_len + 1); return _create_image(p_image, &src_data, p_scale, upsample); } @@ -93,9 +93,10 @@ Error ImageLoaderSVG::load_image(Ref<Image> p_image, FileAccess *f, bool p_force uint32_t size = f->get_len(); PoolVector<uint8_t> src_image; - src_image.resize(size); + src_image.resize(size + 1); PoolVector<uint8_t>::Write src_w = src_image.write(); f->get_buffer(src_w.ptr(), size); + src_w.ptr()[size] = '\0'; return _create_image(p_image, &src_image, p_scale, 1.0); } diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp index b9e7a6ffc4..e7aaf0aa4a 100644 --- a/modules/visual_script/visual_script_editor.cpp +++ b/modules/visual_script/visual_script_editor.cpp @@ -2716,6 +2716,12 @@ void VisualScriptEditor::_selected_connect_node_method_or_setget(const String &p _update_graph_connections(); } +void VisualScriptEditor::_cancel_connect_node_method_or_setget() { + + script->remove_node(edited_func, port_action_new_node); + _update_graph(); +} + void VisualScriptEditor::_default_value_changed() { Ref<VisualScriptNode> vsn = script->get_node(edited_func, editing_id); @@ -3167,6 +3173,7 @@ void VisualScriptEditor::_bind_methods() { ClassDB::bind_method("_button_resource_previewed", &VisualScriptEditor::_button_resource_previewed); ClassDB::bind_method("_port_action_menu", &VisualScriptEditor::_port_action_menu); ClassDB::bind_method("_selected_connect_node_method_or_setget", &VisualScriptEditor::_selected_connect_node_method_or_setget); + ClassDB::bind_method("_cancel_connect_node_method_or_setget", &VisualScriptEditor::_cancel_connect_node_method_or_setget); ClassDB::bind_method("_expression_text_changed", &VisualScriptEditor::_expression_text_changed); ClassDB::bind_method("get_drag_data_fw", &VisualScriptEditor::get_drag_data_fw); @@ -3364,6 +3371,7 @@ VisualScriptEditor::VisualScriptEditor() { new_connect_node_select = memnew(PropertySelector); add_child(new_connect_node_select); new_connect_node_select->connect("selected", this, "_selected_connect_node_method_or_setget"); + new_connect_node_select->get_cancel()->connect("pressed", this, "_cancel_connect_node_method_or_setget"); port_action_popup = memnew(PopupMenu); add_child(port_action_popup); diff --git a/modules/visual_script/visual_script_editor.h b/modules/visual_script/visual_script_editor.h index fee4e27bd5..e68711a036 100644 --- a/modules/visual_script/visual_script_editor.h +++ b/modules/visual_script/visual_script_editor.h @@ -176,6 +176,7 @@ class VisualScriptEditor : public ScriptEditorBase { int port_action_new_node; void _port_action_menu(int p_option); void _selected_connect_node_method_or_setget(const String &p_text); + void _cancel_connect_node_method_or_setget(); int error_line; diff --git a/modules/visual_script/visual_script_expression.cpp b/modules/visual_script/visual_script_expression.cpp index 78b70934c0..25c2ebd6d2 100644 --- a/modules/visual_script/visual_script_expression.cpp +++ b/modules/visual_script/visual_script_expression.cpp @@ -585,7 +585,6 @@ Error VisualScriptExpression::_get_token(Token &r_token) { r_token.type = TK_BASIC_TYPE; r_token.value = i; return OK; - break; } } diff --git a/platform/android/godot_android.cpp b/platform/android/godot_android.cpp index 5933b83d06..2dd2c0532a 100644 --- a/platform/android/godot_android.cpp +++ b/platform/android/godot_android.cpp @@ -833,7 +833,6 @@ void android_main(struct android_app *app) { if (engine.requested_quit) { engine_term_display(&engine); exit(0); - return; } // LOGI("end\n"); diff --git a/platform/haiku/os_haiku.h b/platform/haiku/os_haiku.h index 256c9eecf7..4440f2843d 100644 --- a/platform/haiku/os_haiku.h +++ b/platform/haiku/os_haiku.h @@ -96,8 +96,8 @@ public: virtual int get_screen_count() const; virtual int get_current_screen() const; virtual void set_current_screen(int p_screen); - virtual Point2 get_screen_position(int p_screen = 0) const; - virtual Size2 get_screen_size(int p_screen = 0) const; + virtual Point2 get_screen_position(int p_screen = -1) const; + virtual Size2 get_screen_size(int p_screen = -1) const; virtual void set_window_title(const String &p_title); virtual Size2 get_window_size() const; virtual void set_window_size(const Size2 p_size); diff --git a/platform/javascript/os_javascript.cpp b/platform/javascript/os_javascript.cpp index d339baf024..f49acb04de 100644 --- a/platform/javascript/os_javascript.cpp +++ b/platform/javascript/os_javascript.cpp @@ -687,8 +687,6 @@ OS::VideoMode OS_JavaScript::get_video_mode(int p_screen) const { Size2 OS_JavaScript::get_screen_size(int p_screen) const { - ERR_FAIL_COND_V(p_screen != 0, Size2()); - EmscriptenFullscreenChangeEvent ev; EMSCRIPTEN_RESULT result = emscripten_get_fullscreen_status(&ev); ERR_FAIL_COND_V(result != EMSCRIPTEN_RESULT_SUCCESS, Size2()); diff --git a/platform/javascript/os_javascript.h b/platform/javascript/os_javascript.h index 13c500b3dc..ff484204c7 100644 --- a/platform/javascript/os_javascript.h +++ b/platform/javascript/os_javascript.h @@ -124,7 +124,7 @@ public: virtual VideoMode get_video_mode(int p_screen = 0) const; virtual void get_fullscreen_mode_list(List<VideoMode> *p_list, int p_screen = 0) const; - virtual Size2 get_screen_size(int p_screen = 0) const; + virtual Size2 get_screen_size(int p_screen = -1) const; virtual void set_window_size(const Size2); virtual Size2 get_window_size() const; diff --git a/platform/osx/os_osx.h b/platform/osx/os_osx.h index 56e6802eeb..827114cd2b 100644 --- a/platform/osx/os_osx.h +++ b/platform/osx/os_osx.h @@ -187,9 +187,9 @@ public: virtual int get_screen_count() const; virtual int get_current_screen() const; virtual void set_current_screen(int p_screen); - virtual Point2 get_screen_position(int p_screen = 0) const; - virtual Size2 get_screen_size(int p_screen = 0) const; - virtual int get_screen_dpi(int p_screen = 0) const; + virtual Point2 get_screen_position(int p_screen = -1) const; + virtual Size2 get_screen_size(int p_screen = -1) const; + virtual int get_screen_dpi(int p_screen = -1) const; virtual Point2 get_window_position() const; virtual void set_window_position(const Point2 &p_position); diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index 34f1a93f3b..a0fc53d517 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -1433,6 +1433,10 @@ void OS_OSX::set_current_screen(int p_screen) { }; Point2 OS_OSX::get_screen_position(int p_screen) const { + if (p_screen == -1) { + p_screen = get_current_screen(); + } + NSArray *screenArray = [NSScreen screens]; if (p_screen < [screenArray count]) { float displayScale = 1.0; @@ -1449,6 +1453,10 @@ Point2 OS_OSX::get_screen_position(int p_screen) const { } int OS_OSX::get_screen_dpi(int p_screen) const { + if (p_screen == -1) { + p_screen = get_current_screen(); + } + NSArray *screenArray = [NSScreen screens]; if (p_screen < [screenArray count]) { float displayScale = 1.0; @@ -1469,6 +1477,10 @@ int OS_OSX::get_screen_dpi(int p_screen) const { } Size2 OS_OSX::get_screen_size(int p_screen) const { + if (p_screen == -1) { + p_screen = get_current_screen(); + } + NSArray *screenArray = [NSScreen screens]; if (p_screen < [screenArray count]) { float displayScale = 1.0; diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 2e908b82ab..db453a5f46 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -1384,7 +1384,7 @@ static BOOL CALLBACK _MonitorEnumProcPos(HMONITOR hMonitor, HDC hdcMonitor, LPRE Point2 OS_Windows::get_screen_position(int p_screen) const { - EnumPosData data = { 0, p_screen, Point2() }; + EnumPosData data = { 0, p_screen == -1 ? get_current_screen() : p_screen, Point2() }; EnumDisplayMonitors(NULL, NULL, _MonitorEnumProcPos, (LPARAM)&data); return data.pos; } @@ -1409,7 +1409,7 @@ static BOOL CALLBACK _MonitorEnumProcSize(HMONITOR hMonitor, HDC hdcMonitor, LPR Size2 OS_Windows::get_screen_size(int p_screen) const { - EnumSizeData data = { 0, p_screen, Size2() }; + EnumSizeData data = { 0, p_screen == -1 ? get_current_screen() : p_screen, Size2() }; EnumDisplayMonitors(NULL, NULL, _MonitorEnumProcSize, (LPARAM)&data); return data.size; } @@ -1433,7 +1433,7 @@ static BOOL CALLBACK _MonitorEnumProcDpi(HMONITOR hMonitor, HDC hdcMonitor, LPRE int OS_Windows::get_screen_dpi(int p_screen) const { - EnumDpiData data = { 0, p_screen, 72 }; + EnumDpiData data = { 0, p_screen == -1 ? get_current_screen() : p_screen, 72 }; EnumDisplayMonitors(NULL, NULL, _MonitorEnumProcDpi, (LPARAM)&data); return data.dpi; } diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h index e9af14f11c..deb1ae0982 100644 --- a/platform/windows/os_windows.h +++ b/platform/windows/os_windows.h @@ -194,9 +194,9 @@ public: virtual int get_screen_count() const; virtual int get_current_screen() const; virtual void set_current_screen(int p_screen); - virtual Point2 get_screen_position(int p_screen = 0) const; - virtual Size2 get_screen_size(int p_screen = 0) const; - virtual int get_screen_dpi(int p_screen = 0) const; + virtual Point2 get_screen_position(int p_screen = -1) const; + virtual Size2 get_screen_size(int p_screen = -1) const; + virtual int get_screen_dpi(int p_screen = -1) const; virtual Point2 get_window_position() const; virtual void set_window_position(const Point2 &p_position); diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index 8b4253c72c..dbc3914410 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -761,6 +761,10 @@ void OS_X11::set_current_screen(int p_screen) { } Point2 OS_X11::get_screen_position(int p_screen) const { + if (p_screen == -1) { + p_screen = get_current_screen(); + } + // Using Xinerama Extension int event_base, error_base; const Bool ext_okay = XineramaQueryExtension(x11_display, &event_base, &error_base); @@ -782,6 +786,10 @@ Point2 OS_X11::get_screen_position(int p_screen) const { } Size2 OS_X11::get_screen_size(int p_screen) const { + if (p_screen == -1) { + p_screen = get_current_screen(); + } + // Using Xinerama Extension int event_base, error_base; const Bool ext_okay = XineramaQueryExtension(x11_display, &event_base, &error_base); @@ -797,6 +805,9 @@ Size2 OS_X11::get_screen_size(int p_screen) const { } int OS_X11::get_screen_dpi(int p_screen) const { + if (p_screen == -1) { + p_screen = get_current_screen(); + } //invalid screen? ERR_FAIL_INDEX_V(p_screen, get_screen_count(), 0); diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h index db70f8f84a..497ce1dde2 100644 --- a/platform/x11/os_x11.h +++ b/platform/x11/os_x11.h @@ -233,9 +233,9 @@ public: virtual int get_screen_count() const; virtual int get_current_screen() const; virtual void set_current_screen(int p_screen); - virtual Point2 get_screen_position(int p_screen = 0) const; - virtual Size2 get_screen_size(int p_screen = 0) const; - virtual int get_screen_dpi(int p_screen = 0) const; + virtual Point2 get_screen_position(int p_screen = -1) const; + virtual Size2 get_screen_size(int p_screen = -1) const; + virtual int get_screen_dpi(int p_screen = -1) const; virtual Point2 get_window_position() const; virtual void set_window_position(const Point2 &p_position); virtual Size2 get_window_size() const; diff --git a/scene/2d/parallax_layer.cpp b/scene/2d/parallax_layer.cpp index a5a59252a9..debdc22b65 100644 --- a/scene/2d/parallax_layer.cpp +++ b/scene/2d/parallax_layer.cpp @@ -36,6 +36,9 @@ void ParallaxLayer::set_motion_scale(const Size2 &p_scale) { motion_scale = p_scale; + if (!get_parent()) + return; + ParallaxBackground *pb = get_parent()->cast_to<ParallaxBackground>(); if (is_inside_tree() && pb) { Vector2 ofs = pb->get_final_offset(); @@ -53,6 +56,9 @@ void ParallaxLayer::set_motion_offset(const Size2 &p_offset) { motion_offset = p_offset; + if (!get_parent()) + return; + ParallaxBackground *pb = get_parent()->cast_to<ParallaxBackground>(); if (is_inside_tree() && pb) { Vector2 ofs = pb->get_final_offset(); diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index 6a3ef66e0a..36fc9a6b3a 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -1839,8 +1839,6 @@ Control *Control::find_prev_valid_focus() const { } return NULL; - - return NULL; } Control::FocusMode Control::get_focus_mode() const { diff --git a/scene/gui/scroll_bar.cpp b/scene/gui/scroll_bar.cpp index 6519cde6d3..4242ee4523 100644 --- a/scene/gui/scroll_bar.cpp +++ b/scene/gui/scroll_bar.cpp @@ -40,6 +40,11 @@ void ScrollBar::set_can_focus_by_default(bool p_can_focus) { void ScrollBar::_gui_input(Ref<InputEvent> p_event) { + Ref<InputEventMouseMotion> m = p_event; + if (!m.is_valid() || drag.active) { + emit_signal("scrolling"); + } + Ref<InputEventMouseButton> b = p_event; if (b.is_valid()) { @@ -143,8 +148,6 @@ void ScrollBar::_gui_input(Ref<InputEvent> p_event) { } } - Ref<InputEventMouseMotion> m = p_event; - if (m.is_valid()) { accept_event(); @@ -823,6 +826,8 @@ void ScrollBar::_bind_methods() { ClassDB::bind_method(D_METHOD("_drag_slave_input"), &ScrollBar::_drag_slave_input); ClassDB::bind_method(D_METHOD("_drag_slave_exit"), &ScrollBar::_drag_slave_exit); + ADD_SIGNAL(MethodInfo("scrolling")); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "custom_step", PROPERTY_HINT_RANGE, "-1,4096"), "set_custom_step", "get_custom_step"); } diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index f15fb71f87..245e7e04be 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -2880,6 +2880,8 @@ void TextEdit::_post_shift_selection() { } void TextEdit::_scroll_lines_up() { + scrolling = false; + // adjust the vertical scroll if (get_v_scroll() > 0) { set_v_scroll(get_v_scroll() - 1); @@ -2892,6 +2894,8 @@ void TextEdit::_scroll_lines_up() { } void TextEdit::_scroll_lines_down() { + scrolling = false; + // calculate the maximum vertical scroll position int max_v_scroll = get_line_count() - 1; if (!scroll_past_end_of_file_enabled) { @@ -3156,6 +3160,7 @@ int TextEdit::get_visible_rows() const { return total; } void TextEdit::adjust_viewport_to_cursor() { + scrolling = false; if (cursor.line_ofs > cursor.line) cursor.line_ofs = cursor.line; @@ -3195,6 +3200,7 @@ void TextEdit::adjust_viewport_to_cursor() { } void TextEdit::center_viewport_to_cursor() { + scrolling = false; if (cursor.line_ofs > cursor.line) cursor.line_ofs = cursor.line; @@ -3313,6 +3319,10 @@ bool TextEdit::cursor_is_block_mode() const { return block_caret; } +void TextEdit::_v_scroll_input() { + scrolling = false; +} + void TextEdit::_scroll_moved(double p_to_val) { if (updating_scrolls) @@ -3656,9 +3666,6 @@ void TextEdit::cut() { void TextEdit::copy() { - if (!selection.active) - return; - if (!selection.active) { String clipboard = _base_get_text(cursor.line, 0, cursor.line, text[cursor.line].length()); OS::get_singleton()->set_clipboard(clipboard); @@ -4709,6 +4716,7 @@ void TextEdit::_bind_methods() { ClassDB::bind_method(D_METHOD("_push_current_op"), &TextEdit::_push_current_op); ClassDB::bind_method(D_METHOD("_click_selection_held"), &TextEdit::_click_selection_held); ClassDB::bind_method(D_METHOD("_toggle_draw_caret"), &TextEdit::_toggle_draw_caret); + ClassDB::bind_method(D_METHOD("_v_scroll_input"), &TextEdit::_v_scroll_input); BIND_ENUM_CONSTANT(SEARCH_MATCH_CASE); BIND_ENUM_CONSTANT(SEARCH_WHOLE_WORDS); @@ -4846,6 +4854,8 @@ TextEdit::TextEdit() { h_scroll->connect("value_changed", this, "_scroll_moved"); v_scroll->connect("value_changed", this, "_scroll_moved"); + v_scroll->connect("scrolling", this, "_v_scroll_input"); + cursor_changed_dirty = false; text_changed_dirty = false; diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h index 1abfe368dd..6321cad2da 100644 --- a/scene/gui/text_edit.h +++ b/scene/gui/text_edit.h @@ -299,6 +299,7 @@ class TextEdit : public Control { void adjust_viewport_to_cursor(); void _scroll_moved(double); void _update_scrollbars(); + void _v_scroll_input(); void _click_selection_held(); void _pre_shift_selection(); diff --git a/scene/gui/texture_progress.cpp b/scene/gui/texture_progress.cpp index 08025452d8..59cff84719 100644 --- a/scene/gui/texture_progress.cpp +++ b/scene/gui/texture_progress.cpp @@ -57,9 +57,33 @@ Ref<Texture> TextureProgress::get_over_texture() const { return over; } +void TextureProgress::set_stretch_margin(Margin p_margin, int p_size) { + ERR_FAIL_INDEX(p_margin, 4); + stretch_margin[p_margin] = p_size; + update(); + minimum_size_changed(); +} + +int TextureProgress::get_stretch_margin(Margin p_margin) const { + ERR_FAIL_INDEX_V(p_margin, 4, 0); + return stretch_margin[p_margin]; +} + +void TextureProgress::set_nine_patch_stretch(bool p_stretch) { + nine_patch_stretch = p_stretch; + update(); + minimum_size_changed(); +} + +bool TextureProgress::get_nine_patch_stretch() const { + return nine_patch_stretch; +} + Size2 TextureProgress::get_minimum_size() const { - if (under.is_valid()) + if (nine_patch_stretch) + return Size2(stretch_margin[MARGIN_LEFT] + stretch_margin[MARGIN_RIGHT], stretch_margin[MARGIN_TOP] + stretch_margin[MARGIN_BOTTOM]); + else if (under.is_valid()) return under->get_size(); else if (over.is_valid()) return over->get_size(); @@ -122,80 +146,165 @@ Point2 TextureProgress::get_relative_center() { return p; } +void TextureProgress::draw_nine_patch_stretched(const Ref<Texture> &p_texture, FillMode p_mode, double p_ratio) { + Vector2 texture_size = p_texture->get_size(); + Vector2 topleft = Vector2(stretch_margin[MARGIN_LEFT], stretch_margin[MARGIN_TOP]); + Vector2 bottomright = Vector2(stretch_margin[MARGIN_RIGHT], stretch_margin[MARGIN_BOTTOM]); + + Rect2 src_rect = Rect2(Point2(), texture_size); + Rect2 dst_rect = Rect2(Point2(), get_size()); + + if (p_ratio < 1.0) { + // Drawing a partially-filled 9-patch is a little tricky - + // texture is divided by 3 sections toward fill direction, + // then middle section is streching while the other two aren't. + + double width_total = 0.0; + double width_texture = 0.0; + double first_section_size = 0.0; + double last_section_size = 0.0; + switch (mode) { + case FILL_LEFT_TO_RIGHT: + case FILL_RIGHT_TO_LEFT: { + width_total = dst_rect.size.x; + width_texture = texture_size.x; + first_section_size = topleft.x; + last_section_size = bottomright.x; + } break; + case FILL_TOP_TO_BOTTOM: + case FILL_BOTTOM_TO_TOP: { + width_total = dst_rect.size.y; + width_texture = texture_size.y; + first_section_size = topleft.y; + last_section_size = bottomright.y; + } break; + } + + double width_filled = width_total * p_ratio; + double middle_section_size = MAX(0.0, width_texture - first_section_size - last_section_size); + + middle_section_size *= MIN(1.0, (MAX(0.0, width_filled - first_section_size) / MAX(1.0, width_total - first_section_size - last_section_size))); + last_section_size = MAX(0.0, last_section_size - (width_total - width_filled)); + width_texture = MIN(width_texture, first_section_size + middle_section_size + last_section_size); + + switch (mode) { + case FILL_LEFT_TO_RIGHT: { + src_rect.size.x = width_texture; + dst_rect.size.x = width_filled; + bottomright.x = last_section_size; + } break; + case FILL_RIGHT_TO_LEFT: { + src_rect.position.x += src_rect.size.x - width_texture; + src_rect.size.x = width_texture; + dst_rect.position.x += width_total - width_filled; + dst_rect.size.x = width_filled; + topleft.x = last_section_size; + } break; + case FILL_TOP_TO_BOTTOM: { + src_rect.size.y = width_texture; + dst_rect.size.y = width_filled; + bottomright.y = last_section_size; + } break; + case FILL_BOTTOM_TO_TOP: { + src_rect.position.y += src_rect.size.y - width_texture; + src_rect.size.y = width_texture; + dst_rect.position.y += width_total - width_filled; + dst_rect.size.y = width_filled; + topleft.y = last_section_size; + } break; + } + } + + RID ci = get_canvas_item(); + VS::get_singleton()->canvas_item_add_nine_patch(ci, dst_rect, src_rect, p_texture->get_rid(), topleft, bottomright); +} + void TextureProgress::_notification(int p_what) { const float corners[12] = { -0.125, -0.375, -0.625, -0.875, 0.125, 0.375, 0.625, 0.875, 1.125, 1.375, 1.625, 1.875 }; switch (p_what) { case NOTIFICATION_DRAW: { - if (under.is_valid()) - draw_texture(under, Point2()); - if (progress.is_valid()) { - Size2 s = progress->get_size(); - switch (mode) { - case FILL_LEFT_TO_RIGHT: { - Rect2 region = Rect2(Point2(), Size2(s.x * get_as_ratio(), s.y)); - draw_texture_rect_region(progress, region, region); - } break; - case FILL_RIGHT_TO_LEFT: { - Rect2 region = Rect2(Point2(s.x - s.x * get_as_ratio(), 0), Size2(s.x * get_as_ratio(), s.y)); - draw_texture_rect_region(progress, region, region); - } break; - case FILL_TOP_TO_BOTTOM: { - Rect2 region = Rect2(Point2(), Size2(s.x, s.y * get_as_ratio())); - draw_texture_rect_region(progress, region, region); - } break; - case FILL_BOTTOM_TO_TOP: { - Rect2 region = Rect2(Point2(0, s.y - s.y * get_as_ratio()), Size2(s.x, s.y * get_as_ratio())); - draw_texture_rect_region(progress, region, region); - } break; - case FILL_CLOCKWISE: - case FILL_COUNTER_CLOCKWISE: { - float val = get_as_ratio() * rad_max_degrees / 360; - if (val == 1) { - Rect2 region = Rect2(Point2(), s); + if (nine_patch_stretch && (mode == FILL_LEFT_TO_RIGHT || mode == FILL_RIGHT_TO_LEFT || mode == FILL_TOP_TO_BOTTOM || mode == FILL_BOTTOM_TO_TOP)) { + if (under.is_valid()) { + draw_nine_patch_stretched(under, FILL_LEFT_TO_RIGHT, 1.0); + } + if (progress.is_valid()) { + draw_nine_patch_stretched(progress, mode, get_as_ratio()); + } + if (over.is_valid()) { + draw_nine_patch_stretched(over, FILL_LEFT_TO_RIGHT, 1.0); + } + } else { + if (under.is_valid()) + draw_texture(under, Point2()); + if (progress.is_valid()) { + Size2 s = progress->get_size(); + switch (mode) { + case FILL_LEFT_TO_RIGHT: { + Rect2 region = Rect2(Point2(), Size2(s.x * get_as_ratio(), s.y)); + draw_texture_rect_region(progress, region, region); + } break; + case FILL_RIGHT_TO_LEFT: { + Rect2 region = Rect2(Point2(s.x - s.x * get_as_ratio(), 0), Size2(s.x * get_as_ratio(), s.y)); draw_texture_rect_region(progress, region, region); - } else if (val != 0) { - Array pts; - float direction = mode == FILL_CLOCKWISE ? 1 : -1; - float start = rad_init_angle / 360; - float end = start + direction * val; - pts.append(start); - pts.append(end); - float from = MIN(start, end); - float to = MAX(start, end); - for (int i = 0; i < 12; i++) - if (corners[i] > from && corners[i] < to) - pts.append(corners[i]); - pts.sort(); - Vector<Point2> uvs; - Vector<Point2> points; - uvs.push_back(get_relative_center()); - points.push_back(Point2(s.x * get_relative_center().x, s.y * get_relative_center().y)); - for (int i = 0; i < pts.size(); i++) { - Point2 uv = unit_val_to_uv(pts[i]); - if (uvs.find(uv) >= 0) - continue; - uvs.push_back(uv); - points.push_back(Point2(uv.x * s.x, uv.y * s.y)); + } break; + case FILL_TOP_TO_BOTTOM: { + Rect2 region = Rect2(Point2(), Size2(s.x, s.y * get_as_ratio())); + draw_texture_rect_region(progress, region, region); + } break; + case FILL_BOTTOM_TO_TOP: { + Rect2 region = Rect2(Point2(0, s.y - s.y * get_as_ratio()), Size2(s.x, s.y * get_as_ratio())); + draw_texture_rect_region(progress, region, region); + } break; + case FILL_CLOCKWISE: + case FILL_COUNTER_CLOCKWISE: { + float val = get_as_ratio() * rad_max_degrees / 360; + if (val == 1) { + Rect2 region = Rect2(Point2(), s); + draw_texture_rect_region(progress, region, region); + } else if (val != 0) { + Array pts; + float direction = mode == FILL_CLOCKWISE ? 1 : -1; + float start = rad_init_angle / 360; + float end = start + direction * val; + pts.append(start); + pts.append(end); + float from = MIN(start, end); + float to = MAX(start, end); + for (int i = 0; i < 12; i++) + if (corners[i] > from && corners[i] < to) + pts.append(corners[i]); + pts.sort(); + Vector<Point2> uvs; + Vector<Point2> points; + uvs.push_back(get_relative_center()); + points.push_back(Point2(s.x * get_relative_center().x, s.y * get_relative_center().y)); + for (int i = 0; i < pts.size(); i++) { + Point2 uv = unit_val_to_uv(pts[i]); + if (uvs.find(uv) >= 0) + continue; + uvs.push_back(uv); + points.push_back(Point2(uv.x * s.x, uv.y * s.y)); + } + draw_polygon(points, Vector<Color>(), uvs, progress); + } + if (Engine::get_singleton()->is_editor_hint()) { + Point2 p = progress->get_size(); + p.x *= get_relative_center().x; + p.y *= get_relative_center().y; + p = p.floor(); + draw_line(p - Point2(8, 0), p + Point2(8, 0), Color(0.9, 0.5, 0.5), 2); + draw_line(p - Point2(0, 8), p + Point2(0, 8), Color(0.9, 0.5, 0.5), 2); } - draw_polygon(points, Vector<Color>(), uvs, progress); - } - if (Engine::get_singleton()->is_editor_hint()) { - Point2 p = progress->get_size(); - p.x *= get_relative_center().x; - p.y *= get_relative_center().y; - p = p.floor(); - draw_line(p - Point2(8, 0), p + Point2(8, 0), Color(0.9, 0.5, 0.5), 2); - draw_line(p - Point2(0, 8), p + Point2(0, 8), Color(0.9, 0.5, 0.5), 2); - } - } break; - default: - draw_texture_rect_region(progress, Rect2(Point2(), Size2(s.x * get_as_ratio(), s.y)), Rect2(Point2(), Size2(s.x * get_as_ratio(), s.y))); + } break; + default: + draw_texture_rect_region(progress, Rect2(Point2(), Size2(s.x * get_as_ratio(), s.y)), Rect2(Point2(), Size2(s.x * get_as_ratio(), s.y))); + } } + if (over.is_valid()) + draw_texture(over, Point2()); } - if (over.is_valid()) - draw_texture(over, Point2()); } break; } @@ -265,6 +374,12 @@ void TextureProgress::_bind_methods() { ClassDB::bind_method(D_METHOD("set_fill_degrees", "mode"), &TextureProgress::set_fill_degrees); ClassDB::bind_method(D_METHOD("get_fill_degrees"), &TextureProgress::get_fill_degrees); + ClassDB::bind_method(D_METHOD("set_stretch_margin", "margin", "value"), &TextureProgress::set_stretch_margin); + ClassDB::bind_method(D_METHOD("get_stretch_margin", "margin"), &TextureProgress::get_stretch_margin); + + ClassDB::bind_method(D_METHOD("set_nine_patch_stretch", "stretch"), &TextureProgress::set_nine_patch_stretch); + ClassDB::bind_method(D_METHOD("get_nine_patch_stretch"), &TextureProgress::get_nine_patch_stretch); + ADD_GROUP("Textures", "texture_"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture_under", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_under_texture", "get_under_texture"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture_over", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_over_texture", "get_over_texture"); @@ -274,6 +389,12 @@ void TextureProgress::_bind_methods() { ADD_PROPERTYNZ(PropertyInfo(Variant::REAL, "radial_initial_angle", PROPERTY_HINT_RANGE, "0.0,360.0,0.1,slider"), "set_radial_initial_angle", "get_radial_initial_angle"); ADD_PROPERTYNZ(PropertyInfo(Variant::REAL, "radial_fill_degrees", PROPERTY_HINT_RANGE, "0.0,360.0,0.1,slider"), "set_fill_degrees", "get_fill_degrees"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "radial_center_offset"), "set_radial_center_offset", "get_radial_center_offset"); + ADD_GROUP("Stretch", "stretch_"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "nine_patch_stretch"), "set_nine_patch_stretch", "get_nine_patch_stretch"); + ADD_PROPERTYINZ(PropertyInfo(Variant::INT, "stretch_margin_left", PROPERTY_HINT_RANGE, "0,16384,1"), "set_stretch_margin", "get_stretch_margin", MARGIN_LEFT); + ADD_PROPERTYINZ(PropertyInfo(Variant::INT, "stretch_margin_top", PROPERTY_HINT_RANGE, "0,16384,1"), "set_stretch_margin", "get_stretch_margin", MARGIN_TOP); + ADD_PROPERTYINZ(PropertyInfo(Variant::INT, "stretch_margin_right", PROPERTY_HINT_RANGE, "0,16384,1"), "set_stretch_margin", "get_stretch_margin", MARGIN_RIGHT); + ADD_PROPERTYINZ(PropertyInfo(Variant::INT, "stretch_margin_bottom", PROPERTY_HINT_RANGE, "0,16384,1"), "set_stretch_margin", "get_stretch_margin", MARGIN_BOTTOM); BIND_ENUM_CONSTANT(FILL_LEFT_TO_RIGHT); BIND_ENUM_CONSTANT(FILL_RIGHT_TO_LEFT); @@ -289,4 +410,10 @@ TextureProgress::TextureProgress() { rad_center_off = Point2(); rad_max_degrees = 360; set_mouse_filter(MOUSE_FILTER_PASS); + + nine_patch_stretch = false; + stretch_margin[MARGIN_LEFT] = 0; + stretch_margin[MARGIN_RIGHT] = 0; + stretch_margin[MARGIN_BOTTOM] = 0; + stretch_margin[MARGIN_TOP] = 0; } diff --git a/scene/gui/texture_progress.h b/scene/gui/texture_progress.h index 3c018febf3..20546bd11f 100644 --- a/scene/gui/texture_progress.h +++ b/scene/gui/texture_progress.h @@ -75,6 +75,12 @@ public: void set_over_texture(const Ref<Texture> &p_texture); Ref<Texture> get_over_texture() const; + void set_stretch_margin(Margin p_margin, int p_size); + int get_stretch_margin(Margin p_margin) const; + + void set_nine_patch_stretch(bool p_stretch); + bool get_nine_patch_stretch() const; + Size2 get_minimum_size() const; TextureProgress(); @@ -84,9 +90,12 @@ private: float rad_init_angle; float rad_max_degrees; Point2 rad_center_off; + bool nine_patch_stretch; + int stretch_margin[4]; Point2 unit_val_to_uv(float val); Point2 get_relative_center(); + void draw_nine_patch_stretched(const Ref<Texture> &p_texture, FillMode p_mode, double p_ratio); }; VARIANT_ENUM_CAST(TextureProgress::FillMode); diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp index 00460e9eda..10ab28150b 100644 --- a/scene/main/scene_tree.cpp +++ b/scene/main/scene_tree.cpp @@ -630,7 +630,7 @@ void SceneTree::_notification(int p_notification) { case NOTIFICATION_WM_ABOUT: { #ifdef TOOLS_ENABLED - if (Engine::get_singleton()->is_editor_hint()) { + if (EditorNode::get_singleton()) { EditorNode::get_singleton()->show_about(); } else { #endif diff --git a/scene/resources/style_box.cpp b/scene/resources/style_box.cpp index 9309cef89f..7b2a9ffbc2 100644 --- a/scene/resources/style_box.cpp +++ b/scene/resources/style_box.cpp @@ -191,6 +191,22 @@ void StyleBoxTexture::set_expand_margin_size(Margin p_expand_margin, float p_siz emit_changed(); } +void StyleBoxTexture::set_expand_margin_size_individual(float p_left, float p_top, float p_right, float p_bottom) { + expand_margin[MARGIN_LEFT] = p_left; + expand_margin[MARGIN_TOP] = p_top; + expand_margin[MARGIN_RIGHT] = p_right; + expand_margin[MARGIN_BOTTOM] = p_bottom; + emit_changed(); +} + +void StyleBoxTexture::set_expand_margin_size_all(float p_expand_margin_size) { + for (int i = 0; i < 4; i++) { + + expand_margin[i] = p_expand_margin_size; + } + emit_changed(); +} + float StyleBoxTexture::get_expand_margin_size(Margin p_expand_margin) const { ERR_FAIL_INDEX_V(p_expand_margin, 4, 0); @@ -257,6 +273,8 @@ void StyleBoxTexture::_bind_methods() { ClassDB::bind_method(D_METHOD("get_margin_size", "margin"), &StyleBoxTexture::get_margin_size); ClassDB::bind_method(D_METHOD("set_expand_margin_size", "margin", "size"), &StyleBoxTexture::set_expand_margin_size); + ClassDB::bind_method(D_METHOD("set_expand_margin_all", "size"), &StyleBoxTexture::set_expand_margin_size_all); + ClassDB::bind_method(D_METHOD("set_expand_margin_individual", "size_left", "size_top", "size_right", "size_bottom"), &StyleBoxTexture::set_expand_margin_size_individual); ClassDB::bind_method(D_METHOD("get_expand_margin_size", "margin"), &StyleBoxTexture::get_expand_margin_size); ClassDB::bind_method(D_METHOD("set_region_rect", "region"), &StyleBoxTexture::set_region_rect); @@ -421,7 +439,25 @@ void StyleBoxFlat::set_expand_margin_size(Margin p_expand_margin, float p_size) expand_margin[p_expand_margin] = p_size; emit_changed(); } + +void StyleBoxFlat::set_expand_margin_size_individual(float p_left, float p_top, float p_right, float p_bottom) { + expand_margin[MARGIN_LEFT] = p_left; + expand_margin[MARGIN_TOP] = p_top; + expand_margin[MARGIN_RIGHT] = p_right; + expand_margin[MARGIN_BOTTOM] = p_bottom; + emit_changed(); +} + +void StyleBoxFlat::set_expand_margin_size_all(float p_expand_margin_size) { + for (int i = 0; i < 4; i++) { + + expand_margin[i] = p_expand_margin_size; + } + emit_changed(); +} + float StyleBoxFlat::get_expand_margin_size(Margin p_expand_margin) const { + return expand_margin[p_expand_margin]; } void StyleBoxFlat::set_filled(bool p_filled) { @@ -736,6 +772,8 @@ void StyleBoxFlat::_bind_methods() { ClassDB::bind_method(D_METHOD("get_corner_radius", "corner"), &StyleBoxFlat::get_corner_radius); ClassDB::bind_method(D_METHOD("set_expand_margin", "margin", "size"), &StyleBoxFlat::set_expand_margin_size); + ClassDB::bind_method(D_METHOD("set_expand_margin_all", "size"), &StyleBoxFlat::set_expand_margin_size_all); + ClassDB::bind_method(D_METHOD("set_expand_margin_individual", "size_left", "size_top", "size_right", "size_bottom"), &StyleBoxFlat::set_expand_margin_size_individual); ClassDB::bind_method(D_METHOD("get_expand_margin", "margin"), &StyleBoxFlat::get_expand_margin_size); ClassDB::bind_method(D_METHOD("set_filled", "filled"), &StyleBoxFlat::set_filled); diff --git a/scene/resources/style_box.h b/scene/resources/style_box.h index a750fae753..30eb9543e8 100644 --- a/scene/resources/style_box.h +++ b/scene/resources/style_box.h @@ -101,6 +101,8 @@ protected: public: void set_expand_margin_size(Margin p_expand_margin, float p_size); + void set_expand_margin_size_all(float p_expand_margin_size); + void set_expand_margin_size_individual(float p_left, float p_top, float p_right, float p_bottom); float get_expand_margin_size(Margin p_expand_margin) const; void set_margin_size(Margin p_margin, float p_size); @@ -196,6 +198,8 @@ public: //EXPANDS void set_expand_margin_size(Margin p_expand_margin, float p_size); + void set_expand_margin_size_all(float p_expand_margin_size); + void set_expand_margin_size_individual(float p_left, float p_top, float p_right, float p_bottom); float get_expand_margin_size(Margin p_expand_margin) const; //FILLED diff --git a/thirdparty/minizip/godot-zlib-1.2.4-minizip-unbreak-gentoo.patch b/thirdparty/minizip/godot-zlib-1.2.4-minizip-unbreak-gentoo.patch new file mode 100644 index 0000000000..9292e32ac6 --- /dev/null +++ b/thirdparty/minizip/godot-zlib-1.2.4-minizip-unbreak-gentoo.patch @@ -0,0 +1,27 @@ +diff --git a/thirdparty/minizip/ioapi.h b/thirdparty/minizip/ioapi.h +index f25ab6464..6043d34ce 100644 +--- a/thirdparty/minizip/ioapi.h ++++ b/thirdparty/minizip/ioapi.h +@@ -44,6 +44,22 @@ + #include <stdlib.h> + #include "zlib.h" + ++/* GODOT start */ ++/* Mighty Gentoo saves the day by breaking the API of their zlib.h, ++ * removing this definition of OF(args) for no practical reason ++ * worth breaking compatibility with all projects that embed minizip ++ * while trying not to diverge too much from upstream zlib. ++ * Cf. https://github.com/godotengine/godot/issues/10539 ++ * ++ * "By and large, this is good open source behaviour, and fits with ++ * the gentoo _don't fuck with upstream's releases_ philosophy" ++ * -- Gentoo philosopher ++ */ ++#ifndef OF /* function prototypes */ ++ #define OF(args) args ++#endif ++/* GODOT end */ ++ + #if defined(USE_FILE32API) + #define fopen64 fopen + #define ftello64 ftell diff --git a/thirdparty/minizip/ioapi.h b/thirdparty/minizip/ioapi.h index f25ab6464f..6043d34cea 100644 --- a/thirdparty/minizip/ioapi.h +++ b/thirdparty/minizip/ioapi.h @@ -44,6 +44,22 @@ #include <stdlib.h> #include "zlib.h" +/* GODOT start */ +/* Mighty Gentoo saves the day by breaking the API of their zlib.h, + * removing this definition of OF(args) for no practical reason + * worth breaking compatibility with all projects that embed minizip + * while trying not to diverge too much from upstream zlib. + * Cf. https://github.com/godotengine/godot/issues/10539 + * + * "By and large, this is good open source behaviour, and fits with + * the gentoo _don't fuck with upstream's releases_ philosophy" + * -- Gentoo philosopher + */ +#ifndef OF /* function prototypes */ + #define OF(args) args +#endif +/* GODOT end */ + #if defined(USE_FILE32API) #define fopen64 fopen #define ftello64 ftell |