Merge pull request #22885 from neikeq/issue-22122
Hide numeric value for constants in EditorPropertyEnum
This commit is contained in:
commit
5d4a073e98
@ -477,33 +477,16 @@ EditorPropertyCheck::EditorPropertyCheck() {
|
|||||||
|
|
||||||
void EditorPropertyEnum::_option_selected(int p_which) {
|
void EditorPropertyEnum::_option_selected(int p_which) {
|
||||||
|
|
||||||
String text = options->get_item_text(p_which);
|
int val = options->get_item_metadata(p_which);
|
||||||
Vector<String> text_split = text.split(":");
|
emit_signal("property_changed", get_edited_property(), val);
|
||||||
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() {
|
void EditorPropertyEnum::update_property() {
|
||||||
|
|
||||||
int which = get_edited_object()->get(get_edited_property());
|
int which = get_edited_object()->get(get_edited_property());
|
||||||
if (which == 0) {
|
|
||||||
options->select(which);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < options->get_item_count(); i++) {
|
for (int i = 0; i < options->get_item_count(); i++) {
|
||||||
String text = options->get_item_text(i);
|
if (which == (int)options->get_item_metadata(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);
|
options->select(i);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -511,8 +494,15 @@ void EditorPropertyEnum::update_property() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void EditorPropertyEnum::setup(const Vector<String> &p_options) {
|
void EditorPropertyEnum::setup(const Vector<String> &p_options) {
|
||||||
|
|
||||||
|
int current_val = 0;
|
||||||
for (int i = 0; i < p_options.size(); i++) {
|
for (int i = 0; i < p_options.size(); i++) {
|
||||||
options->add_item(p_options[i], i);
|
Vector<String> text_split = p_options[i].split(":");
|
||||||
|
if (text_split.size() != 1)
|
||||||
|
current_val = text_split[1].to_int();
|
||||||
|
options->add_item(text_split[0]);
|
||||||
|
options->set_item_metadata(i, current_val);
|
||||||
|
current_val += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ void CustomPropertyEditor::_menu_option(int p_which) {
|
|||||||
emit_signal("variant_changed");
|
emit_signal("variant_changed");
|
||||||
} else if (hint == PROPERTY_HINT_ENUM) {
|
} else if (hint == PROPERTY_HINT_ENUM) {
|
||||||
|
|
||||||
v = p_which;
|
v = menu->get_item_metadata(p_which);
|
||||||
emit_signal("variant_changed");
|
emit_signal("variant_changed");
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
@ -427,12 +427,14 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
|
|||||||
} else if (hint == PROPERTY_HINT_ENUM) {
|
} else if (hint == PROPERTY_HINT_ENUM) {
|
||||||
|
|
||||||
Vector<String> options = hint_text.split(",");
|
Vector<String> options = hint_text.split(",");
|
||||||
|
int current_val = 0;
|
||||||
for (int i = 0; i < options.size(); i++) {
|
for (int i = 0; i < options.size(); i++) {
|
||||||
if (options[i].find(":") != -1) {
|
Vector<String> text_split = options[i].split(":");
|
||||||
menu->add_item(options[i].get_slicec(':', 0), options[i].get_slicec(':', 1).to_int());
|
if (text_split.size() != 1)
|
||||||
} else {
|
current_val = text_split[1].to_int();
|
||||||
menu->add_item(options[i], i);
|
menu->add_item(text_split[0]);
|
||||||
}
|
menu->set_item_metadata(i, current_val);
|
||||||
|
current_val += 1;
|
||||||
}
|
}
|
||||||
menu->set_position(get_position());
|
menu->set_position(get_position());
|
||||||
menu->popup();
|
menu->popup();
|
||||||
|
Loading…
Reference in New Issue
Block a user