summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
Diffstat (limited to 'editor')
-rw-r--r--editor/editor_file_system.cpp24
-rw-r--r--editor/editor_help.cpp4
-rw-r--r--editor/export/editor_export_platform.cpp4
-rw-r--r--editor/plugins/node_3d_editor_plugin.cpp7
-rw-r--r--editor/plugins/script_editor_plugin.cpp82
-rw-r--r--editor/plugins/script_editor_plugin.h18
-rw-r--r--editor/plugins/text_editor.cpp71
-rw-r--r--editor/plugins/text_editor.h2
-rw-r--r--editor/plugins/tiles/tile_atlas_view.cpp11
-rw-r--r--editor/plugins/tiles/tile_map_editor.cpp28
-rw-r--r--editor/plugins/tiles/tile_set_atlas_source_editor.cpp11
-rw-r--r--editor/project_manager.cpp2
12 files changed, 209 insertions, 55 deletions
diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp
index 88831e0c33..8a595be6e6 100644
--- a/editor/editor_file_system.cpp
+++ b/editor/editor_file_system.cpp
@@ -1237,10 +1237,23 @@ void EditorFileSystem::_notification(int p_what) {
case NOTIFICATION_PROCESS: {
if (use_threads) {
+ /** This hack exists because of the EditorProgress nature
+ * of processing events recursively. This needs to be rewritten
+ * at some point entirely, but in the meantime the following
+ * hack prevents deadlock on import.
+ */
+
+ static bool prevent_recursive_process_hack = false;
+ if (prevent_recursive_process_hack) {
+ break;
+ }
+
+ prevent_recursive_process_hack = true;
+
+ bool done_importing = false;
+
if (scanning_changes) {
if (scanning_changes_done) {
- scanning_changes = false;
-
set_process(false);
thread_sources.wait_to_finish();
@@ -1251,6 +1264,8 @@ void EditorFileSystem::_notification(int p_what) {
}
emit_signal(SNAME("sources_changed"), sources_changed.size() > 0);
first_scan = false;
+ scanning_changes = false; // Changed to false here to prevent recursive triggering of scan thread.
+ done_importing = true;
}
} else if (!scanning && thread.is_started()) {
set_process(false);
@@ -1268,10 +1283,12 @@ void EditorFileSystem::_notification(int p_what) {
first_scan = false;
}
- if (!is_processing() && scan_changes_pending) {
+ if (done_importing && scan_changes_pending) {
scan_changes_pending = false;
scan_changes();
}
+
+ prevent_recursive_process_hack = false;
}
} break;
}
@@ -2180,6 +2197,7 @@ void EditorFileSystem::_reimport_thread(uint32_t p_index, ImportThreadData *p_im
}
void EditorFileSystem::reimport_files(const Vector<String> &p_files) {
+ ERR_FAIL_COND_MSG(importing, "Attempted to call reimport_files() recursively, this is not allowed.");
importing = true;
Vector<String> reloads;
diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp
index 0c7ea33b54..acbc3ce0dc 100644
--- a/editor/editor_help.cpp
+++ b/editor/editor_help.cpp
@@ -1540,6 +1540,10 @@ void EditorHelp::_update_doc() {
if (cd.properties[i].overridden) {
continue;
}
+ // Ignore undocumented private.
+ if (cd.properties[i].name.begins_with("_") && cd.properties[i].description.strip_edges().is_empty()) {
+ continue;
+ }
property_line[cd.properties[i].name] = class_desc->get_paragraph_count() - 2;
diff --git a/editor/export/editor_export_platform.cpp b/editor/export/editor_export_platform.cpp
index a46484bb0e..96a8cc8b91 100644
--- a/editor/export/editor_export_platform.cpp
+++ b/editor/export/editor_export_platform.cpp
@@ -1513,7 +1513,7 @@ Error EditorExportPlatform::save_pack(const Ref<EditorExportPreset> &p_preset, b
f = FileAccess::open(p_path, FileAccess::WRITE);
if (f.is_null()) {
DirAccess::remove_file_or_error(tmppath);
- add_message(EXPORT_MESSAGE_ERROR, TTR("Save PCK"), vformat(TTR("Can't open file to read from path \"%s\"."), tmppath));
+ add_message(EXPORT_MESSAGE_ERROR, TTR("Save PCK"), vformat(TTR("Can't open file for writing at path \"%s\"."), p_path));
return ERR_CANT_CREATE;
}
} else {
@@ -1521,7 +1521,7 @@ Error EditorExportPlatform::save_pack(const Ref<EditorExportPreset> &p_preset, b
f = FileAccess::open(p_path, FileAccess::READ_WRITE);
if (f.is_null()) {
DirAccess::remove_file_or_error(tmppath);
- add_message(EXPORT_MESSAGE_ERROR, TTR("Save PCK"), vformat(TTR("Can't open executable file from path \"%s\"."), tmppath));
+ add_message(EXPORT_MESSAGE_ERROR, TTR("Save PCK"), vformat(TTR("Can't open file for reading-writing at path \"%s\"."), p_path));
return ERR_FILE_CANT_OPEN;
}
diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp
index b001b4f766..fc1d8936d5 100644
--- a/editor/plugins/node_3d_editor_plugin.cpp
+++ b/editor/plugins/node_3d_editor_plugin.cpp
@@ -3392,7 +3392,6 @@ void Node3DEditorViewport::_menu_option(int p_option) {
VIEW_DISPLAY_SHADELESS,
VIEW_DISPLAY_LIGHTING,
VIEW_DISPLAY_NORMAL_BUFFER,
- VIEW_DISPLAY_WIREFRAME,
VIEW_DISPLAY_DEBUG_SHADOW_ATLAS,
VIEW_DISPLAY_DEBUG_DIRECTIONAL_SHADOW_ATLAS,
VIEW_DISPLAY_DEBUG_VOXEL_GI_ALBEDO,
@@ -3422,7 +3421,6 @@ void Node3DEditorViewport::_menu_option(int p_option) {
Viewport::DEBUG_DRAW_UNSHADED,
Viewport::DEBUG_DRAW_LIGHTING,
Viewport::DEBUG_DRAW_NORMAL_BUFFER,
- Viewport::DEBUG_DRAW_WIREFRAME,
Viewport::DEBUG_DRAW_SHADOW_ATLAS,
Viewport::DEBUG_DRAW_DIRECTIONAL_SHADOW_ATLAS,
Viewport::DEBUG_DRAW_VOXEL_GI_ALBEDO,
@@ -3445,9 +3443,7 @@ void Node3DEditorViewport::_menu_option(int p_option) {
Viewport::DEBUG_DRAW_MOTION_VECTORS,
};
- int idx = 0;
-
- while (display_options[idx] != VIEW_MAX) {
+ for (int idx = 0; display_options[idx] != VIEW_MAX; idx++) {
int id = display_options[idx];
int item_idx = view_menu->get_popup()->get_item_index(id);
if (item_idx != -1) {
@@ -3461,7 +3457,6 @@ void Node3DEditorViewport::_menu_option(int p_option) {
if (id == p_option) {
viewport->set_debug_draw(debug_draw_modes[idx]);
}
- idx++;
}
} break;
}
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index 74d82aa4a2..6d747ba6a8 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -33,6 +33,7 @@
#include "core/config/project_settings.h"
#include "core/input/input.h"
#include "core/io/file_access.h"
+#include "core/io/json.h"
#include "core/io/resource_loader.h"
#include "core/os/keyboard.h"
#include "core/os/os.h"
@@ -209,6 +210,27 @@ Ref<EditorSyntaxHighlighter> EditorPlainTextSyntaxHighlighter::_create() const {
return syntax_highlighter;
}
+////
+
+void EditorJSONSyntaxHighlighter::_update_cache() {
+ highlighter->set_text_edit(text_edit);
+ highlighter->clear_keyword_colors();
+ highlighter->clear_member_keyword_colors();
+ highlighter->clear_color_regions();
+
+ highlighter->set_symbol_color(EDITOR_GET("text_editor/theme/highlighting/symbol_color"));
+ highlighter->set_number_color(EDITOR_GET("text_editor/theme/highlighting/number_color"));
+
+ const Color string_color = EDITOR_GET("text_editor/theme/highlighting/string_color");
+ highlighter->add_color_region("\"", "\"", string_color);
+}
+
+Ref<EditorSyntaxHighlighter> EditorJSONSyntaxHighlighter::_create() const {
+ Ref<EditorJSONSyntaxHighlighter> syntax_highlighter;
+ syntax_highlighter.instantiate();
+ return syntax_highlighter;
+}
+
////////////////////////////////////////////////////////////////////////////////
/*** SCRIPT EDITOR ****/
@@ -702,9 +724,10 @@ void ScriptEditor::_open_recent_script(int p_idx) {
if (FileAccess::exists(path)) {
List<String> extensions;
ResourceLoader::get_recognized_extensions_for_type("Script", &extensions);
+ ResourceLoader::get_recognized_extensions_for_type("JSON", &extensions);
if (extensions.find(path.get_extension())) {
- Ref<Script> scr = ResourceLoader::load(path);
+ Ref<Resource> scr = ResourceLoader::load(path);
if (scr.is_valid()) {
edit(scr, true);
return;
@@ -1182,6 +1205,7 @@ void ScriptEditor::_menu_option(int p_option) {
List<String> extensions;
ResourceLoader::get_recognized_extensions_for_type("Script", &extensions);
+ ResourceLoader::get_recognized_extensions_for_type("JSON", &extensions);
bool built_in = !path.is_resource_file();
if (extensions.find(path.get_extension()) || built_in) {
@@ -1196,7 +1220,7 @@ void ScriptEditor::_menu_option(int p_option) {
}
}
- Ref<Script> scr = ResourceLoader::load(path);
+ Ref<Resource> scr = ResourceLoader::load(path);
if (!scr.is_valid()) {
EditorNode::get_singleton()->show_warning(TTR("Could not load file at:") + "\n\n" + path, TTR("Error!"));
file_dialog_option = -1;
@@ -2319,12 +2343,23 @@ bool ScriptEditor::edit(const Ref<Resource> &p_resource, int p_line, int p_col,
}
se->add_syntax_highlighter(highlighter);
- if (scr != nullptr && !highlighter_set) {
- PackedStringArray languages = highlighter->_get_supported_languages();
+ if (highlighter_set) {
+ continue;
+ }
+
+ PackedStringArray languages = highlighter->_get_supported_languages();
+ // If script try language, else use extension.
+ if (scr != nullptr) {
if (languages.has(scr->get_language()->get_name())) {
se->set_syntax_highlighter(highlighter);
highlighter_set = true;
}
+ continue;
+ }
+
+ if (languages.has(p_resource->get_path().get_extension())) {
+ se->set_syntax_highlighter(highlighter);
+ highlighter_set = true;
}
}
@@ -2536,6 +2571,14 @@ void ScriptEditor::reload_scripts(bool p_refresh_only) {
scr->reload(true);
}
+ Ref<JSON> json = edited_res;
+ if (json != nullptr) {
+ Ref<JSON> rel_json = ResourceLoader::load(json->get_path(), json->get_class(), ResourceFormatLoader::CACHE_MODE_IGNORE);
+ ERR_CONTINUE(!rel_json.is_valid());
+ json->parse(rel_json->get_parsed_text(), true);
+ json->set_last_modified_time(rel_json->get_last_modified_time());
+ }
+
Ref<TextFile> text_file = edited_res;
if (text_file.is_valid()) {
text_file->reload_from_file();
@@ -2564,8 +2607,9 @@ void ScriptEditor::open_text_file_create_dialog(const String &p_base_path, const
Ref<Resource> ScriptEditor::open_file(const String &p_file) {
List<String> extensions;
ResourceLoader::get_recognized_extensions_for_type("Script", &extensions);
+ ResourceLoader::get_recognized_extensions_for_type("JSON", &extensions);
if (extensions.find(p_file.get_extension())) {
- Ref<Script> scr = ResourceLoader::load(p_file);
+ Ref<Resource> scr = ResourceLoader::load(p_file);
if (!scr.is_valid()) {
EditorNode::get_singleton()->show_warning(TTR("Could not load file at:") + "\n\n" + p_file, TTR("Error!"));
return Ref<Resource>();
@@ -2866,8 +2910,8 @@ bool ScriptEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_data
if (file.is_empty() || !FileAccess::exists(file)) {
continue;
}
- if (ResourceLoader::exists(file, "Script")) {
- Ref<Script> scr = ResourceLoader::load(file);
+ if (ResourceLoader::exists(file, "Script") || ResourceLoader::exists(file, "JSON")) {
+ Ref<Resource> scr = ResourceLoader::load(file);
if (scr.is_valid()) {
return true;
}
@@ -2947,7 +2991,7 @@ void ScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, Co
continue;
}
- if (!ResourceLoader::exists(file, "Script") && !textfile_extensions.has(file.get_extension())) {
+ if (!ResourceLoader::exists(file, "Script") && !ResourceLoader::exists(file, "JSON") && !textfile_extensions.has(file.get_extension())) {
continue;
}
@@ -3105,6 +3149,7 @@ void ScriptEditor::set_window_layout(Ref<ConfigFile> p_layout) {
HashSet<String> loaded_scripts;
List<String> extensions;
ResourceLoader::get_recognized_extensions_for_type("Script", &extensions);
+ ResourceLoader::get_recognized_extensions_for_type("JSON", &extensions);
for (int i = 0; i < scripts.size(); i++) {
String path = scripts[i];
@@ -3123,7 +3168,7 @@ void ScriptEditor::set_window_layout(Ref<ConfigFile> p_layout) {
loaded_scripts.insert(path);
if (extensions.find(path.get_extension())) {
- Ref<Script> scr = ResourceLoader::load(path);
+ Ref<Resource> scr = ResourceLoader::load(path);
if (!scr.is_valid()) {
continue;
}
@@ -3477,6 +3522,12 @@ void ScriptEditor::_open_script_request(const String &p_path) {
return;
}
+ Ref<JSON> json = ResourceLoader::load(p_path);
+ if (json.is_valid()) {
+ script_editor->edit(json, false);
+ return;
+ }
+
Error err;
Ref<TextFile> text_file = script_editor->_load_text_file(p_path, &err);
if (text_file.is_valid()) {
@@ -3539,7 +3590,8 @@ void ScriptEditor::_on_find_in_files_result_selected(String fpath, int line_numb
return;
} else {
Ref<Script> scr = res;
- if (scr.is_valid()) {
+ Ref<JSON> json = res;
+ if (scr.is_valid() || json.is_valid()) {
edit(scr);
ScriptTextEditor *ste = Object::cast_to<ScriptTextEditor>(_get_current_editor());
@@ -3942,6 +3994,10 @@ ScriptEditor::ScriptEditor() {
add_theme_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("ScriptEditorPanel"), SNAME("EditorStyles")));
tab_container->add_theme_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("ScriptEditor"), SNAME("EditorStyles")));
+
+ Ref<EditorJSONSyntaxHighlighter> json_syntax_highlighter;
+ json_syntax_highlighter.instantiate();
+ register_syntax_highlighter(json_syntax_highlighter);
}
ScriptEditor::~ScriptEditor() {
@@ -3963,6 +4019,8 @@ void ScriptEditorPlugin::edit(Object *p_object) {
}
}
script_editor->edit(p_script);
+ } else if (Object::cast_to<JSON>(p_object)) {
+ script_editor->edit(Object::cast_to<JSON>(p_object));
} else if (Object::cast_to<TextFile>(p_object)) {
script_editor->edit(Object::cast_to<TextFile>(p_object));
}
@@ -3977,6 +4035,10 @@ bool ScriptEditorPlugin::handles(Object *p_object) const {
return true;
}
+ if (Object::cast_to<JSON>(p_object)) {
+ return true;
+ }
+
return p_object->is_class("Script");
}
diff --git a/editor/plugins/script_editor_plugin.h b/editor/plugins/script_editor_plugin.h
index 988d07621c..f8e684ae34 100644
--- a/editor/plugins/script_editor_plugin.h
+++ b/editor/plugins/script_editor_plugin.h
@@ -96,6 +96,24 @@ public:
virtual Ref<EditorSyntaxHighlighter> _create() const override;
};
+class EditorJSONSyntaxHighlighter : public EditorSyntaxHighlighter {
+ GDCLASS(EditorJSONSyntaxHighlighter, EditorSyntaxHighlighter)
+
+private:
+ Ref<CodeHighlighter> highlighter;
+
+public:
+ virtual void _update_cache() override;
+ virtual Dictionary _get_line_syntax_highlighting_impl(int p_line) override { return highlighter->get_line_syntax_highlighting(p_line); }
+
+ virtual PackedStringArray _get_supported_languages() const override { return PackedStringArray{ "json" }; }
+ virtual String _get_name() const override { return TTR("JSON"); }
+
+ virtual Ref<EditorSyntaxHighlighter> _create() const override;
+
+ EditorJSONSyntaxHighlighter() { highlighter.instantiate(); }
+};
+
///////////////////////////////////////////////////////////////////////////////
class ScriptEditorQuickOpen : public ConfirmationDialog {
diff --git a/editor/plugins/text_editor.cpp b/editor/plugins/text_editor.cpp
index a376699e54..ceb170d7d8 100644
--- a/editor/plugins/text_editor.cpp
+++ b/editor/plugins/text_editor.cpp
@@ -30,6 +30,7 @@
#include "text_editor.h"
+#include "core/io/json.h"
#include "core/os/keyboard.h"
#include "editor/editor_node.h"
#include "editor/editor_settings.h"
@@ -67,12 +68,12 @@ void TextEditor::_load_theme_settings() {
String TextEditor::get_name() {
String name;
- name = text_file->get_path().get_file();
+ name = edited_res->get_path().get_file();
if (name.is_empty()) {
// This appears for newly created built-in text_files before saving the scene.
name = TTR("[unsaved]");
- } else if (text_file->is_built_in()) {
- const String &text_file_name = text_file->get_name();
+ } else if (edited_res->is_built_in()) {
+ const String &text_file_name = edited_res->get_name();
if (!text_file_name.is_empty()) {
// If the built-in text_file has a custom resource name defined,
// display the built-in text_file name as follows: `ResourceName (scene_file.tscn)`
@@ -88,20 +89,29 @@ String TextEditor::get_name() {
}
Ref<Texture2D> TextEditor::get_theme_icon() {
- return EditorNode::get_singleton()->get_object_icon(text_file.ptr(), "");
+ return EditorNode::get_singleton()->get_object_icon(edited_res.ptr(), "TextFile");
}
Ref<Resource> TextEditor::get_edited_resource() const {
- return text_file;
+ return edited_res;
}
void TextEditor::set_edited_resource(const Ref<Resource> &p_res) {
- ERR_FAIL_COND(text_file.is_valid());
+ ERR_FAIL_COND(edited_res.is_valid());
ERR_FAIL_COND(p_res.is_null());
- text_file = p_res;
+ edited_res = p_res;
+
+ Ref<TextFile> text_file = edited_res;
+ if (text_file != nullptr) {
+ code_editor->get_text_editor()->set_text(text_file->get_text());
+ }
+
+ Ref<JSON> json_file = edited_res;
+ if (json_file != nullptr) {
+ code_editor->get_text_editor()->set_text(json_file->get_parsed_text());
+ }
- code_editor->get_text_editor()->set_text(text_file->get_text());
code_editor->get_text_editor()->clear_undo_history();
code_editor->get_text_editor()->tag_saved_version();
@@ -118,6 +128,8 @@ void TextEditor::enable_editor(Control *p_shortcut_context) {
_load_theme_settings();
+ _validate_script();
+
if (p_shortcut_context) {
for (int i = 0; i < edit_hb->get_child_count(); ++i) {
Control *c = cast_to<Control>(edit_hb->get_child(i));
@@ -143,7 +155,7 @@ PackedInt32Array TextEditor::get_breakpoints() {
}
void TextEditor::reload_text() {
- ERR_FAIL_COND(text_file.is_null());
+ ERR_FAIL_COND(edited_res.is_null());
CodeEdit *te = code_editor->get_text_editor();
int column = te->get_caret_column();
@@ -151,7 +163,16 @@ void TextEditor::reload_text() {
int h = te->get_h_scroll();
int v = te->get_v_scroll();
- te->set_text(text_file->get_text());
+ Ref<TextFile> text_file = edited_res;
+ if (text_file != nullptr) {
+ te->set_text(text_file->get_text());
+ }
+
+ Ref<JSON> json_file = edited_res;
+ if (json_file != nullptr) {
+ te->set_text(json_file->get_parsed_text());
+ }
+
te->set_caret_line(row);
te->set_caret_column(column);
te->set_h_scroll(h);
@@ -166,6 +187,20 @@ void TextEditor::reload_text() {
void TextEditor::_validate_script() {
emit_signal(SNAME("name_changed"));
emit_signal(SNAME("edited_script_changed"));
+
+ Ref<JSON> json_file = edited_res;
+ if (json_file != nullptr) {
+ CodeEdit *te = code_editor->get_text_editor();
+
+ te->set_line_background_color(code_editor->get_error_pos().x, Color(0, 0, 0, 0));
+ code_editor->set_error("");
+
+ if (json_file->parse(te->get_text(), true) != OK) {
+ code_editor->set_error(json_file->get_error_message());
+ code_editor->set_error_pos(json_file->get_error_line(), 0);
+ te->set_line_background_color(code_editor->get_error_pos().x, EDITOR_GET("text_editor/theme/highlighting/mark_color"));
+ }
+ }
}
void TextEditor::_update_bookmark_list() {
@@ -204,13 +239,22 @@ void TextEditor::_bookmark_item_pressed(int p_idx) {
}
void TextEditor::apply_code() {
- text_file->set_text(code_editor->get_text_editor()->get_text());
+ Ref<TextFile> text_file = edited_res;
+ if (text_file != nullptr) {
+ text_file->set_text(code_editor->get_text_editor()->get_text());
+ }
+
+ Ref<JSON> json_file = edited_res;
+ if (json_file != nullptr) {
+ json_file->parse(code_editor->get_text_editor()->get_text(), true);
+ }
+ code_editor->get_text_editor()->get_syntax_highlighter()->update_cache();
}
bool TextEditor::is_unsaved() {
const bool unsaved =
code_editor->get_text_editor()->get_version() != code_editor->get_text_editor()->get_saved_version() ||
- text_file->get_path().is_empty(); // In memory.
+ edited_res->get_path().is_empty(); // In memory.
return unsaved;
}
@@ -431,7 +475,7 @@ void TextEditor::_convert_case(CodeTextEditor::CaseStyle p_case) {
}
static ScriptEditorBase *create_editor(const Ref<Resource> &p_resource) {
- if (Object::cast_to<TextFile>(*p_resource)) {
+ if (Object::cast_to<TextFile>(*p_resource) || Object::cast_to<JSON>(*p_resource)) {
return memnew(TextEditor);
}
return nullptr;
@@ -656,4 +700,5 @@ TextEditor::~TextEditor() {
}
void TextEditor::validate() {
+ this->code_editor->validate_script();
}
diff --git a/editor/plugins/text_editor.h b/editor/plugins/text_editor.h
index 6db81508b3..85e0fee627 100644
--- a/editor/plugins/text_editor.h
+++ b/editor/plugins/text_editor.h
@@ -41,7 +41,7 @@ class TextEditor : public ScriptEditorBase {
private:
CodeTextEditor *code_editor = nullptr;
- Ref<TextFile> text_file;
+ Ref<Resource> edited_res;
bool editor_enabled = false;
HBoxContainer *edit_hb = nullptr;
diff --git a/editor/plugins/tiles/tile_atlas_view.cpp b/editor/plugins/tiles/tile_atlas_view.cpp
index fd651dd507..43c6d1a48b 100644
--- a/editor/plugins/tiles/tile_atlas_view.cpp
+++ b/editor/plugins/tiles/tile_atlas_view.cpp
@@ -404,13 +404,16 @@ void TileAtlasView::_draw_background_right() {
}
void TileAtlasView::set_atlas_source(TileSet *p_tile_set, TileSetAtlasSource *p_tile_set_atlas_source, int p_source_id) {
- ERR_FAIL_COND(!p_tile_set);
- ERR_FAIL_COND(!p_tile_set_atlas_source);
+ tile_set = p_tile_set;
+ tile_set_atlas_source = p_tile_set_atlas_source;
+
+ if (!tile_set) {
+ return;
+ }
+
ERR_FAIL_COND(p_source_id < 0);
ERR_FAIL_COND(p_tile_set->get_source(p_source_id) != p_tile_set_atlas_source);
- tile_set = p_tile_set;
- tile_set_atlas_source = p_tile_set_atlas_source;
source_id = p_source_id;
// Show or hide the view.
diff --git a/editor/plugins/tiles/tile_map_editor.cpp b/editor/plugins/tiles/tile_map_editor.cpp
index 8277e473fd..04a09a97e7 100644
--- a/editor/plugins/tiles/tile_map_editor.cpp
+++ b/editor/plugins/tiles/tile_map_editor.cpp
@@ -571,14 +571,14 @@ bool TileMapEditorTilesPlugin::forward_canvas_gui_input(const Ref<InputEvent> &p
case DRAG_TYPE_PAINT: {
HashMap<Vector2i, TileMapCell> to_draw = _draw_line(drag_start_mouse_pos, drag_last_mouse_pos, mpos, drag_erasing);
for (const KeyValue<Vector2i, TileMapCell> &E : to_draw) {
- if (!drag_erasing && E.value.source_id == TileSet::INVALID_SOURCE) {
- continue;
- }
Vector2i coords = E.key;
if (!drag_modified.has(coords)) {
drag_modified.insert(coords, tile_map->get_cell(tile_map_layer, coords));
+ if (!drag_erasing && E.value.source_id == TileSet::INVALID_SOURCE) {
+ continue;
+ }
+ tile_map->set_cell(tile_map_layer, coords, E.value.source_id, E.value.get_atlas_coords(), E.value.alternative_tile);
}
- tile_map->set_cell(tile_map_layer, coords, E.value.source_id, E.value.get_atlas_coords(), E.value.alternative_tile);
}
_fix_invalid_tiles_in_tile_map_selection();
} break;
@@ -588,14 +588,14 @@ bool TileMapEditorTilesPlugin::forward_canvas_gui_input(const Ref<InputEvent> &p
if (!drag_modified.has(line[i])) {
HashMap<Vector2i, TileMapCell> to_draw = _draw_bucket_fill(line[i], bucket_contiguous_checkbox->is_pressed(), drag_erasing);
for (const KeyValue<Vector2i, TileMapCell> &E : to_draw) {
- if (!drag_erasing && E.value.source_id == TileSet::INVALID_SOURCE) {
- continue;
- }
Vector2i coords = E.key;
if (!drag_modified.has(coords)) {
drag_modified.insert(coords, tile_map->get_cell(tile_map_layer, coords));
+ if (!drag_erasing && E.value.source_id == TileSet::INVALID_SOURCE) {
+ continue;
+ }
+ tile_map->set_cell(tile_map_layer, coords, E.value.source_id, E.value.get_atlas_coords(), E.value.alternative_tile);
}
- tile_map->set_cell(tile_map_layer, coords, E.value.source_id, E.value.get_atlas_coords(), E.value.alternative_tile);
}
}
}
@@ -684,14 +684,14 @@ bool TileMapEditorTilesPlugin::forward_canvas_gui_input(const Ref<InputEvent> &p
if (!drag_modified.has(line[i])) {
HashMap<Vector2i, TileMapCell> to_draw = _draw_bucket_fill(line[i], bucket_contiguous_checkbox->is_pressed(), drag_erasing);
for (const KeyValue<Vector2i, TileMapCell> &E : to_draw) {
- if (!drag_erasing && E.value.source_id == TileSet::INVALID_SOURCE) {
- continue;
- }
Vector2i coords = E.key;
if (!drag_modified.has(coords)) {
drag_modified.insert(coords, tile_map->get_cell(tile_map_layer, coords));
+ if (!drag_erasing && E.value.source_id == TileSet::INVALID_SOURCE) {
+ continue;
+ }
+ tile_map->set_cell(tile_map_layer, coords, E.value.source_id, E.value.get_atlas_coords(), E.value.alternative_tile);
}
- tile_map->set_cell(tile_map_layer, coords, E.value.source_id, E.value.get_atlas_coords(), E.value.alternative_tile);
}
}
}
@@ -2141,7 +2141,7 @@ TileMapEditorTilesPlugin::TileMapEditorTilesPlugin() {
scatter_controls_container = memnew(HBoxContainer);
scatter_label = memnew(Label);
- scatter_label->set_tooltip_text(TTR("Defines the probability of painting nothing instead of a randomly selected tile."));
+ scatter_label->set_tooltip_text(TTR("Modifies the chance of painting nothing instead of a randomly selected tile."));
scatter_label->set_text(TTR("Scattering:"));
scatter_controls_container->add_child(scatter_label);
@@ -2149,7 +2149,7 @@ TileMapEditorTilesPlugin::TileMapEditorTilesPlugin() {
scatter_spinbox->set_min(0.0);
scatter_spinbox->set_max(1000);
scatter_spinbox->set_step(0.001);
- scatter_spinbox->set_tooltip_text(TTR("Defines the probability of painting nothing instead of a randomly selected tile."));
+ scatter_spinbox->set_tooltip_text(TTR("Modifies the chance of painting nothing instead of a randomly selected tile."));
scatter_spinbox->get_line_edit()->add_theme_constant_override("minimum_character_width", 4);
scatter_spinbox->connect("value_changed", callable_mp(this, &TileMapEditorTilesPlugin::_on_scattering_spinbox_changed));
scatter_controls_container->add_child(scatter_spinbox);
diff --git a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp
index 912fdb03a9..e56541b50d 100644
--- a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp
+++ b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp
@@ -120,10 +120,9 @@ void TileSetAtlasSourceEditor::TileSetAtlasSourceProxyObject::_bind_methods() {
}
void TileSetAtlasSourceEditor::TileSetAtlasSourceProxyObject::edit(Ref<TileSet> p_tile_set, TileSetAtlasSource *p_tile_set_atlas_source, int p_source_id) {
- ERR_FAIL_COND(!p_tile_set.is_valid());
ERR_FAIL_COND(!p_tile_set_atlas_source);
ERR_FAIL_COND(p_source_id < 0);
- ERR_FAIL_COND(p_tile_set->get_source(p_source_id) != p_tile_set_atlas_source);
+ ERR_FAIL_COND(p_tile_set.is_valid() && p_tile_set->get_source(p_source_id) != p_tile_set_atlas_source);
if (p_tile_set == tile_set && p_tile_set_atlas_source == tile_set_atlas_source && p_source_id == source_id) {
return;
@@ -611,6 +610,10 @@ void TileSetAtlasSourceEditor::_update_tile_data_editors() {
tile_data_editors_tree->clear();
+ if (tile_set.is_null()) {
+ return;
+ }
+
TreeItem *root = tile_data_editors_tree->create_item();
TreeItem *group;
@@ -919,6 +922,10 @@ void TileSetAtlasSourceEditor::_update_atlas_view() {
alternative_tiles_control->get_child(i)->queue_free();
}
+ if (tile_set.is_null()) {
+ return;
+ }
+
Vector2i pos;
Vector2 texture_region_base_size = tile_set_atlas_source->get_texture_region_size();
int texture_region_base_size_min = MIN(texture_region_base_size.x, texture_region_base_size.y);
diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp
index 5d66be3853..dc019d8e7c 100644
--- a/editor/project_manager.cpp
+++ b/editor/project_manager.cpp
@@ -1359,6 +1359,8 @@ void ProjectList::load_projects() {
create_project_item_control(i);
}
+ sort_projects();
+
set_v_scroll(0);
update_icons_async();