summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
Diffstat (limited to 'editor')
-rw-r--r--editor/animation_track_editor.cpp3
-rw-r--r--editor/code_editor.cpp5
-rw-r--r--editor/connections_dialog.cpp1
-rw-r--r--editor/editor_inspector.cpp36
-rw-r--r--editor/editor_node.cpp17
-rw-r--r--editor/editor_settings.cpp8
-rw-r--r--editor/find_in_files.cpp14
-rw-r--r--editor/find_in_files.h2
-rw-r--r--editor/import/resource_importer_texture_atlas.cpp8
-rw-r--r--editor/plugins/asset_library_editor_plugin.cpp11
-rw-r--r--editor/plugins/mesh_instance_editor_plugin.cpp2
-rw-r--r--editor/plugins/script_editor_plugin.cpp2
-rw-r--r--editor/plugins/script_text_editor.cpp15
-rw-r--r--editor/plugins/shader_editor_plugin.cpp5
-rw-r--r--editor/plugins/visual_shader_editor_plugin.cpp92
-rw-r--r--editor/plugins/visual_shader_editor_plugin.h17
16 files changed, 190 insertions, 48 deletions
diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp
index 9742cadfd3..8758fbcfc9 100644
--- a/editor/animation_track_editor.cpp
+++ b/editor/animation_track_editor.cpp
@@ -2480,6 +2480,9 @@ void AnimationTrackEdit::_path_entered(const String &p_text) {
bool AnimationTrackEdit::_is_value_key_valid(const Variant &p_key_value, Variant::Type &r_valid_type) const {
+ if (root == nullptr)
+ return false;
+
RES res;
Vector<StringName> leftover_path;
Node *node = root->get_node_and_resource(animation->track_get_path(track), res, leftover_path);
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp
index 86631def9d..948955eabd 100644
--- a/editor/code_editor.cpp
+++ b/editor/code_editor.cpp
@@ -925,8 +925,9 @@ void CodeTextEditor::update_editor_settings() {
text_editor->set_hiding_enabled(EditorSettings::get_singleton()->get("text_editor/appearance/code_folding"));
text_editor->set_draw_fold_gutter(EditorSettings::get_singleton()->get("text_editor/appearance/code_folding"));
text_editor->set_wrap_enabled(EditorSettings::get_singleton()->get("text_editor/appearance/word_wrap"));
- text_editor->set_show_line_length_guideline(EditorSettings::get_singleton()->get("text_editor/appearance/show_line_length_guideline"));
- text_editor->set_line_length_guideline_column(EditorSettings::get_singleton()->get("text_editor/appearance/line_length_guideline_column"));
+ text_editor->set_show_line_length_guidelines(EditorSettings::get_singleton()->get("text_editor/appearance/show_line_length_guidelines"));
+ text_editor->set_line_length_guideline_soft_column(EditorSettings::get_singleton()->get("text_editor/appearance/line_length_guideline_soft_column"));
+ text_editor->set_line_length_guideline_hard_column(EditorSettings::get_singleton()->get("text_editor/appearance/line_length_guideline_hard_column"));
text_editor->set_scroll_pass_end_of_file(EditorSettings::get_singleton()->get("text_editor/cursor/scroll_past_end_of_file"));
text_editor->cursor_set_block_mode(EditorSettings::get_singleton()->get("text_editor/cursor/block_caret"));
text_editor->cursor_set_blink_enabled(EditorSettings::get_singleton()->get("text_editor/cursor/caret_blink"));
diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp
index 2adc6f5398..f78867e493 100644
--- a/editor/connections_dialog.cpp
+++ b/editor/connections_dialog.cpp
@@ -502,7 +502,6 @@ Control *ConnectionsDockTree::make_custom_tooltip(const String &p_text) const {
String text = TTR("Signal:") + " [u][b]" + p_text.get_slice("::", 0) + "[/b][/u]";
text += p_text.get_slice("::", 1).strip_edges() + "\n";
text += p_text.get_slice("::", 2).strip_edges();
- help_bit->set_text(text);
help_bit->call_deferred("set_text", text); //hack so it uses proper theme once inside scene
return help_bit;
}
diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp
index d10cc7f91e..adf6a42f53 100644
--- a/editor/editor_inspector.cpp
+++ b/editor/editor_inspector.cpp
@@ -778,10 +778,20 @@ Control *EditorProperty::make_custom_tooltip(const String &p_text) const {
help_bit->add_style_override("panel", get_stylebox("panel", "TooltipPanel"));
help_bit->get_rich_text()->set_fixed_size_to_width(360 * EDSCALE);
- String text = TTR("Property:") + " [u][b]" + p_text.get_slice("::", 0) + "[/b][/u]\n";
- text += p_text.get_slice("::", 1).strip_edges();
- help_bit->set_text(text);
- help_bit->call_deferred("set_text", text); //hack so it uses proper theme once inside scene
+ PackedStringArray slices = p_text.split("::", false);
+ if (!slices.empty()) {
+ String property_name = slices[0].strip_edges();
+ String text = TTR("Property:") + " [u][b]" + property_name + "[/b][/u]";
+
+ if (slices.size() > 1) {
+ String property_doc = slices[1].strip_edges();
+ if (property_name != property_doc) {
+ text += "\n" + property_doc;
+ }
+ }
+ help_bit->call_deferred("set_text", text); //hack so it uses proper theme once inside scene
+ }
+
return help_bit;
}
@@ -1005,10 +1015,20 @@ Control *EditorInspectorCategory::make_custom_tooltip(const String &p_text) cons
help_bit->add_style_override("panel", get_stylebox("panel", "TooltipPanel"));
help_bit->get_rich_text()->set_fixed_size_to_width(360 * EDSCALE);
- String text = "[u][b]" + p_text.get_slice("::", 0) + "[/b][/u]\n";
- text += p_text.get_slice("::", 1).strip_edges();
- help_bit->set_text(text);
- help_bit->call_deferred("set_text", text); //hack so it uses proper theme once inside scene
+ PackedStringArray slices = p_text.split("::", false);
+ if (!slices.empty()) {
+ String property_name = slices[0].strip_edges();
+ String text = "[u][b]" + property_name + "[/b][/u]";
+
+ if (slices.size() > 1) {
+ String property_doc = slices[1].strip_edges();
+ if (property_name != property_doc) {
+ text += "\n" + property_doc;
+ }
+ }
+ help_bit->call_deferred("set_text", text); //hack so it uses proper theme once inside scene
+ }
+
return help_bit;
}
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 9624b3ee56..e889298aa3 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -6146,7 +6146,7 @@ EditorNode::EditorNode() {
ED_SHORTCUT("editor/next_tab", TTR("Next tab"), KEY_MASK_CMD + KEY_TAB);
ED_SHORTCUT("editor/prev_tab", TTR("Previous tab"), KEY_MASK_CMD + KEY_MASK_SHIFT + KEY_TAB);
- ED_SHORTCUT("editor/filter_files", TTR("Filter Files..."), KEY_MASK_ALT + KEY_MASK_CMD + KEY_P);
+ ED_SHORTCUT("editor/filter_files", TTR("Filter Files..."), KEY_MASK_CMD + KEY_MASK_ALT + KEY_P);
PopupMenu *p;
file_menu->set_tooltip(TTR("Operations with scene files."));
@@ -6161,13 +6161,14 @@ EditorNode::EditorNode() {
p->add_separator();
p->add_shortcut(ED_SHORTCUT("editor/save_scene", TTR("Save Scene"), KEY_MASK_CMD + KEY_S), FILE_SAVE_SCENE);
- p->add_shortcut(ED_SHORTCUT("editor/save_scene_as", TTR("Save Scene As..."), KEY_MASK_SHIFT + KEY_MASK_CMD + KEY_S), FILE_SAVE_AS_SCENE);
- p->add_shortcut(ED_SHORTCUT("editor/save_all_scenes", TTR("Save All Scenes"), KEY_MASK_ALT + KEY_MASK_SHIFT + KEY_MASK_CMD + KEY_S), FILE_SAVE_ALL_SCENES);
+ p->add_shortcut(ED_SHORTCUT("editor/save_scene_as", TTR("Save Scene As..."), KEY_MASK_CMD + KEY_MASK_SHIFT + KEY_S), FILE_SAVE_AS_SCENE);
+ p->add_shortcut(ED_SHORTCUT("editor/save_all_scenes", TTR("Save All Scenes"), KEY_MASK_CMD + KEY_MASK_SHIFT + KEY_MASK_ALT + KEY_S), FILE_SAVE_ALL_SCENES);
p->add_separator();
+
p->add_shortcut(ED_SHORTCUT("editor/quick_open", TTR("Quick Open..."), KEY_MASK_SHIFT + KEY_MASK_ALT + KEY_O), FILE_QUICK_OPEN);
- p->add_shortcut(ED_SHORTCUT("editor/quick_open_scene", TTR("Quick Open Scene..."), KEY_MASK_SHIFT + KEY_MASK_CMD + KEY_O), FILE_QUICK_OPEN_SCENE);
- p->add_shortcut(ED_SHORTCUT("editor/quick_open_script", TTR("Quick Open Script..."), KEY_MASK_ALT + KEY_MASK_CMD + KEY_O), FILE_QUICK_OPEN_SCRIPT);
+ p->add_shortcut(ED_SHORTCUT("editor/quick_open_scene", TTR("Quick Open Scene..."), KEY_MASK_CMD + KEY_MASK_SHIFT + KEY_O), FILE_QUICK_OPEN_SCENE);
+ p->add_shortcut(ED_SHORTCUT("editor/quick_open_script", TTR("Quick Open Script..."), KEY_MASK_CMD + KEY_MASK_ALT + KEY_O), FILE_QUICK_OPEN_SCRIPT);
p->add_separator();
PopupMenu *pm_export = memnew(PopupMenu);
@@ -6180,11 +6181,11 @@ EditorNode::EditorNode() {
p->add_separator();
p->add_shortcut(ED_SHORTCUT("editor/undo", TTR("Undo"), KEY_MASK_CMD + KEY_Z), EDIT_UNDO, true);
- p->add_shortcut(ED_SHORTCUT("editor/redo", TTR("Redo"), KEY_MASK_SHIFT + KEY_MASK_CMD + KEY_Z), EDIT_REDO, true);
+ p->add_shortcut(ED_SHORTCUT("editor/redo", TTR("Redo"), KEY_MASK_CMD + KEY_MASK_SHIFT + KEY_Z), EDIT_REDO, true);
p->add_separator();
p->add_shortcut(ED_SHORTCUT("editor/revert_scene", TTR("Revert Scene")), EDIT_REVERT);
- p->add_shortcut(ED_SHORTCUT("editor/close_scene", TTR("Close Scene"), KEY_MASK_SHIFT + KEY_MASK_CMD + KEY_W), FILE_CLOSE);
+ p->add_shortcut(ED_SHORTCUT("editor/close_scene", TTR("Close Scene"), KEY_MASK_CMD + KEY_MASK_SHIFT + KEY_W), FILE_CLOSE);
recent_scenes = memnew(PopupMenu);
recent_scenes->set_name("RecentScenes");
@@ -6236,7 +6237,7 @@ EditorNode::EditorNode() {
#ifdef OSX_ENABLED
p->add_shortcut(ED_SHORTCUT("editor/quit_to_project_list", TTR("Quit to Project List"), KEY_MASK_SHIFT + KEY_MASK_ALT + KEY_Q), RUN_PROJECT_MANAGER, true);
#else
- p->add_shortcut(ED_SHORTCUT("editor/quit_to_project_list", TTR("Quit to Project List"), KEY_MASK_SHIFT + KEY_MASK_CMD + KEY_Q), RUN_PROJECT_MANAGER, true);
+ p->add_shortcut(ED_SHORTCUT("editor/quit_to_project_list", TTR("Quit to Project List"), KEY_MASK_CMD + KEY_MASK_SHIFT + KEY_Q), RUN_PROJECT_MANAGER, true);
#endif
menu_hb->add_spacer();
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index bd2505f146..3f3d79c83a 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -456,9 +456,11 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
_initial_set("text_editor/appearance/show_info_gutter", true);
_initial_set("text_editor/appearance/code_folding", true);
_initial_set("text_editor/appearance/word_wrap", false);
- _initial_set("text_editor/appearance/show_line_length_guideline", true);
- _initial_set("text_editor/appearance/line_length_guideline_column", 80);
- hints["text_editor/appearance/line_length_guideline_column"] = PropertyInfo(Variant::INT, "text_editor/appearance/line_length_guideline_column", PROPERTY_HINT_RANGE, "20, 160, 1");
+ _initial_set("text_editor/appearance/show_line_length_guidelines", true);
+ _initial_set("text_editor/appearance/line_length_guideline_soft_column", 80);
+ hints["text_editor/appearance/line_length_guideline_soft_column"] = PropertyInfo(Variant::INT, "text_editor/appearance/line_length_guideline_soft_column", PROPERTY_HINT_RANGE, "20, 160, 1");
+ _initial_set("text_editor/appearance/line_length_guideline_hard_column", 100);
+ hints["text_editor/appearance/line_length_guideline_hard_column"] = PropertyInfo(Variant::INT, "text_editor/appearance/line_length_guideline_hard_column", PROPERTY_HINT_RANGE, "20, 160, 1");
// Script list
_initial_set("text_editor/script_list/show_members_overview", true);
diff --git a/editor/find_in_files.cpp b/editor/find_in_files.cpp
index 5c012183e7..0bc9b0585c 100644
--- a/editor/find_in_files.cpp
+++ b/editor/find_in_files.cpp
@@ -594,6 +594,12 @@ FindInFilesPanel::FindInFilesPanel() {
_status_label = memnew(Label);
hbc->add_child(_status_label);
+ _refresh_button = memnew(Button);
+ _refresh_button->set_text(TTR("Refresh"));
+ _refresh_button->connect_compat("pressed", this, "_on_refresh_button_clicked");
+ _refresh_button->hide();
+ hbc->add_child(_refresh_button);
+
_cancel_button = memnew(Button);
_cancel_button->set_text(TTR("Cancel"));
_cancel_button->connect_compat("pressed", this, "_on_cancel_button_clicked");
@@ -681,6 +687,7 @@ void FindInFilesPanel::start_search() {
_finder->start();
update_replace_buttons();
+ _refresh_button->hide();
_cancel_button->show();
}
@@ -691,6 +698,7 @@ void FindInFilesPanel::stop_search() {
_status_label->set_text("");
update_replace_buttons();
set_progress_visible(false);
+ _refresh_button->show();
_cancel_button->hide();
}
@@ -793,9 +801,14 @@ void FindInFilesPanel::_on_finished() {
_status_label->set_text(TTR("Search complete"));
update_replace_buttons();
set_progress_visible(false);
+ _refresh_button->show();
_cancel_button->hide();
}
+void FindInFilesPanel::_on_refresh_button_clicked() {
+ start_search();
+}
+
void FindInFilesPanel::_on_cancel_button_clicked() {
stop_search();
}
@@ -970,6 +983,7 @@ void FindInFilesPanel::_bind_methods() {
ClassDB::bind_method("_on_result_found", &FindInFilesPanel::_on_result_found);
ClassDB::bind_method("_on_item_edited", &FindInFilesPanel::_on_item_edited);
ClassDB::bind_method("_on_finished", &FindInFilesPanel::_on_finished);
+ ClassDB::bind_method("_on_refresh_button_clicked", &FindInFilesPanel::_on_refresh_button_clicked);
ClassDB::bind_method("_on_cancel_button_clicked", &FindInFilesPanel::_on_cancel_button_clicked);
ClassDB::bind_method("_on_result_selected", &FindInFilesPanel::_on_result_selected);
ClassDB::bind_method("_on_replace_text_changed", &FindInFilesPanel::_on_replace_text_changed);
diff --git a/editor/find_in_files.h b/editor/find_in_files.h
index 5dc4ef5e19..7002f750b7 100644
--- a/editor/find_in_files.h
+++ b/editor/find_in_files.h
@@ -179,6 +179,7 @@ protected:
private:
void _on_result_found(String fpath, int line_number, int begin, int end, String text);
void _on_finished();
+ void _on_refresh_button_clicked();
void _on_cancel_button_clicked();
void _on_result_selected();
void _on_item_edited();
@@ -206,6 +207,7 @@ private:
Label *_search_text_label;
Tree *_results_display;
Label *_status_label;
+ Button *_refresh_button;
Button *_cancel_button;
ProgressBar *_progress_bar;
Map<String, TreeItem *> _file_items;
diff --git a/editor/import/resource_importer_texture_atlas.cpp b/editor/import/resource_importer_texture_atlas.cpp
index 4291d6f2d7..3172cc7279 100644
--- a/editor/import/resource_importer_texture_atlas.cpp
+++ b/editor/import/resource_importer_texture_atlas.cpp
@@ -143,8 +143,8 @@ static void _plot_triangle(Vector2 *vertices, const Vector2 &p_offset, bool p_tr
int px = xi, py = yi;
int sx = px, sy = py;
- sx = CLAMP(sx, 0, src_width);
- sy = CLAMP(sy, 0, src_height);
+ sx = CLAMP(sx, 0, src_width - 1);
+ sy = CLAMP(sy, 0, src_height - 1);
Color color = p_src_image->get_pixel(sx, sy);
if (p_transposed) {
SWAP(px, py);
@@ -165,8 +165,8 @@ static void _plot_triangle(Vector2 *vertices, const Vector2 &p_offset, bool p_tr
for (int xi = (xf < width ? int(xf) : width - 1); xi >= (xt > 0 ? xt : 0); xi--) {
int px = xi, py = yi;
int sx = px, sy = py;
- sx = CLAMP(sx, 0, src_width);
- sy = CLAMP(sy, 0, src_height);
+ sx = CLAMP(sx, 0, src_width - 1);
+ sy = CLAMP(sy, 0, src_height - 1);
Color color = p_src_image->get_pixel(sx, sy);
if (p_transposed) {
SWAP(px, py);
diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp
index 01c3c33995..c8cbc59e45 100644
--- a/editor/plugins/asset_library_editor_plugin.cpp
+++ b/editor/plugins/asset_library_editor_plugin.cpp
@@ -1210,7 +1210,16 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const
library_vb->add_child(asset_bottom_page);
if (result.empty()) {
- library_error->set_text(vformat(TTR("No results for \"%s\"."), filter->get_text()));
+ if (filter->get_text() != String()) {
+ library_error->set_text(
+ vformat(TTR("No results for \"%s\"."), filter->get_text()));
+ } else {
+ // No results, even though the user didn't search for anything specific.
+ // This is typically because the version number changed recently
+ // and no assets compatible with the new version have been published yet.
+ library_error->set_text(
+ vformat(TTR("No results compatible with %s %s."), String(VERSION_SHORT_NAME).capitalize(), String(VERSION_BRANCH)));
+ }
library_error->show();
}
diff --git a/editor/plugins/mesh_instance_editor_plugin.cpp b/editor/plugins/mesh_instance_editor_plugin.cpp
index 182a8600e4..37cf16de58 100644
--- a/editor/plugins/mesh_instance_editor_plugin.cpp
+++ b/editor/plugins/mesh_instance_editor_plugin.cpp
@@ -455,7 +455,7 @@ MeshInstanceEditor::MeshInstanceEditor() {
options->get_popup()->add_separator();
options->get_popup()->add_item(TTR("Create Trimesh Collision Sibling"), MENU_OPTION_CREATE_TRIMESH_COLLISION_SHAPE);
options->get_popup()->set_item_tooltip(options->get_popup()->get_item_count() - 1, TTR("Creates a polygon-based collision shape.\nThis is the most accurate (but slowest) option for collision detection."));
- options->get_popup()->add_item(TTR("Create Single Convex Collision Siblings"), MENU_OPTION_CREATE_SINGLE_CONVEX_COLLISION_SHAPE);
+ options->get_popup()->add_item(TTR("Create Single Convex Collision Sibling"), MENU_OPTION_CREATE_SINGLE_CONVEX_COLLISION_SHAPE);
options->get_popup()->set_item_tooltip(options->get_popup()->get_item_count() - 1, TTR("Creates a single convex collision shape.\nThis is the fastest (but least accurate) option for collision detection."));
options->get_popup()->add_item(TTR("Create Multiple Convex Collision Siblings"), MENU_OPTION_CREATE_MULTIPLE_CONVEX_COLLISION_SHAPES);
options->get_popup()->set_item_tooltip(options->get_popup()->get_item_count() - 1, TTR("Creates a polygon-based collision shape.\nThis is a performance middle-ground between the two above options."));
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index 9dc98dc2a0..127b98c15b 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -3149,7 +3149,7 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
scripts_vbox->add_child(script_list);
script_list->set_custom_minimum_size(Size2(150, 60) * EDSCALE); //need to give a bit of limit to avoid it from disappearing
script_list->set_v_size_flags(SIZE_EXPAND_FILL);
- script_split->set_split_offset(140);
+ script_split->set_split_offset(70 * EDSCALE);
_sort_list_on_update = true;
script_list->connect_compat("gui_input", this, "_script_list_gui_input", varray(), CONNECT_DEFERRED);
script_list->set_allow_rmb_select(true);
diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp
index 4e0787c805..f4ebd7c3cc 100644
--- a/editor/plugins/script_text_editor.cpp
+++ b/editor/plugins/script_text_editor.cpp
@@ -292,24 +292,29 @@ void ScriptTextEditor::_set_theme_for_script() {
const Color basetype_color = colors_cache.basetype_color;
text_edit->add_keyword_color("String", basetype_color);
text_edit->add_keyword_color("Vector2", basetype_color);
+ text_edit->add_keyword_color("Vector2i", basetype_color);
text_edit->add_keyword_color("Rect2", basetype_color);
- text_edit->add_keyword_color("Transform2D", basetype_color);
+ text_edit->add_keyword_color("Rect2i", basetype_color);
text_edit->add_keyword_color("Vector3", basetype_color);
+ text_edit->add_keyword_color("Vector3i", basetype_color);
+ text_edit->add_keyword_color("Transform2D", basetype_color);
+ text_edit->add_keyword_color("Plane", basetype_color);
+ text_edit->add_keyword_color("Quat", basetype_color);
text_edit->add_keyword_color("AABB", basetype_color);
text_edit->add_keyword_color("Basis", basetype_color);
- text_edit->add_keyword_color("Plane", basetype_color);
text_edit->add_keyword_color("Transform", basetype_color);
- text_edit->add_keyword_color("Quat", basetype_color);
text_edit->add_keyword_color("Color", basetype_color);
- text_edit->add_keyword_color("Object", basetype_color);
+ text_edit->add_keyword_color("StringName", basetype_color);
text_edit->add_keyword_color("NodePath", basetype_color);
text_edit->add_keyword_color("RID", basetype_color);
+ text_edit->add_keyword_color("Object", basetype_color);
+ text_edit->add_keyword_color("Callable", basetype_color);
text_edit->add_keyword_color("Dictionary", basetype_color);
text_edit->add_keyword_color("Array", basetype_color);
text_edit->add_keyword_color("PackedByteArray", basetype_color);
text_edit->add_keyword_color("PackedInt32Array", basetype_color);
- text_edit->add_keyword_color("PackedFloat32Array", basetype_color);
text_edit->add_keyword_color("PackedInt64Array", basetype_color);
+ text_edit->add_keyword_color("PackedFloat32Array", basetype_color);
text_edit->add_keyword_color("PackedFloat64Array", basetype_color);
text_edit->add_keyword_color("PackedStringArray", basetype_color);
text_edit->add_keyword_color("PackedVector2Array", basetype_color);
diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp
index 6c20483cf6..b45aacd1ee 100644
--- a/editor/plugins/shader_editor_plugin.cpp
+++ b/editor/plugins/shader_editor_plugin.cpp
@@ -382,8 +382,9 @@ void ShaderEditor::_editor_settings_changed() {
shader_editor->get_text_edit()->set_v_scroll_speed(EditorSettings::get_singleton()->get("text_editor/navigation/v_scroll_speed"));
shader_editor->get_text_edit()->set_draw_minimap(EditorSettings::get_singleton()->get("text_editor/navigation/show_minimap"));
shader_editor->get_text_edit()->set_minimap_width((int)EditorSettings::get_singleton()->get("text_editor/navigation/minimap_width") * EDSCALE);
- shader_editor->get_text_edit()->set_show_line_length_guideline(EditorSettings::get_singleton()->get("text_editor/appearance/show_line_length_guideline"));
- shader_editor->get_text_edit()->set_line_length_guideline_column(EditorSettings::get_singleton()->get("text_editor/appearance/line_length_guideline_column"));
+ shader_editor->get_text_edit()->set_show_line_length_guidelines(EditorSettings::get_singleton()->get("text_editor/appearance/show_line_length_guidelines"));
+ shader_editor->get_text_edit()->set_line_length_guideline_soft_column(EditorSettings::get_singleton()->get("text_editor/appearance/line_length_guideline_soft_column"));
+ shader_editor->get_text_edit()->set_line_length_guideline_hard_column(EditorSettings::get_singleton()->get("text_editor/appearance/line_length_guideline_hard_column"));
shader_editor->get_text_edit()->set_breakpoint_gutter_enabled(false);
}
diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp
index 653ab153a1..2fb23f6a84 100644
--- a/editor/plugins/visual_shader_editor_plugin.cpp
+++ b/editor/plugins/visual_shader_editor_plugin.cpp
@@ -438,14 +438,22 @@ void VisualShaderEditor::_update_created_node(GraphNode *node) {
if (EditorSettings::get_singleton()->get("interface/theme/use_graph_node_headers")) {
Ref<StyleBoxFlat> sb = node->get_stylebox("frame", "GraphNode");
Color c = sb->get_border_color();
- Color mono_color = ((c.r + c.g + c.b) / 3) < 0.7 ? Color(1.0, 1.0, 1.0) : Color(0.0, 0.0, 0.0);
+ Color ic;
+ Color mono_color;
+ if (((c.r + c.g + c.b) / 3) < 0.7) {
+ mono_color = Color(1.0, 1.0, 1.0);
+ ic = Color(0.0, 0.0, 0.0, 0.7);
+ } else {
+ mono_color = Color(0.0, 0.0, 0.0);
+ ic = Color(1.0, 1.0, 1.0, 0.7);
+ }
mono_color.a = 0.85;
c = mono_color;
node->add_color_override("title_color", c);
c.a = 0.7;
node->add_color_override("close_color", c);
- node->add_color_override("resizer_color", c);
+ node->add_color_override("resizer_color", ic);
}
}
@@ -1601,8 +1609,29 @@ void VisualShaderEditor::_graph_gui_input(const Ref<InputEvent> &p_event) {
Ref<InputEventMouseButton> mb = p_event;
- if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == BUTTON_RIGHT)
- _show_members_dialog(true);
+ if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == BUTTON_RIGHT) {
+ List<int> to_change;
+ for (int i = 0; i < graph->get_child_count(); i++) {
+ GraphNode *gn = Object::cast_to<GraphNode>(graph->get_child(i));
+ if (gn) {
+ if (gn->is_selected() && gn->is_close_button_visible()) {
+ to_change.push_back(gn->get_name().operator String().to_int());
+ }
+ }
+ }
+ if (to_change.empty() && copy_nodes_buffer.empty()) {
+ _show_members_dialog(true);
+ } else {
+ popup_menu->set_item_disabled(NodeMenuOptions::COPY, to_change.empty());
+ popup_menu->set_item_disabled(NodeMenuOptions::PASTE, copy_nodes_buffer.empty());
+ popup_menu->set_item_disabled(NodeMenuOptions::DELETE, to_change.empty());
+ popup_menu->set_item_disabled(NodeMenuOptions::DUPLICATE, to_change.empty());
+ menu_point = graph->get_local_mouse_position();
+ Point2 gpos = Input::get_singleton()->get_mouse_position();
+ popup_menu->set_position(gpos);
+ popup_menu->popup();
+ }
+ }
}
void VisualShaderEditor::_show_members_dialog(bool at_mouse_pos) {
@@ -1900,7 +1929,7 @@ void VisualShaderEditor::_copy_nodes() {
_dup_copy_nodes(copy_type, copy_nodes_buffer, copy_nodes_excluded_buffer);
}
-void VisualShaderEditor::_paste_nodes() {
+void VisualShaderEditor::_paste_nodes(bool p_use_custom_position, const Vector2 &p_custom_position) {
if (copy_nodes_buffer.empty())
return;
@@ -1911,12 +1940,19 @@ void VisualShaderEditor::_paste_nodes() {
float scale = graph->get_zoom();
- _dup_paste_nodes(type, copy_type, copy_nodes_buffer, copy_nodes_excluded_buffer, (graph->get_scroll_ofs() / scale + graph->get_local_mouse_position() / scale - selection_center), false);
+ Vector2 mpos;
+ if (p_use_custom_position) {
+ mpos = p_custom_position;
+ } else {
+ mpos = graph->get_local_mouse_position();
+ }
+
+ _dup_paste_nodes(type, copy_type, copy_nodes_buffer, copy_nodes_excluded_buffer, (graph->get_scroll_ofs() / scale + mpos / scale - selection_center), false);
_dup_update_excluded(type, copy_nodes_excluded_buffer); // to prevent selection of previous copies at new paste
}
-void VisualShaderEditor::_on_nodes_delete() {
+void VisualShaderEditor::_delete_nodes() {
VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
List<int> to_erase;
@@ -2102,6 +2138,26 @@ void VisualShaderEditor::_tools_menu_option(int p_idx) {
}
}
+void VisualShaderEditor::_node_menu_id_pressed(int p_idx) {
+ switch (p_idx) {
+ case NodeMenuOptions::ADD:
+ _show_members_dialog(true);
+ break;
+ case NodeMenuOptions::COPY:
+ _copy_nodes();
+ break;
+ case NodeMenuOptions::PASTE:
+ _paste_nodes(true, menu_point);
+ break;
+ case NodeMenuOptions::DELETE:
+ _delete_nodes();
+ break;
+ case NodeMenuOptions::DUPLICATE:
+ _duplicate_nodes();
+ break;
+ }
+}
+
Variant VisualShaderEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from) {
if (p_from == members) {
@@ -2240,7 +2296,7 @@ void VisualShaderEditor::_bind_methods() {
ClassDB::bind_method("_node_selected", &VisualShaderEditor::_node_selected);
ClassDB::bind_method("_scroll_changed", &VisualShaderEditor::_scroll_changed);
ClassDB::bind_method("_delete_request", &VisualShaderEditor::_delete_request);
- ClassDB::bind_method("_on_nodes_delete", &VisualShaderEditor::_on_nodes_delete);
+ ClassDB::bind_method("_delete_nodes", &VisualShaderEditor::_delete_nodes);
ClassDB::bind_method("_node_changed", &VisualShaderEditor::_node_changed);
ClassDB::bind_method("_edit_port_default_input", &VisualShaderEditor::_edit_port_default_input);
ClassDB::bind_method("_port_edited", &VisualShaderEditor::_port_edited);
@@ -2283,6 +2339,8 @@ void VisualShaderEditor::_bind_methods() {
ClassDB::bind_method("_member_unselected", &VisualShaderEditor::_member_unselected);
ClassDB::bind_method("_member_create", &VisualShaderEditor::_member_create);
ClassDB::bind_method("_member_cancel", &VisualShaderEditor::_member_cancel);
+
+ ClassDB::bind_method("_node_menu_id_pressed", &VisualShaderEditor::_node_menu_id_pressed);
}
VisualShaderEditor *VisualShaderEditor::singleton = NULL;
@@ -2330,7 +2388,7 @@ VisualShaderEditor::VisualShaderEditor() {
graph->connect_compat("duplicate_nodes_request", this, "_duplicate_nodes");
graph->connect_compat("copy_nodes_request", this, "_copy_nodes");
graph->connect_compat("paste_nodes_request", this, "_paste_nodes");
- graph->connect_compat("delete_nodes_request", this, "_on_nodes_delete");
+ graph->connect_compat("delete_nodes_request", this, "_delete_nodes");
graph->connect_compat("gui_input", this, "_graph_gui_input");
graph->connect_compat("connection_to_empty", this, "_connection_to_empty");
graph->connect_compat("connection_from_empty", this, "_connection_from_empty");
@@ -2399,6 +2457,20 @@ VisualShaderEditor::VisualShaderEditor() {
error_text->set_visible(false);
///////////////////////////////////////
+ // POPUP MENU
+ ///////////////////////////////////////
+
+ popup_menu = memnew(PopupMenu);
+ add_child(popup_menu);
+ popup_menu->add_item("Add Node", NodeMenuOptions::ADD);
+ popup_menu->add_separator();
+ popup_menu->add_item("Copy", NodeMenuOptions::COPY);
+ popup_menu->add_item("Paste", NodeMenuOptions::PASTE);
+ popup_menu->add_item("Delete", NodeMenuOptions::DELETE);
+ popup_menu->add_item("Duplicate", NodeMenuOptions::DUPLICATE);
+ popup_menu->connect_compat("id_pressed", this, "_node_menu_id_pressed");
+
+ ///////////////////////////////////////
// SHADER NODES TREE
///////////////////////////////////////
@@ -2636,7 +2708,7 @@ VisualShaderEditor::VisualShaderEditor() {
add_options.push_back(AddOption("CustomAlpha", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "custom_alpha"), "custom_alpha", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_VERTEX, Shader::MODE_PARTICLES));
add_options.push_back(AddOption("Delta", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "delta"), "delta", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_VERTEX, Shader::MODE_PARTICLES));
add_options.push_back(AddOption("EmissionTransform", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "emission_transform"), "emission_transform", VisualShaderNode::PORT_TYPE_TRANSFORM, VisualShader::TYPE_VERTEX, Shader::MODE_PARTICLES));
- add_options.push_back(AddOption("Index", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "index"), "index", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_VERTEX, Shader::MODE_PARTICLES));
+ add_options.push_back(AddOption("Index", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "index"), "index", VisualShaderNode::PORT_TYPE_SCALAR_INT, VisualShader::TYPE_VERTEX, Shader::MODE_PARTICLES));
add_options.push_back(AddOption("LifeTime", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "lifetime"), "lifetime", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_VERTEX, Shader::MODE_PARTICLES));
add_options.push_back(AddOption("Restart", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "restart"), "restart", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_VERTEX, Shader::MODE_PARTICLES));
add_options.push_back(AddOption("Time", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "time"), "time", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_VERTEX, Shader::MODE_PARTICLES));
diff --git a/editor/plugins/visual_shader_editor_plugin.h b/editor/plugins/visual_shader_editor_plugin.h
index 8919690ada..8756fe9fe9 100644
--- a/editor/plugins/visual_shader_editor_plugin.h
+++ b/editor/plugins/visual_shader_editor_plugin.h
@@ -81,6 +81,7 @@ class VisualShaderEditor : public VBoxContainer {
bool saved_node_pos_dirty;
ConfirmationDialog *members_dialog;
+ PopupMenu *popup_menu;
MenuButton *tools;
bool preview_showed;
@@ -90,6 +91,15 @@ class VisualShaderEditor : public VBoxContainer {
COLLAPSE_ALL
};
+ enum NodeMenuOptions {
+ ADD,
+ SEPARATOR, // ignore
+ COPY,
+ PASTE,
+ DELETE,
+ DUPLICATE,
+ };
+
Tree *members;
AcceptDialog *alert;
LineEdit *node_filter;
@@ -181,7 +191,7 @@ class VisualShaderEditor : public VBoxContainer {
void _node_selected(Object *p_node);
void _delete_request(int);
- void _on_nodes_delete();
+ void _delete_nodes();
void _removed_from_graph();
@@ -216,7 +226,7 @@ class VisualShaderEditor : public VBoxContainer {
void _clear_buffer();
void _copy_nodes();
- void _paste_nodes();
+ void _paste_nodes(bool p_use_custom_position = false, const Vector2 &p_custom_position = Vector2());
Vector<Ref<VisualShaderNodePlugin> > plugins;
@@ -250,6 +260,9 @@ class VisualShaderEditor : public VBoxContainer {
void _member_create();
void _member_cancel();
+ Vector2 menu_point;
+ void _node_menu_id_pressed(int p_idx);
+
Variant get_drag_data_fw(const Point2 &p_point, Control *p_from);
bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;
void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);