mirror of
https://github.com/godotengine/godot.git
synced 2026-01-03 18:11:19 +03:00
Compile out editor-only logic within validate_property in games
This commit is contained in:
@@ -458,7 +458,7 @@ void Control::_get_property_list(List<PropertyInfo> *p_list) const {
|
||||
|
||||
void Control::_validate_property(PropertyInfo &p_property) const {
|
||||
// Update theme type variation options.
|
||||
if (p_property.name == "theme_type_variation") {
|
||||
if (Engine::get_singleton()->is_editor_hint() && p_property.name == "theme_type_variation") {
|
||||
List<StringName> names;
|
||||
|
||||
ThemeDB::get_singleton()->get_default_theme()->get_type_variation_list(get_class_name(), &names);
|
||||
@@ -505,20 +505,19 @@ void Control::_validate_property(PropertyInfo &p_property) const {
|
||||
p_property.hint_string = hint_string;
|
||||
}
|
||||
|
||||
if (p_property.name == "mouse_force_pass_scroll_events") {
|
||||
if (Engine::get_singleton()->is_editor_hint() && p_property.name == "mouse_force_pass_scroll_events") {
|
||||
// Disable force pass if the control is not stopping the event.
|
||||
if (data.mouse_filter != MOUSE_FILTER_STOP) {
|
||||
p_property.usage |= PROPERTY_USAGE_READ_ONLY;
|
||||
}
|
||||
}
|
||||
|
||||
if (p_property.name == "scale") {
|
||||
if (Engine::get_singleton()->is_editor_hint() && p_property.name == "scale") {
|
||||
p_property.hint = PROPERTY_HINT_LINK;
|
||||
}
|
||||
|
||||
// Validate which positioning properties should be displayed depending on the parent and the layout mode.
|
||||
Control *parent_control = get_parent_control();
|
||||
if (!parent_control) {
|
||||
if (Engine::get_singleton()->is_editor_hint() && !parent_control) {
|
||||
// If there is no parent control, display both anchor and container options.
|
||||
|
||||
// Set the layout mode to be disabled with the proper value.
|
||||
@@ -538,11 +537,11 @@ void Control::_validate_property(PropertyInfo &p_property) const {
|
||||
p_property.usage ^= PROPERTY_USAGE_DEFAULT;
|
||||
} else if (p_property.name == "position" || p_property.name == "rotation" || p_property.name == "scale" || p_property.name == "size" || p_property.name == "pivot_offset") {
|
||||
p_property.usage = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_READ_ONLY;
|
||||
} else if (p_property.name == "layout_mode") {
|
||||
} else if (Engine::get_singleton()->is_editor_hint() && p_property.name == "layout_mode") {
|
||||
// Set the layout mode to be disabled with the proper value.
|
||||
p_property.hint_string = "Position,Anchors,Container,Uncontrolled";
|
||||
p_property.usage |= PROPERTY_USAGE_READ_ONLY;
|
||||
} else if (p_property.name == "size_flags_horizontal" || p_property.name == "size_flags_vertical") {
|
||||
} else if (Engine::get_singleton()->is_editor_hint() && (p_property.name == "size_flags_horizontal" || p_property.name == "size_flags_vertical")) {
|
||||
// Filter allowed size flags based on the parent container configuration.
|
||||
Container *parent_container = Object::cast_to<Container>(parent_control);
|
||||
Vector<int> size_flags;
|
||||
@@ -583,7 +582,7 @@ void Control::_validate_property(PropertyInfo &p_property) const {
|
||||
p_property.hint_string = hint_string;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
} else if (Engine::get_singleton()->is_editor_hint()) {
|
||||
// If the parent is a non-container control, display only anchoring-related properties.
|
||||
if (p_property.name.begins_with("size_flags_")) {
|
||||
p_property.usage ^= PROPERTY_USAGE_EDITOR;
|
||||
@@ -604,7 +603,9 @@ void Control::_validate_property(PropertyInfo &p_property) const {
|
||||
p_property.usage ^= PROPERTY_USAGE_EDITOR;
|
||||
}
|
||||
}
|
||||
|
||||
if (!Engine::get_singleton()->is_editor_hint()) {
|
||||
return;
|
||||
}
|
||||
// Disable the property if it's managed by the parent container.
|
||||
if (!Object::cast_to<Container>(parent_control)) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user