summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
Diffstat (limited to 'editor')
-rw-r--r--editor/editor_file_dialog.cpp18
-rw-r--r--editor/import/scene_import_settings.cpp16
-rw-r--r--editor/import/scene_import_settings.h2
-rw-r--r--editor/plugins/theme_editor_plugin.cpp7
4 files changed, 31 insertions, 12 deletions
diff --git a/editor/editor_file_dialog.cpp b/editor/editor_file_dialog.cpp
index 4a1f0b4c09..80d1e9dcd7 100644
--- a/editor/editor_file_dialog.cpp
+++ b/editor/editor_file_dialog.cpp
@@ -472,6 +472,14 @@ void EditorFileDialog::_action_pressed() {
}
}
+ // First check we're not having an empty name.
+ String file_name = file_text.strip_edges().get_file();
+ if (file_name.is_empty()) {
+ error_dialog->set_text(TTR("Cannot save file with an empty filename."));
+ error_dialog->popup_centered(Size2(250, 80) * EDSCALE);
+ return;
+ }
+
// Add first extension of filter if no valid extension is found.
if (!valid) {
int idx = filter->get_selected();
@@ -480,9 +488,15 @@ void EditorFileDialog::_action_pressed() {
f += "." + ext;
}
+ if (file_name.begins_with(".")) { // Could still happen if typed manually.
+ error_dialog->set_text(TTR("Cannot save file with a name starting with a dot."));
+ error_dialog->popup_centered(Size2(250, 80) * EDSCALE);
+ return;
+ }
+
if (dir_access->file_exists(f) && !disable_overwrite_warning) {
- confirm_save->set_text(TTR("File exists, overwrite?"));
- confirm_save->popup_centered(Size2(200, 80));
+ confirm_save->set_text(vformat(TTR("File \"%s\" already exists.\nDo you want to overwrite it?"), f));
+ confirm_save->popup_centered(Size2(250, 80) * EDSCALE);
} else {
_save_to_recent();
hide();
diff --git a/editor/import/scene_import_settings.cpp b/editor/import/scene_import_settings.cpp
index 6eebb84216..348aad1162 100644
--- a/editor/import/scene_import_settings.cpp
+++ b/editor/import/scene_import_settings.cpp
@@ -142,24 +142,23 @@ void SceneImportSettings::_fill_material(Tree *p_tree, const Ref<Material> &p_ma
String import_id;
bool has_import_id = false;
- bool created = false;
- if (!material_set.has(p_material)) {
- material_set.insert(p_material);
- created = true;
- }
-
if (p_material->has_meta("import_id")) {
import_id = p_material->get_meta("import_id");
has_import_id = true;
} else if (!p_material->get_name().is_empty()) {
import_id = p_material->get_name();
has_import_id = true;
+ } else if (unnamed_material_name_map.has(p_material)) {
+ import_id = unnamed_material_name_map[p_material];
} else {
- import_id = "@MATERIAL:" + itos(material_set.size() - 1);
+ import_id = "@MATERIAL:" + itos(material_map.size());
+ unnamed_material_name_map[p_material] = import_id;
}
+ bool created = false;
if (!material_map.has(import_id)) {
MaterialData md;
+ created = true;
md.has_import_id = has_import_id;
md.material = p_material;
@@ -169,6 +168,7 @@ void SceneImportSettings::_fill_material(Tree *p_tree, const Ref<Material> &p_ma
}
MaterialData &material_data = material_map[import_id];
+ ERR_FAIL_COND(p_material != material_data.material);
Ref<Texture2D> icon = get_theme_icon(SNAME("StandardMaterial3D"), SNAME("EditorIcons"));
@@ -564,10 +564,10 @@ void SceneImportSettings::open_settings(const String &p_path, bool p_for_animati
base_path = p_path;
- material_set.clear();
mesh_set.clear();
animation_map.clear();
material_map.clear();
+ unnamed_material_name_map.clear();
mesh_map.clear();
node_map.clear();
defaults.clear();
diff --git a/editor/import/scene_import_settings.h b/editor/import/scene_import_settings.h
index 69bf58b627..d65bb1404a 100644
--- a/editor/import/scene_import_settings.h
+++ b/editor/import/scene_import_settings.h
@@ -107,6 +107,7 @@ class SceneImportSettings : public ConfirmationDialog {
HashMap<StringName, Variant> settings;
};
HashMap<String, MaterialData> material_map;
+ HashMap<Ref<Material>, String> unnamed_material_name_map;
struct MeshData {
bool has_import_id;
@@ -141,7 +142,6 @@ class SceneImportSettings : public ConfirmationDialog {
void _fill_scene(Node *p_node, TreeItem *p_parent_item);
HashSet<Ref<Mesh>> mesh_set;
- HashSet<Ref<Material>> material_set;
String selected_type;
String selected_id;
diff --git a/editor/plugins/theme_editor_plugin.cpp b/editor/plugins/theme_editor_plugin.cpp
index 073adb467a..2519928ea3 100644
--- a/editor/plugins/theme_editor_plugin.cpp
+++ b/editor/plugins/theme_editor_plugin.cpp
@@ -3223,6 +3223,7 @@ void ThemeTypeEditor::_update_stylebox_from_leading() {
if (!leading_stylebox.pinned || leading_stylebox.stylebox.is_null()) {
return;
}
+ ERR_FAIL_COND_MSG(edited_theme.is_null(), "Leading stylebox does not have an edited theme to update");
// Prevent changes from immediately being reported while the operation is still ongoing.
edited_theme->_freeze_change_propagation();
@@ -3706,7 +3707,11 @@ void ThemeEditorPlugin::edit(Object *p_node) {
if (Object::cast_to<Theme>(p_node)) {
theme_editor->edit(Object::cast_to<Theme>(p_node));
} else {
- theme_editor->edit(Ref<Theme>());
+ // We intentionally keep a reference to the last used theme to work around
+ // the the editor being hidden while base resources are edited. Uncomment
+ // the following line again and remove this comment once that bug has been
+ // fixed (scheduled for Godot 4.1 in PR 73098):
+ // theme_editor->edit(Ref<Theme>());
}
}