diff options
25 files changed, 390 insertions, 235 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 7de1c7e6b9..9c655b9460 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -453,6 +453,11 @@ int _OS::get_power_percent_left() { return OS::get_singleton()->get_power_percent_left(); } +bool _OS::has_feature(const String &p_feature) const { + + return OS::get_singleton()->has_feature(p_feature); +} + /* enum Weekday { DAY_SUNDAY, @@ -1105,6 +1110,8 @@ void _OS::_bind_methods() { ClassDB::bind_method(D_METHOD("set_use_vsync", "enable"), &_OS::set_use_vsync); ClassDB::bind_method(D_METHOD("is_vsync_enabled"), &_OS::is_vsync_enabled); + ClassDB::bind_method(D_METHOD("has_feature", "tag_name"), &_OS::has_feature); + ClassDB::bind_method(D_METHOD("get_power_state"), &_OS::get_power_state); ClassDB::bind_method(D_METHOD("get_power_seconds_left"), &_OS::get_power_seconds_left); ClassDB::bind_method(D_METHOD("get_power_percent_left"), &_OS::get_power_percent_left); diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index 6f3606dcc3..d69cb86e48 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -317,6 +317,8 @@ public: int get_power_seconds_left(); int get_power_percent_left(); + bool has_feature(const String &p_feature) const; + static _OS *get_singleton() { return singleton; } _OS(); diff --git a/core/io/resource_import.cpp b/core/io/resource_import.cpp index bc7ea47762..401d704222 100644 --- a/core/io/resource_import.cpp +++ b/core/io/resource_import.cpp @@ -77,7 +77,7 @@ Error ResourceFormatImporter::_get_path_and_type(const String &p_path, PathAndTy if (assign != String()) { if (!path_found && assign.begins_with("path.") && r_path_and_type.path == String()) { String feature = assign.get_slicec('.', 1); - if (OS::get_singleton()->check_feature_support(feature)) { + if (OS::get_singleton()->has_feature(feature)) { r_path_and_type.path = value; path_found = true; //first match must have priority } diff --git a/core/os/os.cpp b/core/os/os.cpp index ff17cdb508..f2295823b2 100644 --- a/core/os/os.cpp +++ b/core/os/os.cpp @@ -494,7 +494,7 @@ int OS::get_power_percent_left() { return -1; } -bool OS::check_feature_support(const String &p_feature) { +bool OS::has_feature(const String &p_feature) { if (p_feature == get_name()) return true; @@ -506,6 +506,13 @@ bool OS::check_feature_support(const String &p_feature) { return true; #endif + if (sizeof(void *) == 8 && p_feature == "64") { + return true; + } + if (sizeof(void *) == 4 && p_feature == "32") { + return true; + } + if (_check_internal_feature_support(p_feature)) return true; diff --git a/core/os/os.h b/core/os/os.h index 5de07be005..e819666a73 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -427,7 +427,7 @@ public: virtual int get_power_seconds_left(); virtual int get_power_percent_left(); - bool check_feature_support(const String &p_feature); + bool has_feature(const String &p_feature); /** * Returns the stack bottom of the main thread of the application. diff --git a/core/project_settings.cpp b/core/project_settings.cpp index 14ebe87dc5..3e27597e74 100644 --- a/core/project_settings.cpp +++ b/core/project_settings.cpp @@ -152,7 +152,7 @@ bool ProjectSettings::_set(const StringName &p_name, const Variant &p_value) { bool override_valid = false; for (int i = 1; i < s.size(); i++) { String feature = s[i].strip_edges(); - if (OS::get_singleton()->check_feature_support(feature) || custom_features.has(feature)) { + if (OS::get_singleton()->has_feature(feature) || custom_features.has(feature)) { override_valid = true; break; } diff --git a/doc/classes/OS.xml b/doc/classes/OS.xml index 468ccfb8f4..d411d07979 100644 --- a/doc/classes/OS.xml +++ b/doc/classes/OS.xml @@ -326,6 +326,7 @@ <return type="int"> </return> <description> + Returns the amount of static memory being used by the program in bytes. </description> </method> <method name="get_system_dir" qualifiers="const"> @@ -340,6 +341,7 @@ <return type="int"> </return> <description> + Returns the epoch time of the operating system in seconds. </description> </method> <method name="get_ticks_msec" qualifiers="const"> @@ -435,6 +437,9 @@ <return type="bool"> </return> <description> + Returns [code]true[/code] if the build is a debug build. + Returns [code]true[/code] when running in the editor. + Returns [code]false[/code] if the build is a release build. </description> </method> <method name="is_in_low_processor_usage_mode" qualifiers="const"> @@ -483,6 +488,7 @@ <return type="bool"> </return> <description> + Returns [code]true[/code] if synchronizing the framerate to the monitor's refresh rate is enabled. </description> </method> <method name="is_window_fullscreen" qualifiers="const"> @@ -695,6 +701,7 @@ <argument index="0" name="enable" type="bool"> </argument> <description> + If [code]true[/code] the framerate will synchronize to the monitor's refresh rate. </description> </method> <method name="set_window_fullscreen"> diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp index ae41a936c6..44a9909bd7 100644 --- a/drivers/gles3/rasterizer_storage_gles3.cpp +++ b/drivers/gles3/rasterizer_storage_gles3.cpp @@ -2473,7 +2473,7 @@ void RasterizerStorageGLES3::_update_material(Material *material) { glGenBuffers(1, &material->ubo_id); glBindBuffer(GL_UNIFORM_BUFFER, material->ubo_id); - glBufferData(GL_UNIFORM_BUFFER, material->shader->ubo_size, NULL, GL_DYNAMIC_DRAW); + glBufferData(GL_UNIFORM_BUFFER, material->shader->ubo_size, NULL, GL_STATIC_DRAW); glBindBuffer(GL_UNIFORM_BUFFER, 0); material->ubo_size = material->shader->ubo_size; } @@ -3768,7 +3768,7 @@ void RasterizerStorageGLES3::multimesh_allocate(RID p_multimesh, int p_instances glGenBuffers(1, &multimesh->buffer); glBindBuffer(GL_ARRAY_BUFFER, multimesh->buffer); - glBufferData(GL_ARRAY_BUFFER, multimesh->data.size() * sizeof(float), NULL, GL_DYNAMIC_DRAW); + glBufferData(GL_ARRAY_BUFFER, multimesh->data.size() * sizeof(float), NULL, GL_STATIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, 0); } @@ -5215,7 +5215,7 @@ void RasterizerStorageGLES3::particles_set_amount(RID p_particles, int p_amount) glBindVertexArray(particles->particle_vaos[i]); glBindBuffer(GL_ARRAY_BUFFER, particles->particle_buffers[i]); - glBufferData(GL_ARRAY_BUFFER, floats * sizeof(float), data, GL_DYNAMIC_DRAW); + glBufferData(GL_ARRAY_BUFFER, floats * sizeof(float), data, GL_STATIC_DRAW); for (int i = 0; i < 6; i++) { glEnableVertexAttribArray(i); @@ -6198,7 +6198,7 @@ void RasterizerStorageGLES3::_render_target_allocate(RenderTarget *rt) { rt->buffers.effects_active = true; } - if (!rt->flags[RENDER_TARGET_NO_SAMPLING]) { + if (!rt->flags[RENDER_TARGET_NO_SAMPLING] && rt->width >= 2 && rt->height >= 2) { for (int i = 0; i < 2; i++) { @@ -6511,7 +6511,7 @@ void RasterizerStorageGLES3::canvas_light_occluder_set_polylines(RID p_occluder, if (!co->vertex_id) { glGenBuffers(1, &co->vertex_id); glBindBuffer(GL_ARRAY_BUFFER, co->vertex_id); - glBufferData(GL_ARRAY_BUFFER, lc * 6 * sizeof(real_t), vw.ptr(), GL_DYNAMIC_DRAW); + glBufferData(GL_ARRAY_BUFFER, lc * 6 * sizeof(real_t), vw.ptr(), GL_STATIC_DRAW); } else { glBindBuffer(GL_ARRAY_BUFFER, co->vertex_id); diff --git a/drivers/gles3/shaders/scene.glsl b/drivers/gles3/shaders/scene.glsl index dee5994124..341a5bf2c7 100644 --- a/drivers/gles3/shaders/scene.glsl +++ b/drivers/gles3/shaders/scene.glsl @@ -164,7 +164,7 @@ uniform int spot_light_count; out vec4 diffuse_light_interp; out vec4 specular_light_interp; -void light_compute(vec3 N, vec3 L,vec3 V, vec3 light_color,float roughness,inout vec3 diffuse, inout vec3 specular) { +void light_compute(vec3 N, vec3 L,vec3 V, vec3 light_color, float roughness, inout vec3 diffuse, inout vec3 specular) { float dotNL = max(dot(N,L), 0.0 ); diffuse += dotNL * light_color / M_PI; @@ -888,9 +888,13 @@ float GTR1(float NdotH, float a) return (a2-1.0) / (M_PI*log(a2)*t); } +vec3 metallic_to_specular_color(float metallic, float specular, vec3 albedo) { + float dielectric = (0.034 * 2.0) * specular; + // energy conservation + return mix(vec3(dielectric), albedo, metallic); // TODO: reference? +} - -void light_compute(vec3 N, vec3 L,vec3 V,vec3 B, vec3 T,vec3 light_color,vec3 attenuation,vec3 diffuse_color, vec3 transmission, float specular_blob_intensity, float roughness, float rim,float rim_tint, float clearcoat, float clearcoat_gloss,float anisotropy,inout vec3 diffuse, inout vec3 specular) { +void light_compute(vec3 N, vec3 L, vec3 V, vec3 B, vec3 T, vec3 light_color, vec3 attenuation, vec3 diffuse_color, vec3 transmission, float specular_blob_intensity, float roughness, float rim, float rim_tint, float clearcoat, float clearcoat_gloss, float anisotropy, inout vec3 diffuse_light, inout vec3 specular_light) { #if defined(USE_LIGHT_SHADER_CODE) //light is written by the light shader @@ -904,41 +908,42 @@ LIGHT_SHADER_CODE #else - - float dotNL = max(dot(N,L), 0.0 ); + float NdotL = dot(N,L); + float cNdotL = max(NdotL, 0.0); // clamped NdotL + float NdotV = dot(N, V); + float cNdotV = max(NdotV, 0.0); #if defined(DIFFUSE_OREN_NAYAR) - vec3 light_amount; + vec3 diffuse_brdf_NL; #else - float light_amount; + float diffuse_brdf_NL; // BRDF times N.L for calculating diffuse radiance #endif #if defined(DIFFUSE_LAMBERT_WRAP) //energy conserving lambert wrap shader - light_amount = max(0.0,(dot(N,L) + roughness) / ((1.0 + roughness) * (1.0 + roughness))); + diffuse_brdf_NL = max(0.0,(NdotL + roughness) / ((1.0 + roughness) * (1.0 + roughness))); #elif defined(DIFFUSE_OREN_NAYAR) { // see http://mimosa-pudica.net/improved-oren-nayar.html float LdotV = dot(L, V); - float NdotL = dot(L, N); - float NdotV = dot(N, V); + float s = LdotV - NdotL * NdotV; float t = mix(1.0, max(NdotL, NdotV), step(0.0, s)); - float sigma2 = roughness * roughness; + float sigma2 = roughness * roughness; // TODO: this needs checking vec3 A = 1.0 + sigma2 * (- 0.5 / (sigma2 + 0.33) + 0.17*diffuse_color / (sigma2 + 0.13) ); float B = 0.45 * sigma2 / (sigma2 + 0.09); - light_amount = dotNL * (A + vec3(B) * s / t) / M_PI; + diffuse_brdf_NL = cNdotL * (A + vec3(B) * s / t) * (1.0 / M_PI); } #elif defined(DIFFUSE_TOON) - light_amount = smoothstep(-roughness,max(roughness,0.01),dot(N,L)); + diffuse_brdf_NL = smoothstep(-roughness,max(roughness,0.01),NdotL); #elif defined(DIFFUSE_BURLEY) @@ -946,40 +951,38 @@ LIGHT_SHADER_CODE vec3 H = normalize(V + L); - float NoL = max(0.0,dot(N, L)); - float LoH = max(0.0,dot(L, H)); - float NoV = max(0.0,dot(N, V)); - - float FD90 = 0.5 + 2.0 * LoH * LoH * roughness; - float FdV = 1.0 + (FD90 - 1.0) * SchlickFresnel(NoV); - float FdL = 1.0 + (FD90 - 1.0) * SchlickFresnel(NoL); - light_amount = ( (1.0 / M_PI) * FdV * FdL ) * NoL; + float cLdotH = max(0.0,dot(L, H)); + + float FD90 = 0.5 + 2.0 * cLdotH * cLdotH * roughness; + float FdV = 1.0 + (FD90 - 1.0) * SchlickFresnel(cNdotV); + float FdL = 1.0 + (FD90 - 1.0) * SchlickFresnel(cNdotL); + diffuse_brdf_NL = (1.0 / M_PI) * FdV * FdL * cNdotL; /* float energyBias = mix(roughness, 0.0, 0.5); float energyFactor = mix(roughness, 1.0, 1.0 / 1.51); float fd90 = energyBias + 2.0 * VoH * VoH * roughness; float f0 = 1.0; - float lightScatter = f0 + (fd90 - f0) * pow(1.0 - NoL, 5.0); - float viewScatter = f0 + (fd90 - f0) * pow(1.0 - NoV, 5.0); + float lightScatter = f0 + (fd90 - f0) * pow(1.0 - cNdotL, 5.0); + float viewScatter = f0 + (fd90 - f0) * pow(1.0 - cNdotV, 5.0); - light_amount = lightScatter * viewScatter * energyFactor;*/ + diffuse_brdf_NL = lightScatter * viewScatter * energyFactor;*/ } #else //lambert - light_amount = dotNL / M_PI; + diffuse_brdf_NL = cNdotL * (1.0 / M_PI); #endif #if defined(TRANSMISSION_USED) - diffuse += light_color * diffuse_color * mix(vec3(light_amount),vec3(M_PI),transmission) * attenuation; + diffuse_light += light_color * diffuse_color * mix(vec3(diffuse_brdf_NL), vec3(M_PI), transmission) * attenuation; #else - diffuse += light_color * diffuse_color * light_amount * attenuation; + diffuse_light += light_color * diffuse_color * diffuse_brdf_NL * attenuation; #endif - float dotNV = max(dot(N,V), 0.0 ); + #if defined(LIGHT_USE_RIM) - float rim_light = pow(1.0-dotNV,(1.0-roughness)*16.0); - diffuse += rim_light * rim * mix(vec3(1.0),diffuse_color,rim_tint) * light_color; + float rim_light = pow(1.0-cNdotV, (1.0-roughness)*16.0); + diffuse_light += rim_light * rim * mix(vec3(1.0),diffuse_color,rim_tint) * light_color; #endif @@ -991,25 +994,25 @@ LIGHT_SHADER_CODE #if defined(SPECULAR_BLINN) vec3 H = normalize(V + L); - float dotNH = max(dot(N,H), 0.0 ); - float intensity = pow( dotNH, (1.0-roughness) * 256.0); - specular += light_color * intensity * specular_blob_intensity * attenuation; + float cNdotH = max(dot(N,H), 0.0 ); + float intensity = pow( cNdotH, (1.0-roughness) * 256.0); + specular_light += light_color * intensity * specular_blob_intensity * attenuation; #elif defined(SPECULAR_PHONG) vec3 R = normalize(-reflect(L,N)); - float dotNV = max(0.0,dot(R,V)); - float intensity = pow( dotNV, (1.0-roughness) * 256.0); - specular += light_color * intensity * specular_blob_intensity * attenuation; + float cRdotV = max(0.0,dot(R,V)); + float intensity = pow( cRdotV, (1.0-roughness) * 256.0); + specular_light += light_color * intensity * specular_blob_intensity * attenuation; #elif defined(SPECULAR_TOON) vec3 R = normalize(-reflect(L,N)); - float dotNV = dot(R,V); + float RdotV = dot(R,V); float mid = 1.0-roughness; mid*=mid; - float intensity = smoothstep(mid-roughness*0.5,mid+roughness*0.5,dotNV) * mid; - diffuse += light_color * intensity * specular_blob_intensity * attenuation; //write to diffuse, as in toon shading you generally want no reflection + float intensity = smoothstep(mid-roughness*0.5, mid+roughness*0.5, RdotV) * mid; + diffuse_light += light_color * intensity * specular_blob_intensity * attenuation; // write to diffuse_light, as in toon shading you generally want no reflection #elif defined(SPECULAR_DISABLED) //none.. @@ -1020,8 +1023,8 @@ LIGHT_SHADER_CODE vec3 H = normalize(V + L); - float dotNH = max(dot(N,H), 0.0 ); - float dotLH = max(dot(L,H), 0.0 ); + float cNdotH = max(dot(N,H), 0.0); + float cLdotH = max(dot(L,H), 0.0); #if defined(LIGHT_USE_ANISOTROPY) @@ -1030,44 +1033,46 @@ LIGHT_SHADER_CODE float ry = roughness*aspect; float ax = rx*rx; float ay = ry*ry; - float dotXH = dot( T, H ); - float dotYH = dot( B, H ); - float pi = M_PI; - float denom = dotXH*dotXH / (ax*ax) + dotYH*dotYH / (ay*ay) + dotNH*dotNH; - float D = 1.0 / ( pi * ax*ay * denom*denom ); + float XdotH = dot( T, H ); + float YdotH = dot( B, H ); + float denom = XdotH*XdotH / (ax*ax) + YdotH*YdotH / (ay*ay) + cNdotH*cNdotH; + float D = 1.0 / ( M_PI * ax*ay * denom*denom ); #else float alphaSqr = alpha * alpha; - float pi = M_PI; - float denom = dotNH * dotNH * (alphaSqr - 1.0) + 1.0; - float D = alphaSqr / (pi * denom * denom); + float denom = cNdotH * cNdotH * (alphaSqr - 1.0) + 1.0; + float D = alphaSqr / (M_PI * denom * denom); #endif // F - float F0 = 1.0; - float dotLH5 = SchlickFresnel( dotLH ); - float F = F0 + (1.0 - F0) * (dotLH5); + float F0 = 1.0; // FIXME + float cLdotH5 = SchlickFresnel(cLdotH); + float F = mix(cLdotH5, 1.0, F0); // V float k = alpha / 2.0f; - float vis = G1V(dotNL, k) * G1V(dotNV, k); + float vis = G1V(cNdotL, k) * G1V(cNdotV, k); - float speci = dotNL * D * F * vis; + float speci = cNdotL * D * F * vis; - specular += speci * light_color * specular_blob_intensity * attenuation; + specular_light += speci * light_color * specular_blob_intensity * attenuation; #endif #if defined(LIGHT_USE_CLEARCOAT) -# if !defined(SPECULAR_SCHLICK_GGX) + +# if !defined(SPECULAR_SCHLICK_GGX) && !defined(SPECULAR_BLINN) vec3 H = normalize(V + L); - float dotLH5 = SchlickFresnel( dotLH ); - float dotNH = max(dot(N,H), 0.0 ); # endif +# if !defined(SPECULAR_SCHLICK_GGX) + float cNdotH = max(dot(N,H), 0.0); + float cLdotH = max(dot(L,H), 0.0); + float cLdotH5 = SchlickFresnel(cLdotH); +#endif + float Dr = GTR1(cNdotH, mix(.1, .001, clearcoat_gloss)); + float Fr = mix(.04, 1.0, cLdotH5); + float Gr = G1V(cNdotL, .25) * G1V(cNdotV, .25); - float Dr = GTR1(dotNH, mix(.1,.001,clearcoat_gloss)); - float Fr = mix(.04, 1.0, dotLH5); - float Gr = G1V(dotNL, .25) * G1V(dotNV, .25); - specular += .25*clearcoat*Gr*Fr*Dr; + specular_light += .25*clearcoat*Gr*Fr*Dr; #endif } @@ -1095,9 +1100,7 @@ float sample_shadow(highp sampler2DShadow shadow, vec2 shadow_pixel_size, vec2 p avg+=textureProj(shadow,vec4(pos+vec2(0.0,-shadow_pixel_size.y*2.0),depth,1.0)); return avg*(1.0/13.0); -#endif - -#ifdef SHADOW_MODE_PCF_5 +#elif defined(SHADOW_MODE_PCF_5) float avg=textureProj(shadow,vec4(pos,depth,1.0)); avg+=textureProj(shadow,vec4(pos+vec2(shadow_pixel_size.x,0.0),depth,1.0)); @@ -1105,11 +1108,11 @@ float sample_shadow(highp sampler2DShadow shadow, vec2 shadow_pixel_size, vec2 p avg+=textureProj(shadow,vec4(pos+vec2(0.0,shadow_pixel_size.y),depth,1.0)); avg+=textureProj(shadow,vec4(pos+vec2(0.0,-shadow_pixel_size.y),depth,1.0)); return avg*(1.0/5.0); -#endif -#if !defined(SHADOW_MODE_PCF_5) && !defined(SHADOW_MODE_PCF_13) +#else return textureProj(shadow,vec4(pos,depth,1.0)); + #endif } @@ -1151,7 +1154,7 @@ vec3 light_transmittance(float translucency,vec3 light_vec, vec3 normal, vec3 po } #endif -void light_process_omni(int idx, vec3 vertex, vec3 eye_vec,vec3 normal,vec3 binormal, vec3 tangent, vec3 albedo, vec3 transmission, float roughness, float rim, float rim_tint, float clearcoat, float clearcoat_gloss,float anisotropy,float p_blob_intensity,inout vec3 diffuse_light, inout vec3 specular_light) { +void light_process_omni(int idx, vec3 vertex, vec3 eye_vec,vec3 normal,vec3 binormal, vec3 tangent, vec3 albedo, vec3 transmission, float roughness, float rim, float rim_tint, float clearcoat, float clearcoat_gloss, float anisotropy, float p_blob_intensity, inout vec3 diffuse_light, inout vec3 specular_light) { vec3 light_rel_vec = omni_lights[idx].light_pos_inv_radius.xyz-vertex; float light_length = length( light_rel_vec ); @@ -1940,9 +1943,9 @@ FRAGMENT_SHADER_CODE - //energu conservation - diffuse_light=mix(diffuse_light,vec3(0.0),metallic); - ambient_light=mix(ambient_light,vec3(0.0),metallic); + //energy conservation + diffuse_light *= 1.0-metallic; // TODO: avoid diffuse and ambient light calculations when metallic == 1 + ambient_light *= 1.0-metallic; { @@ -1951,9 +1954,6 @@ FRAGMENT_SHADER_CODE //simplify for toon, as specular_light *= specular * metallic * albedo * 2.0; #else - //energy conservation - vec3 dielectric = vec3(0.034) * specular * 2.0; - vec3 specular_color = mix(dielectric, albedo, metallic); // Environment brdf approximation (Lazarov 2013) // see https://www.unrealengine.com/en-US/blog/physically-based-shading-on-mobile const vec4 c0 = vec4(-1.0, -0.0275, -0.572, 0.022); @@ -1963,6 +1963,7 @@ FRAGMENT_SHADER_CODE float a004 = min( r.x * r.x, exp2( -9.28 * ndotv ) ) * r.x + r.y; vec2 AB = vec2( -1.04, 1.04 ) * a004 + r.zw; + vec3 specular_color = metallic_to_specular_color(metallic, specular, albedo); specular_light *= AB.x * specular_color + AB.y; #endif diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp index db12998dd2..bc20a99809 100644 --- a/editor/editor_export.cpp +++ b/editor/editor_export.cpp @@ -1141,6 +1141,12 @@ void EditorExportPlatformPC::get_preset_features(const Ref<EditorExportPreset> & if (p_preset->get("texture_format/etc2")) { r_features->push_back("etc2"); } + + if (p_preset->get("binary_format/64_bits")) { + r_features->push_back("64"); + } else { + r_features->push_back("32"); + } } void EditorExportPlatformPC::get_export_options(List<ExportOption> *r_options) { diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index a2e6df4e41..0436ac78df 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -146,6 +146,25 @@ void editor_register_and_generate_icons(Ref<Theme> p_theme, bool p_dark_theme = ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#84c2ff", "#5caeff"); // selection (blue) ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#ea686c", "#e3383d"); // key xform (red) + + ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#69ecbd", "#25e3a0"); // VS variant + ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#8da6f0", "#6d8eeb"); // VS bool + ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#7dc6ef", "#4fb2e9"); // VS int + ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#61daf4", "#27ccf0"); // VS float + ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#6ba7ec", "#4690e7"); // VS string + ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#bd91f1", "#ad76ee"); // VS vector2 + ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#f191a5", "#ee758e"); // VS rect + ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#e286f0", "#dc6aed"); // VS vector3 + ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#c4ec69", "#96ce1a"); // VS transform2D + ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#f77070", "#f77070"); // VS plane + ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#ec69a3", "#ec69a3"); // VS quat + ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#ee7991", "#ee7991"); // VS aabb + ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#e3ec69", "#b2bb19"); // VS basis + ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#f6a86e", "#f49047"); // VS transform + ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#6993ec", "#6993ec"); // VS path + ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#69ec9a", "#2ce573"); // VS rid + ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#79f3e8", "#12d5c3"); // VS object + ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#77edb1", "#57e99f"); // VS dict } // these ones should be converted even if we are using a dark theme @@ -474,7 +493,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_stylebox("MenuPanel", "EditorStyles", style_menu); // Script Editor - theme->set_stylebox("ScriptEditorPanel", "EditorStyles", make_empty_stylebox(4, 0, 4, 4)); + theme->set_stylebox("ScriptEditorPanel", "EditorStyles", make_empty_stylebox(default_margin_size, 0, default_margin_size, default_margin_size)); theme->set_stylebox("ScriptEditor", "EditorStyles", make_empty_stylebox(0, 0, 0, 0)); // Play button group @@ -545,7 +564,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_color("font_color_disabled", "OptionButton", font_color_disabled); theme->set_color("icon_color_hover", "OptionButton", font_color_hl); theme->set_icon("arrow", "OptionButton", theme->get_icon("GuiOptionArrow", "EditorIcons")); - theme->set_constant("arrow_margin", "OptionButton", 4 * EDSCALE); + theme->set_constant("arrow_margin", "OptionButton", default_margin_size * EDSCALE); theme->set_constant("modulate_arrow", "OptionButton", true); // CheckButton @@ -597,6 +616,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_icon("unchecked", "Tree", theme->get_icon("GuiUnchecked", "EditorIcons")); theme->set_icon("arrow", "Tree", theme->get_icon("GuiTreeArrowDown", "EditorIcons")); theme->set_icon("arrow_collapsed", "Tree", theme->get_icon("GuiTreeArrowRight", "EditorIcons")); + theme->set_icon("updown", "Tree", theme->get_icon("GuiTreeUpdown", "EditorIcons")); theme->set_icon("select_arrow", "Tree", theme->get_icon("GuiDropdown", "EditorIcons")); theme->set_icon("select_option", "Tree", theme->get_icon("GuiTreeOption", "EditorIcons")); theme->set_stylebox("bg_focus", "Tree", style_focus); @@ -672,8 +692,8 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_color("font_color", "ItemList", font_color); theme->set_color("font_color_selected", "ItemList", mono_color); theme->set_color("guide_color", "ItemList", guide_color); - theme->set_constant("vseparation", "ItemList", 2); - theme->set_constant("hseparation", "ItemList", 2); + theme->set_constant("vseparation", "ItemList", 2 * EDSCALE); + theme->set_constant("hseparation", "ItemList", 2 * EDSCALE); theme->set_constant("icon_margin", "ItemList", default_margin_size * EDSCALE); theme->set_constant("line_separation", "ItemList", 2 * EDSCALE); @@ -880,21 +900,23 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { // GraphNode + const float mv = dark_theme ? 0.0 : 1.0; + const float mv2 = 1.0 - mv; const int gn_margin_side = 28; - Ref<StyleBoxFlat> graphsb = make_flat_stylebox(Color(0, 0, 0, 0.3), gn_margin_side, 24, gn_margin_side, 5); + Ref<StyleBoxFlat> graphsb = make_flat_stylebox(Color(mv, mv, mv, 0.7), gn_margin_side, 24, gn_margin_side, 5); graphsb->set_border_width_all(border_width); - graphsb->set_border_color_all(Color(1, 1, 1, 0.9)); - Ref<StyleBoxFlat> graphsbselected = make_flat_stylebox(Color(0, 0, 0, 0.6), gn_margin_side, 24, gn_margin_side, 5); + graphsb->set_border_color_all(Color(mv2, mv2, mv2, 0.9)); + Ref<StyleBoxFlat> graphsbselected = make_flat_stylebox(Color(mv, mv, mv, 0.9), gn_margin_side, 24, gn_margin_side, 5); graphsbselected->set_border_width_all(border_width); graphsbselected->set_border_color_all(Color(accent_color.r, accent_color.g, accent_color.b, 0.9)); graphsbselected->set_shadow_size(8 * EDSCALE); graphsbselected->set_shadow_color(shadow_color); - Ref<StyleBoxFlat> graphsbcomment = make_flat_stylebox(Color(0, 0, 0, 0.3), gn_margin_side, 24, gn_margin_side, 5); + Ref<StyleBoxFlat> graphsbcomment = make_flat_stylebox(Color(mv, mv, mv, 0.3), gn_margin_side, 24, gn_margin_side, 5); graphsbcomment->set_border_width_all(border_width); - graphsbcomment->set_border_color_all(Color(1, 1, 1, 0.9)); - Ref<StyleBoxFlat> graphsbcommentselected = make_flat_stylebox(Color(0, 0, 0, 0.4), gn_margin_side, 24, gn_margin_side, 5); + graphsbcomment->set_border_color_all(Color(mv2, mv2, mv2, 0.9)); + Ref<StyleBoxFlat> graphsbcommentselected = make_flat_stylebox(Color(mv, mv, mv, 0.4), gn_margin_side, 24, gn_margin_side, 5); graphsbcommentselected->set_border_width_all(border_width); - graphsbcommentselected->set_border_color_all(Color(1, 1, 1, 0.9)); + graphsbcommentselected->set_border_color_all(Color(mv2, mv2, mv2, 0.9)); Ref<StyleBoxFlat> graphsbbreakpoint = graphsbselected->duplicate(); graphsbbreakpoint->set_draw_center(false); graphsbbreakpoint->set_border_color_all(warning_color); diff --git a/editor/icons/icon_GUI_tree_updown.svg b/editor/icons/icon_GUI_tree_updown.svg new file mode 100644 index 0000000000..cdcd6c2441 --- /dev/null +++ b/editor/icons/icon_GUI_tree_updown.svg @@ -0,0 +1,5 @@ +<svg width="14" height="14" version="1.1" viewBox="0 0 14 14" xmlns="http://www.w3.org/2000/svg"> +<g transform="translate(0 -1038.4)"> +<path transform="translate(0 1038.4)" d="m6.9844 1.002a1.0001 1.0001 0 0 0 -0.69141 0.29102l-3 3a1 1 0 0 0 0 1.4141 1 1 0 0 0 1.4141 0l2.293-2.293 2.293 2.293a1 1 0 0 0 1.4141 0 1 1 0 0 0 0 -1.4141l-3-3a1.0001 1.0001 0 0 0 -0.72266 -0.29102zm3 6.998a1 1 0 0 0 -0.69141 0.29297l-2.293 2.293-2.293-2.293a1 1 0 0 0 -0.7207 -0.29102 1 1 0 0 0 -0.69336 0.29102 1 1 0 0 0 0 1.4141l3 3a1.0001 1.0001 0 0 0 1.4141 0l3-3a1 1 0 0 0 0 -1.4141 1 1 0 0 0 -0.72266 -0.29297z" color="#000000" color-rendering="auto" dominant-baseline="auto" fill="#fff" fill-opacity=".58824" image-rendering="auto" shape-rendering="auto" solid-color="#000000" style="filter-blend-mode:normal;filter-gaussianBlur-deviation:0;font-feature-settings:normal;font-variant-alternates:normal;font-variant-caps:normal;font-variant-east-asian:normal;font-variant-ligatures:normal;font-variant-numeric:normal;font-variant-position:normal;isolation:auto;mix-blend-mode:normal;shape-padding:0;text-decoration-color:#000000;text-decoration-line:none;text-decoration-style:solid;text-indent:0;text-orientation:mixed;text-transform:none;white-space:normal"/> +</g> +</svg> diff --git a/editor/icons/icon_mini_color.svg b/editor/icons/icon_mini_color.svg index b70015a05d..623f922158 100644 --- a/editor/icons/icon_mini_color.svg +++ b/editor/icons/icon_mini_color.svg @@ -1,7 +1,7 @@ <svg width="16" height="12" version="1.1" viewBox="0 0 16 12" xmlns="http://www.w3.org/2000/svg"> <g transform="translate(0 -1040.4)"> -<path transform="translate(0 1040.4)" d="m4 4a3 3 0 0 0 -3 3 3 3 0 0 0 3 3h1v-2h-1a1 1 0 0 1 -1 -1 1 1 0 0 1 1 -1h1v-2h-1z" fill="#ff7070"/> -<path transform="translate(0 1040.4)" d="m14 4a3 3 0 0 0 -3 3v3h2v-3a1 1 0 0 1 1 -1h1v-2h-1z" fill="#70bfff"/> -<path transform="translate(0 1040.4)" d="m6 2v5a3 3 0 0 0 3 3h1v-2h-1a1 1 0 0 1 -1 -1v-5h-2z" fill="#7aff70"/> +<path transform="translate(0 1040.4)" d="m4 4a3 3 0 0 0 -3 3 3 3 0 0 0 3 3h1v-2h-1a1 1 0 0 1 -1 -1 1 1 0 0 1 1 -1h1v-2h-1z" fill="#ff8484"/> +<path transform="translate(0 1040.4)" d="m14 4a3 3 0 0 0 -3 3v3h2v-3a1 1 0 0 1 1 -1h1v-2h-1z" fill="#84c2ff"/> +<path transform="translate(0 1040.4)" d="m6 2v5a3 3 0 0 0 3 3h1v-2h-1a1 1 0 0 1 -1 -1v-5h-2z" fill="#84ffb1"/> </g> </svg> diff --git a/editor/icons/icon_mini_image.svg b/editor/icons/icon_mini_image.svg deleted file mode 100644 index 735cb563cb..0000000000 --- a/editor/icons/icon_mini_image.svg +++ /dev/null @@ -1,5 +0,0 @@ -<svg width="16" height="12" version="1.1" viewBox="0 0 16 12" xmlns="http://www.w3.org/2000/svg"> -<g transform="translate(0 -1040.4)"> -<path transform="translate(0 1040.4)" d="m0 1v2h2v-2h-2zm3 2v6h2v-4a1 1 0 0 1 1 1v3h2v-3-1a1 1 0 0 1 1 1v3h2v-3a3 3 0 0 0 -3 -3h-2v0.17578a3 3 0 0 0 -1 -0.17578h-2zm8 3a3 3 0 0 0 3 3 1 1 0 0 1 -1 1h-1v2h1a3 3 0 0 0 3 -3v-6h-2a3 3 0 0 0 -3 3zm-11-1v4h2v-4h-2zm14 0v2a1 1 0 0 1 -1 -1 1 1 0 0 1 1 -1z" fill="#93f1b9"/> -</g> -</svg> diff --git a/editor/icons/icon_mini_input.svg b/editor/icons/icon_mini_input.svg deleted file mode 100644 index 92cf763cf8..0000000000 --- a/editor/icons/icon_mini_input.svg +++ /dev/null @@ -1,5 +0,0 @@ -<svg width="16" height="12" version="1.1" viewBox="0 0 16 12" xmlns="http://www.w3.org/2000/svg"> -<g transform="translate(0 -1040.4)"> -<path transform="translate(0 1040.4)" d="m0 2v2h2v-2h-2zm13 0v5a3 3 0 0 0 3 3v-2a1 1 0 0 1 -1 -1v-1h1v-2h-1v-2h-2zm0 5a3 3 0 0 0 -3 -3h-2v3a3 3 0 0 0 -3 -3h-2v6h2v-4a1 1 0 0 1 1 1v3h2v2h2v-2a3 3 0 0 0 3 -3zm-13-1v4h2v-4h-2zm10 0a1 1 0 0 1 1 1 1 1 0 0 1 -1 1v-2z" fill="#adf18f"/> -</g> -</svg> diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 9af5885a17..5e66488afb 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -1683,9 +1683,8 @@ bool ScriptEditor::edit(const Ref<Script> &p_script, int p_line, int p_col, bool } ERR_FAIL_COND_V(!se, false); - // load script before adding as child else editor will crash at theme loading - se->set_edited_script(p_script); tab_container->add_child(se); + se->set_edited_script(p_script); se->set_tooltip_request_func("_get_debug_tooltip", this); if (se->get_edit_menu()) { se->get_edit_menu()->hide(); diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index b66e9598f9..a24856dad7 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -168,14 +168,34 @@ void ScriptTextEditor::_load_theme_settings() { text_edit->add_constant_override("line_spacing", EDITOR_DEF("text_editor/theme/line_spacing", 4)); + colors_cache.symbol_color = symbol_color; + colors_cache.keyword_color = keyword_color; + colors_cache.basetype_color = basetype_color; + colors_cache.type_color = type_color; + colors_cache.comment_color = comment_color; + colors_cache.string_color = string_color; + + theme_loaded = true; + if (!script.is_null()) + _set_theme_for_script(); +} + +void ScriptTextEditor::_set_theme_for_script() { + + if (!theme_loaded) + return; + + TextEdit *text_edit = code_editor->get_text_edit(); + List<String> keywords; script->get_language()->get_reserved_words(&keywords); for (List<String>::Element *E = keywords.front(); E; E = E->next()) { - text_edit->add_keyword_color(E->get(), keyword_color); + text_edit->add_keyword_color(E->get(), colors_cache.keyword_color); } //colorize core types + const Color basetype_color = colors_cache.basetype_color; text_edit->add_keyword_color("String", basetype_color); text_edit->add_keyword_color("Vector2", basetype_color); text_edit->add_keyword_color("Rect2", basetype_color); @@ -210,7 +230,7 @@ void ScriptTextEditor::_load_theme_settings() { if (n.begins_with("_")) n = n.substr(1, n.length()); - text_edit->add_keyword_color(n, type_color); + text_edit->add_keyword_color(n, colors_cache.type_color); } //colorize comments @@ -223,7 +243,7 @@ void ScriptTextEditor::_load_theme_settings() { String beg = comment.get_slice(" ", 0); String end = comment.get_slice_count(" ") > 1 ? comment.get_slice(" ", 1) : String(); - text_edit->add_color_region(beg, end, comment_color, end == ""); + text_edit->add_color_region(beg, end, colors_cache.comment_color, end == ""); } //colorize strings @@ -235,7 +255,7 @@ void ScriptTextEditor::_load_theme_settings() { String string = E->get(); String beg = string.get_slice(" ", 0); String end = string.get_slice_count(" ") > 1 ? string.get_slice(" ", 1) : String(); - text_edit->add_color_region(beg, end, string_color, end == ""); + text_edit->add_color_region(beg, end, colors_cache.string_color, end == ""); } } @@ -263,10 +283,10 @@ void ScriptTextEditor::reload_text() { void ScriptTextEditor::_notification(int p_what) { - if (p_what == NOTIFICATION_READY) { - - //emit_signal("name_changed"); - _load_theme_settings(); + switch (p_what) { + case NOTIFICATION_READY: + _load_theme_settings(); + break; } } @@ -556,6 +576,8 @@ void ScriptTextEditor::set_edited_script(const Ref<Script> &p_script) { emit_signal("name_changed"); code_editor->update_line_and_column(); + + _set_theme_for_script(); } void ScriptTextEditor::_validate_script() { @@ -1452,6 +1474,8 @@ void ScriptTextEditor::_make_context_menu(bool p_selection, bool p_color) { ScriptTextEditor::ScriptTextEditor() { + theme_loaded = false; + code_editor = memnew(CodeTextEditor); add_child(code_editor); code_editor->add_constant_override("separation", 0); diff --git a/editor/plugins/script_text_editor.h b/editor/plugins/script_text_editor.h index f8b7470ec8..83f3ea57c0 100644 --- a/editor/plugins/script_text_editor.h +++ b/editor/plugins/script_text_editor.h @@ -57,6 +57,17 @@ class ScriptTextEditor : public ScriptEditorBase { int color_line; String color_args; + struct ColorsCache { + Color symbol_color; + Color keyword_color; + Color basetype_color; + Color type_color; + Color comment_color; + Color string_color; + } colors_cache; + + bool theme_loaded; + enum { EDIT_UNDO, EDIT_REDO, @@ -101,6 +112,7 @@ protected: void _validate_script(); void _code_complete_script(const String &p_code, List<String> *r_options, bool &r_force); void _load_theme_settings(); + void _set_theme_for_script(); void _notification(int p_what); static void _bind_methods(); diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp index 56e593e34b..288328c7ed 100644 --- a/editor/project_settings_editor.cpp +++ b/editor/project_settings_editor.cpp @@ -907,6 +907,8 @@ void ProjectSettingsEditor::_copy_to_platform_about_to_show() { presets.insert("pvrtc"); presets.insert("debug"); presets.insert("release"); + presets.insert("32"); + presets.insert("64"); for (int i = 0; i < EditorExport::get_singleton()->get_export_platform_count(); i++) { List<String> p; diff --git a/modules/gdnative/SCsub b/modules/gdnative/SCsub index 31178be973..4e5f155f45 100644 --- a/modules/gdnative/SCsub +++ b/modules/gdnative/SCsub @@ -10,7 +10,6 @@ gdn_env.add_source_files(env.modules_sources, "register_types.cpp") gdn_env.add_source_files(env.modules_sources, "gdnative/*.cpp") gdn_env.add_source_files(env.modules_sources, "nativescript/*.cpp") -gdn_env.Append(CPPFLAGS=['-DGDAPI_BUILT_IN']) gdn_env.Append(CPPPATH=['#modules/gdnative/include/']) def _spaced(e): @@ -25,6 +24,8 @@ def _build_gdnative_api_struct_header(api): '#include <gdnative/gdnative.h>', '#include <nativescript/godot_nativescript.h>', '', + '#define GDNATIVE_API_INIT(options) do { extern const godot_gdnative_api_struct *_gdnative_wrapper_api_struct; _gdnative_wrapper_api_struct = options->api_struct; } while (0)', + '', '#ifdef __cplusplus', 'extern "C" {', '#endif', @@ -81,7 +82,68 @@ _, gensource = gdn_env.Command(['include/gdnative_api_struct.gen.h', 'gdnative_a 'gdnative_api.json', build_gdnative_api_struct) gdn_env.add_source_files(env.modules_sources, [gensource]) -if "platform" in env and env["platform"] in ["x11", "iphone"]: - env.Append(LINKFLAGS=["-rdynamic"]) - env.use_ptrcall = True + + +def _build_gdnative_wrapper_code(api): + out = [ + '/* THIS FILE IS GENERATED DO NOT EDIT */', + '', + '#include <gdnative/gdnative.h>', + '#include <nativescript/godot_nativescript.h>', + '', + '#include <gdnative_api_struct.gen.h>', + '', + 'godot_gdnative_api_struct *_gdnative_wrapper_api_struct = 0;', + '', + '#ifdef __cplusplus', + 'extern "C" {', + '#endif', + '' + ] + + for funcname, funcdef in api['api'].items(): + args = ', '.join(['%s%s' % (_spaced(t), n) for t, n in funcdef['arguments']]) + out.append('%s %s(%s) {' % (_spaced(funcdef['return_type']), funcname, args)) + + args = ', '.join(['%s' % n for t, n in funcdef['arguments']]) + + return_line = '\treturn ' if funcdef['return_type'] != 'void' else '\t' + return_line += '_gdnative_wrapper_api_struct->' + funcname + '(' + args + ');' + + out.append(return_line) + out.append('}') + out.append('') + + out += [ + '#ifdef __cplusplus', + '}', + '#endif' + ] + + return '\n'.join(out) + + +def build_gdnative_wrapper_code(target, source, env): + import json + with open(source[0].path, 'r') as fd: +#Keep the json ordered + api = json.load(fd) + + wrapper_file = target[0] + with open(wrapper_file.path, 'w') as fd: + fd.write(_build_gdnative_wrapper_code(api)) + + + +if ARGUMENTS.get('gdnative_wrapper', False): + #build wrapper code + gdn_env.Command('gdnative_wrapper_code.gen.cpp', 'gdnative_api.json', build_gdnative_wrapper_code) + + gd_wrapper_env = env.Clone() + gd_wrapper_env.Append(CPPPATH=['#modules/gdnative/include/']) + + # I think this doesn't work on MSVC yet... + gd_wrapper_env.Append(CCFLAGS=['-fPIC']) + + gd_wrapper_env.Library("#bin/gdnative_wrapper_code", ["#modules/gdnative/gdnative_wrapper_code.gen.cpp"]) diff --git a/modules/gdnative/gdnative_api.json b/modules/gdnative/gdnative_api.json index 9e66f6952b..8b6593c9c3 100644 --- a/modules/gdnative/gdnative_api.json +++ b/modules/gdnative/gdnative_api.json @@ -3334,7 +3334,7 @@ "arguments": [ ["godot_variant *", "p_self"], ["const godot_string *", "p_method"], - ["const godot_variant *", "*p_args"], + ["const godot_variant **", "p_args"], ["const godot_int", "p_argcount"], ["godot_variant_call_error *", "r_error"] ] @@ -3889,7 +3889,7 @@ "return_type": "double", "arguments": [ ["const wchar_t *", "p_str"], - ["const wchar_t *", "*r_end"] + ["const wchar_t **", "r_end"] ] }, "godot_string_get_slice_count": { @@ -4390,7 +4390,7 @@ "arguments": [ ["godot_method_bind *", "p_method_bind"], ["godot_object *", "p_instance"], - ["const void *", "*p_args"], + ["const void **", "p_args"], ["void *", "p_ret"] ] }, @@ -4399,7 +4399,7 @@ "arguments": [ ["godot_method_bind *", "p_method_bind"], ["godot_object *", "p_instance"], - ["const godot_variant *", "*p_args"], + ["const godot_variant **", "p_args"], ["const int", "p_arg_count"], ["godot_variant_call_error *", "p_call_error"] ] diff --git a/modules/gdnative/include/gdnative/gdnative.h b/modules/gdnative/include/gdnative/gdnative.h index 9134f1c581..008968a5e5 100644 --- a/modules/gdnative/include/gdnative/gdnative.h +++ b/modules/gdnative/include/gdnative/gdnative.h @@ -34,18 +34,9 @@ extern "C" { #endif -#ifdef GDAPI_BUILT_IN -#define GDAPI_EXPORT -#endif - #ifdef _WIN32 -#if defined(GDAPI_EXPORT) -#define GDCALLINGCONV -#define GDAPI __declspec(dllexport) GDCALLINGCONV -#else #define GDCALLINGCONV -#define GDAPI __declspec(dllimport) GDCALLINGCONV -#endif +#define GDAPI GDCALLINGCONV #elif defined(__APPLE__) #include "TargetConditionals.h" #if TARGET_OS_IPHONE diff --git a/modules/gdnative/include/nativescript/godot_nativescript.h b/modules/gdnative/include/nativescript/godot_nativescript.h index 5095b7a83e..8baff0fff9 100644 --- a/modules/gdnative/include/nativescript/godot_nativescript.h +++ b/modules/gdnative/include/nativescript/godot_nativescript.h @@ -36,42 +36,6 @@ extern "C" { #endif -#ifdef GDAPI_BUILT_IN -#define GDAPI_EXPORT -#endif - -#ifdef _WIN32 -#if defined(GDAPI_EXPORT) -#define GDCALLINGCONV -#define GDAPI __declspec(dllexport) GDCALLINGCONV -#else -#define GDCALLINGCONV -#define GDAPI __declspec(dllimport) GDCALLINGCONV -#endif -#elif defined(__APPLE__) -#include "TargetConditionals.h" -#if TARGET_OS_IPHONE -#define GDCALLINGCONV __attribute__((visibility("default"))) -#define GDAPI GDCALLINGCONV -#elif TARGET_OS_MAC -#define GDCALLINGCONV __attribute__((sysv_abi)) -#define GDAPI GDCALLINGCONV -#endif -#else -#define GDCALLINGCONV __attribute__((sysv_abi, visibility("default"))) -#define GDAPI GDCALLINGCONV -#endif - -// This is for libraries *using* the header, NOT GODOT EXPOSING STUFF!! -#ifdef _WIN32 -#define GDN_EXPORT __declspec(dllexport) -#else -#define GDN_EXPORT -#endif - -#include <stdbool.h> -#include <stdint.h> - typedef enum { GODOT_METHOD_RPC_MODE_DISABLED, GODOT_METHOD_RPC_MODE_REMOTE, diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp index 985f8a8d0e..47ef0182dc 100644 --- a/modules/visual_script/visual_script_editor.cpp +++ b/modules/visual_script/visual_script_editor.cpp @@ -331,44 +331,83 @@ public: VisualScriptEditorVariableEdit() { undo_redo = NULL; } }; -static Color _color_from_type(Variant::Type p_type) { +static Color _color_from_type(Variant::Type p_type, bool dark_theme = true) { Color color; - switch (p_type) { - case Variant::NIL: color = Color::html("69ecbd"); break; - - case Variant::BOOL: color = Color::html("8da6f0"); break; - case Variant::INT: color = Color::html("7dc6ef"); break; - case Variant::REAL: color = Color::html("61daf4"); break; - case Variant::STRING: color = Color::html("6ba7ec"); break; - - case Variant::VECTOR2: color = Color::html("bd91f1"); break; - case Variant::RECT2: color = Color::html("f191a5"); break; - case Variant::VECTOR3: color = Color::html("d67dee"); break; - case Variant::TRANSFORM2D: color = Color::html("c4ec69"); break; - case Variant::PLANE: color = Color::html("f77070"); break; - case Variant::QUAT: color = Color::html("ec69a3"); break; - case Variant::RECT3: color = Color::html("ee7991"); break; - case Variant::BASIS: color = Color::html("e3ec69"); break; - case Variant::TRANSFORM: color = Color::html("f6a86e"); break; - - case Variant::COLOR: color = Color::html("9dff70"); break; - case Variant::NODE_PATH: color = Color::html("6993ec"); break; - case Variant::_RID: color = Color::html("69ec9a"); break; - case Variant::OBJECT: color = Color::html("79f3e8"); break; - case Variant::DICTIONARY: color = Color::html("77edb1"); break; - - case Variant::ARRAY: color = Color::html("e0e0e0"); break; - case Variant::POOL_BYTE_ARRAY: color = Color::html("aaf4c8"); break; - case Variant::POOL_INT_ARRAY: color = Color::html("afdcf5"); break; - case Variant::POOL_REAL_ARRAY: color = Color::html("97e7f8"); break; - case Variant::POOL_STRING_ARRAY: color = Color::html("9dc4f2"); break; - case Variant::POOL_VECTOR2_ARRAY: color = Color::html("d1b3f5"); break; - case Variant::POOL_VECTOR3_ARRAY: color = Color::html("df9bf2"); break; - case Variant::POOL_COLOR_ARRAY: color = Color::html("e9ff97"); break; - - default: - color.set_hsv(p_type / float(Variant::VARIANT_MAX), 0.7, 0.7); - } + if (dark_theme) + switch (p_type) { + case Variant::NIL: color = Color::html("#69ecbd"); break; + + case Variant::BOOL: color = Color::html("#8da6f0"); break; + case Variant::INT: color = Color::html("#7dc6ef"); break; + case Variant::REAL: color = Color::html("#61daf4"); break; + case Variant::STRING: color = Color::html("#6ba7ec"); break; + + case Variant::VECTOR2: color = Color::html("#bd91f1"); break; + case Variant::RECT2: color = Color::html("#f191a5"); break; + case Variant::VECTOR3: color = Color::html("#d67dee"); break; + case Variant::TRANSFORM2D: color = Color::html("#c4ec69"); break; + case Variant::PLANE: color = Color::html("#f77070"); break; + case Variant::QUAT: color = Color::html("#ec69a3"); break; + case Variant::RECT3: color = Color::html("#ee7991"); break; + case Variant::BASIS: color = Color::html("#e3ec69"); break; + case Variant::TRANSFORM: color = Color::html("#f6a86e"); break; + + case Variant::COLOR: color = Color::html("#9dff70"); break; + case Variant::NODE_PATH: color = Color::html("#6993ec"); break; + case Variant::_RID: color = Color::html("#69ec9a"); break; + case Variant::OBJECT: color = Color::html("#79f3e8"); break; + case Variant::DICTIONARY: color = Color::html("#77edb1"); break; + + case Variant::ARRAY: color = Color::html("#e0e0e0"); break; + case Variant::POOL_BYTE_ARRAY: color = Color::html("#aaf4c8"); break; + case Variant::POOL_INT_ARRAY: color = Color::html("#afdcf5"); break; + case Variant::POOL_REAL_ARRAY: color = Color::html("#97e7f8"); break; + case Variant::POOL_STRING_ARRAY: color = Color::html("#9dc4f2"); break; + case Variant::POOL_VECTOR2_ARRAY: color = Color::html("#d1b3f5"); break; + case Variant::POOL_VECTOR3_ARRAY: color = Color::html("#df9bf2"); break; + case Variant::POOL_COLOR_ARRAY: color = Color::html("#e9ff97"); break; + + default: + color.set_hsv(p_type / float(Variant::VARIANT_MAX), 0.7, 0.7); + } + else + switch (p_type) { + case Variant::NIL: color = Color::html("#25e3a0"); break; + + case Variant::BOOL: color = Color::html("#6d8eeb"); break; + case Variant::INT: color = Color::html("#4fb2e9"); break; + case Variant::REAL: color = Color::html("#27ccf0"); break; + case Variant::STRING: color = Color::html("#4690e7"); break; + + case Variant::VECTOR2: color = Color::html("#ad76ee"); break; + case Variant::RECT2: color = Color::html("#ee758e"); break; + case Variant::VECTOR3: color = Color::html("#dc6aed"); break; + case Variant::TRANSFORM2D: color = Color::html("#96ce1a"); break; + case Variant::PLANE: color = Color::html("#f77070"); break; + case Variant::QUAT: color = Color::html("#ec69a3"); break; + case Variant::RECT3: color = Color::html("#ee7991"); break; + case Variant::BASIS: color = Color::html("#b2bb19"); break; + case Variant::TRANSFORM: color = Color::html("#f49047"); break; + + case Variant::COLOR: color = Color::html("#3cbf00"); break; + case Variant::NODE_PATH: color = Color::html("#6993ec"); break; + case Variant::_RID: color = Color::html("#2ce573"); break; + case Variant::OBJECT: color = Color::html("#12d5c3"); break; + case Variant::DICTIONARY: color = Color::html("#57e99f"); break; + + case Variant::ARRAY: color = Color::html("#737373"); break; + case Variant::POOL_BYTE_ARRAY: color = Color::html("#61ea98"); break; + case Variant::POOL_INT_ARRAY: color = Color::html("#61baeb"); break; + case Variant::POOL_REAL_ARRAY: color = Color::html("#40d3f2"); break; + case Variant::POOL_STRING_ARRAY: color = Color::html("#609fea"); break; + case Variant::POOL_VECTOR2_ARRAY: color = Color::html("#9d5dea"); break; + case Variant::POOL_VECTOR3_ARRAY: color = Color::html("#ca5aea"); break; + case Variant::POOL_COLOR_ARRAY: color = Color::html("#92ba00"); break; + + default: + color.set_hsv(p_type / float(Variant::VARIANT_MAX), 0.3, 0.3); + } + return color; } @@ -531,7 +570,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) { Color c = sbf->get_border_color(MARGIN_TOP); c.a = 1; if (EditorSettings::get_singleton()->get("interface/theme/use_graph_node_headers")) { - Color mono_color = ((c.r + c.g + c.b) / 3) < 0.5 ? Color(1.0, 1.0, 1.0) : Color(0, 0, 0); + Color mono_color = ((c.r + c.g + c.b) / 3) < 0.7 ? Color(1.0, 1.0, 1.0) : Color(0.0, 0.0, 0.0); mono_color.a = 0.85; c = mono_color; } @@ -542,10 +581,12 @@ void VisualScriptEditor::_update_graph(int p_only_id) { gnode->add_style_override("frame", sbf); } + const Color mono_color = get_color("mono_color", "Editor"); + int slot_idx = 0; bool single_seq_output = node->get_output_sequence_port_count() == 1 && node->get_output_sequence_port_text(0) == String(); - gnode->set_slot(0, node->has_input_sequence_port(), TYPE_SEQUENCE, Color(1, 1, 1, 1), single_seq_output, TYPE_SEQUENCE, Color(1, 1, 1, 1), seq_port, seq_port); + gnode->set_slot(0, node->has_input_sequence_port(), TYPE_SEQUENCE, mono_color, single_seq_output, TYPE_SEQUENCE, mono_color, seq_port, seq_port); gnode->set_offset(pos * EDSCALE); slot_idx++; @@ -562,7 +603,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) { text2->set_text(node->get_output_sequence_port_text(i)); text2->set_align(Label::ALIGN_RIGHT); gnode->add_child(text2); - gnode->set_slot(slot_idx, false, 0, Color(), true, TYPE_SEQUENCE, Color(1, 1, 1, 1), seq_port, seq_port); + gnode->set_slot(slot_idx, false, 0, Color(), true, TYPE_SEQUENCE, mono_color, seq_port, seq_port); slot_idx++; } } @@ -677,10 +718,11 @@ void VisualScriptEditor::_update_graph(int p_only_id) { gnode->add_child(hbc); + bool dark_theme = get_constant("dark_theme", "Editor"); if (i < mixed_seq_ports) { - gnode->set_slot(slot_idx, left_ok, left_type, _color_from_type(left_type), true, TYPE_SEQUENCE, Color(1, 1, 1, 1), Ref<Texture>(), seq_port); + gnode->set_slot(slot_idx, left_ok, left_type, _color_from_type(left_type, dark_theme), true, TYPE_SEQUENCE, mono_color, Ref<Texture>(), seq_port); } else { - gnode->set_slot(slot_idx, left_ok, left_type, _color_from_type(left_type), right_ok, right_type, _color_from_type(right_type)); + gnode->set_slot(slot_idx, left_ok, left_type, _color_from_type(left_type, dark_theme), right_ok, right_type, _color_from_type(right_type, dark_theme)); } slot_idx++; @@ -710,7 +752,7 @@ void VisualScriptEditor::_update_members() { functions->set_text(0, TTR("Functions:")); functions->add_button(0, Control::get_icon("Override", "EditorIcons"), 1); functions->add_button(0, Control::get_icon("Add", "EditorIcons"), 0); - functions->set_custom_bg_color(0, Control::get_color("prop_section", "Editor")); + functions->set_custom_color(0, Control::get_color("mono_color", "Editor")); List<StringName> func_names; script->get_function_list(&func_names); @@ -719,13 +761,7 @@ void VisualScriptEditor::_update_members() { ti->set_text(0, E->get()); ti->set_selectable(0, true); ti->set_editable(0, true); - //ti->add_button(0,Control::get_icon("Edit","EditorIcons"),0); function arguments are in the node now - //ti->add_button(0, Control::get_icon("Del", "EditorIcons"), 1); ti->set_metadata(0, E->get()); - if (E->get() == edited_func) { - ti->set_custom_bg_color(0, get_color("prop_category", "Editor")); - ti->set_custom_color(0, Color(1, 1, 1, 1)); - } if (selected == E->get()) ti->select(0); } @@ -734,7 +770,7 @@ void VisualScriptEditor::_update_members() { variables->set_selectable(0, false); variables->set_text(0, TTR("Variables:")); variables->add_button(0, Control::get_icon("Add", "EditorIcons")); - variables->set_custom_bg_color(0, Control::get_color("prop_section", "Editor")); + variables->set_custom_color(0, Control::get_color("mono_color", "Editor")); Ref<Texture> type_icons[Variant::VARIANT_MAX] = { Control::get_icon("MiniVariant", "EditorIcons"), @@ -778,8 +814,6 @@ void VisualScriptEditor::_update_members() { ti->set_selectable(0, true); ti->set_editable(0, true); - //ti->add_button(0, Control::get_icon("Edit", "EditorIcons"), 0); - //ti->add_button(0, Control::get_icon("Del", "EditorIcons"), 1); ti->set_metadata(0, E->get()); if (selected == E->get()) ti->select(0); @@ -789,7 +823,7 @@ void VisualScriptEditor::_update_members() { _signals->set_selectable(0, false); _signals->set_text(0, TTR("Signals:")); _signals->add_button(0, Control::get_icon("Add", "EditorIcons")); - _signals->set_custom_bg_color(0, Control::get_color("prop_section", "Editor")); + _signals->set_custom_color(0, Control::get_color("mono_color", "Editor")); List<StringName> signal_names; script->get_custom_signal_list(&signal_names); @@ -798,8 +832,6 @@ void VisualScriptEditor::_update_members() { ti->set_text(0, E->get()); ti->set_selectable(0, true); ti->set_editable(0, true); - //ti->add_button(0, Control::get_icon("Edit", "EditorIcons"), 0); - //ti->add_button(0, Control::get_icon("Del", "EditorIcons"), 1); ti->set_metadata(0, E->get()); if (selected == E->get()) ti->select(0); @@ -2767,18 +2799,30 @@ void VisualScriptEditor::_notification(int p_what) { variable_editor->connect("changed", this, "_update_members"); signal_editor->connect("changed", this, "_update_members"); + Ref<Theme> tm = EditorNode::get_singleton()->get_theme_base()->get_theme(); + + bool dark_theme = tm->get_constant("dark_theme", "Editor"); + List<Pair<String, Color> > colors; - colors.push_back(Pair<String, Color>("flow_control", Color::html("#f4f4f4"))); - colors.push_back(Pair<String, Color>("functions", Color::html("#f58581"))); - colors.push_back(Pair<String, Color>("data", Color::html("#80f6cf"))); - colors.push_back(Pair<String, Color>("operators", Color::html("#ab97df"))); - colors.push_back(Pair<String, Color>("custom", Color::html("#80bbf6"))); - colors.push_back(Pair<String, Color>("constants", Color::html("#f680b0"))); + if (dark_theme) { + colors.push_back(Pair<String, Color>("flow_control", Color::html("#f4f4f4"))); + colors.push_back(Pair<String, Color>("functions", Color::html("#f58581"))); + colors.push_back(Pair<String, Color>("data", Color::html("#80f6cf"))); + colors.push_back(Pair<String, Color>("operators", Color::html("#ab97df"))); + colors.push_back(Pair<String, Color>("custom", Color::html("#80bbf6"))); + colors.push_back(Pair<String, Color>("constants", Color::html("#f680b0"))); + } else { + colors.push_back(Pair<String, Color>("flow_control", Color::html("#424242"))); + colors.push_back(Pair<String, Color>("functions", Color::html("#f26661"))); + colors.push_back(Pair<String, Color>("data", Color::html("#13bb83"))); + colors.push_back(Pair<String, Color>("operators", Color::html("#8265d0"))); + colors.push_back(Pair<String, Color>("custom", Color::html("#4ea0f2"))); + colors.push_back(Pair<String, Color>("constants", Color::html("#f02f7d"))); + } for (List<Pair<String, Color> >::Element *E = colors.front(); E; E = E->next()) { - print_line(E->get().first); - Ref<StyleBoxFlat> sb = EditorNode::get_singleton()->get_theme_base()->get_theme()->get_stylebox("frame", "GraphNode"); - if (sb != NULL) { + Ref<StyleBoxFlat> sb = tm->get_stylebox("frame", "GraphNode"); + if (!sb.is_null()) { Ref<StyleBoxFlat> frame_style = sb->duplicate(); Color c = sb->get_border_color(MARGIN_TOP); Color cn = E->get().second; diff --git a/platform/osx/export/export.cpp b/platform/osx/export/export.cpp index 2ec76fe0dd..0fd21d62ee 100644 --- a/platform/osx/export/export.cpp +++ b/platform/osx/export/export.cpp @@ -97,6 +97,16 @@ void EditorExportPlatformOSX::get_preset_features(const Ref<EditorExportPreset> if (p_preset->get("texture_format/etc2")) { r_features->push_back("etc2"); } + + int bits = p_preset->get("application/bits_mode"); + + if (bits == 0 || bits == 1) { + r_features->push_back("64"); + } + + if (bits == 0 || bits == 2) { + r_features->push_back("32"); + } } void EditorExportPlatformOSX::get_export_options(List<ExportOption> *r_options) { |