Fix -new inspector- Inconsistencies with exported enums - Fixes remaining issues in #19534

This commit is contained in:
ordigdug 2018-07-12 15:18:08 -04:00
parent de910f8c26
commit afb4dfab22
1 changed files with 26 additions and 2 deletions

View File

@ -390,13 +390,37 @@ EditorPropertyCheck::EditorPropertyCheck() {
void EditorPropertyEnum::_option_selected(int p_which) {
emit_signal("property_changed", get_edited_property(), p_which);
String text = options->get_item_text(p_which);
Vector<String> text_split = text.split(":");
if (text_split.size() == 1) {
emit_signal("property_changed", get_edited_property(), p_which);
return;
}
String name = text_split[1];
emit_signal("property_changed", get_edited_property(), name.to_int());
}
void EditorPropertyEnum::update_property() {
int which = get_edited_object()->get(get_edited_property());
options->select(which);
if (which == 0) {
options->select(which);
return;
}
for (int i = 0; i < options->get_item_count(); i++) {
String text = options->get_item_text(i);
Vector<String> text_split = text.split(":");
if (text_split.size() == 1) {
options->select(which);
return;
}
String name = text_split[1];
if (itos(which) == name) {
options->select(i);
return;
}
}
}
void EditorPropertyEnum::setup(const Vector<String> &p_options) {