summaryrefslogtreecommitdiff
path: root/editor/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'editor/plugins')
-rw-r--r--editor/plugins/abstract_polygon_2d_editor.cpp2
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp40
-rw-r--r--editor/plugins/canvas_item_editor_plugin.h10
-rw-r--r--editor/plugins/debugger_editor_plugin.cpp32
-rw-r--r--editor/plugins/editor_debugger_plugin.cpp124
-rw-r--r--editor/plugins/editor_debugger_plugin.h64
-rw-r--r--editor/plugins/editor_preview_plugins.cpp4
-rw-r--r--editor/plugins/mesh_instance_3d_editor_plugin.cpp1
-rw-r--r--editor/plugins/node_3d_editor_plugin.cpp171
-rw-r--r--editor/plugins/node_3d_editor_plugin.h6
-rw-r--r--editor/plugins/packed_scene_translation_parser_plugin.cpp8
-rw-r--r--editor/plugins/packed_scene_translation_parser_plugin.h2
-rw-r--r--editor/plugins/script_editor_plugin.cpp7
-rw-r--r--editor/plugins/script_editor_plugin.h2
-rw-r--r--editor/plugins/script_text_editor.cpp243
-rw-r--r--editor/plugins/script_text_editor.h13
-rw-r--r--editor/plugins/shader_editor_plugin.cpp139
-rw-r--r--editor/plugins/sprite_frames_editor_plugin.cpp7
-rw-r--r--editor/plugins/text_editor.cpp45
-rw-r--r--editor/plugins/text_editor.h2
-rw-r--r--editor/plugins/texture_3d_editor_plugin.cpp213
-rw-r--r--editor/plugins/texture_3d_editor_plugin.h93
-rw-r--r--editor/plugins/texture_region_editor_plugin.cpp2
-rw-r--r--editor/plugins/theme_editor_plugin.cpp6
-rw-r--r--editor/plugins/tile_map_editor_plugin.cpp5
-rw-r--r--editor/plugins/tile_set_editor_plugin.cpp16
-rw-r--r--editor/plugins/visual_shader_editor_plugin.cpp1797
-rw-r--r--editor/plugins/visual_shader_editor_plugin.h108
28 files changed, 2169 insertions, 993 deletions
diff --git a/editor/plugins/abstract_polygon_2d_editor.cpp b/editor/plugins/abstract_polygon_2d_editor.cpp
index 49e67f3605..7a3fb1ff52 100644
--- a/editor/plugins/abstract_polygon_2d_editor.cpp
+++ b/editor/plugins/abstract_polygon_2d_editor.cpp
@@ -287,7 +287,7 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event)
pre_move_edit = vertices2;
edited_point = PosVertex(insert.polygon, insert.vertex + 1, xform.affine_inverse().xform(insert.pos));
vertices2.insert(edited_point.vertex, edited_point.pos);
- selected_point = edited_point;
+ selected_point = Vertex(edited_point.polygon, edited_point.vertex);
edge_point = PosVertex();
undo_redo->create_action(TTR("Insert Point"));
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index f3508cedbd..ef4ba9819f 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -863,10 +863,11 @@ 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;
+ Vector2 output = Vector2();
+ output.x = (parent_rect.size.x == 0) ? 0.0 : (p_control->get_transform().xform(position).x - parent_rect.position.x) / parent_rect.size.x;
+ output.y = (parent_rect.size.y == 0) ? 0.0 : (p_control->get_transform().xform(position).y - parent_rect.position.y) / parent_rect.size.y;
+ return output;
}
void CanvasItemEditor::_save_canvas_item_ik_chain(const CanvasItem *p_canvas_item, List<float> *p_bones_length, List<Dictionary> *p_bones_state) {
@@ -2599,6 +2600,11 @@ void CanvasItemEditor::_gui_input_viewport(const Ref<InputEvent> &p_event) {
void CanvasItemEditor::_update_cursor() {
CursorShape c = CURSOR_ARROW;
+ bool should_switch = false;
+ if (drag_selection.size() != 0) {
+ float angle = drag_selection[0]->_edit_get_rotation();
+ should_switch = abs(Math::cos(angle)) < Math_SQRT12;
+ }
switch (drag_type) {
case DRAG_NONE:
switch (tool) {
@@ -2621,21 +2627,37 @@ void CanvasItemEditor::_update_cursor() {
case DRAG_LEFT:
case DRAG_RIGHT:
case DRAG_V_GUIDE:
- c = CURSOR_HSIZE;
+ if (should_switch) {
+ c = CURSOR_VSIZE;
+ } else {
+ c = CURSOR_HSIZE;
+ }
break;
case DRAG_TOP:
case DRAG_BOTTOM:
case DRAG_H_GUIDE:
- c = CURSOR_VSIZE;
+ if (should_switch) {
+ c = CURSOR_HSIZE;
+ } else {
+ c = CURSOR_VSIZE;
+ }
break;
case DRAG_TOP_LEFT:
case DRAG_BOTTOM_RIGHT:
case DRAG_DOUBLE_GUIDE:
- c = CURSOR_FDIAGSIZE;
+ if (should_switch) {
+ c = CURSOR_BDIAGSIZE;
+ } else {
+ c = CURSOR_FDIAGSIZE;
+ }
break;
case DRAG_TOP_RIGHT:
case DRAG_BOTTOM_LEFT:
- c = CURSOR_BDIAGSIZE;
+ if (should_switch) {
+ c = CURSOR_FDIAGSIZE;
+ } else {
+ c = CURSOR_BDIAGSIZE;
+ }
break;
case DRAG_MOVE:
c = CURSOR_MOVE;
@@ -3803,12 +3825,12 @@ void CanvasItemEditor::_draw_viewport() {
_draw_grid();
_draw_ruler_tool();
- _draw_selection();
_draw_axis();
if (editor->get_edited_scene()) {
_draw_locks_and_groups(editor->get_edited_scene());
_draw_invisible_nodes_positions(editor->get_edited_scene());
}
+ _draw_selection();
RID ci = viewport->get_canvas_item();
RenderingServer::get_singleton()->canvas_item_add_set_transform(ci, Transform2D());
@@ -6235,7 +6257,7 @@ void CanvasItemEditorViewport::_perform_drop_data() {
files_str += error_files[i].get_file().get_basename() + ",";
}
files_str = files_str.substr(0, files_str.length() - 1);
- accept->set_text(vformat(TTR("Error instancing scene from %s"), files_str.c_str()));
+ accept->set_text(vformat(TTR("Error instancing scene from %s"), files_str.get_data()));
accept->popup_centered();
}
}
diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h
index ea58fb1e36..859e80befe 100644
--- a/editor/plugins/canvas_item_editor_plugin.h
+++ b/editor/plugins/canvas_item_editor_plugin.h
@@ -400,11 +400,11 @@ private:
Ref<Texture2D> select_handle;
Ref<Texture2D> anchor_handle;
- Ref<ShortCut> drag_pivot_shortcut;
- Ref<ShortCut> set_pivot_shortcut;
- Ref<ShortCut> multiply_grid_step_shortcut;
- Ref<ShortCut> divide_grid_step_shortcut;
- Ref<ShortCut> pan_view_shortcut;
+ Ref<Shortcut> drag_pivot_shortcut;
+ 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/debugger_editor_plugin.cpp b/editor/plugins/debugger_editor_plugin.cpp
index 0a4d173923..0747e42045 100644
--- a/editor/plugins/debugger_editor_plugin.cpp
+++ b/editor/plugins/debugger_editor_plugin.cpp
@@ -47,7 +47,7 @@ DebuggerEditorPlugin::DebuggerEditorPlugin(EditorNode *p_editor, MenuButton *p_d
ED_SHORTCUT("debugger/keep_debugger_open", TTR("Keep Debugger Open"));
ED_SHORTCUT("debugger/debug_with_external_editor", TTR("Debug with External Editor"));
- // File Server for deploy with remote fs.
+ // File Server for deploy with remote filesystem.
file_server = memnew(EditorFileServer);
EditorDebuggerNode *debugger = memnew(EditorDebuggerNode);
@@ -59,19 +59,31 @@ DebuggerEditorPlugin::DebuggerEditorPlugin(EditorNode *p_editor, MenuButton *p_d
PopupMenu *p = debug_menu->get_popup();
p->set_hide_on_checkable_item_selection(false);
p->add_check_shortcut(ED_SHORTCUT("editor/deploy_with_remote_debug", TTR("Deploy with Remote Debug")), RUN_DEPLOY_REMOTE_DEBUG);
- p->set_item_tooltip(p->get_item_count() - 1, TTR("When exporting or deploying, the resulting executable will attempt to connect to the IP of this computer in order to be debugged."));
- p->add_check_shortcut(ED_SHORTCUT("editor/small_deploy_with_network_fs", TTR("Small Deploy with Network FS")), RUN_FILE_SERVER);
- p->set_item_tooltip(p->get_item_count() - 1, TTR("When this option is enabled, export or deploy will produce a minimal executable.\nThe filesystem will be provided from the project by the editor over the network.\nOn Android, deploy will use the USB cable for faster performance. This option speeds up testing for games with a large footprint."));
+ p->set_item_tooltip(
+ p->get_item_count() - 1,
+ TTR("When this option is enabled, using one-click deploy will make the executable attempt to connect to this computer's IP so the running project can be debugged.\nThis option is intended to be used for remote debugging (typically with a mobile device).\nYou don't need to enable it to use the GDScript debugger locally."));
+ p->add_check_shortcut(ED_SHORTCUT("editor/small_deploy_with_network_fs", TTR("Small Deploy with Network Filesystem")), RUN_FILE_SERVER);
+ p->set_item_tooltip(
+ p->get_item_count() - 1,
+ TTR("When this option is enabled, using one-click deploy for Android will only export an executable without the project data.\nThe filesystem will be provided from the project by the editor over the network.\nOn Android, deploying will use the USB cable for faster performance. This option speeds up testing for projects with large assets."));
p->add_separator();
p->add_check_shortcut(ED_SHORTCUT("editor/visible_collision_shapes", TTR("Visible Collision Shapes")), RUN_DEBUG_COLLISONS);
- p->set_item_tooltip(p->get_item_count() - 1, TTR("Collision shapes and raycast nodes (for 2D and 3D) will be visible on the running game if this option is turned on."));
+ p->set_item_tooltip(
+ p->get_item_count() - 1,
+ TTR("When this option is enabled, collision shapes and raycast nodes (for 2D and 3D) will be visible in the running project."));
p->add_check_shortcut(ED_SHORTCUT("editor/visible_navigation", TTR("Visible Navigation")), RUN_DEBUG_NAVIGATION);
- p->set_item_tooltip(p->get_item_count() - 1, TTR("Navigation meshes and polygons will be visible on the running game if this option is turned on."));
+ p->set_item_tooltip(
+ p->get_item_count() - 1,
+ TTR("When this option is enabled, navigation meshes and polygons will be visible in the running project."));
p->add_separator();
- p->add_check_shortcut(ED_SHORTCUT("editor/sync_scene_changes", TTR("Sync Scene Changes")), RUN_LIVE_DEBUG);
- p->set_item_tooltip(p->get_item_count() - 1, TTR("When this option is turned on, any changes made to the scene in the editor will be replicated in the running game.\nWhen used remotely on a device, this is more efficient with network filesystem."));
- p->add_check_shortcut(ED_SHORTCUT("editor/sync_script_changes", TTR("Sync Script Changes")), RUN_RELOAD_SCRIPTS);
- p->set_item_tooltip(p->get_item_count() - 1, TTR("When this option is turned on, any script that is saved will be reloaded on the running game.\nWhen used remotely on a device, this is more efficient with network filesystem."));
+ p->add_check_shortcut(ED_SHORTCUT("editor/sync_scene_changes", TTR("Synchronize Scene Changes")), RUN_LIVE_DEBUG);
+ p->set_item_tooltip(
+ p->get_item_count() - 1,
+ TTR("When this option is enabled, any changes made to the scene in the editor will be replicated in the running project.\nWhen used remotely on a device, this is more efficient when the network filesystem option is enabled."));
+ p->add_check_shortcut(ED_SHORTCUT("editor/sync_script_changes", TTR("Synchronize Script Changes")), RUN_RELOAD_SCRIPTS);
+ p->set_item_tooltip(
+ p->get_item_count() - 1,
+ TTR("When this option is enabled, any script that is saved will be reloaded in the running project.\nWhen used remotely on a device, this is more efficient when the network filesystem option is enabled."));
// Multi-instance, start/stop
instances_menu = memnew(PopupMenu);
diff --git a/editor/plugins/editor_debugger_plugin.cpp b/editor/plugins/editor_debugger_plugin.cpp
new file mode 100644
index 0000000000..b775e871e2
--- /dev/null
+++ b/editor/plugins/editor_debugger_plugin.cpp
@@ -0,0 +1,124 @@
+/*************************************************************************/
+/* editor_debugger_plugin.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#include "editor_debugger_plugin.h"
+
+#include "editor/debugger/script_editor_debugger.h"
+
+void EditorDebuggerPlugin::_breaked(bool p_really_did, bool p_can_debug) {
+ if (p_really_did) {
+ emit_signal("breaked", p_can_debug);
+ } else {
+ emit_signal("continued");
+ }
+}
+
+void EditorDebuggerPlugin::_started() {
+ emit_signal("started");
+}
+
+void EditorDebuggerPlugin::_stopped() {
+ emit_signal("stopped");
+}
+
+void EditorDebuggerPlugin::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("send_message", "message", "data"), &EditorDebuggerPlugin::send_message);
+ ClassDB::bind_method(D_METHOD("register_message_capture", "name", "callable"), &EditorDebuggerPlugin::register_message_capture);
+ ClassDB::bind_method(D_METHOD("unregister_message_capture", "name"), &EditorDebuggerPlugin::unregister_message_capture);
+ ClassDB::bind_method(D_METHOD("has_capture", "name"), &EditorDebuggerPlugin::has_capture);
+ ClassDB::bind_method(D_METHOD("is_breaked"), &EditorDebuggerPlugin::is_breaked);
+ ClassDB::bind_method(D_METHOD("is_debuggable"), &EditorDebuggerPlugin::is_debuggable);
+ ClassDB::bind_method(D_METHOD("is_session_active"), &EditorDebuggerPlugin::is_session_active);
+
+ ADD_SIGNAL(MethodInfo("started"));
+ ADD_SIGNAL(MethodInfo("stopped"));
+ ADD_SIGNAL(MethodInfo("breaked", PropertyInfo(Variant::BOOL, "can_debug")));
+ ADD_SIGNAL(MethodInfo("continued"));
+}
+
+void EditorDebuggerPlugin::attach_debugger(ScriptEditorDebugger *p_debugger) {
+ debugger = p_debugger;
+ if (debugger) {
+ debugger->connect("started", callable_mp(this, &EditorDebuggerPlugin::_started));
+ debugger->connect("stopped", callable_mp(this, &EditorDebuggerPlugin::_stopped));
+ debugger->connect("breaked", callable_mp(this, &EditorDebuggerPlugin::_breaked));
+ }
+}
+
+void EditorDebuggerPlugin::detach_debugger(bool p_call_debugger) {
+ if (debugger) {
+ debugger->disconnect("started", callable_mp(this, &EditorDebuggerPlugin::_started));
+ debugger->disconnect("stopped", callable_mp(this, &EditorDebuggerPlugin::_stopped));
+ debugger->disconnect("breaked", callable_mp(this, &EditorDebuggerPlugin::_breaked));
+ if (p_call_debugger && get_script_instance()) {
+ debugger->remove_debugger_plugin(get_script_instance()->get_script());
+ }
+ debugger = nullptr;
+ }
+}
+
+void EditorDebuggerPlugin::send_message(const String &p_message, const Array &p_args) {
+ ERR_FAIL_COND_MSG(!debugger, "Plugin is not attached to debugger");
+ debugger->send_message(p_message, p_args);
+}
+
+void EditorDebuggerPlugin::register_message_capture(const StringName &p_name, const Callable &p_callable) {
+ ERR_FAIL_COND_MSG(!debugger, "Plugin is not attached to debugger");
+ debugger->register_message_capture(p_name, p_callable);
+}
+
+void EditorDebuggerPlugin::unregister_message_capture(const StringName &p_name) {
+ ERR_FAIL_COND_MSG(!debugger, "Plugin is not attached to debugger");
+ debugger->unregister_message_capture(p_name);
+}
+
+bool EditorDebuggerPlugin::has_capture(const StringName &p_name) {
+ ERR_FAIL_COND_V_MSG(!debugger, false, "Plugin is not attached to debugger");
+ return debugger->has_capture(p_name);
+}
+
+bool EditorDebuggerPlugin::is_breaked() {
+ ERR_FAIL_COND_V_MSG(!debugger, false, "Plugin is not attached to debugger");
+ return debugger->is_breaked();
+}
+
+bool EditorDebuggerPlugin::is_debuggable() {
+ ERR_FAIL_COND_V_MSG(!debugger, false, "Plugin is not attached to debugger");
+ return debugger->is_debuggable();
+}
+
+bool EditorDebuggerPlugin::is_session_active() {
+ ERR_FAIL_COND_V_MSG(!debugger, false, "Plugin is not attached to debugger");
+ return debugger->is_session_active();
+}
+
+EditorDebuggerPlugin::~EditorDebuggerPlugin() {
+ detach_debugger(true);
+}
diff --git a/editor/plugins/editor_debugger_plugin.h b/editor/plugins/editor_debugger_plugin.h
new file mode 100644
index 0000000000..10fd1151de
--- /dev/null
+++ b/editor/plugins/editor_debugger_plugin.h
@@ -0,0 +1,64 @@
+/*************************************************************************/
+/* editor_debugger_plugin.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#ifndef EDITOR_DEBUGGER_PLUGIN_H
+#define EDITOR_DEBUGGER_PLUGIN_H
+
+#include "scene/gui/control.h"
+
+class ScriptEditorDebugger;
+
+class EditorDebuggerPlugin : public Control {
+ GDCLASS(EditorDebuggerPlugin, Control);
+
+private:
+ ScriptEditorDebugger *debugger = nullptr;
+
+ void _breaked(bool p_really_did, bool p_can_debug);
+ void _started();
+ void _stopped();
+
+protected:
+ static void _bind_methods();
+
+public:
+ void attach_debugger(ScriptEditorDebugger *p_debugger);
+ void detach_debugger(bool p_call_debugger);
+ void send_message(const String &p_message, const Array &p_args);
+ void register_message_capture(const StringName &p_name, const Callable &p_callable);
+ void unregister_message_capture(const StringName &p_name);
+ bool has_capture(const StringName &p_name);
+ bool is_breaked();
+ bool is_debuggable();
+ bool is_session_active();
+ ~EditorDebuggerPlugin();
+};
+
+#endif // EDITOR_DEBUGGER_PLUGIN_H
diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp
index 2889cb50a0..3cf4dc5ac8 100644
--- a/editor/plugins/editor_preview_plugins.cpp
+++ b/editor/plugins/editor_preview_plugins.cpp
@@ -466,7 +466,7 @@ EditorMaterialPreviewPlugin::~EditorMaterialPreviewPlugin() {
///////////////////////////////////////////////////////////////////////////
-static bool _is_text_char(CharType c) {
+static bool _is_text_char(char32_t c) {
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '_';
}
@@ -525,7 +525,7 @@ Ref<Texture2D> EditorScriptPreviewPlugin::generate(const RES &p_from, const Size
bool prev_is_text = false;
bool in_keyword = false;
for (int i = 0; i < code.length(); i++) {
- CharType c = code[i];
+ char32_t c = code[i];
if (c > 32) {
if (col < thumbnail_size) {
Color color = text_color;
diff --git a/editor/plugins/mesh_instance_3d_editor_plugin.cpp b/editor/plugins/mesh_instance_3d_editor_plugin.cpp
index 1b65987af0..5b241deab0 100644
--- a/editor/plugins/mesh_instance_3d_editor_plugin.cpp
+++ b/editor/plugins/mesh_instance_3d_editor_plugin.cpp
@@ -138,6 +138,7 @@ void MeshInstance3DEditor::_menu_option(int p_option) {
CollisionShape3D *cshape = memnew(CollisionShape3D);
cshape->set_shape(shape);
+ cshape->set_transform(node->get_transform());
Node *owner = node->get_owner();
diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp
index 21a75c2f5d..944bf9913c 100644
--- a/editor/plugins/node_3d_editor_plugin.cpp
+++ b/editor/plugins/node_3d_editor_plugin.cpp
@@ -900,12 +900,15 @@ bool Node3DEditorViewport::_gizmo_select(const Vector2 &p_screenpos, bool p_high
}
float dist = r.distance_to(gt.origin);
-
- if (dist > gs * (GIZMO_CIRCLE_SIZE - GIZMO_RING_HALF_WIDTH) && dist < gs * (GIZMO_CIRCLE_SIZE + GIZMO_RING_HALF_WIDTH)) {
- float d = ray_pos.distance_to(r);
- if (d < col_d) {
- col_d = d;
- col_axis = i;
+ Vector3 r_dir = (r - gt.origin).normalized();
+
+ if (_get_camera_normal().dot(r_dir) <= 0.005) {
+ if (dist > gs * (GIZMO_CIRCLE_SIZE - GIZMO_RING_HALF_WIDTH) && dist < gs * (GIZMO_CIRCLE_SIZE + GIZMO_RING_HALF_WIDTH)) {
+ float d = ray_pos.distance_to(r);
+ if (d < col_d) {
+ col_d = d;
+ col_axis = i;
+ }
}
}
}
@@ -2246,7 +2249,7 @@ Point2i Node3DEditorViewport::_get_warped_mouse_motion(const Ref<InputEventMouse
}
static bool is_shortcut_pressed(const String &p_path) {
- Ref<ShortCut> shortcut = ED_GET_SHORTCUT(p_path);
+ Ref<Shortcut> shortcut = ED_GET_SHORTCUT(p_path);
if (shortcut.is_null()) {
return false;
}
@@ -3125,6 +3128,14 @@ void Node3DEditorViewport::_init_gizmo_instance(int p_idx) {
RS::get_singleton()->instance_geometry_set_cast_shadows_setting(scale_plane_gizmo_instance[i], RS::SHADOW_CASTING_SETTING_OFF);
RS::get_singleton()->instance_set_layer_mask(scale_plane_gizmo_instance[i], layer);
}
+
+ // Rotation white outline
+ rotate_gizmo_instance[3] = RS::get_singleton()->instance_create();
+ RS::get_singleton()->instance_set_base(rotate_gizmo_instance[3], spatial_editor->get_rotate_gizmo(3)->get_rid());
+ RS::get_singleton()->instance_set_scenario(rotate_gizmo_instance[3], get_tree()->get_root()->get_world_3d()->get_scenario());
+ RS::get_singleton()->instance_set_visible(rotate_gizmo_instance[3], false);
+ RS::get_singleton()->instance_geometry_set_cast_shadows_setting(rotate_gizmo_instance[3], RS::SHADOW_CASTING_SETTING_OFF);
+ RS::get_singleton()->instance_set_layer_mask(rotate_gizmo_instance[3], layer);
}
void Node3DEditorViewport::_finish_gizmo_instances() {
@@ -3135,6 +3146,8 @@ void Node3DEditorViewport::_finish_gizmo_instances() {
RS::get_singleton()->free(scale_gizmo_instance[i]);
RS::get_singleton()->free(scale_plane_gizmo_instance[i]);
}
+ // Rotation white outline
+ RS::get_singleton()->free(rotate_gizmo_instance[3]);
}
void Node3DEditorViewport::_toggle_camera_preview(bool p_activate) {
@@ -3226,6 +3239,8 @@ void Node3DEditorViewport::update_transform_gizmo_view() {
RenderingServer::get_singleton()->instance_set_visible(scale_gizmo_instance[i], false);
RenderingServer::get_singleton()->instance_set_visible(scale_plane_gizmo_instance[i], false);
}
+ // Rotation white outline
+ RenderingServer::get_singleton()->instance_set_visible(rotate_gizmo_instance[3], false);
return;
}
@@ -3264,6 +3279,9 @@ void Node3DEditorViewport::update_transform_gizmo_view() {
RenderingServer::get_singleton()->instance_set_transform(scale_plane_gizmo_instance[i], xform);
RenderingServer::get_singleton()->instance_set_visible(scale_plane_gizmo_instance[i], spatial_editor->is_gizmo_visible() && (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SCALE));
}
+ // Rotation white outline
+ RenderingServer::get_singleton()->instance_set_transform(rotate_gizmo_instance[3], xform);
+ RenderingServer::get_singleton()->instance_set_visible(rotate_gizmo_instance[3], spatial_editor->is_gizmo_visible() && (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SELECT || spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_ROTATE));
}
void Node3DEditorViewport::set_state(const Dictionary &p_state) {
@@ -3729,7 +3747,7 @@ void Node3DEditorViewport::_perform_drop_data() {
files_str += error_files[i].get_file().get_basename() + ",";
}
files_str = files_str.substr(0, files_str.length() - 1);
- accept->set_text(vformat(TTR("Error instancing scene from %s"), files_str.c_str()));
+ accept->set_text(vformat(TTR("Error instancing scene from %s"), files_str.get_data()));
accept->popup_centered();
}
}
@@ -4403,7 +4421,7 @@ void Node3DEditor::select_gizmo_highlight_axis(int p_axis) {
for (int i = 0; i < 3; i++) {
move_gizmo[i]->surface_set_material(0, i == p_axis ? gizmo_color_hl[i] : gizmo_color[i]);
move_plane_gizmo[i]->surface_set_material(0, (i + 6) == p_axis ? plane_gizmo_color_hl[i] : plane_gizmo_color[i]);
- rotate_gizmo[i]->surface_set_material(0, (i + 3) == p_axis ? gizmo_color_hl[i] : gizmo_color[i]);
+ rotate_gizmo[i]->surface_set_material(0, (i + 3) == p_axis ? rotate_gizmo_color_hl[i] : rotate_gizmo_color[i]);
scale_gizmo[i]->surface_set_material(0, (i + 9) == p_axis ? gizmo_color_hl[i] : gizmo_color[i]);
scale_plane_gizmo[i]->surface_set_material(0, (i + 12) == p_axis ? plane_gizmo_color_hl[i] : plane_gizmo_color[i]);
}
@@ -5287,37 +5305,122 @@ void Node3DEditor::_init_indicators() {
Ref<SurfaceTool> surftool = memnew(SurfaceTool);
surftool->begin(Mesh::PRIMITIVE_TRIANGLES);
- Vector3 circle[5] = {
- ivec * 0.02 + ivec2 * 0.02 + ivec2 * GIZMO_CIRCLE_SIZE,
- ivec * -0.02 + ivec2 * 0.02 + ivec2 * GIZMO_CIRCLE_SIZE,
- ivec * -0.02 + ivec2 * -0.02 + ivec2 * GIZMO_CIRCLE_SIZE,
- ivec * 0.02 + ivec2 * -0.02 + ivec2 * GIZMO_CIRCLE_SIZE,
- ivec * 0.02 + ivec2 * 0.02 + ivec2 * GIZMO_CIRCLE_SIZE,
- };
+ int n = 128; // number of circle segments
+ int m = 6; // number of thickness segments
- for (int k = 0; k < 64; k++) {
- Basis ma(ivec, Math_PI * 2 * float(k) / 64);
- Basis mb(ivec, Math_PI * 2 * float(k + 1) / 64);
+ for (int j = 0; j < n; ++j) {
+ Basis basis = Basis(ivec, (Math_PI * 2.0f * j) / n);
- for (int j = 0; j < 4; j++) {
- Vector3 points[4] = {
- ma.xform(circle[j]),
- mb.xform(circle[j]),
- mb.xform(circle[j + 1]),
- ma.xform(circle[j + 1]),
- };
- surftool->add_vertex(points[0]);
- surftool->add_vertex(points[1]);
- surftool->add_vertex(points[2]);
+ Vector3 vertex = basis.xform(ivec2 * GIZMO_CIRCLE_SIZE);
- surftool->add_vertex(points[0]);
- surftool->add_vertex(points[2]);
- surftool->add_vertex(points[3]);
+ for (int k = 0; k < m; ++k) {
+ Vector2 ofs = Vector2(Math::cos((Math_PI * 2.0 * k) / m), Math::sin((Math_PI * 2.0 * k) / m));
+ Vector3 normal = ivec * ofs.x + ivec2 * ofs.y;
+
+ surftool->add_normal(basis.xform(normal));
+ surftool->add_vertex(vertex);
}
}
- surftool->set_material(mat);
- surftool->commit(rotate_gizmo[i]);
+ for (int j = 0; j < n; ++j) {
+ for (int k = 0; k < m; ++k) {
+ int current_ring = j * m;
+ int next_ring = ((j + 1) % n) * m;
+ int current_segment = k;
+ int next_segment = (k + 1) % m;
+
+ surftool->add_index(current_ring + next_segment);
+ surftool->add_index(current_ring + current_segment);
+ surftool->add_index(next_ring + current_segment);
+
+ surftool->add_index(next_ring + current_segment);
+ surftool->add_index(next_ring + next_segment);
+ surftool->add_index(current_ring + next_segment);
+ }
+ }
+
+ Ref<Shader> rotate_shader = memnew(Shader);
+
+ rotate_shader->set_code("\n"
+ "shader_type spatial; \n"
+ "render_mode unshaded, depth_test_disabled; \n"
+ "uniform vec4 albedo; \n"
+ "\n"
+ "mat3 orthonormalize(mat3 m) { \n"
+ " vec3 x = normalize(m[0]); \n"
+ " vec3 y = normalize(m[1] - x * dot(x, m[1])); \n"
+ " vec3 z = m[2] - x * dot(x, m[2]); \n"
+ " z = normalize(z - y * (dot(y,m[2]))); \n"
+ " return mat3(x,y,z); \n"
+ "} \n"
+ "\n"
+ "void vertex() { \n"
+ " mat3 mv = orthonormalize(mat3(MODELVIEW_MATRIX)); \n"
+ " vec3 n = mv * VERTEX; \n"
+ " float orientation = dot(vec3(0,0,-1),n); \n"
+ " if (orientation <= 0.005) { \n"
+ " VERTEX += NORMAL*0.02; \n"
+ " } \n"
+ "} \n"
+ "\n"
+ "void fragment() { \n"
+ " ALBEDO = albedo.rgb; \n"
+ " ALPHA = albedo.a; \n"
+ "}");
+
+ Ref<ShaderMaterial> rotate_mat = memnew(ShaderMaterial);
+ rotate_mat->set_render_priority(Material::RENDER_PRIORITY_MAX);
+ rotate_mat->set_shader(rotate_shader);
+ rotate_mat->set_shader_param("albedo", col);
+ rotate_gizmo_color[i] = rotate_mat;
+
+ Array arrays = surftool->commit_to_arrays();
+ rotate_gizmo[i]->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, arrays);
+ rotate_gizmo[i]->surface_set_material(0, rotate_mat);
+
+ Ref<ShaderMaterial> rotate_mat_hl = rotate_mat->duplicate();
+ rotate_mat_hl->set_shader_param("albedo", Color(col.r, col.g, col.b, 1.0));
+ rotate_gizmo_color_hl[i] = rotate_mat_hl;
+
+ if (i == 2) { // Rotation white outline
+ Ref<ShaderMaterial> border_mat = rotate_mat->duplicate();
+
+ Ref<Shader> border_shader = memnew(Shader);
+ border_shader->set_code("\n"
+ "shader_type spatial; \n"
+ "render_mode unshaded, depth_test_disabled; \n"
+ "uniform vec4 albedo; \n"
+ "\n"
+ "mat3 orthonormalize(mat3 m) { \n"
+ " vec3 x = normalize(m[0]); \n"
+ " vec3 y = normalize(m[1] - x * dot(x, m[1])); \n"
+ " vec3 z = m[2] - x * dot(x, m[2]); \n"
+ " z = normalize(z - y * (dot(y,m[2]))); \n"
+ " return mat3(x,y,z); \n"
+ "} \n"
+ "\n"
+ "void vertex() { \n"
+ " mat3 mv = orthonormalize(mat3(MODELVIEW_MATRIX)); \n"
+ " mv = inverse(mv); \n"
+ " VERTEX += NORMAL*0.008; \n"
+ " vec3 camera_dir_local = mv * vec3(0,0,1); \n"
+ " vec3 camera_up_local = mv * vec3(0,1,0); \n"
+ " mat3 rotation_matrix = mat3(cross(camera_dir_local, camera_up_local), camera_up_local, camera_dir_local); \n"
+ " VERTEX = rotation_matrix * VERTEX; \n"
+ "} \n"
+ "\n"
+ "void fragment() { \n"
+ " ALBEDO = albedo.rgb; \n"
+ " ALPHA = albedo.a; \n"
+ "}");
+
+ border_mat->set_shader(border_shader);
+ border_mat->set_shader_param("albedo", Color(0.75, 0.75, 0.75, col.a / 3.0));
+
+ rotate_gizmo[3] = Ref<ArrayMesh>(memnew(ArrayMesh));
+ rotate_gizmo[3]->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, arrays);
+ rotate_gizmo[3]->surface_set_material(0, border_mat);
+ }
}
// Scale
diff --git a/editor/plugins/node_3d_editor_plugin.h b/editor/plugins/node_3d_editor_plugin.h
index 6a8af38742..b3dc4ef5f2 100644
--- a/editor/plugins/node_3d_editor_plugin.h
+++ b/editor/plugins/node_3d_editor_plugin.h
@@ -412,7 +412,7 @@ private:
real_t zoom_indicator_delay;
- RID move_gizmo_instance[3], move_plane_gizmo_instance[3], rotate_gizmo_instance[3], scale_gizmo_instance[3], scale_plane_gizmo_instance[3];
+ RID move_gizmo_instance[3], move_plane_gizmo_instance[3], rotate_gizmo_instance[4], scale_gizmo_instance[3], scale_plane_gizmo_instance[3];
String last_message;
String message;
@@ -600,11 +600,13 @@ private:
bool grid_enable[3]; //should be always visible if true
bool grid_enabled;
- Ref<ArrayMesh> move_gizmo[3], move_plane_gizmo[3], rotate_gizmo[3], scale_gizmo[3], scale_plane_gizmo[3];
+ Ref<ArrayMesh> move_gizmo[3], move_plane_gizmo[3], rotate_gizmo[4], scale_gizmo[3], scale_plane_gizmo[3];
Ref<StandardMaterial3D> gizmo_color[3];
Ref<StandardMaterial3D> plane_gizmo_color[3];
+ Ref<ShaderMaterial> rotate_gizmo_color[3];
Ref<StandardMaterial3D> gizmo_color_hl[3];
Ref<StandardMaterial3D> plane_gizmo_color_hl[3];
+ Ref<ShaderMaterial> rotate_gizmo_color_hl[3];
int over_gizmo_handle;
float snap_translate_value;
diff --git a/editor/plugins/packed_scene_translation_parser_plugin.cpp b/editor/plugins/packed_scene_translation_parser_plugin.cpp
index 52af0008b7..608b5c3104 100644
--- a/editor/plugins/packed_scene_translation_parser_plugin.cpp
+++ b/editor/plugins/packed_scene_translation_parser_plugin.cpp
@@ -37,7 +37,7 @@ void PackedSceneEditorTranslationParserPlugin::get_recognized_extensions(List<St
ResourceLoader::get_recognized_extensions_for_type("PackedScene", r_extensions);
}
-Error PackedSceneEditorTranslationParserPlugin::parse_file(const String &p_path, Vector<String> *r_extracted_strings) {
+Error PackedSceneEditorTranslationParserPlugin::parse_file(const String &p_path, Vector<String> *r_ids, Vector<Vector<String>> *r_ids_ctx_plural) {
// Parse specific scene Node's properties (see in constructor) that are auto-translated by the engine when set. E.g Label's text property.
// These properties are translated with the tr() function in the C++ code when being set or updated.
@@ -71,8 +71,10 @@ Error PackedSceneEditorTranslationParserPlugin::parse_file(const String &p_path,
String extension = s->get_language()->get_extension();
if (EditorTranslationParser::get_singleton()->can_parse(extension)) {
Vector<String> temp;
- EditorTranslationParser::get_singleton()->get_parser(extension)->parse_file(s->get_path(), &temp);
+ Vector<Vector<String>> ids_context_plural;
+ EditorTranslationParser::get_singleton()->get_parser(extension)->parse_file(s->get_path(), &temp, &ids_context_plural);
parsed_strings.append_array(temp);
+ r_ids_ctx_plural->append_array(ids_context_plural);
}
} else if (property_name == "filters") {
// Extract FileDialog's filters property with values in format "*.png ; PNG Images","*.gd ; GDScript Files".
@@ -93,7 +95,7 @@ Error PackedSceneEditorTranslationParserPlugin::parse_file(const String &p_path,
}
}
- r_extracted_strings->append_array(parsed_strings);
+ r_ids->append_array(parsed_strings);
return OK;
}
diff --git a/editor/plugins/packed_scene_translation_parser_plugin.h b/editor/plugins/packed_scene_translation_parser_plugin.h
index 2bd4dae995..a0ffdf692c 100644
--- a/editor/plugins/packed_scene_translation_parser_plugin.h
+++ b/editor/plugins/packed_scene_translation_parser_plugin.h
@@ -40,7 +40,7 @@ class PackedSceneEditorTranslationParserPlugin : public EditorTranslationParserP
Set<String> lookup_properties;
public:
- virtual Error parse_file(const String &p_path, Vector<String> *r_extracted_strings) override;
+ virtual Error parse_file(const String &p_path, Vector<String> *r_ids, Vector<Vector<String>> *r_ids_ctx_plural) override;
virtual void get_recognized_extensions(List<String> *r_extensions) const override;
PackedSceneEditorTranslationParserPlugin();
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index 20eef1cebd..be8ddf789b 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -1585,15 +1585,14 @@ void ScriptEditor::get_breakpoints(List<String> *p_breakpoints) {
continue;
}
- List<int> bpoints;
- se->get_breakpoints(&bpoints);
String base = script->get_path();
if (base.begins_with("local://") || base == "") {
continue;
}
- for (List<int>::Element *E = bpoints.front(); E; E = E->next()) {
- p_breakpoints->push_back(base + ":" + itos(E->get() + 1));
+ Array bpoints = se->get_breakpoints();
+ for (int j = 0; j < bpoints.size(); j++) {
+ p_breakpoints->push_back(base + ":" + itos((int)bpoints[j] + 1));
}
}
}
diff --git a/editor/plugins/script_editor_plugin.h b/editor/plugins/script_editor_plugin.h
index 1234ebd267..c2b0b458eb 100644
--- a/editor/plugins/script_editor_plugin.h
+++ b/editor/plugins/script_editor_plugin.h
@@ -151,7 +151,7 @@ public:
virtual void ensure_focus() = 0;
virtual void tag_saved_version() = 0;
virtual void reload(bool p_soft) {}
- virtual void get_breakpoints(List<int> *p_breakpoints) = 0;
+ virtual Array get_breakpoints() = 0;
virtual void add_callback(const String &p_function, PackedStringArray p_args) = 0;
virtual void update_settings() = 0;
virtual void set_debugger_active(bool p_active) = 0;
diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp
index 4b89ca1216..7feb7cb3d3 100644
--- a/editor/plugins/script_text_editor.cpp
+++ b/editor/plugins/script_text_editor.cpp
@@ -111,7 +111,7 @@ ConnectionInfoDialog::ConnectionInfoDialog() {
Vector<String> ScriptTextEditor::get_functions() {
String errortxt;
int line = -1, col;
- TextEdit *te = code_editor->get_text_edit();
+ CodeEdit *te = code_editor->get_text_editor();
String text = te->get_text();
List<String> fnc;
@@ -130,9 +130,9 @@ void ScriptTextEditor::apply_code() {
if (script.is_null()) {
return;
}
- script->set_source_code(code_editor->get_text_edit()->get_text());
+ script->set_source_code(code_editor->get_text_editor()->get_text());
script->update_exports();
- code_editor->get_text_edit()->get_syntax_highlighter()->update_cache();
+ code_editor->get_text_editor()->get_syntax_highlighter()->update_cache();
}
RES ScriptTextEditor::get_edited_resource() const {
@@ -145,9 +145,9 @@ void ScriptTextEditor::set_edited_resource(const RES &p_res) {
script = p_res;
- code_editor->get_text_edit()->set_text(script->get_source_code());
- code_editor->get_text_edit()->clear_undo_history();
- code_editor->get_text_edit()->tag_saved_version();
+ code_editor->get_text_editor()->set_text(script->get_source_code());
+ code_editor->get_text_editor()->clear_undo_history();
+ code_editor->get_text_editor()->tag_saved_version();
emit_signal("name_changed");
code_editor->update_line_and_column();
@@ -167,9 +167,19 @@ void ScriptTextEditor::enable_editor() {
}
void ScriptTextEditor::_load_theme_settings() {
- TextEdit *text_edit = code_editor->get_text_edit();
+ CodeEdit *text_edit = code_editor->get_text_editor();
text_edit->clear_keywords();
+ Color updated_safe_line_number_color = EDITOR_GET("text_editor/highlighting/safe_line_number_color");
+ if (updated_safe_line_number_color != safe_line_number_color) {
+ safe_line_number_color = updated_safe_line_number_color;
+ for (int i = 0; i < text_edit->get_line_count(); i++) {
+ if (text_edit->get_line_gutter_item_color(i, line_number_gutter) != default_line_number_color) {
+ text_edit->set_line_gutter_item_color(i, line_number_gutter, safe_line_number_color);
+ }
+ }
+ }
+
Color background_color = EDITOR_GET("text_editor/highlighting/background_color");
Color completion_background_color = EDITOR_GET("text_editor/highlighting/completion_background_color");
Color completion_selected_color = EDITOR_GET("text_editor/highlighting/completion_selected_color");
@@ -178,7 +188,6 @@ void ScriptTextEditor::_load_theme_settings() {
Color completion_font_color = EDITOR_GET("text_editor/highlighting/completion_font_color");
Color text_color = EDITOR_GET("text_editor/highlighting/text_color");
Color line_number_color = EDITOR_GET("text_editor/highlighting/line_number_color");
- Color safe_line_number_color = EDITOR_GET("text_editor/highlighting/safe_line_number_color");
Color caret_color = EDITOR_GET("text_editor/highlighting/caret_color");
Color caret_background_color = EDITOR_GET("text_editor/highlighting/caret_background_color");
Color text_selected_color = EDITOR_GET("text_editor/highlighting/text_selected_color");
@@ -203,7 +212,6 @@ void ScriptTextEditor::_load_theme_settings() {
text_edit->add_theme_color_override("completion_font_color", completion_font_color);
text_edit->add_theme_color_override("font_color", text_color);
text_edit->add_theme_color_override("line_number_color", line_number_color);
- text_edit->add_theme_color_override("safe_line_number_color", safe_line_number_color);
text_edit->add_theme_color_override("caret_color", caret_color);
text_edit->add_theme_color_override("caret_background_color", caret_background_color);
text_edit->add_theme_color_override("font_color_selected", text_selected_color);
@@ -233,7 +241,7 @@ void ScriptTextEditor::_set_theme_for_script() {
return;
}
- TextEdit *text_edit = code_editor->get_text_edit();
+ CodeEdit *text_edit = code_editor->get_text_editor();
text_edit->get_syntax_highlighter()->update_cache();
/* add keywords for auto completion */
@@ -284,10 +292,10 @@ void ScriptTextEditor::_show_warnings_panel(bool p_show) {
void ScriptTextEditor::_warning_clicked(Variant p_line) {
if (p_line.get_type() == Variant::INT) {
- code_editor->get_text_edit()->cursor_set_line(p_line.operator int64_t());
+ code_editor->get_text_editor()->cursor_set_line(p_line.operator int64_t());
} else if (p_line.get_type() == Variant::DICTIONARY) {
Dictionary meta = p_line.operator Dictionary();
- code_editor->get_text_edit()->insert_at("# warning-ignore:" + meta["code"].operator String(), meta["line"].operator int64_t() - 1);
+ code_editor->get_text_editor()->insert_at("# warning-ignore:" + meta["code"].operator String(), meta["line"].operator int64_t() - 1);
_validate_script();
}
}
@@ -295,7 +303,7 @@ void ScriptTextEditor::_warning_clicked(Variant p_line) {
void ScriptTextEditor::reload_text() {
ERR_FAIL_COND(script.is_null());
- TextEdit *te = code_editor->get_text_edit();
+ CodeEdit *te = code_editor->get_text_editor();
int column = te->cursor_get_column();
int row = te->cursor_get_line();
int h = te->get_h_scroll();
@@ -313,20 +321,20 @@ void ScriptTextEditor::reload_text() {
}
void ScriptTextEditor::add_callback(const String &p_function, PackedStringArray p_args) {
- String code = code_editor->get_text_edit()->get_text();
+ String code = code_editor->get_text_editor()->get_text();
int pos = script->get_language()->find_function(p_function, code);
if (pos == -1) {
//does not exist
- code_editor->get_text_edit()->deselect();
- pos = code_editor->get_text_edit()->get_line_count() + 2;
+ code_editor->get_text_editor()->deselect();
+ pos = code_editor->get_text_editor()->get_line_count() + 2;
String func = script->get_language()->make_function("", p_function, p_args);
//code=code+func;
- code_editor->get_text_edit()->cursor_set_line(pos + 1);
- code_editor->get_text_edit()->cursor_set_column(1000000); //none shall be that big
- code_editor->get_text_edit()->insert_text_at_cursor("\n\n" + func);
+ code_editor->get_text_editor()->cursor_set_line(pos + 1);
+ code_editor->get_text_editor()->cursor_set_column(1000000); //none shall be that big
+ code_editor->get_text_editor()->insert_text_at_cursor("\n\n" + func);
}
- code_editor->get_text_edit()->cursor_set_line(pos);
- code_editor->get_text_edit()->cursor_set_column(1);
+ code_editor->get_text_editor()->cursor_set_line(pos);
+ code_editor->get_text_editor()->cursor_set_column(1);
}
bool ScriptTextEditor::show_members_overview() {
@@ -334,12 +342,13 @@ bool ScriptTextEditor::show_members_overview() {
}
void ScriptTextEditor::update_settings() {
+ code_editor->get_text_editor()->set_gutter_draw(connection_gutter, EditorSettings::get_singleton()->get("text_editor/appearance/show_info_gutter"));
code_editor->update_editor_settings();
}
bool ScriptTextEditor::is_unsaved() {
const bool unsaved =
- code_editor->get_text_edit()->get_version() != code_editor->get_text_edit()->get_saved_version() ||
+ code_editor->get_text_editor()->get_version() != code_editor->get_text_editor()->get_saved_version() ||
script->get_path().empty(); // In memory.
return unsaved;
}
@@ -385,7 +394,7 @@ void ScriptTextEditor::convert_indent_to_tabs() {
}
void ScriptTextEditor::tag_saved_version() {
- code_editor->get_text_edit()->tag_saved_version();
+ code_editor->get_text_editor()->tag_saved_version();
}
void ScriptTextEditor::goto_line(int p_line, bool p_with_error) {
@@ -409,7 +418,7 @@ void ScriptTextEditor::clear_executing_line() {
}
void ScriptTextEditor::ensure_focus() {
- code_editor->get_text_edit()->grab_focus();
+ code_editor->get_text_editor()->grab_focus();
}
String ScriptTextEditor::get_name() {
@@ -443,7 +452,7 @@ Ref<Texture2D> ScriptTextEditor::get_theme_icon() {
void ScriptTextEditor::_validate_script() {
String errortxt;
int line = -1, col;
- TextEdit *te = code_editor->get_text_edit();
+ CodeEdit *te = code_editor->get_text_editor();
String text = te->get_text();
List<String> fnc;
@@ -540,16 +549,16 @@ void ScriptTextEditor::_validate_script() {
te->set_line_as_marked(i, line == i);
if (highlight_safe) {
if (safe_lines.has(i + 1)) {
- te->set_line_as_safe(i, true);
+ te->set_line_gutter_item_color(i, line_number_gutter, safe_line_number_color);
last_is_safe = true;
} else if (last_is_safe && (te->is_line_comment(i) || te->get_line(i).strip_edges().empty())) {
- te->set_line_as_safe(i, true);
+ te->set_line_gutter_item_color(i, line_number_gutter, safe_line_number_color);
} else {
- te->set_line_as_safe(i, false);
+ te->set_line_gutter_item_color(i, line_number_gutter, default_line_number_color);
last_is_safe = false;
}
} else {
- te->set_line_as_safe(i, false);
+ te->set_line_gutter_item_color(line, 1, default_line_number_color);
}
}
@@ -566,7 +575,7 @@ void ScriptTextEditor::_update_bookmark_list() {
bookmarks_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/goto_next_bookmark"), BOOKMARK_GOTO_NEXT);
bookmarks_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/goto_previous_bookmark"), BOOKMARK_GOTO_PREV);
- Array bookmark_list = code_editor->get_text_edit()->get_bookmarks_array();
+ Array bookmark_list = code_editor->get_text_editor()->get_bookmarked_lines();
if (bookmark_list.size() == 0) {
return;
}
@@ -576,7 +585,7 @@ void ScriptTextEditor::_update_bookmark_list() {
for (int i = 0; i < bookmark_list.size(); i++) {
// Strip edges to remove spaces or tabs.
// Also replace any tabs by spaces, since we can't print tabs in the menu.
- String line = code_editor->get_text_edit()->get_line(bookmark_list[i]).replace("\t", " ").strip_edges();
+ String line = code_editor->get_text_editor()->get_line(bookmark_list[i]).replace("\t", " ").strip_edges();
// Limit the size of the line if too big.
if (line.length() > 50) {
@@ -593,7 +602,7 @@ void ScriptTextEditor::_bookmark_item_pressed(int p_idx) {
_edit_option(bookmarks_menu->get_item_id(p_idx));
} else {
code_editor->goto_line(bookmarks_menu->get_item_metadata(p_idx));
- code_editor->get_text_edit()->call_deferred("center_viewport_to_cursor"); //Need to be deferred, because goto uses call_deferred().
+ code_editor->get_text_editor()->call_deferred("center_viewport_to_cursor"); //Need to be deferred, because goto uses call_deferred().
}
}
@@ -704,7 +713,7 @@ void ScriptTextEditor::_code_complete_script(const String &p_code, List<ScriptCo
String hint;
Error err = script->get_language()->complete_code(p_code, script->get_path(), base, r_options, r_force, hint);
if (err == OK) {
- code_editor->get_text_edit()->set_code_hint(hint);
+ code_editor->get_text_editor()->set_code_hint(hint);
}
}
@@ -717,7 +726,7 @@ void ScriptTextEditor::_update_breakpoint_list() {
breakpoints_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/goto_next_breakpoint"), DEBUG_GOTO_NEXT_BREAKPOINT);
breakpoints_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/goto_previous_breakpoint"), DEBUG_GOTO_PREV_BREAKPOINT);
- Array breakpoint_list = code_editor->get_text_edit()->get_breakpoints_array();
+ Array breakpoint_list = code_editor->get_text_editor()->get_breakpointed_lines();
if (breakpoint_list.size() == 0) {
return;
}
@@ -727,7 +736,7 @@ void ScriptTextEditor::_update_breakpoint_list() {
for (int i = 0; i < breakpoint_list.size(); i++) {
// Strip edges to remove spaces or tabs.
// Also replace any tabs by spaces, since we can't print tabs in the menu.
- String line = code_editor->get_text_edit()->get_line(breakpoint_list[i]).replace("\t", " ").strip_edges();
+ String line = code_editor->get_text_editor()->get_line(breakpoint_list[i]).replace("\t", " ").strip_edges();
// Limit the size of the line if too big.
if (line.length() > 50) {
@@ -744,12 +753,12 @@ void ScriptTextEditor::_breakpoint_item_pressed(int p_idx) {
_edit_option(breakpoints_menu->get_item_id(p_idx));
} else {
code_editor->goto_line(breakpoints_menu->get_item_metadata(p_idx));
- code_editor->get_text_edit()->call_deferred("center_viewport_to_cursor"); //Need to be deferred, because goto uses call_deferred().
+ code_editor->get_text_editor()->call_deferred("center_viewport_to_cursor"); //Need to be deferred, because goto uses call_deferred().
}
}
void ScriptTextEditor::_breakpoint_toggled(int p_row) {
- EditorDebuggerNode::get_singleton()->set_breakpoint(script->get_path(), p_row + 1, code_editor->get_text_edit()->is_line_set_as_breakpoint(p_row));
+ EditorDebuggerNode::get_singleton()->set_breakpoint(script->get_path(), p_row + 1, code_editor->get_text_editor()->is_line_breakpointed(p_row));
}
void ScriptTextEditor::_lookup_symbol(const String &p_symbol, int p_row, int p_column) {
@@ -771,7 +780,7 @@ void ScriptTextEditor::_lookup_symbol(const String &p_symbol, int p_row, int p_c
EditorNode::get_singleton()->load_resource(p_symbol);
}
- } else if (script->get_language()->lookup_code(code_editor->get_text_edit()->get_text_for_lookup_completion(), p_symbol, script->get_path(), base, result) == OK) {
+ } else if (script->get_language()->lookup_code(code_editor->get_text_editor()->get_text_for_lookup_completion(), p_symbol, script->get_path(), base, result) == OK) {
_goto_line(p_row);
result.class_name = result.class_name.trim_prefix("_");
@@ -866,7 +875,7 @@ void ScriptTextEditor::_lookup_symbol(const String &p_symbol, int p_row, int p_c
}
void ScriptTextEditor::_validate_symbol(const String &p_symbol) {
- TextEdit *text_edit = code_editor->get_text_edit();
+ CodeEdit *text_edit = code_editor->get_text_editor();
Node *base = get_tree()->get_edited_scene_root();
if (base) {
@@ -874,7 +883,7 @@ void ScriptTextEditor::_validate_symbol(const String &p_symbol) {
}
ScriptLanguage::LookupResult result;
- if (ScriptServer::is_global_class(p_symbol) || p_symbol.is_resource_file() || script->get_language()->lookup_code(code_editor->get_text_edit()->get_text_for_lookup_completion(), p_symbol, script->get_path(), base, result) == OK || (ProjectSettings::get_singleton()->has_autoload(p_symbol) && ProjectSettings::get_singleton()->get_autoload(p_symbol).is_singleton)) {
+ if (ScriptServer::is_global_class(p_symbol) || p_symbol.is_resource_file() || script->get_language()->lookup_code(code_editor->get_text_editor()->get_text_for_lookup_completion(), p_symbol, script->get_path(), base, result) == OK || (ProjectSettings::get_singleton()->has_autoload(p_symbol) && ProjectSettings::get_singleton()->get_autoload(p_symbol).is_singleton)) {
text_edit->set_highlighted_word(p_symbol);
} else if (p_symbol.is_rel_path()) {
String path = _get_absolute_path(p_symbol);
@@ -902,8 +911,15 @@ void ScriptTextEditor::update_toggle_scripts_button() {
}
void ScriptTextEditor::_update_connected_methods() {
- TextEdit *text_edit = code_editor->get_text_edit();
- text_edit->clear_info_icons();
+ CodeEdit *text_edit = code_editor->get_text_editor();
+ for (int i = 0; i < text_edit->get_line_count(); i++) {
+ if (text_edit->get_line_gutter_metadata(i, connection_gutter) == "") {
+ continue;
+ }
+ text_edit->set_line_gutter_metadata(i, connection_gutter, "");
+ text_edit->set_line_gutter_icon(i, connection_gutter, nullptr);
+ text_edit->set_line_gutter_clickable(i, connection_gutter, false);
+ }
missing_connections.clear();
if (!script_is_valid) {
@@ -943,8 +959,10 @@ void ScriptTextEditor::_update_connected_methods() {
for (int j = 0; j < functions.size(); j++) {
String name = functions[j].get_slice(":", 0);
if (name == connection.callable.get_method()) {
- line = functions[j].get_slice(":", 1).to_int();
- text_edit->set_line_info_icon(line - 1, get_parent_control()->get_theme_icon("Slot", "EditorIcons"), connection.callable.get_method());
+ line = functions[j].get_slice(":", 1).to_int() - 1;
+ text_edit->set_line_gutter_metadata(line, connection_gutter, connection.callable.get_method());
+ text_edit->set_line_gutter_icon(line, connection_gutter, get_parent_control()->get_theme_icon("Slot", "EditorIcons"));
+ text_edit->set_line_gutter_clickable(line, connection_gutter, true);
methods_found.insert(connection.callable.get_method());
break;
}
@@ -974,18 +992,41 @@ void ScriptTextEditor::_update_connected_methods() {
}
}
-void ScriptTextEditor::_lookup_connections(int p_row, String p_method) {
+void ScriptTextEditor::_update_gutter_indexes() {
+ for (int i = 0; i < code_editor->get_text_editor()->get_gutter_count(); i++) {
+ if (code_editor->get_text_editor()->get_gutter_name(i) == "connection_gutter") {
+ connection_gutter = i;
+ continue;
+ }
+
+ if (code_editor->get_text_editor()->get_gutter_name(i) == "line_numbers") {
+ line_number_gutter = i;
+ continue;
+ }
+ }
+}
+
+void ScriptTextEditor::_gutter_clicked(int p_line, int p_gutter) {
+ if (p_gutter != connection_gutter) {
+ return;
+ }
+
+ String method = code_editor->get_text_editor()->get_line_gutter_metadata(p_line, p_gutter);
+ if (method == "") {
+ return;
+ }
+
Node *base = get_tree()->get_edited_scene_root();
if (!base) {
return;
}
Vector<Node *> nodes = _find_all_node_for_script(base, base, script);
- connection_info_dialog->popup_connections(p_method, nodes);
+ connection_info_dialog->popup_connections(method, nodes);
}
void ScriptTextEditor::_edit_option(int p_op) {
- TextEdit *tx = code_editor->get_text_edit();
+ CodeEdit *tx = code_editor->get_text_editor();
switch (p_op) {
case EDIT_UNDO: {
@@ -1109,7 +1150,7 @@ void ScriptTextEditor::_edit_option(int p_op) {
} break;
case EDIT_EVALUATE: {
Expression expression;
- Vector<String> lines = code_editor->get_text_edit()->get_selection_text().split("\n");
+ Vector<String> lines = code_editor->get_text_editor()->get_selection_text().split("\n");
PackedStringArray results;
for (int i = 0; i < lines.size(); i++) {
@@ -1128,9 +1169,9 @@ void ScriptTextEditor::_edit_option(int p_op) {
}
}
- code_editor->get_text_edit()->begin_complex_operation(); //prevents creating a two-step undo
- code_editor->get_text_edit()->insert_text_at_cursor(String("\n").join(results));
- code_editor->get_text_edit()->end_complex_operation();
+ code_editor->get_text_editor()->begin_complex_operation(); //prevents creating a two-step undo
+ code_editor->get_text_editor()->insert_text_at_cursor(String("\n").join(results));
+ code_editor->get_text_editor()->end_complex_operation();
} break;
case SEARCH_FIND: {
code_editor->get_find_replace_bar()->popup_search();
@@ -1145,14 +1186,14 @@ void ScriptTextEditor::_edit_option(int p_op) {
code_editor->get_find_replace_bar()->popup_replace();
} break;
case SEARCH_IN_FILES: {
- String selected_text = code_editor->get_text_edit()->get_selection_text();
+ String selected_text = code_editor->get_text_editor()->get_selection_text();
// Yep, because it doesn't make sense to instance this dialog for every single script open...
// So this will be delegated to the ScriptEditor.
emit_signal("search_in_files_requested", selected_text);
} break;
case REPLACE_IN_FILES: {
- String selected_text = code_editor->get_text_edit()->get_selection_text();
+ String selected_text = code_editor->get_text_editor()->get_selection_text();
emit_signal("replace_in_files_requested", selected_text);
} break;
@@ -1177,24 +1218,22 @@ void ScriptTextEditor::_edit_option(int p_op) {
} break;
case DEBUG_TOGGLE_BREAKPOINT: {
int line = tx->cursor_get_line();
- bool dobreak = !tx->is_line_set_as_breakpoint(line);
+ bool dobreak = !tx->is_line_breakpointed(line);
tx->set_line_as_breakpoint(line, dobreak);
EditorDebuggerNode::get_singleton()->set_breakpoint(script->get_path(), line + 1, dobreak);
} break;
case DEBUG_REMOVE_ALL_BREAKPOINTS: {
- List<int> bpoints;
- tx->get_breakpoints(&bpoints);
+ Array bpoints = tx->get_breakpointed_lines();
- for (List<int>::Element *E = bpoints.front(); E; E = E->next()) {
- int line = E->get();
- bool dobreak = !tx->is_line_set_as_breakpoint(line);
+ for (int i = 0; i < bpoints.size(); i++) {
+ int line = bpoints[i];
+ bool dobreak = !tx->is_line_breakpointed(line);
tx->set_line_as_breakpoint(line, dobreak);
EditorDebuggerNode::get_singleton()->set_breakpoint(script->get_path(), line + 1, dobreak);
}
} break;
case DEBUG_GOTO_NEXT_BREAKPOINT: {
- List<int> bpoints;
- tx->get_breakpoints(&bpoints);
+ Array bpoints = tx->get_breakpointed_lines();
if (bpoints.size() <= 0) {
return;
}
@@ -1202,13 +1241,13 @@ void ScriptTextEditor::_edit_option(int p_op) {
int line = tx->cursor_get_line();
// wrap around
- if (line >= bpoints[bpoints.size() - 1]) {
+ if (line >= (int)bpoints[bpoints.size() - 1]) {
tx->unfold_line(bpoints[0]);
tx->cursor_set_line(bpoints[0]);
tx->center_viewport_to_cursor();
} else {
- for (List<int>::Element *E = bpoints.front(); E; E = E->next()) {
- int bline = E->get();
+ for (int i = 0; i < bpoints.size(); i++) {
+ int bline = bpoints[i];
if (bline > line) {
tx->unfold_line(bline);
tx->cursor_set_line(bline);
@@ -1220,21 +1259,20 @@ void ScriptTextEditor::_edit_option(int p_op) {
} break;
case DEBUG_GOTO_PREV_BREAKPOINT: {
- List<int> bpoints;
- tx->get_breakpoints(&bpoints);
+ Array bpoints = tx->get_breakpointed_lines();
if (bpoints.size() <= 0) {
return;
}
int line = tx->cursor_get_line();
// wrap around
- if (line <= bpoints[0]) {
+ if (line <= (int)bpoints[0]) {
tx->unfold_line(bpoints[bpoints.size() - 1]);
tx->cursor_set_line(bpoints[bpoints.size() - 1]);
tx->center_viewport_to_cursor();
} else {
- for (List<int>::Element *E = bpoints.back(); E; E = E->prev()) {
- int bline = E->get();
+ for (int i = bpoints.size(); i >= 0; i--) {
+ int bline = bpoints[i];
if (bline < line) {
tx->unfold_line(bline);
tx->cursor_set_line(bline);
@@ -1303,7 +1341,7 @@ void ScriptTextEditor::set_syntax_highlighter(Ref<EditorSyntaxHighlighter> p_hig
el = el->next();
}
- TextEdit *te = code_editor->get_text_edit();
+ CodeEdit *te = code_editor->get_text_editor();
p_highlighter->_set_edited_resource(script);
te->set_syntax_highlighter(p_highlighter);
}
@@ -1312,6 +1350,16 @@ void ScriptTextEditor::_change_syntax_highlighter(int p_idx) {
set_syntax_highlighter(highlighters[highlighter_menu->get_item_text(p_idx)]);
}
+void ScriptTextEditor::_notification(int p_what) {
+ switch (p_what) {
+ case NOTIFICATION_THEME_CHANGED: {
+ code_editor->get_text_editor()->set_gutter_width(connection_gutter, code_editor->get_text_editor()->get_row_height());
+ } break;
+ default:
+ break;
+ }
+}
+
void ScriptTextEditor::_bind_methods() {
ClassDB::bind_method("_update_connected_methods", &ScriptTextEditor::_update_connected_methods);
@@ -1331,7 +1379,7 @@ void ScriptTextEditor::clear_edit_menu() {
}
void ScriptTextEditor::reload(bool p_soft) {
- TextEdit *te = code_editor->get_text_edit();
+ CodeEdit *te = code_editor->get_text_editor();
Ref<Script> scr = script;
if (scr.is_null()) {
return;
@@ -1342,12 +1390,12 @@ void ScriptTextEditor::reload(bool p_soft) {
scr->get_language()->reload_tool_script(scr, soft);
}
-void ScriptTextEditor::get_breakpoints(List<int> *p_breakpoints) {
- code_editor->get_text_edit()->get_breakpoints(p_breakpoints);
+Array ScriptTextEditor::get_breakpoints() {
+ return code_editor->get_text_editor()->get_breakpointed_lines();
}
void ScriptTextEditor::set_tooltip_request_func(String p_method, Object *p_obj) {
- code_editor->get_text_edit()->set_tooltip_request_func(p_obj, p_method, this);
+ code_editor->get_text_editor()->set_tooltip_request_func(p_obj, p_method, this);
}
void ScriptTextEditor::set_debugger_active(bool p_active) {
@@ -1393,7 +1441,7 @@ static Node *_find_script_node(Node *p_edited_scene, Node *p_current_node, const
void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
Dictionary d = p_data;
- TextEdit *te = code_editor->get_text_edit();
+ CodeEdit *te = code_editor->get_text_editor();
int row, col;
te->_get_mouse_pos(p_point, row, col);
@@ -1466,7 +1514,7 @@ void ScriptTextEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) {
Point2 local_pos;
bool create_menu = false;
- TextEdit *tx = code_editor->get_text_edit();
+ CodeEdit *tx = code_editor->get_text_editor();
if (mb.is_valid() && mb->get_button_index() == BUTTON_RIGHT && mb->is_pressed()) {
local_pos = mb->get_global_position() - tx->get_global_position();
create_menu = true;
@@ -1519,7 +1567,7 @@ void ScriptTextEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) {
base = _find_node_for_script(base, base, script);
}
ScriptLanguage::LookupResult result;
- if (script->get_language()->lookup_code(code_editor->get_text_edit()->get_text_for_lookup_completion(), word_at_pos, script->get_path(), base, result) == OK) {
+ if (script->get_language()->lookup_code(code_editor->get_text_editor()->get_text_for_lookup_completion(), word_at_pos, script->get_path(), base, result) == OK) {
open_docs = true;
}
}
@@ -1567,17 +1615,17 @@ void ScriptTextEditor::_color_changed(const Color &p_color) {
new_args = String("(" + rtos(p_color.r) + ", " + rtos(p_color.g) + ", " + rtos(p_color.b) + ", " + rtos(p_color.a) + ")");
}
- String line = code_editor->get_text_edit()->get_line(color_position.x);
+ String line = code_editor->get_text_editor()->get_line(color_position.x);
int color_args_pos = line.find(color_args, color_position.y);
String line_with_replaced_args = line;
line_with_replaced_args.erase(color_args_pos, color_args.length());
line_with_replaced_args = line_with_replaced_args.insert(color_args_pos, new_args);
color_args = new_args;
- code_editor->get_text_edit()->begin_complex_operation();
- code_editor->get_text_edit()->set_line(color_position.x, line_with_replaced_args);
- code_editor->get_text_edit()->end_complex_operation();
- code_editor->get_text_edit()->update();
+ code_editor->get_text_editor()->begin_complex_operation();
+ code_editor->get_text_editor()->set_line(color_position.x, line_with_replaced_args);
+ code_editor->get_text_editor()->end_complex_operation();
+ code_editor->get_text_editor()->update();
}
void ScriptTextEditor::_make_context_menu(bool p_selection, bool p_color, bool p_foldable, bool p_open_docs, bool p_goto_definition, Vector2 p_pos) {
@@ -1636,12 +1684,15 @@ void ScriptTextEditor::_enable_code_editor() {
code_editor->connect("show_warnings_panel", callable_mp(this, &ScriptTextEditor::_show_warnings_panel));
code_editor->connect("validate_script", callable_mp(this, &ScriptTextEditor::_validate_script));
code_editor->connect("load_theme_settings", callable_mp(this, &ScriptTextEditor::_load_theme_settings));
- code_editor->get_text_edit()->connect("breakpoint_toggled", callable_mp(this, &ScriptTextEditor::_breakpoint_toggled));
- code_editor->get_text_edit()->connect("symbol_lookup", callable_mp(this, &ScriptTextEditor::_lookup_symbol));
- code_editor->get_text_edit()->connect("symbol_validate", callable_mp(this, &ScriptTextEditor::_validate_symbol));
- code_editor->get_text_edit()->connect("info_clicked", callable_mp(this, &ScriptTextEditor::_lookup_connections));
- code_editor->get_text_edit()->connect("gui_input", callable_mp(this, &ScriptTextEditor::_text_edit_gui_input));
+ code_editor->get_text_editor()->connect("breakpoint_toggled", callable_mp(this, &ScriptTextEditor::_breakpoint_toggled));
+ code_editor->get_text_editor()->connect("symbol_lookup", callable_mp(this, &ScriptTextEditor::_lookup_symbol));
+ code_editor->get_text_editor()->connect("symbol_validate", callable_mp(this, &ScriptTextEditor::_validate_symbol));
+ code_editor->get_text_editor()->connect("gutter_added", callable_mp(this, &ScriptTextEditor::_update_gutter_indexes));
+ code_editor->get_text_editor()->connect("gutter_removed", callable_mp(this, &ScriptTextEditor::_update_gutter_indexes));
+ code_editor->get_text_editor()->connect("gutter_clicked", callable_mp(this, &ScriptTextEditor::_gutter_clicked));
+ code_editor->get_text_editor()->connect("gui_input", callable_mp(this, &ScriptTextEditor::_text_edit_gui_input));
code_editor->show_toggle_scripts_button();
+ _update_gutter_indexes();
editor_box->add_child(warnings_panel);
warnings_panel->add_theme_font_override(
@@ -1758,6 +1809,16 @@ ScriptTextEditor::ScriptTextEditor() {
code_editor->set_code_complete_func(_code_complete_scripts, this);
code_editor->set_v_size_flags(SIZE_EXPAND_FILL);
+ code_editor->get_text_editor()->set_draw_breakpoints_gutter(true);
+ code_editor->get_text_editor()->set_draw_executing_lines_gutter(true);
+
+ connection_gutter = 1;
+ code_editor->get_text_editor()->add_gutter(connection_gutter);
+ code_editor->get_text_editor()->set_gutter_name(connection_gutter, "connection_gutter");
+ code_editor->get_text_editor()->set_gutter_draw(connection_gutter, false);
+ code_editor->get_text_editor()->set_gutter_overwritable(connection_gutter, true);
+ code_editor->get_text_editor()->set_gutter_type(connection_gutter, TextEdit::GUTTER_TPYE_ICON);
+
warnings_panel = memnew(RichTextLabel);
warnings_panel->set_custom_minimum_size(Size2(0, 100 * EDSCALE));
warnings_panel->set_h_size_flags(SIZE_EXPAND_FILL);
@@ -1768,12 +1829,12 @@ ScriptTextEditor::ScriptTextEditor() {
update_settings();
- code_editor->get_text_edit()->set_callhint_settings(
+ code_editor->get_text_editor()->set_callhint_settings(
EditorSettings::get_singleton()->get("text_editor/completion/put_callhint_tooltip_below_current_line"),
EditorSettings::get_singleton()->get("text_editor/completion/callhint_tooltip_offset"));
- code_editor->get_text_edit()->set_select_identifiers_on_hover(true);
- code_editor->get_text_edit()->set_context_menu_enabled(false);
+ code_editor->get_text_editor()->set_select_identifiers_on_hover(true);
+ code_editor->get_text_editor()->set_context_menu_enabled(false);
context_menu = memnew(PopupMenu);
@@ -1816,7 +1877,7 @@ ScriptTextEditor::ScriptTextEditor() {
connection_info_dialog = memnew(ConnectionInfoDialog);
- code_editor->get_text_edit()->set_drag_forwarding(this);
+ code_editor->get_text_editor()->set_drag_forwarding(this);
}
ScriptTextEditor::~ScriptTextEditor() {
diff --git a/editor/plugins/script_text_editor.h b/editor/plugins/script_text_editor.h
index e931c9fdc6..1e436fbe65 100644
--- a/editor/plugins/script_text_editor.h
+++ b/editor/plugins/script_text_editor.h
@@ -81,6 +81,14 @@ class ScriptTextEditor : public ScriptEditorBase {
ScriptEditorQuickOpen *quick_open = nullptr;
ConnectionInfoDialog *connection_info_dialog = nullptr;
+ int connection_gutter = -1;
+ void _gutter_clicked(int p_line, int p_gutter);
+ void _update_gutter_indexes();
+
+ int line_number_gutter = -1;
+ Color default_line_number_color = Color(1, 1, 1);
+ Color safe_line_number_color = Color(1, 1, 1);
+
PopupPanel *color_panel = nullptr;
ColorPicker *color_picker = nullptr;
Vector2 color_position;
@@ -154,6 +162,7 @@ protected:
void _show_warnings_panel(bool p_show);
void _warning_clicked(Variant p_line);
+ void _notification(int p_what);
static void _bind_methods();
Map<String, Ref<EditorSyntaxHighlighter>> highlighters;
@@ -169,8 +178,6 @@ protected:
void _lookup_symbol(const String &p_symbol, int p_row, int p_column);
void _validate_symbol(const String &p_symbol);
- void _lookup_connections(int p_row, String p_method);
-
void _convert_case(CodeTextEditor::CaseStyle p_case);
Variant get_drag_data_fw(const Point2 &p_point, Control *p_from);
@@ -211,7 +218,7 @@ public:
virtual void clear_executing_line() override;
virtual void reload(bool p_soft) override;
- virtual void get_breakpoints(List<int> *p_breakpoints) override;
+ virtual Array get_breakpoints() override;
virtual void add_callback(const String &p_function, PackedStringArray p_args) override;
virtual void update_settings() override;
diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp
index 2a7f3f0656..29db284b44 100644
--- a/editor/plugins/shader_editor_plugin.cpp
+++ b/editor/plugins/shader_editor_plugin.cpp
@@ -55,8 +55,8 @@ void ShaderTextEditor::set_edited_shader(const Ref<Shader> &p_shader) {
_load_theme_settings();
- get_text_edit()->set_text(p_shader->get_code());
- get_text_edit()->clear_undo_history();
+ get_text_editor()->set_text(p_shader->get_code());
+ get_text_editor()->clear_undo_history();
_validate_script();
_line_col_changed();
@@ -65,7 +65,7 @@ void ShaderTextEditor::set_edited_shader(const Ref<Shader> &p_shader) {
void ShaderTextEditor::reload_text() {
ERR_FAIL_COND(shader.is_null());
- TextEdit *te = get_text_edit();
+ CodeEdit *te = get_text_editor();
int column = te->cursor_get_column();
int row = te->cursor_get_line();
int h = te->get_h_scroll();
@@ -107,29 +107,29 @@ void ShaderTextEditor::_load_theme_settings() {
Color search_result_color = EDITOR_GET("text_editor/highlighting/search_result_color");
Color search_result_border_color = EDITOR_GET("text_editor/highlighting/search_result_border_color");
- get_text_edit()->add_theme_color_override("background_color", background_color);
- get_text_edit()->add_theme_color_override("completion_background_color", completion_background_color);
- get_text_edit()->add_theme_color_override("completion_selected_color", completion_selected_color);
- get_text_edit()->add_theme_color_override("completion_existing_color", completion_existing_color);
- get_text_edit()->add_theme_color_override("completion_scroll_color", completion_scroll_color);
- get_text_edit()->add_theme_color_override("completion_font_color", completion_font_color);
- get_text_edit()->add_theme_color_override("font_color", text_color);
- get_text_edit()->add_theme_color_override("line_number_color", line_number_color);
- get_text_edit()->add_theme_color_override("caret_color", caret_color);
- get_text_edit()->add_theme_color_override("caret_background_color", caret_background_color);
- get_text_edit()->add_theme_color_override("font_color_selected", text_selected_color);
- get_text_edit()->add_theme_color_override("selection_color", selection_color);
- get_text_edit()->add_theme_color_override("brace_mismatch_color", brace_mismatch_color);
- get_text_edit()->add_theme_color_override("current_line_color", current_line_color);
- get_text_edit()->add_theme_color_override("line_length_guideline_color", line_length_guideline_color);
- get_text_edit()->add_theme_color_override("word_highlighted_color", word_highlighted_color);
- get_text_edit()->add_theme_color_override("mark_color", mark_color);
- get_text_edit()->add_theme_color_override("bookmark_color", bookmark_color);
- get_text_edit()->add_theme_color_override("breakpoint_color", breakpoint_color);
- get_text_edit()->add_theme_color_override("executing_line_color", executing_line_color);
- get_text_edit()->add_theme_color_override("code_folding_color", code_folding_color);
- get_text_edit()->add_theme_color_override("search_result_color", search_result_color);
- get_text_edit()->add_theme_color_override("search_result_border_color", search_result_border_color);
+ get_text_editor()->add_theme_color_override("background_color", background_color);
+ get_text_editor()->add_theme_color_override("completion_background_color", completion_background_color);
+ get_text_editor()->add_theme_color_override("completion_selected_color", completion_selected_color);
+ get_text_editor()->add_theme_color_override("completion_existing_color", completion_existing_color);
+ get_text_editor()->add_theme_color_override("completion_scroll_color", completion_scroll_color);
+ get_text_editor()->add_theme_color_override("completion_font_color", completion_font_color);
+ get_text_editor()->add_theme_color_override("font_color", text_color);
+ get_text_editor()->add_theme_color_override("line_number_color", line_number_color);
+ get_text_editor()->add_theme_color_override("caret_color", caret_color);
+ get_text_editor()->add_theme_color_override("caret_background_color", caret_background_color);
+ get_text_editor()->add_theme_color_override("font_color_selected", text_selected_color);
+ get_text_editor()->add_theme_color_override("selection_color", selection_color);
+ get_text_editor()->add_theme_color_override("brace_mismatch_color", brace_mismatch_color);
+ get_text_editor()->add_theme_color_override("current_line_color", current_line_color);
+ get_text_editor()->add_theme_color_override("line_length_guideline_color", line_length_guideline_color);
+ get_text_editor()->add_theme_color_override("word_highlighted_color", word_highlighted_color);
+ get_text_editor()->add_theme_color_override("mark_color", mark_color);
+ get_text_editor()->add_theme_color_override("bookmark_color", bookmark_color);
+ get_text_editor()->add_theme_color_override("breakpoint_color", breakpoint_color);
+ get_text_editor()->add_theme_color_override("executing_line_color", executing_line_color);
+ get_text_editor()->add_theme_color_override("code_folding_color", code_folding_color);
+ get_text_editor()->add_theme_color_override("search_result_color", search_result_color);
+ get_text_editor()->add_theme_color_override("search_result_border_color", search_result_border_color);
syntax_highlighter->set_number_color(EDITOR_GET("text_editor/highlighting/number_color"));
syntax_highlighter->set_symbol_color(EDITOR_GET("text_editor/highlighting/symbol_color"));
@@ -176,7 +176,7 @@ void ShaderTextEditor::_load_theme_settings() {
}
void ShaderTextEditor::_check_shader_mode() {
- String type = ShaderLanguage::get_shader_type(get_text_edit()->get_text());
+ String type = ShaderLanguage::get_shader_type(get_text_editor()->get_text());
Shader::Mode mode;
@@ -189,7 +189,7 @@ void ShaderTextEditor::_check_shader_mode() {
}
if (shader->get_mode() != mode) {
- shader->set_code(get_text_edit()->get_text());
+ shader->set_code(get_text_editor()->get_text());
_load_theme_settings();
}
}
@@ -207,13 +207,13 @@ void ShaderTextEditor::_code_complete_script(const String &p_code, List<ScriptCo
sl.complete(p_code, ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(shader->get_mode())), ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(shader->get_mode())), ShaderTypes::get_singleton()->get_types(), _get_global_variable_type, r_options, calltip);
- get_text_edit()->set_code_hint(calltip);
+ get_text_editor()->set_code_hint(calltip);
}
void ShaderTextEditor::_validate_script() {
_check_shader_mode();
- String code = get_text_edit()->get_text();
+ String code = get_text_editor()->get_text();
//List<StringName> params;
//shader->get_param_list(&params);
@@ -225,14 +225,14 @@ void ShaderTextEditor::_validate_script() {
String error_text = "error(" + itos(sl.get_error_line()) + "): " + sl.get_error_text();
set_error(error_text);
set_error_pos(sl.get_error_line() - 1, 0);
- for (int i = 0; i < get_text_edit()->get_line_count(); i++) {
- get_text_edit()->set_line_as_marked(i, false);
+ for (int i = 0; i < get_text_editor()->get_line_count(); i++) {
+ get_text_editor()->set_line_as_marked(i, false);
}
- get_text_edit()->set_line_as_marked(sl.get_error_line() - 1, true);
+ get_text_editor()->set_line_as_marked(sl.get_error_line() - 1, true);
} else {
- for (int i = 0; i < get_text_edit()->get_line_count(); i++) {
- get_text_edit()->set_line_as_marked(i, false);
+ for (int i = 0; i < get_text_editor()->get_line_count(); i++) {
+ get_text_editor()->set_line_as_marked(i, false);
}
set_error("");
}
@@ -245,7 +245,7 @@ void ShaderTextEditor::_bind_methods() {
ShaderTextEditor::ShaderTextEditor() {
syntax_highlighter.instance();
- get_text_edit()->set_syntax_highlighter(syntax_highlighter);
+ get_text_editor()->set_syntax_highlighter(syntax_highlighter);
}
/*** SCRIPT EDITOR ******/
@@ -253,22 +253,22 @@ ShaderTextEditor::ShaderTextEditor() {
void ShaderEditor::_menu_option(int p_option) {
switch (p_option) {
case EDIT_UNDO: {
- shader_editor->get_text_edit()->undo();
+ shader_editor->get_text_editor()->undo();
} break;
case EDIT_REDO: {
- shader_editor->get_text_edit()->redo();
+ shader_editor->get_text_editor()->redo();
} break;
case EDIT_CUT: {
- shader_editor->get_text_edit()->cut();
+ shader_editor->get_text_editor()->cut();
} break;
case EDIT_COPY: {
- shader_editor->get_text_edit()->copy();
+ shader_editor->get_text_editor()->copy();
} break;
case EDIT_PASTE: {
- shader_editor->get_text_edit()->paste();
+ shader_editor->get_text_editor()->paste();
} break;
case EDIT_SELECT_ALL: {
- shader_editor->get_text_edit()->select_all();
+ shader_editor->get_text_editor()->select_all();
} break;
case EDIT_MOVE_LINE_UP: {
shader_editor->move_lines_up();
@@ -281,7 +281,7 @@ void ShaderEditor::_menu_option(int p_option) {
return;
}
- TextEdit *tx = shader_editor->get_text_edit();
+ CodeEdit *tx = shader_editor->get_text_editor();
tx->indent_left();
} break;
@@ -290,7 +290,7 @@ void ShaderEditor::_menu_option(int p_option) {
return;
}
- TextEdit *tx = shader_editor->get_text_edit();
+ CodeEdit *tx = shader_editor->get_text_editor();
tx->indent_right();
} break;
@@ -309,7 +309,7 @@ void ShaderEditor::_menu_option(int p_option) {
} break;
case EDIT_COMPLETE: {
- shader_editor->get_text_edit()->query_code_comple();
+ shader_editor->get_text_editor()->query_code_comple();
} break;
case SEARCH_FIND: {
shader_editor->get_find_replace_bar()->popup_search();
@@ -324,7 +324,7 @@ void ShaderEditor::_menu_option(int p_option) {
shader_editor->get_find_replace_bar()->popup_replace();
} break;
case SEARCH_GOTO_LINE: {
- goto_line_dialog->popup_find_line(shader_editor->get_text_edit());
+ goto_line_dialog->popup_find_line(shader_editor->get_text_editor());
} break;
case BOOKMARK_TOGGLE: {
shader_editor->toggle_bookmark();
@@ -343,7 +343,7 @@ void ShaderEditor::_menu_option(int p_option) {
} break;
}
if (p_option != SEARCH_FIND && p_option != SEARCH_REPLACE && p_option != SEARCH_GOTO_LINE) {
- shader_editor->get_text_edit()->call_deferred("grab_focus");
+ shader_editor->get_text_editor()->call_deferred("grab_focus");
}
}
@@ -358,28 +358,11 @@ void ShaderEditor::_params_changed() {
}
void ShaderEditor::_editor_settings_changed() {
- shader_editor->get_text_edit()->set_auto_brace_completion(EditorSettings::get_singleton()->get("text_editor/completion/auto_brace_complete"));
- shader_editor->get_text_edit()->set_scroll_pass_end_of_file(EditorSettings::get_singleton()->get("text_editor/cursor/scroll_past_end_of_file"));
- shader_editor->get_text_edit()->set_indent_size(EditorSettings::get_singleton()->get("text_editor/indent/size"));
- shader_editor->get_text_edit()->set_indent_using_spaces(EditorSettings::get_singleton()->get("text_editor/indent/type"));
- shader_editor->get_text_edit()->set_auto_indent(EditorSettings::get_singleton()->get("text_editor/indent/auto_indent"));
- shader_editor->get_text_edit()->set_draw_tabs(EditorSettings::get_singleton()->get("text_editor/indent/draw_tabs"));
- shader_editor->get_text_edit()->set_draw_spaces(EditorSettings::get_singleton()->get("text_editor/indent/draw_spaces"));
- shader_editor->get_text_edit()->set_show_line_numbers(EditorSettings::get_singleton()->get("text_editor/appearance/show_line_numbers"));
- shader_editor->get_text_edit()->set_highlight_all_occurrences(EditorSettings::get_singleton()->get("text_editor/highlighting/highlight_all_occurrences"));
- shader_editor->get_text_edit()->set_highlight_current_line(EditorSettings::get_singleton()->get("text_editor/highlighting/highlight_current_line"));
- shader_editor->get_text_edit()->cursor_set_blink_enabled(EditorSettings::get_singleton()->get("text_editor/cursor/caret_blink"));
- shader_editor->get_text_edit()->cursor_set_blink_speed(EditorSettings::get_singleton()->get("text_editor/cursor/caret_blink_speed"));
- shader_editor->get_text_edit()->add_theme_constant_override("line_spacing", EditorSettings::get_singleton()->get("text_editor/theme/line_spacing"));
- shader_editor->get_text_edit()->cursor_set_block_mode(EditorSettings::get_singleton()->get("text_editor/cursor/block_caret"));
- shader_editor->get_text_edit()->set_smooth_scroll_enabled(EditorSettings::get_singleton()->get("text_editor/navigation/smooth_scrolling"));
- 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_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);
+ shader_editor->update_editor_settings();
+
+ shader_editor->get_text_editor()->add_theme_constant_override("line_spacing", EditorSettings::get_singleton()->get("text_editor/theme/line_spacing"));
+ shader_editor->get_text_editor()->set_draw_breakpoints_gutter(false);
+ shader_editor->get_text_editor()->set_draw_executing_lines_gutter(false);
}
void ShaderEditor::_bind_methods() {
@@ -466,7 +449,7 @@ void ShaderEditor::save_external_data(const String &p_str) {
void ShaderEditor::apply_shaders() {
if (shader.is_valid()) {
String shader_code = shader->get_code();
- String editor_code = shader_editor->get_text_edit()->get_text();
+ String editor_code = shader_editor->get_text_editor()->get_text();
if (shader_code != editor_code) {
shader->set_code(editor_code);
shader->set_edited(true);
@@ -480,7 +463,7 @@ void ShaderEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) {
if (mb.is_valid()) {
if (mb->get_button_index() == BUTTON_RIGHT && mb->is_pressed()) {
int col, row;
- TextEdit *tx = shader_editor->get_text_edit();
+ CodeEdit *tx = shader_editor->get_text_editor();
tx->_get_mouse_pos(mb->get_global_position() - tx->get_global_position(), row, col);
tx->set_right_click_moves_caret(EditorSettings::get_singleton()->get("text_editor/cursor/right_click_moves_caret"));
@@ -507,7 +490,7 @@ void ShaderEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) {
Ref<InputEventKey> k = ev;
if (k.is_valid() && k->is_pressed() && k->get_keycode() == KEY_MENU) {
- TextEdit *tx = shader_editor->get_text_edit();
+ CodeEdit *tx = shader_editor->get_text_editor();
_make_context_menu(tx->is_selection_active(), (get_global_transform().inverse() * tx->get_global_transform()).xform(tx->_get_cursor_pixel_pos()));
context_menu->grab_focus();
}
@@ -521,7 +504,7 @@ void ShaderEditor::_update_bookmark_list() {
bookmarks_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/goto_next_bookmark"), BOOKMARK_GOTO_NEXT);
bookmarks_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/goto_previous_bookmark"), BOOKMARK_GOTO_PREV);
- Array bookmark_list = shader_editor->get_text_edit()->get_bookmarks_array();
+ Array bookmark_list = shader_editor->get_text_editor()->get_bookmarked_lines();
if (bookmark_list.size() == 0) {
return;
}
@@ -529,7 +512,7 @@ void ShaderEditor::_update_bookmark_list() {
bookmarks_menu->add_separator();
for (int i = 0; i < bookmark_list.size(); i++) {
- String line = shader_editor->get_text_edit()->get_line(bookmark_list[i]).strip_edges();
+ String line = shader_editor->get_text_editor()->get_line(bookmark_list[i]).strip_edges();
// Limit the size of the line if too big.
if (line.length() > 50) {
line = line.substr(0, 50);
@@ -581,13 +564,13 @@ ShaderEditor::ShaderEditor(EditorNode *p_node) {
shader_editor->connect("script_changed", callable_mp(this, &ShaderEditor::apply_shaders));
EditorSettings::get_singleton()->connect("settings_changed", callable_mp(this, &ShaderEditor::_editor_settings_changed));
- shader_editor->get_text_edit()->set_callhint_settings(
+ shader_editor->get_text_editor()->set_callhint_settings(
EditorSettings::get_singleton()->get("text_editor/completion/put_callhint_tooltip_below_current_line"),
EditorSettings::get_singleton()->get("text_editor/completion/callhint_tooltip_offset"));
- shader_editor->get_text_edit()->set_select_identifiers_on_hover(true);
- shader_editor->get_text_edit()->set_context_menu_enabled(false);
- shader_editor->get_text_edit()->connect("gui_input", callable_mp(this, &ShaderEditor::_text_edit_gui_input));
+ shader_editor->get_text_editor()->set_select_identifiers_on_hover(true);
+ shader_editor->get_text_editor()->set_context_menu_enabled(false);
+ shader_editor->get_text_editor()->connect("gui_input", callable_mp(this, &ShaderEditor::_text_edit_gui_input));
shader_editor->update_editor_settings();
diff --git a/editor/plugins/sprite_frames_editor_plugin.cpp b/editor/plugins/sprite_frames_editor_plugin.cpp
index 18942b371c..5007983581 100644
--- a/editor/plugins/sprite_frames_editor_plugin.cpp
+++ b/editor/plugins/sprite_frames_editor_plugin.cpp
@@ -995,11 +995,16 @@ SpriteFramesEditor::SpriteFramesEditor() {
animations->connect("item_edited", callable_mp(this, &SpriteFramesEditor::_animation_name_edited));
animations->set_allow_reselect(true);
+ HBoxContainer *hbc_anim_speed = memnew(HBoxContainer);
+ hbc_anim_speed->add_child(memnew(Label(TTR("Speed:"))));
+ vbc_animlist->add_child(hbc_anim_speed);
anim_speed = memnew(SpinBox);
- vbc_animlist->add_margin_child(TTR("Speed (FPS):"), anim_speed);
+ anim_speed->set_suffix(TTR("FPS"));
anim_speed->set_min(0);
anim_speed->set_max(100);
anim_speed->set_step(0.01);
+ anim_speed->set_h_size_flags(SIZE_EXPAND_FILL);
+ hbc_anim_speed->add_child(anim_speed);
anim_speed->connect("value_changed", callable_mp(this, &SpriteFramesEditor::_animation_fps_changed));
anim_loop = memnew(CheckButton);
diff --git a/editor/plugins/text_editor.cpp b/editor/plugins/text_editor.cpp
index 82e231e396..8935b698b6 100644
--- a/editor/plugins/text_editor.cpp
+++ b/editor/plugins/text_editor.cpp
@@ -50,7 +50,7 @@ void TextEditor::set_syntax_highlighter(Ref<EditorSyntaxHighlighter> p_highlight
el = el->next();
}
- TextEdit *te = code_editor->get_text_edit();
+ CodeEdit *te = code_editor->get_text_editor();
te->set_syntax_highlighter(p_highlighter);
}
@@ -59,7 +59,7 @@ void TextEditor::_change_syntax_highlighter(int p_idx) {
}
void TextEditor::_load_theme_settings() {
- TextEdit *text_edit = code_editor->get_text_edit();
+ CodeEdit *text_edit = code_editor->get_text_editor();
text_edit->get_syntax_highlighter()->update_cache();
Color background_color = EDITOR_GET("text_editor/highlighting/background_color");
@@ -147,9 +147,9 @@ void TextEditor::set_edited_resource(const RES &p_res) {
text_file = p_res;
- code_editor->get_text_edit()->set_text(text_file->get_text());
- code_editor->get_text_edit()->clear_undo_history();
- code_editor->get_text_edit()->tag_saved_version();
+ 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();
emit_signal("name_changed");
code_editor->update_line_and_column();
@@ -171,13 +171,14 @@ void TextEditor::add_callback(const String &p_function, PackedStringArray p_args
void TextEditor::set_debugger_active(bool p_active) {
}
-void TextEditor::get_breakpoints(List<int> *p_breakpoints) {
+Array TextEditor::get_breakpoints() {
+ return Array();
}
void TextEditor::reload_text() {
ERR_FAIL_COND(text_file.is_null());
- TextEdit *te = code_editor->get_text_edit();
+ CodeEdit *te = code_editor->get_text_editor();
int column = te->cursor_get_column();
int row = te->cursor_get_line();
int h = te->get_h_scroll();
@@ -207,7 +208,7 @@ void TextEditor::_update_bookmark_list() {
bookmarks_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/goto_next_bookmark"), BOOKMARK_GOTO_NEXT);
bookmarks_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/goto_previous_bookmark"), BOOKMARK_GOTO_PREV);
- Array bookmark_list = code_editor->get_text_edit()->get_bookmarks_array();
+ Array bookmark_list = code_editor->get_text_editor()->get_bookmarked_lines();
if (bookmark_list.size() == 0) {
return;
}
@@ -215,7 +216,7 @@ void TextEditor::_update_bookmark_list() {
bookmarks_menu->add_separator();
for (int i = 0; i < bookmark_list.size(); i++) {
- String line = code_editor->get_text_edit()->get_line(bookmark_list[i]).strip_edges();
+ String line = code_editor->get_text_editor()->get_line(bookmark_list[i]).strip_edges();
// Limit the size of the line if too big.
if (line.length() > 50) {
line = line.substr(0, 50);
@@ -235,12 +236,12 @@ void TextEditor::_bookmark_item_pressed(int p_idx) {
}
void TextEditor::apply_code() {
- text_file->set_text(code_editor->get_text_edit()->get_text());
+ text_file->set_text(code_editor->get_text_editor()->get_text());
}
bool TextEditor::is_unsaved() {
const bool unsaved =
- code_editor->get_text_edit()->get_version() != code_editor->get_text_edit()->get_saved_version() ||
+ code_editor->get_text_editor()->get_version() != code_editor->get_text_editor()->get_saved_version() ||
text_file->get_path().empty(); // In memory.
return unsaved;
}
@@ -280,7 +281,7 @@ void TextEditor::convert_indent_to_tabs() {
}
void TextEditor::tag_saved_version() {
- code_editor->get_text_edit()->tag_saved_version();
+ code_editor->get_text_editor()->tag_saved_version();
}
void TextEditor::goto_line(int p_line, bool p_with_error) {
@@ -300,7 +301,7 @@ void TextEditor::clear_executing_line() {
}
void TextEditor::ensure_focus() {
- code_editor->get_text_edit()->grab_focus();
+ code_editor->get_text_editor()->grab_focus();
}
Vector<String> TextEditor::get_functions() {
@@ -316,7 +317,7 @@ void TextEditor::update_settings() {
}
void TextEditor::set_tooltip_request_func(String p_method, Object *p_obj) {
- code_editor->get_text_edit()->set_tooltip_request_func(p_obj, p_method, this);
+ code_editor->get_text_editor()->set_tooltip_request_func(p_obj, p_method, this);
}
Control *TextEditor::get_edit_menu() {
@@ -328,7 +329,7 @@ void TextEditor::clear_edit_menu() {
}
void TextEditor::_edit_option(int p_op) {
- TextEdit *tx = code_editor->get_text_edit();
+ CodeEdit *tx = code_editor->get_text_editor();
switch (p_op) {
case EDIT_UNDO: {
@@ -416,14 +417,14 @@ void TextEditor::_edit_option(int p_op) {
code_editor->get_find_replace_bar()->popup_replace();
} break;
case SEARCH_IN_FILES: {
- String selected_text = code_editor->get_text_edit()->get_selection_text();
+ String selected_text = code_editor->get_text_editor()->get_selection_text();
// Yep, because it doesn't make sense to instance this dialog for every single script open...
// So this will be delegated to the ScriptEditor.
emit_signal("search_in_files_requested", selected_text);
} break;
case REPLACE_IN_FILES: {
- String selected_text = code_editor->get_text_edit()->get_selection_text();
+ String selected_text = code_editor->get_text_editor()->get_selection_text();
emit_signal("replace_in_files_requested", selected_text);
} break;
@@ -470,7 +471,7 @@ void TextEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) {
if (mb.is_valid()) {
if (mb->get_button_index() == BUTTON_RIGHT) {
int col, row;
- TextEdit *tx = code_editor->get_text_edit();
+ CodeEdit *tx = code_editor->get_text_editor();
tx->_get_mouse_pos(mb->get_global_position() - tx->get_global_position(), row, col);
tx->set_right_click_moves_caret(EditorSettings::get_singleton()->get("text_editor/cursor/right_click_moves_caret"));
@@ -503,7 +504,7 @@ void TextEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) {
Ref<InputEventKey> k = ev;
if (k.is_valid() && k->is_pressed() && k->get_keycode() == KEY_MENU) {
- TextEdit *tx = code_editor->get_text_edit();
+ CodeEdit *tx = code_editor->get_text_editor();
int line = tx->cursor_get_line();
_make_context_menu(tx->is_selection_active(), tx->can_fold(line), tx->is_folded(line), (get_global_transform().inverse() * tx->get_global_transform()).xform(tx->_get_cursor_pixel_pos()));
context_menu->grab_focus();
@@ -552,8 +553,8 @@ TextEditor::TextEditor() {
update_settings();
- code_editor->get_text_edit()->set_context_menu_enabled(false);
- code_editor->get_text_edit()->connect("gui_input", callable_mp(this, &TextEditor::_text_edit_gui_input));
+ code_editor->get_text_editor()->set_context_menu_enabled(false);
+ code_editor->get_text_editor()->connect("gui_input", callable_mp(this, &TextEditor::_text_edit_gui_input));
context_menu = memnew(PopupMenu);
add_child(context_menu);
@@ -649,7 +650,7 @@ TextEditor::TextEditor() {
goto_line_dialog = memnew(GotoLineDialog);
add_child(goto_line_dialog);
- code_editor->get_text_edit()->set_drag_forwarding(this);
+ code_editor->get_text_editor()->set_drag_forwarding(this);
}
TextEditor::~TextEditor() {
diff --git a/editor/plugins/text_editor.h b/editor/plugins/text_editor.h
index f3e9e599cf..ea425bd033 100644
--- a/editor/plugins/text_editor.h
+++ b/editor/plugins/text_editor.h
@@ -119,7 +119,7 @@ public:
virtual Variant get_edit_state() override;
virtual void set_edit_state(const Variant &p_state) override;
virtual Vector<String> get_functions() override;
- virtual void get_breakpoints(List<int> *p_breakpoints) override;
+ virtual Array get_breakpoints() override;
virtual void goto_line(int p_line, bool p_with_error = false) override;
void goto_line_selection(int p_line, int p_begin, int p_end);
virtual void set_executing_line(int p_line) override;
diff --git a/editor/plugins/texture_3d_editor_plugin.cpp b/editor/plugins/texture_3d_editor_plugin.cpp
new file mode 100644
index 0000000000..ba2eef8484
--- /dev/null
+++ b/editor/plugins/texture_3d_editor_plugin.cpp
@@ -0,0 +1,213 @@
+/*************************************************************************/
+/* texture_3d_editor_plugin.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#include "texture_3d_editor_plugin.h"
+
+#include "core/io/resource_loader.h"
+#include "core/project_settings.h"
+#include "editor/editor_settings.h"
+
+void Texture3DEditor::_gui_input(Ref<InputEvent> p_event) {
+}
+
+void Texture3DEditor::_texture_rect_draw() {
+ texture_rect->draw_rect(Rect2(Point2(), texture_rect->get_size()), Color(1, 1, 1, 1));
+}
+
+void Texture3DEditor::_notification(int p_what) {
+ if (p_what == NOTIFICATION_READY) {
+ //get_scene()->connect("node_removed",this,"_node_removed");
+ }
+ if (p_what == NOTIFICATION_RESIZED) {
+ _texture_rect_update_area();
+ }
+
+ if (p_what == NOTIFICATION_DRAW) {
+ Ref<Texture2D> checkerboard = get_theme_icon("Checkerboard", "EditorIcons");
+ Size2 size = get_size();
+
+ draw_texture_rect(checkerboard, Rect2(Point2(), size), true);
+ }
+}
+
+void Texture3DEditor::_changed_callback(Object *p_changed, const char *p_prop) {
+ if (!is_visible()) {
+ return;
+ }
+ update();
+}
+
+void Texture3DEditor::_update_material() {
+ material->set_shader_param("layer", (layer->get_value() + 0.5) / texture->get_depth());
+ material->set_shader_param("tex", texture->get_rid());
+
+ String format = Image::get_format_name(texture->get_format());
+
+ String text;
+ text = itos(texture->get_width()) + "x" + itos(texture->get_height()) + "x" + itos(texture->get_depth()) + " " + format;
+
+ info->set_text(text);
+}
+
+void Texture3DEditor::_make_shaders() {
+ String shader_3d = ""
+ "shader_type canvas_item;\n"
+ "uniform sampler3D tex;\n"
+ "uniform float layer;\n"
+ "void fragment() {\n"
+ " COLOR = textureLod(tex,vec3(UV,layer),0.0);\n"
+ "}";
+
+ shader.instance();
+ shader->set_code(shader_3d);
+ material.instance();
+ material->set_shader(shader);
+}
+
+void Texture3DEditor::_texture_rect_update_area() {
+ Size2 size = get_size();
+ int tex_width = texture->get_width() * size.height / texture->get_height();
+ int tex_height = size.height;
+
+ if (tex_width > size.width) {
+ tex_width = size.width;
+ tex_height = texture->get_height() * tex_width / texture->get_width();
+ }
+
+ // Prevent the texture from being unpreviewable after the rescale, so that we can still see something
+ if (tex_height <= 0) {
+ tex_height = 1;
+ }
+ if (tex_width <= 0) {
+ tex_width = 1;
+ }
+
+ int ofs_x = (size.width - tex_width) / 2;
+ int ofs_y = (size.height - tex_height) / 2;
+
+ texture_rect->set_position(Vector2(ofs_x, ofs_y));
+ texture_rect->set_size(Vector2(tex_width, tex_height));
+}
+
+void Texture3DEditor::edit(Ref<Texture3D> p_texture) {
+ if (!texture.is_null()) {
+ texture->remove_change_receptor(this);
+ }
+
+ texture = p_texture;
+
+ if (!texture.is_null()) {
+ if (shader.is_null()) {
+ _make_shaders();
+ }
+
+ texture->add_change_receptor(this);
+ update();
+ texture_rect->set_material(material);
+ setting = true;
+ layer->set_max(texture->get_depth() - 1);
+ layer->set_value(0);
+ layer->show();
+ _update_material();
+ setting = false;
+ _texture_rect_update_area();
+ } else {
+ hide();
+ }
+}
+
+void Texture3DEditor::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("_gui_input"), &Texture3DEditor::_gui_input);
+ ClassDB::bind_method(D_METHOD("_layer_changed"), &Texture3DEditor::_layer_changed);
+}
+
+Texture3DEditor::Texture3DEditor() {
+ set_texture_repeat(TextureRepeat::TEXTURE_REPEAT_ENABLED);
+ set_custom_minimum_size(Size2(1, 150));
+ texture_rect = memnew(Control);
+ texture_rect->connect("draw", callable_mp(this, &Texture3DEditor::_texture_rect_draw));
+ texture_rect->set_mouse_filter(MOUSE_FILTER_IGNORE);
+ add_child(texture_rect);
+
+ layer = memnew(SpinBox);
+ layer->set_step(1);
+ layer->set_max(100);
+ add_child(layer);
+ layer->set_anchor(MARGIN_RIGHT, 1);
+ layer->set_anchor(MARGIN_LEFT, 1);
+ layer->set_h_grow_direction(GROW_DIRECTION_BEGIN);
+ layer->set_modulate(Color(1, 1, 1, 0.8));
+ info = memnew(Label);
+ add_child(info);
+ info->set_anchor(MARGIN_RIGHT, 1);
+ info->set_anchor(MARGIN_LEFT, 1);
+ info->set_anchor(MARGIN_BOTTOM, 1);
+ info->set_anchor(MARGIN_TOP, 1);
+ info->set_h_grow_direction(GROW_DIRECTION_BEGIN);
+ info->set_v_grow_direction(GROW_DIRECTION_BEGIN);
+ info->add_theme_color_override("font_color", Color(1, 1, 1, 1));
+ info->add_theme_color_override("font_color_shadow", Color(0, 0, 0, 0.5));
+ info->add_theme_color_override("font_color_shadow", Color(0, 0, 0, 0.5));
+ info->add_theme_constant_override("shadow_as_outline", 1);
+ info->add_theme_constant_override("shadow_offset_x", 2);
+ info->add_theme_constant_override("shadow_offset_y", 2);
+
+ setting = false;
+ layer->connect("value_changed", Callable(this, "_layer_changed"));
+}
+
+Texture3DEditor::~Texture3DEditor() {
+ if (!texture.is_null()) {
+ texture->remove_change_receptor(this);
+ }
+}
+
+//
+bool EditorInspectorPlugin3DTexture::can_handle(Object *p_object) {
+ return Object::cast_to<Texture3D>(p_object) != nullptr;
+}
+
+void EditorInspectorPlugin3DTexture::parse_begin(Object *p_object) {
+ Texture3D *texture = Object::cast_to<Texture3D>(p_object);
+ if (!texture) {
+ return;
+ }
+ Ref<Texture3D> m(texture);
+
+ Texture3DEditor *editor = memnew(Texture3DEditor);
+ editor->edit(m);
+ add_custom_control(editor);
+}
+
+Texture3DEditorPlugin::Texture3DEditorPlugin(EditorNode *p_node) {
+ Ref<EditorInspectorPlugin3DTexture> plugin;
+ plugin.instance();
+ add_inspector_plugin(plugin);
+}
diff --git a/editor/plugins/texture_3d_editor_plugin.h b/editor/plugins/texture_3d_editor_plugin.h
new file mode 100644
index 0000000000..4fbf47ecfe
--- /dev/null
+++ b/editor/plugins/texture_3d_editor_plugin.h
@@ -0,0 +1,93 @@
+/*************************************************************************/
+/* texture_3d_editor_plugin.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#ifndef TEXTURE_3D_EDITOR_PLUGIN_H
+#define TEXTURE_3D_EDITOR_PLUGIN_H
+
+#include "editor/editor_node.h"
+#include "editor/editor_plugin.h"
+#include "scene/resources/shader.h"
+#include "scene/resources/texture.h"
+
+class Texture3DEditor : public Control {
+ GDCLASS(Texture3DEditor, Control);
+
+ SpinBox *layer;
+ Label *info;
+ Ref<Texture3D> texture;
+
+ Ref<Shader> shader;
+ Ref<ShaderMaterial> material;
+
+ Control *texture_rect;
+
+ void _make_shaders();
+
+ void _update_material();
+ bool setting;
+ void _layer_changed(double) {
+ if (!setting) {
+ _update_material();
+ }
+ }
+
+ void _texture_rect_update_area();
+ void _texture_rect_draw();
+
+protected:
+ void _notification(int p_what);
+ void _gui_input(Ref<InputEvent> p_event);
+ void _changed_callback(Object *p_changed, const char *p_prop) override;
+ static void _bind_methods();
+
+public:
+ void edit(Ref<Texture3D> p_texture);
+ Texture3DEditor();
+ ~Texture3DEditor();
+};
+
+class EditorInspectorPlugin3DTexture : public EditorInspectorPlugin {
+ GDCLASS(EditorInspectorPlugin3DTexture, EditorInspectorPlugin);
+
+public:
+ virtual bool can_handle(Object *p_object) override;
+ virtual void parse_begin(Object *p_object) override;
+};
+
+class Texture3DEditorPlugin : public EditorPlugin {
+ GDCLASS(Texture3DEditorPlugin, EditorPlugin);
+
+public:
+ virtual String get_name() const override { return "Texture3D"; }
+
+ Texture3DEditorPlugin(EditorNode *p_node);
+};
+
+#endif // TEXTURE_EDITOR_PLUGIN_H
diff --git a/editor/plugins/texture_region_editor_plugin.cpp b/editor/plugins/texture_region_editor_plugin.cpp
index 762f42abeb..6e722607f7 100644
--- a/editor/plugins/texture_region_editor_plugin.cpp
+++ b/editor/plugins/texture_region_editor_plugin.cpp
@@ -875,7 +875,7 @@ void TextureRegionEditor::_changed_callback(Object *p_changed, const char *p_pro
if (!is_visible()) {
return;
}
- if (p_prop == StringName("atlas") || p_prop == StringName("texture")) {
+ if (p_prop == StringName("atlas") || p_prop == StringName("texture") || p_prop == StringName("region")) {
_edit_region();
}
}
diff --git a/editor/plugins/theme_editor_plugin.cpp b/editor/plugins/theme_editor_plugin.cpp
index 18a107ff75..932ded6938 100644
--- a/editor/plugins/theme_editor_plugin.cpp
+++ b/editor/plugins/theme_editor_plugin.cpp
@@ -206,8 +206,8 @@ void ThemeEditor::_save_template_cbk(String fname) {
file->store_line("; [value] examples:");
file->store_line("; ");
file->store_line("; Type.item = 6 ; numeric constant. ");
- file->store_line("; Type.item = #FF00FF ; HTML color ");
- file->store_line("; Type.item = #55FF00FF ; HTML color with alpha 55.");
+ file->store_line("; Type.item = #FF00FF ; HTML color (magenta).");
+ file->store_line("; Type.item = #FF00FF55 ; HTML color (magenta with alpha 0x55).");
file->store_line("; Type.item = icon(image.png) ; icon in a png file (relative to theme file).");
file->store_line("; Type.item = font(font.xres) ; font in a resource (relative to theme file).");
file->store_line("; Type.item = sbox(stylebox.xres) ; stylebox in a resource (relative to theme file).");
@@ -629,7 +629,7 @@ ThemeEditor::ThemeEditor() {
ScrollContainer *scroll = memnew(ScrollContainer);
add_child(scroll);
scroll->set_enable_v_scroll(true);
- scroll->set_enable_h_scroll(false);
+ scroll->set_enable_h_scroll(true);
scroll->set_v_size_flags(SIZE_EXPAND_FILL);
MarginContainer *root_container = memnew(MarginContainer);
diff --git a/editor/plugins/tile_map_editor_plugin.cpp b/editor/plugins/tile_map_editor_plugin.cpp
index e71485e9fc..8cd8aaf277 100644
--- a/editor/plugins/tile_map_editor_plugin.cpp
+++ b/editor/plugins/tile_map_editor_plugin.cpp
@@ -802,7 +802,6 @@ void TileMapEditor::_draw_cell(Control *p_viewport, int p_cell, const Point2i &p
r.size = node->get_tileset()->autotile_get_size(p_cell);
r.position += (r.size + Vector2(spacing, spacing)) * offset;
}
- Size2 sc = p_xform.get_scale();
Size2 cell_size = node->get_cell_size();
bool centered_texture = node->is_centered_textures_enabled();
bool compatibility_mode_enabled = node->is_compatibility_mode_enabled();
@@ -838,12 +837,12 @@ void TileMapEditor::_draw_cell(Control *p_viewport, int p_cell, const Point2i &p
}
if (p_flip_h) {
- sc.x *= -1.0;
+ rect.size.x *= -1.0;
tile_ofs.x *= -1.0;
}
if (p_flip_v) {
- sc.y *= -1.0;
+ rect.size.y *= -1.0;
tile_ofs.y *= -1.0;
}
diff --git a/editor/plugins/tile_set_editor_plugin.cpp b/editor/plugins/tile_set_editor_plugin.cpp
index 274c64263f..684d8f0f10 100644
--- a/editor/plugins/tile_set_editor_plugin.cpp
+++ b/editor/plugins/tile_set_editor_plugin.cpp
@@ -3109,6 +3109,7 @@ Vector2 TileSetEditor::snap_point(const Vector2 &point) {
anchor += tileset->tile_get_region(get_current_tile()).position;
anchor += WORKSPACE_MARGIN;
Rect2 region(anchor, tile_size);
+ Rect2 tile_region(tileset->tile_get_region(get_current_tile()).position + WORKSPACE_MARGIN, tileset->tile_get_region(get_current_tile()).size);
if (tileset->tile_get_tile_mode(get_current_tile()) == TileSet::SINGLE_TILE) {
region.position = tileset->tile_get_region(get_current_tile()).position + WORKSPACE_MARGIN;
region.size = tileset->tile_get_region(get_current_tile()).size;
@@ -3118,6 +3119,7 @@ Vector2 TileSetEditor::snap_point(const Vector2 &point) {
p.x = Math::snap_scalar_separation(snap_offset.x, snap_step.x, p.x, snap_separation.x);
p.y = Math::snap_scalar_separation(snap_offset.y, snap_step.y, p.y, snap_separation.y);
}
+
if (tools[SHAPE_KEEP_INSIDE_TILE]->is_pressed()) {
if (p.x < region.position.x) {
p.x = region.position.x;
@@ -3132,6 +3134,20 @@ Vector2 TileSetEditor::snap_point(const Vector2 &point) {
p.y = region.position.y + region.size.y;
}
}
+
+ if (p.x < tile_region.position.x) {
+ p.x = tile_region.position.x;
+ }
+ if (p.y < tile_region.position.y) {
+ p.y = tile_region.position.y;
+ }
+ if (p.x > (tile_region.position.x + tile_region.size.x)) {
+ p.x = (tile_region.position.x + tile_region.size.x);
+ }
+ if (p.y > (tile_region.position.y + tile_region.size.y)) {
+ p.y = (tile_region.position.y + tile_region.size.y);
+ }
+
return p;
}
diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp
index 53bd1150ec..c14d07789f 100644
--- a/editor/plugins/visual_shader_editor_plugin.cpp
+++ b/editor/plugins/visual_shader_editor_plugin.cpp
@@ -60,6 +60,572 @@ void VisualShaderNodePlugin::_bind_methods() {
///////////////////
+static Ref<StyleBoxEmpty> make_empty_stylebox(float p_margin_left = -1, float p_margin_top = -1, float p_margin_right = -1, float p_margin_bottom = -1) {
+ Ref<StyleBoxEmpty> style(memnew(StyleBoxEmpty));
+ style->set_default_margin(MARGIN_LEFT, p_margin_left * EDSCALE);
+ style->set_default_margin(MARGIN_RIGHT, p_margin_right * EDSCALE);
+ style->set_default_margin(MARGIN_BOTTOM, p_margin_bottom * EDSCALE);
+ style->set_default_margin(MARGIN_TOP, p_margin_top * EDSCALE);
+ return style;
+}
+
+///////////////////
+
+VisualShaderGraphPlugin::VisualShaderGraphPlugin() {
+}
+
+void VisualShaderGraphPlugin::_bind_methods() {
+ ClassDB::bind_method("add_node", &VisualShaderGraphPlugin::add_node);
+ ClassDB::bind_method("remove_node", &VisualShaderGraphPlugin::remove_node);
+ ClassDB::bind_method("connect_nodes", &VisualShaderGraphPlugin::connect_nodes);
+ ClassDB::bind_method("disconnect_nodes", &VisualShaderGraphPlugin::disconnect_nodes);
+ ClassDB::bind_method("set_node_position", &VisualShaderGraphPlugin::set_node_position);
+ ClassDB::bind_method("set_node_size", &VisualShaderGraphPlugin::set_node_size);
+ ClassDB::bind_method("show_port_preview", &VisualShaderGraphPlugin::show_port_preview);
+ ClassDB::bind_method("update_node", &VisualShaderGraphPlugin::update_node);
+ ClassDB::bind_method("update_node_deferred", &VisualShaderGraphPlugin::update_node_deferred);
+ ClassDB::bind_method("set_input_port_default_value", &VisualShaderGraphPlugin::set_input_port_default_value);
+ ClassDB::bind_method("set_uniform_name", &VisualShaderGraphPlugin::set_uniform_name);
+}
+
+void VisualShaderGraphPlugin::register_shader(VisualShader *p_shader) {
+ visual_shader = Ref<VisualShader>(p_shader);
+}
+
+void VisualShaderGraphPlugin::set_connections(List<VisualShader::Connection> &p_connections) {
+ connections = p_connections;
+}
+
+void VisualShaderGraphPlugin::show_port_preview(VisualShader::Type p_type, int p_node_id, int p_port_id) {
+ if (visual_shader->get_shader_type() == p_type && links.has(p_node_id)) {
+ for (Map<int, Port>::Element *E = links[p_node_id].output_ports.front(); E; E = E->next()) {
+ E->value().preview_button->set_pressed(false);
+ }
+
+ if (links[p_node_id].preview_visible && !is_dirty() && links[p_node_id].preview_box != nullptr) {
+ links[p_node_id].graph_node->remove_child(links[p_node_id].preview_box);
+ memdelete(links[p_node_id].preview_box);
+ links[p_node_id].graph_node->set_size(Vector2(-1, -1));
+ links[p_node_id].preview_visible = false;
+ }
+
+ if (p_port_id != -1) {
+ if (is_dirty()) {
+ links[p_node_id].preview_pos = links[p_node_id].graph_node->get_child_count();
+ }
+
+ VBoxContainer *vbox = memnew(VBoxContainer);
+ links[p_node_id].graph_node->add_child(vbox);
+ if (links[p_node_id].preview_pos != -1) {
+ links[p_node_id].graph_node->move_child(vbox, links[p_node_id].preview_pos);
+ }
+
+ Control *offset = memnew(Control);
+ offset->set_custom_minimum_size(Size2(0, 5 * EDSCALE));
+ vbox->add_child(offset);
+
+ VisualShaderNodePortPreview *port_preview = memnew(VisualShaderNodePortPreview);
+ port_preview->setup(visual_shader, visual_shader->get_shader_type(), p_node_id, p_port_id);
+ port_preview->set_h_size_flags(Control::SIZE_SHRINK_CENTER);
+ vbox->add_child(port_preview);
+ links[p_node_id].preview_visible = true;
+ links[p_node_id].preview_box = vbox;
+ links[p_node_id].output_ports[p_port_id].preview_button->set_pressed(true);
+ }
+ }
+}
+
+void VisualShaderGraphPlugin::update_node_deferred(VisualShader::Type p_type, int p_node_id) {
+ call_deferred("update_node", p_type, p_node_id);
+}
+
+void VisualShaderGraphPlugin::update_node(VisualShader::Type p_type, int p_node_id) {
+ if (p_type != visual_shader->get_shader_type() || !links.has(p_node_id)) {
+ return;
+ }
+ remove_node(p_type, p_node_id);
+ add_node(p_type, p_node_id);
+}
+
+void VisualShaderGraphPlugin::set_input_port_default_value(VisualShader::Type p_type, int p_node_id, int p_port_id, Variant p_value) {
+ if (p_type != visual_shader->get_shader_type() || !links.has(p_node_id)) {
+ return;
+ }
+
+ Button *button = links[p_node_id].input_ports[p_port_id].default_input_button;
+
+ switch (p_value.get_type()) {
+ case Variant::COLOR: {
+ button->set_custom_minimum_size(Size2(30, 0) * EDSCALE);
+ if (!button->is_connected("draw", callable_mp(VisualShaderEditor::get_singleton(), &VisualShaderEditor::_draw_color_over_button))) {
+ button->connect("draw", callable_mp(VisualShaderEditor::get_singleton(), &VisualShaderEditor::_draw_color_over_button), varray(button, p_value));
+ }
+ } break;
+ case Variant::BOOL: {
+ button->set_text(((bool)p_value) ? "true" : "false");
+ } break;
+ case Variant::INT:
+ case Variant::FLOAT: {
+ button->set_text(String::num(p_value, 4));
+ } break;
+ case Variant::VECTOR3: {
+ Vector3 v = p_value;
+ button->set_text(String::num(v.x, 3) + "," + String::num(v.y, 3) + "," + String::num(v.z, 3));
+ } break;
+ default: {
+ }
+ }
+}
+
+void VisualShaderGraphPlugin::set_uniform_name(VisualShader::Type p_type, int p_node_id, const String &p_name) {
+ if (visual_shader->get_shader_type() == p_type && links.has(p_node_id) && links[p_node_id].uniform_name != nullptr) {
+ links[p_node_id].uniform_name->set_text(p_name);
+ }
+}
+
+void VisualShaderGraphPlugin::register_default_input_button(int p_node_id, int p_port_id, Button *p_button) {
+ links[p_node_id].input_ports.insert(p_port_id, { p_button });
+}
+
+void VisualShaderGraphPlugin::update_uniform_refs() {
+ for (Map<int, Link>::Element *E = links.front(); E; E = E->next()) {
+ VisualShaderNodeUniformRef *ref = Object::cast_to<VisualShaderNodeUniformRef>(E->get().visual_node);
+ if (ref) {
+ remove_node(E->get().type, E->key());
+ add_node(E->get().type, E->key());
+ }
+ }
+}
+
+VisualShader::Type VisualShaderGraphPlugin::get_shader_type() const {
+ return visual_shader->get_shader_type();
+}
+
+void VisualShaderGraphPlugin::set_node_position(VisualShader::Type p_type, int p_id, const Vector2 &p_position) {
+ if (visual_shader->get_shader_type() == p_type && links.has(p_id)) {
+ links[p_id].graph_node->set_offset(p_position);
+ }
+}
+
+void VisualShaderGraphPlugin::set_node_size(VisualShader::Type p_type, int p_id, const Vector2 &p_size) {
+ if (visual_shader->get_shader_type() == p_type && links.has(p_id)) {
+ links[p_id].graph_node->set_size(p_size);
+ }
+}
+
+bool VisualShaderGraphPlugin::is_preview_visible(int p_id) const {
+ return links[p_id].preview_visible;
+}
+
+void VisualShaderGraphPlugin::clear_links() {
+ links.clear();
+}
+
+bool VisualShaderGraphPlugin::is_dirty() const {
+ return dirty;
+}
+
+void VisualShaderGraphPlugin::make_dirty(bool p_enabled) {
+ dirty = p_enabled;
+}
+
+void VisualShaderGraphPlugin::register_link(VisualShader::Type p_type, int p_id, VisualShaderNode *p_visual_node, GraphNode *p_graph_node) {
+ links.insert(p_id, { p_type, p_visual_node, p_graph_node, p_visual_node->get_output_port_for_preview() != -1, -1, Map<int, InputPort>(), Map<int, Port>(), nullptr, nullptr });
+}
+
+void VisualShaderGraphPlugin::register_output_port(int p_node_id, int p_port, TextureButton *p_button) {
+ links[p_node_id].output_ports.insert(p_port, { p_button });
+}
+
+void VisualShaderGraphPlugin::register_uniform_name(int p_node_id, LineEdit *p_uniform_name) {
+ links[p_node_id].uniform_name = p_uniform_name;
+}
+
+void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) {
+ if (p_type != visual_shader->get_shader_type()) {
+ return;
+ }
+
+ Control *offset;
+
+ static Ref<StyleBoxEmpty> label_style = make_empty_stylebox(2, 1, 2, 1);
+
+ static const Color type_color[6] = {
+ Color(0.38, 0.85, 0.96), // scalar (float)
+ Color(0.49, 0.78, 0.94), // scalar (int)
+ Color(0.84, 0.49, 0.93), // vector
+ Color(0.55, 0.65, 0.94), // boolean
+ Color(0.96, 0.66, 0.43), // transform
+ Color(1.0, 1.0, 0.0), // sampler
+ };
+
+ Ref<VisualShaderNode> vsnode = visual_shader->get_node(p_type, p_id);
+
+ Ref<VisualShaderNodeGroupBase> group_node = Object::cast_to<VisualShaderNodeGroupBase>(vsnode.ptr());
+ bool is_group = !group_node.is_null();
+ Size2 size = Size2(0, 0);
+
+ Ref<VisualShaderNodeExpression> expression_node = Object::cast_to<VisualShaderNodeExpression>(group_node.ptr());
+ bool is_expression = !expression_node.is_null();
+ String expression = "";
+
+ GraphNode *node = memnew(GraphNode);
+ register_link(p_type, p_id, vsnode.ptr(), node);
+
+ if (is_group) {
+ size = group_node->get_size();
+
+ node->set_resizable(true);
+ node->connect("resize_request", callable_mp(VisualShaderEditor::get_singleton(), &VisualShaderEditor::_node_resized), varray((int)p_type, p_id));
+ }
+ if (is_expression) {
+ expression = expression_node->get_expression();
+ }
+
+ node->set_offset(visual_shader->get_node_position(p_type, p_id));
+ node->set_title(vsnode->get_caption());
+ node->set_name(itos(p_id));
+
+ if (p_id >= 2) {
+ node->set_show_close_button(true);
+ node->connect("close_request", callable_mp(VisualShaderEditor::get_singleton(), &VisualShaderEditor::_delete_request), varray(p_id), CONNECT_DEFERRED);
+ }
+
+ node->connect("dragged", callable_mp(VisualShaderEditor::get_singleton(), &VisualShaderEditor::_node_dragged), varray(p_id));
+
+ Control *custom_editor = nullptr;
+ int port_offset = 0;
+
+ if (is_group) {
+ port_offset += 2;
+ }
+
+ Ref<VisualShaderNodeUniform> uniform = vsnode;
+ if (uniform.is_valid()) {
+ VisualShaderEditor::get_singleton()->graph->add_child(node);
+ VisualShaderEditor::get_singleton()->_update_created_node(node);
+
+ LineEdit *uniform_name = memnew(LineEdit);
+ register_uniform_name(p_id, uniform_name);
+ uniform_name->set_text(uniform->get_uniform_name());
+ node->add_child(uniform_name);
+ uniform_name->connect("text_entered", callable_mp(VisualShaderEditor::get_singleton(), &VisualShaderEditor::_uniform_line_edit_changed), varray(p_id));
+ uniform_name->connect("focus_exited", callable_mp(VisualShaderEditor::get_singleton(), &VisualShaderEditor::_uniform_line_edit_focus_out), varray(uniform_name, p_id));
+
+ if (vsnode->get_input_port_count() == 0 && vsnode->get_output_port_count() == 1 && vsnode->get_output_port_name(0) == "") {
+ //shortcut
+ VisualShaderNode::PortType port_right = vsnode->get_output_port_type(0);
+ node->set_slot(0, false, VisualShaderNode::PORT_TYPE_SCALAR, Color(), true, port_right, type_color[port_right]);
+ if (!vsnode->is_use_prop_slots()) {
+ return;
+ }
+ }
+ port_offset++;
+ }
+
+ for (int i = 0; i < VisualShaderEditor::get_singleton()->plugins.size(); i++) {
+ vsnode->set_meta("id", p_id);
+ vsnode->set_meta("shader_type", (int)p_type);
+ custom_editor = VisualShaderEditor::get_singleton()->plugins.write[i]->create_editor(visual_shader, vsnode);
+ vsnode->remove_meta("id");
+ vsnode->remove_meta("shader_type");
+ if (custom_editor) {
+ if (vsnode->is_show_prop_names()) {
+ custom_editor->call_deferred("_show_prop_names", true);
+ }
+ break;
+ }
+ }
+
+ if (custom_editor && !vsnode->is_use_prop_slots() && vsnode->get_output_port_count() > 0 && vsnode->get_output_port_name(0) == "" && (vsnode->get_input_port_count() == 0 || vsnode->get_input_port_name(0) == "")) {
+ //will be embedded in first port
+ } else if (custom_editor) {
+ port_offset++;
+ node->add_child(custom_editor);
+ if (vsnode->is_use_prop_slots()) {
+ return;
+ }
+ custom_editor = nullptr;
+ }
+
+ if (is_group) {
+ offset = memnew(Control);
+ offset->set_custom_minimum_size(Size2(0, 6 * EDSCALE));
+ node->add_child(offset);
+
+ if (group_node->is_editable()) {
+ HBoxContainer *hb2 = memnew(HBoxContainer);
+
+ Button *add_input_btn = memnew(Button);
+ add_input_btn->set_text(TTR("Add Input"));
+ add_input_btn->connect("pressed", callable_mp(VisualShaderEditor::get_singleton(), &VisualShaderEditor::_add_input_port), varray(p_id, group_node->get_free_input_port_id(), VisualShaderNode::PORT_TYPE_VECTOR, "input" + itos(group_node->get_free_input_port_id())), CONNECT_DEFERRED);
+ hb2->add_child(add_input_btn);
+
+ hb2->add_spacer();
+
+ Button *add_output_btn = memnew(Button);
+ add_output_btn->set_text(TTR("Add Output"));
+ add_output_btn->connect("pressed", callable_mp(VisualShaderEditor::get_singleton(), &VisualShaderEditor::_add_output_port), varray(p_id, group_node->get_free_output_port_id(), VisualShaderNode::PORT_TYPE_VECTOR, "output" + itos(group_node->get_free_output_port_id())), CONNECT_DEFERRED);
+ hb2->add_child(add_output_btn);
+
+ node->add_child(hb2);
+ }
+ }
+
+ for (int i = 0; i < MAX(vsnode->get_input_port_count(), vsnode->get_output_port_count()); i++) {
+ if (vsnode->is_port_separator(i)) {
+ node->add_child(memnew(HSeparator));
+ port_offset++;
+ }
+
+ bool valid_left = i < vsnode->get_input_port_count();
+ VisualShaderNode::PortType port_left = VisualShaderNode::PORT_TYPE_SCALAR;
+ bool port_left_used = false;
+ String name_left;
+ if (valid_left) {
+ name_left = vsnode->get_input_port_name(i);
+ port_left = vsnode->get_input_port_type(i);
+ for (List<VisualShader::Connection>::Element *E = connections.front(); E; E = E->next()) {
+ if (E->get().to_node == p_id && E->get().to_port == i) {
+ port_left_used = true;
+ }
+ }
+ }
+
+ bool valid_right = i < vsnode->get_output_port_count();
+ VisualShaderNode::PortType port_right = VisualShaderNode::PORT_TYPE_SCALAR;
+ String name_right;
+ if (valid_right) {
+ name_right = vsnode->get_output_port_name(i);
+ port_right = vsnode->get_output_port_type(i);
+ }
+
+ HBoxContainer *hb = memnew(HBoxContainer);
+ hb->add_theme_constant_override("separation", 7 * EDSCALE);
+
+ Variant default_value;
+
+ if (valid_left && !port_left_used) {
+ default_value = vsnode->get_input_port_default_value(i);
+ }
+
+ Button *button = memnew(Button);
+ hb->add_child(button);
+ register_default_input_button(p_id, i, button);
+ button->connect("pressed", callable_mp(VisualShaderEditor::get_singleton(), &VisualShaderEditor::_edit_port_default_input), varray(button, p_id, i));
+ if (default_value.get_type() != Variant::NIL) { // only a label
+ set_input_port_default_value(p_type, p_id, i, default_value);
+ } else {
+ button->hide();
+ }
+
+ if (i == 0 && custom_editor) {
+ hb->add_child(custom_editor);
+ custom_editor->set_h_size_flags(Control::SIZE_EXPAND_FILL);
+ } else {
+ if (valid_left) {
+ if (is_group) {
+ OptionButton *type_box = memnew(OptionButton);
+ hb->add_child(type_box);
+ type_box->add_item(TTR("Float"));
+ type_box->add_item(TTR("Int"));
+ type_box->add_item(TTR("Vector"));
+ type_box->add_item(TTR("Boolean"));
+ type_box->add_item(TTR("Transform"));
+ type_box->add_item(TTR("Sampler"));
+ type_box->select(group_node->get_input_port_type(i));
+ type_box->set_custom_minimum_size(Size2(100 * EDSCALE, 0));
+ type_box->connect("item_selected", callable_mp(VisualShaderEditor::get_singleton(), &VisualShaderEditor::_change_input_port_type), varray(p_id, i), CONNECT_DEFERRED);
+
+ LineEdit *name_box = memnew(LineEdit);
+ hb->add_child(name_box);
+ name_box->set_custom_minimum_size(Size2(65 * EDSCALE, 0));
+ name_box->set_h_size_flags(Control::SIZE_EXPAND_FILL);
+ name_box->set_text(name_left);
+ name_box->connect("text_entered", callable_mp(VisualShaderEditor::get_singleton(), &VisualShaderEditor::_change_input_port_name), varray(name_box, p_id, i));
+ name_box->connect("focus_exited", callable_mp(VisualShaderEditor::get_singleton(), &VisualShaderEditor::_port_name_focus_out), varray(name_box, p_id, i, false));
+
+ Button *remove_btn = memnew(Button);
+ remove_btn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Remove", "EditorIcons"));
+ remove_btn->set_tooltip(TTR("Remove") + " " + name_left);
+ remove_btn->connect("pressed", callable_mp(VisualShaderEditor::get_singleton(), &VisualShaderEditor::_remove_input_port), varray(p_id, i), CONNECT_DEFERRED);
+ hb->add_child(remove_btn);
+ } else {
+ Label *label = memnew(Label);
+ label->set_text(name_left);
+ label->add_theme_style_override("normal", label_style); //more compact
+ hb->add_child(label);
+
+ if (vsnode->get_input_port_default_hint(i) != "" && !port_left_used) {
+ Label *hint_label = memnew(Label);
+ hint_label->set_text("[" + vsnode->get_input_port_default_hint(i) + "]");
+ hint_label->add_theme_color_override("font_color", VisualShaderEditor::get_singleton()->get_theme_color("font_color_readonly", "TextEdit"));
+ hint_label->add_theme_style_override("normal", label_style);
+ hb->add_child(hint_label);
+ }
+ }
+ }
+
+ if (!is_group) {
+ hb->add_spacer();
+ }
+
+ if (valid_right) {
+ if (is_group) {
+ Button *remove_btn = memnew(Button);
+ remove_btn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Remove", "EditorIcons"));
+ remove_btn->set_tooltip(TTR("Remove") + " " + name_left);
+ remove_btn->connect("pressed", callable_mp(VisualShaderEditor::get_singleton(), &VisualShaderEditor::_remove_output_port), varray(p_id, i), CONNECT_DEFERRED);
+ hb->add_child(remove_btn);
+
+ LineEdit *name_box = memnew(LineEdit);
+ hb->add_child(name_box);
+ name_box->set_custom_minimum_size(Size2(65 * EDSCALE, 0));
+ name_box->set_h_size_flags(Control::SIZE_EXPAND_FILL);
+ name_box->set_text(name_right);
+ name_box->connect("text_entered", callable_mp(VisualShaderEditor::get_singleton(), &VisualShaderEditor::_change_output_port_name), varray(name_box, p_id, i));
+ name_box->connect("focus_exited", callable_mp(VisualShaderEditor::get_singleton(), &VisualShaderEditor::_port_name_focus_out), varray(name_box, p_id, i, true));
+
+ OptionButton *type_box = memnew(OptionButton);
+ hb->add_child(type_box);
+ type_box->add_item(TTR("Float"));
+ type_box->add_item(TTR("Int"));
+ type_box->add_item(TTR("Vector"));
+ type_box->add_item(TTR("Boolean"));
+ type_box->add_item(TTR("Transform"));
+ type_box->select(group_node->get_output_port_type(i));
+ type_box->set_custom_minimum_size(Size2(100 * EDSCALE, 0));
+ type_box->connect("item_selected", callable_mp(VisualShaderEditor::get_singleton(), &VisualShaderEditor::_change_output_port_type), varray(p_id, i), CONNECT_DEFERRED);
+ } else {
+ Label *label = memnew(Label);
+ label->set_text(name_right);
+ label->add_theme_style_override("normal", label_style); //more compact
+ hb->add_child(label);
+ }
+ }
+ }
+
+ if (valid_right && visual_shader->get_shader_type() == VisualShader::TYPE_FRAGMENT && port_right != VisualShaderNode::PORT_TYPE_TRANSFORM && port_right != VisualShaderNode::PORT_TYPE_SAMPLER) {
+ TextureButton *preview = memnew(TextureButton);
+ preview->set_toggle_mode(true);
+ preview->set_normal_texture(VisualShaderEditor::get_singleton()->get_theme_icon("GuiVisibilityHidden", "EditorIcons"));
+ preview->set_pressed_texture(VisualShaderEditor::get_singleton()->get_theme_icon("GuiVisibilityVisible", "EditorIcons"));
+ preview->set_v_size_flags(Control::SIZE_SHRINK_CENTER);
+
+ register_output_port(p_id, i, preview);
+
+ preview->connect("pressed", callable_mp(VisualShaderEditor::get_singleton(), &VisualShaderEditor::_preview_select_port), varray(p_id, i), CONNECT_DEFERRED);
+ hb->add_child(preview);
+ }
+
+ if (is_group) {
+ offset = memnew(Control);
+ offset->set_custom_minimum_size(Size2(0, 5 * EDSCALE));
+ node->add_child(offset);
+ port_offset++;
+ }
+
+ node->add_child(hb);
+
+ node->set_slot(i + port_offset, valid_left, port_left, type_color[port_left], valid_right, port_right, type_color[port_right]);
+ }
+
+ if (vsnode->get_output_port_for_preview() >= 0) {
+ show_port_preview(p_type, p_id, vsnode->get_output_port_for_preview());
+ }
+
+ offset = memnew(Control);
+ offset->set_custom_minimum_size(Size2(0, 4 * EDSCALE));
+ node->add_child(offset);
+
+ String error = vsnode->get_warning(visual_shader->get_mode(), p_type);
+ if (error != String()) {
+ Label *error_label = memnew(Label);
+ error_label->add_theme_color_override("font_color", VisualShaderEditor::get_singleton()->get_theme_color("error_color", "Editor"));
+ error_label->set_text(error);
+ node->add_child(error_label);
+ }
+
+ if (is_expression) {
+ CodeEdit *expression_box = memnew(CodeEdit);
+ Ref<CodeHighlighter> expression_syntax_highlighter;
+ expression_syntax_highlighter.instance();
+ expression_node->set_control(expression_box, 0);
+ node->add_child(expression_box);
+
+ Color background_color = EDITOR_GET("text_editor/highlighting/background_color");
+ Color text_color = EDITOR_GET("text_editor/highlighting/text_color");
+ Color keyword_color = EDITOR_GET("text_editor/highlighting/keyword_color");
+ Color comment_color = EDITOR_GET("text_editor/highlighting/comment_color");
+ Color symbol_color = EDITOR_GET("text_editor/highlighting/symbol_color");
+ Color function_color = EDITOR_GET("text_editor/highlighting/function_color");
+ Color number_color = EDITOR_GET("text_editor/highlighting/number_color");
+ Color members_color = EDITOR_GET("text_editor/highlighting/member_variable_color");
+
+ expression_box->set_syntax_highlighter(expression_syntax_highlighter);
+ expression_box->add_theme_color_override("background_color", background_color);
+
+ for (List<String>::Element *E = VisualShaderEditor::get_singleton()->keyword_list.front(); E; E = E->next()) {
+ expression_syntax_highlighter->add_keyword_color(E->get(), keyword_color);
+ }
+
+ expression_box->add_theme_font_override("font", VisualShaderEditor::get_singleton()->get_theme_font("expression", "EditorFonts"));
+ expression_box->add_theme_color_override("font_color", text_color);
+ expression_syntax_highlighter->set_number_color(number_color);
+ expression_syntax_highlighter->set_symbol_color(symbol_color);
+ expression_syntax_highlighter->set_function_color(function_color);
+ expression_syntax_highlighter->set_member_variable_color(members_color);
+ expression_syntax_highlighter->add_color_region("/*", "*/", comment_color, false);
+ expression_syntax_highlighter->add_color_region("//", "", comment_color, true);
+
+ expression_box->set_text(expression);
+ expression_box->set_context_menu_enabled(false);
+ expression_box->set_draw_line_numbers(true);
+
+ expression_box->connect("focus_exited", callable_mp(VisualShaderEditor::get_singleton(), &VisualShaderEditor::_expression_focus_out), varray(expression_box, p_id));
+ }
+
+ if (!uniform.is_valid()) {
+ VisualShaderEditor::get_singleton()->graph->add_child(node);
+ VisualShaderEditor::get_singleton()->_update_created_node(node);
+ if (is_group) {
+ VisualShaderEditor::get_singleton()->call_deferred("_set_node_size", (int)p_type, p_id, size);
+ }
+ }
+}
+
+void VisualShaderGraphPlugin::remove_node(VisualShader::Type p_type, int p_id) {
+ if (visual_shader->get_shader_type() == p_type && links.has(p_id)) {
+ links[p_id].graph_node->get_parent()->remove_child(links[p_id].graph_node);
+ memdelete(links[p_id].graph_node);
+ links.erase(p_id);
+ }
+}
+
+void VisualShaderGraphPlugin::connect_nodes(VisualShader::Type p_type, int p_from_node, int p_from_port, int p_to_node, int p_to_port) {
+ if (visual_shader->get_shader_type() == p_type) {
+ VisualShaderEditor::get_singleton()->graph->connect_node(itos(p_from_node), p_from_port, itos(p_to_node), p_to_port);
+ if (links[p_to_node].input_ports.has(p_to_port) && links[p_to_node].input_ports[p_to_port].default_input_button != nullptr) {
+ links[p_to_node].input_ports[p_to_port].default_input_button->hide();
+ }
+ }
+}
+
+void VisualShaderGraphPlugin::disconnect_nodes(VisualShader::Type p_type, int p_from_node, int p_from_port, int p_to_node, int p_to_port) {
+ if (visual_shader->get_shader_type() == p_type) {
+ VisualShaderEditor::get_singleton()->graph->disconnect_node(itos(p_from_node), p_from_port, itos(p_to_node), p_to_port);
+ if (links[p_to_node].input_ports.has(p_to_port) && links[p_to_node].input_ports[p_to_port].default_input_button != nullptr && links[p_to_node].visual_node->get_input_port_default_value(p_to_port).get_type() != Variant::NIL) {
+ links[p_to_node].input_ports[p_to_port].default_input_button->show();
+ set_input_port_default_value(p_type, p_to_node, p_to_port, links[p_to_node].visual_node->get_input_port_default_value(p_to_port));
+ }
+ }
+}
+
+VisualShaderGraphPlugin::~VisualShaderGraphPlugin() {
+}
+
+/////////////////
+
void VisualShaderEditor::edit(VisualShader *p_visual_shader) {
bool changed = false;
if (p_visual_shader) {
@@ -71,6 +637,7 @@ void VisualShaderEditor::edit(VisualShader *p_visual_shader) {
}
}
visual_shader = Ref<VisualShader>(p_visual_shader);
+ graph_plugin->register_shader(visual_shader.ptr());
if (!visual_shader->is_connected("changed", callable_mp(this, &VisualShaderEditor::_update_preview))) {
visual_shader->connect("changed", callable_mp(this, &VisualShaderEditor::_update_preview));
}
@@ -81,6 +648,7 @@ void VisualShaderEditor::edit(VisualShader *p_visual_shader) {
}
#endif
visual_shader->set_graph_offset(graph->get_scroll_ofs() / EDSCALE);
+ _set_mode(visual_shader->get_mode());
} else {
if (visual_shader.is_valid()) {
if (visual_shader->is_connected("changed", callable_mp(this, &VisualShaderEditor::_update_preview))) {
@@ -97,8 +665,8 @@ void VisualShaderEditor::edit(VisualShader *p_visual_shader) {
_clear_buffer();
_update_options_menu();
_update_preview();
+ _update_graph();
}
- _update_graph();
}
}
@@ -168,34 +736,18 @@ bool VisualShaderEditor::_is_available(int p_mode) {
if (p_mode != -1) {
switch (current_mode) {
- case VisualShader::TYPE_VERTEX:
+ case 0: // Vertex or Emit
current_mode = 1;
break;
- case VisualShader::TYPE_FRAGMENT:
+ case 1: // Fragment or Process
current_mode = 2;
break;
- case VisualShader::TYPE_LIGHT:
+ case 2: // Light or End
current_mode = 4;
break;
default:
break;
}
-
- int temp_mode = 0;
-
- if (p_mode & VisualShader::TYPE_FRAGMENT) {
- temp_mode |= 2;
- }
-
- if (p_mode & VisualShader::TYPE_LIGHT) {
- temp_mode |= 4;
- }
-
- if (temp_mode == 0) {
- temp_mode |= 1;
- }
-
- p_mode = temp_mode;
}
return (p_mode == -1 || (p_mode & current_mode) != 0);
@@ -404,6 +956,21 @@ void VisualShaderEditor::_update_options_menu() {
}
}
+void VisualShaderEditor::_set_mode(int p_which) {
+ if (p_which == VisualShader::MODE_PARTICLES) {
+ edit_type_standart->set_visible(false);
+ edit_type_particles->set_visible(true);
+ edit_type = edit_type_particles;
+ particles_mode = true;
+ } else {
+ edit_type_particles->set_visible(false);
+ edit_type_standart->set_visible(true);
+ edit_type = edit_type_standart;
+ particles_mode = false;
+ }
+ visual_shader->set_shader_type(get_current_shader_type());
+}
+
Size2 VisualShaderEditor::get_minimum_size() const {
return Size2(10, 200);
}
@@ -418,15 +985,6 @@ void VisualShaderEditor::_draw_color_over_button(Object *obj, Color p_color) {
button->draw_rect(Rect2(normal->get_offset(), button->get_size() - normal->get_minimum_size()), p_color);
}
-static Ref<StyleBoxEmpty> make_empty_stylebox(float p_margin_left = -1, float p_margin_top = -1, float p_margin_right = -1, float p_margin_bottom = -1) {
- Ref<StyleBoxEmpty> style(memnew(StyleBoxEmpty));
- style->set_default_margin(MARGIN_LEFT, p_margin_left * EDSCALE);
- style->set_default_margin(MARGIN_RIGHT, p_margin_right * EDSCALE);
- style->set_default_margin(MARGIN_BOTTOM, p_margin_bottom * EDSCALE);
- style->set_default_margin(MARGIN_TOP, p_margin_top * EDSCALE);
- return style;
-}
-
void VisualShaderEditor::_update_created_node(GraphNode *node) {
if (EditorSettings::get_singleton()->get("interface/theme/use_graph_node_headers")) {
Ref<StyleBoxFlat> sb = node->get_theme_stylebox("frame", "GraphNode");
@@ -450,49 +1008,9 @@ void VisualShaderEditor::_update_created_node(GraphNode *node) {
}
}
-void VisualShaderEditor::_update_graph() {
- if (updating) {
- return;
- }
-
- if (visual_shader.is_null()) {
- return;
- }
-
- graph->set_scroll_ofs(visual_shader->get_graph_offset() * EDSCALE);
-
- VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
- graph->clear_connections();
- //erase all nodes
- for (int i = 0; i < graph->get_child_count(); i++) {
- if (Object::cast_to<GraphNode>(graph->get_child(i))) {
- Node *node = graph->get_child(i);
- graph->remove_child(node);
- memdelete(node);
- i--;
- }
- }
-
- static const Color type_color[6] = {
- Color(0.38, 0.85, 0.96), // scalar (float)
- Color(0.49, 0.78, 0.94), // scalar (int)
- Color(0.84, 0.49, 0.93), // vector
- Color(0.55, 0.65, 0.94), // boolean
- Color(0.96, 0.66, 0.43), // transform
- Color(1.0, 1.0, 0.0), // sampler
- };
-
- List<VisualShader::Connection> connections;
- visual_shader->get_node_connections(type, &connections);
-
- Ref<StyleBoxEmpty> label_style = make_empty_stylebox(2, 1, 2, 1);
-
- Vector<int> nodes = visual_shader->get_node_list(type);
-
+void VisualShaderEditor::_update_uniforms(bool p_update_refs) {
VisualShaderNodeUniformRef::clear_uniforms();
- // scan for all uniforms
-
for (int t = 0; t < VisualShader::TYPE_MAX; t++) {
Vector<int> tnodes = visual_shader->get_node_list((VisualShader::Type)t);
for (int i = 0; i < tnodes.size(); i++) {
@@ -527,388 +1045,73 @@ void VisualShaderEditor::_update_graph() {
}
}
}
+ if (p_update_refs) {
+ graph_plugin->update_uniform_refs();
+ }
+}
- Control *offset;
-
- for (int n_i = 0; n_i < nodes.size(); n_i++) {
- Vector2 position = visual_shader->get_node_position(type, nodes[n_i]);
- Ref<VisualShaderNode> vsnode = visual_shader->get_node(type, nodes[n_i]);
-
- Ref<VisualShaderNodeGroupBase> group_node = Object::cast_to<VisualShaderNodeGroupBase>(vsnode.ptr());
- bool is_group = !group_node.is_null();
- Size2 size = Size2(0, 0);
-
- Ref<VisualShaderNodeExpression> expression_node = Object::cast_to<VisualShaderNodeExpression>(group_node.ptr());
- bool is_expression = !expression_node.is_null();
- String expression = "";
-
- GraphNode *node = memnew(GraphNode);
-
- if (is_group) {
- size = group_node->get_size();
-
- node->set_resizable(true);
- node->connect("resize_request", callable_mp(this, &VisualShaderEditor::_node_resized), varray((int)type, nodes[n_i]));
- }
- if (is_expression) {
- expression = expression_node->get_expression();
- }
-
- node->set_offset(position);
-
- node->set_title(vsnode->get_caption());
- node->set_name(itos(nodes[n_i]));
-
- if (nodes[n_i] >= 2) {
- node->set_show_close_button(true);
- node->connect("close_request", callable_mp(this, &VisualShaderEditor::_delete_request), varray(nodes[n_i]), CONNECT_DEFERRED);
- }
-
- node->connect("dragged", callable_mp(this, &VisualShaderEditor::_node_dragged), varray(nodes[n_i]));
-
- Control *custom_editor = nullptr;
- int port_offset = 0;
-
- if (is_group) {
- port_offset += 2;
- }
-
- Ref<VisualShaderNodeUniform> uniform = vsnode;
- Ref<VisualShaderNodeFloatUniform> float_uniform = vsnode;
- Ref<VisualShaderNodeIntUniform> int_uniform = vsnode;
- Ref<VisualShaderNodeVec3Uniform> vec3_uniform = vsnode;
- Ref<VisualShaderNodeColorUniform> color_uniform = vsnode;
- Ref<VisualShaderNodeBooleanUniform> bool_uniform = vsnode;
- Ref<VisualShaderNodeTransformUniform> transform_uniform = vsnode;
- if (uniform.is_valid()) {
- graph->add_child(node);
- _update_created_node(node);
-
- LineEdit *uniform_name = memnew(LineEdit);
- uniform_name->set_text(uniform->get_uniform_name());
- node->add_child(uniform_name);
- uniform_name->connect("text_entered", callable_mp(this, &VisualShaderEditor::_line_edit_changed), varray(uniform_name, nodes[n_i]));
- uniform_name->connect("focus_exited", callable_mp(this, &VisualShaderEditor::_line_edit_focus_out), varray(uniform_name, nodes[n_i]));
-
- String error = vsnode->get_warning(visual_shader->get_mode(), type);
- if (error != String()) {
- offset = memnew(Control);
- offset->set_custom_minimum_size(Size2(0, 4 * EDSCALE));
- node->add_child(offset);
- Label *error_label = memnew(Label);
- error_label->add_theme_color_override("font_color", get_theme_color("error_color", "Editor"));
- error_label->set_text(error);
- node->add_child(error_label);
- }
-
- if (vsnode->get_input_port_count() == 0 && vsnode->get_output_port_count() == 1 && vsnode->get_output_port_name(0) == "") {
- //shortcut
- VisualShaderNode::PortType port_right = vsnode->get_output_port_type(0);
- node->set_slot(0, false, VisualShaderNode::PORT_TYPE_SCALAR, Color(), true, port_right, type_color[port_right]);
- if (!float_uniform.is_valid() && !int_uniform.is_valid() && !vec3_uniform.is_valid() && !color_uniform.is_valid() && !bool_uniform.is_valid() && !transform_uniform.is_valid()) {
- continue;
- }
- }
- port_offset++;
- }
-
- for (int i = 0; i < plugins.size(); i++) {
- custom_editor = plugins.write[i]->create_editor(visual_shader, vsnode);
- if (custom_editor) {
- break;
- }
- }
-
- if (custom_editor && !float_uniform.is_valid() && !int_uniform.is_valid() && !vec3_uniform.is_valid() && !bool_uniform.is_valid() && !transform_uniform.is_valid() && vsnode->get_output_port_count() > 0 && vsnode->get_output_port_name(0) == "" && (vsnode->get_input_port_count() == 0 || vsnode->get_input_port_name(0) == "")) {
- //will be embedded in first port
- } else if (custom_editor) {
- port_offset++;
- node->add_child(custom_editor);
- if (color_uniform.is_valid()) {
- custom_editor->call_deferred("_show_prop_names", true);
- }
- if (float_uniform.is_valid() || int_uniform.is_valid() || vec3_uniform.is_valid() || bool_uniform.is_valid() || transform_uniform.is_valid()) {
- custom_editor->call_deferred("_show_prop_names", true);
- continue;
- }
- custom_editor = nullptr;
- }
-
- if (is_group) {
- offset = memnew(Control);
- offset->set_custom_minimum_size(Size2(0, 6 * EDSCALE));
- node->add_child(offset);
-
- if (group_node->is_editable()) {
- HBoxContainer *hb2 = memnew(HBoxContainer);
-
- Button *add_input_btn = memnew(Button);
- add_input_btn->set_text(TTR("Add Input"));
- add_input_btn->connect("pressed", callable_mp(this, &VisualShaderEditor::_add_input_port), varray(nodes[n_i], group_node->get_free_input_port_id(), VisualShaderNode::PORT_TYPE_VECTOR, "input" + itos(group_node->get_free_input_port_id())), CONNECT_DEFERRED);
- hb2->add_child(add_input_btn);
-
- hb2->add_spacer();
-
- Button *add_output_btn = memnew(Button);
- add_output_btn->set_text(TTR("Add Output"));
- add_output_btn->connect("pressed", callable_mp(this, &VisualShaderEditor::_add_output_port), varray(nodes[n_i], group_node->get_free_output_port_id(), VisualShaderNode::PORT_TYPE_VECTOR, "output" + itos(group_node->get_free_output_port_id())), CONNECT_DEFERRED);
- hb2->add_child(add_output_btn);
-
- node->add_child(hb2);
- }
- }
-
- for (int i = 0; i < MAX(vsnode->get_input_port_count(), vsnode->get_output_port_count()); i++) {
- if (vsnode->is_port_separator(i)) {
- node->add_child(memnew(HSeparator));
- port_offset++;
- }
-
- bool valid_left = i < vsnode->get_input_port_count();
- VisualShaderNode::PortType port_left = VisualShaderNode::PORT_TYPE_SCALAR;
- bool port_left_used = false;
- String name_left;
- if (valid_left) {
- name_left = vsnode->get_input_port_name(i);
- port_left = vsnode->get_input_port_type(i);
- for (List<VisualShader::Connection>::Element *E = connections.front(); E; E = E->next()) {
- if (E->get().to_node == nodes[n_i] && E->get().to_port == i) {
- port_left_used = true;
- }
- }
- }
-
- bool valid_right = i < vsnode->get_output_port_count();
- VisualShaderNode::PortType port_right = VisualShaderNode::PORT_TYPE_SCALAR;
- String name_right;
- if (valid_right) {
- name_right = vsnode->get_output_port_name(i);
- port_right = vsnode->get_output_port_type(i);
- }
-
- HBoxContainer *hb = memnew(HBoxContainer);
- hb->add_theme_constant_override("separation", 7 * EDSCALE);
-
- Variant default_value;
-
- if (valid_left && !port_left_used) {
- default_value = vsnode->get_input_port_default_value(i);
- }
-
- if (default_value.get_type() != Variant::NIL) { // only a label
- Button *button = memnew(Button);
- hb->add_child(button);
- button->connect("pressed", callable_mp(this, &VisualShaderEditor::_edit_port_default_input), varray(button, nodes[n_i], i));
-
- switch (default_value.get_type()) {
- case Variant::COLOR: {
- button->set_custom_minimum_size(Size2(30, 0) * EDSCALE);
- button->connect("draw", callable_mp(this, &VisualShaderEditor::_draw_color_over_button), varray(button, default_value));
- } break;
- case Variant::BOOL: {
- button->set_text(((bool)default_value) ? "true" : "false");
- } break;
- case Variant::INT:
- case Variant::FLOAT: {
- button->set_text(String::num(default_value, 4));
- } break;
- case Variant::VECTOR3: {
- Vector3 v = default_value;
- button->set_text(String::num(v.x, 3) + "," + String::num(v.y, 3) + "," + String::num(v.z, 3));
- } break;
- default: {
- }
- }
- }
-
- if (i == 0 && custom_editor) {
- hb->add_child(custom_editor);
- custom_editor->set_h_size_flags(SIZE_EXPAND_FILL);
- } else {
- if (valid_left) {
- if (is_group) {
- OptionButton *type_box = memnew(OptionButton);
- hb->add_child(type_box);
- type_box->add_item(TTR("Float"));
- type_box->add_item(TTR("Int"));
- type_box->add_item(TTR("Vector"));
- type_box->add_item(TTR("Boolean"));
- type_box->add_item(TTR("Transform"));
- type_box->add_item(TTR("Sampler"));
- type_box->select(group_node->get_input_port_type(i));
- type_box->set_custom_minimum_size(Size2(100 * EDSCALE, 0));
- type_box->connect("item_selected", callable_mp(this, &VisualShaderEditor::_change_input_port_type), varray(nodes[n_i], i), CONNECT_DEFERRED);
-
- LineEdit *name_box = memnew(LineEdit);
- hb->add_child(name_box);
- name_box->set_custom_minimum_size(Size2(65 * EDSCALE, 0));
- name_box->set_h_size_flags(SIZE_EXPAND_FILL);
- name_box->set_text(name_left);
- name_box->connect("text_entered", callable_mp(this, &VisualShaderEditor::_change_input_port_name), varray(name_box, nodes[n_i], i));
- name_box->connect("focus_exited", callable_mp(this, &VisualShaderEditor::_port_name_focus_out), varray(name_box, nodes[n_i], i, false));
-
- Button *remove_btn = memnew(Button);
- remove_btn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Remove", "EditorIcons"));
- remove_btn->set_tooltip(TTR("Remove") + " " + name_left);
- remove_btn->connect("pressed", callable_mp(this, &VisualShaderEditor::_remove_input_port), varray(nodes[n_i], i), CONNECT_DEFERRED);
- hb->add_child(remove_btn);
- } else {
- Label *label = memnew(Label);
- label->set_text(name_left);
- label->add_theme_style_override("normal", label_style); //more compact
- hb->add_child(label);
-
- if (vsnode->get_input_port_default_hint(i) != "" && !port_left_used) {
- Label *hint_label = memnew(Label);
- hint_label->set_text("[" + vsnode->get_input_port_default_hint(i) + "]");
- hint_label->add_theme_color_override("font_color", get_theme_color("font_color_readonly", "TextEdit"));
- hint_label->add_theme_style_override("normal", label_style);
- hb->add_child(hint_label);
- }
- }
- }
-
- if (!is_group) {
- hb->add_spacer();
- }
+void VisualShaderEditor::_update_uniform_refs(Set<String> &p_deleted_names) {
+ for (int i = 0; i < VisualShader::TYPE_MAX; i++) {
+ VisualShader::Type type = VisualShader::Type(i);
- if (valid_right) {
- if (is_group) {
- Button *remove_btn = memnew(Button);
- remove_btn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Remove", "EditorIcons"));
- remove_btn->set_tooltip(TTR("Remove") + " " + name_left);
- remove_btn->connect("pressed", callable_mp(this, &VisualShaderEditor::_remove_output_port), varray(nodes[n_i], i), CONNECT_DEFERRED);
- hb->add_child(remove_btn);
-
- LineEdit *name_box = memnew(LineEdit);
- hb->add_child(name_box);
- name_box->set_custom_minimum_size(Size2(65 * EDSCALE, 0));
- name_box->set_h_size_flags(SIZE_EXPAND_FILL);
- name_box->set_text(name_right);
- name_box->connect("text_entered", callable_mp(this, &VisualShaderEditor::_change_output_port_name), varray(name_box, nodes[n_i], i));
- name_box->connect("focus_exited", callable_mp(this, &VisualShaderEditor::_port_name_focus_out), varray(name_box, nodes[n_i], i, true));
-
- OptionButton *type_box = memnew(OptionButton);
- hb->add_child(type_box);
- type_box->add_item(TTR("Float"));
- type_box->add_item(TTR("Int"));
- type_box->add_item(TTR("Vector"));
- type_box->add_item(TTR("Boolean"));
- type_box->add_item(TTR("Transform"));
- type_box->select(group_node->get_output_port_type(i));
- type_box->set_custom_minimum_size(Size2(100 * EDSCALE, 0));
- type_box->connect("item_selected", callable_mp(this, &VisualShaderEditor::_change_output_port_type), varray(nodes[n_i], i), CONNECT_DEFERRED);
- } else {
- Label *label = memnew(Label);
- label->set_text(name_right);
- label->add_theme_style_override("normal", label_style); //more compact
- hb->add_child(label);
+ Vector<int> nodes = visual_shader->get_node_list(type);
+ for (int j = 0; j < nodes.size(); j++) {
+ if (j > 0) {
+ Ref<VisualShaderNodeUniformRef> ref = visual_shader->get_node(type, nodes[j]);
+ if (ref.is_valid()) {
+ if (p_deleted_names.has(ref->get_uniform_name())) {
+ undo_redo->add_do_method(ref.ptr(), "set_uniform_name", "[None]");
+ undo_redo->add_undo_method(ref.ptr(), "set_uniform_name", ref->get_uniform_name());
+ undo_redo->add_do_method(graph_plugin.ptr(), "update_node", VisualShader::Type(i), nodes[j]);
+ undo_redo->add_undo_method(graph_plugin.ptr(), "update_node", VisualShader::Type(i), nodes[j]);
}
}
}
-
- if (valid_right && edit_type->get_selected() == VisualShader::TYPE_FRAGMENT && port_right != VisualShaderNode::PORT_TYPE_TRANSFORM && port_right != VisualShaderNode::PORT_TYPE_SAMPLER) {
- TextureButton *preview = memnew(TextureButton);
- preview->set_toggle_mode(true);
- preview->set_normal_texture(get_theme_icon("GuiVisibilityHidden", "EditorIcons"));
- preview->set_pressed_texture(get_theme_icon("GuiVisibilityVisible", "EditorIcons"));
- preview->set_v_size_flags(SIZE_SHRINK_CENTER);
-
- if (vsnode->get_output_port_for_preview() == i) {
- preview->set_pressed(true);
- }
-
- preview->connect("pressed", callable_mp(this, &VisualShaderEditor::_preview_select_port), varray(nodes[n_i], i), CONNECT_DEFERRED);
- hb->add_child(preview);
- }
-
- if (is_group) {
- offset = memnew(Control);
- offset->set_custom_minimum_size(Size2(0, 5 * EDSCALE));
- node->add_child(offset);
- port_offset++;
- }
-
- node->add_child(hb);
-
- node->set_slot(i + port_offset, valid_left, port_left, type_color[port_left], valid_right, port_right, type_color[port_right]);
}
+ }
+}
- if (vsnode->get_output_port_for_preview() >= 0) {
- int port_type = vsnode->get_output_port_type(vsnode->get_output_port_for_preview());
+void VisualShaderEditor::_update_graph() {
+ if (updating) {
+ return;
+ }
- if (port_type != VisualShaderNode::PORT_TYPE_TRANSFORM && port_type != VisualShaderNode::PORT_TYPE_SAMPLER) {
- offset = memnew(Control);
- offset->set_custom_minimum_size(Size2(0, 5 * EDSCALE));
- node->add_child(offset);
+ if (visual_shader.is_null()) {
+ return;
+ }
- VisualShaderNodePortPreview *port_preview = memnew(VisualShaderNodePortPreview);
- port_preview->setup(visual_shader, type, nodes[n_i], vsnode->get_output_port_for_preview());
- port_preview->set_h_size_flags(SIZE_SHRINK_CENTER);
- node->add_child(port_preview);
- }
- }
+ graph->set_scroll_ofs(visual_shader->get_graph_offset() * EDSCALE);
- offset = memnew(Control);
- offset->set_custom_minimum_size(Size2(0, 4 * EDSCALE));
- node->add_child(offset);
+ VisualShader::Type type = get_current_shader_type();
- String error = vsnode->get_warning(visual_shader->get_mode(), type);
- if (error != String()) {
- Label *error_label = memnew(Label);
- error_label->add_theme_color_override("font_color", get_theme_color("error_color", "Editor"));
- error_label->set_text(error);
- node->add_child(error_label);
+ graph->clear_connections();
+ //erase all nodes
+ for (int i = 0; i < graph->get_child_count(); i++) {
+ if (Object::cast_to<GraphNode>(graph->get_child(i))) {
+ Node *node = graph->get_child(i);
+ graph->remove_child(node);
+ memdelete(node);
+ i--;
}
+ }
- if (is_expression) {
- TextEdit *expression_box = memnew(TextEdit);
- Ref<CodeHighlighter> expression_syntax_highlighter;
- expression_syntax_highlighter.instance();
- expression_node->set_control(expression_box, 0);
- node->add_child(expression_box);
-
- Color background_color = EDITOR_GET("text_editor/highlighting/background_color");
- Color text_color = EDITOR_GET("text_editor/highlighting/text_color");
- Color keyword_color = EDITOR_GET("text_editor/highlighting/keyword_color");
- Color comment_color = EDITOR_GET("text_editor/highlighting/comment_color");
- Color symbol_color = EDITOR_GET("text_editor/highlighting/symbol_color");
- Color function_color = EDITOR_GET("text_editor/highlighting/function_color");
- Color number_color = EDITOR_GET("text_editor/highlighting/number_color");
- Color members_color = EDITOR_GET("text_editor/highlighting/member_variable_color");
-
- expression_box->set_syntax_highlighter(expression_syntax_highlighter);
- expression_box->add_theme_color_override("background_color", background_color);
-
- for (List<String>::Element *E = keyword_list.front(); E; E = E->next()) {
- expression_syntax_highlighter->add_keyword_color(E->get(), keyword_color);
- }
+ List<VisualShader::Connection> connections;
+ visual_shader->get_node_connections(type, &connections);
+ graph_plugin->set_connections(connections);
- expression_box->add_theme_font_override("font", get_theme_font("expression", "EditorFonts"));
- expression_box->add_theme_color_override("font_color", text_color);
- expression_syntax_highlighter->set_number_color(number_color);
- expression_syntax_highlighter->set_symbol_color(symbol_color);
- expression_syntax_highlighter->set_function_color(function_color);
- expression_syntax_highlighter->set_member_variable_color(members_color);
- expression_syntax_highlighter->add_color_region("/*", "*/", comment_color, false);
- expression_syntax_highlighter->add_color_region("//", "", comment_color, true);
+ Vector<int> nodes = visual_shader->get_node_list(type);
- expression_box->set_text(expression);
- expression_box->set_context_menu_enabled(false);
- expression_box->set_show_line_numbers(true);
+ _update_uniforms(false);
- expression_box->connect("focus_exited", callable_mp(this, &VisualShaderEditor::_expression_focus_out), varray(expression_box, nodes[n_i]));
- }
+ graph_plugin->clear_links();
+ graph_plugin->make_dirty(true);
- if (!uniform.is_valid()) {
- graph->add_child(node);
- _update_created_node(node);
- if (is_group) {
- call_deferred("_set_node_size", (int)type, nodes[n_i], size);
- }
- }
+ for (int n_i = 0; n_i < nodes.size(); n_i++) {
+ graph_plugin->add_node(type, nodes[n_i]);
}
+ graph_plugin->make_dirty(false);
+
for (List<VisualShader::Connection>::Element *E = connections.front(); E; E = E->next()) {
int from = E->get().from_node;
int from_idx = E->get().from_port;
@@ -919,8 +1122,18 @@ void VisualShaderEditor::_update_graph() {
}
}
+VisualShader::Type VisualShaderEditor::get_current_shader_type() const {
+ VisualShader::Type type;
+ if (particles_mode) {
+ type = VisualShader::Type(edit_type->get_selected() + 3);
+ } else {
+ type = VisualShader::Type(edit_type->get_selected());
+ }
+ return type;
+}
+
void VisualShaderEditor::_add_input_port(int p_node, int p_port, int p_port_type, const String &p_name) {
- VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
+ VisualShader::Type type = get_current_shader_type();
Ref<VisualShaderNodeExpression> node = visual_shader->get_node(type, p_node);
if (node.is_null()) {
return;
@@ -929,15 +1142,13 @@ void VisualShaderEditor::_add_input_port(int p_node, int p_port, int p_port_type
undo_redo->create_action(TTR("Add input port"));
undo_redo->add_do_method(node.ptr(), "add_input_port", p_port, p_port_type, p_name);
undo_redo->add_undo_method(node.ptr(), "remove_input_port", p_port);
- undo_redo->add_do_method(this, "_update_graph");
- undo_redo->add_undo_method(this, "_update_graph");
- undo_redo->add_do_method(this, "_rebuild");
- undo_redo->add_undo_method(this, "_rebuild");
+ undo_redo->add_do_method(graph_plugin.ptr(), "update_node", type, p_node);
+ undo_redo->add_undo_method(graph_plugin.ptr(), "update_node", type, p_node);
undo_redo->commit_action();
}
void VisualShaderEditor::_add_output_port(int p_node, int p_port, int p_port_type, const String &p_name) {
- VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
+ VisualShader::Type type = get_current_shader_type();
Ref<VisualShaderNodeGroupBase> node = visual_shader->get_node(type, p_node);
if (node.is_null()) {
return;
@@ -946,15 +1157,13 @@ void VisualShaderEditor::_add_output_port(int p_node, int p_port, int p_port_typ
undo_redo->create_action(TTR("Add output port"));
undo_redo->add_do_method(node.ptr(), "add_output_port", p_port, p_port_type, p_name);
undo_redo->add_undo_method(node.ptr(), "remove_output_port", p_port);
- undo_redo->add_do_method(this, "_update_graph");
- undo_redo->add_undo_method(this, "_update_graph");
- undo_redo->add_do_method(this, "_rebuild");
- undo_redo->add_undo_method(this, "_rebuild");
+ undo_redo->add_do_method(graph_plugin.ptr(), "update_node", type, p_node);
+ undo_redo->add_undo_method(graph_plugin.ptr(), "update_node", type, p_node);
undo_redo->commit_action();
}
void VisualShaderEditor::_change_input_port_type(int p_type, int p_node, int p_port) {
- VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
+ VisualShader::Type type = get_current_shader_type();
Ref<VisualShaderNodeGroupBase> node = visual_shader->get_node(type, p_node);
if (node.is_null()) {
return;
@@ -963,15 +1172,13 @@ void VisualShaderEditor::_change_input_port_type(int p_type, int p_node, int p_p
undo_redo->create_action(TTR("Change input port type"));
undo_redo->add_do_method(node.ptr(), "set_input_port_type", p_port, p_type);
undo_redo->add_undo_method(node.ptr(), "set_input_port_type", p_port, node->get_input_port_type(p_port));
- undo_redo->add_do_method(this, "_update_graph");
- undo_redo->add_undo_method(this, "_update_graph");
- undo_redo->add_do_method(this, "_rebuild");
- undo_redo->add_undo_method(this, "_rebuild");
+ undo_redo->add_do_method(graph_plugin.ptr(), "update_node", type, p_node);
+ undo_redo->add_undo_method(graph_plugin.ptr(), "update_node", type, p_node);
undo_redo->commit_action();
}
void VisualShaderEditor::_change_output_port_type(int p_type, int p_node, int p_port) {
- VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
+ VisualShader::Type type = get_current_shader_type();
Ref<VisualShaderNodeGroupBase> node = visual_shader->get_node(type, p_node);
if (node.is_null()) {
return;
@@ -980,15 +1187,13 @@ void VisualShaderEditor::_change_output_port_type(int p_type, int p_node, int p_
undo_redo->create_action(TTR("Change output port type"));
undo_redo->add_do_method(node.ptr(), "set_output_port_type", p_port, p_type);
undo_redo->add_undo_method(node.ptr(), "set_output_port_type", p_port, node->get_output_port_type(p_port));
- undo_redo->add_do_method(this, "_update_graph");
- undo_redo->add_undo_method(this, "_update_graph");
- undo_redo->add_do_method(this, "_rebuild");
- undo_redo->add_undo_method(this, "_rebuild");
+ undo_redo->add_do_method(graph_plugin.ptr(), "update_node", type, p_node);
+ undo_redo->add_undo_method(graph_plugin.ptr(), "update_node", type, p_node);
undo_redo->commit_action();
}
void VisualShaderEditor::_change_input_port_name(const String &p_text, Object *line_edit, int p_node_id, int p_port_id) {
- VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
+ VisualShader::Type type = get_current_shader_type();
Ref<VisualShaderNodeGroupBase> node = visual_shader->get_node(type, p_node_id);
ERR_FAIL_COND(!node.is_valid());
@@ -996,13 +1201,13 @@ void VisualShaderEditor::_change_input_port_name(const String &p_text, Object *l
undo_redo->create_action(TTR("Change input port name"));
undo_redo->add_do_method(node.ptr(), "set_input_port_name", p_port_id, p_text);
undo_redo->add_undo_method(node.ptr(), "set_input_port_name", p_port_id, node->get_input_port_name(p_port_id));
- undo_redo->add_do_method(this, "_rebuild");
- undo_redo->add_undo_method(this, "_rebuild");
+ undo_redo->add_do_method(graph_plugin.ptr(), "update_node", type, p_node_id);
+ undo_redo->add_undo_method(graph_plugin.ptr(), "update_node", type, p_node_id);
undo_redo->commit_action();
}
void VisualShaderEditor::_change_output_port_name(const String &p_text, Object *line_edit, int p_node_id, int p_port_id) {
- VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
+ VisualShader::Type type = get_current_shader_type();
Ref<VisualShaderNodeGroupBase> node = visual_shader->get_node(type, p_node_id);
ERR_FAIL_COND(!node.is_valid());
@@ -1010,13 +1215,13 @@ void VisualShaderEditor::_change_output_port_name(const String &p_text, Object *
undo_redo->create_action(TTR("Change output port name"));
undo_redo->add_do_method(node.ptr(), "set_output_port_name", p_port_id, p_text);
undo_redo->add_undo_method(node.ptr(), "set_output_port_name", p_port_id, node->get_output_port_name(p_port_id));
- undo_redo->add_do_method(this, "_rebuild");
- undo_redo->add_undo_method(this, "_rebuild");
+ undo_redo->add_do_method(graph_plugin.ptr(), "update_node", type, p_node_id);
+ undo_redo->add_undo_method(graph_plugin.ptr(), "update_node", type, p_node_id);
undo_redo->commit_action();
}
void VisualShaderEditor::_remove_input_port(int p_node, int p_port) {
- VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
+ VisualShader::Type type = get_current_shader_type();
Ref<VisualShaderNodeGroupBase> node = visual_shader->get_node(type, p_node);
if (node.is_null()) {
return;
@@ -1036,12 +1241,21 @@ void VisualShaderEditor::_remove_input_port(int p_node, int p_port) {
if (to_port == p_port) {
undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, from_node, from_port, to_node, to_port);
undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes_forced", type, from_node, from_port, to_node, to_port);
+
+ undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, from_node, from_port, to_node, to_port);
+ undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, from_node, from_port, to_node, to_port);
} else if (to_port > p_port) {
undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, from_node, from_port, to_node, to_port);
undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes_forced", type, from_node, from_port, to_node, to_port);
+ undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, from_node, from_port, to_node, to_port);
+ undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, from_node, from_port, to_node, to_port);
+
undo_redo->add_do_method(visual_shader.ptr(), "connect_nodes_forced", type, from_node, from_port, to_node, to_port - 1);
undo_redo->add_undo_method(visual_shader.ptr(), "disconnect_nodes", type, from_node, from_port, to_node, to_port - 1);
+
+ undo_redo->add_do_method(graph_plugin.ptr(), "connect_nodes", type, from_node, from_port, to_node, to_port - 1);
+ undo_redo->add_undo_method(graph_plugin.ptr(), "disconnect_nodes", type, from_node, from_port, to_node, to_port - 1);
}
}
}
@@ -1049,17 +1263,14 @@ void VisualShaderEditor::_remove_input_port(int p_node, int p_port) {
undo_redo->add_do_method(node.ptr(), "remove_input_port", p_port);
undo_redo->add_undo_method(node.ptr(), "add_input_port", p_port, (int)node->get_input_port_type(p_port), node->get_input_port_name(p_port));
- undo_redo->add_do_method(this, "_update_graph");
- undo_redo->add_undo_method(this, "_update_graph");
-
- undo_redo->add_do_method(this, "_rebuild");
- undo_redo->add_undo_method(this, "_rebuild");
+ undo_redo->add_do_method(graph_plugin.ptr(), "update_node", type, p_node);
+ undo_redo->add_undo_method(graph_plugin.ptr(), "update_node", type, p_node);
undo_redo->commit_action();
}
void VisualShaderEditor::_remove_output_port(int p_node, int p_port) {
- VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
+ VisualShader::Type type = get_current_shader_type();
Ref<VisualShaderNodeGroupBase> node = visual_shader->get_node(type, p_node);
if (node.is_null()) {
return;
@@ -1079,12 +1290,21 @@ void VisualShaderEditor::_remove_output_port(int p_node, int p_port) {
if (from_port == p_port) {
undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, from_node, from_port, to_node, to_port);
undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes_forced", type, from_node, from_port, to_node, to_port);
+
+ undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, from_node, from_port, to_node, to_port);
+ undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, from_node, from_port, to_node, to_port);
} else if (from_port > p_port) {
undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, from_node, from_port, to_node, to_port);
undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes_forced", type, from_node, from_port, to_node, to_port);
+ undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, from_node, from_port, to_node, to_port);
+ undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, from_node, from_port, to_node, to_port);
+
undo_redo->add_do_method(visual_shader.ptr(), "connect_nodes_forced", type, from_node, from_port - 1, to_node, to_port);
undo_redo->add_undo_method(visual_shader.ptr(), "disconnect_nodes", type, from_node, from_port - 1, to_node, to_port);
+
+ undo_redo->add_do_method(graph_plugin.ptr(), "connect_nodes", type, from_node, from_port - 1, to_node, to_port);
+ undo_redo->add_undo_method(graph_plugin.ptr(), "disconnect_nodes", type, from_node, from_port - 1, to_node, to_port);
}
}
}
@@ -1092,23 +1312,20 @@ void VisualShaderEditor::_remove_output_port(int p_node, int p_port) {
undo_redo->add_do_method(node.ptr(), "remove_output_port", p_port);
undo_redo->add_undo_method(node.ptr(), "add_output_port", p_port, (int)node->get_output_port_type(p_port), node->get_output_port_name(p_port));
- undo_redo->add_do_method(this, "_update_graph");
- undo_redo->add_undo_method(this, "_update_graph");
-
- undo_redo->add_do_method(this, "_rebuild");
- undo_redo->add_undo_method(this, "_rebuild");
+ undo_redo->add_do_method(graph_plugin.ptr(), "update_node", type, p_node);
+ undo_redo->add_undo_method(graph_plugin.ptr(), "update_node", type, p_node);
undo_redo->commit_action();
}
-void VisualShaderEditor::_expression_focus_out(Object *text_edit, int p_node) {
- VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
+void VisualShaderEditor::_expression_focus_out(Object *code_edit, int p_node) {
+ VisualShader::Type type = get_current_shader_type();
Ref<VisualShaderNodeExpression> node = visual_shader->get_node(type, p_node);
if (node.is_null()) {
return;
}
- TextEdit *expression_box = Object::cast_to<TextEdit>(text_edit);
+ CodeEdit *expression_box = Object::cast_to<CodeEdit>(code_edit);
if (node->get_expression() == expression_box->get_text()) {
return;
@@ -1117,20 +1334,11 @@ void VisualShaderEditor::_expression_focus_out(Object *text_edit, int p_node) {
undo_redo->create_action(TTR("Set expression"));
undo_redo->add_do_method(node.ptr(), "set_expression", expression_box->get_text());
undo_redo->add_undo_method(node.ptr(), "set_expression", node->get_expression());
- undo_redo->add_do_method(this, "_rebuild");
- undo_redo->add_undo_method(this, "_rebuild");
undo_redo->commit_action();
}
-void VisualShaderEditor::_rebuild() {
- if (visual_shader != nullptr) {
- EditorNode::get_singleton()->get_log()->clear();
- visual_shader->rebuild();
- }
-}
-
void VisualShaderEditor::_set_node_size(int p_type, int p_node, const Vector2 &p_size) {
- VisualShader::Type type = VisualShader::Type(p_type);
+ VisualShader::Type type = get_current_shader_type();
Ref<VisualShaderNode> node = visual_shader->get_node(type, p_node);
if (node.is_null()) {
return;
@@ -1177,7 +1385,7 @@ void VisualShaderEditor::_set_node_size(int p_type, int p_node, const Vector2 &p
}
void VisualShaderEditor::_node_resized(const Vector2 &p_new_size, int p_type, int p_node) {
- VisualShader::Type type = VisualShader::Type(p_type);
+ VisualShader::Type type = get_current_shader_type();
Ref<VisualShaderNodeGroupBase> node = visual_shader->get_node(type, p_node);
if (node.is_null()) {
return;
@@ -1190,50 +1398,57 @@ void VisualShaderEditor::_node_resized(const Vector2 &p_new_size, int p_type, in
}
void VisualShaderEditor::_preview_select_port(int p_node, int p_port) {
- VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
+ VisualShader::Type type = get_current_shader_type();
Ref<VisualShaderNode> node = visual_shader->get_node(type, p_node);
if (node.is_null()) {
return;
}
-
+ int prev_port = node->get_output_port_for_preview();
if (node->get_output_port_for_preview() == p_port) {
p_port = -1; //toggle it
}
- undo_redo->create_action(TTR("Set Uniform Name"));
+ undo_redo->create_action(p_port == -1 ? TTR("Hide Port Preview") : TTR("Show Port Preview"));
undo_redo->add_do_method(node.ptr(), "set_output_port_for_preview", p_port);
- undo_redo->add_undo_method(node.ptr(), "set_output_port_for_preview", node->get_output_port_for_preview());
- undo_redo->add_do_method(this, "_update_graph");
- undo_redo->add_undo_method(this, "_update_graph");
+ undo_redo->add_undo_method(node.ptr(), "set_output_port_for_preview", prev_port);
+ undo_redo->add_do_method(graph_plugin.ptr(), "show_port_preview", (int)type, p_node, p_port);
+ undo_redo->add_undo_method(graph_plugin.ptr(), "show_port_preview", (int)type, p_node, prev_port);
undo_redo->commit_action();
}
-void VisualShaderEditor::_line_edit_changed(const String &p_text, Object *line_edit, int p_node_id) {
- VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
+void VisualShaderEditor::_uniform_line_edit_changed(const String &p_text, int p_node_id) {
+ VisualShader::Type type = get_current_shader_type();
Ref<VisualShaderNodeUniform> node = visual_shader->get_node(type, p_node_id);
ERR_FAIL_COND(!node.is_valid());
String validated_name = visual_shader->validate_uniform_name(p_text, node);
- updating = true;
+ if (validated_name == node->get_uniform_name()) {
+ return;
+ }
+
undo_redo->create_action(TTR("Set Uniform Name"));
undo_redo->add_do_method(node.ptr(), "set_uniform_name", validated_name);
undo_redo->add_undo_method(node.ptr(), "set_uniform_name", node->get_uniform_name());
- undo_redo->add_do_method(this, "_update_graph");
- undo_redo->add_undo_method(this, "_update_graph");
- undo_redo->commit_action();
- updating = false;
+ undo_redo->add_do_method(graph_plugin.ptr(), "set_uniform_name", type, p_node_id, validated_name);
+ undo_redo->add_undo_method(graph_plugin.ptr(), "set_uniform_name", type, p_node_id, node->get_uniform_name());
+
+ undo_redo->add_do_method(this, "_update_uniforms", true);
+ undo_redo->add_undo_method(this, "_update_uniforms", true);
+
+ Set<String> changed_names;
+ changed_names.insert(node->get_uniform_name());
+ _update_uniform_refs(changed_names);
- Object::cast_to<LineEdit>(line_edit)->set_text(validated_name);
+ undo_redo->commit_action();
}
-void VisualShaderEditor::_line_edit_focus_out(Object *line_edit, int p_node_id) {
- String text = Object::cast_to<LineEdit>(line_edit)->get_text();
- _line_edit_changed(text, line_edit, p_node_id);
+void VisualShaderEditor::_uniform_line_edit_focus_out(Object *line_edit, int p_node_id) {
+ _uniform_line_edit_changed(Object::cast_to<LineEdit>(line_edit)->get_text(), p_node_id);
}
void VisualShaderEditor::_port_name_focus_out(Object *line_edit, int p_node_id, int p_port_id, bool p_output) {
- VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
+ VisualShader::Type type = get_current_shader_type();
Ref<VisualShaderNodeGroupBase> node = visual_shader->get_node(type, p_node_id);
ERR_FAIL_COND(!node.is_valid());
@@ -1284,7 +1499,7 @@ void VisualShaderEditor::_port_name_focus_out(Object *line_edit, int p_node_id,
}
void VisualShaderEditor::_port_edited() {
- VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
+ VisualShader::Type type = get_current_shader_type();
Variant value = property_editor->get_variant();
Ref<VisualShaderNode> vsn = visual_shader->get_node(type, editing_node);
@@ -1293,15 +1508,15 @@ void VisualShaderEditor::_port_edited() {
undo_redo->create_action(TTR("Set Input Default Port"));
undo_redo->add_do_method(vsn.ptr(), "set_input_port_default_value", editing_port, value);
undo_redo->add_undo_method(vsn.ptr(), "set_input_port_default_value", editing_port, vsn->get_input_port_default_value(editing_port));
- undo_redo->add_do_method(this, "_update_graph");
- undo_redo->add_undo_method(this, "_update_graph");
+ undo_redo->add_do_method(graph_plugin.ptr(), "set_input_port_default_value", type, editing_node, editing_port, value);
+ undo_redo->add_undo_method(graph_plugin.ptr(), "set_input_port_default_value", type, editing_node, editing_port, vsn->get_input_port_default_value(editing_port));
undo_redo->commit_action();
property_editor->hide();
}
void VisualShaderEditor::_edit_port_default_input(Object *p_button, int p_node, int p_port) {
- VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
+ VisualShader::Type type = get_current_shader_type();
Ref<VisualShaderNode> vsn = visual_shader->get_node(type, p_node);
@@ -1467,13 +1682,15 @@ VisualShaderNode *VisualShaderEditor::_add_node(int p_idx, int p_op_idx) {
}
saved_node_pos_dirty = false;
- VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
+ VisualShader::Type type = get_current_shader_type();
int id_to_use = visual_shader->get_valid_node_id(type);
undo_redo->create_action(TTR("Add Node to Visual Shader"));
undo_redo->add_do_method(visual_shader.ptr(), "add_node", type, vsnode, position, id_to_use);
undo_redo->add_undo_method(visual_shader.ptr(), "remove_node", type, id_to_use);
+ undo_redo->add_do_method(graph_plugin.ptr(), "add_node", type, id_to_use);
+ undo_redo->add_undo_method(graph_plugin.ptr(), "remove_node", type, id_to_use);
VisualShaderNodeExpression *expr = Object::cast_to<VisualShaderNodeExpression>(vsnode.ptr());
if (expr) {
@@ -1488,6 +1705,8 @@ VisualShaderNode *VisualShaderEditor::_add_node(int p_idx, int p_op_idx) {
if (visual_shader->is_port_types_compatible(vsnode->get_output_port_type(_from_slot), visual_shader->get_node(type, to_node)->get_input_port_type(to_slot))) {
undo_redo->add_do_method(visual_shader.ptr(), "connect_nodes", type, _from_node, _from_slot, to_node, to_slot);
undo_redo->add_undo_method(visual_shader.ptr(), "disconnect_nodes", type, _from_node, _from_slot, to_node, to_slot);
+ undo_redo->add_do_method(graph_plugin.ptr(), "connect_nodes", type, _from_node, _from_slot, to_node, to_slot);
+ undo_redo->add_undo_method(graph_plugin.ptr(), "disconnect_nodes", type, _from_node, _from_slot, to_node, to_slot);
}
}
} else if (from_node != -1 && from_slot != -1) {
@@ -1496,33 +1715,51 @@ VisualShaderNode *VisualShaderEditor::_add_node(int p_idx, int p_op_idx) {
int _to_slot = 0;
if (visual_shader->is_port_types_compatible(visual_shader->get_node(type, from_node)->get_output_port_type(from_slot), vsnode->get_input_port_type(_to_slot))) {
- undo_redo->add_do_method(visual_shader.ptr(), "connect_nodes", type, from_node, from_slot, _to_node, _to_slot);
undo_redo->add_undo_method(visual_shader.ptr(), "disconnect_nodes", type, from_node, from_slot, _to_node, _to_slot);
+ undo_redo->add_do_method(visual_shader.ptr(), "connect_nodes", type, from_node, from_slot, _to_node, _to_slot);
+ undo_redo->add_undo_method(graph_plugin.ptr(), "disconnect_nodes", type, from_node, from_slot, _to_node, _to_slot);
+ undo_redo->add_do_method(graph_plugin.ptr(), "connect_nodes", type, from_node, from_slot, _to_node, _to_slot);
}
}
}
- undo_redo->add_do_method(this, "_update_graph");
- undo_redo->add_undo_method(this, "_update_graph");
+ VisualShaderNodeUniform *uniform = Object::cast_to<VisualShaderNodeUniform>(vsnode.ptr());
+ if (uniform) {
+ undo_redo->add_do_method(this, "_update_uniforms", true);
+ undo_redo->add_undo_method(this, "_update_uniforms", true);
+ }
+
undo_redo->commit_action();
return vsnode.ptr();
}
void VisualShaderEditor::_node_dragged(const Vector2 &p_from, const Vector2 &p_to, int p_node) {
- VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
+ VisualShader::Type type = get_current_shader_type();
+ drag_buffer.push_back({ type, p_node, p_from, p_to });
+ if (!drag_dirty) {
+ call_deferred("_nodes_dragged");
+ }
+ drag_dirty = true;
+}
- updating = true;
- undo_redo->create_action(TTR("Node Moved"));
- undo_redo->add_do_method(visual_shader.ptr(), "set_node_position", type, p_node, p_to);
- undo_redo->add_undo_method(visual_shader.ptr(), "set_node_position", type, p_node, p_from);
- undo_redo->add_do_method(this, "_update_graph");
- undo_redo->add_undo_method(this, "_update_graph");
+void VisualShaderEditor::_nodes_dragged() {
+ drag_dirty = false;
+
+ undo_redo->create_action(TTR("Node(s) Moved"));
+
+ for (List<DragOp>::Element *E = drag_buffer.front(); E; E = E->next()) {
+ undo_redo->add_do_method(visual_shader.ptr(), "set_node_position", E->get().type, E->get().node, E->get().to);
+ undo_redo->add_undo_method(visual_shader.ptr(), "set_node_position", E->get().type, E->get().node, E->get().from);
+ undo_redo->add_do_method(graph_plugin.ptr(), "set_node_position", E->get().type, E->get().node, E->get().to);
+ undo_redo->add_undo_method(graph_plugin.ptr(), "set_node_position", E->get().type, E->get().node, E->get().from);
+ }
+
+ drag_buffer.clear();
undo_redo->commit_action();
- updating = false;
}
void VisualShaderEditor::_connection_request(const String &p_from, int p_from_index, const String &p_to, int p_to_index) {
- VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
+ VisualShader::Type type = get_current_shader_type();
int from = p_from.to_int();
int to = p_to.to_int();
@@ -1540,32 +1777,32 @@ void VisualShaderEditor::_connection_request(const String &p_from, int p_from_in
if (E->get().to_node == to && E->get().to_port == p_to_index) {
undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port);
undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port);
+ undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port);
+ undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port);
}
}
undo_redo->add_do_method(visual_shader.ptr(), "connect_nodes", type, from, p_from_index, to, p_to_index);
undo_redo->add_undo_method(visual_shader.ptr(), "disconnect_nodes", type, from, p_from_index, to, p_to_index);
- undo_redo->add_do_method(this, "_update_graph");
- undo_redo->add_undo_method(this, "_update_graph");
+ undo_redo->add_do_method(graph_plugin.ptr(), "connect_nodes", type, from, p_from_index, to, p_to_index);
+ undo_redo->add_undo_method(graph_plugin.ptr(), "disconnect_nodes", type, from, p_from_index, to, p_to_index);
undo_redo->commit_action();
}
void VisualShaderEditor::_disconnection_request(const String &p_from, int p_from_index, const String &p_to, int p_to_index) {
graph->disconnect_node(p_from, p_from_index, p_to, p_to_index);
- VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
+ VisualShader::Type type = get_current_shader_type();
int from = p_from.to_int();
int to = p_to.to_int();
- //updating = true; seems graph edit can handle this, no need to protect
undo_redo->create_action(TTR("Nodes Disconnected"));
undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, from, p_from_index, to, p_to_index);
undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes", type, from, p_from_index, to, p_to_index);
- undo_redo->add_do_method(this, "_update_graph");
- undo_redo->add_undo_method(this, "_update_graph");
+ undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, from, p_from_index, to, p_to_index);
+ undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, from, p_from_index, to, p_to_index);
undo_redo->commit_action();
- //updating = false;
}
void VisualShaderEditor::_connection_to_empty(const String &p_from, int p_from_slot, const Vector2 &p_release_position) {
@@ -1581,12 +1818,22 @@ void VisualShaderEditor::_connection_from_empty(const String &p_to, int p_to_slo
}
void VisualShaderEditor::_delete_request(int which) {
- VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
+ VisualShader::Type type = get_current_shader_type();
Ref<VisualShaderNode> node = Ref<VisualShaderNode>(visual_shader->get_node(type, which));
undo_redo->create_action(TTR("Delete Node"));
+
+ List<VisualShader::Connection> conns;
+ visual_shader->get_node_connections(type, &conns);
+ for (List<VisualShader::Connection>::Element *E = conns.front(); E; E = E->next()) {
+ if (E->get().from_node == which || E->get().to_node == which) {
+ undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port);
+ }
+ }
+
undo_redo->add_do_method(visual_shader.ptr(), "remove_node", type, which);
undo_redo->add_undo_method(visual_shader.ptr(), "add_node", type, node, visual_shader->get_node_position(type, which), which);
+ undo_redo->add_undo_method(graph_plugin.ptr(), "add_node", type, which);
undo_redo->add_do_method(this, "_clear_buffer");
undo_redo->add_undo_method(this, "_clear_buffer");
@@ -1605,22 +1852,31 @@ void VisualShaderEditor::_delete_request(int which) {
undo_redo->add_undo_method(expression, "set_expression", expression->get_expression());
}
- List<VisualShader::Connection> conns;
- visual_shader->get_node_connections(type, &conns);
-
for (List<VisualShader::Connection>::Element *E = conns.front(); E; E = E->next()) {
if (E->get().from_node == which || E->get().to_node == which) {
undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port);
+ undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port);
}
}
+ // delete a node from the graph
+ undo_redo->add_do_method(graph_plugin.ptr(), "remove_node", type, which);
+
+ VisualShaderNodeUniform *uniform = Object::cast_to<VisualShaderNodeUniform>(node.ptr());
+ if (uniform) {
+ undo_redo->add_do_method(this, "_update_uniforms", true);
+ undo_redo->add_undo_method(this, "_update_uniforms", true);
+
+ Set<String> uniform_names;
+ uniform_names.insert(uniform->get_uniform_name());
+
+ _update_uniform_refs(uniform_names);
+ }
- undo_redo->add_do_method(this, "_update_graph");
- undo_redo->add_undo_method(this, "_update_graph");
undo_redo->commit_action();
}
void VisualShaderEditor::_node_selected(Object *p_node) {
- VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
+ VisualShader::Type type = get_current_shader_type();
GraphNode *gn = Object::cast_to<GraphNode>(p_node);
ERR_FAIL_COND(!gn);
@@ -1874,12 +2130,13 @@ void VisualShaderEditor::_dup_paste_nodes(int p_type, int p_pasted_type, List<in
Ref<VisualShaderNode> dupli = node->duplicate();
undo_redo->add_do_method(visual_shader.ptr(), "add_node", type, dupli, visual_shader->get_node_position(pasted_type, E->get()) + p_offset, id_from);
- undo_redo->add_undo_method(visual_shader.ptr(), "remove_node", type, id_from);
+ undo_redo->add_do_method(graph_plugin.ptr(), "add_node", type, id_from);
// duplicate size, inputs and outputs if node is group
Ref<VisualShaderNodeGroupBase> group = Object::cast_to<VisualShaderNodeGroupBase>(node.ptr());
if (!group.is_null()) {
undo_redo->add_do_method(dupli.ptr(), "set_size", group->get_size());
+ undo_redo->add_do_method(graph_plugin.ptr(), "set_node_size", type, id_from, group->get_size());
undo_redo->add_do_method(dupli.ptr(), "set_inputs", group->get_inputs());
undo_redo->add_do_method(dupli.ptr(), "set_outputs", group->get_outputs());
}
@@ -1900,12 +2157,19 @@ void VisualShaderEditor::_dup_paste_nodes(int p_type, int p_pasted_type, List<in
continue;
}
if (connection_remap.has(E->get().from_node) && connection_remap.has(E->get().to_node)) {
- undo_redo->add_do_method(visual_shader.ptr(), "connect_nodes_forced", type, connection_remap[E->get().from_node], E->get().from_port, connection_remap[E->get().to_node], E->get().to_port);
+ undo_redo->add_do_method(visual_shader.ptr(), "connect_nodes", type, connection_remap[E->get().from_node], E->get().from_port, connection_remap[E->get().to_node], E->get().to_port);
+ undo_redo->add_do_method(graph_plugin.ptr(), "connect_nodes", type, connection_remap[E->get().from_node], E->get().from_port, connection_remap[E->get().to_node], E->get().to_port);
+ undo_redo->add_undo_method(graph_plugin.ptr(), "disconnect_nodes", type, connection_remap[E->get().from_node], E->get().from_port, connection_remap[E->get().to_node], E->get().to_port);
}
}
- undo_redo->add_do_method(this, "_update_graph");
- undo_redo->add_undo_method(this, "_update_graph");
+ id_from = base_id;
+ for (List<int>::Element *E = r_nodes.front(); E; E = E->next()) {
+ undo_redo->add_undo_method(visual_shader.ptr(), "remove_node", type, id_from);
+ undo_redo->add_undo_method(graph_plugin.ptr(), "remove_node", type, id_from);
+ id_from++;
+ }
+
undo_redo->commit_action();
if (p_select) {
@@ -1978,7 +2242,7 @@ void VisualShaderEditor::_paste_nodes(bool p_use_custom_position, const Vector2
}
void VisualShaderEditor::_delete_nodes() {
- VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
+ VisualShader::Type type = get_current_shader_type();
List<int> to_erase;
for (int i = 0; i < graph->get_child_count(); i++) {
@@ -1996,11 +2260,25 @@ void VisualShaderEditor::_delete_nodes() {
undo_redo->create_action(TTR("Delete Nodes"));
+ List<VisualShader::Connection> conns;
+ visual_shader->get_node_connections(type, &conns);
+
+ for (List<int>::Element *F = to_erase.front(); F; F = F->next()) {
+ for (List<VisualShader::Connection>::Element *E = conns.front(); E; E = E->next()) {
+ if (E->get().from_node == F->get() || E->get().to_node == F->get()) {
+ undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port);
+ }
+ }
+ }
+
+ Set<String> uniform_names;
+
for (List<int>::Element *F = to_erase.front(); F; F = F->next()) {
Ref<VisualShaderNode> node = visual_shader->get_node(type, F->get());
undo_redo->add_do_method(visual_shader.ptr(), "remove_node", type, F->get());
undo_redo->add_undo_method(visual_shader.ptr(), "add_node", type, node, visual_shader->get_node_position(type, F->get()), F->get());
+ undo_redo->add_undo_method(graph_plugin.ptr(), "add_node", type, F->get());
undo_redo->add_do_method(this, "_clear_buffer");
undo_redo->add_undo_method(this, "_clear_buffer");
@@ -2018,10 +2296,12 @@ void VisualShaderEditor::_delete_nodes() {
if (expression) {
undo_redo->add_undo_method(expression, "set_expression", expression->get_expression());
}
- }
- List<VisualShader::Connection> conns;
- visual_shader->get_node_connections(type, &conns);
+ VisualShaderNodeUniform *uniform = Object::cast_to<VisualShaderNodeUniform>(node.ptr());
+ if (uniform) {
+ uniform_names.insert(uniform->get_uniform_name());
+ }
+ }
List<VisualShader::Connection> used_conns;
for (List<int>::Element *F = to_erase.front(); F; F = F->next()) {
@@ -2036,53 +2316,78 @@ void VisualShaderEditor::_delete_nodes() {
}
if (!cancel) {
undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port);
+ undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port);
used_conns.push_back(E->get());
}
}
}
}
- undo_redo->add_do_method(this, "_update_graph");
- undo_redo->add_undo_method(this, "_update_graph");
+ // delete nodes from the graph
+ for (List<int>::Element *F = to_erase.front(); F; F = F->next()) {
+ undo_redo->add_do_method(graph_plugin.ptr(), "remove_node", type, F->get());
+ }
+
+ // update uniform refs if any uniform has been deleted
+ if (uniform_names.size() > 0) {
+ undo_redo->add_do_method(this, "_update_uniforms", true);
+ undo_redo->add_undo_method(this, "_update_uniforms", true);
+
+ _update_uniform_refs(uniform_names);
+ }
+
undo_redo->commit_action();
}
void VisualShaderEditor::_mode_selected(int p_id) {
+ visual_shader->set_shader_type(particles_mode ? VisualShader::Type(p_id + 3) : VisualShader::Type(p_id));
_update_options_menu();
_update_graph();
}
-void VisualShaderEditor::_input_select_item(Ref<VisualShaderNodeInput> input, String name) {
- String prev_name = input->get_input_name();
+void VisualShaderEditor::_input_select_item(Ref<VisualShaderNodeInput> p_input, String p_name) {
+ String prev_name = p_input->get_input_name();
- if (name == prev_name) {
+ if (p_name == prev_name) {
return;
}
- bool type_changed = input->get_input_type_by_name(name) != input->get_input_type_by_name(prev_name);
+ bool type_changed = p_input->get_input_type_by_name(p_name) != p_input->get_input_type_by_name(prev_name);
UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo();
undo_redo->create_action(TTR("Visual Shader Input Type Changed"));
- undo_redo->add_do_method(input.ptr(), "set_input_name", name);
- undo_redo->add_undo_method(input.ptr(), "set_input_name", prev_name);
-
- if (type_changed) {
- //restore connections if type changed
- VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
- int id = visual_shader->find_node_id(type, input);
- List<VisualShader::Connection> conns;
- visual_shader->get_node_connections(type, &conns);
- for (List<VisualShader::Connection>::Element *E = conns.front(); E; E = E->next()) {
- if (E->get().from_node == id) {
- undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port);
+ undo_redo->add_do_method(p_input.ptr(), "set_input_name", p_name);
+ undo_redo->add_undo_method(p_input.ptr(), "set_input_name", prev_name);
+
+ // update output port
+ for (int type_id = 0; type_id < VisualShader::TYPE_MAX; type_id++) {
+ VisualShader::Type type = VisualShader::Type(type_id);
+ int id = visual_shader->find_node_id(type, p_input);
+ if (id != VisualShader::NODE_ID_INVALID) {
+ if (type_changed) {
+ List<VisualShader::Connection> conns;
+ visual_shader->get_node_connections(type, &conns);
+ for (List<VisualShader::Connection>::Element *E = conns.front(); E; E = E->next()) {
+ if (E->get().from_node == id) {
+ if (visual_shader->is_port_types_compatible(p_input->get_input_type_by_name(p_name), visual_shader->get_node(type, E->get().to_node)->get_input_port_type(E->get().to_port))) {
+ undo_redo->add_do_method(visual_shader.ptr(), "connect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port);
+ undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port);
+ continue;
+ }
+ undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port);
+ undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port);
+ undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port);
+ undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port);
+ }
+ }
}
+ undo_redo->add_do_method(graph_plugin.ptr(), "update_node", type_id, id);
+ undo_redo->add_undo_method(graph_plugin.ptr(), "update_node", type_id, id);
+ break;
}
}
- undo_redo->add_do_method(VisualShaderEditor::get_singleton(), "_update_graph");
- undo_redo->add_undo_method(VisualShaderEditor::get_singleton(), "_update_graph");
-
undo_redo->commit_action();
}
@@ -2101,23 +2406,32 @@ void VisualShaderEditor::_uniform_select_item(Ref<VisualShaderNodeUniformRef> p_
undo_redo->add_do_method(p_uniform_ref.ptr(), "set_uniform_name", p_name);
undo_redo->add_undo_method(p_uniform_ref.ptr(), "set_uniform_name", prev_name);
- if (type_changed) {
- //restore connections if type changed
- VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
+ // update output port
+ for (int type_id = 0; type_id < VisualShader::TYPE_MAX; type_id++) {
+ VisualShader::Type type = VisualShader::Type(type_id);
int id = visual_shader->find_node_id(type, p_uniform_ref);
- List<VisualShader::Connection> conns;
- visual_shader->get_node_connections(type, &conns);
- for (List<VisualShader::Connection>::Element *E = conns.front(); E; E = E->next()) {
- if (E->get().from_node == id) {
- undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port);
- undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port);
+ if (id != VisualShader::NODE_ID_INVALID) {
+ if (type_changed) {
+ List<VisualShader::Connection> conns;
+ visual_shader->get_node_connections(type, &conns);
+ for (List<VisualShader::Connection>::Element *E = conns.front(); E; E = E->next()) {
+ if (E->get().from_node == id) {
+ if (visual_shader->is_port_types_compatible(p_uniform_ref->get_uniform_type_by_name(p_name), visual_shader->get_node(type, E->get().to_node)->get_input_port_type(E->get().to_port))) {
+ continue;
+ }
+ undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port);
+ undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port);
+ undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port);
+ undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port);
+ }
+ }
}
+ undo_redo->add_do_method(graph_plugin.ptr(), "update_node", type_id, id);
+ undo_redo->add_undo_method(graph_plugin.ptr(), "update_node", type_id, id);
+ break;
}
}
- undo_redo->add_do_method(VisualShaderEditor::get_singleton(), "_update_graph");
- undo_redo->add_undo_method(VisualShaderEditor::get_singleton(), "_update_graph");
-
undo_redo->commit_action();
}
@@ -2340,7 +2654,6 @@ void VisualShaderEditor::_update_preview() {
}
void VisualShaderEditor::_bind_methods() {
- ClassDB::bind_method("_rebuild", &VisualShaderEditor::_rebuild);
ClassDB::bind_method("_update_graph", &VisualShaderEditor::_update_graph);
ClassDB::bind_method("_update_options_menu", &VisualShaderEditor::_update_options_menu);
ClassDB::bind_method("_add_node", &VisualShaderEditor::_add_node);
@@ -2349,6 +2662,9 @@ void VisualShaderEditor::_bind_methods() {
ClassDB::bind_method("_uniform_select_item", &VisualShaderEditor::_uniform_select_item);
ClassDB::bind_method("_set_node_size", &VisualShaderEditor::_set_node_size);
ClassDB::bind_method("_clear_buffer", &VisualShaderEditor::_clear_buffer);
+ ClassDB::bind_method("_update_uniforms", &VisualShaderEditor::_update_uniforms);
+ ClassDB::bind_method("_set_mode", &VisualShaderEditor::_set_mode);
+ ClassDB::bind_method("_nodes_dragged", &VisualShaderEditor::_nodes_dragged);
ClassDB::bind_method(D_METHOD("get_drag_data_fw"), &VisualShaderEditor::get_drag_data_fw);
ClassDB::bind_method(D_METHOD("can_drop_data_fw"), &VisualShaderEditor::can_drop_data_fw);
@@ -2428,14 +2744,26 @@ VisualShaderEditor::VisualShaderEditor() {
graph->get_zoom_hbox()->add_child(vs);
graph->get_zoom_hbox()->move_child(vs, 0);
- edit_type = memnew(OptionButton);
- edit_type->add_item(TTR("Vertex"));
- edit_type->add_item(TTR("Fragment"));
- edit_type->add_item(TTR("Light"));
- edit_type->select(1);
- edit_type->connect("item_selected", callable_mp(this, &VisualShaderEditor::_mode_selected));
- graph->get_zoom_hbox()->add_child(edit_type);
- graph->get_zoom_hbox()->move_child(edit_type, 0);
+ edit_type_standart = memnew(OptionButton);
+ edit_type_standart->add_item(TTR("Vertex"));
+ edit_type_standart->add_item(TTR("Fragment"));
+ edit_type_standart->add_item(TTR("Light"));
+ edit_type_standart->select(1);
+ edit_type_standart->connect("item_selected", callable_mp(this, &VisualShaderEditor::_mode_selected));
+
+ edit_type_particles = memnew(OptionButton);
+ edit_type_particles->add_item(TTR("Emit"));
+ edit_type_particles->add_item(TTR("Process"));
+ edit_type_particles->add_item(TTR("End"));
+ edit_type_particles->select(0);
+ edit_type_particles->connect("item_selected", callable_mp(this, &VisualShaderEditor::_mode_selected));
+
+ edit_type = edit_type_standart;
+
+ graph->get_zoom_hbox()->add_child(edit_type_particles);
+ graph->get_zoom_hbox()->move_child(edit_type_particles, 0);
+ graph->get_zoom_hbox()->add_child(edit_type_standart);
+ graph->get_zoom_hbox()->move_child(edit_type_standart, 0);
add_node = memnew(Button);
add_node->set_flat(true);
@@ -2458,14 +2786,14 @@ VisualShaderEditor::VisualShaderEditor() {
preview_vbox = memnew(VBoxContainer);
preview_vbox->set_visible(preview_showed);
main_box->add_child(preview_vbox);
- preview_text = memnew(TextEdit);
+ preview_text = memnew(CodeEdit);
syntax_highlighter.instance();
preview_vbox->add_child(preview_text);
preview_text->set_h_size_flags(SIZE_EXPAND_FILL);
preview_text->set_v_size_flags(SIZE_EXPAND_FILL);
preview_text->set_custom_minimum_size(Size2(400 * EDSCALE, 0));
preview_text->set_syntax_highlighter(syntax_highlighter);
- preview_text->set_show_line_numbers(true);
+ preview_text->set_draw_line_numbers(true);
preview_text->set_readonly(true);
error_text = memnew(Label);
@@ -2614,6 +2942,7 @@ VisualShaderEditor::VisualShaderEditor() {
// INPUT
// SPATIAL-FOR-ALL
+
const String input_param_shader_modes = TTR("'%s' input parameter for all shader modes.");
add_options.push_back(AddOption("Camera", "Input", "All", "VisualShaderNodeInput", vformat(input_param_shader_modes, "camera"), "camera", VisualShaderNode::PORT_TYPE_TRANSFORM, -1, Shader::MODE_SPATIAL));
add_options.push_back(AddOption("InvCamera", "Input", "All", "VisualShaderNodeInput", vformat(input_param_shader_modes, "inv_camera"), "inv_camera", VisualShaderNode::PORT_TYPE_TRANSFORM, -1, Shader::MODE_SPATIAL));
@@ -2644,124 +2973,156 @@ VisualShaderEditor::VisualShaderEditor() {
const String input_param_for_fragment_shader_mode = TTR("'%s' input parameter for fragment shader mode.");
const String input_param_for_light_shader_mode = TTR("'%s' input parameter for light shader mode.");
const String input_param_for_vertex_shader_mode = TTR("'%s' input parameter for vertex shader mode.");
+ const String input_param_for_emit_shader_mode = TTR("'%s' input parameter for emit shader mode.");
+ const String input_param_for_process_shader_mode = TTR("'%s' input parameter for process shader mode.");
+ const String input_param_for_end_shader_mode = TTR("'%s' input parameter for end shader mode.");
+ const String input_param_for_emit_and_process_shader_mode = TTR("'%s' input parameter for emit and process shader mode.");
const String input_param_for_vertex_and_fragment_shader_mode = TTR("'%s' input parameter for vertex and fragment shader mode.");
- add_options.push_back(AddOption("Alpha", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "alpha"), "alpha", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("Binormal", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "binormal"), "binormal", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("Color", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "color"), "color", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("DepthTexture", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "depth_texture"), "depth_texture", VisualShaderNode::PORT_TYPE_SAMPLER, VisualShader::TYPE_FRAGMENT, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("FragCoord", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_and_light_shader_modes, "fragcoord"), "fragcoord", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("FrontFacing", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "front_facing"), "front_facing", VisualShaderNode::PORT_TYPE_BOOLEAN, VisualShader::TYPE_FRAGMENT, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("PointCoord", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "point_coord"), "point_coord", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("ScreenTexture", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "screen_texture"), "screen_texture", VisualShaderNode::PORT_TYPE_SAMPLER, VisualShader::TYPE_FRAGMENT, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("ScreenUV", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "screen_uv"), "screen_uv", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("Side", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "side"), "side", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("Tangent", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "tangent"), "tangent", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("UV", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "uv"), "uv", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("UV2", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "uv2"), "uv2", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("Vertex", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "vertex"), "vertex", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("View", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_and_light_shader_modes, "view"), "view", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SPATIAL));
-
- add_options.push_back(AddOption("Albedo", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_light_shader_mode, "albedo"), "albedo", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_LIGHT, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("Attenuation", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_light_shader_mode, "attenuation"), "attenuation", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_LIGHT, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("Diffuse", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_light_shader_mode, "diffuse"), "diffuse", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_LIGHT, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("FragCoord", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_fragment_and_light_shader_modes, "fragcoord"), "fragcoord", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_LIGHT, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("Light", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_light_shader_mode, "light"), "light", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_LIGHT, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("LightColor", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_light_shader_mode, "light_color"), "light_color", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_LIGHT, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("Roughness", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_light_shader_mode, "roughness"), "roughness", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_LIGHT, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("Specular", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_light_shader_mode, "specular"), "specular", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_LIGHT, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("Transmission", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_light_shader_mode, "transmission"), "transmission", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_LIGHT, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("View", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_fragment_and_light_shader_modes, "view"), "view", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_LIGHT, Shader::MODE_SPATIAL));
-
- add_options.push_back(AddOption("Alpha", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "alpha"), "alpha", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_VERTEX, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("Binormal", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "binormal"), "binormal", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_VERTEX, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("Color", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "color"), "color", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_VERTEX, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("ModelView", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "modelview"), "modelview", VisualShaderNode::PORT_TYPE_TRANSFORM, VisualShader::TYPE_VERTEX, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("PointSize", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "point_size"), "point_size", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_VERTEX, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("Tangent", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_mode, "tangent"), "tangent", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_VERTEX, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("UV", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "uv"), "uv", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_VERTEX, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("UV2", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "uv2"), "uv2", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_VERTEX, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("Vertex", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "vertex"), "vertex", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_VERTEX, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("Alpha", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "alpha"), "alpha", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_FRAGMENT, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("Binormal", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "binormal"), "binormal", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_FRAGMENT, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("Color", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "color"), "color", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_FRAGMENT, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("DepthTexture", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "depth_texture"), "depth_texture", VisualShaderNode::PORT_TYPE_SAMPLER, TYPE_FLAGS_FRAGMENT, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("FragCoord", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_and_light_shader_modes, "fragcoord"), "fragcoord", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_FRAGMENT, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("FrontFacing", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "front_facing"), "front_facing", VisualShaderNode::PORT_TYPE_BOOLEAN, TYPE_FLAGS_FRAGMENT, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("PointCoord", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "point_coord"), "point_coord", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_FRAGMENT, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("ScreenTexture", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "screen_texture"), "screen_texture", VisualShaderNode::PORT_TYPE_SAMPLER, TYPE_FLAGS_FRAGMENT, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("ScreenUV", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "screen_uv"), "screen_uv", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_FRAGMENT, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("Side", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "side"), "side", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_FRAGMENT, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("Tangent", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "tangent"), "tangent", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_FRAGMENT, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("UV", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "uv"), "uv", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_FRAGMENT, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("UV2", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "uv2"), "uv2", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_FRAGMENT, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("Vertex", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "vertex"), "vertex", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_FRAGMENT, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("View", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_and_light_shader_modes, "view"), "view", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_FRAGMENT, Shader::MODE_SPATIAL));
+
+ add_options.push_back(AddOption("Albedo", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_light_shader_mode, "albedo"), "albedo", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_LIGHT, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("Attenuation", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_light_shader_mode, "attenuation"), "attenuation", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_LIGHT, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("Diffuse", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_light_shader_mode, "diffuse"), "diffuse", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_LIGHT, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("FragCoord", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_fragment_and_light_shader_modes, "fragcoord"), "fragcoord", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_LIGHT, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("Light", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_light_shader_mode, "light"), "light", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_LIGHT, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("LightColor", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_light_shader_mode, "light_color"), "light_color", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_LIGHT, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("Roughness", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_light_shader_mode, "roughness"), "roughness", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_LIGHT, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("Specular", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_light_shader_mode, "specular"), "specular", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_LIGHT, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("Transmission", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_light_shader_mode, "transmission"), "transmission", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_LIGHT, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("View", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_fragment_and_light_shader_modes, "view"), "view", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_LIGHT, Shader::MODE_SPATIAL));
+
+ add_options.push_back(AddOption("Alpha", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "alpha"), "alpha", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_VERTEX, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("Binormal", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "binormal"), "binormal", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_VERTEX, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("Color", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "color"), "color", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_VERTEX, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("ModelView", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "modelview"), "modelview", VisualShaderNode::PORT_TYPE_TRANSFORM, TYPE_FLAGS_VERTEX, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("PointSize", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "point_size"), "point_size", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_VERTEX, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("Tangent", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_mode, "tangent"), "tangent", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_VERTEX, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("UV", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "uv"), "uv", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_VERTEX, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("UV2", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "uv2"), "uv2", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_VERTEX, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("Vertex", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "vertex"), "vertex", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_VERTEX, Shader::MODE_SPATIAL));
// CANVASITEM INPUTS
- add_options.push_back(AddOption("FragCoord", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_and_light_shader_modes, "fragcoord"), "fragcoord", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_CANVAS_ITEM));
- add_options.push_back(AddOption("LightPass", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "light_pass"), "light_pass", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_FRAGMENT, Shader::MODE_CANVAS_ITEM));
- add_options.push_back(AddOption("NormalTexture", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "normal_texture"), "normal_texture", VisualShaderNode::PORT_TYPE_SAMPLER, VisualShader::TYPE_FRAGMENT, Shader::MODE_CANVAS_ITEM));
- add_options.push_back(AddOption("PointCoord", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_and_light_shader_modes, "point_coord"), "point_coord", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_CANVAS_ITEM));
- add_options.push_back(AddOption("ScreenPixelSize", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "screen_pixel_size"), "screen_pixel_size", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_CANVAS_ITEM));
- add_options.push_back(AddOption("ScreenTexture", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "screen_texture"), "screen_texture", VisualShaderNode::PORT_TYPE_SAMPLER, VisualShader::TYPE_FRAGMENT, Shader::MODE_CANVAS_ITEM));
- add_options.push_back(AddOption("ScreenUV", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_and_light_shader_modes, "screen_uv"), "screen_uv", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_CANVAS_ITEM));
- add_options.push_back(AddOption("Texture", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_and_light_shader_modes, "texture"), "texture", VisualShaderNode::PORT_TYPE_SAMPLER, VisualShader::TYPE_FRAGMENT, Shader::MODE_CANVAS_ITEM));
-
- add_options.push_back(AddOption("FragCoord", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_fragment_and_light_shader_modes, "fragcoord"), "fragcoord", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_LIGHT, Shader::MODE_CANVAS_ITEM));
- add_options.push_back(AddOption("LightAlpha", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_light_shader_mode, "light_alpha"), "light_alpha", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_LIGHT, Shader::MODE_CANVAS_ITEM));
- add_options.push_back(AddOption("LightColor", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_light_shader_mode, "light_color"), "light_color", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_LIGHT, Shader::MODE_CANVAS_ITEM));
- add_options.push_back(AddOption("LightHeight", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_light_shader_mode, "light_height"), "light_height", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_LIGHT, Shader::MODE_CANVAS_ITEM));
- add_options.push_back(AddOption("LightUV", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_light_shader_mode, "light_uv"), "light_uv", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_LIGHT, Shader::MODE_CANVAS_ITEM));
- add_options.push_back(AddOption("LightVector", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_light_shader_mode, "light_vec"), "light_vec", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_LIGHT, Shader::MODE_CANVAS_ITEM));
- add_options.push_back(AddOption("Normal", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_light_shader_mode, "normal"), "normal", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_LIGHT, Shader::MODE_CANVAS_ITEM));
- add_options.push_back(AddOption("PointCoord", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_fragment_and_light_shader_modes, "point_coord"), "point_coord", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_LIGHT, Shader::MODE_CANVAS_ITEM));
- add_options.push_back(AddOption("ScreenUV", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_fragment_and_light_shader_modes, "screen_uv"), "screen_uv", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_LIGHT, Shader::MODE_CANVAS_ITEM));
- add_options.push_back(AddOption("ShadowAlpha", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_light_shader_mode, "shadow_alpha"), "shadow_alpha", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_LIGHT, Shader::MODE_CANVAS_ITEM));
- add_options.push_back(AddOption("ShadowColor", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_light_shader_mode, "shadow_color"), "shadow_color", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_LIGHT, Shader::MODE_CANVAS_ITEM));
- add_options.push_back(AddOption("ShadowVec", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_light_shader_mode, "shadow_vec"), "shadow_vec", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_LIGHT, Shader::MODE_CANVAS_ITEM));
- add_options.push_back(AddOption("Texture", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_fragment_and_light_shader_modes, "texture"), "texture", VisualShaderNode::PORT_TYPE_SAMPLER, VisualShader::TYPE_LIGHT, Shader::MODE_CANVAS_ITEM));
-
- add_options.push_back(AddOption("Extra", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "extra"), "extra", VisualShaderNode::PORT_TYPE_TRANSFORM, VisualShader::TYPE_VERTEX, Shader::MODE_CANVAS_ITEM));
- add_options.push_back(AddOption("LightPass", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "light_pass"), "light_pass", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_VERTEX, Shader::MODE_CANVAS_ITEM));
- add_options.push_back(AddOption("PointSize", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "point_size"), "point_size", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_VERTEX, Shader::MODE_CANVAS_ITEM));
- add_options.push_back(AddOption("Projection", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "projection"), "projection", VisualShaderNode::PORT_TYPE_TRANSFORM, VisualShader::TYPE_VERTEX, Shader::MODE_CANVAS_ITEM));
- add_options.push_back(AddOption("Vertex", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "vertex"), "vertex", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_VERTEX, Shader::MODE_CANVAS_ITEM));
- add_options.push_back(AddOption("World", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "world"), "world", VisualShaderNode::PORT_TYPE_TRANSFORM, VisualShader::TYPE_VERTEX, Shader::MODE_CANVAS_ITEM));
+ add_options.push_back(AddOption("FragCoord", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_and_light_shader_modes, "fragcoord"), "fragcoord", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_FRAGMENT, Shader::MODE_CANVAS_ITEM));
+ add_options.push_back(AddOption("LightPass", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "light_pass"), "light_pass", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_FRAGMENT, Shader::MODE_CANVAS_ITEM));
+ add_options.push_back(AddOption("NormalTexture", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "normal_texture"), "normal_texture", VisualShaderNode::PORT_TYPE_SAMPLER, TYPE_FLAGS_FRAGMENT, Shader::MODE_CANVAS_ITEM));
+ add_options.push_back(AddOption("PointCoord", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_and_light_shader_modes, "point_coord"), "point_coord", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_FRAGMENT, Shader::MODE_CANVAS_ITEM));
+ add_options.push_back(AddOption("ScreenPixelSize", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "screen_pixel_size"), "screen_pixel_size", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_FRAGMENT, Shader::MODE_CANVAS_ITEM));
+ add_options.push_back(AddOption("ScreenTexture", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "screen_texture"), "screen_texture", VisualShaderNode::PORT_TYPE_SAMPLER, TYPE_FLAGS_FRAGMENT, Shader::MODE_CANVAS_ITEM));
+ add_options.push_back(AddOption("ScreenUV", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_and_light_shader_modes, "screen_uv"), "screen_uv", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_FRAGMENT, Shader::MODE_CANVAS_ITEM));
+ add_options.push_back(AddOption("Texture", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_and_light_shader_modes, "texture"), "texture", VisualShaderNode::PORT_TYPE_SAMPLER, TYPE_FLAGS_FRAGMENT, Shader::MODE_CANVAS_ITEM));
+
+ add_options.push_back(AddOption("FragCoord", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_fragment_and_light_shader_modes, "fragcoord"), "fragcoord", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_LIGHT, Shader::MODE_CANVAS_ITEM));
+ add_options.push_back(AddOption("LightAlpha", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_light_shader_mode, "light_alpha"), "light_alpha", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_LIGHT, Shader::MODE_CANVAS_ITEM));
+ add_options.push_back(AddOption("LightColor", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_light_shader_mode, "light_color"), "light_color", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_LIGHT, Shader::MODE_CANVAS_ITEM));
+ add_options.push_back(AddOption("LightHeight", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_light_shader_mode, "light_height"), "light_height", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_LIGHT, Shader::MODE_CANVAS_ITEM));
+ add_options.push_back(AddOption("LightUV", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_light_shader_mode, "light_uv"), "light_uv", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_LIGHT, Shader::MODE_CANVAS_ITEM));
+ add_options.push_back(AddOption("LightVector", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_light_shader_mode, "light_vec"), "light_vec", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_LIGHT, Shader::MODE_CANVAS_ITEM));
+ add_options.push_back(AddOption("Normal", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_light_shader_mode, "normal"), "normal", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_LIGHT, Shader::MODE_CANVAS_ITEM));
+ add_options.push_back(AddOption("PointCoord", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_fragment_and_light_shader_modes, "point_coord"), "point_coord", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_LIGHT, Shader::MODE_CANVAS_ITEM));
+ add_options.push_back(AddOption("ScreenUV", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_fragment_and_light_shader_modes, "screen_uv"), "screen_uv", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_LIGHT, Shader::MODE_CANVAS_ITEM));
+ add_options.push_back(AddOption("ShadowAlpha", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_light_shader_mode, "shadow_alpha"), "shadow_alpha", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_LIGHT, Shader::MODE_CANVAS_ITEM));
+ add_options.push_back(AddOption("ShadowColor", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_light_shader_mode, "shadow_color"), "shadow_color", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_LIGHT, Shader::MODE_CANVAS_ITEM));
+ add_options.push_back(AddOption("ShadowVec", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_light_shader_mode, "shadow_vec"), "shadow_vec", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_LIGHT, Shader::MODE_CANVAS_ITEM));
+ add_options.push_back(AddOption("Texture", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_fragment_and_light_shader_modes, "texture"), "texture", VisualShaderNode::PORT_TYPE_SAMPLER, TYPE_FLAGS_LIGHT, Shader::MODE_CANVAS_ITEM));
+
+ add_options.push_back(AddOption("Extra", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "extra"), "extra", VisualShaderNode::PORT_TYPE_TRANSFORM, TYPE_FLAGS_VERTEX, Shader::MODE_CANVAS_ITEM));
+ add_options.push_back(AddOption("LightPass", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "light_pass"), "light_pass", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_VERTEX, Shader::MODE_CANVAS_ITEM));
+ add_options.push_back(AddOption("PointSize", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "point_size"), "point_size", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_VERTEX, Shader::MODE_CANVAS_ITEM));
+ add_options.push_back(AddOption("Projection", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "projection"), "projection", VisualShaderNode::PORT_TYPE_TRANSFORM, TYPE_FLAGS_VERTEX, Shader::MODE_CANVAS_ITEM));
+ add_options.push_back(AddOption("Vertex", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "vertex"), "vertex", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_VERTEX, Shader::MODE_CANVAS_ITEM));
+ add_options.push_back(AddOption("World", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "world"), "world", VisualShaderNode::PORT_TYPE_TRANSFORM, TYPE_FLAGS_VERTEX, Shader::MODE_CANVAS_ITEM));
// PARTICLES INPUTS
- add_options.push_back(AddOption("Active", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "active"), "active", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_VERTEX, Shader::MODE_PARTICLES));
- add_options.push_back(AddOption("Alpha", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "alpha"), "alpha", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_VERTEX, Shader::MODE_PARTICLES));
- add_options.push_back(AddOption("Color", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "color"), "color", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_VERTEX, Shader::MODE_PARTICLES));
- add_options.push_back(AddOption("Custom", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "custom"), "custom", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_VERTEX, Shader::MODE_PARTICLES));
- 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_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));
- add_options.push_back(AddOption("Transform", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "transform"), "transform", VisualShaderNode::PORT_TYPE_TRANSFORM, VisualShader::TYPE_VERTEX, Shader::MODE_PARTICLES));
- add_options.push_back(AddOption("Velocity", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "velocity"), "velocity", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_VERTEX, Shader::MODE_PARTICLES));
+ add_options.push_back(AddOption("Active", "Input", "Emit", "VisualShaderNodeInput", vformat(input_param_shader_modes, "active"), "active", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_EMIT, Shader::MODE_PARTICLES));
+ add_options.push_back(AddOption("Alpha", "Input", "Emit", "VisualShaderNodeInput", vformat(input_param_shader_modes, "alpha"), "alpha", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_EMIT, Shader::MODE_PARTICLES));
+ add_options.push_back(AddOption("Color", "Input", "Emit", "VisualShaderNodeInput", vformat(input_param_shader_modes, "color"), "color", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_EMIT, Shader::MODE_PARTICLES));
+ add_options.push_back(AddOption("Custom", "Input", "Emit", "VisualShaderNodeInput", vformat(input_param_shader_modes, "custom"), "custom", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_EMIT, Shader::MODE_PARTICLES));
+ add_options.push_back(AddOption("CustomAlpha", "Input", "Emit", "VisualShaderNodeInput", vformat(input_param_shader_modes, "custom_alpha"), "custom_alpha", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_EMIT, Shader::MODE_PARTICLES));
+ add_options.push_back(AddOption("Delta", "Input", "Emit", "VisualShaderNodeInput", vformat(input_param_shader_modes, "delta"), "delta", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_EMIT, Shader::MODE_PARTICLES));
+ add_options.push_back(AddOption("EmissionTransform", "Input", "Emit", "VisualShaderNodeInput", vformat(input_param_shader_modes, "emission_transform"), "emission_transform", VisualShaderNode::PORT_TYPE_TRANSFORM, TYPE_FLAGS_EMIT, Shader::MODE_PARTICLES));
+ add_options.push_back(AddOption("Index", "Input", "Emit", "VisualShaderNodeInput", vformat(input_param_shader_modes, "index"), "index", VisualShaderNode::PORT_TYPE_SCALAR_INT, TYPE_FLAGS_EMIT, Shader::MODE_PARTICLES));
+ add_options.push_back(AddOption("LifeTime", "Input", "Emit", "VisualShaderNodeInput", vformat(input_param_shader_modes, "lifetime"), "lifetime", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_EMIT, Shader::MODE_PARTICLES));
+ add_options.push_back(AddOption("Restart", "Input", "Emit", "VisualShaderNodeInput", vformat(input_param_shader_modes, "restart"), "restart", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_EMIT, Shader::MODE_PARTICLES));
+ add_options.push_back(AddOption("Time", "Input", "Emit", "VisualShaderNodeInput", vformat(input_param_shader_modes, "time"), "time", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_EMIT, Shader::MODE_PARTICLES));
+ add_options.push_back(AddOption("Transform", "Input", "Emit", "VisualShaderNodeInput", vformat(input_param_shader_modes, "transform"), "transform", VisualShaderNode::PORT_TYPE_TRANSFORM, TYPE_FLAGS_EMIT, Shader::MODE_PARTICLES));
+ add_options.push_back(AddOption("Velocity", "Input", "Emit", "VisualShaderNodeInput", vformat(input_param_shader_modes, "velocity"), "velocity", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_EMIT, Shader::MODE_PARTICLES));
+
+ add_options.push_back(AddOption("Active", "Input", "Process", "VisualShaderNodeInput", vformat(input_param_shader_modes, "active"), "active", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_PROCESS, Shader::MODE_PARTICLES));
+ add_options.push_back(AddOption("Alpha", "Input", "Process", "VisualShaderNodeInput", vformat(input_param_shader_modes, "alpha"), "alpha", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_PROCESS, Shader::MODE_PARTICLES));
+ add_options.push_back(AddOption("Color", "Input", "Process", "VisualShaderNodeInput", vformat(input_param_shader_modes, "color"), "color", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_PROCESS, Shader::MODE_PARTICLES));
+ add_options.push_back(AddOption("Custom", "Input", "Process", "VisualShaderNodeInput", vformat(input_param_shader_modes, "custom"), "custom", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_PROCESS, Shader::MODE_PARTICLES));
+ add_options.push_back(AddOption("CustomAlpha", "Input", "Process", "VisualShaderNodeInput", vformat(input_param_shader_modes, "custom_alpha"), "custom_alpha", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_PROCESS, Shader::MODE_PARTICLES));
+ add_options.push_back(AddOption("Delta", "Input", "Process", "VisualShaderNodeInput", vformat(input_param_shader_modes, "delta"), "delta", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_PROCESS, Shader::MODE_PARTICLES));
+ add_options.push_back(AddOption("EmissionTransform", "Input", "Process", "VisualShaderNodeInput", vformat(input_param_shader_modes, "emission_transform"), "emission_transform", VisualShaderNode::PORT_TYPE_TRANSFORM, TYPE_FLAGS_PROCESS, Shader::MODE_PARTICLES));
+ add_options.push_back(AddOption("Index", "Input", "Process", "VisualShaderNodeInput", vformat(input_param_shader_modes, "index"), "index", VisualShaderNode::PORT_TYPE_SCALAR_INT, TYPE_FLAGS_PROCESS, Shader::MODE_PARTICLES));
+ add_options.push_back(AddOption("LifeTime", "Input", "Process", "VisualShaderNodeInput", vformat(input_param_shader_modes, "lifetime"), "lifetime", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_PROCESS, Shader::MODE_PARTICLES));
+ add_options.push_back(AddOption("Restart", "Input", "Process", "VisualShaderNodeInput", vformat(input_param_shader_modes, "restart"), "restart", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_PROCESS, Shader::MODE_PARTICLES));
+ add_options.push_back(AddOption("Time", "Input", "Process", "VisualShaderNodeInput", vformat(input_param_shader_modes, "time"), "time", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_PROCESS, Shader::MODE_PARTICLES));
+ add_options.push_back(AddOption("Transform", "Input", "Process", "VisualShaderNodeInput", vformat(input_param_shader_modes, "transform"), "transform", VisualShaderNode::PORT_TYPE_TRANSFORM, TYPE_FLAGS_PROCESS, Shader::MODE_PARTICLES));
+ add_options.push_back(AddOption("Velocity", "Input", "Process", "VisualShaderNodeInput", vformat(input_param_shader_modes, "velocity"), "velocity", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_PROCESS, Shader::MODE_PARTICLES));
+
+ add_options.push_back(AddOption("Active", "Input", "End", "VisualShaderNodeInput", vformat(input_param_shader_modes, "active"), "active", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_END, Shader::MODE_PARTICLES));
+ add_options.push_back(AddOption("Alpha", "Input", "End", "VisualShaderNodeInput", vformat(input_param_shader_modes, "alpha"), "alpha", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_END, Shader::MODE_PARTICLES));
+ add_options.push_back(AddOption("Color", "Input", "End", "VisualShaderNodeInput", vformat(input_param_shader_modes, "color"), "color", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_END, Shader::MODE_PARTICLES));
+ add_options.push_back(AddOption("Custom", "Input", "End", "VisualShaderNodeInput", vformat(input_param_shader_modes, "custom"), "custom", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_END, Shader::MODE_PARTICLES));
+ add_options.push_back(AddOption("CustomAlpha", "Input", "End", "VisualShaderNodeInput", vformat(input_param_shader_modes, "custom_alpha"), "custom_alpha", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_END, Shader::MODE_PARTICLES));
+ add_options.push_back(AddOption("Delta", "Input", "End", "VisualShaderNodeInput", vformat(input_param_shader_modes, "delta"), "delta", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_END, Shader::MODE_PARTICLES));
+ add_options.push_back(AddOption("EmissionTransform", "Input", "End", "VisualShaderNodeInput", vformat(input_param_shader_modes, "emission_transform"), "emission_transform", VisualShaderNode::PORT_TYPE_TRANSFORM, TYPE_FLAGS_END, Shader::MODE_PARTICLES));
+ add_options.push_back(AddOption("Index", "Input", "End", "VisualShaderNodeInput", vformat(input_param_shader_modes, "index"), "index", VisualShaderNode::PORT_TYPE_SCALAR_INT, TYPE_FLAGS_END, Shader::MODE_PARTICLES));
+ add_options.push_back(AddOption("LifeTime", "Input", "End", "VisualShaderNodeInput", vformat(input_param_shader_modes, "lifetime"), "lifetime", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_END, Shader::MODE_PARTICLES));
+ add_options.push_back(AddOption("Restart", "Input", "End", "VisualShaderNodeInput", vformat(input_param_shader_modes, "restart"), "restart", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_END, Shader::MODE_PARTICLES));
+ add_options.push_back(AddOption("Time", "Input", "End", "VisualShaderNodeInput", vformat(input_param_shader_modes, "time"), "time", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_END, Shader::MODE_PARTICLES));
+ add_options.push_back(AddOption("Transform", "Input", "End", "VisualShaderNodeInput", vformat(input_param_shader_modes, "transform"), "transform", VisualShaderNode::PORT_TYPE_TRANSFORM, TYPE_FLAGS_END, Shader::MODE_PARTICLES));
+ add_options.push_back(AddOption("Velocity", "Input", "End", "VisualShaderNodeInput", vformat(input_param_shader_modes, "velocity"), "velocity", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_END, Shader::MODE_PARTICLES));
// SKY INPUTS
- add_options.push_back(AddOption("AtCubeMapPass", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "at_cubemap_pass"), "at_cubemap_pass", VisualShaderNode::PORT_TYPE_BOOLEAN, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY));
- add_options.push_back(AddOption("AtHalfResPass", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "at_half_res_pass"), "at_half_res_pass", VisualShaderNode::PORT_TYPE_BOOLEAN, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY));
- add_options.push_back(AddOption("AtQuarterResPass", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "at_quarter_res_pass"), "at_quarter_res_pass", VisualShaderNode::PORT_TYPE_BOOLEAN, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY));
- add_options.push_back(AddOption("EyeDir", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "eyedir"), "eyedir", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY));
- add_options.push_back(AddOption("HalfResColor", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "half_res_color"), "half_res_color", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY));
- add_options.push_back(AddOption("HalfResAlpha", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "half_res_alpha"), "half_res_alpha", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY));
- add_options.push_back(AddOption("Light0Color", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light0_color"), "light0_color", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY));
- add_options.push_back(AddOption("Light0Direction", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light0_direction"), "light0_direction", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY));
- add_options.push_back(AddOption("Light0Enabled", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light0_enabled"), "light0_enabled", VisualShaderNode::PORT_TYPE_BOOLEAN, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY));
- add_options.push_back(AddOption("Light0Energy", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light0_energy"), "light0_energy", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY));
- add_options.push_back(AddOption("Light1Color", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light1_color"), "light1_color", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY));
- add_options.push_back(AddOption("Light1Direction", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light1_direction"), "light1_direction", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY));
- add_options.push_back(AddOption("Light1Enabled", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light1_enabled"), "light1_enabled", VisualShaderNode::PORT_TYPE_BOOLEAN, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY));
- add_options.push_back(AddOption("Light1Energy", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light1_energy"), "light1_energy", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY));
- add_options.push_back(AddOption("Light2Color", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light2_color"), "light2_color", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY));
- add_options.push_back(AddOption("Light2Direction", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light2_direction"), "light2_direction", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY));
- add_options.push_back(AddOption("Light2Enabled", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light2_enabled"), "light2_enabled", VisualShaderNode::PORT_TYPE_BOOLEAN, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY));
- add_options.push_back(AddOption("Light2Energy", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light2_energy"), "light2_energy", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY));
- add_options.push_back(AddOption("Light3Color", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light3_color"), "light3_color", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY));
- add_options.push_back(AddOption("Light3Direction", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light3_direction"), "light3_direction", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY));
- add_options.push_back(AddOption("Light3Enabled", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light3_enabled"), "light3_enabled", VisualShaderNode::PORT_TYPE_BOOLEAN, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY));
- add_options.push_back(AddOption("Light3Energy", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light3_energy"), "light3_energy", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY));
- add_options.push_back(AddOption("Position", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "position"), "position", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY));
- add_options.push_back(AddOption("QuarterResColor", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "quarter_res_color"), "quarter_res_color", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY));
- add_options.push_back(AddOption("QuarterResAlpha", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "quarter_res_alpha"), "quarter_res_alpha", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY));
- add_options.push_back(AddOption("Radiance", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "radiance"), "radiance", VisualShaderNode::PORT_TYPE_SAMPLER, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY));
- add_options.push_back(AddOption("ScreenUV", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "screen_uv"), "screen_uv", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY));
- add_options.push_back(AddOption("SkyCoords", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "sky_coords"), "sky_coords", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY));
- add_options.push_back(AddOption("Time", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "time"), "time", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY));
+ add_options.push_back(AddOption("AtCubeMapPass", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "at_cubemap_pass"), "at_cubemap_pass", VisualShaderNode::PORT_TYPE_BOOLEAN, TYPE_FLAGS_FRAGMENT, Shader::MODE_SKY));
+ add_options.push_back(AddOption("AtHalfResPass", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "at_half_res_pass"), "at_half_res_pass", VisualShaderNode::PORT_TYPE_BOOLEAN, TYPE_FLAGS_FRAGMENT, Shader::MODE_SKY));
+ add_options.push_back(AddOption("AtQuarterResPass", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "at_quarter_res_pass"), "at_quarter_res_pass", VisualShaderNode::PORT_TYPE_BOOLEAN, TYPE_FLAGS_FRAGMENT, Shader::MODE_SKY));
+ add_options.push_back(AddOption("EyeDir", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "eyedir"), "eyedir", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_FRAGMENT, Shader::MODE_SKY));
+ add_options.push_back(AddOption("HalfResColor", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "half_res_color"), "half_res_color", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_FRAGMENT, Shader::MODE_SKY));
+ add_options.push_back(AddOption("HalfResAlpha", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "half_res_alpha"), "half_res_alpha", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_FRAGMENT, Shader::MODE_SKY));
+ add_options.push_back(AddOption("Light0Color", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light0_color"), "light0_color", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_FRAGMENT, Shader::MODE_SKY));
+ add_options.push_back(AddOption("Light0Direction", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light0_direction"), "light0_direction", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_FRAGMENT, Shader::MODE_SKY));
+ add_options.push_back(AddOption("Light0Enabled", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light0_enabled"), "light0_enabled", VisualShaderNode::PORT_TYPE_BOOLEAN, TYPE_FLAGS_FRAGMENT, Shader::MODE_SKY));
+ add_options.push_back(AddOption("Light0Energy", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light0_energy"), "light0_energy", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_FRAGMENT, Shader::MODE_SKY));
+ add_options.push_back(AddOption("Light1Color", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light1_color"), "light1_color", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_FRAGMENT, Shader::MODE_SKY));
+ add_options.push_back(AddOption("Light1Direction", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light1_direction"), "light1_direction", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_FRAGMENT, Shader::MODE_SKY));
+ add_options.push_back(AddOption("Light1Enabled", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light1_enabled"), "light1_enabled", VisualShaderNode::PORT_TYPE_BOOLEAN, TYPE_FLAGS_FRAGMENT, Shader::MODE_SKY));
+ add_options.push_back(AddOption("Light1Energy", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light1_energy"), "light1_energy", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_FRAGMENT, Shader::MODE_SKY));
+ add_options.push_back(AddOption("Light2Color", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light2_color"), "light2_color", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_FRAGMENT, Shader::MODE_SKY));
+ add_options.push_back(AddOption("Light2Direction", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light2_direction"), "light2_direction", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_FRAGMENT, Shader::MODE_SKY));
+ add_options.push_back(AddOption("Light2Enabled", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light2_enabled"), "light2_enabled", VisualShaderNode::PORT_TYPE_BOOLEAN, TYPE_FLAGS_FRAGMENT, Shader::MODE_SKY));
+ add_options.push_back(AddOption("Light2Energy", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light2_energy"), "light2_energy", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_FRAGMENT, Shader::MODE_SKY));
+ add_options.push_back(AddOption("Light3Color", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light3_color"), "light3_color", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_FRAGMENT, Shader::MODE_SKY));
+ add_options.push_back(AddOption("Light3Direction", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light3_direction"), "light3_direction", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_FRAGMENT, Shader::MODE_SKY));
+ add_options.push_back(AddOption("Light3Enabled", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light3_enabled"), "light3_enabled", VisualShaderNode::PORT_TYPE_BOOLEAN, TYPE_FLAGS_FRAGMENT, Shader::MODE_SKY));
+ add_options.push_back(AddOption("Light3Energy", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light3_energy"), "light3_energy", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_FRAGMENT, Shader::MODE_SKY));
+ add_options.push_back(AddOption("Position", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "position"), "position", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_FRAGMENT, Shader::MODE_SKY));
+ add_options.push_back(AddOption("QuarterResColor", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "quarter_res_color"), "quarter_res_color", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_FRAGMENT, Shader::MODE_SKY));
+ add_options.push_back(AddOption("QuarterResAlpha", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "quarter_res_alpha"), "quarter_res_alpha", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_FRAGMENT, Shader::MODE_SKY));
+ add_options.push_back(AddOption("Radiance", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "radiance"), "radiance", VisualShaderNode::PORT_TYPE_SAMPLER, TYPE_FLAGS_FRAGMENT, Shader::MODE_SKY));
+ add_options.push_back(AddOption("ScreenUV", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "screen_uv"), "screen_uv", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_FRAGMENT, Shader::MODE_SKY));
+ add_options.push_back(AddOption("SkyCoords", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "sky_coords"), "sky_coords", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_FRAGMENT, Shader::MODE_SKY));
+ add_options.push_back(AddOption("Time", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "time"), "time", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_FRAGMENT, Shader::MODE_SKY));
// SCALAR
@@ -2849,12 +3210,15 @@ VisualShaderEditor::VisualShaderEditor() {
add_options.push_back(AddOption("CubeMap", "Textures", "Functions", "VisualShaderNodeCubemap", TTR("Perform the cubic texture lookup."), -1, -1));
texture_node_option_idx = add_options.size();
- add_options.push_back(AddOption("Texture2D", "Textures", "Functions", "VisualShaderNodeTexture", TTR("Perform the texture lookup."), -1, -1));
- add_options.push_back(AddOption("CubeMapUniform", "Textures", "Variables", "VisualShaderNodeCubemapUniform", TTR("Cubic texture uniform lookup."), -1, -1));
+ add_options.push_back(AddOption("Texture2D", "Textures", "Functions", "VisualShaderNodeTexture", TTR("Perform the 2D texture lookup."), -1, -1));
add_options.push_back(AddOption("Texture2DArray", "Textures", "Functions", "VisualShaderNodeTexture2DArray", TTR("Perform the 2D-array texture lookup."), -1, -1, -1, -1, -1));
+ add_options.push_back(AddOption("Texture3D", "Textures", "Functions", "VisualShaderNodeTexture3D", TTR("Perform the 3D texture lookup."), -1, -1));
+
+ add_options.push_back(AddOption("CubeMapUniform", "Textures", "Variables", "VisualShaderNodeCubemapUniform", TTR("Cubic texture uniform lookup."), -1, -1));
add_options.push_back(AddOption("TextureUniform", "Textures", "Variables", "VisualShaderNodeTextureUniform", TTR("2D texture uniform lookup."), -1, -1));
- add_options.push_back(AddOption("TextureUniformTriplanar", "Textures", "Variables", "VisualShaderNodeTextureUniformTriplanar", TTR("2D texture uniform lookup with triplanar."), -1, -1, VisualShader::TYPE_FRAGMENT | VisualShader::TYPE_LIGHT, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("TextureUniformTriplanar", "Textures", "Variables", "VisualShaderNodeTextureUniformTriplanar", TTR("2D texture uniform lookup with triplanar."), -1, -1, TYPE_FLAGS_FRAGMENT | TYPE_FLAGS_LIGHT, Shader::MODE_SPATIAL));
add_options.push_back(AddOption("Texture2DArrayUniform", "Textures", "Variables", "VisualShaderNodeTexture2DArrayUniform", TTR("2D array of textures uniform lookup."), -1, -1, -1, -1, -1));
+ add_options.push_back(AddOption("Texture3DUniform", "Textures", "Variables", "VisualShaderNodeTexture3DUniform", TTR("3D texture uniform lookup."), -1, -1, -1, -1, -1));
// TRANSFORM
@@ -2951,15 +3315,15 @@ VisualShaderEditor::VisualShaderEditor() {
add_options.push_back(AddOption("GlobalExpression", "Special", "", "VisualShaderNodeGlobalExpression", TTR("Custom Godot Shader Language expression, which is placed on top of the resulted shader. You can place various function definitions inside and call it later in the Expressions. You can also declare varyings, uniforms and constants.")));
add_options.push_back(AddOption("UniformRef", "Special", "", "VisualShaderNodeUniformRef", TTR("A reference to an existing uniform.")));
- add_options.push_back(AddOption("ScalarDerivativeFunc", "Special", "Common", "VisualShaderNodeScalarDerivativeFunc", TTR("(Fragment/Light mode only) Scalar derivative function."), -1, VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_FRAGMENT | VisualShader::TYPE_LIGHT, -1, -1, true));
- add_options.push_back(AddOption("VectorDerivativeFunc", "Special", "Common", "VisualShaderNodeVectorDerivativeFunc", TTR("(Fragment/Light mode only) Vector derivative function."), -1, VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT | VisualShader::TYPE_LIGHT, -1, -1, true));
+ add_options.push_back(AddOption("ScalarDerivativeFunc", "Special", "Common", "VisualShaderNodeScalarDerivativeFunc", TTR("(Fragment/Light mode only) Scalar derivative function."), -1, VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_FRAGMENT | TYPE_FLAGS_LIGHT, -1, -1, true));
+ add_options.push_back(AddOption("VectorDerivativeFunc", "Special", "Common", "VisualShaderNodeVectorDerivativeFunc", TTR("(Fragment/Light mode only) Vector derivative function."), -1, VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_FRAGMENT | TYPE_FLAGS_LIGHT, -1, -1, true));
- add_options.push_back(AddOption("DdX", "Special", "Derivative", "VisualShaderNodeVectorDerivativeFunc", TTR("(Fragment/Light mode only) (Vector) Derivative in 'x' using local differencing."), VisualShaderNodeVectorDerivativeFunc::FUNC_X, VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT | VisualShader::TYPE_LIGHT, -1, -1, true));
- add_options.push_back(AddOption("DdXS", "Special", "Derivative", "VisualShaderNodeScalarDerivativeFunc", TTR("(Fragment/Light mode only) (Scalar) Derivative in 'x' using local differencing."), VisualShaderNodeScalarDerivativeFunc::FUNC_X, VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_FRAGMENT | VisualShader::TYPE_LIGHT, -1, -1, true));
- add_options.push_back(AddOption("DdY", "Special", "Derivative", "VisualShaderNodeVectorDerivativeFunc", TTR("(Fragment/Light mode only) (Vector) Derivative in 'y' using local differencing."), VisualShaderNodeVectorDerivativeFunc::FUNC_Y, VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT | VisualShader::TYPE_LIGHT, -1, -1, true));
- add_options.push_back(AddOption("DdYS", "Special", "Derivative", "VisualShaderNodeScalarDerivativeFunc", TTR("(Fragment/Light mode only) (Scalar) Derivative in 'y' using local differencing."), VisualShaderNodeScalarDerivativeFunc::FUNC_Y, VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_FRAGMENT | VisualShader::TYPE_LIGHT, -1, -1, true));
- add_options.push_back(AddOption("Sum", "Special", "Derivative", "VisualShaderNodeVectorDerivativeFunc", TTR("(Fragment/Light mode only) (Vector) Sum of absolute derivative in 'x' and 'y'."), VisualShaderNodeVectorDerivativeFunc::FUNC_SUM, VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT | VisualShader::TYPE_LIGHT, -1, -1, true));
- add_options.push_back(AddOption("SumS", "Special", "Derivative", "VisualShaderNodeScalarDerivativeFunc", TTR("(Fragment/Light mode only) (Scalar) Sum of absolute derivative in 'x' and 'y'."), VisualShaderNodeScalarDerivativeFunc::FUNC_SUM, VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_FRAGMENT | VisualShader::TYPE_LIGHT, -1, -1, true));
+ add_options.push_back(AddOption("DdX", "Special", "Derivative", "VisualShaderNodeVectorDerivativeFunc", TTR("(Fragment/Light mode only) (Vector) Derivative in 'x' using local differencing."), VisualShaderNodeVectorDerivativeFunc::FUNC_X, VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_FRAGMENT | TYPE_FLAGS_LIGHT, -1, -1, true));
+ add_options.push_back(AddOption("DdXS", "Special", "Derivative", "VisualShaderNodeScalarDerivativeFunc", TTR("(Fragment/Light mode only) (Scalar) Derivative in 'x' using local differencing."), VisualShaderNodeScalarDerivativeFunc::FUNC_X, VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_FRAGMENT | TYPE_FLAGS_LIGHT, -1, -1, true));
+ add_options.push_back(AddOption("DdY", "Special", "Derivative", "VisualShaderNodeVectorDerivativeFunc", TTR("(Fragment/Light mode only) (Vector) Derivative in 'y' using local differencing."), VisualShaderNodeVectorDerivativeFunc::FUNC_Y, VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_FRAGMENT | TYPE_FLAGS_LIGHT, -1, -1, true));
+ add_options.push_back(AddOption("DdYS", "Special", "Derivative", "VisualShaderNodeScalarDerivativeFunc", TTR("(Fragment/Light mode only) (Scalar) Derivative in 'y' using local differencing."), VisualShaderNodeScalarDerivativeFunc::FUNC_Y, VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_FRAGMENT | TYPE_FLAGS_LIGHT, -1, -1, true));
+ add_options.push_back(AddOption("Sum", "Special", "Derivative", "VisualShaderNodeVectorDerivativeFunc", TTR("(Fragment/Light mode only) (Vector) Sum of absolute derivative in 'x' and 'y'."), VisualShaderNodeVectorDerivativeFunc::FUNC_SUM, VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_FRAGMENT | TYPE_FLAGS_LIGHT, -1, -1, true));
+ add_options.push_back(AddOption("SumS", "Special", "Derivative", "VisualShaderNodeScalarDerivativeFunc", TTR("(Fragment/Light mode only) (Scalar) Sum of absolute derivative in 'x' and 'y'."), VisualShaderNodeScalarDerivativeFunc::FUNC_SUM, VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_FRAGMENT | TYPE_FLAGS_LIGHT, -1, -1, true));
custom_node_option_idx = add_options.size();
/////////////////////////////////////////////////////////////////////
@@ -2979,12 +3343,16 @@ VisualShaderEditor::VisualShaderEditor() {
default_plugin.instance();
add_plugin(default_plugin);
+ graph_plugin.instance();
+
property_editor = memnew(CustomPropertyEditor);
add_child(property_editor);
property_editor->connect("variant_changed", callable_mp(this, &VisualShaderEditor::_port_edited));
}
+/////////////////
+
void VisualShaderEditorPlugin::edit(Object *p_object) {
visual_shader_editor->edit(Object::cast_to<VisualShader>(p_object));
}
@@ -3119,6 +3487,8 @@ public:
class VisualShaderNodePluginDefaultEditor : public VBoxContainer {
GDCLASS(VisualShaderNodePluginDefaultEditor, VBoxContainer);
Ref<Resource> parent_resource;
+ int node_id;
+ VisualShader::Type shader_type;
public:
void _property_changed(const String &p_property, const Variant &p_value, const String &p_field = "", bool p_changing = false) {
@@ -3147,8 +3517,10 @@ public:
} else {
undo_redo->add_undo_method(this, "_open_inspector", (RES)parent_resource.ptr());
}
- undo_redo->add_do_method(this, "_refresh_request");
- undo_redo->add_undo_method(this, "_refresh_request");
+ }
+ if (p_property != "constant") {
+ undo_redo->add_do_method(VisualShaderEditor::get_singleton()->get_graph_plugin(), "update_node_deferred", shader_type, node_id);
+ undo_redo->add_undo_method(VisualShaderEditor::get_singleton()->get_graph_plugin(), "update_node_deferred", shader_type, node_id);
}
undo_redo->commit_action();
@@ -3164,10 +3536,6 @@ public:
}
}
- void _refresh_request() {
- VisualShaderEditor::get_singleton()->call_deferred("_update_graph");
- }
-
void _resource_selected(const String &p_path, RES p_resource) {
_open_inspector(p_resource);
}
@@ -3193,6 +3561,9 @@ public:
node = p_node;
properties = p_properties;
+ node_id = (int)p_node->get_meta("id");
+ shader_type = VisualShader::Type((int)p_node->get_meta("shader_type"));
+
for (int i = 0; i < p_properties.size(); i++) {
HBoxContainer *hbox = memnew(HBoxContainer);
hbox->set_h_size_flags(SIZE_EXPAND_FILL);
@@ -3220,11 +3591,9 @@ public:
properties[i]->set_name_split_ratio(0);
}
node->connect("changed", callable_mp(this, &VisualShaderNodePluginDefaultEditor::_node_changed));
- node->connect("editor_refresh_request", callable_mp(this, &VisualShaderNodePluginDefaultEditor::_refresh_request), varray(), CONNECT_DEFERRED);
}
static void _bind_methods() {
- ClassDB::bind_method("_refresh_request", &VisualShaderNodePluginDefaultEditor::_refresh_request); // Used by UndoRedo.
ClassDB::bind_method("_open_inspector", &VisualShaderNodePluginDefaultEditor::_open_inspector); // Used by UndoRedo.
ClassDB::bind_method("_show_prop_names", &VisualShaderNodePluginDefaultEditor::_show_prop_names); // Used with call_deferred.
}
@@ -3313,6 +3682,10 @@ void EditorPropertyShaderMode::_option_selected(int p_which) {
//do is easy
undo_redo->add_do_method(visual_shader.ptr(), "set_mode", p_which);
undo_redo->add_undo_method(visual_shader.ptr(), "set_mode", visual_shader->get_mode());
+
+ undo_redo->add_do_method(VisualShaderEditor::get_singleton(), "_set_mode", p_which);
+ undo_redo->add_undo_method(VisualShaderEditor::get_singleton(), "_set_mode", visual_shader->get_mode());
+
//now undo is hell
//1. restore connections to output
diff --git a/editor/plugins/visual_shader_editor_plugin.h b/editor/plugins/visual_shader_editor_plugin.h
index 9b80488b22..49d7721ecd 100644
--- a/editor/plugins/visual_shader_editor_plugin.h
+++ b/editor/plugins/visual_shader_editor_plugin.h
@@ -50,8 +50,72 @@ public:
virtual Control *create_editor(const Ref<Resource> &p_parent_resource, const Ref<VisualShaderNode> &p_node);
};
+class VisualShaderGraphPlugin : public Reference {
+ GDCLASS(VisualShaderGraphPlugin, Reference);
+
+private:
+ struct InputPort {
+ Button *default_input_button;
+ };
+
+ struct Port {
+ TextureButton *preview_button;
+ };
+
+ struct Link {
+ VisualShader::Type type;
+ VisualShaderNode *visual_node;
+ GraphNode *graph_node;
+ bool preview_visible;
+ int preview_pos;
+ Map<int, InputPort> input_ports;
+ Map<int, Port> output_ports;
+ VBoxContainer *preview_box;
+ LineEdit *uniform_name;
+ };
+
+ Ref<VisualShader> visual_shader;
+ Map<int, Link> links;
+ List<VisualShader::Connection> connections;
+ bool dirty = false;
+
+protected:
+ static void _bind_methods();
+
+public:
+ void register_shader(VisualShader *p_visual_shader);
+ void set_connections(List<VisualShader::Connection> &p_connections);
+ void register_link(VisualShader::Type p_type, int p_id, VisualShaderNode *p_visual_node, GraphNode *p_graph_node);
+ void register_output_port(int p_id, int p_port, TextureButton *p_button);
+ void register_uniform_name(int p_id, LineEdit *p_uniform_name);
+ void clear_links();
+ void set_shader_type(VisualShader::Type p_type);
+ bool is_preview_visible(int p_id) const;
+ bool is_dirty() const;
+ void make_dirty(bool p_enabled);
+ void update_node(VisualShader::Type p_type, int p_id);
+ void update_node_deferred(VisualShader::Type p_type, int p_node_id);
+ void add_node(VisualShader::Type p_type, int p_id);
+ void remove_node(VisualShader::Type p_type, int p_id);
+ void connect_nodes(VisualShader::Type p_type, int p_from_node, int p_from_port, int p_to_node, int p_to_port);
+ void disconnect_nodes(VisualShader::Type p_type, int p_from_node, int p_from_port, int p_to_node, int p_to_port);
+ void show_port_preview(VisualShader::Type p_type, int p_node_id, int p_port_id);
+ void set_node_position(VisualShader::Type p_type, int p_id, const Vector2 &p_position);
+ void set_node_size(VisualShader::Type p_type, int p_id, const Vector2 &p_size);
+ void refresh_node_ports(VisualShader::Type p_type, int p_node);
+ void set_input_port_default_value(VisualShader::Type p_type, int p_node_id, int p_port_id, Variant p_value);
+ void register_default_input_button(int p_node_id, int p_port_id, Button *p_button);
+ void update_uniform_refs();
+ void set_uniform_name(VisualShader::Type p_type, int p_node_id, const String &p_name);
+ VisualShader::Type get_shader_type() const;
+
+ VisualShaderGraphPlugin();
+ ~VisualShaderGraphPlugin();
+};
+
class VisualShaderEditor : public VBoxContainer {
GDCLASS(VisualShaderEditor, VBoxContainer);
+ friend class VisualShaderGraphPlugin;
CustomPropertyEditor *property_editor;
int editing_node;
@@ -63,7 +127,9 @@ class VisualShaderEditor : public VBoxContainer {
Button *add_node;
Button *preview_shader;
- OptionButton *edit_type;
+ OptionButton *edit_type = nullptr;
+ OptionButton *edit_type_standart;
+ OptionButton *edit_type_particles;
PanelContainer *error_panel;
Label *error_label;
@@ -71,7 +137,7 @@ class VisualShaderEditor : public VBoxContainer {
bool pending_update_preview;
bool shader_error;
VBoxContainer *preview_vbox;
- TextEdit *preview_text;
+ CodeEdit *preview_text;
Ref<CodeHighlighter> syntax_highlighter;
Label *error_text;
@@ -84,6 +150,19 @@ class VisualShaderEditor : public VBoxContainer {
MenuButton *tools;
bool preview_showed;
+ bool particles_mode;
+
+ enum TypeFlags {
+ TYPE_FLAGS_VERTEX = 1,
+ TYPE_FLAGS_FRAGMENT = 2,
+ TYPE_FLAGS_LIGHT = 4,
+ };
+
+ enum ParticlesTypeFlags {
+ TYPE_FLAGS_EMIT = 1,
+ TYPE_FLAGS_PROCESS = 2,
+ TYPE_FLAGS_END = 4
+ };
enum ToolsMenuOptions {
EXPAND_ALL,
@@ -166,12 +245,15 @@ class VisualShaderEditor : public VBoxContainer {
int custom_node_option_idx;
List<String> keyword_list;
+ List<VisualShaderNodeUniformRef> uniform_refs;
+
void _draw_color_over_button(Object *obj, Color p_color);
void _add_custom_node(const String &p_path);
void _add_texture_node(const String &p_path);
VisualShaderNode *_add_node(int p_idx, int p_op_idx = -1);
void _update_options_menu();
+ void _set_mode(int p_which);
void _show_preview_text();
void _update_preview();
@@ -179,7 +261,16 @@ class VisualShaderEditor : public VBoxContainer {
static VisualShaderEditor *singleton;
+ struct DragOp {
+ VisualShader::Type type;
+ int node;
+ Vector2 from;
+ Vector2 to;
+ };
+ List<DragOp> drag_buffer;
+ bool drag_dirty = false;
void _node_dragged(const Vector2 &p_from, const Vector2 &p_to, int p_node);
+ void _nodes_dragged();
bool updating;
void _connection_request(const String &p_from, int p_from_index, const String &p_to, int p_to_index);
@@ -206,8 +297,8 @@ class VisualShaderEditor : public VBoxContainer {
void _connection_to_empty(const String &p_from, int p_from_slot, const Vector2 &p_release_position);
void _connection_from_empty(const String &p_to, int p_to_slot, const Vector2 &p_release_position);
- void _line_edit_changed(const String &p_text, Object *line_edit, int p_node_id);
- void _line_edit_focus_out(Object *line_edit, int p_node_id);
+ void _uniform_line_edit_changed(const String &p_text, int p_node_id);
+ void _uniform_line_edit_focus_out(Object *line_edit, int p_node_id);
void _port_name_focus_out(Object *line_edit, int p_node_id, int p_port_id, bool p_output);
@@ -227,13 +318,15 @@ class VisualShaderEditor : public VBoxContainer {
void _paste_nodes(bool p_use_custom_position = false, const Vector2 &p_custom_position = Vector2());
Vector<Ref<VisualShaderNodePlugin>> plugins;
+ Ref<VisualShaderGraphPlugin> graph_plugin;
void _mode_selected(int p_id);
- void _rebuild();
void _input_select_item(Ref<VisualShaderNodeInput> input, String name);
void _uniform_select_item(Ref<VisualShaderNodeUniformRef> p_uniform, String p_name);
+ VisualShader::Type get_current_shader_type() const;
+
void _add_input_port(int p_node, int p_port, int p_port_type, const String &p_name);
void _remove_input_port(int p_node, int p_port);
void _change_input_port_type(int p_type, int p_node, int p_port);
@@ -244,7 +337,7 @@ class VisualShaderEditor : public VBoxContainer {
void _change_output_port_type(int p_type, int p_node, int p_port);
void _change_output_port_name(const String &p_text, Object *line_edit, int p_node, int p_port);
- void _expression_focus_out(Object *text_edit, int p_node);
+ void _expression_focus_out(Object *code_edit, int p_node);
void _set_node_size(int p_type, int p_node, const Size2 &p_size);
void _node_resized(const Vector2 &p_new_size, int p_type, int p_node);
@@ -268,6 +361,8 @@ class VisualShaderEditor : public VBoxContainer {
bool _is_available(int p_mode);
void _update_created_node(GraphNode *node);
+ void _update_uniforms(bool p_update_refs);
+ void _update_uniform_refs(Set<String> &p_names);
protected:
void _notification(int p_what);
@@ -279,6 +374,7 @@ public:
void remove_plugin(const Ref<VisualShaderNodePlugin> &p_plugin);
static VisualShaderEditor *get_singleton() { return singleton; }
+ VisualShaderGraphPlugin *get_graph_plugin() { return graph_plugin.ptr(); }
void clear_custom_types();
void add_custom_type(const String &p_name, const Ref<Script> &p_script, const String &p_description, int p_return_icon_type, const String &p_category, bool p_highend);