Merge pull request #64553 from RedMser/fix-property-validation-refactor

This commit is contained in:
Rémi Verschelde 2022-08-22 16:54:47 +02:00 committed by GitHub
commit fdc36ad082
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 36 additions and 34 deletions

View file

@ -590,7 +590,7 @@ void CSGShape3D::_validate_property(PropertyInfo &property) const {
//hide collision if not root //hide collision if not root
property.usage = PROPERTY_USAGE_NO_EDITOR; property.usage = PROPERTY_USAGE_NO_EDITOR;
} else if (is_collision_prefixed && !bool(get("use_collision"))) { } else if (is_collision_prefixed && !bool(get("use_collision"))) {
property.usage = PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL; property.usage = PROPERTY_USAGE_NO_EDITOR;
} }
GeometryInstance3D::_validate_property(property); GeometryInstance3D::_validate_property(property);
} }

View file

@ -97,7 +97,7 @@ void NoiseTexture::_bind_methods() {
void NoiseTexture::_validate_property(PropertyInfo &property) const { void NoiseTexture::_validate_property(PropertyInfo &property) const {
if (property.name == "bump_strength") { if (property.name == "bump_strength") {
if (!as_normal_map) { if (!as_normal_map) {
property.usage = PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL; property.usage = PROPERTY_USAGE_NO_EDITOR;
} }
} }

View file

@ -515,7 +515,7 @@ Dictionary VisualScriptFunctionCall::_get_argument_cache() const {
void VisualScriptFunctionCall::_validate_property(PropertyInfo &property) const { void VisualScriptFunctionCall::_validate_property(PropertyInfo &property) const {
if (property.name == "base_type") { if (property.name == "base_type") {
if (call_mode != CALL_MODE_INSTANCE) { if (call_mode != CALL_MODE_INSTANCE) {
property.usage = PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL; property.usage = PROPERTY_USAGE_NO_EDITOR;
} }
} }
@ -1293,7 +1293,7 @@ VisualScriptPropertySet::AssignOp VisualScriptPropertySet::get_assign_op() const
void VisualScriptPropertySet::_validate_property(PropertyInfo &property) const { void VisualScriptPropertySet::_validate_property(PropertyInfo &property) const {
if (property.name == "base_type") { if (property.name == "base_type") {
if (call_mode != CALL_MODE_INSTANCE) { if (call_mode != CALL_MODE_INSTANCE) {
property.usage = PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL; property.usage = PROPERTY_USAGE_NO_EDITOR;
} }
} }
@ -1999,7 +1999,7 @@ StringName VisualScriptPropertyGet::get_index() const {
void VisualScriptPropertyGet::_validate_property(PropertyInfo &property) const { void VisualScriptPropertyGet::_validate_property(PropertyInfo &property) const {
if (property.name == "base_type") { if (property.name == "base_type") {
if (call_mode != CALL_MODE_INSTANCE) { if (call_mode != CALL_MODE_INSTANCE) {
property.usage = PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL; property.usage = PROPERTY_USAGE_NO_EDITOR;
} }
} }

View file

@ -512,25 +512,25 @@ void Area2D::_validate_property(PropertyInfo &property) const {
property.hint_string = options; property.hint_string = options;
} else if (property.name.begins_with("gravity") && property.name != "gravity_space_override") { } else if (property.name.begins_with("gravity") && property.name != "gravity_space_override") {
if (gravity_space_override == SPACE_OVERRIDE_DISABLED) { if (gravity_space_override == SPACE_OVERRIDE_DISABLED) {
property.usage = PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL; property.usage = PROPERTY_USAGE_NO_EDITOR;
} else { } else {
if (gravity_is_point) { if (gravity_is_point) {
if (property.name == "gravity_direction") { if (property.name == "gravity_direction") {
property.usage = PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL; property.usage = PROPERTY_USAGE_NO_EDITOR;
} }
} else { } else {
if (property.name.begins_with("gravity_point_")) { if (property.name.begins_with("gravity_point_")) {
property.usage = PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL; property.usage = PROPERTY_USAGE_NO_EDITOR;
} }
} }
} }
} else if (property.name.begins_with("linear_damp") && property.name != "linear_damp_space_override") { } else if (property.name.begins_with("linear_damp") && property.name != "linear_damp_space_override") {
if (linear_damp_space_override == SPACE_OVERRIDE_DISABLED) { if (linear_damp_space_override == SPACE_OVERRIDE_DISABLED) {
property.usage = PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL; property.usage = PROPERTY_USAGE_NO_EDITOR;
} }
} else if (property.name.begins_with("angular_damp") && property.name != "angular_damp_space_override") { } else if (property.name.begins_with("angular_damp") && property.name != "angular_damp_space_override") {
if (angular_damp_space_override == SPACE_OVERRIDE_DISABLED) { if (angular_damp_space_override == SPACE_OVERRIDE_DISABLED) {
property.usage = PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL; property.usage = PROPERTY_USAGE_NO_EDITOR;
} }
} }
} }

View file

@ -1065,7 +1065,7 @@ void RigidDynamicBody2D::_bind_methods() {
void RigidDynamicBody2D::_validate_property(PropertyInfo &property) const { void RigidDynamicBody2D::_validate_property(PropertyInfo &property) const {
if (center_of_mass_mode != CENTER_OF_MASS_MODE_CUSTOM) { if (center_of_mass_mode != CENTER_OF_MASS_MODE_CUSTOM) {
if (property.name == "center_of_mass") { if (property.name == "center_of_mass") {
property.usage = PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL; property.usage = PROPERTY_USAGE_NO_EDITOR;
} }
} }
} }
@ -1779,11 +1779,11 @@ void CharacterBody2D::_bind_methods() {
void CharacterBody2D::_validate_property(PropertyInfo &property) const { void CharacterBody2D::_validate_property(PropertyInfo &property) const {
if (motion_mode == MOTION_MODE_FLOATING) { if (motion_mode == MOTION_MODE_FLOATING) {
if (property.name.begins_with("floor_") || property.name == "up_direction" || property.name == "slide_on_ceiling") { if (property.name.begins_with("floor_") || property.name == "up_direction" || property.name == "slide_on_ceiling") {
property.usage = PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL; property.usage = PROPERTY_USAGE_NO_EDITOR;
} }
} else { } else {
if (property.name == "wall_min_slide_angle") { if (property.name == "wall_min_slide_angle") {
property.usage = PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL; property.usage = PROPERTY_USAGE_NO_EDITOR;
} }
} }
} }

View file

@ -612,25 +612,25 @@ void Area3D::_validate_property(PropertyInfo &property) const {
property.hint_string = options; property.hint_string = options;
} else if (property.name.begins_with("gravity") && property.name != "gravity_space_override") { } else if (property.name.begins_with("gravity") && property.name != "gravity_space_override") {
if (gravity_space_override == SPACE_OVERRIDE_DISABLED) { if (gravity_space_override == SPACE_OVERRIDE_DISABLED) {
property.usage = PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL; property.usage = PROPERTY_USAGE_NO_EDITOR;
} else { } else {
if (gravity_is_point) { if (gravity_is_point) {
if (property.name == "gravity_direction") { if (property.name == "gravity_direction") {
property.usage = PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL; property.usage = PROPERTY_USAGE_NO_EDITOR;
} }
} else { } else {
if (property.name.begins_with("gravity_point_")) { if (property.name.begins_with("gravity_point_")) {
property.usage = PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL; property.usage = PROPERTY_USAGE_NO_EDITOR;
} }
} }
} }
} else if (property.name.begins_with("linear_damp") && property.name != "linear_damp_space_override") { } else if (property.name.begins_with("linear_damp") && property.name != "linear_damp_space_override") {
if (linear_damp_space_override == SPACE_OVERRIDE_DISABLED) { if (linear_damp_space_override == SPACE_OVERRIDE_DISABLED) {
property.usage = PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL; property.usage = PROPERTY_USAGE_NO_EDITOR;
} }
} else if (property.name.begins_with("angular_damp") && property.name != "angular_damp_space_override") { } else if (property.name.begins_with("angular_damp") && property.name != "angular_damp_space_override") {
if (angular_damp_space_override == SPACE_OVERRIDE_DISABLED) { if (angular_damp_space_override == SPACE_OVERRIDE_DISABLED) {
property.usage = PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL; property.usage = PROPERTY_USAGE_NO_EDITOR;
} }
} }

View file

@ -1127,7 +1127,7 @@ void RigidDynamicBody3D::_bind_methods() {
void RigidDynamicBody3D::_validate_property(PropertyInfo &property) const { void RigidDynamicBody3D::_validate_property(PropertyInfo &property) const {
if (center_of_mass_mode != CENTER_OF_MASS_MODE_CUSTOM) { if (center_of_mass_mode != CENTER_OF_MASS_MODE_CUSTOM) {
if (property.name == "center_of_mass") { if (property.name == "center_of_mass") {
property.usage = PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL; property.usage = PROPERTY_USAGE_NO_EDITOR;
} }
} }
PhysicsBody3D::_validate_property(property); PhysicsBody3D::_validate_property(property);
@ -2025,7 +2025,7 @@ void CharacterBody3D::_bind_methods() {
void CharacterBody3D::_validate_property(PropertyInfo &property) const { void CharacterBody3D::_validate_property(PropertyInfo &property) const {
if (motion_mode == MOTION_MODE_FLOATING) { if (motion_mode == MOTION_MODE_FLOATING) {
if (property.name.begins_with("floor_") || property.name == "up_direction" || property.name == "slide_on_ceiling") { if (property.name.begins_with("floor_") || property.name == "up_direction" || property.name == "slide_on_ceiling") {
property.usage = PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL; property.usage = PROPERTY_USAGE_NO_EDITOR;
} }
} }
PhysicsBody3D::_validate_property(property); PhysicsBody3D::_validate_property(property);

View file

@ -179,9 +179,9 @@ AABB ReflectionProbe::get_aabb() const {
} }
void ReflectionProbe::_validate_property(PropertyInfo &property) const { void ReflectionProbe::_validate_property(PropertyInfo &property) const {
if (property.name == "interior/ambient_color" || property.name == "interior/ambient_color_energy") { if (property.name == "ambient_color" || property.name == "ambient_color_energy") {
if (ambient_mode != AMBIENT_COLOR) { if (ambient_mode != AMBIENT_COLOR) {
property.usage = PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL; property.usage = PROPERTY_USAGE_NO_EDITOR;
} }
} }
VisualInstance3D::_validate_property(property); VisualInstance3D::_validate_property(property);

View file

@ -1038,39 +1038,39 @@ void Environment::_update_adjustment() {
// Private methods, constructor and destructor // Private methods, constructor and destructor
void Environment::_validate_property(PropertyInfo &property) const { void Environment::_validate_property(PropertyInfo &property) const {
if (property.name == "sky" || property.name == "sky_custom_fov" || property.name == "sky_rotation" || property.name == "ambient_light/sky_contribution") { if (property.name == "sky" || property.name == "sky_custom_fov" || property.name == "sky_rotation" || property.name == "ambient_light_sky_contribution") {
if (bg_mode != BG_SKY && ambient_source != AMBIENT_SOURCE_SKY && reflection_source != REFLECTION_SOURCE_SKY) { if (bg_mode != BG_SKY && ambient_source != AMBIENT_SOURCE_SKY && reflection_source != REFLECTION_SOURCE_SKY) {
property.usage = PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL; property.usage = PROPERTY_USAGE_NO_EDITOR;
} }
} }
if (property.name == "fog_aerial_perspective") { if (property.name == "fog_aerial_perspective") {
if (bg_mode != BG_SKY) { if (bg_mode != BG_SKY) {
property.usage = PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL; property.usage = PROPERTY_USAGE_NO_EDITOR;
} }
} }
if (property.name == "tonemap_white" && tone_mapper == TONE_MAPPER_LINEAR) { if (property.name == "tonemap_white" && tone_mapper == TONE_MAPPER_LINEAR) {
property.usage = PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL; property.usage = PROPERTY_USAGE_NO_EDITOR;
} }
if (property.name == "glow_intensity" && glow_blend_mode == GLOW_BLEND_MODE_MIX) { if (property.name == "glow_intensity" && glow_blend_mode == GLOW_BLEND_MODE_MIX) {
property.usage = PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL; property.usage = PROPERTY_USAGE_NO_EDITOR;
} }
if (property.name == "glow_mix" && glow_blend_mode != GLOW_BLEND_MODE_MIX) { if (property.name == "glow_mix" && glow_blend_mode != GLOW_BLEND_MODE_MIX) {
property.usage = PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL; property.usage = PROPERTY_USAGE_NO_EDITOR;
} }
if (property.name == "background_color") { if (property.name == "background_color") {
if (bg_mode != BG_COLOR && ambient_source != AMBIENT_SOURCE_COLOR) { if (bg_mode != BG_COLOR && ambient_source != AMBIENT_SOURCE_COLOR) {
property.usage = PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL; property.usage = PROPERTY_USAGE_NO_EDITOR;
} }
} }
if (property.name == "background_canvas_max_layer") { if (property.name == "background_canvas_max_layer") {
if (bg_mode != BG_CANVAS) { if (bg_mode != BG_CANVAS) {
property.usage = PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL; property.usage = PROPERTY_USAGE_NO_EDITOR;
} }
} }
@ -1108,7 +1108,7 @@ void Environment::_validate_property(PropertyInfo &property) const {
String enabled = prefix + "enabled"; String enabled = prefix + "enabled";
if (property.name.begins_with(prefix) && property.name != enabled && !bool(get(enabled))) { if (property.name.begins_with(prefix) && property.name != enabled && !bool(get(enabled))) {
property.usage = PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL; property.usage = PROPERTY_USAGE_NO_EDITOR;
return; return;
} }
@ -1121,7 +1121,7 @@ void Environment::_validate_property(PropertyInfo &property) const {
String prefix = String(*prefixes); String prefix = String(*prefixes);
if (property.name.begins_with(prefix)) { if (property.name.begins_with(prefix)) {
property.usage = PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL; property.usage = PROPERTY_USAGE_NO_EDITOR;
return; return;
} }

View file

@ -614,8 +614,10 @@ void NavigationMesh::_bind_methods() {
ADD_GROUP("Geometry", "geometry_"); ADD_GROUP("Geometry", "geometry_");
ADD_PROPERTY(PropertyInfo(Variant::INT, "geometry_parsed_geometry_type", PROPERTY_HINT_ENUM, "Mesh Instances,Static Colliders,Both"), "set_parsed_geometry_type", "get_parsed_geometry_type"); ADD_PROPERTY(PropertyInfo(Variant::INT, "geometry_parsed_geometry_type", PROPERTY_HINT_ENUM, "Mesh Instances,Static Colliders,Both"), "set_parsed_geometry_type", "get_parsed_geometry_type");
ADD_PROPERTY(PropertyInfo(Variant::INT, "geometry_collision_mask", PROPERTY_HINT_LAYERS_3D_PHYSICS), "set_collision_mask", "get_collision_mask"); ADD_PROPERTY(PropertyInfo(Variant::INT, "geometry_collision_mask", PROPERTY_HINT_LAYERS_3D_PHYSICS), "set_collision_mask", "get_collision_mask");
ADD_PROPERTY_DEFAULT("geometry_collision_mask", 0xFFFFFFFF);
ADD_PROPERTY(PropertyInfo(Variant::INT, "geometry_source_geometry_mode", PROPERTY_HINT_ENUM, "NavMesh Children, Group With Children, Group Explicit"), "set_source_geometry_mode", "get_source_geometry_mode"); ADD_PROPERTY(PropertyInfo(Variant::INT, "geometry_source_geometry_mode", PROPERTY_HINT_ENUM, "NavMesh Children, Group With Children, Group Explicit"), "set_source_geometry_mode", "get_source_geometry_mode");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "geometry_source_group_name"), "set_source_group_name", "get_source_group_name"); ADD_PROPERTY(PropertyInfo(Variant::STRING, "geometry_source_group_name"), "set_source_group_name", "get_source_group_name");
ADD_PROPERTY_DEFAULT("geometry_source_group_name", StringName("navmesh"));
ADD_GROUP("Cells", "cell_"); ADD_GROUP("Cells", "cell_");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "cell_size", PROPERTY_HINT_RANGE, "0.01,500.0,0.01,or_greater,suffix:m"), "set_cell_size", "get_cell_size"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "cell_size", PROPERTY_HINT_RANGE, "0.01,500.0,0.01,or_greater,suffix:m"), "set_cell_size", "get_cell_size");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "cell_height", PROPERTY_HINT_RANGE, "0.01,500.0,0.01,or_greater,suffix:m"), "set_cell_height", "get_cell_height"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "cell_height", PROPERTY_HINT_RANGE, "0.01,500.0,0.01,or_greater,suffix:m"), "set_cell_height", "get_cell_height");
@ -659,14 +661,14 @@ void NavigationMesh::_bind_methods() {
} }
void NavigationMesh::_validate_property(PropertyInfo &property) const { void NavigationMesh::_validate_property(PropertyInfo &property) const {
if (property.name == "geometry/collision_mask") { if (property.name == "geometry_collision_mask") {
if (parsed_geometry_type == PARSED_GEOMETRY_MESH_INSTANCES) { if (parsed_geometry_type == PARSED_GEOMETRY_MESH_INSTANCES) {
property.usage = PROPERTY_USAGE_NONE; property.usage = PROPERTY_USAGE_NONE;
return; return;
} }
} }
if (property.name == "geometry/source_group_name") { if (property.name == "geometry_source_group_name") {
if (source_geometry_mode == SOURCE_GEOMETRY_NAVMESH_CHILDREN) { if (source_geometry_mode == SOURCE_GEOMETRY_NAVMESH_CHILDREN) {
property.usage = PROPERTY_USAGE_NONE; property.usage = PROPERTY_USAGE_NONE;
return; return;