Allow all Variant types to be added as project settings
This commit is contained in:
parent
234289de2b
commit
753eff2f68
1 changed files with 8 additions and 11 deletions
|
@ -845,13 +845,9 @@ void ProjectSettingsEditor::_item_adds(String) {
|
||||||
|
|
||||||
void ProjectSettingsEditor::_item_add() {
|
void ProjectSettingsEditor::_item_add() {
|
||||||
|
|
||||||
Variant value;
|
// Initialize the property with the default value for the given type
|
||||||
switch (type->get_selected()) {
|
Variant::CallError ce;
|
||||||
case 0: value = false; break;
|
const Variant value = Variant::construct(Variant::Type(type->get_selected()), NULL, 0, ce);
|
||||||
case 1: value = 0; break;
|
|
||||||
case 2: value = 0.0; break;
|
|
||||||
case 3: value = ""; break;
|
|
||||||
}
|
|
||||||
|
|
||||||
String catname = category->get_text().strip_edges();
|
String catname = category->get_text().strip_edges();
|
||||||
String propname = property->get_text().strip_edges();
|
String propname = property->get_text().strip_edges();
|
||||||
|
@ -1834,10 +1830,11 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
|
||||||
type = memnew(OptionButton);
|
type = memnew(OptionButton);
|
||||||
type->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
type->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||||
add_prop_bar->add_child(type);
|
add_prop_bar->add_child(type);
|
||||||
type->add_item("bool");
|
|
||||||
type->add_item("int");
|
// Start at 1 to avoid adding "Nil" as an option
|
||||||
type->add_item("float");
|
for (int i = 1; i < Variant::VARIANT_MAX; i++) {
|
||||||
type->add_item("string");
|
type->add_item(Variant::get_type_name(Variant::Type(i)), i);
|
||||||
|
}
|
||||||
|
|
||||||
Button *add = memnew(Button);
|
Button *add = memnew(Button);
|
||||||
add_prop_bar->add_child(add);
|
add_prop_bar->add_child(add);
|
||||||
|
|
Loading…
Reference in a new issue