summaryrefslogtreecommitdiff
path: root/editor/property_editor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/property_editor.cpp')
-rw-r--r--editor/property_editor.cpp35
1 files changed, 16 insertions, 19 deletions
diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp
index d45ee1eae1..07312e42b4 100644
--- a/editor/property_editor.cpp
+++ b/editor/property_editor.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -251,7 +251,7 @@ void CustomPropertyEditor::_menu_option(int p_which) {
emit_signal("variant_changed");
break;
}
- ERR_FAIL_COND(inheritors_array.empty());
+ ERR_FAIL_COND(inheritors_array.is_empty());
String intype = inheritors_array[p_which - TYPE_BASE_ID];
@@ -262,7 +262,7 @@ void CustomPropertyEditor::_menu_option(int p_which) {
return;
}
- Object *obj = ClassDB::instance(intype);
+ Variant obj = ClassDB::instance(intype);
if (!obj) {
if (ScriptServer::is_global_class(intype)) {
@@ -280,7 +280,7 @@ void CustomPropertyEditor::_menu_option(int p_which) {
res->call("set_instance_base_type", owner->get_class());
}
- v = res;
+ v = obj;
emit_signal("variant_changed");
} break;
@@ -367,18 +367,18 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
int c = hint_text.get_slice_count(",");
float min = 0, max = 100, step = type == Variant::FLOAT ? .01 : 1;
if (c >= 1) {
- if (!hint_text.get_slice(",", 0).empty()) {
+ if (!hint_text.get_slice(",", 0).is_empty()) {
min = hint_text.get_slice(",", 0).to_float();
}
}
if (c >= 2) {
- if (!hint_text.get_slice(",", 1).empty()) {
+ if (!hint_text.get_slice(",", 1).is_empty()) {
max = hint_text.get_slice(",", 1).to_float();
}
}
if (c >= 3) {
- if (!hint_text.get_slice(",", 2).empty()) {
+ if (!hint_text.get_slice(",", 2).is_empty()) {
step = hint_text.get_slice(",", 2).to_float();
}
}
@@ -882,7 +882,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
bool is_custom_resource = false;
Ref<Texture2D> icon;
- if (!custom_resources.empty()) {
+ if (!custom_resources.is_empty()) {
for (int k = 0; k < custom_resources.size(); k++) {
if (custom_resources[k].name == t) {
is_custom_resource = true;
@@ -1064,7 +1064,7 @@ void CustomPropertyEditor::_type_create_selected(int p_idx) {
String intype = inheritors_array[p_idx];
- Object *obj = ClassDB::instance(intype);
+ Variant obj = ClassDB::instance(intype);
if (!obj) {
if (ScriptServer::is_global_class(intype)) {
@@ -1075,11 +1075,9 @@ void CustomPropertyEditor::_type_create_selected(int p_idx) {
}
ERR_FAIL_COND(!obj);
+ ERR_FAIL_COND(!Object::cast_to<Resource>(obj));
- Resource *res = Object::cast_to<Resource>(obj);
- ERR_FAIL_COND(!res);
-
- v = res;
+ v = obj;
emit_signal("variant_changed");
hide();
}
@@ -1246,12 +1244,12 @@ void CustomPropertyEditor::_action_pressed(int p_which) {
} break;
case Variant::OBJECT: {
if (p_which == 0) {
- ERR_FAIL_COND(inheritors_array.empty());
+ ERR_FAIL_COND(inheritors_array.is_empty());
String intype = inheritors_array[0];
if (hint == PROPERTY_HINT_RESOURCE_TYPE) {
- Object *obj = ClassDB::instance(intype);
+ Variant obj = ClassDB::instance(intype);
if (!obj) {
if (ScriptServer::is_global_class(intype)) {
@@ -1262,10 +1260,9 @@ void CustomPropertyEditor::_action_pressed(int p_which) {
}
ERR_BREAK(!obj);
- Resource *res = Object::cast_to<Resource>(obj);
- ERR_BREAK(!res);
+ ERR_BREAK(!Object::cast_to<Resource>(obj));
- v = res;
+ v = obj;
emit_signal("variant_changed");
hide();
}