From ad313097ebcb2a0c02c956fdf74a6610c3f7c9a8 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Tue, 2 Aug 2016 19:11:05 -0300 Subject: WIP visual scripting, not working yet but you can check out stuff --- tools/editor/code_editor.cpp | 22 +- tools/editor/code_editor.h | 17 +- tools/editor/editor_node.cpp | 3 + tools/editor/icons/2x/icon_uninstance.png | Bin 0 -> 883 bytes tools/editor/icons/2x/icon_visual_script.png | Bin 0 -> 683 bytes tools/editor/icons/icon_mini_aabb.png | Bin 0 -> 205 bytes tools/editor/icons/icon_mini_array.png | Bin 0 -> 193 bytes tools/editor/icons/icon_mini_boolean.png | Bin 0 -> 203 bytes tools/editor/icons/icon_mini_color.png | Bin 0 -> 202 bytes tools/editor/icons/icon_mini_color_array.png | Bin 0 -> 201 bytes tools/editor/icons/icon_mini_dictionary.png | Bin 0 -> 192 bytes tools/editor/icons/icon_mini_float.png | Bin 0 -> 211 bytes tools/editor/icons/icon_mini_float_array.png | Bin 0 -> 210 bytes tools/editor/icons/icon_mini_image.png | Bin 0 -> 211 bytes tools/editor/icons/icon_mini_input.png | Bin 0 -> 201 bytes tools/editor/icons/icon_mini_int_array.png | Bin 0 -> 198 bytes tools/editor/icons/icon_mini_integer.png | Bin 0 -> 196 bytes tools/editor/icons/icon_mini_matrix3.png | Bin 0 -> 220 bytes tools/editor/icons/icon_mini_matrix32.png | Bin 0 -> 216 bytes tools/editor/icons/icon_mini_object.png | Bin 0 -> 210 bytes tools/editor/icons/icon_mini_path.png | Bin 0 -> 211 bytes tools/editor/icons/icon_mini_plane.png | Bin 0 -> 207 bytes tools/editor/icons/icon_mini_quat.png | Bin 0 -> 205 bytes tools/editor/icons/icon_mini_raw_array.png | Bin 0 -> 214 bytes tools/editor/icons/icon_mini_rect2.png | Bin 0 -> 216 bytes tools/editor/icons/icon_mini_rid.png | Bin 0 -> 205 bytes tools/editor/icons/icon_mini_string.png | Bin 0 -> 198 bytes tools/editor/icons/icon_mini_string_array.png | Bin 0 -> 216 bytes tools/editor/icons/icon_mini_transform.png | Bin 0 -> 216 bytes tools/editor/icons/icon_mini_variant.png | Bin 0 -> 254 bytes tools/editor/icons/icon_mini_vector2.png | Bin 0 -> 217 bytes tools/editor/icons/icon_mini_vector2_array.png | Bin 0 -> 216 bytes tools/editor/icons/icon_mini_vector3.png | Bin 0 -> 219 bytes tools/editor/icons/icon_mini_vector3_array.png | Bin 0 -> 212 bytes tools/editor/icons/icon_override.png | Bin 0 -> 344 bytes tools/editor/icons/icon_uninstance.png | Bin 0 -> 525 bytes tools/editor/icons/icon_variant.png | Bin 0 -> 240 bytes tools/editor/icons/icon_visual_script.png | Bin 0 -> 404 bytes tools/editor/icons/icon_visual_shader_port.png | Bin 0 -> 355 bytes tools/editor/plugins/script_editor_plugin.cpp | 1247 ++++-------------------- tools/editor/plugins/script_editor_plugin.h | 109 +-- tools/editor/plugins/script_text_editor.cpp | 1057 ++++++++++++++++++++ tools/editor/plugins/script_text_editor.h | 112 +++ tools/editor/property_editor.cpp | 28 +- 44 files changed, 1474 insertions(+), 1121 deletions(-) create mode 100644 tools/editor/icons/2x/icon_uninstance.png create mode 100644 tools/editor/icons/2x/icon_visual_script.png create mode 100644 tools/editor/icons/icon_mini_aabb.png create mode 100644 tools/editor/icons/icon_mini_array.png create mode 100644 tools/editor/icons/icon_mini_boolean.png create mode 100644 tools/editor/icons/icon_mini_color.png create mode 100644 tools/editor/icons/icon_mini_color_array.png create mode 100644 tools/editor/icons/icon_mini_dictionary.png create mode 100644 tools/editor/icons/icon_mini_float.png create mode 100644 tools/editor/icons/icon_mini_float_array.png create mode 100644 tools/editor/icons/icon_mini_image.png create mode 100644 tools/editor/icons/icon_mini_input.png create mode 100644 tools/editor/icons/icon_mini_int_array.png create mode 100644 tools/editor/icons/icon_mini_integer.png create mode 100644 tools/editor/icons/icon_mini_matrix3.png create mode 100644 tools/editor/icons/icon_mini_matrix32.png create mode 100644 tools/editor/icons/icon_mini_object.png create mode 100644 tools/editor/icons/icon_mini_path.png create mode 100644 tools/editor/icons/icon_mini_plane.png create mode 100644 tools/editor/icons/icon_mini_quat.png create mode 100644 tools/editor/icons/icon_mini_raw_array.png create mode 100644 tools/editor/icons/icon_mini_rect2.png create mode 100644 tools/editor/icons/icon_mini_rid.png create mode 100644 tools/editor/icons/icon_mini_string.png create mode 100644 tools/editor/icons/icon_mini_string_array.png create mode 100644 tools/editor/icons/icon_mini_transform.png create mode 100644 tools/editor/icons/icon_mini_variant.png create mode 100644 tools/editor/icons/icon_mini_vector2.png create mode 100644 tools/editor/icons/icon_mini_vector2_array.png create mode 100644 tools/editor/icons/icon_mini_vector3.png create mode 100644 tools/editor/icons/icon_mini_vector3_array.png create mode 100644 tools/editor/icons/icon_override.png create mode 100644 tools/editor/icons/icon_uninstance.png create mode 100644 tools/editor/icons/icon_variant.png create mode 100644 tools/editor/icons/icon_visual_script.png create mode 100644 tools/editor/icons/icon_visual_shader_port.png create mode 100644 tools/editor/plugins/script_text_editor.cpp create mode 100644 tools/editor/plugins/script_text_editor.h (limited to 'tools') diff --git a/tools/editor/code_editor.cpp b/tools/editor/code_editor.cpp index 71ae171dfe..c6de541d02 100644 --- a/tools/editor/code_editor.cpp +++ b/tools/editor/code_editor.cpp @@ -1051,7 +1051,11 @@ void CodeTextEditor::_code_complete_timer_timeout() { void CodeTextEditor::_complete_request() { List entries; - _code_complete_script(text_editor->get_text_for_completion(),&entries); + String ctext = text_editor->get_text_for_completion(); + _code_complete_script(ctext,&entries); + if (code_complete_func) { + code_complete_func(code_complete_ud,ctext,&entries); + } // print_line("COMPLETE: "+p_request); if (entries.size()==0) return; @@ -1135,13 +1139,16 @@ void CodeTextEditor::_text_changed_idle_timeout() { _validate_script(); + emit_signal("validate_script"); } void CodeTextEditor::_notification(int p_what) { - if (p_what==EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) + if (p_what==EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) { _load_theme_settings(); + emit_signal("load_theme_settings"); + } if (p_what==NOTIFICATION_ENTER_TREE) { _update_font(); } @@ -1157,10 +1164,21 @@ void CodeTextEditor::_bind_methods() { ObjectTypeDB::bind_method("_code_complete_timer_timeout",&CodeTextEditor::_code_complete_timer_timeout); ObjectTypeDB::bind_method("_complete_request",&CodeTextEditor::_complete_request); ObjectTypeDB::bind_method("_font_resize_timeout",&CodeTextEditor::_font_resize_timeout); + + ADD_SIGNAL(MethodInfo("validate_script")); + ADD_SIGNAL(MethodInfo("load_theme_settings")); + } +void CodeTextEditor::set_code_complete_func(CodeTextEditorCodeCompleteFunc p_code_complete_func,void * p_ud) { + code_complete_func=p_code_complete_func; + code_complete_ud=p_ud; +} + + CodeTextEditor::CodeTextEditor() { + code_complete_func=NULL; ED_SHORTCUT("script_editor/zoom_in", TTR("Zoom In"), KEY_MASK_CMD|KEY_EQUAL); ED_SHORTCUT("script_editor/zoom_out", TTR("Zoom Out"), KEY_MASK_CMD|KEY_MINUS); ED_SHORTCUT("script_editor/reset_zoom", TTR("Reset Zoom"), KEY_MASK_CMD|KEY_0); diff --git a/tools/editor/code_editor.h b/tools/editor/code_editor.h index 7983c46f7a..f6c3ac7564 100644 --- a/tools/editor/code_editor.h +++ b/tools/editor/code_editor.h @@ -189,6 +189,8 @@ public: }; +typedef void (*CodeTextEditorCodeCompleteFunc)(void* p_ud,const String& p_code, List* r_options); + class CodeTextEditor : public VBoxContainer { OBJ_TYPE(CodeTextEditor,VBoxContainer); @@ -218,13 +220,16 @@ class CodeTextEditor : public VBoxContainer { void _zoom_out(); void _reset_zoom(); + + CodeTextEditorCodeCompleteFunc code_complete_func; + void *code_complete_ud; + protected: - void set_error(const String& p_error); virtual void _load_theme_settings() {} - virtual void _validate_script()=0; - virtual void _code_complete_script(const String& p_code, List* r_options) {}; + virtual void _validate_script() {} + virtual void _code_complete_script(const String& p_code, List* r_options) {} void _text_changed_idle_timeout(); void _code_complete_timer_timeout(); @@ -235,10 +240,16 @@ protected: public: + void set_error(const String& p_error); + void update_line_and_column() { _line_col_changed(); } TextEdit *get_text_edit() { return text_editor; } FindReplaceBar *get_find_replace_bar() { return find_replace_bar; } virtual void apply_code() {} + + void set_code_complete_func(CodeTextEditorCodeCompleteFunc p_code_complete_func, void * p_ud); + + CodeTextEditor(); }; diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp index 8b55e73ee7..f7189f022a 100644 --- a/tools/editor/editor_node.cpp +++ b/tools/editor/editor_node.cpp @@ -86,6 +86,7 @@ #include "plugins/collision_polygon_editor_plugin.h" #include "plugins/collision_polygon_2d_editor_plugin.h" #include "plugins/script_editor_plugin.h" +#include "plugins/script_text_editor.h" #include "plugins/path_2d_editor_plugin.h" #include "plugins/particles_editor_plugin.h" #include "plugins/particles_2d_editor_plugin.h" @@ -6443,6 +6444,8 @@ EditorNode::EditorNode() { add_editor_plugin( memnew( SpatialEditorPlugin(this) ) ); add_editor_plugin( memnew( ScriptEditorPlugin(this) ) ); + ScriptTextEditor::register_editor(); //register one for text scripts + if (StreamPeerSSL::is_available()) { add_editor_plugin( memnew( AssetLibraryEditorPlugin(this) ) ); } else { diff --git a/tools/editor/icons/2x/icon_uninstance.png b/tools/editor/icons/2x/icon_uninstance.png new file mode 100644 index 0000000000..bf3dc00368 Binary files /dev/null and b/tools/editor/icons/2x/icon_uninstance.png differ diff --git a/tools/editor/icons/2x/icon_visual_script.png b/tools/editor/icons/2x/icon_visual_script.png new file mode 100644 index 0000000000..adc6353ed2 Binary files /dev/null and b/tools/editor/icons/2x/icon_visual_script.png differ diff --git a/tools/editor/icons/icon_mini_aabb.png b/tools/editor/icons/icon_mini_aabb.png new file mode 100644 index 0000000000..a0b11821a9 Binary files /dev/null and b/tools/editor/icons/icon_mini_aabb.png differ diff --git a/tools/editor/icons/icon_mini_array.png b/tools/editor/icons/icon_mini_array.png new file mode 100644 index 0000000000..2df4a7d516 Binary files /dev/null and b/tools/editor/icons/icon_mini_array.png differ diff --git a/tools/editor/icons/icon_mini_boolean.png b/tools/editor/icons/icon_mini_boolean.png new file mode 100644 index 0000000000..8753084a5b Binary files /dev/null and b/tools/editor/icons/icon_mini_boolean.png differ diff --git a/tools/editor/icons/icon_mini_color.png b/tools/editor/icons/icon_mini_color.png new file mode 100644 index 0000000000..ef4e6b5468 Binary files /dev/null and b/tools/editor/icons/icon_mini_color.png differ diff --git a/tools/editor/icons/icon_mini_color_array.png b/tools/editor/icons/icon_mini_color_array.png new file mode 100644 index 0000000000..fa82c20664 Binary files /dev/null and b/tools/editor/icons/icon_mini_color_array.png differ diff --git a/tools/editor/icons/icon_mini_dictionary.png b/tools/editor/icons/icon_mini_dictionary.png new file mode 100644 index 0000000000..581a7e4e94 Binary files /dev/null and b/tools/editor/icons/icon_mini_dictionary.png differ diff --git a/tools/editor/icons/icon_mini_float.png b/tools/editor/icons/icon_mini_float.png new file mode 100644 index 0000000000..240fe7741b Binary files /dev/null and b/tools/editor/icons/icon_mini_float.png differ diff --git a/tools/editor/icons/icon_mini_float_array.png b/tools/editor/icons/icon_mini_float_array.png new file mode 100644 index 0000000000..205c117522 Binary files /dev/null and b/tools/editor/icons/icon_mini_float_array.png differ diff --git a/tools/editor/icons/icon_mini_image.png b/tools/editor/icons/icon_mini_image.png new file mode 100644 index 0000000000..8433f57b33 Binary files /dev/null and b/tools/editor/icons/icon_mini_image.png differ diff --git a/tools/editor/icons/icon_mini_input.png b/tools/editor/icons/icon_mini_input.png new file mode 100644 index 0000000000..5d52ed70f8 Binary files /dev/null and b/tools/editor/icons/icon_mini_input.png differ diff --git a/tools/editor/icons/icon_mini_int_array.png b/tools/editor/icons/icon_mini_int_array.png new file mode 100644 index 0000000000..3b7bf7dc62 Binary files /dev/null and b/tools/editor/icons/icon_mini_int_array.png differ diff --git a/tools/editor/icons/icon_mini_integer.png b/tools/editor/icons/icon_mini_integer.png new file mode 100644 index 0000000000..17f3762a46 Binary files /dev/null and b/tools/editor/icons/icon_mini_integer.png differ diff --git a/tools/editor/icons/icon_mini_matrix3.png b/tools/editor/icons/icon_mini_matrix3.png new file mode 100644 index 0000000000..be97f2014a Binary files /dev/null and b/tools/editor/icons/icon_mini_matrix3.png differ diff --git a/tools/editor/icons/icon_mini_matrix32.png b/tools/editor/icons/icon_mini_matrix32.png new file mode 100644 index 0000000000..33963066b0 Binary files /dev/null and b/tools/editor/icons/icon_mini_matrix32.png differ diff --git a/tools/editor/icons/icon_mini_object.png b/tools/editor/icons/icon_mini_object.png new file mode 100644 index 0000000000..ba38ad06b1 Binary files /dev/null and b/tools/editor/icons/icon_mini_object.png differ diff --git a/tools/editor/icons/icon_mini_path.png b/tools/editor/icons/icon_mini_path.png new file mode 100644 index 0000000000..7645ba6257 Binary files /dev/null and b/tools/editor/icons/icon_mini_path.png differ diff --git a/tools/editor/icons/icon_mini_plane.png b/tools/editor/icons/icon_mini_plane.png new file mode 100644 index 0000000000..d4f2bda241 Binary files /dev/null and b/tools/editor/icons/icon_mini_plane.png differ diff --git a/tools/editor/icons/icon_mini_quat.png b/tools/editor/icons/icon_mini_quat.png new file mode 100644 index 0000000000..991b684fcb Binary files /dev/null and b/tools/editor/icons/icon_mini_quat.png differ diff --git a/tools/editor/icons/icon_mini_raw_array.png b/tools/editor/icons/icon_mini_raw_array.png new file mode 100644 index 0000000000..a655edde01 Binary files /dev/null and b/tools/editor/icons/icon_mini_raw_array.png differ diff --git a/tools/editor/icons/icon_mini_rect2.png b/tools/editor/icons/icon_mini_rect2.png new file mode 100644 index 0000000000..9d5d48f78c Binary files /dev/null and b/tools/editor/icons/icon_mini_rect2.png differ diff --git a/tools/editor/icons/icon_mini_rid.png b/tools/editor/icons/icon_mini_rid.png new file mode 100644 index 0000000000..c85e40f315 Binary files /dev/null and b/tools/editor/icons/icon_mini_rid.png differ diff --git a/tools/editor/icons/icon_mini_string.png b/tools/editor/icons/icon_mini_string.png new file mode 100644 index 0000000000..0e1198eac0 Binary files /dev/null and b/tools/editor/icons/icon_mini_string.png differ diff --git a/tools/editor/icons/icon_mini_string_array.png b/tools/editor/icons/icon_mini_string_array.png new file mode 100644 index 0000000000..2d8e4ff0aa Binary files /dev/null and b/tools/editor/icons/icon_mini_string_array.png differ diff --git a/tools/editor/icons/icon_mini_transform.png b/tools/editor/icons/icon_mini_transform.png new file mode 100644 index 0000000000..b90ee1cef8 Binary files /dev/null and b/tools/editor/icons/icon_mini_transform.png differ diff --git a/tools/editor/icons/icon_mini_variant.png b/tools/editor/icons/icon_mini_variant.png new file mode 100644 index 0000000000..84b1e04264 Binary files /dev/null and b/tools/editor/icons/icon_mini_variant.png differ diff --git a/tools/editor/icons/icon_mini_vector2.png b/tools/editor/icons/icon_mini_vector2.png new file mode 100644 index 0000000000..56b7726137 Binary files /dev/null and b/tools/editor/icons/icon_mini_vector2.png differ diff --git a/tools/editor/icons/icon_mini_vector2_array.png b/tools/editor/icons/icon_mini_vector2_array.png new file mode 100644 index 0000000000..a8dd5e89a0 Binary files /dev/null and b/tools/editor/icons/icon_mini_vector2_array.png differ diff --git a/tools/editor/icons/icon_mini_vector3.png b/tools/editor/icons/icon_mini_vector3.png new file mode 100644 index 0000000000..b8999c9c22 Binary files /dev/null and b/tools/editor/icons/icon_mini_vector3.png differ diff --git a/tools/editor/icons/icon_mini_vector3_array.png b/tools/editor/icons/icon_mini_vector3_array.png new file mode 100644 index 0000000000..94a6f64043 Binary files /dev/null and b/tools/editor/icons/icon_mini_vector3_array.png differ diff --git a/tools/editor/icons/icon_override.png b/tools/editor/icons/icon_override.png new file mode 100644 index 0000000000..bbba220bcb Binary files /dev/null and b/tools/editor/icons/icon_override.png differ diff --git a/tools/editor/icons/icon_uninstance.png b/tools/editor/icons/icon_uninstance.png new file mode 100644 index 0000000000..de8b2f9a40 Binary files /dev/null and b/tools/editor/icons/icon_uninstance.png differ diff --git a/tools/editor/icons/icon_variant.png b/tools/editor/icons/icon_variant.png new file mode 100644 index 0000000000..1ae2812ff7 Binary files /dev/null and b/tools/editor/icons/icon_variant.png differ diff --git a/tools/editor/icons/icon_visual_script.png b/tools/editor/icons/icon_visual_script.png new file mode 100644 index 0000000000..f4414088b9 Binary files /dev/null and b/tools/editor/icons/icon_visual_script.png differ diff --git a/tools/editor/icons/icon_visual_shader_port.png b/tools/editor/icons/icon_visual_shader_port.png new file mode 100644 index 0000000000..9acdc17c3b Binary files /dev/null and b/tools/editor/icons/icon_visual_shader_port.png differ diff --git a/tools/editor/plugins/script_editor_plugin.cpp b/tools/editor/plugins/script_editor_plugin.cpp index 4032a790d8..1b739e62f6 100644 --- a/tools/editor/plugins/script_editor_plugin.cpp +++ b/tools/editor/plugins/script_editor_plugin.cpp @@ -263,369 +263,11 @@ ScriptEditorQuickOpen::ScriptEditorQuickOpen() { ScriptEditor *ScriptEditor::script_editor=NULL; -Vector ScriptTextEditor::get_functions() { - - - String errortxt; - int line=-1,col; - TextEdit *te=get_text_edit(); - String text = te->get_text(); - List fnc; - - if (script->get_language()->validate(text,line,col,errortxt,script->get_path(),&fnc)) { - - //if valid rewrite functions to latest - functions.clear(); - for (List::Element *E=fnc.front();E;E=E->next()) { - - functions.push_back(E->get()); - } - - - } - - return functions; -} - -void ScriptTextEditor::apply_code() { - - if (script.is_null()) - return; -// print_line("applying code"); - script->set_source_code(get_text_edit()->get_text()); - script->update_exports(); -} - -Ref