diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2019-10-08 16:05:29 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-08 16:05:29 +0200 |
commit | ed1cefd35205d9ccf49db9703bf132c54396a63b (patch) | |
tree | 46c63525b64cc5842b658a9141cf5b295f4cf2ad | |
parent | c2edaa97f3336e9d6660302b3e30fd921bf20fcc (diff) | |
parent | 753eff2f68ca4fd4bece06b6753b736552e09313 (diff) |
Merge pull request #32624 from Calinou/project-settings-allow-all-types
Allow all Variant types to be added as project settings
-rw-r--r-- | editor/project_settings_editor.cpp | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp index f177e634a6..35187214a6 100644 --- a/editor/project_settings_editor.cpp +++ b/editor/project_settings_editor.cpp @@ -845,13 +845,9 @@ void ProjectSettingsEditor::_item_adds(String) { void ProjectSettingsEditor::_item_add() { - Variant value; - switch (type->get_selected()) { - case 0: value = false; break; - case 1: value = 0; break; - case 2: value = 0.0; break; - case 3: value = ""; break; - } + // Initialize the property with the default value for the given type + Variant::CallError ce; + const Variant value = Variant::construct(Variant::Type(type->get_selected()), NULL, 0, ce); String catname = category->get_text().strip_edges(); String propname = property->get_text().strip_edges(); @@ -1834,10 +1830,11 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) { type = memnew(OptionButton); type->set_h_size_flags(Control::SIZE_EXPAND_FILL); add_prop_bar->add_child(type); - type->add_item("bool"); - type->add_item("int"); - type->add_item("float"); - type->add_item("string"); + + // Start at 1 to avoid adding "Nil" as an option + for (int i = 1; i < Variant::VARIANT_MAX; i++) { + type->add_item(Variant::get_type_name(Variant::Type(i)), i); + } Button *add = memnew(Button); add_prop_bar->add_child(add); |