summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorA Thousand Ships <96648715+AThousandShips@users.noreply.github.com>2024-08-31 15:28:39 +0200
committerA Thousand Ships <96648715+AThousandShips@users.noreply.github.com>2024-09-12 16:05:11 +0200
commit7d8684fdb5d0dd1b146f3e6fc5eb454c25a8f1f4 (patch)
treea90798b0bb7573e390c4062bd3a6549b800c2514
parent83d54ab2ad476ae265b323c2b88f4623b922f4c6 (diff)
downloadredot-engine-7d8684fdb5d0dd1b146f3e6fc5eb454c25a8f1f4.tar.gz
[Editor] Merge duplicate entries in enum property inspector
This helps with confusion over how selecting a key with a duplicate value won't be selected as only the first entry with a particular value will be selected.
-rw-r--r--editor/editor_properties.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp
index 2e46068e07..0fb57ce40e 100644
--- a/editor/editor_properties.cpp
+++ b/editor/editor_properties.cpp
@@ -687,16 +687,21 @@ void EditorPropertyEnum::update_property() {
void EditorPropertyEnum::setup(const Vector<String> &p_options) {
options->clear();
+ HashMap<int64_t, Vector<String>> items;
int64_t current_val = 0;
- for (int i = 0; i < p_options.size(); i++) {
- Vector<String> text_split = p_options[i].split(":");
+ for (const String &option : p_options) {
+ Vector<String> text_split = option.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);
+ items[current_val].push_back(text_split[0]);
current_val += 1;
}
+
+ for (const KeyValue<int64_t, Vector<String>> &K : items) {
+ options->add_item(String(", ").join(K.value));
+ options->set_item_metadata(-1, K.key);
+ }
}
void EditorPropertyEnum::set_option_button_clip(bool p_enable) {