Removed unused property hints and Object::get_translatable_strings()

* Remove unused `EditorPropertyMember` and related hints, previouly used by
  VisualScript. Such logic should be implemented in the VS module itself.
* As the above broke compatibility with the VS module, clean up the other
  hacks that were still in core in support of VisualScript.
* `PROPERTY_USAGE_INTERNATIONALIZED` was only used in Object's
  `get_translatable_strings()`, which is a legacy function not used anywhere.
  So both are removed.
* Reordered some usage flags after the above removal to minimize the diff.
* General clean up.

Fixes #30203.

Co-authored-by: Rémi Verschelde <rverschelde@gmail.com>
This commit is contained in:
Juan Linietsky
2023-01-09 15:31:44 +01:00
committed by Rémi Verschelde
parent 964fc6e15d
commit 0e0a6bb39b
25 changed files with 112 additions and 429 deletions

View File

@@ -68,7 +68,7 @@ EditorPropertyNil::EditorPropertyNil() {
void EditorPropertyText::_set_read_only(bool p_read_only) {
text->set_editable(!p_read_only);
};
}
void EditorPropertyText::_text_submitted(const String &p_string) {
if (updating) {
@@ -133,7 +133,7 @@ EditorPropertyText::EditorPropertyText() {
void EditorPropertyMultilineText::_set_read_only(bool p_read_only) {
text->set_editable(!p_read_only);
open_big_text->set_disabled(p_read_only);
};
}
void EditorPropertyMultilineText::_big_text_changed() {
text->set_text(big_text->get_text());
@@ -236,7 +236,7 @@ EditorPropertyMultilineText::EditorPropertyMultilineText(bool p_expression) {
void EditorPropertyTextEnum::_set_read_only(bool p_read_only) {
option_button->set_disabled(p_read_only);
edit_button->set_disabled(p_read_only);
};
}
void EditorPropertyTextEnum::_emit_changed_value(String p_string) {
if (string_name) {
@@ -450,7 +450,7 @@ EditorPropertyLocale::EditorPropertyLocale() {
void EditorPropertyPath::_set_read_only(bool p_read_only) {
path->set_editable(!p_read_only);
path_edit->set_disabled(p_read_only);
};
}
void EditorPropertyPath::_path_selected(const String &p_path) {
emit_changed(get_edited_property(), p_path);
@@ -588,7 +588,7 @@ EditorPropertyPath::EditorPropertyPath() {
void EditorPropertyClassName::_set_read_only(bool p_read_only) {
property->set_disabled(p_read_only);
};
}
void EditorPropertyClassName::setup(const String &p_base_type, const String &p_selected_type) {
base_type = p_base_type;
@@ -629,112 +629,11 @@ EditorPropertyClassName::EditorPropertyClassName() {
add_child(dialog);
}
///////////////////// MEMBER /////////////////////////
void EditorPropertyMember::_set_read_only(bool p_read_only) {
property->set_disabled(p_read_only);
};
void EditorPropertyMember::_property_selected(const String &p_selected) {
emit_changed(get_edited_property(), p_selected);
update_property();
}
void EditorPropertyMember::_property_select() {
if (!selector) {
selector = memnew(PropertySelector);
selector->connect("selected", callable_mp(this, &EditorPropertyMember::_property_selected));
add_child(selector);
}
String current = get_edited_object()->get(get_edited_property());
if (hint == MEMBER_METHOD_OF_VARIANT_TYPE) {
Variant::Type type = Variant::NIL;
for (int i = 0; i < Variant::VARIANT_MAX; i++) {
if (hint_text == Variant::get_type_name(Variant::Type(i))) {
type = Variant::Type(i);
}
}
if (type != Variant::NIL) {
selector->select_method_from_basic_type(type, current);
}
} else if (hint == MEMBER_METHOD_OF_BASE_TYPE) {
selector->select_method_from_base_type(hint_text, current);
} else if (hint == MEMBER_METHOD_OF_INSTANCE) {
Object *instance = ObjectDB::get_instance(ObjectID(hint_text.to_int()));
if (instance) {
selector->select_method_from_instance(instance, current);
}
} else if (hint == MEMBER_METHOD_OF_SCRIPT) {
Object *obj = ObjectDB::get_instance(ObjectID(hint_text.to_int()));
if (Object::cast_to<Script>(obj)) {
selector->select_method_from_script(Object::cast_to<Script>(obj), current);
}
} else if (hint == MEMBER_PROPERTY_OF_VARIANT_TYPE) {
Variant::Type type = Variant::NIL;
String tname = hint_text;
if (tname.contains(".")) {
tname = tname.get_slice(".", 0);
}
for (int i = 0; i < Variant::VARIANT_MAX; i++) {
if (tname == Variant::get_type_name(Variant::Type(i))) {
type = Variant::Type(Variant::Type(i));
}
}
if (type != Variant::NIL) {
selector->select_property_from_basic_type(type, current);
}
} else if (hint == MEMBER_PROPERTY_OF_BASE_TYPE) {
selector->select_property_from_base_type(hint_text, current);
} else if (hint == MEMBER_PROPERTY_OF_INSTANCE) {
Object *instance = ObjectDB::get_instance(ObjectID(hint_text.to_int()));
if (instance) {
selector->select_property_from_instance(instance, current);
}
} else if (hint == MEMBER_PROPERTY_OF_SCRIPT) {
Object *obj = ObjectDB::get_instance(ObjectID(hint_text.to_int()));
if (Object::cast_to<Script>(obj)) {
selector->select_property_from_script(Object::cast_to<Script>(obj), current);
}
}
}
void EditorPropertyMember::setup(Type p_hint, const String &p_hint_text) {
hint = p_hint;
hint_text = p_hint_text;
}
void EditorPropertyMember::update_property() {
String full_path = get_edited_object()->get(get_edited_property());
property->set_text(full_path);
}
void EditorPropertyMember::_bind_methods() {
}
EditorPropertyMember::EditorPropertyMember() {
selector = nullptr;
property = memnew(Button);
property->set_clip_text(true);
add_child(property);
add_focusable(property);
property->connect("pressed", callable_mp(this, &EditorPropertyMember::_property_select));
}
///////////////////// CHECK /////////////////////////
void EditorPropertyCheck::_set_read_only(bool p_read_only) {
checkbox->set_disabled(p_read_only);
};
}
void EditorPropertyCheck::_checkbox_pressed() {
emit_changed(get_edited_property(), checkbox->is_pressed());
@@ -761,7 +660,7 @@ EditorPropertyCheck::EditorPropertyCheck() {
void EditorPropertyEnum::_set_read_only(bool p_read_only) {
options->set_disabled(p_read_only);
};
}
void EditorPropertyEnum::_option_selected(int p_which) {
int64_t val = options->get_item_metadata(p_which);
@@ -820,7 +719,7 @@ void EditorPropertyFlags::_set_read_only(bool p_read_only) {
for (CheckBox *check : flags) {
check->set_disabled(p_read_only);
}
};
}
void EditorPropertyFlags::_flag_toggled(int p_index) {
uint32_t value = get_edited_object()->get(get_edited_property());
@@ -1186,7 +1085,7 @@ void EditorPropertyLayers::_notification(int p_what) {
void EditorPropertyLayers::_set_read_only(bool p_read_only) {
button->set_disabled(p_read_only);
grid->set_read_only(p_read_only);
};
}
void EditorPropertyLayers::_grid_changed(uint32_t p_grid) {
emit_changed(get_edited_property(), p_grid);
@@ -1359,7 +1258,7 @@ EditorPropertyLayers::EditorPropertyLayers() {
void EditorPropertyInteger::_set_read_only(bool p_read_only) {
spin->set_read_only(p_read_only);
};
}
void EditorPropertyInteger::_value_changed(int64_t val) {
if (setting) {
@@ -1406,7 +1305,7 @@ EditorPropertyInteger::EditorPropertyInteger() {
void EditorPropertyObjectID::_set_read_only(bool p_read_only) {
edit->set_disabled(p_read_only);
};
}
void EditorPropertyObjectID::_edit_pressed() {
emit_signal(SNAME("object_id_selected"), get_edited_property(), get_edited_object()->get(get_edited_property()));
@@ -1496,7 +1395,7 @@ EditorPropertyCallable::EditorPropertyCallable() {
void EditorPropertyFloat::_set_read_only(bool p_read_only) {
spin->set_read_only(p_read_only);
};
}
void EditorPropertyFloat::_value_changed(double val) {
if (setting) {
@@ -1546,7 +1445,7 @@ EditorPropertyFloat::EditorPropertyFloat() {
void EditorPropertyEasing::_set_read_only(bool p_read_only) {
spin->set_read_only(p_read_only);
};
}
void EditorPropertyEasing::_drag_easing(const Ref<InputEvent> &p_ev) {
if (is_read_only()) {
@@ -1769,7 +1668,7 @@ void EditorPropertyVector2::_set_read_only(bool p_read_only) {
for (int i = 0; i < 2; i++) {
spin[i]->set_read_only(p_read_only);
}
};
}
void EditorPropertyVector2::_value_changed(double val, const String &p_name) {
if (setting) {
@@ -1900,7 +1799,7 @@ void EditorPropertyRect2::_set_read_only(bool p_read_only) {
for (int i = 0; i < 4; i++) {
spin[i]->set_read_only(p_read_only);
}
};
}
void EditorPropertyRect2::_value_changed(double val, const String &p_name) {
if (setting) {
@@ -2003,7 +1902,7 @@ void EditorPropertyVector3::_set_read_only(bool p_read_only) {
for (int i = 0; i < 3; i++) {
spin[i]->set_read_only(p_read_only);
}
};
}
void EditorPropertyVector3::_value_changed(double val, const String &p_name) {
if (setting) {
@@ -2182,7 +2081,7 @@ void EditorPropertyVector2i::_set_read_only(bool p_read_only) {
for (int i = 0; i < 2; i++) {
spin[i]->set_read_only(p_read_only);
}
};
}
void EditorPropertyVector2i::_value_changed(double val, const String &p_name) {
if (setting) {
@@ -2312,7 +2211,7 @@ void EditorPropertyRect2i::_set_read_only(bool p_read_only) {
for (int i = 0; i < 4; i++) {
spin[i]->set_read_only(p_read_only);
}
};
}
void EditorPropertyRect2i::_value_changed(double val, const String &p_name) {
if (setting) {
@@ -2414,7 +2313,7 @@ void EditorPropertyVector3i::_set_read_only(bool p_read_only) {
for (int i = 0; i < 3; i++) {
spin[i]->set_read_only(p_read_only);
}
};
}
void EditorPropertyVector3i::_value_changed(double val, const String &p_name) {
if (setting) {
@@ -2564,7 +2463,7 @@ void EditorPropertyPlane::_set_read_only(bool p_read_only) {
for (int i = 0; i < 4; i++) {
spin[i]->set_read_only(p_read_only);
}
};
}
void EditorPropertyPlane::_value_changed(double val, const String &p_name) {
if (setting) {
@@ -2660,7 +2559,7 @@ void EditorPropertyQuaternion::_set_read_only(bool p_read_only) {
for (int i = 0; i < 3; i++) {
euler[i]->set_read_only(p_read_only);
}
};
}
void EditorPropertyQuaternion::_edit_custom_value() {
if (edit_button->is_pressed()) {
@@ -2873,7 +2772,7 @@ void EditorPropertyVector4::_set_read_only(bool p_read_only) {
for (int i = 0; i < 4; i++) {
spin[i]->set_read_only(p_read_only);
}
};
}
void EditorPropertyVector4::_value_changed(double val, const String &p_name) {
if (setting) {
@@ -2963,7 +2862,7 @@ void EditorPropertyVector4i::_set_read_only(bool p_read_only) {
for (int i = 0; i < 4; i++) {
spin[i]->set_read_only(p_read_only);
}
};
}
void EditorPropertyVector4i::_value_changed(double val, const String &p_name) {
if (setting) {
@@ -3052,7 +2951,7 @@ void EditorPropertyAABB::_set_read_only(bool p_read_only) {
for (int i = 0; i < 6; i++) {
spin[i]->set_read_only(p_read_only);
}
};
}
void EditorPropertyAABB::_value_changed(double val, const String &p_name) {
if (setting) {
@@ -3135,7 +3034,7 @@ void EditorPropertyTransform2D::_set_read_only(bool p_read_only) {
for (int i = 0; i < 6; i++) {
spin[i]->set_read_only(p_read_only);
}
};
}
void EditorPropertyTransform2D::_value_changed(double val, const String &p_name) {
if (setting) {
@@ -3226,7 +3125,7 @@ void EditorPropertyBasis::_set_read_only(bool p_read_only) {
for (int i = 0; i < 9; i++) {
spin[i]->set_read_only(p_read_only);
}
};
}
void EditorPropertyBasis::_value_changed(double val, const String &p_name) {
if (setting) {
@@ -3316,7 +3215,7 @@ void EditorPropertyTransform3D::_set_read_only(bool p_read_only) {
for (int i = 0; i < 12; i++) {
spin[i]->set_read_only(p_read_only);
}
};
}
void EditorPropertyTransform3D::_value_changed(double val, const String &p_name) {
if (setting) {
@@ -3414,7 +3313,7 @@ void EditorPropertyProjection::_set_read_only(bool p_read_only) {
for (int i = 0; i < 12; i++) {
spin[i]->set_read_only(p_read_only);
}
};
}
void EditorPropertyProjection::_value_changed(double val, const String &p_name) {
if (setting) {
@@ -3517,7 +3416,7 @@ EditorPropertyProjection::EditorPropertyProjection() {
void EditorPropertyColor::_set_read_only(bool p_read_only) {
picker->set_disabled(p_read_only);
};
}
void EditorPropertyColor::_color_changed(const Color &p_color) {
// Cancel the color change if the current color is identical to the new one.
@@ -3819,7 +3718,7 @@ EditorPropertyRID::EditorPropertyRID() {
void EditorPropertyResource::_set_read_only(bool p_read_only) {
resource_picker->set_editable(!p_read_only);
};
}
void EditorPropertyResource::_resource_selected(const Ref<Resource> &p_resource, bool p_inspect) {
if (p_resource->is_built_in() && !p_resource->get_path().is_empty()) {
@@ -3928,12 +3827,10 @@ void EditorPropertyResource::_resource_changed(const Ref<Resource> &p_resource)
}
}
// Make visual script the correct type.
Ref<Script> s = p_resource;
// The bool is_script applies only to an object's main script.
// Changing the value of Script-type exported variables of the main script should not trigger saving/reloading properties.
bool is_script = false;
Ref<Script> s = p_resource;
if (get_edited_object() && s.is_valid() && get_edited_property() == CoreStringNames::get_singleton()->_script) {
is_script = true;
InspectorDock::get_singleton()->store_script_properties(get_edited_object());
@@ -4489,45 +4386,6 @@ EditorProperty *EditorInspectorDefaultPlugin::get_editor_for_property(Object *p_
editor->set_save_mode();
}
return editor;
} else if (p_hint == PROPERTY_HINT_METHOD_OF_VARIANT_TYPE ||
p_hint == PROPERTY_HINT_METHOD_OF_BASE_TYPE ||
p_hint == PROPERTY_HINT_METHOD_OF_INSTANCE ||
p_hint == PROPERTY_HINT_METHOD_OF_SCRIPT ||
p_hint == PROPERTY_HINT_PROPERTY_OF_VARIANT_TYPE ||
p_hint == PROPERTY_HINT_PROPERTY_OF_BASE_TYPE ||
p_hint == PROPERTY_HINT_PROPERTY_OF_INSTANCE ||
p_hint == PROPERTY_HINT_PROPERTY_OF_SCRIPT) {
EditorPropertyMember *editor = memnew(EditorPropertyMember);
EditorPropertyMember::Type type = EditorPropertyMember::MEMBER_METHOD_OF_BASE_TYPE;
switch (p_hint) {
case PROPERTY_HINT_METHOD_OF_BASE_TYPE:
type = EditorPropertyMember::MEMBER_METHOD_OF_BASE_TYPE;
break;
case PROPERTY_HINT_METHOD_OF_INSTANCE:
type = EditorPropertyMember::MEMBER_METHOD_OF_INSTANCE;
break;
case PROPERTY_HINT_METHOD_OF_SCRIPT:
type = EditorPropertyMember::MEMBER_METHOD_OF_SCRIPT;
break;
case PROPERTY_HINT_PROPERTY_OF_VARIANT_TYPE:
type = EditorPropertyMember::MEMBER_PROPERTY_OF_VARIANT_TYPE;
break;
case PROPERTY_HINT_PROPERTY_OF_BASE_TYPE:
type = EditorPropertyMember::MEMBER_PROPERTY_OF_BASE_TYPE;
break;
case PROPERTY_HINT_PROPERTY_OF_INSTANCE:
type = EditorPropertyMember::MEMBER_PROPERTY_OF_INSTANCE;
break;
case PROPERTY_HINT_PROPERTY_OF_SCRIPT:
type = EditorPropertyMember::MEMBER_PROPERTY_OF_SCRIPT;
break;
default: {
}
}
editor->setup(type, p_hint_text);
return editor;
} else {
EditorPropertyText *editor = memnew(EditorPropertyText);
if (p_hint == PROPERTY_HINT_PLACEHOLDER_TEXT) {