Skip to content

Commit

Permalink
Merge pull request godotengine#20117 from ordigdug/inspector-fix-inco…
Browse files Browse the repository at this point in the history
…nsistencies-with-exported-enums

Fix -new inspector- Inconsistencies with exported enums - Fixes remai…
  • Loading branch information
akien-mga authored Jul 19, 2018
2 parents aea6f48 + afb4dfa commit 76bfe14
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions editor/editor_properties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,13 +392,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) {
Expand Down

0 comments on commit 76bfe14

Please sign in to comment.