Merge pull request #36202 from YeldhamDev/sprite_region_hide

Hide extra options from various nodes if they're not enabled
This commit is contained in:
Rémi Verschelde 2021-03-02 14:15:25 +01:00 committed by GitHub
commit 5895cd4c4f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 87 additions and 7 deletions

View File

@ -60,7 +60,7 @@
If [code]true[/code], texture is cut from a larger atlas texture. See [member region_rect].
</member>
<member name="region_filter_clip" type="bool" setter="set_region_filter_clip" getter="is_region_filter_clip_enabled" default="false">
If [code]true[/code], the outermost pixels get blurred out.
If [code]true[/code], the outermost pixels get blurred out. [member region_enabled] must be [code]true[/code].
</member>
<member name="region_rect" type="Rect2" setter="set_region_rect" getter="get_region_rect" default="Rect2( 0, 0, 0, 0 )">
The region of the atlas texture to display. [member region_enabled] must be [code]true[/code].

View File

@ -88,6 +88,12 @@ bool Polygon2D::_edit_is_selected_on_click(const Point2 &p_point, double p_toler
}
return Geometry2D::is_point_in_polygon(p_point - get_offset(), polygon2d);
}
void Polygon2D::_validate_property(PropertyInfo &property) const {
if (!invert && property.name == "invert_border") {
property.usage = PROPERTY_USAGE_NOEDITOR;
}
}
#endif
void Polygon2D::_skeleton_bone_setup_changed() {
@ -455,6 +461,7 @@ Size2 Polygon2D::get_texture_scale() const {
void Polygon2D::set_invert(bool p_invert) {
invert = p_invert;
update();
notify_property_list_changed();
}
bool Polygon2D::get_invert() const {

View File

@ -72,6 +72,10 @@ class Polygon2D : public Node2D {
void _skeleton_bone_setup_changed();
#ifdef TOOLS_ENABLED
void _validate_property(PropertyInfo &property) const override;
#endif
protected:
void _notification(int p_what);
static void _bind_methods();

View File

@ -206,6 +206,7 @@ void Sprite2D::set_region(bool p_region) {
region = p_region;
update();
notify_property_list_changed();
}
bool Sprite2D::is_region() const {
@ -383,6 +384,10 @@ void Sprite2D::_validate_property(PropertyInfo &property) const {
if (property.name == "frame_coords") {
property.usage |= PROPERTY_USAGE_KEYING_INCREMENTS;
}
if (!region && (property.name == "region_rect" || property.name == "region_filter_clip")) {
property.usage = PROPERTY_USAGE_NOEDITOR;
}
}
void Sprite2D::_texture_changed() {

View File

@ -109,6 +109,7 @@ Color Decal::get_modulate() const {
void Decal::set_enable_distance_fade(bool p_enable) {
distance_fade_enabled = p_enable;
RS::get_singleton()->decal_set_distance_fade(decal, distance_fade_enabled, distance_fade_begin, distance_fade_length);
notify_property_list_changed();
}
bool Decal::is_distance_fade_enabled() const {
@ -153,6 +154,14 @@ Vector<Face3> Decal::get_faces(uint32_t p_usage_flags) const {
return Vector<Face3>();
}
#ifdef TOOLS_ENABLED
void Decal::_validate_property(PropertyInfo &property) const {
if (!distance_fade_enabled && (property.name == "distance_fade_begin" || property.name == "distance_fade_length")) {
property.usage = PROPERTY_USAGE_NOEDITOR;
}
}
#endif
void Decal::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_extents", "extents"), &Decal::set_extents);
ClassDB::bind_method(D_METHOD("get_extents"), &Decal::get_extents);

View File

@ -62,6 +62,10 @@ private:
float distance_fade_begin = 10.0;
float distance_fade_length = 1.0;
#ifdef TOOLS_ENABLED
void _validate_property(PropertyInfo &property) const override;
#endif
protected:
static void _bind_methods();

View File

@ -65,6 +65,8 @@ void Light3D::set_shadow(bool p_enable) {
if (type == RenderingServer::LIGHT_SPOT || type == RenderingServer::LIGHT_OMNI) {
update_configuration_warning();
}
notify_property_list_changed();
}
bool Light3D::has_shadow() const {
@ -202,6 +204,10 @@ bool Light3D::is_editor_only() const {
}
void Light3D::_validate_property(PropertyInfo &property) const {
if (!shadow && (property.name == "shadow_color" || property.name == "shadow_color" || property.name == "shadow_bias" || property.name == "shadow_normal_bias" || property.name == "shadow_reverse_cull_face" || property.name == "shadow_transmittance_bias" || property.name == "shadow_blur")) {
property.usage = PROPERTY_USAGE_NOEDITOR;
}
if (get_light_type() == RS::LIGHT_DIRECTIONAL && property.name == "light_size") {
property.usage = 0;
}

View File

@ -518,6 +518,7 @@ void Sprite3D::set_region(bool p_region) {
region = p_region;
_queue_update();
notify_property_list_changed();
}
bool Sprite3D::is_region() const {
@ -623,6 +624,12 @@ void Sprite3D::_validate_property(PropertyInfo &property) const {
if (property.name == "frame_coords") {
property.usage |= PROPERTY_USAGE_KEYING_INCREMENTS;
}
#ifdef TOOLS_ENABLED
if (!region && property.name == "region_rect") {
property.usage = PROPERTY_USAGE_NOEDITOR;
}
#endif
}
void Sprite3D::_bind_methods() {

View File

@ -231,6 +231,7 @@ void CanvasLayer::set_follow_viewport(bool p_enable) {
follow_viewport = p_enable;
_update_follow_viewport();
notify_property_list_changed();
}
bool CanvasLayer::is_following_viewport() const {
@ -257,6 +258,14 @@ void CanvasLayer::_update_follow_viewport(bool p_force_exit) {
}
}
#ifdef TOOLS_ENABLED
void CanvasLayer::_validate_property(PropertyInfo &property) const {
if (!follow_viewport && property.name == "follow_viewport_scale") {
property.usage = PROPERTY_USAGE_NOEDITOR;
}
}
#endif
void CanvasLayer::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_layer", "layer"), &CanvasLayer::set_layer);
ClassDB::bind_method(D_METHOD("get_layer"), &CanvasLayer::get_layer);

View File

@ -61,6 +61,10 @@ class CanvasLayer : public Node {
void _update_locrotscale();
void _update_follow_viewport(bool p_force_exit = false);
#ifdef TOOLS_ENABLED
void _validate_property(PropertyInfo &property) const override;
#endif
protected:
void _notification(int p_what);
static void _bind_methods();

View File

@ -120,6 +120,7 @@ void CameraEffects::_update_dof_blur() {
void CameraEffects::set_override_exposure_enabled(bool p_enabled) {
override_exposure_enabled = p_enabled;
_update_override_exposure();
notify_property_list_changed();
}
bool CameraEffects::is_override_exposure_enabled() const {
@ -144,6 +145,16 @@ void CameraEffects::_update_override_exposure() {
// Private methods, constructor and destructor
#ifdef TOOLS_ENABLED
void CameraEffects::_validate_property(PropertyInfo &property) const {
if ((!dof_blur_far_enabled && (property.name == "dof_blur_far_distance" || property.name == "dof_blur_far_transition")) ||
(!dof_blur_near_enabled && (property.name == "dof_blur_near_distance" || property.name == "dof_blur_near_transition")) ||
(!override_exposure_enabled && property.name == "override_exposure")) {
property.usage = PROPERTY_USAGE_NOEDITOR;
}
}
#endif
void CameraEffects::_bind_methods() {
// DOF blur

View File

@ -57,6 +57,10 @@ private:
float override_exposure = 1.0;
void _update_override_exposure();
#ifdef TOOLS_ENABLED
void _validate_property(PropertyInfo &property) const override;
#endif
protected:
static void _bind_methods();

View File

@ -441,6 +441,7 @@ void Environment::_update_ssao() {
void Environment::set_sdfgi_enabled(bool p_enabled) {
sdfgi_enabled = p_enabled;
_update_sdfgi();
notify_property_list_changed();
}
bool Environment::is_sdfgi_enabled() const {
@ -983,6 +984,7 @@ void Environment::_validate_property(PropertyInfo &property) const {
"auto_exposure_",
"ss_reflections_",
"ssao_",
"sdfgi_",
"glow_",
"adjustment_",
nullptr

View File

@ -1584,7 +1584,7 @@ void BaseMaterial3D::set_flag(Flags p_flag, bool p_enabled) {
}
flags[p_flag] = p_enabled;
if (p_flag == FLAG_USE_SHADOW_TO_OPACITY || p_flag == FLAG_USE_TEXTURE_REPEAT || p_flag == FLAG_SUBSURFACE_MODE_SKIN) {
if (p_flag == FLAG_USE_SHADOW_TO_OPACITY || p_flag == FLAG_USE_TEXTURE_REPEAT || p_flag == FLAG_SUBSURFACE_MODE_SKIN || p_flag == FLAG_USE_POINT_SIZE) {
notify_property_list_changed();
}
_queue_shader_change();
@ -1650,7 +1650,7 @@ BaseMaterial3D::TextureFilter BaseMaterial3D::get_texture_filter() const {
void BaseMaterial3D::_validate_feature(const String &text, Feature feature, PropertyInfo &property) const {
if (property.name.begins_with(text) && property.name != text + "_enabled" && !features[feature]) {
property.usage = 0;
property.usage = PROPERTY_USAGE_NOEDITOR;
}
}
@ -1683,16 +1683,24 @@ void BaseMaterial3D::_validate_property(PropertyInfo &property) const {
property.usage = 0;
}
if (property.name == "params_grow_amount" && !grow_enabled) {
property.usage = 0;
if (property.name == "billboard_keep_scale" && billboard_mode == BILLBOARD_DISABLED) {
property.usage = PROPERTY_USAGE_NOEDITOR;
}
if (property.name == "grow_amount" && !grow_enabled) {
property.usage = PROPERTY_USAGE_NOEDITOR;
}
if (property.name == "point_size" && !flags[FLAG_USE_POINT_SIZE]) {
property.usage = PROPERTY_USAGE_NOEDITOR;
}
if (property.name == "proximity_fade_distance" && !proximity_fade_enabled) {
property.usage = 0;
property.usage = PROPERTY_USAGE_NOEDITOR;
}
if ((property.name == "distance_fade_max_distance" || property.name == "distance_fade_min_distance") && distance_fade == DISTANCE_FADE_DISABLED) {
property.usage = 0;
property.usage = PROPERTY_USAGE_NOEDITOR;
}
// you can only enable anti-aliasing (in mataerials) on alpha scissor and alpha hash