summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
Diffstat (limited to 'editor')
-rw-r--r--editor/code_editor.cpp4
-rw-r--r--editor/editor_help.cpp4
-rw-r--r--editor/editor_path.cpp9
-rw-r--r--editor/editor_path.h1
-rw-r--r--editor/editor_settings.cpp2
-rw-r--r--editor/editor_spin_slider.cpp4
-rw-r--r--editor/export_template_manager.cpp56
-rw-r--r--editor/filesystem_dock.cpp28
-rw-r--r--editor/plugins/asset_library_editor_plugin.cpp15
-rw-r--r--editor/plugins/asset_library_editor_plugin.h1
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp26
-rw-r--r--editor/plugins/curve_editor_plugin.cpp3
-rw-r--r--editor/plugins/style_box_editor_plugin.cpp13
-rw-r--r--editor/plugins/style_box_editor_plugin.h3
-rw-r--r--editor/project_settings_editor.cpp7
15 files changed, 102 insertions, 74 deletions
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp
index 4c31797c50..1a821ddd02 100644
--- a/editor/code_editor.cpp
+++ b/editor/code_editor.cpp
@@ -191,7 +191,9 @@ void FindReplaceBar::_replace() {
results_count = -1;
}
- search_current();
+ if (!search_current()) {
+ search_next();
+ }
}
void FindReplaceBar::_replace_all() {
diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp
index 690538f44c..d2306abfd7 100644
--- a/editor/editor_help.cpp
+++ b/editor/editor_help.cpp
@@ -172,7 +172,9 @@ void EditorHelp::_class_desc_input(const Ref<InputEvent> &p_input) {
void EditorHelp::_class_desc_resized() {
// Add extra horizontal margins for better readability.
// The margins increase as the width of the editor help container increases.
- const int display_margin = MAX(30 * EDSCALE, get_parent_anchorable_rect().size.width - 900 * EDSCALE) * 0.5;
+ Ref<Font> doc_code_font = get_font("doc_source", "EditorFonts");
+ real_t char_width = doc_code_font->get_char_size('x').width;
+ const int display_margin = MAX(30 * EDSCALE, get_parent_anchorable_rect().size.width - char_width * 120 * EDSCALE) * 0.5;
Ref<StyleBox> class_desc_stylebox = EditorNode::get_singleton()->get_theme_base()->get_stylebox("normal", "RichTextLabel")->duplicate();
class_desc_stylebox->set_default_margin(MARGIN_LEFT, display_margin);
diff --git a/editor/editor_path.cpp b/editor/editor_path.cpp
index f487a3048b..e4a939c379 100644
--- a/editor/editor_path.cpp
+++ b/editor/editor_path.cpp
@@ -132,6 +132,15 @@ void EditorPath::_id_pressed(int p_idx) {
EditorNode::get_singleton()->push_item(obj);
}
+void EditorPath::_notification(int p_what) {
+
+ switch (p_what) {
+ case NOTIFICATION_THEME_CHANGED: {
+ update_path();
+ } break;
+ }
+}
+
void EditorPath::_bind_methods() {
ClassDB::bind_method("_about_to_show", &EditorPath::_about_to_show);
diff --git a/editor/editor_path.h b/editor/editor_path.h
index 2dc4d21f9b..a84da9f5ac 100644
--- a/editor/editor_path.h
+++ b/editor/editor_path.h
@@ -48,6 +48,7 @@ class EditorPath : public MenuButton {
void _add_children_to_popup(Object *p_obj, int p_depth = 0);
protected:
+ void _notification(int p_what);
static void _bind_methods();
public:
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index 672844117d..a3a02dbd4c 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -436,7 +436,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
_initial_set("text_editor/indent/size", 4);
hints["text_editor/indent/size"] = PropertyInfo(Variant::INT, "text_editor/indent/size", PROPERTY_HINT_RANGE, "1, 64, 1"); // size of 0 crashes.
_initial_set("text_editor/indent/auto_indent", true);
- _initial_set("text_editor/indent/convert_indent_on_save", false);
+ _initial_set("text_editor/indent/convert_indent_on_save", true);
_initial_set("text_editor/indent/draw_tabs", true);
_initial_set("text_editor/indent/draw_spaces", false);
diff --git a/editor/editor_spin_slider.cpp b/editor/editor_spin_slider.cpp
index 918b0ef96d..d80176f00d 100644
--- a/editor/editor_spin_slider.cpp
+++ b/editor/editor_spin_slider.cpp
@@ -228,9 +228,9 @@ void EditorSpinSlider::_notification(int p_what) {
draw_style_box(focus, Rect2(Vector2(), get_size()));
}
- draw_string(font, Vector2(sb->get_offset().x, vofs), label, lc * Color(1, 1, 1, 0.5));
+ draw_string(font, Vector2(Math::round(sb->get_offset().x), vofs), label, lc * Color(1, 1, 1, 0.5));
- draw_string(font, Vector2(sb->get_offset().x + string_width + sep, vofs), numstr, fc, number_width);
+ draw_string(font, Vector2(Math::round(sb->get_offset().x + string_width + sep), vofs), numstr, fc, number_width);
if (get_step() == 1) {
Ref<Texture> updown2 = get_icon("updown", "SpinBox");
diff --git a/editor/export_template_manager.cpp b/editor/export_template_manager.cpp
index 1cdf9848ef..f47f9b8b92 100644
--- a/editor/export_template_manager.cpp
+++ b/editor/export_template_manager.cpp
@@ -69,9 +69,15 @@ void ExportTemplateManager::_update_template_list() {
memdelete(d);
String current_version = VERSION_FULL_CONFIG;
- // Downloadable export templates are only available for stable, alpha, beta and RC versions.
+ // Downloadable export templates are only available for stable and official alpha/beta/RC builds
+ // (which always have a number following their status, e.g. "alpha1").
// Therefore, don't display download-related features when using a development version
- const bool downloads_available = String(VERSION_STATUS) != String("dev");
+ // (whose builds aren't numbered).
+ const bool downloads_available =
+ String(VERSION_STATUS) != String("dev") &&
+ String(VERSION_STATUS) != String("alpha") &&
+ String(VERSION_STATUS) != String("beta") &&
+ String(VERSION_STATUS) != String("rc");
Label *current = memnew(Label);
current->set_h_size_flags(SIZE_EXPAND_FILL);
@@ -155,38 +161,27 @@ void ExportTemplateManager::_uninstall_template(const String &p_version) {
void ExportTemplateManager::_uninstall_template_confirm() {
- DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
- Error err = d->change_dir(EditorSettings::get_singleton()->get_templates_dir());
-
- ERR_FAIL_COND(err != OK);
-
- err = d->change_dir(to_remove);
-
- ERR_FAIL_COND(err != OK);
-
- Vector<String> files;
- d->list_dir_begin();
- String c = d->get_next();
- while (c != String()) {
- if (!d->current_is_dir()) {
- files.push_back(c);
- }
- c = d->get_next();
- }
- d->list_dir_end();
+ DirAccessRef da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
+ const String &templates_dir = EditorSettings::get_singleton()->get_templates_dir();
+ Error err = da->change_dir(templates_dir);
+ ERR_FAIL_COND_MSG(err != OK, "Could not access templates directory at '" + templates_dir + "'.");
+ err = da->change_dir(to_remove);
+ ERR_FAIL_COND_MSG(err != OK, "Could not access templates directory at '" + templates_dir.plus_file(to_remove) + "'.");
- for (int i = 0; i < files.size(); i++) {
- d->remove(files[i]);
- }
+ err = da->erase_contents_recursive();
+ ERR_FAIL_COND_MSG(err != OK, "Could not remove all templates in '" + templates_dir.plus_file(to_remove) + "'.");
- d->change_dir("..");
- d->remove(to_remove);
+ da->change_dir("..");
+ da->remove(to_remove);
+ ERR_FAIL_COND_MSG(err != OK, "Could not remove templates directory at '" + templates_dir.plus_file(to_remove) + "'.");
_update_template_list();
}
bool ExportTemplateManager::_install_from_file(const String &p_file, bool p_use_progress) {
+ // unzClose() will take care of closing the file stored in the unzFile,
+ // so we don't need to `memdelete(fa)` in this method.
FileAccess *fa = NULL;
zlib_filefunc_def io = zipio_create_io_from_file(&fa);
@@ -251,7 +246,7 @@ bool ExportTemplateManager::_install_from_file(const String &p_file, bool p_use_
String template_path = EditorSettings::get_singleton()->get_templates_dir().plus_file(version);
- DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
+ DirAccessRef d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
Error err = d->make_dir_recursive(template_path);
if (err != OK) {
EditorNode::get_singleton()->show_warning(TTR("Error creating path for templates:") + "\n" + template_path);
@@ -259,8 +254,6 @@ bool ExportTemplateManager::_install_from_file(const String &p_file, bool p_use_
return false;
}
- memdelete(d);
-
ret = unzGoToFirstFile(pkg);
EditorProgress *p = NULL;
@@ -316,7 +309,7 @@ bool ExportTemplateManager::_install_from_file(const String &p_file, bool p_use_
}
String to_write = template_path.plus_file(file);
- FileAccess *f = FileAccess::open(to_write, FileAccess::WRITE);
+ FileAccessRef f = FileAccess::open(to_write, FileAccess::WRITE);
if (!f) {
ret = unzGoToNextFile(pkg);
@@ -326,8 +319,6 @@ bool ExportTemplateManager::_install_from_file(const String &p_file, bool p_use_
f->store_buffer(data.ptr(), data.size());
- memdelete(f);
-
#ifndef WINDOWS_ENABLED
FileAccess::set_unix_permissions(to_write, (info.external_fa >> 16) & 0x01FF);
#endif
@@ -343,7 +334,6 @@ bool ExportTemplateManager::_install_from_file(const String &p_file, bool p_use_
unzClose(pkg);
_update_template_list();
-
return true;
}
diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp
index e3f0021fbc..be05183f92 100644
--- a/editor/filesystem_dock.cpp
+++ b/editor/filesystem_dock.cpp
@@ -333,10 +333,11 @@ void FileSystemDock::_notification(int p_what) {
case NOTIFICATION_DRAG_BEGIN: {
Dictionary dd = get_viewport()->gui_get_drag_data();
if (tree->is_visible_in_tree() && dd.has("type")) {
- if ((String(dd["type"]) == "files") || (String(dd["type"]) == "files_and_dirs") || (String(dd["type"]) == "resource")) {
+ if (dd.has("favorite")) {
+ if ((String(dd["favorite"]) == "all"))
+ tree->set_drop_mode_flags(Tree::DROP_MODE_INBETWEEN);
+ } else if ((String(dd["type"]) == "files") || (String(dd["type"]) == "files_and_dirs") || (String(dd["type"]) == "resource")) {
tree->set_drop_mode_flags(Tree::DROP_MODE_ON_ITEM | Tree::DROP_MODE_INBETWEEN);
- } else if ((String(dd["type"]) == "favorite")) {
- tree->set_drop_mode_flags(Tree::DROP_MODE_INBETWEEN);
}
}
} break;
@@ -1839,7 +1840,7 @@ Variant FileSystemDock::get_drag_data_fw(const Point2 &p_point, Control *p_from)
all_not_favorites &= !is_favorite;
selected = tree->get_next_selected(selected);
}
- if (all_favorites) {
+ if (!all_not_favorites) {
paths = _tree_get_selected(false);
} else {
paths = _tree_get_selected();
@@ -1857,12 +1858,9 @@ Variant FileSystemDock::get_drag_data_fw(const Point2 &p_point, Control *p_from)
if (paths.empty())
return Variant();
- if (!all_favorites && !all_not_favorites)
- return Variant();
-
Dictionary drag_data = EditorNode::get_singleton()->drag_files_and_dirs(paths, p_from);
- if (all_favorites) {
- drag_data["type"] = "favorite";
+ if (!all_not_favorites) {
+ drag_data["favorite"] = all_favorites ? "all" : "mixed";
}
return drag_data;
}
@@ -1870,7 +1868,11 @@ Variant FileSystemDock::get_drag_data_fw(const Point2 &p_point, Control *p_from)
bool FileSystemDock::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
Dictionary drag_data = p_data;
- if (drag_data.has("type") && String(drag_data["type"]) == "favorite") {
+ if (drag_data.has("favorite")) {
+
+ if (String(drag_data["favorite"]) != "all") {
+ return false;
+ }
// Moving favorite around.
TreeItem *ti = tree->get_item_at_position(p_point);
@@ -1937,7 +1939,11 @@ void FileSystemDock::drop_data_fw(const Point2 &p_point, const Variant &p_data,
Vector<String> dirs = EditorSettings::get_singleton()->get_favorites();
- if (drag_data.has("type") && String(drag_data["type"]) == "favorite") {
+ if (drag_data.has("favorite")) {
+
+ if (String(drag_data["favorite"]) != "all") {
+ return;
+ }
// Moving favorite around.
TreeItem *ti = tree->get_item_at_position(p_point);
if (!ti)
diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp
index d5b1f46333..95767a96d8 100644
--- a/editor/plugins/asset_library_editor_plugin.cpp
+++ b/editor/plugins/asset_library_editor_plugin.cpp
@@ -1137,9 +1137,12 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const
initial_loading = false;
- // The loading text only needs to be displayed before the first page is loaded
+ // The loading text only needs to be displayed before the first page is loaded.
+ // Therefore, we don't need to show it again.
library_loading->hide();
+ library_error->hide();
+
if (asset_items) {
memdelete(asset_items);
}
@@ -1187,6 +1190,11 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const
asset_bottom_page = _make_pages(page, pages, page_len, total_items, result.size());
library_vb->add_child(asset_bottom_page);
+ if (result.empty()) {
+ library_error->set_text(vformat(TTR("No results for \"%s\"."), filter->get_text()));
+ library_error->show();
+ }
+
for (int i = 0; i < result.size(); i++) {
Dictionary r = result[i];
@@ -1453,6 +1461,11 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
library_loading->set_align(Label::ALIGN_CENTER);
library_vb->add_child(library_loading);
+ library_error = memnew(Label);
+ library_error->set_align(Label::ALIGN_CENTER);
+ library_error->hide();
+ library_vb->add_child(library_error);
+
asset_top_page = memnew(HBoxContainer);
library_vb->add_child(asset_top_page);
diff --git a/editor/plugins/asset_library_editor_plugin.h b/editor/plugins/asset_library_editor_plugin.h
index 94289f3b49..70ffbd9eed 100644
--- a/editor/plugins/asset_library_editor_plugin.h
+++ b/editor/plugins/asset_library_editor_plugin.h
@@ -184,6 +184,7 @@ class EditorAssetLibrary : public PanelContainer {
ScrollContainer *library_scroll;
VBoxContainer *library_vb;
Label *library_loading;
+ Label *library_error;
LineEdit *filter;
OptionButton *categories;
OptionButton *repository;
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index f9a7b7caf1..7659363cdf 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -2274,7 +2274,7 @@ bool CanvasItemEditor::_gui_input_ruler_tool(const Ref<InputEvent> &p_event) {
Point2 previous_origin = ruler_tool_origin;
if (!ruler_tool_active)
- ruler_tool_origin = snap_point(viewport->get_local_mouse_position() / zoom + view_offset) * zoom;
+ ruler_tool_origin = snap_point(viewport->get_local_mouse_position() / zoom + view_offset);
if (b.is_valid() && b->get_button_index() == BUTTON_LEFT) {
if (b->is_pressed()) {
@@ -2287,9 +2287,7 @@ bool CanvasItemEditor::_gui_input_ruler_tool(const Ref<InputEvent> &p_event) {
return true;
}
- bool is_snap_active = smart_snap_active ^ Input::get_singleton()->is_key_pressed(KEY_CONTROL);
-
- if (m.is_valid() && (ruler_tool_active || (is_snap_active && previous_origin != ruler_tool_origin))) {
+ if (m.is_valid() && (ruler_tool_active || (grid_snap_active && previous_origin != ruler_tool_origin))) {
viewport->update();
return true;
@@ -2687,19 +2685,17 @@ void CanvasItemEditor::_draw_ruler_tool() {
if (tool != TOOL_RULER)
return;
- bool is_snap_active = smart_snap_active ^ Input::get_singleton()->is_key_pressed(KEY_CONTROL);
-
if (ruler_tool_active) {
Color ruler_primary_color = get_color("accent_color", "Editor");
Color ruler_secondary_color = ruler_primary_color;
ruler_secondary_color.a = 0.5;
- Point2 begin = ruler_tool_origin - view_offset * zoom;
+ Point2 begin = (ruler_tool_origin - view_offset) * zoom;
Point2 end = snap_point(viewport->get_local_mouse_position() / zoom + view_offset) * zoom - view_offset * zoom;
Point2 corner = Point2(begin.x, end.y);
Vector2 length_vector = (begin - end).abs() / zoom;
- bool draw_secondary_lines = (begin.y != corner.y && end.x != corner.x);
+ bool draw_secondary_lines = !(Math::is_equal_approx(begin.y, corner.y) || Math::is_equal_approx(end.x, corner.x));
viewport->draw_line(begin, end, ruler_primary_color, Math::round(EDSCALE * 3), true);
if (draw_secondary_lines) {
@@ -2744,13 +2740,13 @@ void CanvasItemEditor::_draw_ruler_tool() {
if (begin.y < end.y) {
h_angle_text_pos.y = end.y + text_height * 1.5;
if (ABS(text_pos2.x - h_angle_text_pos.x) < text_width) {
- int height_multiplier = 1.5 + (int)is_snap_active;
+ int height_multiplier = 1.5 + (int)grid_snap_active;
h_angle_text_pos.y = MAX(text_pos.y + height_multiplier * text_height, MAX(end.y + text_height * 1.5, text_pos2.y + height_multiplier * text_height));
}
} else {
h_angle_text_pos.y = end.y - text_height * 0.5;
if (ABS(text_pos2.x - h_angle_text_pos.x) < text_width) {
- int height_multiplier = 1 + (int)is_snap_active;
+ int height_multiplier = 1 + (int)grid_snap_active;
h_angle_text_pos.y = MIN(text_pos.y - height_multiplier * text_height, MIN(end.y - text_height * 0.5, text_pos2.y - height_multiplier * text_height));
}
}
@@ -2785,7 +2781,7 @@ void CanvasItemEditor::_draw_ruler_tool() {
viewport->draw_arc(end, arc_2_radius, arc_2_start_angle, arc_2_end_angle, arc_point_count, ruler_primary_color, Math::round(EDSCALE * arc_line_width));
}
- if (is_snap_active) {
+ if (grid_snap_active) {
text_pos = (begin + end) / 2 + Vector2(-text_width / 2, text_height / 2);
text_pos.x = CLAMP(text_pos.x, text_width / 2, viewport->get_rect().size.x - text_width * 1.5);
@@ -2796,20 +2792,20 @@ void CanvasItemEditor::_draw_ruler_tool() {
Point2 text_pos2 = text_pos;
text_pos2.x = begin.x < text_pos.x ? MIN(text_pos.x - text_width, begin.x - text_width / 2) : MAX(text_pos.x + text_width, begin.x - text_width / 2);
- viewport->draw_string(font, text_pos2, vformat("%d units", (int)(length_vector.y / grid_step.y)), font_secondary_color);
+ viewport->draw_string(font, text_pos2, vformat("%d units", roundf(length_vector.y / grid_step.y)), font_secondary_color);
text_pos2 = text_pos;
text_pos2.y = end.y < text_pos.y ? MIN(text_pos.y - text_height * 2, end.y + text_height / 2) : MAX(text_pos.y + text_height * 2, end.y + text_height / 2);
- viewport->draw_string(font, text_pos2, vformat("%d units", (int)(length_vector.x / grid_step.x)), font_secondary_color);
+ viewport->draw_string(font, text_pos2, vformat("%d units", roundf(length_vector.x / grid_step.x)), font_secondary_color);
} else {
viewport->draw_string(font, text_pos, vformat("%d units", roundf((length_vector / grid_step).length())), font_color);
}
}
} else {
- if (is_snap_active) {
+ if (grid_snap_active) {
Ref<Texture> position_icon = get_icon("EditorPosition", "EditorIcons");
- viewport->draw_texture(get_icon("EditorPosition", "EditorIcons"), ruler_tool_origin - view_offset * zoom - position_icon->get_size() / 2);
+ viewport->draw_texture(get_icon("EditorPosition", "EditorIcons"), (ruler_tool_origin - view_offset) * zoom - position_icon->get_size() / 2);
}
}
}
diff --git a/editor/plugins/curve_editor_plugin.cpp b/editor/plugins/curve_editor_plugin.cpp
index 9160920c50..727d92ba05 100644
--- a/editor/plugins/curve_editor_plugin.cpp
+++ b/editor/plugins/curve_editor_plugin.cpp
@@ -736,6 +736,9 @@ void CurveEditor::_draw() {
if (_selected_point > 0 && _selected_point + 1 < curve.get_point_count()) {
text_color.a *= 0.4;
draw_string(font, Vector2(50, font_height), TTR("Hold Shift to edit tangents individually"), text_color);
+ } else if (curve.get_point_count() == 0) {
+ text_color.a *= 0.4;
+ draw_string(font, Vector2(50, font_height), TTR("Right click to add point"), text_color);
}
}
diff --git a/editor/plugins/style_box_editor_plugin.cpp b/editor/plugins/style_box_editor_plugin.cpp
index defc0a40ea..c4a9803ff4 100644
--- a/editor/plugins/style_box_editor_plugin.cpp
+++ b/editor/plugins/style_box_editor_plugin.cpp
@@ -64,21 +64,24 @@ void StyleBoxPreview::edit(const Ref<StyleBox> &p_stylebox) {
void StyleBoxPreview::_sb_changed() {
preview->update();
+}
+
+void StyleBoxPreview::_redraw() {
if (stylebox.is_valid()) {
- Size2 ms = stylebox->get_minimum_size() * 4 / 3;
- ms.height = MAX(ms.height, 150 * EDSCALE);
- preview->set_custom_minimum_size(ms);
+ preview->draw_style_box(stylebox, preview->get_rect());
}
}
void StyleBoxPreview::_bind_methods() {
ClassDB::bind_method("_sb_changed", &StyleBoxPreview::_sb_changed);
+ ClassDB::bind_method("_redraw", &StyleBoxPreview::_redraw);
}
StyleBoxPreview::StyleBoxPreview() {
-
- preview = memnew(Panel);
+ preview = memnew(Control);
+ preview->set_custom_minimum_size(Size2(0, 150 * EDSCALE));
+ preview->connect("draw", this, "_redraw");
add_margin_child(TTR("Preview:"), preview);
}
diff --git a/editor/plugins/style_box_editor_plugin.h b/editor/plugins/style_box_editor_plugin.h
index d31a28b3e4..fead8e0de8 100644
--- a/editor/plugins/style_box_editor_plugin.h
+++ b/editor/plugins/style_box_editor_plugin.h
@@ -41,10 +41,11 @@ class StyleBoxPreview : public VBoxContainer {
GDCLASS(StyleBoxPreview, VBoxContainer);
- Panel *preview;
+ Control *preview;
Ref<StyleBox> stylebox;
void _sb_changed();
+ void _redraw();
protected:
static void _bind_methods();
diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp
index 803c806028..f56f7ef7ca 100644
--- a/editor/project_settings_editor.cpp
+++ b/editor/project_settings_editor.cpp
@@ -845,9 +845,10 @@ void ProjectSettingsEditor::_item_adds(String) {
void ProjectSettingsEditor::_item_add() {
- // Initialize the property with the default value for the given type
+ // Initialize the property with the default value for the given type.
+ // The type list starts at 1 (as we exclude Nil), so add 1 to the selected value.
Variant::CallError ce;
- const Variant value = Variant::construct(Variant::Type(type->get_selected()), NULL, 0, ce);
+ const Variant value = Variant::construct(Variant::Type(type->get_selected() + 1), NULL, 0, ce);
String catname = category->get_text().strip_edges();
String propname = property->get_text().strip_edges();
@@ -1835,7 +1836,7 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
// 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);
+ type->add_item(Variant::get_type_name(Variant::Type(i)));
}
Button *add = memnew(Button);