diff options
Diffstat (limited to 'editor/editor_properties.cpp')
-rw-r--r-- | editor/editor_properties.cpp | 51 |
1 files changed, 30 insertions, 21 deletions
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index b7910a152e..d78fee6ad6 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -52,7 +52,7 @@ void EditorPropertyNil::update_property() { EditorPropertyNil::EditorPropertyNil() { Label *label = memnew(Label); - label->set_text("[null]"); + label->set_text("<null>"); add_child(label); } @@ -832,26 +832,35 @@ void EditorPropertyFlags::setup(const Vector<String> &p_options) { bool first = true; uint32_t current_val; for (int i = 0; i < p_options.size(); i++) { + // An empty option is not considered a "flag". String option = p_options[i].strip_edges(); - if (!option.is_empty()) { - CheckBox *cb = memnew(CheckBox); - cb->set_text(option); - cb->set_clip_text(true); - cb->connect("pressed", callable_mp(this, &EditorPropertyFlags::_flag_toggled).bind(i)); - add_focusable(cb); - vbox->add_child(cb); - flags.push_back(cb); - Vector<String> text_split = p_options[i].split(":"); - if (text_split.size() != 1) { - current_val = text_split[1].to_int(); - } else { - current_val = 1 << i; - } - flag_values.push_back(current_val); - if (first) { - set_label_reference(cb); - first = false; - } + if (option.is_empty()) { + continue; + } + const int flag_index = flags.size(); // Index of the next element (added by the code below). + + // Value for a flag can be explicitly overridden. + Vector<String> text_split = p_options[i].split(":"); + if (text_split.size() != 1) { + current_val = text_split[1].to_int(); + } else { + current_val = 1 << i; + } + flag_values.push_back(current_val); + + // Create a CheckBox for the current flag. + CheckBox *cb = memnew(CheckBox); + cb->set_text(option); + cb->set_clip_text(true); + cb->connect("pressed", callable_mp(this, &EditorPropertyFlags::_flag_toggled).bind(flag_index)); + add_focusable(cb); + vbox->add_child(cb); + flags.push_back(cb); + + // Can't use `i == 0` because we want to find the first none-empty option. + if (first) { + set_label_reference(cb); + first = false; } } } @@ -1382,7 +1391,7 @@ void EditorPropertyObjectID::update_property() { edit->set_disabled(false); edit->set_icon(EditorNode::get_singleton()->get_class_icon(type)); } else { - edit->set_text(TTR("[Empty]")); + edit->set_text(TTR("<empty>")); edit->set_disabled(true); edit->set_icon(Ref<Texture2D>()); } |