summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
Diffstat (limited to 'editor')
-rw-r--r--editor/editor_export.cpp14
-rw-r--r--editor/editor_file_dialog.cpp2
-rw-r--r--editor/editor_file_system.cpp13
-rw-r--r--editor/editor_paths.cpp9
-rw-r--r--editor/editor_paths.h2
-rw-r--r--editor/find_in_files.cpp5
-rw-r--r--editor/plugins/tiles/tile_set_atlas_source_editor.cpp200
-rw-r--r--editor/project_manager.cpp4
8 files changed, 165 insertions, 84 deletions
diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp
index a88adf3634..2010ee01db 100644
--- a/editor/editor_export.cpp
+++ b/editor/editor_export.cpp
@@ -1046,17 +1046,19 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> &
return err;
}
}
- if (FileAccess::exists(ResourceUID::CACHE_FILE)) {
- Vector<uint8_t> array = FileAccess::get_file_as_array(ResourceUID::CACHE_FILE);
- err = p_func(p_udata, ResourceUID::CACHE_FILE, array, idx, total, enc_in_filters, enc_ex_filters, key);
+ String resource_cache_file = ResourceUID::get_cache_file();
+ if (FileAccess::exists(resource_cache_file)) {
+ Vector<uint8_t> array = FileAccess::get_file_as_array(resource_cache_file);
+ err = p_func(p_udata, resource_cache_file, array, idx, total, enc_in_filters, enc_ex_filters, key);
if (err != OK) {
return err;
}
}
- if (FileAccess::exists(NativeExtension::EXTENSION_LIST_CONFIG_FILE)) {
- Vector<uint8_t> array = FileAccess::get_file_as_array(NativeExtension::EXTENSION_LIST_CONFIG_FILE);
- err = p_func(p_udata, NativeExtension::EXTENSION_LIST_CONFIG_FILE, array, idx, total, enc_in_filters, enc_ex_filters, key);
+ String extension_list_config_file = NativeExtension::get_extension_list_config_file();
+ if (FileAccess::exists(extension_list_config_file)) {
+ Vector<uint8_t> array = FileAccess::get_file_as_array(extension_list_config_file);
+ err = p_func(p_udata, extension_list_config_file, array, idx, total, enc_in_filters, enc_ex_filters, key);
if (err != OK) {
return err;
}
diff --git a/editor/editor_file_dialog.cpp b/editor/editor_file_dialog.cpp
index 8956983646..675234959a 100644
--- a/editor/editor_file_dialog.cpp
+++ b/editor/editor_file_dialog.cpp
@@ -588,7 +588,7 @@ void EditorFileDialog::_item_list_item_rmb_selected(int p_item, const Vector2 &p
continue;
}
Dictionary item_meta = item_list->get_item_metadata(i);
- if (String(item_meta["path"]).begins_with("res://.godot")) {
+ if (String(item_meta["path"]).begins_with(ProjectSettings::get_singleton()->get_project_data_path())) {
allow_delete = false;
break;
}
diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp
index 0882b525d7..953989aadd 100644
--- a/editor/editor_file_system.cpp
+++ b/editor/editor_file_system.cpp
@@ -2163,6 +2163,10 @@ Error EditorFileSystem::_resource_import(const String &p_path) {
}
bool EditorFileSystem::_should_skip_directory(const String &p_path) {
+ if (p_path == ProjectSettings::get_singleton()->get_project_data_path()) {
+ return true;
+ }
+
if (FileAccess::exists(p_path.plus_file("project.godot"))) {
// skip if another project inside this
return true;
@@ -2228,7 +2232,7 @@ void EditorFileSystem::move_group_file(const String &p_path, const String &p_new
}
ResourceUID::ID EditorFileSystem::_resource_saver_get_resource_id_for_path(const String &p_path, bool p_generate) {
- if (!p_path.is_resource_file() || p_path.begins_with("res://.godot")) {
+ if (!p_path.is_resource_file() || p_path.begins_with(ProjectSettings::get_singleton()->get_project_data_path())) {
//saved externally (configuration file) or internal file, do not assign an ID.
return ResourceUID::INVALID_ID;
}
@@ -2286,17 +2290,18 @@ bool EditorFileSystem::_scan_extensions() {
}
}
+ String extension_list_config_file = NativeExtension::get_extension_list_config_file();
if (extensions.size()) {
if (extensions_added.size() || extensions_removed.size()) { //extensions were added or removed
- FileAccessRef f = FileAccess::open(NativeExtension::EXTENSION_LIST_CONFIG_FILE, FileAccess::WRITE);
+ FileAccessRef f = FileAccess::open(extension_list_config_file, FileAccess::WRITE);
for (const String &E : extensions) {
f->store_line(E);
}
}
} else {
- if (loaded_extensions.size() || FileAccess::exists(NativeExtension::EXTENSION_LIST_CONFIG_FILE)) { //extensions were removed
+ if (loaded_extensions.size() || FileAccess::exists(extension_list_config_file)) { //extensions were removed
DirAccessRef da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
- da->remove(NativeExtension::EXTENSION_LIST_CONFIG_FILE);
+ da->remove(extension_list_config_file);
}
}
diff --git a/editor/editor_paths.cpp b/editor/editor_paths.cpp
index c9817190dd..71f13c0c2f 100644
--- a/editor/editor_paths.cpp
+++ b/editor/editor_paths.cpp
@@ -87,6 +87,8 @@ void EditorPaths::_bind_methods() {
EditorPaths::EditorPaths() {
singleton = this;
+ project_data_dir = ProjectSettings::get_singleton()->get_project_data_path();
+
// Self-contained mode if a `._sc_` or `_sc_` file is present in executable dir.
String exe_path = OS::get_singleton()->get_executable_path().get_base_dir();
{
@@ -183,7 +185,7 @@ EditorPaths::EditorPaths() {
}
}
- // Validate or create project-specific editor data dir (`res://.godot`),
+ // Validate or create project-specific editor data dir,
// including shader cache subdir.
if (Main::is_project_manager() || Main::is_cmdline_tool()) {
@@ -205,8 +207,9 @@ EditorPaths::EditorPaths() {
dir_res->make_dir("editor");
}
// Imported assets dir.
- if (!dir_res->dir_exists(ProjectSettings::IMPORTED_FILES_PATH)) {
- dir_res->make_dir(ProjectSettings::IMPORTED_FILES_PATH);
+ String imported_files_path = ProjectSettings::get_singleton()->get_imported_files_path();
+ if (!dir_res->dir_exists(imported_files_path)) {
+ dir_res->make_dir(imported_files_path);
}
}
}
diff --git a/editor/editor_paths.h b/editor/editor_paths.h
index 2c156b7c96..cf94ed797a 100644
--- a/editor/editor_paths.h
+++ b/editor/editor_paths.h
@@ -41,7 +41,7 @@ class EditorPaths : public Object {
String data_dir; // Editor data (templates, shader cache, etc.).
String config_dir; // Editor config (settings, profiles, themes, etc.).
String cache_dir; // Editor cache (thumbnails, tmp generated files).
- String project_data_dir = "res://.godot"; // Project-specific data (metadata, shader cache, etc.).
+ String project_data_dir; // Project-specific data (metadata, shader cache, etc.).
bool self_contained = false; // Self-contained means everything goes to `editor_data` dir.
String self_contained_file; // Self-contained file with configuration.
diff --git a/editor/find_in_files.cpp b/editor/find_in_files.cpp
index 380b269675..283496c0f1 100644
--- a/editor/find_in_files.cpp
+++ b/editor/find_in_files.cpp
@@ -233,8 +233,9 @@ void FindInFiles::_scan_dir(String path, PackedStringArray &out_folders) {
break;
}
- // Ignore special dirs (such as .git and .import)
- if (file == "." || file == ".." || file.begins_with(".")) {
+ // Ignore special dirs (such as .git and project data directory)
+ String project_data_dir_name = ProjectSettings::get_singleton()->get_project_data_dir_name();
+ if (file.begins_with(".") || file == project_data_dir_name) {
continue;
}
if (dir->current_is_hidden()) {
diff --git a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp
index bc026146ef..3fbd315aec 100644
--- a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp
+++ b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp
@@ -131,6 +131,7 @@ bool TileSetAtlasSourceEditor::AtlasTileProxyObject::_set(const StringName &p_na
return false;
}
+ // ID and size related properties.
if (tiles.size() == 1) {
const Vector2i &coords = tiles.front()->get().tile;
const int &alternative = tiles.front()->get().alternative;
@@ -160,36 +161,6 @@ bool TileSetAtlasSourceEditor::AtlasTileProxyObject::_set(const StringName &p_na
tile_set_atlas_source->move_tile_in_atlas(coords, TileSetSource::INVALID_ATLAS_COORDS, as_vector2i);
emit_signal(SNAME("changed"), "size_in_atlas");
return true;
- } else if (p_name == "animation_columns") {
- bool has_room_for_tile = tile_set_atlas_source->has_room_for_tile(coords, tile_set_atlas_source->get_tile_size_in_atlas(coords), p_value, tile_set_atlas_source->get_tile_animation_separation(coords), tile_set_atlas_source->get_tile_animation_frames_count(coords), coords);
- ERR_FAIL_COND_V(!has_room_for_tile, false);
- tile_set_atlas_source->set_tile_animation_columns(coords, p_value);
- emit_signal(SNAME("changed"), "animation_columns");
- return true;
- } else if (p_name == "animation_separation") {
- bool has_room_for_tile = tile_set_atlas_source->has_room_for_tile(coords, tile_set_atlas_source->get_tile_size_in_atlas(coords), tile_set_atlas_source->get_tile_animation_columns(coords), p_value, tile_set_atlas_source->get_tile_animation_frames_count(coords), coords);
- ERR_FAIL_COND_V(!has_room_for_tile, false);
- tile_set_atlas_source->set_tile_animation_separation(coords, p_value);
- emit_signal(SNAME("changed"), "animation_separation");
- return true;
- } else if (p_name == "animation_speed") {
- tile_set_atlas_source->set_tile_animation_speed(coords, p_value);
- emit_signal(SNAME("changed"), "animation_speed");
- return true;
- } else if (p_name == "animation_frames_count") {
- bool has_room_for_tile = tile_set_atlas_source->has_room_for_tile(coords, tile_set_atlas_source->get_tile_size_in_atlas(coords), tile_set_atlas_source->get_tile_animation_columns(coords), tile_set_atlas_source->get_tile_animation_separation(coords), p_value, coords);
- ERR_FAIL_COND_V(!has_room_for_tile, false);
- tile_set_atlas_source->set_tile_animation_frames_count(coords, p_value);
- notify_property_list_changed();
- emit_signal(SNAME("changed"), "animation_separation");
- return true;
- } else if (components.size() == 2 && components[0].begins_with("animation_frame_") && components[0].trim_prefix("animation_frame_").is_valid_int()) {
- int frame = components[0].trim_prefix("animation_frame_").to_int();
- ERR_FAIL_INDEX_V(frame, tile_set_atlas_source->get_tile_animation_frames_count(coords), false);
- if (components[1] == "duration") {
- tile_set_atlas_source->set_tile_animation_frame_duration(coords, frame, p_value);
- return true;
- }
}
} else if (alternative > 0) {
if (p_name == "alternative_id") {
@@ -213,6 +184,74 @@ bool TileSetAtlasSourceEditor::AtlasTileProxyObject::_set(const StringName &p_na
}
}
+ // Animation.
+ // Check if all tiles have an alternative_id of 0.
+ bool all_alternatve_id_zero = true;
+ for (TileSelection tile : tiles) {
+ if (tile.alternative != 0) {
+ all_alternatve_id_zero = false;
+ break;
+ }
+ }
+
+ if (all_alternatve_id_zero) {
+ Vector<String> components = String(p_name).split("/", true, 2);
+ if (p_name == "animation_columns") {
+ for (TileSelection tile : tiles) {
+ bool has_room_for_tile = tile_set_atlas_source->has_room_for_tile(tile.tile, tile_set_atlas_source->get_tile_size_in_atlas(tile.tile), p_value, tile_set_atlas_source->get_tile_animation_separation(tile.tile), tile_set_atlas_source->get_tile_animation_frames_count(tile.tile), tile.tile);
+ if (!has_room_for_tile) {
+ ERR_PRINT("No room for tile");
+ } else {
+ tile_set_atlas_source->set_tile_animation_columns(tile.tile, p_value);
+ }
+ }
+ emit_signal(SNAME("changed"), "animation_columns");
+ return true;
+ } else if (p_name == "animation_separation") {
+ for (TileSelection tile : tiles) {
+ bool has_room_for_tile = tile_set_atlas_source->has_room_for_tile(tile.tile, tile_set_atlas_source->get_tile_size_in_atlas(tile.tile), tile_set_atlas_source->get_tile_animation_columns(tile.tile), p_value, tile_set_atlas_source->get_tile_animation_frames_count(tile.tile), tile.tile);
+ if (!has_room_for_tile) {
+ ERR_PRINT("No room for tile");
+ } else {
+ tile_set_atlas_source->set_tile_animation_separation(tile.tile, p_value);
+ }
+ }
+ emit_signal(SNAME("changed"), "animation_separation");
+ return true;
+ } else if (p_name == "animation_speed") {
+ for (TileSelection tile : tiles) {
+ tile_set_atlas_source->set_tile_animation_speed(tile.tile, p_value);
+ }
+ emit_signal(SNAME("changed"), "animation_speed");
+ return true;
+ } else if (p_name == "animation_frames_count") {
+ for (TileSelection tile : tiles) {
+ bool has_room_for_tile = tile_set_atlas_source->has_room_for_tile(tile.tile, tile_set_atlas_source->get_tile_size_in_atlas(tile.tile), tile_set_atlas_source->get_tile_animation_columns(tile.tile), tile_set_atlas_source->get_tile_animation_separation(tile.tile), p_value, tile.tile);
+ if (!has_room_for_tile) {
+ ERR_PRINT("No room for tile");
+ } else {
+ tile_set_atlas_source->set_tile_animation_frames_count(tile.tile, p_value);
+ }
+ }
+ notify_property_list_changed();
+ emit_signal(SNAME("changed"), "animation_separation");
+ return true;
+ } else if (components.size() == 2 && components[0].begins_with("animation_frame_") && components[0].trim_prefix("animation_frame_").is_valid_int()) {
+ for (TileSelection tile : tiles) {
+ int frame = components[0].trim_prefix("animation_frame_").to_int();
+ if (frame < 0 || frame >= tile_set_atlas_source->get_tile_animation_frames_count(tile.tile)) {
+ ERR_PRINT(vformat("No tile animation frame with index %d", frame));
+ } else {
+ if (components[1] == "duration") {
+ tile_set_atlas_source->set_tile_animation_frame_duration(tile.tile, frame, p_value);
+ return true;
+ }
+ }
+ }
+ }
+ }
+
+ // Other properties.
bool any_valid = false;
for (Set<TileSelection>::Element *E = tiles.front(); E; E = E->next()) {
const Vector2i &coords = E->get().tile;
@@ -238,6 +277,7 @@ bool TileSetAtlasSourceEditor::AtlasTileProxyObject::_get(const StringName &p_na
return false;
}
+ // ID and size related properties.s
if (tiles.size() == 1) {
const Vector2i &coords = tiles.front()->get().tile;
const int &alternative = tiles.front()->get().alternative;
@@ -250,27 +290,6 @@ bool TileSetAtlasSourceEditor::AtlasTileProxyObject::_get(const StringName &p_na
} else if (p_name == "size_in_atlas") {
r_ret = tile_set_atlas_source->get_tile_size_in_atlas(coords);
return true;
- } else if (p_name == "animation_columns") {
- r_ret = tile_set_atlas_source->get_tile_animation_columns(coords);
- return true;
- } else if (p_name == "animation_separation") {
- r_ret = tile_set_atlas_source->get_tile_animation_separation(coords);
- return true;
- } else if (p_name == "animation_speed") {
- r_ret = tile_set_atlas_source->get_tile_animation_speed(coords);
- return true;
- } else if (p_name == "animation_frames_count") {
- r_ret = tile_set_atlas_source->get_tile_animation_frames_count(coords);
- return true;
- } else if (components.size() == 2 && components[0].begins_with("animation_frame_") && components[0].trim_prefix("animation_frame_").is_valid_int()) {
- int frame = components[0].trim_prefix("animation_frame_").to_int();
- if (components[1] == "duration") {
- if (frame < 0 || frame >= tile_set_atlas_source->get_tile_animation_frames_count(coords)) {
- return false;
- }
- r_ret = tile_set_atlas_source->get_tile_animation_frame_duration(coords, frame);
- return true;
- }
}
} else if (alternative > 0) {
if (p_name == "alternative_id") {
@@ -280,6 +299,44 @@ bool TileSetAtlasSourceEditor::AtlasTileProxyObject::_get(const StringName &p_na
}
}
+ // Animation.
+ // Check if all tiles have an alternative_id of 0.
+ bool all_alternatve_id_zero = true;
+ for (TileSelection tile : tiles) {
+ if (tile.alternative != 0) {
+ all_alternatve_id_zero = false;
+ break;
+ }
+ }
+
+ if (all_alternatve_id_zero) {
+ const Vector2i &coords = tiles.front()->get().tile;
+
+ Vector<String> components = String(p_name).split("/", true, 2);
+ if (p_name == "animation_columns") {
+ r_ret = tile_set_atlas_source->get_tile_animation_columns(coords);
+ return true;
+ } else if (p_name == "animation_separation") {
+ r_ret = tile_set_atlas_source->get_tile_animation_separation(coords);
+ return true;
+ } else if (p_name == "animation_speed") {
+ r_ret = tile_set_atlas_source->get_tile_animation_speed(coords);
+ return true;
+ } else if (p_name == "animation_frames_count") {
+ r_ret = tile_set_atlas_source->get_tile_animation_frames_count(coords);
+ return true;
+ } else if (components.size() == 2 && components[0].begins_with("animation_frame_") && components[0].trim_prefix("animation_frame_").is_valid_int()) {
+ int frame = components[0].trim_prefix("animation_frame_").to_int();
+ if (components[1] == "duration") {
+ if (frame < 0 || frame >= tile_set_atlas_source->get_tile_animation_frames_count(coords)) {
+ return false;
+ }
+ r_ret = tile_set_atlas_source->get_tile_animation_frame_duration(coords, frame);
+ return true;
+ }
+ }
+ }
+
for (Set<TileSelection>::Element *E = tiles.front(); E; E = E->next()) {
// Return the first tile with a property matching the name.
// Note: It's a little bit annoying, but the behavior is the same the one in MultiNodeEdit.
@@ -304,29 +361,42 @@ void TileSetAtlasSourceEditor::AtlasTileProxyObject::_get_property_list(List<Pro
return;
}
+ // ID and size related properties.
if (tiles.size() == 1) {
if (tiles.front()->get().alternative == 0) {
p_list->push_back(PropertyInfo(Variant::VECTOR2I, "atlas_coords", PROPERTY_HINT_NONE, ""));
p_list->push_back(PropertyInfo(Variant::VECTOR2I, "size_in_atlas", PROPERTY_HINT_NONE, ""));
-
- // Animation.
- p_list->push_back(PropertyInfo(Variant::NIL, "Animation", PROPERTY_HINT_NONE, "animation_", PROPERTY_USAGE_GROUP));
- p_list->push_back(PropertyInfo(Variant::INT, "animation_columns", PROPERTY_HINT_NONE, ""));
- p_list->push_back(PropertyInfo(Variant::VECTOR2I, "animation_separation", PROPERTY_HINT_NONE, ""));
- p_list->push_back(PropertyInfo(Variant::FLOAT, "animation_speed", PROPERTY_HINT_NONE, ""));
- p_list->push_back(PropertyInfo(Variant::INT, "animation_frames_count", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_ARRAY, "Frames,animation_frame_"));
- if (tile_set_atlas_source->get_tile_animation_frames_count(tiles.front()->get().tile) == 1) {
- p_list->push_back(PropertyInfo(Variant::FLOAT, "animation_frame_0/duration", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_READ_ONLY));
- } else {
- for (int i = 0; i < tile_set_atlas_source->get_tile_animation_frames_count(tiles.front()->get().tile); i++) {
- p_list->push_back(PropertyInfo(Variant::FLOAT, vformat("animation_frame_%d/duration", i), PROPERTY_HINT_NONE, ""));
- }
- }
} else {
p_list->push_back(PropertyInfo(Variant::INT, "alternative_id", PROPERTY_HINT_NONE, ""));
}
}
+ // Animation.
+ // Check if all tiles have an alternative_id of 0.
+ bool all_alternatve_id_zero = true;
+ for (TileSelection tile : tiles) {
+ if (tile.alternative != 0) {
+ all_alternatve_id_zero = false;
+ break;
+ }
+ }
+
+ if (all_alternatve_id_zero) {
+ p_list->push_back(PropertyInfo(Variant::NIL, "Animation", PROPERTY_HINT_NONE, "animation_", PROPERTY_USAGE_GROUP));
+ p_list->push_back(PropertyInfo(Variant::INT, "animation_columns", PROPERTY_HINT_NONE, ""));
+ p_list->push_back(PropertyInfo(Variant::VECTOR2I, "animation_separation", PROPERTY_HINT_NONE, ""));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, "animation_speed", PROPERTY_HINT_NONE, ""));
+ p_list->push_back(PropertyInfo(Variant::INT, "animation_frames_count", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_ARRAY, "Frames,animation_frame_"));
+ // Not optimal, but returns value for the first tile. This is similar to what MultiNodeEdit does.
+ if (tile_set_atlas_source->get_tile_animation_frames_count(tiles.front()->get().tile) == 1) {
+ p_list->push_back(PropertyInfo(Variant::FLOAT, "animation_frame_0/duration", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_READ_ONLY));
+ } else {
+ for (int i = 0; i < tile_set_atlas_source->get_tile_animation_frames_count(tiles.front()->get().tile); i++) {
+ p_list->push_back(PropertyInfo(Variant::FLOAT, vformat("animation_frame_%d/duration", i), PROPERTY_HINT_NONE, ""));
+ }
+ }
+ }
+
// Get the list of properties common to all tiles (similar to what's done in MultiNodeEdit).
struct PropertyId {
int occurence_id = 0;
diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp
index 81554c9550..e8fd3070c2 100644
--- a/editor/project_manager.cpp
+++ b/editor/project_manager.cpp
@@ -2123,8 +2123,8 @@ void ProjectManager::_run_project_confirm() {
const String &selected = selected_list[i].project_key;
String path = EditorSettings::get_singleton()->get("projects/" + selected);
- // `.substr(6)` on `IMPORTED_FILES_PATH` strips away the leading "res://".
- if (!DirAccess::exists(path.plus_file(ProjectSettings::IMPORTED_FILES_PATH.substr(6)))) {
+ // `.substr(6)` on `ProjectSettings::get_singleton()->get_imported_files_path()` strips away the leading "res://".
+ if (!DirAccess::exists(path.plus_file(ProjectSettings::get_singleton()->get_imported_files_path().substr(6)))) {
run_error_diag->set_text(TTR("Can't run project: Assets need to be imported.\nPlease edit the project to trigger the initial import."));
run_error_diag->popup_centered();
continue;