summaryrefslogtreecommitdiff
path: root/editor/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'editor/plugins')
-rw-r--r--editor/plugins/animation_blend_tree_editor_plugin.cpp4
-rw-r--r--editor/plugins/animation_player_editor_plugin.cpp2
-rw-r--r--editor/plugins/animation_state_machine_editor.cpp2
-rw-r--r--editor/plugins/asset_library_editor_plugin.cpp78
-rw-r--r--editor/plugins/asset_library_editor_plugin.h5
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp22
-rw-r--r--editor/plugins/canvas_item_editor_plugin.h2
-rw-r--r--editor/plugins/editor_preview_plugins.cpp2
-rw-r--r--editor/plugins/multimesh_editor_plugin.cpp2
-rw-r--r--editor/plugins/particles_editor_plugin.cpp2
-rw-r--r--editor/plugins/script_editor_plugin.cpp53
-rw-r--r--editor/plugins/script_editor_plugin.h4
-rw-r--r--editor/plugins/script_text_editor.cpp99
-rw-r--r--editor/plugins/script_text_editor.h3
-rw-r--r--editor/plugins/shader_editor_plugin.cpp85
-rw-r--r--editor/plugins/shader_editor_plugin.h8
-rw-r--r--editor/plugins/spatial_editor_plugin.cpp2
-rw-r--r--editor/plugins/text_editor.cpp8
-rw-r--r--editor/plugins/text_editor.h3
-rw-r--r--editor/plugins/tile_map_editor_plugin.cpp108
20 files changed, 332 insertions, 162 deletions
diff --git a/editor/plugins/animation_blend_tree_editor_plugin.cpp b/editor/plugins/animation_blend_tree_editor_plugin.cpp
index bfee76492b..dff6eb5c5e 100644
--- a/editor/plugins/animation_blend_tree_editor_plugin.cpp
+++ b/editor/plugins/animation_blend_tree_editor_plugin.cpp
@@ -471,7 +471,7 @@ void AnimationNodeBlendTreeEditor::_node_selected(Object *p_node) {
void AnimationNodeBlendTreeEditor::_open_in_editor(const String &p_which) {
Ref<AnimationNode> an = blend_tree->get_node(p_which);
- ERR_FAIL_COND(!an.is_valid())
+ ERR_FAIL_COND(!an.is_valid());
AnimationTreeEditor::get_singleton()->enter_editor(p_which);
}
@@ -798,7 +798,7 @@ void AnimationNodeBlendTreeEditor::_node_renamed(const String &p_text, Ref<Anima
String new_name = p_text;
- ERR_FAIL_COND(new_name == "" || new_name.find(".") != -1 || new_name.find("/") != -1)
+ ERR_FAIL_COND(new_name == "" || new_name.find(".") != -1 || new_name.find("/") != -1);
if (new_name == prev_name) {
return; //nothing to do
diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp
index 7d96f0b87b..5204565c06 100644
--- a/editor/plugins/animation_player_editor_plugin.cpp
+++ b/editor/plugins/animation_player_editor_plugin.cpp
@@ -769,7 +769,7 @@ void AnimationPlayerEditor::_dialog_action(String p_file) {
if (current != "") {
Ref<Animation> anim = player->get_animation(current);
- ERR_FAIL_COND(!Object::cast_to<Resource>(*anim))
+ ERR_FAIL_COND(!Object::cast_to<Resource>(*anim));
RES current_res = RES(Object::cast_to<Resource>(*anim));
diff --git a/editor/plugins/animation_state_machine_editor.cpp b/editor/plugins/animation_state_machine_editor.cpp
index f06b4b2828..e25e7ac7ed 100644
--- a/editor/plugins/animation_state_machine_editor.cpp
+++ b/editor/plugins/animation_state_machine_editor.cpp
@@ -1096,7 +1096,7 @@ void AnimationNodeStateMachineEditor::_name_edited(const String &p_text) {
String new_name = p_text;
- ERR_FAIL_COND(new_name == "" || new_name.find(".") != -1 || new_name.find("/") != -1)
+ ERR_FAIL_COND(new_name == "" || new_name.find(".") != -1 || new_name.find("/") != -1);
if (new_name == prev_name) {
return; // Nothing to do.
diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp
index 0dfb53b34a..1503258ff5 100644
--- a/editor/plugins/asset_library_editor_plugin.cpp
+++ b/editor/plugins/asset_library_editor_plugin.cpp
@@ -35,7 +35,7 @@
#include "editor_node.h"
#include "editor_settings.h"
-void EditorAssetLibraryItem::configure(const String &p_title, int p_asset_id, const String &p_category, int p_category_id, const String &p_author, int p_author_id, int p_rating, const String &p_cost) {
+void EditorAssetLibraryItem::configure(const String &p_title, int p_asset_id, const String &p_category, int p_category_id, const String &p_author, int p_author_id, const String &p_cost) {
title->set_text(p_title);
asset_id = p_asset_id;
@@ -44,13 +44,6 @@ void EditorAssetLibraryItem::configure(const String &p_title, int p_asset_id, co
author->set_text(p_author);
author_id = p_author_id;
price->set_text(p_cost);
-
- for (int i = 0; i < 5; i++) {
- if (i < p_rating)
- stars[i]->set_texture(get_icon("Favorites", "EditorIcons"));
- else
- stars[i]->set_texture(get_icon("NonFavorite", "EditorIcons"));
- }
}
void EditorAssetLibraryItem::set_image(int p_type, int p_index, const Ref<Texture> &p_image) {
@@ -65,9 +58,10 @@ void EditorAssetLibraryItem::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
- icon->set_normal_texture(get_icon("DefaultProjectIcon", "EditorIcons"));
+ icon->set_normal_texture(get_icon("ProjectIconLoading", "EditorIcons"));
category->add_color_override("font_color", Color(0.5, 0.5, 0.5));
author->add_color_override("font_color", Color(0.5, 0.5, 0.5));
+ price->add_color_override("font_color", Color(0.5, 0.5, 0.5));
}
}
@@ -100,17 +94,19 @@ EditorAssetLibraryItem::EditorAssetLibraryItem() {
Ref<StyleBoxEmpty> border;
border.instance();
- border->set_default_margin(MARGIN_LEFT, 5);
- border->set_default_margin(MARGIN_RIGHT, 5);
- border->set_default_margin(MARGIN_BOTTOM, 5);
- border->set_default_margin(MARGIN_TOP, 5);
+ border->set_default_margin(MARGIN_LEFT, 5 * EDSCALE);
+ border->set_default_margin(MARGIN_RIGHT, 5 * EDSCALE);
+ border->set_default_margin(MARGIN_BOTTOM, 5 * EDSCALE);
+ border->set_default_margin(MARGIN_TOP, 5 * EDSCALE);
add_style_override("panel", border);
HBoxContainer *hb = memnew(HBoxContainer);
+ // Add some spacing to visually separate the icon from the asset details
+ hb->add_constant_override("separation", 15 * EDSCALE);
add_child(hb);
icon = memnew(TextureButton);
- icon->set_custom_minimum_size(Size2(64, 64));
+ icon->set_custom_minimum_size(Size2(64, 64) * EDSCALE);
icon->set_default_cursor_shape(CURSOR_POINTING_HAND);
icon->connect("pressed", this, "_asset_clicked");
@@ -139,18 +135,11 @@ EditorAssetLibraryItem::EditorAssetLibraryItem() {
author->connect("pressed", this, "_author_clicked");
vb->add_child(author);
- HBoxContainer *rating_hb = memnew(HBoxContainer);
- vb->add_child(rating_hb);
-
- for (int i = 0; i < 5; i++) {
- stars[i] = memnew(TextureRect);
- rating_hb->add_child(stars[i]);
- }
price = memnew(Label);
price->set_text(TTR("Free"));
vb->add_child(price);
- set_custom_minimum_size(Size2(250, 100));
+ set_custom_minimum_size(Size2(250, 100) * EDSCALE);
set_h_size_flags(SIZE_EXPAND_FILL);
set_mouse_filter(MOUSE_FILTER_PASS);
@@ -194,7 +183,6 @@ void EditorAssetLibraryItemDescription::set_image(int p_type, int p_index, const
break;
}
}
- //item->call("set_image",p_type,p_index,p_image);
} break;
case EditorAssetLibrary::IMAGE_QUEUE_SCREENSHOT: {
@@ -207,7 +195,6 @@ void EditorAssetLibraryItemDescription::set_image(int p_type, int p_index, const
break;
}
}
- //item->call("set_image",p_type,p_index,p_image);
} break;
}
}
@@ -248,13 +235,13 @@ void EditorAssetLibraryItemDescription::_preview_click(int p_id) {
}
}
-void EditorAssetLibraryItemDescription::configure(const String &p_title, int p_asset_id, const String &p_category, int p_category_id, const String &p_author, int p_author_id, int p_rating, const String &p_cost, int p_version, const String &p_version_string, const String &p_description, const String &p_download_url, const String &p_browse_url, const String &p_sha256_hash) {
+void EditorAssetLibraryItemDescription::configure(const String &p_title, int p_asset_id, const String &p_category, int p_category_id, const String &p_author, int p_author_id, const String &p_cost, int p_version, const String &p_version_string, const String &p_description, const String &p_download_url, const String &p_browse_url, const String &p_sha256_hash) {
asset_id = p_asset_id;
title = p_title;
download_url = p_download_url;
sha256 = p_sha256_hash;
- item->configure(p_title, p_asset_id, p_category, p_category_id, p_author, p_author_id, p_rating, p_cost);
+ item->configure(p_title, p_asset_id, p_category, p_category_id, p_author, p_author_id, p_cost);
description->clear();
description->add_text(TTR("Version:") + " " + p_version_string + "\n");
description->add_text(TTR("Contents:") + " ");
@@ -554,7 +541,7 @@ EditorAssetLibraryItemDownload::EditorAssetLibraryItemDownload() {
hb2->add_child(retry);
hb2->add_child(install);
- set_custom_minimum_size(Size2(310, 0));
+ set_custom_minimum_size(Size2(310, 0) * EDSCALE);
download = memnew(HTTPRequest);
add_child(download);
@@ -666,7 +653,6 @@ void EditorAssetLibrary::_install_asset() {
}
const char *EditorAssetLibrary::sort_key[SORT_MAX] = {
- "rating",
"downloads",
"name",
"cost",
@@ -674,10 +660,9 @@ const char *EditorAssetLibrary::sort_key[SORT_MAX] = {
};
const char *EditorAssetLibrary::sort_text[SORT_MAX] = {
- "Rating",
"Downloads",
"Name",
- "Cost",
+ "License", // "cost" stores the SPDX license name in the Godot Asset Library
"Updated"
};
@@ -733,6 +718,7 @@ void EditorAssetLibrary::_image_update(bool use_cache, bool final, const PoolByt
image_data = cached_data;
file->close();
+ memdelete(file);
}
}
@@ -807,6 +793,7 @@ void EditorAssetLibrary::_image_request_completed(int p_status, int p_code, cons
if (file) {
file->store_line(new_etag);
file->close();
+ memdelete(file);
}
int len = p_data.size();
@@ -816,6 +803,7 @@ void EditorAssetLibrary::_image_request_completed(int p_status, int p_code, cons
file->store_32(len);
file->store_buffer(r.ptr(), len);
file->close();
+ memdelete(file);
}
break;
@@ -855,6 +843,7 @@ void EditorAssetLibrary::_update_image_queue() {
if (file) {
headers.push_back("If-None-Match: " + file->get_line());
file->close();
+ memdelete(file);
}
}
@@ -984,7 +973,7 @@ HBoxContainer *EditorAssetLibrary::_make_pages(int p_page, int p_page_count, int
to = p_page_count;
hbc->add_spacer();
- hbc->add_constant_override("separation", 5);
+ hbc->add_constant_override("separation", 5 * EDSCALE);
Button *first = memnew(Button);
first->set_text(TTR("First"));
@@ -1190,8 +1179,8 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const
asset_items = memnew(GridContainer);
asset_items->set_columns(2);
- asset_items->add_constant_override("hseparation", 10);
- asset_items->add_constant_override("vseparation", 10);
+ asset_items->add_constant_override("hseparation", 10 * EDSCALE);
+ asset_items->add_constant_override("vseparation", 10 * EDSCALE);
library_vb->add_child(asset_items);
@@ -1208,12 +1197,11 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const
ERR_CONTINUE(!r.has("author_id"));
ERR_CONTINUE(!r.has("category_id"));
ERR_FAIL_COND(!category_map.has(r["category_id"]));
- ERR_CONTINUE(!r.has("rating"));
ERR_CONTINUE(!r.has("cost"));
EditorAssetLibraryItem *item = memnew(EditorAssetLibraryItem);
asset_items->add_child(item);
- item->configure(r["title"], r["asset_id"], category_map[r["category_id"]], r["category_id"], r["author"], r["author_id"], r["rating"], r["cost"]);
+ item->configure(r["title"], r["asset_id"], category_map[r["category_id"]], r["category_id"], r["author"], r["author_id"], r["cost"]);
item->connect("asset_selected", this, "_select_asset");
item->connect("author_selected", this, "_select_author");
item->connect("category_selected", this, "_select_category");
@@ -1234,7 +1222,6 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const
ERR_FAIL_COND(!r.has("version_string"));
ERR_FAIL_COND(!r.has("category_id"));
ERR_FAIL_COND(!category_map.has(r["category_id"]));
- ERR_FAIL_COND(!r.has("rating"));
ERR_FAIL_COND(!r.has("cost"));
ERR_FAIL_COND(!r.has("description"));
ERR_FAIL_COND(!r.has("download_url"));
@@ -1250,7 +1237,7 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const
description->popup_centered_minsize();
description->connect("confirmed", this, "_install_asset");
- description->configure(r["title"], r["asset_id"], category_map[r["category_id"]], r["category_id"], r["author"], r["author_id"], r["rating"], r["cost"], r["version"], r["version_string"], r["description"], r["download_url"], r["browse_url"], r["download_hash"]);
+ description->configure(r["title"], r["asset_id"], category_map[r["category_id"]], r["category_id"], r["author"], r["author_id"], r["cost"], r["version"], r["version_string"], r["description"], r["download_url"], r["browse_url"], r["download_hash"]);
/*item->connect("asset_selected",this,"_select_asset");
item->connect("author_selected",this,"_select_author");
item->connect("category_selected",this,"_category_selected");*/
@@ -1357,7 +1344,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
HBoxContainer *search_hb = memnew(HBoxContainer);
library_main->add_child(search_hb);
- library_main->add_constant_override("separation", 10);
+ library_main->add_constant_override("separation", 10 * EDSCALE);
search_hb->add_child(memnew(Label(TTR("Search:") + " ")));
filter = memnew(LineEdit);
@@ -1459,10 +1446,10 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
Ref<StyleBoxEmpty> border2;
border2.instance();
- border2->set_default_margin(MARGIN_LEFT, 15);
- border2->set_default_margin(MARGIN_RIGHT, 35);
- border2->set_default_margin(MARGIN_BOTTOM, 15);
- border2->set_default_margin(MARGIN_TOP, 15);
+ border2->set_default_margin(MARGIN_LEFT, 15 * EDSCALE);
+ border2->set_default_margin(MARGIN_RIGHT, 35 * EDSCALE);
+ border2->set_default_margin(MARGIN_BOTTOM, 15 * EDSCALE);
+ border2->set_default_margin(MARGIN_TOP, 15 * EDSCALE);
PanelContainer *library_vb_border = memnew(PanelContainer);
library_scroll->add_child(library_vb_border);
@@ -1474,15 +1461,14 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
library_vb->set_h_size_flags(SIZE_EXPAND_FILL);
library_vb_border->add_child(library_vb);
- //margin_panel->set_stop_mouse(false);
asset_top_page = memnew(HBoxContainer);
library_vb->add_child(asset_top_page);
asset_items = memnew(GridContainer);
asset_items->set_columns(2);
- asset_items->add_constant_override("hseparation", 10);
- asset_items->add_constant_override("vseparation", 10);
+ asset_items->add_constant_override("hseparation", 10 * EDSCALE);
+ asset_items->add_constant_override("vseparation", 10 * EDSCALE);
library_vb->add_child(asset_items);
@@ -1496,7 +1482,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
last_queue_id = 0;
- library_vb->add_constant_override("separation", 20);
+ library_vb->add_constant_override("separation", 20 * EDSCALE);
load_status = memnew(ProgressBar);
load_status->set_min(0);
diff --git a/editor/plugins/asset_library_editor_plugin.h b/editor/plugins/asset_library_editor_plugin.h
index dd5f3c2077..81288ae831 100644
--- a/editor/plugins/asset_library_editor_plugin.h
+++ b/editor/plugins/asset_library_editor_plugin.h
@@ -77,7 +77,7 @@ protected:
static void _bind_methods();
public:
- void configure(const String &p_title, int p_asset_id, const String &p_category, int p_category_id, const String &p_author, int p_author_id, int p_rating, const String &p_cost);
+ void configure(const String &p_title, int p_asset_id, const String &p_category, int p_category_id, const String &p_author, int p_author_id, const String &p_cost);
EditorAssetLibraryItem();
};
@@ -120,7 +120,7 @@ protected:
static void _bind_methods();
public:
- void configure(const String &p_title, int p_asset_id, const String &p_category, int p_category_id, const String &p_author, int p_author_id, int p_rating, const String &p_cost, int p_version, const String &p_version_string, const String &p_description, const String &p_download_url, const String &p_browse_url, const String &p_sha256_hash);
+ void configure(const String &p_title, int p_asset_id, const String &p_category, int p_category_id, const String &p_author, int p_author_id, const String &p_cost, int p_version, const String &p_version_string, const String &p_description, const String &p_download_url, const String &p_browse_url, const String &p_sha256_hash);
void add_preview(int p_id, bool p_video, const String &p_url);
String get_title() { return title; }
@@ -216,7 +216,6 @@ class EditorAssetLibrary : public PanelContainer {
};
enum SortOrder {
- SORT_RATING,
SORT_DOWNLOADS,
SORT_NAME,
SORT_COST,
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index e8ef689ca3..3c24fd19b6 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -731,6 +731,8 @@ Vector2 CanvasItemEditor::_position_to_anchor(const Control *p_control, Vector2
ERR_FAIL_COND_V(!p_control, Vector2());
Rect2 parent_rect = p_control->get_parent_anchorable_rect();
+ ERR_FAIL_COND_V(parent_rect.size.x == 0, Vector2());
+ ERR_FAIL_COND_V(parent_rect.size.y == 0, Vector2());
return (p_control->get_transform().xform(position) - parent_rect.position) / parent_rect.size;
}
@@ -1081,7 +1083,7 @@ bool CanvasItemEditor::_gui_input_zoom_or_pan(const Ref<InputEvent> &p_event) {
if (b->is_pressed() &&
(b->get_button_index() == BUTTON_MIDDLE ||
(b->get_button_index() == BUTTON_LEFT && tool == TOOL_PAN) ||
- (b->get_button_index() == BUTTON_LEFT && !EditorSettings::get_singleton()->get("editors/2d/simple_spacebar_panning") && Input::get_singleton()->is_key_pressed(KEY_SPACE)))) {
+ (b->get_button_index() == BUTTON_LEFT && !EditorSettings::get_singleton()->get("editors/2d/simple_panning") && pan_pressed))) {
// Pan the viewport
panning = true;
}
@@ -1097,7 +1099,9 @@ bool CanvasItemEditor::_gui_input_zoom_or_pan(const Ref<InputEvent> &p_event) {
Ref<InputEventKey> k = p_event;
if (k.is_valid()) {
- if (k->get_scancode() == KEY_SPACE && (EditorSettings::get_singleton()->get("editors/2d/simple_spacebar_panning") || drag_type != DRAG_NONE)) {
+ bool is_pan_key = pan_view_shortcut.is_valid() && pan_view_shortcut->is_shortcut(p_event);
+
+ if (is_pan_key && (EditorSettings::get_singleton()->get("editors/2d/simple_panning") || drag_type != DRAG_NONE)) {
if (!panning) {
if (k->is_pressed() && !k->is_echo()) {
//Pan the viewport
@@ -1110,6 +1114,9 @@ bool CanvasItemEditor::_gui_input_zoom_or_pan(const Ref<InputEvent> &p_event) {
}
}
}
+
+ if (is_pan_key)
+ pan_pressed = k->is_pressed();
}
Ref<InputEventMouseMotion> m = p_event;
@@ -2214,7 +2221,7 @@ bool CanvasItemEditor::_gui_input_hover(const Ref<InputEvent> &p_event) {
void CanvasItemEditor::_gui_input_viewport(const Ref<InputEvent> &p_event) {
bool accepted = false;
- if (EditorSettings::get_singleton()->get("editors/2d/simple_spacebar_panning") || !Input::get_singleton()->is_key_pressed(KEY_SPACE)) {
+ if (EditorSettings::get_singleton()->get("editors/2d/simple_panning") || !pan_pressed) {
if ((accepted = _gui_input_rulers_and_guides(p_event))) {
//printf("Rulers and guides\n");
} else if ((accepted = editor->get_editor_plugins_over()->forward_gui_input(p_event))) {
@@ -3343,9 +3350,6 @@ void CanvasItemEditor::_notification(int p_what) {
presets_menu->set_visible(true);
anchor_mode_button->set_visible(true);
- // Set the pressed state of the node
- anchor_mode_button->set_pressed(anchors_mode);
-
// Disable if the selected node is child of a container
if (has_container_parents) {
presets_menu->set_disabled(true);
@@ -3516,6 +3520,7 @@ void CanvasItemEditor::_selection_changed() {
}
}
anchors_mode = (nbValidControls == nbAnchorsMode);
+ anchor_mode_button->set_pressed(anchors_mode);
}
void CanvasItemEditor::edit(CanvasItem *p_canvas_item) {
@@ -3737,6 +3742,7 @@ void CanvasItemEditor::_set_anchors_and_margins_preset(Control::LayoutPreset p_p
undo_redo->commit_action();
anchors_mode = false;
+ anchor_mode_button->set_pressed(anchors_mode);
}
void CanvasItemEditor::_set_anchors_and_margins_to_keep_ratio() {
@@ -3761,6 +3767,7 @@ void CanvasItemEditor::_set_anchors_and_margins_to_keep_ratio() {
undo_redo->add_undo_method(control, "set_meta", "_edit_use_anchors_", use_anchors);
anchors_mode = true;
+ anchor_mode_button->set_pressed(anchors_mode);
}
}
@@ -3907,7 +3914,6 @@ void CanvasItemEditor::_button_toggle_anchor_mode(bool p_status) {
}
anchors_mode = p_status;
-
viewport->update();
}
@@ -4780,6 +4786,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
dragged_guide_pos = Point2();
dragged_guide_index = -1;
panning = false;
+ pan_pressed = false;
bone_last_frame = 0;
@@ -5129,6 +5136,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
multiply_grid_step_shortcut = ED_SHORTCUT("canvas_item_editor/multiply_grid_step", TTR("Multiply grid step by 2"), KEY_KP_MULTIPLY);
divide_grid_step_shortcut = ED_SHORTCUT("canvas_item_editor/divide_grid_step", TTR("Divide grid step by 2"), KEY_KP_DIVIDE);
+ pan_view_shortcut = ED_SHORTCUT("canvas_item_editor/pan_view", TTR("Pan View"), KEY_SPACE);
skeleton_menu->get_popup()->set_item_checked(skeleton_menu->get_popup()->get_item_index(SKELETON_SHOW_BONES), true);
singleton = this;
diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h
index e098d261c0..ff221eb758 100644
--- a/editor/plugins/canvas_item_editor_plugin.h
+++ b/editor/plugins/canvas_item_editor_plugin.h
@@ -265,6 +265,7 @@ private:
bool key_rot;
bool key_scale;
bool panning;
+ bool pan_pressed;
MenuOption last_option;
@@ -383,6 +384,7 @@ private:
Ref<ShortCut> set_pivot_shortcut;
Ref<ShortCut> multiply_grid_step_shortcut;
Ref<ShortCut> divide_grid_step_shortcut;
+ Ref<ShortCut> pan_view_shortcut;
bool _is_node_locked(const Node *p_node);
bool _is_node_movable(const Node *p_node, bool p_popup_warning = false);
diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp
index 28e57ac48a..285823d95a 100644
--- a/editor/plugins/editor_preview_plugins.cpp
+++ b/editor/plugins/editor_preview_plugins.cpp
@@ -643,7 +643,7 @@ Ref<Texture> EditorAudioStreamPreviewPlugin::generate(const RES &p_from, const S
float max = -1000;
float min = 1000;
int from = uint64_t(i) * frame_length / w;
- int to = uint64_t(i + 1) * frame_length / w;
+ int to = (uint64_t(i) + 1) * frame_length / w;
to = MIN(to, frame_length);
from = MIN(from, frame_length - 1);
if (to == from) {
diff --git a/editor/plugins/multimesh_editor_plugin.cpp b/editor/plugins/multimesh_editor_plugin.cpp
index fc0a425bfc..cae705a697 100644
--- a/editor/plugins/multimesh_editor_plugin.cpp
+++ b/editor/plugins/multimesh_editor_plugin.cpp
@@ -197,7 +197,7 @@ void MultiMeshEditor::_populate() {
float areapos = Math::random(0.0f, area_accum);
Map<float, int>::Element *E = triangle_area_map.find_closest(areapos);
- ERR_FAIL_COND(!E)
+ ERR_FAIL_COND(!E);
int index = E->get();
ERR_FAIL_INDEX(index, facecount);
diff --git a/editor/plugins/particles_editor_plugin.cpp b/editor/plugins/particles_editor_plugin.cpp
index 66cecf7068..3f4f66a26d 100644
--- a/editor/plugins/particles_editor_plugin.cpp
+++ b/editor/plugins/particles_editor_plugin.cpp
@@ -67,7 +67,7 @@ bool ParticlesEditorBase::_generate(PoolVector<Vector3> &points, PoolVector<Vect
float areapos = Math::random(0.0f, area_accum);
Map<float, int>::Element *E = triangle_area_map.find_closest(areapos);
- ERR_FAIL_COND_V(!E, false)
+ ERR_FAIL_COND_V(!E, false);
int index = E->get();
ERR_FAIL_INDEX_V(index, geometry.size(), false);
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index 3e0494b9b6..b4719b2e6d 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -437,6 +437,8 @@ void ScriptEditor::_go_to_tab(int p_idx) {
if (script != NULL) {
notify_script_changed(script);
}
+
+ Object::cast_to<ScriptEditorBase>(c)->validate();
}
if (Object::cast_to<EditorHelp>(c)) {
@@ -723,6 +725,8 @@ void ScriptEditor::_resave_scripts(const String &p_str) {
se->trim_trailing_whitespace();
}
+ se->insert_final_newline();
+
if (convert_indent_on_save) {
if (use_space_indentation) {
se->convert_indent_to_spaces();
@@ -1078,6 +1082,8 @@ void ScriptEditor::_menu_option(int p_option) {
if (trim_trailing_whitespace_on_save)
current->trim_trailing_whitespace();
+ current->insert_final_newline();
+
if (convert_indent_on_save) {
if (use_space_indentation) {
current->convert_indent_to_spaces();
@@ -1097,7 +1103,10 @@ void ScriptEditor::_menu_option(int p_option) {
} break;
case FILE_SAVE_AS: {
- current->trim_trailing_whitespace();
+ if (trim_trailing_whitespace_on_save)
+ current->trim_trailing_whitespace();
+
+ current->insert_final_newline();
if (convert_indent_on_save) {
if (use_space_indentation) {
@@ -1304,23 +1313,29 @@ void ScriptEditor::_theme_option(int p_option) {
EditorSettings::get_singleton()->load_text_editor_theme();
} break;
case THEME_SAVE: {
- if (!EditorSettings::get_singleton()->save_text_editor_theme()) {
+ if (EditorSettings::get_singleton()->is_default_text_editor_theme()) {
+ ScriptEditor::_show_save_theme_as_dialog();
+ } else if (!EditorSettings::get_singleton()->save_text_editor_theme()) {
editor->show_warning(TTR("Error while saving theme"), TTR("Error saving"));
}
} break;
case THEME_SAVE_AS: {
- file_dialog->set_mode(EditorFileDialog::MODE_SAVE_FILE);
- file_dialog->set_access(EditorFileDialog::ACCESS_FILESYSTEM);
- file_dialog_option = THEME_SAVE_AS;
- file_dialog->clear_filters();
- file_dialog->add_filter("*.tet");
- file_dialog->set_current_path(EditorSettings::get_singleton()->get_text_editor_themes_dir().plus_file(EditorSettings::get_singleton()->get("text_editor/theme/color_theme")));
- file_dialog->popup_centered_ratio();
- file_dialog->set_title(TTR("Save Theme As..."));
+ ScriptEditor::_show_save_theme_as_dialog();
} break;
}
}
+void ScriptEditor::_show_save_theme_as_dialog() {
+ file_dialog->set_mode(EditorFileDialog::MODE_SAVE_FILE);
+ file_dialog->set_access(EditorFileDialog::ACCESS_FILESYSTEM);
+ file_dialog_option = THEME_SAVE_AS;
+ file_dialog->clear_filters();
+ file_dialog->add_filter("*.tet");
+ file_dialog->set_current_path(EditorSettings::get_singleton()->get_text_editor_themes_dir().plus_file(EditorSettings::get_singleton()->get("text_editor/theme/color_theme")));
+ file_dialog->popup_centered_ratio();
+ file_dialog->set_title(TTR("Save Theme As..."));
+}
+
void ScriptEditor::_tab_changed(int p_which) {
ensure_select_current();
@@ -1981,10 +1996,11 @@ bool ScriptEditor::edit(const RES &p_resource, int p_line, int p_col, bool p_gra
String flags = EditorSettings::get_singleton()->get("text_editor/external/exec_flags");
List<String> args;
+ bool has_file_flag = false;
+ String script_path = ProjectSettings::get_singleton()->globalize_path(p_resource->get_path());
if (flags.size()) {
String project_path = ProjectSettings::get_singleton()->get_resource_path();
- String script_path = ProjectSettings::get_singleton()->globalize_path(p_resource->get_path());
flags = flags.replacen("{line}", itos(p_line > 0 ? p_line : 0));
flags = flags.replacen("{col}", itos(p_col));
@@ -2006,6 +2022,9 @@ bool ScriptEditor::edit(const RES &p_resource, int p_line, int p_col, bool p_gra
} else if (flags[i] == '\0' || (!inside_quotes && flags[i] == ' ')) {
String arg = flags.substr(from, num_chars);
+ if (arg.find("{file}") != -1) {
+ has_file_flag = true;
+ }
// do path replacement here, else there will be issues with spaces and quotes
arg = arg.replacen("{project}", project_path);
@@ -2020,6 +2039,11 @@ bool ScriptEditor::edit(const RES &p_resource, int p_line, int p_col, bool p_gra
}
}
+ // Default to passing script path if no {file} flag is specified.
+ if (!has_file_flag) {
+ args.push_back(script_path);
+ }
+
Error err = OS::get_singleton()->execute(path, args, false);
if (err == OK)
return false;
@@ -2046,6 +2070,8 @@ bool ScriptEditor::edit(const RES &p_resource, int p_line, int p_col, bool p_gra
se->goto_line(p_line - 1);
}
}
+ _update_script_names();
+ script_list->ensure_current_is_visible();
return true;
}
}
@@ -2133,6 +2159,8 @@ void ScriptEditor::save_all_scripts() {
se->trim_trailing_whitespace();
}
+ se->insert_final_newline();
+
if (!se->is_unsaved())
continue;
@@ -3466,7 +3494,8 @@ ScriptEditorPlugin::ScriptEditorPlugin(EditorNode *p_node) {
EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::INT, "text_editor/open_scripts/list_script_names_as", PROPERTY_HINT_ENUM, "Name,Parent Directory And Name,Full Path"));
EDITOR_DEF("text_editor/open_scripts/list_script_names_as", 0);
EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "text_editor/external/exec_path", PROPERTY_HINT_GLOBAL_FILE));
- EDITOR_DEF("text_editor/external/exec_flags", "");
+ EDITOR_DEF("text_editor/external/exec_flags", "{file}");
+ EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "text_editor/external/exec_flags", PROPERTY_HINT_PLACEHOLDER_TEXT, "Call flags with placeholders: {project}, {file}, {col}, {line}."));
ED_SHORTCUT("script_editor/open_recent", TTR("Open Recent"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_T);
ED_SHORTCUT("script_editor/clear_recent", TTR("Clear Recent Files"));
diff --git a/editor/plugins/script_editor_plugin.h b/editor/plugins/script_editor_plugin.h
index 35f32107f5..0d9168261a 100644
--- a/editor/plugins/script_editor_plugin.h
+++ b/editor/plugins/script_editor_plugin.h
@@ -100,6 +100,7 @@ public:
virtual void set_executing_line(int p_line) = 0;
virtual void clear_executing_line() = 0;
virtual void trim_trailing_whitespace() = 0;
+ virtual void insert_final_newline() = 0;
virtual void convert_indent_to_spaces() = 0;
virtual void convert_indent_to_tabs() = 0;
virtual void ensure_focus() = 0;
@@ -117,6 +118,8 @@ public:
virtual Control *get_edit_menu() = 0;
virtual void clear_edit_menu() = 0;
+ virtual void validate() = 0;
+
ScriptEditorBase() {}
};
@@ -267,6 +270,7 @@ class ScriptEditor : public PanelContainer {
void _tab_changed(int p_which);
void _menu_option(int p_option);
void _theme_option(int p_option);
+ void _show_save_theme_as_dialog();
Tree *disk_changed_list;
ConfirmationDialog *disk_changed;
diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp
index 1fe4ac1372..ce0859a1f6 100644
--- a/editor/plugins/script_text_editor.cpp
+++ b/editor/plugins/script_text_editor.cpp
@@ -457,6 +457,11 @@ void ScriptTextEditor::trim_trailing_whitespace() {
code_editor->trim_trailing_whitespace();
}
+void ScriptTextEditor::insert_final_newline() {
+
+ code_editor->insert_final_newline();
+}
+
void ScriptTextEditor::convert_indent_to_spaces() {
code_editor->convert_indent_to_spaces();
@@ -542,7 +547,6 @@ void ScriptTextEditor::_validate_script() {
script->set_source_code(text);
script->update_exports();
_update_member_keywords();
- //script->reload(); //will update all the variables in property editors
}
functions.clear();
@@ -553,30 +557,36 @@ void ScriptTextEditor::_validate_script() {
}
_update_connected_methods();
- code_editor->set_warning_nb(missing_connections.size() + warnings.size());
+ int warning_nb = warnings.size();
warnings_panel->clear();
- // add missing connections
- Node *base = get_tree()->get_edited_scene_root();
- if (base && missing_connections.size() > 0) {
- warnings_panel->push_table(1);
- for (List<Connection>::Element *E = missing_connections.front(); E; E = E->next()) {
- Connection connection = E->get();
-
- String base_path = base->get_name();
- String source_path = base == connection.source ? base_path : base_path + "/" + String(base->get_path_to(Object::cast_to<Node>(connection.source)));
- String target_path = base == connection.target ? base_path : base_path + "/" + String(base->get_path_to(Object::cast_to<Node>(connection.target)));
+ // Add missing connections.
+ if (GLOBAL_GET("debug/gdscript/warnings/enable").booleanize()) {
+ Node *base = get_tree()->get_edited_scene_root();
+ if (base && missing_connections.size() > 0) {
+ warnings_panel->push_table(1);
+ for (List<Connection>::Element *E = missing_connections.front(); E; E = E->next()) {
+ Connection connection = E->get();
+
+ String base_path = base->get_name();
+ String source_path = base == connection.source ? base_path : base_path + "/" + String(base->get_path_to(Object::cast_to<Node>(connection.source)));
+ String target_path = base == connection.target ? base_path : base_path + "/" + String(base->get_path_to(Object::cast_to<Node>(connection.target)));
+
+ warnings_panel->push_cell();
+ warnings_panel->push_color(warnings_panel->get_color("warning_color", "Editor"));
+ warnings_panel->add_text(vformat(TTR("Missing connected method '%s' for signal '%s' from node '%s' to node '%s'."), connection.method, connection.signal, source_path, target_path));
+ warnings_panel->pop(); // Color.
+ warnings_panel->pop(); // Cell.
+ }
+ warnings_panel->pop(); // Table.
- warnings_panel->push_cell();
- warnings_panel->push_color(warnings_panel->get_color("warning_color", "Editor"));
- warnings_panel->add_text(vformat(TTR("Missing connected method '%s' for signal '%s' from node '%s' to node '%s'"), connection.method, connection.signal, source_path, target_path));
- warnings_panel->pop(); // Color
- warnings_panel->pop(); // Cell
+ warning_nb += missing_connections.size();
}
- warnings_panel->pop(); // Table
}
- // add script warnings
+ code_editor->set_warning_nb(warning_nb);
+
+ // Add script warnings.
warnings_panel->push_table(3);
for (List<ScriptLanguage::Warning>::Element *E = warnings.front(); E; E = E->next()) {
ScriptLanguage::Warning w = E->get();
@@ -586,13 +596,13 @@ void ScriptTextEditor::_validate_script() {
warnings_panel->push_color(warnings_panel->get_color("warning_color", "Editor"));
warnings_panel->add_text(TTR("Line") + " " + itos(w.line));
warnings_panel->add_text(" (" + w.string_code + "):");
- warnings_panel->pop(); // Color
- warnings_panel->pop(); // Meta goto
- warnings_panel->pop(); // Cell
+ warnings_panel->pop(); // Color.
+ warnings_panel->pop(); // Meta goto.
+ warnings_panel->pop(); // Cell.
warnings_panel->push_cell();
warnings_panel->add_text(w.message);
- warnings_panel->pop(); // Cell
+ warnings_panel->pop(); // Cell.
Dictionary ignore_meta;
ignore_meta["line"] = w.line;
@@ -600,11 +610,10 @@ void ScriptTextEditor::_validate_script() {
warnings_panel->push_cell();
warnings_panel->push_meta(ignore_meta);
warnings_panel->add_text(TTR("(ignore)"));
- warnings_panel->pop(); // Meta ignore
- warnings_panel->pop(); // Cell
- //warnings_panel->add_newline();
+ warnings_panel->pop(); // Meta ignore.
+ warnings_panel->pop(); // Cell.
}
- warnings_panel->pop(); // Table
+ warnings_panel->pop(); // Table.
line--;
bool highlight_safe = EDITOR_DEF("text_editor/highlighting/highlight_type_safe_lines", true);
@@ -867,12 +876,36 @@ void ScriptTextEditor::_update_connected_methods() {
continue;
}
- int line = script->get_language()->find_function(connection.method, text_edit->get_text());
- if (line < 0) {
- missing_connections.push_back(connection);
+ // As deleted nodes are still accessible via the undo/redo system, check if they're still on the tree.
+ Node *source = Object::cast_to<Node>(connection.source);
+ if (source && !source->is_inside_tree()) {
continue;
}
- text_edit->set_line_info_icon(line - 1, get_parent_control()->get_icon("Slot", "EditorIcons"), connection.method);
+
+ if (!ClassDB::has_method(script->get_instance_base_type(), connection.method)) {
+
+ int line = script->get_language()->find_function(connection.method, text_edit->get_text());
+ if (line < 0) {
+ // There is a chance that the method is inherited from another script.
+ bool found_inherited_function = false;
+ Ref<Script> inherited_script = script->get_base_script();
+ while (!inherited_script.is_null()) {
+ line = inherited_script->get_language()->find_function(connection.method, inherited_script->get_source_code());
+ if (line != -1) {
+ found_inherited_function = true;
+ break;
+ }
+
+ inherited_script = inherited_script->get_base_script();
+ }
+
+ if (!found_inherited_function) {
+ missing_connections.push_back(connection);
+ }
+ } else {
+ text_edit->set_line_info_icon(line - 1, get_parent_control()->get_icon("Slot", "EditorIcons"), connection.method);
+ }
+ }
}
}
}
@@ -1777,3 +1810,7 @@ void ScriptTextEditor::register_editor() {
ScriptEditor::register_create_script_editor_function(create_editor);
}
+
+void ScriptTextEditor::validate() {
+ this->code_editor->validate_script();
+}
diff --git a/editor/plugins/script_text_editor.h b/editor/plugins/script_text_editor.h
index bdfdf18d45..24d40a5eec 100644
--- a/editor/plugins/script_text_editor.h
+++ b/editor/plugins/script_text_editor.h
@@ -194,6 +194,7 @@ public:
virtual void set_edit_state(const Variant &p_state);
virtual void ensure_focus();
virtual void trim_trailing_whitespace();
+ virtual void insert_final_newline();
virtual void convert_indent_to_spaces();
virtual void convert_indent_to_tabs();
virtual void tag_saved_version();
@@ -219,6 +220,8 @@ public:
virtual void clear_edit_menu();
static void register_editor();
+ virtual void validate();
+
ScriptTextEditor();
};
diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp
index a795405dfc..f9ca38b919 100644
--- a/editor/plugins/shader_editor_plugin.cpp
+++ b/editor/plugins/shader_editor_plugin.cpp
@@ -60,6 +60,26 @@ void ShaderTextEditor::set_edited_shader(const Ref<Shader> &p_shader) {
_line_col_changed();
}
+void ShaderTextEditor::reload_text() {
+ ERR_FAIL_COND(shader.is_null());
+
+ TextEdit *te = get_text_edit();
+ int column = te->cursor_get_column();
+ int row = te->cursor_get_line();
+ int h = te->get_h_scroll();
+ int v = te->get_v_scroll();
+
+ te->set_text(shader->get_code());
+ te->cursor_set_line(row);
+ te->cursor_set_column(column);
+ te->set_h_scroll(h);
+ te->set_v_scroll(v);
+
+ te->tag_saved_version();
+
+ update_line_and_column();
+}
+
void ShaderTextEditor::_load_theme_settings() {
get_text_edit()->clear_colors();
@@ -330,9 +350,8 @@ void ShaderEditor::_menu_option(int p_option) {
void ShaderEditor::_notification(int p_what) {
- if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
- //if (is_visible_in_tree())
- // shader_editor->get_text_edit()->grab_focus();
+ if (p_what == MainLoop::NOTIFICATION_WM_FOCUS_IN) {
+ _check_for_external_edit();
}
}
@@ -363,12 +382,14 @@ void ShaderEditor::_editor_settings_changed() {
void ShaderEditor::_bind_methods() {
+ ClassDB::bind_method("_reload_shader_from_disk", &ShaderEditor::_reload_shader_from_disk);
ClassDB::bind_method("_editor_settings_changed", &ShaderEditor::_editor_settings_changed);
ClassDB::bind_method("_text_edit_gui_input", &ShaderEditor::_text_edit_gui_input);
ClassDB::bind_method("_menu_option", &ShaderEditor::_menu_option);
ClassDB::bind_method("_params_changed", &ShaderEditor::_params_changed);
ClassDB::bind_method("apply_shaders", &ShaderEditor::apply_shaders);
+ ClassDB::bind_method("save_external_data", &ShaderEditor::save_external_data);
}
void ShaderEditor::ensure_select_current() {
@@ -389,6 +410,37 @@ void ShaderEditor::goto_line_selection(int p_line, int p_begin, int p_end) {
shader_editor->goto_line_selection(p_line, p_begin, p_end);
}
+void ShaderEditor::_check_for_external_edit() {
+
+ if (shader.is_null() || !shader.is_valid()) {
+ return;
+ }
+
+ // internal shader.
+ if (shader->get_path() == "" || shader->get_path().find("local://") != -1 || shader->get_path().find("::") != -1) {
+ return;
+ }
+
+ bool use_autoreload = bool(EDITOR_DEF("text_editor/files/auto_reload_scripts_on_external_change", false));
+ if (shader->get_last_modified_time() != FileAccess::get_modified_time(shader->get_path())) {
+ if (use_autoreload) {
+ _reload_shader_from_disk();
+ } else {
+ disk_changed->call_deferred("popup_centered");
+ }
+ }
+}
+
+void ShaderEditor::_reload_shader_from_disk() {
+
+ Ref<Shader> rel_shader = ResourceLoader::load(shader->get_path(), shader->get_class(), true);
+ ERR_FAIL_COND(!rel_shader.is_valid());
+
+ shader->set_code(rel_shader->get_code());
+ shader->set_last_modified_time(rel_shader->get_last_modified_time());
+ shader_editor->reload_text();
+}
+
void ShaderEditor::edit(const Ref<Shader> &p_shader) {
if (p_shader.is_null() || !p_shader->is_text_shader())
@@ -405,16 +457,20 @@ void ShaderEditor::edit(const Ref<Shader> &p_shader) {
// see if already has it
}
-void ShaderEditor::save_external_data() {
+void ShaderEditor::save_external_data(const String &p_str) {
- if (shader.is_null())
+ if (shader.is_null()) {
+ disk_changed->hide();
return;
- apply_shaders();
+ }
+ apply_shaders();
if (shader->get_path() != "" && shader->get_path().find("local://") == -1 && shader->get_path().find("::") == -1) {
//external shader, save it
ResourceSaver::save(shader->get_path(), shader);
}
+
+ disk_changed->hide();
}
void ShaderEditor::apply_shaders() {
@@ -573,6 +629,23 @@ ShaderEditor::ShaderEditor(EditorNode *p_node) {
goto_line_dialog = memnew(GotoLineDialog);
add_child(goto_line_dialog);
+ disk_changed = memnew(ConfirmationDialog);
+
+ VBoxContainer *vbc = memnew(VBoxContainer);
+ disk_changed->add_child(vbc);
+
+ Label *dl = memnew(Label);
+ dl->set_text(TTR("This shader has been modified on on disk.\nWhat action should be taken?"));
+ vbc->add_child(dl);
+
+ disk_changed->connect("confirmed", this, "_reload_shader_from_disk");
+ disk_changed->get_ok()->set_text(TTR("Reload"));
+
+ disk_changed->add_button(TTR("Resave"), !OS::get_singleton()->get_swap_ok_cancel(), "resave");
+ disk_changed->connect("custom_action", this, "save_external_data");
+
+ add_child(disk_changed);
+
_editor_settings_changed();
}
diff --git a/editor/plugins/shader_editor_plugin.h b/editor/plugins/shader_editor_plugin.h
index 28ac9faaa5..b56c1451ad 100644
--- a/editor/plugins/shader_editor_plugin.h
+++ b/editor/plugins/shader_editor_plugin.h
@@ -58,6 +58,8 @@ protected:
public:
virtual void _validate_script();
+ void reload_text();
+
Ref<Shader> get_edited_shader() const;
void set_edited_shader(const Ref<Shader> &p_shader);
ShaderTextEditor();
@@ -103,6 +105,7 @@ class ShaderEditor : public PanelContainer {
GotoLineDialog *goto_line_dialog;
ConfirmationDialog *erase_tab_confirm;
+ ConfirmationDialog *disk_changed;
ShaderTextEditor *shader_editor;
@@ -112,6 +115,9 @@ class ShaderEditor : public PanelContainer {
void _editor_settings_changed();
+ void _check_for_external_edit();
+ void _reload_shader_from_disk();
+
protected:
void _notification(int p_what);
static void _bind_methods();
@@ -127,7 +133,7 @@ public:
void goto_line_selection(int p_line, int p_begin, int p_end);
virtual Size2 get_minimum_size() const { return Size2(0, 200); }
- void save_external_data();
+ void save_external_data(const String &p_str = "");
ShaderEditor(EditorNode *p_node);
};
diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp
index 60f1248ace..a1c0b732fa 100644
--- a/editor/plugins/spatial_editor_plugin.cpp
+++ b/editor/plugins/spatial_editor_plugin.cpp
@@ -4211,7 +4211,7 @@ void SpatialEditor::set_state(const Dictionary &p_state) {
Array vp = d["viewports"];
uint32_t vp_size = static_cast<uint32_t>(vp.size());
if (vp_size > VIEWPORTS_COUNT) {
- WARN_PRINT("Ignoring superfluous viewport settings from spatial editor state.")
+ WARN_PRINT("Ignoring superfluous viewport settings from spatial editor state.");
vp_size = VIEWPORTS_COUNT;
}
diff --git a/editor/plugins/text_editor.cpp b/editor/plugins/text_editor.cpp
index a0f3c253d1..eeef3397d2 100644
--- a/editor/plugins/text_editor.cpp
+++ b/editor/plugins/text_editor.cpp
@@ -251,6 +251,11 @@ void TextEditor::trim_trailing_whitespace() {
code_editor->trim_trailing_whitespace();
}
+void TextEditor::insert_final_newline() {
+
+ code_editor->insert_final_newline();
+}
+
void TextEditor::convert_indent_to_spaces() {
code_editor->convert_indent_to_spaces();
@@ -649,3 +654,6 @@ TextEditor::TextEditor() {
code_editor->get_text_edit()->set_drag_forwarding(this);
}
+
+void TextEditor::validate() {
+}
diff --git a/editor/plugins/text_editor.h b/editor/plugins/text_editor.h
index 2da7474793..e91909e0ea 100644
--- a/editor/plugins/text_editor.h
+++ b/editor/plugins/text_editor.h
@@ -130,6 +130,7 @@ public:
virtual void set_executing_line(int p_line);
virtual void clear_executing_line();
virtual void trim_trailing_whitespace();
+ virtual void insert_final_newline();
virtual void convert_indent_to_spaces();
virtual void convert_indent_to_tabs();
virtual void ensure_focus();
@@ -144,6 +145,8 @@ public:
virtual Control *get_edit_menu();
virtual void clear_edit_menu();
+ virtual void validate();
+
static void register_editor();
TextEditor();
diff --git a/editor/plugins/tile_map_editor_plugin.cpp b/editor/plugins/tile_map_editor_plugin.cpp
index 4ef2d17128..16f93b8fd3 100644
--- a/editor/plugins/tile_map_editor_plugin.cpp
+++ b/editor/plugins/tile_map_editor_plugin.cpp
@@ -299,9 +299,13 @@ void TileMapEditor::_set_cell(const Point2i &p_pos, Vector<int> p_values, bool p
Vector2 position;
int current = manual_palette->get_current();
if (current != -1) {
- position = manual_palette->get_item_metadata(current);
+ if (tool != TOOL_PASTING) {
+ position = manual_palette->get_item_metadata(current);
+ } else {
+ position = p_autotile_coord;
+ }
} else {
- // if there is no manual tile selected, that either means that
+ // If there is no manual tile selected, that either means that
// autotiling is enabled, or the given tile is not autotiling. Either
// way, the coordinate of the tile does not matter, so assigning it to
// the coordinate of the existing tile works fine.
@@ -309,7 +313,7 @@ void TileMapEditor::_set_cell(const Point2i &p_pos, Vector<int> p_values, bool p
}
if (p_value == prev_val && p_flip_h == prev_flip_h && p_flip_v == prev_flip_v && p_transpose == prev_transpose && prev_position == position)
- return; //check that it's actually different
+ return; // Check that it's actually different.
for (int y = p_pos.y - 1; y <= p_pos.y + 1; y++) {
for (int x = p_pos.x - 1; x <= p_pos.x + 1; x++) {
@@ -322,21 +326,19 @@ void TileMapEditor::_set_cell(const Point2i &p_pos, Vector<int> p_values, bool p
node->_set_celld(p_pos, _create_cell_dictionary(p_value, p_flip_h, p_flip_v, p_transpose, p_autotile_coord));
+ if (tool == TOOL_PASTING)
+ return;
+
if (manual_autotile || (p_value != -1 && node->get_tileset()->tile_get_tile_mode(p_value) == TileSet::ATLAS_TILE)) {
if (current != -1) {
node->set_cell_autotile_coord(p_pos.x, p_pos.y, position);
-
- } else if (tool != TOOL_PASTING && node->get_tileset()->tile_get_tile_mode(p_value) == TileSet::ATLAS_TILE && priority_atlastile) {
-
- // BIND_CENTER is used to indicate that bitmask should not update for this tile cell
+ } else if (node->get_tileset()->tile_get_tile_mode(p_value) == TileSet::ATLAS_TILE && priority_atlastile) {
+ // BIND_CENTER is used to indicate that bitmask should not update for this tile cell.
node->get_tileset()->autotile_set_bitmask(p_value, Vector2(p_pos.x, p_pos.y), TileSet::BIND_CENTER);
node->update_cell_bitmask(p_pos.x, p_pos.y);
}
} else {
- // manually placing tiles should not update bitmasks
- if (tool != TOOL_PASTING) {
- node->update_bitmask_area(Point2(p_pos));
- }
+ node->update_bitmask_area(Point2(p_pos));
}
}
@@ -396,6 +398,8 @@ void TileMapEditor::_update_palette() {
// Update the palette
Vector<int> selected = get_selected_tiles();
+ int selected_single = palette->get_current();
+ int selected_manual = manual_palette->get_current();
palette->clear();
manual_palette->clear();
manual_palette->hide();
@@ -503,7 +507,7 @@ void TileMapEditor::_update_palette() {
if (selected.get(0) != TileMap::INVALID_CELL) {
set_selected_tiles(selected);
sel_tile = selected.get(Math::rand() % selected.size());
- } else {
+ } else if (palette->get_item_count() > 0) {
palette->select(0);
}
@@ -545,9 +549,10 @@ void TileMapEditor::_update_palette() {
if (manual_palette->get_item_count() > 0) {
// Only show the manual palette if at least tile exists in it
- int selected2 = manual_palette->get_current();
- if (selected2 == -1) selected2 = 0;
- manual_palette->set_current(selected2);
+ if (selected_manual == -1 || selected_single != palette->get_current())
+ selected_manual = 0;
+ if (selected_manual < manual_palette->get_item_count())
+ manual_palette->set_current(selected_manual);
manual_palette->show();
}
@@ -567,23 +572,25 @@ void TileMapEditor::_pick_tile(const Point2 &p_pos) {
if (id == TileMap::INVALID_CELL)
return;
- if (search_box->get_text().strip_edges() != "") {
-
+ if (search_box->get_text() != "") {
search_box->set_text("");
_update_palette();
}
- Vector<int> selected;
-
- selected.push_back(id);
- set_selected_tiles(selected);
-
flip_h = node->is_cell_x_flipped(p_pos.x, p_pos.y);
flip_v = node->is_cell_y_flipped(p_pos.x, p_pos.y);
transpose = node->is_cell_transposed(p_pos.x, p_pos.y);
autotile_coord = node->get_cell_autotile_coord(p_pos.x, p_pos.y);
+ Vector<int> selected;
+ selected.push_back(id);
+ set_selected_tiles(selected);
_update_palette();
+
+ if ((manual_autotile && node->get_tileset()->tile_get_tile_mode(id) == TileSet::AUTO_TILE) || (!priority_atlastile && node->get_tileset()->tile_get_tile_mode(id) == TileSet::ATLAS_TILE)) {
+ manual_palette->select(manual_palette->find_metadata((Point2)autotile_coord));
+ }
+
CanvasItemEditor::get_singleton()->update_viewport();
}
@@ -759,15 +766,15 @@ void TileMapEditor::_draw_cell(Control *p_viewport, int p_cell, const Point2i &p
Rect2 r = node->get_tileset()->tile_get_region(p_cell);
if (node->get_tileset()->tile_get_tile_mode(p_cell) == TileSet::AUTO_TILE || node->get_tileset()->tile_get_tile_mode(p_cell) == TileSet::ATLAS_TILE) {
Vector2 offset;
- int selected = manual_palette->get_current();
- if ((manual_autotile || (node->get_tileset()->tile_get_tile_mode(p_cell) == TileSet::ATLAS_TILE && !priority_atlastile)) && selected != -1) {
- offset = manual_palette->get_item_metadata(selected);
- } else {
- if (tool != TOOL_PASTING) {
- offset = node->get_tileset()->autotile_get_icon_coordinate(p_cell);
+ if (tool != TOOL_PASTING) {
+ int selected = manual_palette->get_current();
+ if ((manual_autotile || (node->get_tileset()->tile_get_tile_mode(p_cell) == TileSet::ATLAS_TILE && !priority_atlastile)) && selected != -1) {
+ offset = manual_palette->get_item_metadata(selected);
} else {
- offset = p_autotile_coord;
+ offset = node->get_tileset()->autotile_get_icon_coordinate(p_cell);
}
+ } else {
+ offset = p_autotile_coord;
}
int spacing = node->get_tileset()->autotile_get_spacing(p_cell);
@@ -775,7 +782,8 @@ void TileMapEditor::_draw_cell(Control *p_viewport, int p_cell, const Point2i &p
r.position += (r.size + Vector2(spacing, spacing)) * offset;
}
Size2 sc = p_xform.get_scale();
- Size2 cell_size = node->get_cell_size();
+ /* For a future CheckBox to Center Texture:
+ Size2 cell_size = node->get_cell_size(); */
Rect2 rect = Rect2();
rect.position = node->map_to_world(p_point) + node->get_cell_draw_offset();
@@ -787,10 +795,11 @@ void TileMapEditor::_draw_cell(Control *p_viewport, int p_cell, const Point2i &p
if (p_transpose) {
SWAP(tile_ofs.x, tile_ofs.y);
+ /* For a future CheckBox to Center Texture:
rect.position.x += cell_size.x / 2 - rect.size.y / 2;
rect.position.y += cell_size.y / 2 - rect.size.x / 2;
} else {
- rect.position += cell_size / 2 - rect.size / 2;
+ rect.position += cell_size / 2 - rect.size / 2; */
}
if (p_flip_h) {
@@ -810,10 +819,11 @@ void TileMapEditor::_draw_cell(Control *p_viewport, int p_cell, const Point2i &p
Color modulate = node->get_tileset()->tile_get_modulate(p_cell);
modulate.a = 0.5;
- if (r.has_no_area())
+ if (r.has_no_area()) {
p_viewport->draw_texture_rect(t, rect, false, modulate, p_transpose);
- else
+ } else {
p_viewport->draw_texture_rect_region(t, rect, r, modulate, p_transpose);
+ }
}
void TileMapEditor::_draw_fill_preview(Control *p_viewport, int p_cell, const Point2i &p_point, bool p_flip_h, bool p_flip_v, bool p_transpose, const Point2i p_autotile_coord, const Transform2D &p_xform) {
@@ -848,7 +858,6 @@ void TileMapEditor::_update_copydata() {
TileData tcd;
tcd.cell = node->get_cell(j, i);
-
if (tcd.cell != TileMap::INVALID_CELL) {
tcd.pos = Point2i(j, i);
tcd.flip_h = node->is_cell_x_flipped(j, i);
@@ -975,7 +984,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
return true;
} else {
- // Mousebutton was released
+ // Mousebutton was released.
if (tool != TOOL_NONE) {
if (tool == TOOL_PAINTING) {
@@ -1039,7 +1048,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
CanvasItemEditor::get_singleton()->update_viewport();
- return true; // We want to keep the Pasting tool
+ return true; // We want to keep the Pasting tool.
} else if (tool == TOOL_SELECTING) {
CanvasItemEditor::get_singleton()->update_viewport();
@@ -1063,7 +1072,10 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
_finish_undo();
- // We want to keep the bucket-tool active
+ // So the fill preview is cleared right after the click.
+ CanvasItemEditor::get_singleton()->update_viewport();
+
+ // We want to keep the bucket-tool active.
return true;
}
@@ -1190,7 +1202,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
if (tool == TOOL_PAINTING) {
- // Paint using bresenham line to prevent holes in painting if the user moves fast
+ // Paint using bresenham line to prevent holes in painting if the user moves fast.
Vector<Point2i> points = line(old_over_tile.x, over_tile.x, old_over_tile.y, over_tile.y);
Vector<int> ids = get_selected_tiles();
@@ -1211,7 +1223,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
if (tool == TOOL_ERASING) {
- // erase using bresenham line to prevent holes in painting if the user moves fast
+ // Erase using bresenham line to prevent holes in painting if the user moves fast.
Vector<Point2i> points = line(old_over_tile.x, over_tile.x, old_over_tile.y, over_tile.y);
@@ -1336,13 +1348,13 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
}
if (!mouse_over) {
- // Editor shortcuts should not fire if mouse not in viewport
+ // Editor shortcuts should not fire if mouse not in viewport.
return false;
}
if (ED_IS_SHORTCUT("tile_map_editor/paint_tile", p_event)) {
// NOTE: We do not set tool = TOOL_PAINTING as this begins painting
- // immediately without pressing the left mouse button first
+ // immediately without pressing the left mouse button first.
tool = TOOL_NONE;
CanvasItemEditor::get_singleton()->update_viewport();
@@ -1424,7 +1436,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
CanvasItemEditor::get_singleton()->update_viewport();
return true;
}
- } else if (k.is_valid()) { // release event
+ } else if (k.is_valid()) { // Release event.
if (tool == TOOL_NONE) {
@@ -1440,7 +1452,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
#else
if (k->get_scancode() == KEY_CONTROL) {
#endif
- // go back to that last tool if KEY_CONTROL was released
+ // Go back to that last tool if KEY_CONTROL was released.
tool = last_tool;
CanvasItemEditor::get_singleton()->update_viewport();
@@ -1980,31 +1992,31 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) {
p->connect("id_pressed", this, "_menu_option");
rotate_left_button = memnew(ToolButton);
- rotate_left_button->set_tooltip(TTR("Rotate left"));
+ rotate_left_button->set_tooltip(TTR("Rotate Left"));
rotate_left_button->set_focus_mode(FOCUS_NONE);
rotate_left_button->connect("pressed", this, "_rotate", varray(-1));
tool_hb->add_child(rotate_left_button);
rotate_right_button = memnew(ToolButton);
- rotate_right_button->set_tooltip(TTR("Rotate right"));
+ rotate_right_button->set_tooltip(TTR("Rotate Right"));
rotate_right_button->set_focus_mode(FOCUS_NONE);
rotate_right_button->connect("pressed", this, "_rotate", varray(1));
tool_hb->add_child(rotate_right_button);
flip_horizontal_button = memnew(ToolButton);
- flip_horizontal_button->set_tooltip(TTR("Flip horizontally"));
+ flip_horizontal_button->set_tooltip(TTR("Flip Horizontally"));
flip_horizontal_button->set_focus_mode(FOCUS_NONE);
flip_horizontal_button->connect("pressed", this, "_flip_horizontal");
tool_hb->add_child(flip_horizontal_button);
flip_vertical_button = memnew(ToolButton);
- flip_vertical_button->set_tooltip(TTR("Flip vertically"));
+ flip_vertical_button->set_tooltip(TTR("Flip Vertically"));
flip_vertical_button->set_focus_mode(FOCUS_NONE);
flip_vertical_button->connect("pressed", this, "_flip_vertical");
tool_hb->add_child(flip_vertical_button);
clear_transform_button = memnew(ToolButton);
- clear_transform_button->set_tooltip(TTR("Clear transform"));
+ clear_transform_button->set_tooltip(TTR("Clear Transform"));
clear_transform_button->set_focus_mode(FOCUS_NONE);
clear_transform_button->connect("pressed", this, "_clear_transform");
tool_hb->add_child(clear_transform_button);