Skip to content

Commit 0fc9fb5

Browse files
committed
Compile out editor-only logic within validate_property in export template
1 parent 1cf573f commit 0fc9fb5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+1099
-795
lines changed

modules/csg/csg_shape.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -948,13 +948,17 @@ bool CSGShape3D::is_calculating_tangents() const {
948948
}
949949

950950
void CSGShape3D::_validate_property(PropertyInfo &p_property) const {
951-
bool is_collision_prefixed = p_property.name.begins_with("collision_");
952-
if ((is_collision_prefixed || p_property.name.begins_with("use_collision")) && is_inside_tree() && !is_root_shape()) {
953-
//hide collision if not root
954-
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
955-
} else if (is_collision_prefixed && !bool(get("use_collision"))) {
956-
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
951+
#if TOOLS_ENABLED
952+
if (Engine::get_singleton()->is_editor_hint()) {
953+
bool is_collision_prefixed = p_property.name.begins_with("collision_");
954+
if ((is_collision_prefixed || p_property.name.begins_with("use_collision")) && is_inside_tree() && !is_root_shape()) {
955+
//hide collision if not root
956+
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
957+
} else if (is_collision_prefixed && !bool(get("use_collision"))) {
958+
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
959+
}
957960
}
961+
#endif
958962
}
959963

960964
Array CSGShape3D::get_meshes() const {

modules/noise/fastnoise_lite.cpp

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
/**************************************************************************/
3030

3131
#include "fastnoise_lite.h"
32+
#include "core/config/engine.h"
3233

3334
_FastNoiseLite::FractalType FastNoiseLite::_convert_domain_warp_fractal_type_enum(DomainWarpFractalType p_domain_warp_fractal_type) {
3435
_FastNoiseLite::FractalType type;
@@ -477,23 +478,27 @@ void FastNoiseLite::_bind_methods() {
477478
}
478479

479480
void FastNoiseLite::_validate_property(PropertyInfo &p_property) const {
480-
if (p_property.name.begins_with("cellular") && get_noise_type() != TYPE_CELLULAR) {
481-
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
482-
return;
483-
}
484-
485-
if (p_property.name != "fractal_type" && p_property.name.begins_with("fractal") && get_fractal_type() == FRACTAL_NONE) {
486-
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
487-
return;
488-
}
489-
490-
if (p_property.name == "fractal_ping_pong_strength" && get_fractal_type() != FRACTAL_PING_PONG) {
491-
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
492-
return;
493-
}
494-
495-
if (p_property.name != "domain_warp_enabled" && p_property.name.begins_with("domain_warp") && !domain_warp_enabled) {
496-
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
497-
return;
481+
#if TOOLS_ENABLED
482+
if (Engine::get_singleton()->is_editor_hint()) {
483+
if (p_property.name.begins_with("cellular") && get_noise_type() != TYPE_CELLULAR) {
484+
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
485+
return;
486+
}
487+
488+
if (p_property.name != "fractal_type" && p_property.name.begins_with("fractal") && get_fractal_type() == FRACTAL_NONE) {
489+
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
490+
return;
491+
}
492+
493+
if (p_property.name == "fractal_ping_pong_strength" && get_fractal_type() != FRACTAL_PING_PONG) {
494+
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
495+
return;
496+
}
497+
498+
if (p_property.name != "domain_warp_enabled" && p_property.name.begins_with("domain_warp") && !domain_warp_enabled) {
499+
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
500+
return;
501+
}
498502
}
503+
#endif
499504
}

modules/noise/noise_texture_2d.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,17 +97,21 @@ void NoiseTexture2D::_bind_methods() {
9797
}
9898

9999
void NoiseTexture2D::_validate_property(PropertyInfo &p_property) const {
100-
if (p_property.name == "bump_strength") {
101-
if (!as_normal_map) {
102-
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
100+
#if TOOLS_ENABLED
101+
if (Engine::get_singleton()->is_editor_hint()) {
102+
if (p_property.name == "bump_strength") {
103+
if (!as_normal_map) {
104+
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
105+
}
103106
}
104-
}
105107

106-
if (p_property.name == "seamless_blend_skirt") {
107-
if (!seamless) {
108-
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
108+
if (p_property.name == "seamless_blend_skirt") {
109+
if (!seamless) {
110+
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
111+
}
109112
}
110113
}
114+
#endif
111115
}
112116

113117
void NoiseTexture2D::_set_texture_image(const Ref<Image> &p_image) {

modules/noise/noise_texture_3d.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,15 @@ void NoiseTexture3D::_bind_methods() {
8383
}
8484

8585
void NoiseTexture3D::_validate_property(PropertyInfo &p_property) const {
86-
if (p_property.name == "seamless_blend_skirt") {
87-
if (!seamless) {
88-
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
86+
#if TOOLS_ENABLED
87+
if (Engine::get_singleton()->is_editor_hint()) {
88+
if (p_property.name == "seamless_blend_skirt") {
89+
if (!seamless) {
90+
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
91+
}
8992
}
9093
}
94+
#endif
9195
}
9296

9397
void NoiseTexture3D::_set_texture_data(const TypedArray<Image> &p_data) {

modules/openxr/scene/openxr_composition_layer.cpp

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -677,19 +677,23 @@ bool OpenXRCompositionLayer::_set(const StringName &p_property, const Variant &p
677677
}
678678

679679
void OpenXRCompositionLayer::_validate_property(PropertyInfo &p_property) const {
680-
if (p_property.name == "layer_viewport") {
681-
if (use_android_surface) {
682-
p_property.usage &= ~PROPERTY_USAGE_EDITOR;
683-
} else {
684-
p_property.usage |= PROPERTY_USAGE_EDITOR;
685-
}
686-
} else if (p_property.name == "android_surface_size") {
687-
if (use_android_surface) {
688-
p_property.usage |= PROPERTY_USAGE_EDITOR;
689-
} else {
690-
p_property.usage &= ~PROPERTY_USAGE_EDITOR;
680+
#if TOOLS_ENABLED
681+
if (Engine::get_singleton()->is_editor_hint()) {
682+
if (p_property.name == "layer_viewport") {
683+
if (use_android_surface) {
684+
p_property.usage &= ~PROPERTY_USAGE_EDITOR;
685+
} else {
686+
p_property.usage |= PROPERTY_USAGE_EDITOR;
687+
}
688+
} else if (p_property.name == "android_surface_size") {
689+
if (use_android_surface) {
690+
p_property.usage |= PROPERTY_USAGE_EDITOR;
691+
} else {
692+
p_property.usage &= ~PROPERTY_USAGE_EDITOR;
693+
}
691694
}
692695
}
696+
#endif
693697
}
694698

695699
PackedStringArray OpenXRCompositionLayer::get_configuration_warnings() const {

scene/2d/animated_sprite_2d.cpp

Lines changed: 42 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -113,56 +113,60 @@ Rect2 AnimatedSprite2D::_get_rect() const {
113113
}
114114

115115
void AnimatedSprite2D::_validate_property(PropertyInfo &p_property) const {
116-
if (frames.is_null()) {
117-
return;
118-
}
116+
#if TOOLS_ENABLED
117+
if (Engine::get_singleton()->is_editor_hint()) {
118+
if (frames.is_null()) {
119+
return;
120+
}
119121

120-
if (p_property.name == "animation") {
121-
List<StringName> names;
122-
frames->get_animation_list(&names);
123-
names.sort_custom<StringName::AlphCompare>();
122+
if (p_property.name == "animation") {
123+
List<StringName> names;
124+
frames->get_animation_list(&names);
125+
names.sort_custom<StringName::AlphCompare>();
124126

125-
bool current_found = false;
126-
bool is_first_element = true;
127+
bool current_found = false;
128+
bool is_first_element = true;
127129

128-
for (const StringName &E : names) {
129-
if (!is_first_element) {
130-
p_property.hint_string += ",";
131-
} else {
132-
is_first_element = false;
133-
}
130+
for (const StringName &E : names) {
131+
if (!is_first_element) {
132+
p_property.hint_string += ",";
133+
} else {
134+
is_first_element = false;
135+
}
134136

135-
p_property.hint_string += String(E);
136-
if (animation == E) {
137-
current_found = true;
137+
p_property.hint_string += String(E);
138+
if (animation == E) {
139+
current_found = true;
140+
}
138141
}
139-
}
140142

141-
if (!current_found) {
142-
if (p_property.hint_string.is_empty()) {
143-
p_property.hint_string = String(animation);
144-
} else {
145-
p_property.hint_string = String(animation) + "," + p_property.hint_string;
143+
if (!current_found) {
144+
if (p_property.hint_string.is_empty()) {
145+
p_property.hint_string = String(animation);
146+
} else {
147+
p_property.hint_string = String(animation) + "," + p_property.hint_string;
148+
}
146149
}
147-
}
148-
return;
149-
}
150-
151-
if (p_property.name == "frame") {
152-
if (playing) {
153-
p_property.usage = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_READ_ONLY;
154150
return;
155151
}
156152

157-
p_property.hint = PROPERTY_HINT_RANGE;
158-
if (frames->has_animation(animation) && frames->get_frame_count(animation) > 0) {
159-
p_property.hint_string = "0," + itos(frames->get_frame_count(animation) - 1) + ",1";
160-
} else {
161-
// Avoid an error, `hint_string` is required for `PROPERTY_HINT_RANGE`.
162-
p_property.hint_string = "0,0,1";
153+
if (p_property.name == "frame") {
154+
if (playing) {
155+
p_property.usage = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_READ_ONLY;
156+
return;
157+
}
158+
159+
p_property.hint = PROPERTY_HINT_RANGE;
160+
if (frames->has_animation(animation) && frames->get_frame_count(animation) > 0) {
161+
p_property.hint_string = "0," + itos(frames->get_frame_count(animation) - 1) + ",1";
162+
} else {
163+
// Avoid an error, `hint_string` is required for `PROPERTY_HINT_RANGE`.
164+
p_property.hint_string = "0,0,1";
165+
}
166+
p_property.usage |= PROPERTY_USAGE_KEYING_INCREMENTS;
163167
}
164-
p_property.usage |= PROPERTY_USAGE_KEYING_INCREMENTS;
165168
}
169+
#endif
166170
}
167171

168172
void AnimatedSprite2D::_notification(int p_what) {

scene/2d/back_buffer_copy.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,13 @@ BackBufferCopy::CopyMode BackBufferCopy::get_copy_mode() const {
8080
}
8181

8282
void BackBufferCopy::_validate_property(PropertyInfo &p_property) const {
83-
if (copy_mode != COPY_MODE_RECT && p_property.name == "rect") {
84-
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
83+
#if TOOLS_ENABLED
84+
if (Engine::get_singleton()->is_editor_hint()) {
85+
if (copy_mode != COPY_MODE_RECT && p_property.name == "rect") {
86+
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
87+
}
8588
}
89+
#endif
8690
}
8791

8892
void BackBufferCopy::_bind_methods() {

scene/2d/camera_2d.cpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -920,15 +920,19 @@ bool Camera2D::is_margin_drawing_enabled() const {
920920
}
921921

922922
void Camera2D::_validate_property(PropertyInfo &p_property) const {
923-
if (!limit_enabled && (p_property.name == "limit_smoothed" || p_property.name == "limit_left" || p_property.name == "limit_top" || p_property.name == "limit_right" || p_property.name == "limit_bottom")) {
924-
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
925-
}
926-
if (!position_smoothing_enabled && p_property.name == "position_smoothing_speed") {
927-
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
928-
}
929-
if (!rotation_smoothing_enabled && p_property.name == "rotation_smoothing_speed") {
930-
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
923+
#if TOOLS_ENABLED
924+
if (Engine::get_singleton()->is_editor_hint()) {
925+
if (!limit_enabled && (p_property.name == "limit_smoothed" || p_property.name == "limit_left" || p_property.name == "limit_top" || p_property.name == "limit_right" || p_property.name == "limit_bottom")) {
926+
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
927+
}
928+
if (!position_smoothing_enabled && p_property.name == "position_smoothing_speed") {
929+
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
930+
}
931+
if (!rotation_smoothing_enabled && p_property.name == "rotation_smoothing_speed") {
932+
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
933+
}
931934
}
935+
#endif
932936
}
933937

934938
void Camera2D::_bind_methods() {

scene/2d/cpu_particles_2d.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -616,9 +616,13 @@ void CPUParticles2D::request_particles_process(real_t p_requested_process_time)
616616
}
617617

618618
void CPUParticles2D::_validate_property(PropertyInfo &p_property) const {
619-
if (p_property.name == "emitting") {
620-
p_property.hint = one_shot ? PROPERTY_HINT_ONESHOT : PROPERTY_HINT_NONE;
619+
#if TOOLS_ENABLED
620+
if (Engine::get_singleton()->is_editor_hint()) {
621+
if (p_property.name == "emitting") {
622+
p_property.hint = one_shot ? PROPERTY_HINT_ONESHOT : PROPERTY_HINT_NONE;
623+
}
621624
}
625+
#endif
622626

623627
if (p_property.name == "emission_sphere_radius" && (emission_shape != EMISSION_SHAPE_SPHERE && emission_shape != EMISSION_SHAPE_SPHERE_SURFACE)) {
624628
p_property.usage = PROPERTY_USAGE_NONE;

scene/2d/gpu_particles_2d.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,9 +431,13 @@ void GPUParticles2D::_validate_property(PropertyInfo &p_property) const {
431431
if (p_property.name == "seed" && !use_fixed_seed) {
432432
p_property.usage = PROPERTY_USAGE_NONE;
433433
}
434-
if (p_property.name == "emitting") {
435-
p_property.hint = one_shot ? PROPERTY_HINT_ONESHOT : PROPERTY_HINT_NONE;
434+
#if TOOLS_ENABLED
435+
if (Engine::get_singleton()->is_editor_hint()) {
436+
if (p_property.name == "emitting") {
437+
p_property.hint = one_shot ? PROPERTY_HINT_ONESHOT : PROPERTY_HINT_NONE;
438+
}
436439
}
440+
#endif
437441
}
438442

439443
void GPUParticles2D::emit_particle(const Transform2D &p_transform2d, const Vector2 &p_velocity2d, const Color &p_color, const Color &p_custom, uint32_t p_emit_flags) {

0 commit comments

Comments
 (0)