mirror of
https://github.com/Redot-Engine/redot-engine.git
synced 2025-12-06 07:17:42 -05:00
Compile out editor-only logic within validate_property in games
This commit is contained in:
@@ -116,7 +116,12 @@ void AnimatedSprite2D::_validate_property(PropertyInfo &p_property) const {
|
||||
if (frames.is_null()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Engine::get_singleton()->is_editor_hint()) {
|
||||
if (p_property.name == "frame" && playing) {
|
||||
p_property.usage = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_READ_ONLY;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (p_property.name == "animation") {
|
||||
List<StringName> names;
|
||||
frames->get_animation_list(&names);
|
||||
|
||||
@@ -80,6 +80,9 @@ BackBufferCopy::CopyMode BackBufferCopy::get_copy_mode() const {
|
||||
}
|
||||
|
||||
void BackBufferCopy::_validate_property(PropertyInfo &p_property) const {
|
||||
if (!Engine::get_singleton()->is_editor_hint()) {
|
||||
return;
|
||||
}
|
||||
if (copy_mode != COPY_MODE_RECT && p_property.name == "rect") {
|
||||
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
|
||||
}
|
||||
|
||||
@@ -616,7 +616,7 @@ void CPUParticles2D::request_particles_process(real_t p_requested_process_time)
|
||||
}
|
||||
|
||||
void CPUParticles2D::_validate_property(PropertyInfo &p_property) const {
|
||||
if (p_property.name == "emitting") {
|
||||
if (Engine::get_singleton()->is_editor_hint() && p_property.name == "emitting") {
|
||||
p_property.hint = one_shot ? PROPERTY_HINT_ONESHOT : PROPERTY_HINT_NONE;
|
||||
}
|
||||
|
||||
|
||||
@@ -431,7 +431,7 @@ void GPUParticles2D::_validate_property(PropertyInfo &p_property) const {
|
||||
if (p_property.name == "seed" && !use_fixed_seed) {
|
||||
p_property.usage = PROPERTY_USAGE_NONE;
|
||||
}
|
||||
if (p_property.name == "emitting") {
|
||||
if (Engine::get_singleton()->is_editor_hint() && p_property.name == "emitting") {
|
||||
p_property.hint = one_shot ? PROPERTY_HINT_ONESHOT : PROPERTY_HINT_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -243,6 +243,9 @@ real_t Light2D::get_shadow_smooth() const {
|
||||
}
|
||||
|
||||
void Light2D::_validate_property(PropertyInfo &p_property) const {
|
||||
if (!Engine::get_singleton()->is_editor_hint()) {
|
||||
return;
|
||||
}
|
||||
if (shadow && p_property.name == "shadow_filter_smooth" && shadow_filter == SHADOW_FILTER_NONE) {
|
||||
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
|
||||
}
|
||||
|
||||
@@ -364,6 +364,9 @@ bool PathFollow2D::is_cubic_interpolation_enabled() const {
|
||||
}
|
||||
|
||||
void PathFollow2D::_validate_property(PropertyInfo &p_property) const {
|
||||
if (!Engine::get_singleton()->is_editor_hint()) {
|
||||
return;
|
||||
}
|
||||
if (p_property.name == "offset") {
|
||||
real_t max = 10000.0;
|
||||
if (path && path->get_curve().is_valid()) {
|
||||
|
||||
@@ -541,6 +541,9 @@ StringName Area2D::get_audio_bus_name() const {
|
||||
}
|
||||
|
||||
void Area2D::_validate_property(PropertyInfo &p_property) const {
|
||||
if (!Engine::get_singleton()->is_editor_hint()) {
|
||||
return;
|
||||
}
|
||||
if (p_property.name == "audio_bus_name") {
|
||||
String options;
|
||||
for (int i = 0; i < AudioServer::get_singleton()->get_bus_count(); i++) {
|
||||
|
||||
@@ -646,6 +646,9 @@ void CharacterBody2D::_notification(int p_what) {
|
||||
}
|
||||
|
||||
void CharacterBody2D::_validate_property(PropertyInfo &p_property) const {
|
||||
if (!Engine::get_singleton()->is_editor_hint()) {
|
||||
return;
|
||||
}
|
||||
if (motion_mode == MOTION_MODE_FLOATING) {
|
||||
if (p_property.name.begins_with("floor_") || p_property.name == "up_direction" || p_property.name == "slide_on_ceiling") {
|
||||
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
|
||||
|
||||
@@ -790,6 +790,9 @@ void RigidBody2D::_bind_methods() {
|
||||
}
|
||||
|
||||
void RigidBody2D::_validate_property(PropertyInfo &p_property) const {
|
||||
if (!Engine::get_singleton()->is_editor_hint()) {
|
||||
return;
|
||||
}
|
||||
if (center_of_mass_mode != CENTER_OF_MASS_MODE_CUSTOM && p_property.name == "center_of_mass") {
|
||||
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
|
||||
}
|
||||
|
||||
@@ -461,6 +461,9 @@ Rect2 Sprite2D::get_rect() const {
|
||||
}
|
||||
|
||||
void Sprite2D::_validate_property(PropertyInfo &p_property) const {
|
||||
if (!Engine::get_singleton()->is_editor_hint()) {
|
||||
return;
|
||||
}
|
||||
if (p_property.name == "frame") {
|
||||
p_property.hint = PROPERTY_HINT_RANGE;
|
||||
p_property.hint_string = "0," + itos(vframes * hframes - 1) + ",1";
|
||||
|
||||
@@ -2203,6 +2203,9 @@ void TileMapLayer::_bind_methods() {
|
||||
}
|
||||
|
||||
void TileMapLayer::_validate_property(PropertyInfo &p_property) const {
|
||||
if (!Engine::get_singleton()->is_editor_hint()) {
|
||||
return;
|
||||
}
|
||||
if (is_y_sort_enabled()) {
|
||||
if (p_property.name == "rendering_quadrant_size") {
|
||||
p_property.usage |= PROPERTY_USAGE_READ_ONLY;
|
||||
|
||||
Reference in New Issue
Block a user