diff options
Diffstat (limited to 'tools/editor')
41 files changed, 458 insertions, 185 deletions
diff --git a/tools/editor/SCsub b/tools/editor/SCsub index 34651b36f2..f6cb16dc24 100644 --- a/tools/editor/SCsub +++ b/tools/editor/SCsub @@ -1,3 +1,5 @@ +#!/usr/bin/env python + Import('env') diff --git a/tools/editor/animation_editor.cpp b/tools/editor/animation_editor.cpp index 2f67df1fc3..a556031e5e 100644 --- a/tools/editor/animation_editor.cpp +++ b/tools/editor/animation_editor.cpp @@ -1933,12 +1933,20 @@ void AnimationKeyEditor::_track_editor_input_event(const InputEvent& p_input) { if (mb.button_index==BUTTON_WHEEL_UP && mb.pressed) { - v_scroll->set_val( v_scroll->get_val() - v_scroll->get_page() / 8 ); + if (mb.mod.command) { + zoom->set_val(zoom->get_val() + zoom->get_step()); + } else { + v_scroll->set_val( v_scroll->get_val() - v_scroll->get_page() / 8 ); + } } if (mb.button_index==BUTTON_WHEEL_DOWN && mb.pressed) { - v_scroll->set_val( v_scroll->get_val() + v_scroll->get_page() / 8 ); + if (mb.mod.command) { + zoom->set_val(zoom->get_val() - zoom->get_step()); + } else { + v_scroll->set_val( v_scroll->get_val() + v_scroll->get_page() / 8 ); + } } if (mb.button_index==BUTTON_RIGHT && mb.pressed) { diff --git a/tools/editor/code_editor.cpp b/tools/editor/code_editor.cpp index 9240e3527c..626f86d33d 100644 --- a/tools/editor/code_editor.cpp +++ b/tools/editor/code_editor.cpp @@ -1051,7 +1051,7 @@ void CodeTextEditor::_reset_zoom() { void CodeTextEditor::_line_col_changed() { line_nb->set_text(itos(text_editor->cursor_get_line() + 1)); - col_nb->set_text(itos(text_editor->cursor_get_column())); + col_nb->set_text(itos(text_editor->cursor_get_column() + 1)); } void CodeTextEditor::_text_changed() { @@ -1105,6 +1105,24 @@ void CodeTextEditor::_font_resize_timeout() { } } +void CodeTextEditor::update_editor_settings() { + + text_editor->set_auto_brace_completion(EditorSettings::get_singleton()->get("text_editor/auto_brace_complete")); + text_editor->set_scroll_pass_end_of_file(EditorSettings::get_singleton()->get("text_editor/scroll_past_end_of_file")); + text_editor->set_tab_size(EditorSettings::get_singleton()->get("text_editor/tab_size")); + text_editor->set_draw_tabs(EditorSettings::get_singleton()->get("text_editor/draw_tabs")); + text_editor->set_show_line_numbers(EditorSettings::get_singleton()->get("text_editor/show_line_numbers")); + text_editor->set_line_numbers_zero_padded(EditorSettings::get_singleton()->get("text_editor/line_numbers_zero_padded")); + text_editor->set_show_line_length_guideline(EditorSettings::get_singleton()->get("text_editor/show_line_length_guideline")); + text_editor->set_line_length_guideline_column(EditorSettings::get_singleton()->get("text_editor/line_length_guideline_column")); + text_editor->set_syntax_coloring(EditorSettings::get_singleton()->get("text_editor/syntax_highlighting")); + text_editor->set_highlight_all_occurrences(EditorSettings::get_singleton()->get("text_editor/highlight_all_occurrences")); + text_editor->cursor_set_blink_enabled(EditorSettings::get_singleton()->get("text_editor/caret_blink")); + text_editor->cursor_set_blink_speed(EditorSettings::get_singleton()->get("text_editor/caret_blink_speed")); + text_editor->set_draw_breakpoint_gutter(EditorSettings::get_singleton()->get("text_editor/show_breakpoint_gutter")); + text_editor->cursor_set_block_mode(EditorSettings::get_singleton()->get("text_editor/block_caret")); +} + void CodeTextEditor::set_error(const String& p_error) { if (p_error!="") { diff --git a/tools/editor/code_editor.h b/tools/editor/code_editor.h index 6f59dda1ee..ce3b5bee26 100644 --- a/tools/editor/code_editor.h +++ b/tools/editor/code_editor.h @@ -242,6 +242,7 @@ protected: public: + void update_editor_settings(); void set_error(const String& p_error); void update_line_and_column() { _line_col_changed(); } TextEdit *get_text_edit() { return text_editor; } diff --git a/tools/editor/connections_dialog.cpp b/tools/editor/connections_dialog.cpp index c4f2435675..1baad2c6b3 100644 --- a/tools/editor/connections_dialog.cpp +++ b/tools/editor/connections_dialog.cpp @@ -181,6 +181,14 @@ void ConnectDialog::ok_pressed() { error->popup_centered_minsize(); return; } + Node* target = tree->get_selected(); + if (target->get_script().is_null()) { + if (!target->has_method(dst_method->get_text())) { + error->set_text(TTR("Target method not found! Specify a valid method or attach a script to target Node.")); + error->popup_centered_minsize(); + return; + } + } emit_signal("connected"); hide(); diff --git a/tools/editor/editor_log.cpp b/tools/editor/editor_log.cpp index 20613467d3..02af9712a8 100644 --- a/tools/editor/editor_log.cpp +++ b/tools/editor/editor_log.cpp @@ -161,7 +161,7 @@ void EditorLog::_undo_redo_cbk(void *p_self,const String& p_name) { void EditorLog::_bind_methods() { ObjectTypeDB::bind_method(_MD("_clear_request"),&EditorLog::_clear_request ); - + ObjectTypeDB::bind_method("_override_logger_styles",&EditorLog::_override_logger_styles ); //ObjectTypeDB::bind_method(_MD("_dragged"),&EditorLog::_dragged ); ADD_SIGNAL( MethodInfo("clear_request")); } @@ -193,11 +193,10 @@ EditorLog::EditorLog() { ec->set_custom_minimum_size(Size2(0,180)); ec->set_v_size_flags(SIZE_EXPAND_FILL); - - PanelContainer *pc = memnew( PanelContainer ); - pc->add_style_override("panel",get_stylebox("normal","TextEdit")); + pc = memnew( PanelContainer ); ec->add_child(pc); pc->set_area_as_parent_rect(); + pc->connect("enter_tree", this, "_override_logger_styles"); log = memnew( RichTextLabel ); log->set_scroll_follow(true); @@ -224,6 +223,11 @@ void EditorLog::deinit() { } +void EditorLog::_override_logger_styles() { + + pc->add_style_override("panel",get_stylebox("normal","TextEdit")); + +} EditorLog::~EditorLog() { diff --git a/tools/editor/editor_log.h b/tools/editor/editor_log.h index 699be710d8..bbf35b63cb 100644 --- a/tools/editor/editor_log.h +++ b/tools/editor/editor_log.h @@ -50,6 +50,7 @@ class EditorLog : public VBoxContainer { HBoxContainer *title_hb; // PaneDrag *pd; Control *ec; + PanelContainer *pc; static void _error_handler(void *p_self, const char*p_func, const char*p_file,int p_line, const char*p_error,const char*p_errorexp,ErrorHandlerType p_type); @@ -64,6 +65,7 @@ protected: static void _bind_methods(); void _notification(int p_what); + void _override_logger_styles(); public: void add_message(const String& p_msg, bool p_error=false); diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp index 1ee0b93114..c17cf05ea7 100644 --- a/tools/editor/editor_node.cpp +++ b/tools/editor/editor_node.cpp @@ -266,10 +266,12 @@ void EditorNode::_notification(int p_what) { circle_step=0; circle_step_msec=tick; - circle_step_frame=frame+1; - - update_menu->set_icon(gui_base->get_icon("Progress"+itos(circle_step+1),"EditorIcons")); + circle_step_frame=frame+1; + // update the circle itself only when its enabled + if (!update_menu->get_popup()->is_item_checked(3)){ + update_menu->set_icon(gui_base->get_icon("Progress"+itos(circle_step+1),"EditorIcons")); + } } scene_root->set_size_override(true,Size2(Globals::get_singleton()->get("display/width"),Globals::get_singleton()->get("display/height"))); @@ -2678,7 +2680,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { } break; case RUN_PLAY_NATIVE: { - + bool autosave = EDITOR_DEF("run/auto_save_before_running",true); if (autosave) { _menu_option_confirm(FILE_SAVE_ALL_SCENES, false); @@ -2797,6 +2799,10 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { update_menu->get_popup()->set_item_checked(1,true); OS::get_singleton()->set_low_processor_usage_mode(true); } break; + case SETTINGS_UPDATE_SPINNER_HIDE: { + update_menu->set_icon(gui_base->get_icon("Collapse","EditorIcons")); + update_menu->get_popup()->toggle_item_checked(3); + } break; case SETTINGS_PREFERENCES: { settings_config_dialog->popup_edit_settings(); @@ -3018,6 +3024,10 @@ void EditorNode::remove_editor_plugin(EditorPlugin *p_editor) { if (p_editor->get_name()==singleton->main_editor_buttons[i]->get_text()) { + if (singleton->main_editor_buttons[i]->is_pressed()) { + singleton->_editor_select(EDITOR_SCRIPT); + } + memdelete( singleton->main_editor_buttons[i] ); singleton->main_editor_buttons.remove(i); @@ -6060,6 +6070,8 @@ EditorNode::EditorNode() { p=update_menu->get_popup(); p->add_check_item(TTR("Update Always"),SETTINGS_UPDATE_ALWAYS); p->add_check_item(TTR("Update Changes"),SETTINGS_UPDATE_CHANGES); + p->add_separator(); + p->add_check_item(TTR("Disable Update Spinner"),SETTINGS_UPDATE_SPINNER_HIDE); p->set_item_checked(1,true); //sources_button->connect(); diff --git a/tools/editor/editor_node.h b/tools/editor/editor_node.h index 2fae5daced..6392b96f8f 100644 --- a/tools/editor/editor_node.h +++ b/tools/editor/editor_node.h @@ -179,6 +179,7 @@ private: RUN_RELOAD_SCRIPTS, SETTINGS_UPDATE_ALWAYS, SETTINGS_UPDATE_CHANGES, + SETTINGS_UPDATE_SPINNER_HIDE, SETTINGS_EXPORT_PREFERENCES, SETTINGS_PREFERENCES, SETTINGS_OPTIMIZED_PRESETS, @@ -700,6 +701,7 @@ public: void notify_child_process_exited(); + OS::ProcessID get_child_process_id() const { return editor_run.get_pid(); } void stop_child_process(); Ref<Theme> get_editor_theme() const { return theme; } diff --git a/tools/editor/editor_run.cpp b/tools/editor/editor_run.cpp index fb0f24c084..5fbb4ae2a0 100644 --- a/tools/editor/editor_run.cpp +++ b/tools/editor/editor_run.cpp @@ -52,6 +52,9 @@ Error EditorRun::run(const String& p_scene,const String p_custom_args,const List args.push_back("localhost:"+String::num(GLOBAL_DEF("debug/debug_port", 6007))); } + args.push_back("-epid"); + args.push_back(String::num(OS::get_singleton()->get_process_ID())); + if (p_custom_args!="") { Vector<String> cargs=p_custom_args.split(" ",false); @@ -132,6 +135,7 @@ Error EditorRun::run(const String& p_scene,const String p_custom_args,const List } + if (p_breakpoints.size()) { args.push_back("-bp"); diff --git a/tools/editor/editor_run.h b/tools/editor/editor_run.h index 0b96a2c91c..5aa2adf801 100644 --- a/tools/editor/editor_run.h +++ b/tools/editor/editor_run.h @@ -53,6 +53,8 @@ public: void run_native_notify() { status=STATUS_PLAY; } void stop(); + OS::ProcessID get_pid() const { return pid; } + void set_debug_collisions(bool p_debug); bool get_debug_collisions() const; diff --git a/tools/editor/editor_settings.cpp b/tools/editor/editor_settings.cpp index 4778a7ce90..bdbf20e348 100644 --- a/tools/editor/editor_settings.cpp +++ b/tools/editor/editor_settings.cpp @@ -546,9 +546,15 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { hints["text_editor/tab_size"]=PropertyInfo(Variant::INT,"text_editor/tab_size",PROPERTY_HINT_RANGE,"1, 64, 1"); // size of 0 crashes. set("text_editor/draw_tabs", true); + set("text_editor/line_numbers_zero_padded", false); + set("text_editor/show_line_numbers", true); set("text_editor/show_breakpoint_gutter", true); + set("text_editor/show_line_length_guideline", false); + set("text_editor/line_length_guideline_column", 80); + hints["text_editor/line_length_guideline_column"]=PropertyInfo(Variant::INT,"text_editor/line_length_guideline_column",PROPERTY_HINT_RANGE,"20, 160, 10"); + set("text_editor/trim_trailing_whitespace_on_save", false); set("text_editor/idle_parse_delay",2); set("text_editor/create_signal_callbacks",true); @@ -565,8 +571,6 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { set("text_editor/restore_scripts_on_load",true); - set("scenetree_editor/duplicate_node_name_num_separator",0); - hints["scenetree_editor/duplicate_node_name_num_separator"]=PropertyInfo(Variant::INT,"scenetree_editor/duplicate_node_name_num_separator",PROPERTY_HINT_ENUM, "None,Space,Underscore,Dash"); //set("scenetree_editor/display_old_action_buttons",false); set("scenetree_editor/start_create_dialog_fully_expanded",false); set("scenetree_editor/draw_relationship_lines",false); diff --git a/tools/editor/fileserver/SCsub b/tools/editor/fileserver/SCsub index 363a2ce4c0..6299fd416c 100644 --- a/tools/editor/fileserver/SCsub +++ b/tools/editor/fileserver/SCsub @@ -1,3 +1,5 @@ +#!/usr/bin/env python + Import('env') Export('env') env.add_source_files(env.tool_sources,"*.cpp") diff --git a/tools/editor/icons/2x/icon_load.png b/tools/editor/icons/2x/icon_load.png Binary files differindex 2e797c448b..729eedd2dd 100644 --- a/tools/editor/icons/2x/icon_load.png +++ b/tools/editor/icons/2x/icon_load.png diff --git a/tools/editor/icons/2x/icon_open.png b/tools/editor/icons/2x/icon_open.png Binary files differdeleted file mode 100644 index 2e797c448b..0000000000 --- a/tools/editor/icons/2x/icon_open.png +++ /dev/null diff --git a/tools/editor/icons/SCsub b/tools/editor/icons/SCsub index 44e28f49e6..9e05d8f391 100644 --- a/tools/editor/icons/SCsub +++ b/tools/editor/icons/SCsub @@ -1,3 +1,5 @@ +#!/usr/bin/env python + Import('env') def make_editor_icons_action(target, source, env): diff --git a/tools/editor/icons/icon_load.png b/tools/editor/icons/icon_load.png Binary files differindex cc05e98ebb..98da8135f2 100644 --- a/tools/editor/icons/icon_load.png +++ b/tools/editor/icons/icon_load.png diff --git a/tools/editor/icons/icon_open.png b/tools/editor/icons/icon_open.png Binary files differdeleted file mode 100644 index cc05e98ebb..0000000000 --- a/tools/editor/icons/icon_open.png +++ /dev/null diff --git a/tools/editor/icons/source/icon_load.svg b/tools/editor/icons/source/icon_load.svg new file mode 100644 index 0000000000..f8e78fb4ea --- /dev/null +++ b/tools/editor/icons/source/icon_load.svg @@ -0,0 +1,85 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="16" + height="16" + viewBox="0 0 16 16" + id="svg2" + version="1.1" + inkscape:version="0.91 r13725" + inkscape:export-filename="/home/godotengine/godot/tools/editor/icons/2x/icon_load.png" + inkscape:export-xdpi="180" + inkscape:export-ydpi="180" + sodipodi:docname="icon_load.svg"> + <defs + id="defs4" /> + <sodipodi:namedview + id="base" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:pageopacity="0.0" + inkscape:pageshadow="2" + inkscape:zoom="22.627417" + inkscape:cx="12.685427" + inkscape:cy="1.6294402" + inkscape:document-units="px" + inkscape:current-layer="layer1" + showgrid="false" + units="px" + inkscape:snap-bbox="true" + inkscape:bbox-paths="true" + inkscape:bbox-nodes="true" + inkscape:snap-bbox-edge-midpoints="true" + inkscape:snap-bbox-midpoints="false" + inkscape:snap-object-midpoints="true" + inkscape:snap-center="true" + inkscape:window-width="1920" + inkscape:window-height="1119" + inkscape:window-x="0" + inkscape:window-y="26" + inkscape:window-maximized="1" + inkscape:snap-smooth-nodes="true" + inkscape:object-nodes="true" + showguides="false"> + <inkscape:grid + type="xygrid" + id="grid3336" + spacingx="0.5" + spacingy="0.5" + empspacing="2" /> + </sodipodi:namedview> + <metadata + id="metadata7"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title></dc:title> + </cc:Work> + </rdf:RDF> + </metadata> + <g + inkscape:label="Layer 1" + inkscape:groupmode="layer" + id="layer1" + transform="translate(0,-1036.3622)"> + <path + style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000000;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;baseline-shift:baseline;text-anchor:start;white-space:normal;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#e0e0e0;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" + d="M 1.5000703,2 C 1.0834036,2 0.7251221,2.1928844 0.4590547,2.4589844 0.1929873,2.7250844 7.03e-5,3.0834 7.03e-5,3.5 l 0.5,8.5 c 0.041565,0.581917 0.1536332,1.110716 0.5214844,1.478516 C 1.3894058,13.846416 1.916737,14 2.5000703,14 l 0.5,0 0.5,0 9.9997657,0 c 0.231666,-10e-5 0.432919,-0.159266 0.486328,-0.384766 l 2,-7.4999996 C 16.060474,5.8013344 15.822456,5.5002 15.499836,5.5 L 4.7559297,5.5 C 4.5236856,5.5003 4.3126587,5.6584963 4.2696015,5.8867188 L 3.0383769,12.412759 C 2.9838992,12.701515 2.7130529,12.963778 2.2988984,12.972656 1.7175274,12.985119 1.5058274,12.46121 1.5000703,12 l -0.5,-8.5 c 0,-0.083 0.057083,-0.2249844 0.1660156,-0.3339844 C 1.2750185,3.0571156 1.416737,3 1.5000703,3 L 12.499836,3 c 0.08333,0 0.225052,0.057016 0.333984,0.1660156 0.108933,0.109 0.224913,0.2750776 0.166016,0.3339844 l 0,1 1,0 0,-1 c 0,-0.4166 -0.192917,-0.7749156 -0.458984,-1.0410156 C 13.274784,2.1928844 12.916503,2 12.499836,2 Z" + transform="translate(0,1036.3622)" + id="path8167" + inkscape:connector-curvature="0" + sodipodi:nodetypes="sscccscccccccssscccssssccssss" /> + </g> +</svg> diff --git a/tools/editor/io_plugins/SCsub b/tools/editor/io_plugins/SCsub index 363a2ce4c0..6299fd416c 100644 --- a/tools/editor/io_plugins/SCsub +++ b/tools/editor/io_plugins/SCsub @@ -1,3 +1,5 @@ +#!/usr/bin/env python + Import('env') Export('env') env.add_source_files(env.tool_sources,"*.cpp") diff --git a/tools/editor/io_plugins/editor_scene_import_plugin.cpp b/tools/editor/io_plugins/editor_scene_import_plugin.cpp index 190b56faba..56af35c6db 100644 --- a/tools/editor/io_plugins/editor_scene_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_scene_import_plugin.cpp @@ -175,6 +175,7 @@ class EditorSceneImportDialog : public ConfirmationDialog { EditorDirDialog *save_select; OptionButton *texture_action; CreateDialog *root_type_choose; + LineEdit *root_node_name; ConfirmationDialog *confirm_open; @@ -639,6 +640,7 @@ void EditorSceneImportDialog::_choose_file(const String& p_path) { } else { #endif save_path->set_text(""); + root_node_name->set_text(""); //save_path->set_text(p_path.get_file().basename()+".scn"); #if 0 } @@ -656,6 +658,9 @@ void EditorSceneImportDialog::_choose_file(const String& p_path) { import_path->set_text(p_path); + if (root_node_name->get_text().size()==0){ + root_node_name->set_text(import_path->get_text().get_file().basename()); + } } void EditorSceneImportDialog::_choose_save_file(const String& p_path) { @@ -788,6 +793,10 @@ void EditorSceneImportDialog::_import(bool p_and_open) { if (!root_default->is_pressed()) { rim->set_option("root_type",root_type->get_text()); } + if (root_node_name->get_text().size()==0) { + root_node_name->set_text(import_path->get_text().get_file().basename()); + } + rim->set_option("root_name",root_node_name->get_text()); List<String> missing; Error err = plugin->import1(rim,&scene,&missing); @@ -946,7 +955,11 @@ void EditorSceneImportDialog::popup_import(const String &p_from) { root_default->set_pressed(true); root_type->set_disabled(true); } - + if (rimd->has_option("root_name")) { + root_node_name->set_text(rimd->get_option("root_name")); + } else { + root_node_name->set_text(root_type->get_text()); // backward compatibility for 2.1 or before + } script_path->set_text(rimd->get_option("post_import_script")); save_path->set_text(p_from.get_base_dir()); @@ -1241,7 +1254,9 @@ EditorSceneImportDialog::EditorSceneImportDialog(EditorNode *p_editor, EditorSce root_default->connect("pressed",this,"_root_default_pressed"); custom_root_hb->add_child(root_default); - + root_node_name = memnew( LineEdit ); + root_node_name->set_h_size_flags(SIZE_EXPAND_FILL); + vbc->add_margin_child(TTR("Root Node Name:"),root_node_name); /* this_import = memnew( OptionButton ); this_import->add_item("Overwrite Existing Scene"); @@ -2185,6 +2200,7 @@ Error EditorSceneImportPlugin::import1(const Ref<ResourceImportMetadata>& p_from } } + scene->set_name(from->get_option("root_name")); _tag_import_paths(scene,scene); *r_node=scene; diff --git a/tools/editor/io_plugins/editor_texture_import_plugin.cpp b/tools/editor/io_plugins/editor_texture_import_plugin.cpp index 60642999f2..2935ea8fe2 100644 --- a/tools/editor/io_plugins/editor_texture_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_texture_import_plugin.cpp @@ -38,6 +38,7 @@ #include "scene/gui/check_button.h" #include "scene/gui/button_group.h" #include "scene/gui/margin_container.h" +#include "scene/io/resource_format_image.h" static const char *flag_names[]={ ("Streaming Format"), @@ -1589,16 +1590,9 @@ Vector<uint8_t> EditorTextureImportPlugin::custom_export(const String& p_path, c } break; //use default } + String validated_path=EditorImportPlugin::validate_source_path(p_path); - int flags=0; - - if (Globals::get_singleton()->get("image_loader/filter")) - flags|=IMAGE_FLAG_FILTER; - if (!Globals::get_singleton()->get("image_loader/gen_mipmaps")) - flags|=IMAGE_FLAG_NO_MIPMAPS; - if (!Globals::get_singleton()->get("image_loader/repeat")) - flags|=IMAGE_FLAG_REPEAT; - + int flags=texture_flags_to_export_flags(ResourceFormatLoaderImage::load_image_flags(validated_path)); flags|=IMAGE_FLAG_FIX_BORDER_ALPHA; print_line("group format"+itos(group_format)); @@ -1607,7 +1601,7 @@ Vector<uint8_t> EditorTextureImportPlugin::custom_export(const String& p_path, c rimd->set_option("quality",group_lossy_quality); rimd->set_option("atlas",false); rimd->set_option("shrink",group_shrink); - rimd->add_source(EditorImportPlugin::validate_source_path(p_path),FileAccess::get_md5(p_path)); + rimd->add_source(validated_path,FileAccess::get_md5(p_path)); } else if (EditorImportExport::get_singleton()->get_image_formats().has(p_path.extension().to_lower()) && EditorImportExport::get_singleton()->get_export_image_action()!=EditorImportExport::IMAGE_ACTION_NONE) { //handled by general image export settings @@ -1619,22 +1613,16 @@ Vector<uint8_t> EditorTextureImportPlugin::custom_export(const String& p_path, c case EditorImportExport::IMAGE_ACTION_COMPRESS_RAM: rimd->set_option("format",IMAGE_FORMAT_COMPRESS_RAM); break; } - int flags=0; - - if (Globals::get_singleton()->get("image_loader/filter")) - flags|=IMAGE_FLAG_FILTER; - if (!Globals::get_singleton()->get("image_loader/gen_mipmaps")) - flags|=IMAGE_FLAG_NO_MIPMAPS; - if (!Globals::get_singleton()->get("image_loader/repeat")) - flags|=IMAGE_FLAG_REPEAT; + String validated_path=EditorImportPlugin::validate_source_path(p_path); + int flags=texture_flags_to_export_flags(ResourceFormatLoaderImage::load_image_flags(validated_path)); flags|=IMAGE_FLAG_FIX_BORDER_ALPHA; rimd->set_option("shrink",EditorImportExport::get_singleton()->get_export_image_shrink()); rimd->set_option("flags",flags); rimd->set_option("quality",EditorImportExport::get_singleton()->get_export_image_quality()); rimd->set_option("atlas",false); - rimd->add_source(EditorImportPlugin::validate_source_path(p_path),FileAccess::get_md5(p_path)); + rimd->add_source(validated_path,FileAccess::get_md5(p_path)); } else { return Vector<uint8_t>(); @@ -1726,6 +1714,33 @@ Vector<uint8_t> EditorTextureImportPlugin::custom_export(const String& p_path, c return ret; } +uint32_t EditorTextureImportPlugin::texture_flags_to_export_flags(uint32_t p_tex_flags) const { + + uint32_t flags=0; + + if (!(p_tex_flags&Texture::FLAG_MIPMAPS)) { + flags|=IMAGE_FLAG_NO_MIPMAPS; + } + if (p_tex_flags&Texture::FLAG_REPEAT) { + flags|=IMAGE_FLAG_REPEAT; + } + if (p_tex_flags&Texture::FLAG_FILTER) { + flags|=IMAGE_FLAG_FILTER; + } + if (p_tex_flags&Texture::FLAG_ANISOTROPIC_FILTER) { + flags|=IMAGE_FLAG_USE_ANISOTROPY; + } + if (p_tex_flags&Texture::FLAG_CONVERT_TO_LINEAR) { + flags|=IMAGE_FLAG_CONVERT_TO_LINEAR; + } + /* // no correspondence yet + if (p_tex_flags&Texture::TEXTURE_FLAG_MIRRORED_REPEAT) { + flags|=; + }*/ + + return flags; +} + void EditorTextureImportPlugin::import_from_drop(const Vector<String>& p_drop,const String& p_dest_path) { Vector<String> valid; diff --git a/tools/editor/io_plugins/editor_texture_import_plugin.h b/tools/editor/io_plugins/editor_texture_import_plugin.h index 5c8abd10a4..22c10a1a3a 100644 --- a/tools/editor/io_plugins/editor_texture_import_plugin.h +++ b/tools/editor/io_plugins/editor_texture_import_plugin.h @@ -72,6 +72,8 @@ private: Error _process_texture_data(Ref<ImageTexture> &texture, int format, float quality, int flags,EditorExportPlatform::ImageCompression p_compr,int tex_flags,float shrink); void compress_image(EditorExportPlatform::ImageCompression p_mode,Image& image,bool p_smaller); + + uint32_t texture_flags_to_export_flags(uint32_t p_tex_flags) const; public: diff --git a/tools/editor/multi_node_edit.cpp b/tools/editor/multi_node_edit.cpp index 4d27b8e349..e4ceaf4a8b 100644 --- a/tools/editor/multi_node_edit.cpp +++ b/tools/editor/multi_node_edit.cpp @@ -53,7 +53,14 @@ bool MultiNodeEdit::_set(const StringName& p_name, const Variant& p_value){ if (!n) continue; - ur->add_do_property(n,name,p_value); + if (p_value.get_type() == Variant::NODE_PATH) { + Node *tonode = n->get_node(p_value); + NodePath p_path = n->get_path_to(tonode); + ur->add_do_property(n,name,p_path); + } else { + ur->add_do_property(n,name,p_value); + } + ur->add_undo_property(n,name,n->get(name)); diff --git a/tools/editor/plugins/SCsub b/tools/editor/plugins/SCsub index 363a2ce4c0..6299fd416c 100644 --- a/tools/editor/plugins/SCsub +++ b/tools/editor/plugins/SCsub @@ -1,3 +1,5 @@ +#!/usr/bin/env python + Import('env') Export('env') env.add_source_files(env.tool_sources,"*.cpp") diff --git a/tools/editor/plugins/animation_player_editor_plugin.cpp b/tools/editor/plugins/animation_player_editor_plugin.cpp index b4d54c6b1e..d6d452dd72 100644 --- a/tools/editor/plugins/animation_player_editor_plugin.cpp +++ b/tools/editor/plugins/animation_player_editor_plugin.cpp @@ -666,7 +666,7 @@ void AnimationPlayerEditor::set_state(const Dictionary& p_state) { return; Node *n = EditorNode::get_singleton()->get_edited_scene()->get_node(p_state["player"]); - if (n && n->cast_to<AnimationPlayer>()) { + if (n && n->cast_to<AnimationPlayer>() && EditorNode::get_singleton()->get_editor_selection()->is_selected(n)) { player=n->cast_to<AnimationPlayer>(); _update_player(); show(); diff --git a/tools/editor/plugins/script_editor_plugin.cpp b/tools/editor/plugins/script_editor_plugin.cpp index fd25843de9..3cd6d8336a 100644 --- a/tools/editor/plugins/script_editor_plugin.cpp +++ b/tools/editor/plugins/script_editor_plugin.cpp @@ -755,29 +755,10 @@ void ScriptEditor::_menu_option(int p_option) { } break; case FILE_SAVE_ALL: { - if (!_test_script_times_on_disk()) + if (_test_script_times_on_disk()) return; save_all_scripts(); - -#if 0 - for(int i=0;i<tab_container->get_child_count();i++) { - - ScriptTextEditor *se = tab_container->get_child(i)->cast_to<ScriptTextEditor>(); - if (!se) - continue; - - - Ref<Script> script = se->get_edited_script(); - - if (script->get_path()=="" || script->get_path().find("local://")!=-1 || script->get_path().find("::")!=-1) - continue; //internal script, who cares - - - editor->save_resource( script ); - } - -#endif } break; case FILE_IMPORT_THEME: { file_dialog->set_mode(EditorFileDialog::MODE_OPEN_FILE); diff --git a/tools/editor/plugins/script_text_editor.cpp b/tools/editor/plugins/script_text_editor.cpp index ca0398f069..40fc3a7bda 100644 --- a/tools/editor/plugins/script_text_editor.cpp +++ b/tools/editor/plugins/script_text_editor.cpp @@ -249,17 +249,7 @@ void ScriptTextEditor::add_callback(const String& p_function,StringArray p_args) void ScriptTextEditor::update_settings() { - code_editor->get_text_edit()->set_auto_brace_completion(EditorSettings::get_singleton()->get("text_editor/auto_brace_complete")); - code_editor->get_text_edit()->set_scroll_pass_end_of_file(EditorSettings::get_singleton()->get("text_editor/scroll_past_end_of_file")); - code_editor->get_text_edit()->set_tab_size(EditorSettings::get_singleton()->get("text_editor/tab_size")); - code_editor->get_text_edit()->set_draw_tabs(EditorSettings::get_singleton()->get("text_editor/draw_tabs")); - code_editor->get_text_edit()->set_show_line_numbers(EditorSettings::get_singleton()->get("text_editor/show_line_numbers")); - code_editor->get_text_edit()->set_syntax_coloring(EditorSettings::get_singleton()->get("text_editor/syntax_highlighting")); - code_editor->get_text_edit()->set_highlight_all_occurrences(EditorSettings::get_singleton()->get("text_editor/highlight_all_occurrences")); - code_editor->get_text_edit()->cursor_set_blink_enabled(EditorSettings::get_singleton()->get("text_editor/caret_blink")); - code_editor->get_text_edit()->cursor_set_blink_speed(EditorSettings::get_singleton()->get("text_editor/caret_blink_speed")); - code_editor->get_text_edit()->set_draw_breakpoint_gutter(EditorSettings::get_singleton()->get("text_editor/show_breakpoint_gutter")); - code_editor->get_text_edit()->cursor_set_block_mode(EditorSettings::get_singleton()->get("text_editor/block_caret")); + code_editor->update_editor_settings(); } bool ScriptTextEditor::is_unsaved() { @@ -498,6 +488,7 @@ void ScriptTextEditor::_code_complete_scripts(void* p_ud,const String& p_code, L void ScriptTextEditor::_code_complete_script(const String& p_code, List<String>* r_options) { + if (color_panel->is_visible()) return; Node *base = get_tree()->get_edited_scene_root(); if (base) { base = _find_node_for_script(base,base,script); @@ -882,6 +873,9 @@ void ScriptTextEditor::_edit_option(int p_op) { case EDIT_TRIM_TRAILING_WHITESAPCE: { trim_trailing_whitespace(); } break; + case EDIT_PICK_COLOR: { + color_panel->popup(); + } break; case SEARCH_FIND: { @@ -989,7 +983,8 @@ void ScriptTextEditor::_bind_methods() { ObjectTypeDB::bind_method("_edit_option",&ScriptTextEditor::_edit_option); ObjectTypeDB::bind_method("_goto_line",&ScriptTextEditor::_goto_line); ObjectTypeDB::bind_method("_lookup_symbol",&ScriptTextEditor::_lookup_symbol); - + ObjectTypeDB::bind_method("_text_edit_input_event", &ScriptTextEditor::_text_edit_input_event); + ObjectTypeDB::bind_method("_color_changed", &ScriptTextEditor::_color_changed); ObjectTypeDB::bind_method("get_drag_data_fw",&ScriptTextEditor::get_drag_data_fw); @@ -1168,6 +1163,96 @@ void ScriptTextEditor::drop_data_fw(const Point2& p_point,const Variant& p_data, } +void ScriptTextEditor::_text_edit_input_event(const InputEvent& ev) { + if (ev.type == InputEvent::MOUSE_BUTTON) { + InputEventMouseButton mb = ev.mouse_button; + if (mb.button_index == BUTTON_RIGHT && !mb.pressed) { + + int col, row; + TextEdit* tx = code_editor->get_text_edit(); + tx->_get_mouse_pos(Point2i(mb.global_x, mb.global_y)-tx->get_global_pos(), row, col); + Vector2 mpos = Vector2(mb.global_x, mb.global_y)-tx->get_global_pos(); + bool have_selection = (tx->get_selection_text().length() > 0); + bool have_color = (tx->get_word_at_pos(mpos) == "Color"); + if (have_color) { + + String line = tx->get_line(row); + color_line = row; + int begin = 0; + int end = 0; + bool valid = false; + for (int i = col; i < line.length(); i++) { + if (line[i] == '(') { + begin = i; + continue; + } + else if (line[i] == ')') { + end = i+1; + valid = true; + break; + } + } + if (valid) { + color_args = line.substr(begin, end-begin); + String stripped = color_args.replace(" ", "").replace("(", "").replace(")", ""); + Vector<float> color = stripped.split_floats(","); + if (color.size() > 2) { + float alpha = color.size() > 3 ? color[3] : 1.0f; + color_picker->set_color(Color(color[0], color[1], color[2], alpha)); + } + color_panel->set_pos(get_global_transform().xform(get_local_mouse_pos())); + Size2 ms = Size2(300, color_picker->get_combined_minimum_size().height+10); + color_panel->set_size(ms); + } else { + have_color = false; + } + } + _make_context_menu(have_selection, have_color); + } + } +} + +void ScriptTextEditor::_color_changed(const Color& p_color) { + String new_args; + if (p_color.a == 1.0f) { + new_args = String("("+rtos(p_color.r)+", "+rtos(p_color.g)+", "+rtos(p_color.b)+")"); + } else { + 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_line); + String new_line = line.replace(color_args, new_args); + color_args = new_args; + code_editor->get_text_edit()->set_line(color_line, new_line); +} + +void ScriptTextEditor::_make_context_menu(bool p_selection, bool p_color) { + + context_menu->clear(); + if (p_selection) { + context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/cut")); + context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/copy")); + } + + context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/paste")); + context_menu->add_separator(); + context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/select_all")); + context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/undo")); + + if (p_selection) { + context_menu->add_separator(); + context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/indent_left")); + context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/indent_right")); + context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/toggle_comment")); + } + if (p_color) { + context_menu->add_separator(); + context_menu->add_item(TTR("Pick Color"), EDIT_PICK_COLOR); + } + context_menu->set_pos(get_global_transform().xform(get_local_mouse_pos())); + context_menu->set_size(Vector2(1, 1)); + context_menu->popup(); +} ScriptTextEditor::ScriptTextEditor() { @@ -1180,23 +1265,26 @@ ScriptTextEditor::ScriptTextEditor() { code_editor->get_text_edit()->connect("breakpoint_toggled", this, "_breakpoint_toggled"); code_editor->get_text_edit()->connect("symbol_lookup", this, "_lookup_symbol"); + update_settings(); - code_editor->get_text_edit()->set_scroll_pass_end_of_file(EditorSettings::get_singleton()->get("text_editor/scroll_past_end_of_file")); - code_editor->get_text_edit()->set_auto_brace_completion(EditorSettings::get_singleton()->get("text_editor/auto_brace_complete")); - code_editor->get_text_edit()->set_tab_size(EditorSettings::get_singleton()->get("text_editor/tab_size")); - code_editor->get_text_edit()->set_draw_tabs(EditorSettings::get_singleton()->get("text_editor/draw_tabs")); - code_editor->get_text_edit()->set_show_line_numbers(EditorSettings::get_singleton()->get("text_editor/show_line_numbers")); - code_editor->get_text_edit()->set_syntax_coloring(EditorSettings::get_singleton()->get("text_editor/syntax_highlighting")); - code_editor->get_text_edit()->set_highlight_all_occurrences(EditorSettings::get_singleton()->get("text_editor/highlight_all_occurrences")); - code_editor->get_text_edit()->cursor_set_blink_enabled(EditorSettings::get_singleton()->get("text_editor/caret_blink")); - code_editor->get_text_edit()->cursor_set_blink_speed(EditorSettings::get_singleton()->get("text_editor/caret_blink_speed")); - code_editor->get_text_edit()->set_draw_breakpoint_gutter(EditorSettings::get_singleton()->get("text_editor/show_breakpoint_gutter")); - code_editor->get_text_edit()->cursor_set_block_mode(EditorSettings::get_singleton()->get("text_editor/block_caret")); code_editor->get_text_edit()->set_callhint_settings( EditorSettings::get_singleton()->get("text_editor/put_callhint_tooltip_below_current_line"), EditorSettings::get_singleton()->get("text_editor/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_edit()->connect("input_event", this, "_text_edit_input_event"); + + context_menu = memnew(PopupMenu); + add_child(context_menu); + context_menu->connect("item_pressed", this, "_edit_option"); + + color_panel = memnew(PopupPanel); + add_child(color_panel); + color_picker = memnew(ColorPicker); + color_panel->add_child(color_picker); + color_panel->set_child_rect(color_picker); + color_picker->connect("color_changed", this, "_color_changed"); edit_hb = memnew (HBoxContainer); @@ -1279,8 +1367,8 @@ void ScriptTextEditor::register_editor() { ED_SHORTCUT("script_text_editor/select_all", TTR("Select All"), KEY_MASK_CMD|KEY_A); ED_SHORTCUT("script_text_editor/move_up", TTR("Move Up"), KEY_MASK_ALT|KEY_UP); ED_SHORTCUT("script_text_editor/move_down", TTR("Move Down"), KEY_MASK_ALT|KEY_DOWN); - ED_SHORTCUT("script_text_editor/indent_left", TTR("Indent Left"), 0); - ED_SHORTCUT("script_text_editor/indent_right", TTR("Indent Right"), 0); + ED_SHORTCUT("script_text_editor/indent_left", TTR("Indent Left"), KEY_MASK_ALT|KEY_LEFT); + ED_SHORTCUT("script_text_editor/indent_right", TTR("Indent Right"), KEY_MASK_ALT|KEY_RIGHT); ED_SHORTCUT("script_text_editor/toggle_comment", TTR("Toggle Comment"), KEY_MASK_CMD|KEY_K); ED_SHORTCUT("script_text_editor/clone_down", TTR("Clone Down"), KEY_MASK_CMD|KEY_B); #ifdef OSX_ENABLED diff --git a/tools/editor/plugins/script_text_editor.h b/tools/editor/plugins/script_text_editor.h index 2c7eac6095..ceef50f0bc 100644 --- a/tools/editor/plugins/script_text_editor.h +++ b/tools/editor/plugins/script_text_editor.h @@ -30,6 +30,7 @@ #define SCRIPT_TEXT_EDITOR_H #include "script_editor_plugin.h" +#include "scene/gui/color_picker.h" class ScriptTextEditor : public ScriptEditorBase { @@ -47,10 +48,16 @@ class ScriptTextEditor : public ScriptEditorBase { MenuButton *edit_menu; MenuButton *search_menu; + PopupMenu *context_menu; GotoLineDialog *goto_line_dialog; ScriptEditorQuickOpen *quick_open; + PopupPanel *color_panel; + ColorPicker *color_picker; + int color_line; + String color_args; + enum { EDIT_UNDO, EDIT_REDO, @@ -67,6 +74,7 @@ class ScriptTextEditor : public ScriptEditorBase { EDIT_INDENT_RIGHT, EDIT_INDENT_LEFT, EDIT_CLONE_DOWN, + EDIT_PICK_COLOR, SEARCH_FIND, SEARCH_FIND_NEXT, SEARCH_FIND_PREV, @@ -96,6 +104,9 @@ protected: static void _bind_methods(); void _edit_option(int p_op); + void _make_context_menu(bool p_selection, bool p_color); + void _text_edit_input_event(const InputEvent& ev); + void _color_changed(const Color& p_color); void _goto_line(int p_line) { goto_line(p_line); } void _lookup_symbol(const String& p_symbol,int p_row, int p_column); diff --git a/tools/editor/plugins/shader_editor_plugin.cpp b/tools/editor/plugins/shader_editor_plugin.cpp index b3317e8313..861f5678f6 100644 --- a/tools/editor/plugins/shader_editor_plugin.cpp +++ b/tools/editor/plugins/shader_editor_plugin.cpp @@ -155,7 +155,7 @@ void ShaderTextEditor::_validate_script() { Error err = ShaderLanguage::compile(code,type,NULL,NULL,&errortxt,&line,&col); if (err!=OK) { - String error_text="error("+itos(line+1)+","+itos(col)+"): "+errortxt; + String error_text="error("+itos(line+1)+","+itos(col+1)+"): "+errortxt; set_error(error_text); get_text_edit()->set_line_as_marked(line,true); @@ -372,41 +372,9 @@ void ShaderEditor::_params_changed() { void ShaderEditor::_editor_settings_changed() { - vertex_editor->get_text_edit()->set_auto_brace_completion(EditorSettings::get_singleton()->get("text_editor/auto_brace_complete")); - vertex_editor->get_text_edit()->set_scroll_pass_end_of_file(EditorSettings::get_singleton()->get("text_editor/scroll_past_end_of_file")); - vertex_editor->get_text_edit()->set_tab_size(EditorSettings::get_singleton()->get("text_editor/tab_size")); - vertex_editor->get_text_edit()->set_draw_tabs(EditorSettings::get_singleton()->get("text_editor/draw_tabs")); - vertex_editor->get_text_edit()->set_show_line_numbers(EditorSettings::get_singleton()->get("text_editor/show_line_numbers")); - vertex_editor->get_text_edit()->set_syntax_coloring(EditorSettings::get_singleton()->get("text_editor/syntax_highlighting")); - vertex_editor->get_text_edit()->set_highlight_all_occurrences(EditorSettings::get_singleton()->get("text_editor/highlight_all_occurrences")); - vertex_editor->get_text_edit()->cursor_set_blink_enabled(EditorSettings::get_singleton()->get("text_editor/caret_blink")); - vertex_editor->get_text_edit()->cursor_set_blink_speed(EditorSettings::get_singleton()->get("text_editor/caret_blink_speed")); - vertex_editor->get_text_edit()->add_constant_override("line_spacing", EditorSettings::get_singleton()->get("text_editor/line_spacing")); - vertex_editor->get_text_edit()->cursor_set_block_mode(EditorSettings::get_singleton()->get("text_editor/block_caret")); - - fragment_editor->get_text_edit()->set_auto_brace_completion(EditorSettings::get_singleton()->get("text_editor/auto_brace_complete")); - fragment_editor->get_text_edit()->set_scroll_pass_end_of_file(EditorSettings::get_singleton()->get("text_editor/scroll_past_end_of_file")); - fragment_editor->get_text_edit()->set_tab_size(EditorSettings::get_singleton()->get("text_editor/tab_size")); - fragment_editor->get_text_edit()->set_draw_tabs(EditorSettings::get_singleton()->get("text_editor/draw_tabs")); - fragment_editor->get_text_edit()->set_show_line_numbers(EditorSettings::get_singleton()->get("text_editor/show_line_numbers")); - fragment_editor->get_text_edit()->set_syntax_coloring(EditorSettings::get_singleton()->get("text_editor/syntax_highlighting")); - fragment_editor->get_text_edit()->set_highlight_all_occurrences(EditorSettings::get_singleton()->get("text_editor/highlight_all_occurrences")); - fragment_editor->get_text_edit()->cursor_set_blink_enabled(EditorSettings::get_singleton()->get("text_editor/caret_blink")); - fragment_editor->get_text_edit()->cursor_set_blink_speed(EditorSettings::get_singleton()->get("text_editor/caret_blink_speed")); - fragment_editor->get_text_edit()->add_constant_override("line_spacing", EditorSettings::get_singleton()->get("text_editor/line_spacing")); - fragment_editor->get_text_edit()->cursor_set_block_mode(EditorSettings::get_singleton()->get("text_editor/block_caret")); - - light_editor->get_text_edit()->set_auto_brace_completion(EditorSettings::get_singleton()->get("text_editor/auto_brace_complete")); - light_editor->get_text_edit()->set_scroll_pass_end_of_file(EditorSettings::get_singleton()->get("text_editor/scroll_past_end_of_file")); - light_editor->get_text_edit()->set_tab_size(EditorSettings::get_singleton()->get("text_editor/tab_size")); - light_editor->get_text_edit()->set_draw_tabs(EditorSettings::get_singleton()->get("text_editor/draw_tabs")); - light_editor->get_text_edit()->set_show_line_numbers(EditorSettings::get_singleton()->get("text_editor/show_line_numbers")); - light_editor->get_text_edit()->set_syntax_coloring(EditorSettings::get_singleton()->get("text_editor/syntax_highlighting")); - light_editor->get_text_edit()->set_highlight_all_occurrences(EditorSettings::get_singleton()->get("text_editor/highlight_all_occurrences")); - light_editor->get_text_edit()->cursor_set_blink_enabled(EditorSettings::get_singleton()->get("text_editor/caret_blink")); - light_editor->get_text_edit()->cursor_set_blink_speed(EditorSettings::get_singleton()->get("text_editor/caret_blink_speed")); - light_editor->get_text_edit()->add_constant_override("line_spacing", EditorSettings::get_singleton()->get("text_editor/line_spacing")); - light_editor->get_text_edit()->cursor_set_block_mode(EditorSettings::get_singleton()->get("text_editor/block_caret")); + vertex_editor->update_editor_settings(); + fragment_editor->update_editor_settings(); + light_editor->update_editor_settings(); } void ShaderEditor::_bind_methods() { diff --git a/tools/editor/plugins/spatial_editor_plugin.cpp b/tools/editor/plugins/spatial_editor_plugin.cpp index 9701b8030d..6dcc71422a 100644 --- a/tools/editor/plugins/spatial_editor_plugin.cpp +++ b/tools/editor/plugins/spatial_editor_plugin.cpp @@ -1978,6 +1978,11 @@ void SpatialEditorViewport::_menu_option(int p_option) { _update_name(); } break; + case VIEW_CENTER_TO_ORIGIN: { + + cursor.pos = Vector3(0,0,0); + + } break; case VIEW_CENTER_TO_SELECTION: { focus_selection(); @@ -2391,6 +2396,7 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(VIEW_GIZMOS),true); view_menu->get_popup()->add_separator(); + view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/focus_origin"), VIEW_CENTER_TO_ORIGIN); view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/focus_selection"), VIEW_CENTER_TO_SELECTION); view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/align_selection_with_view"), VIEW_ALIGN_SELECTION_WITH_VIEW); view_menu->get_popup()->connect("item_pressed",this,"_menu_option"); @@ -3858,6 +3864,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) { ED_SHORTCUT("spatial_editor/switch_perspective_orthogonal", TTR("Switch Perspective/Orthogonal view"), KEY_KP_5); ED_SHORTCUT("spatial_editor/snap", TTR("Snap"), KEY_S); ED_SHORTCUT("spatial_editor/insert_anim_key", TTR("Insert Animation Key"), KEY_K); + ED_SHORTCUT("spatial_editor/focus_origin", TTR("Focus Origin"), KEY_O); ED_SHORTCUT("spatial_editor/focus_selection", TTR("Focus Selection"), KEY_F); ED_SHORTCUT("spatial_editor/align_selection_with_view", TTR("Align Selection With View"), KEY_MASK_ALT+KEY_MASK_CMD+KEY_F); diff --git a/tools/editor/plugins/spatial_editor_plugin.h b/tools/editor/plugins/spatial_editor_plugin.h index 975092a01d..89587526ee 100644 --- a/tools/editor/plugins/spatial_editor_plugin.h +++ b/tools/editor/plugins/spatial_editor_plugin.h @@ -76,6 +76,7 @@ friend class SpatialEditor; VIEW_RIGHT, VIEW_FRONT, VIEW_REAR, + VIEW_CENTER_TO_ORIGIN, VIEW_CENTER_TO_SELECTION, VIEW_ALIGN_SELECTION_WITH_VIEW, VIEW_PERSPECTIVE, diff --git a/tools/editor/plugins/texture_region_editor_plugin.cpp b/tools/editor/plugins/texture_region_editor_plugin.cpp index 43086fb208..6b918e6e8f 100644 --- a/tools/editor/plugins/texture_region_editor_plugin.cpp +++ b/tools/editor/plugins/texture_region_editor_plugin.cpp @@ -653,6 +653,7 @@ void TextureRegionEditor::edit(Object *p_obj) } else { p_obj->connect("texture_changed",this,"_edit_region"); } + p_obj->add_change_receptor(this); p_obj->connect("exit_tree",this,"_node_removed",varray(p_obj),CONNECT_ONESHOT); _edit_region(); } else { @@ -673,6 +674,12 @@ void TextureRegionEditor::edit(Object *p_obj) edit_draw->update(); } +void TextureRegionEditor::_changed_callback(Object *p_changed, const char *p_prop) { + if ((String)p_prop == "region_rect") { + _edit_region(); + } +} + void TextureRegionEditor::_edit_region() { Ref<Texture> texture = NULL; diff --git a/tools/editor/plugins/texture_region_editor_plugin.h b/tools/editor/plugins/texture_region_editor_plugin.h index 3658a38f11..f0bb7c9bc2 100644 --- a/tools/editor/plugins/texture_region_editor_plugin.h +++ b/tools/editor/plugins/texture_region_editor_plugin.h @@ -116,6 +116,8 @@ protected: Vector2 snap_point(Vector2 p_target) const; + virtual void _changed_callback(Object *p_changed, const char *p_prop); + public: void _edit_region(); diff --git a/tools/editor/plugins/theme_editor_plugin.cpp b/tools/editor/plugins/theme_editor_plugin.cpp index 5db331ba45..84568aa8c0 100644 --- a/tools/editor/plugins/theme_editor_plugin.cpp +++ b/tools/editor/plugins/theme_editor_plugin.cpp @@ -668,7 +668,7 @@ ThemeEditor::ThemeEditor() { theme_menu = memnew( MenuButton ); - theme_menu->set_text("Theme"); + theme_menu->set_text(TTR("Theme")); theme_menu->get_popup()->add_item(TTR("Add Item"),POPUP_ADD); theme_menu->get_popup()->add_item(TTR("Add Class Items"),POPUP_CLASS_ADD); theme_menu->get_popup()->add_item(TTR("Remove Item"),POPUP_REMOVE); diff --git a/tools/editor/project_manager.cpp b/tools/editor/project_manager.cpp index b2eae2f6d1..1c99982155 100644 --- a/tools/editor/project_manager.cpp +++ b/tools/editor/project_manager.cpp @@ -142,6 +142,7 @@ private: String sp = p.simplify_path(); project_path->set_text(sp); _path_text_changed(p); + get_ok()->call_deferred("grab_focus"); } void _path_selected(const String& p_path) { @@ -150,7 +151,7 @@ private: String sp = p.simplify_path(); project_path->set_text(sp); _path_text_changed(p); - + get_ok()->call_deferred("grab_focus"); } void _browse_path() { @@ -506,7 +507,7 @@ void ProjectManager::_panel_draw(Node *p_hb) { hb->draw_line(Point2(0,hb->get_size().y+1),Point2(hb->get_size().x-10,hb->get_size().y+1),get_color("guide_color","Tree")); if (selected_list.has(hb->get_meta("name"))) { - hb->draw_style_box(get_stylebox("selected","Tree"),Rect2(Point2(),hb->get_size()-Size2(10,0))); + hb->draw_style_box( gui_base->get_stylebox("selected","Tree"),Rect2(Point2(),hb->get_size()-Size2(10,0))); } } @@ -753,7 +754,7 @@ void ProjectManager::_load_recent_projects() { List<PropertyInfo> properties; EditorSettings::get_singleton()->get_property_list(&properties); - Color font_color = get_color("font_color","Tree"); + Color font_color = gui_base->get_color("font_color","Tree"); List<ProjectItem> projects; List<ProjectItem> favorite_projects; @@ -864,6 +865,7 @@ void ProjectManager::_load_recent_projects() { hb->set_meta("favorite",is_favorite); hb->connect("draw",this,"_panel_draw",varray(hb)); hb->connect("input_event",this,"_panel_input",varray(hb)); + hb->add_constant_override("separation",10*EDSCALE); VBoxContainer *favorite_box = memnew( VBoxContainer ); TextureButton *favorite = memnew( TextureButton ); @@ -885,7 +887,7 @@ void ProjectManager::_load_recent_projects() { ec->set_custom_minimum_size(Size2(0,1)); vb->add_child(ec); Label *title = memnew( Label(project_name) ); - title->add_font_override("font",get_font("large","Fonts")); + title->add_font_override("font", gui_base->get_font("large","Fonts")); title->add_color_override("font_color",font_color); vb->add_child(title); Label *fpath = memnew( Label(path) ); @@ -1205,6 +1207,7 @@ ProjectManager::ProjectManager() { gui_base = memnew( Control ); add_child(gui_base); gui_base->set_area_as_parent_rect(); + gui_base->set_theme(create_custom_theme()); Panel *panel = memnew( Panel ); gui_base->add_child(panel); @@ -1227,7 +1230,7 @@ ProjectManager::ProjectManager() { CenterContainer *ccl = memnew( CenterContainer ); Label *l = memnew( Label ); l->set_text(_MKSTR(VERSION_NAME)+String(" - ")+TTR("Project Manager")); - l->add_font_override("font",get_font("doc","EditorFonts")); + l->add_font_override("font", gui_base->get_font("doc","EditorFonts")); ccl->add_child(l); top_hb->add_child(ccl); top_hb->add_spacer(); @@ -1263,7 +1266,7 @@ ProjectManager::ProjectManager() { search_tree_vb->add_child(search_box); PanelContainer *pc = memnew( PanelContainer); - pc->add_style_override("panel",get_stylebox("bg","Tree")); + pc->add_style_override("panel", gui_base->get_stylebox("bg","Tree")); search_tree_vb->add_child(pc); pc->set_v_size_flags(SIZE_EXPAND_FILL); @@ -1392,8 +1395,6 @@ ProjectManager::ProjectManager() { last_clicked = ""; SceneTree::get_singleton()->connect("files_dropped", this, "_files_dropped"); - - gui_base->set_theme(create_custom_theme()); } diff --git a/tools/editor/property_editor.cpp b/tools/editor/property_editor.cpp index 1a8d373f7f..ef6b1aa47c 100644 --- a/tools/editor/property_editor.cpp +++ b/tools/editor/property_editor.cpp @@ -328,26 +328,26 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty if (c>=2) { if (!hint_text.get_slice(",",1).empty()) - max=hint_text.get_slice(",",1).to_double(); + max=hint_text.get_slice(",",1).to_double(); } - if (type==Variant::REAL && c>=3) { + if (c>=3) { if (!hint_text.get_slice(",",2).empty()) - step= hint_text.get_slice(",",2).to_double(); + step= hint_text.get_slice(",",2).to_double(); } if (c>=4 && hint_text.get_slice(",",3)=="slider") { slider->set_min(min); slider->set_max(max); - slider->set_step((type==Variant::REAL) ? step : 1); + slider->set_step(step); slider->set_val(v); slider->show(); set_size(Size2(110,30)*EDSCALE); } else { spinbox->set_min(min); spinbox->set_max(max); - spinbox->set_step((type==Variant::REAL) ? step : 1); + spinbox->set_step(step); spinbox->set_val(v); spinbox->show(); set_size(Size2(70,35)*EDSCALE); @@ -3049,7 +3049,7 @@ void PropertyEditor::update_tree() { if (E) { descr=E->get().brief_description; } - class_descr_cache[type]=descr.world_wrap(80); + class_descr_cache[type]=descr.word_wrap(80); } @@ -3142,7 +3142,7 @@ void PropertyEditor::update_tree() { if (E) { for(int i=0;i<E->get().methods.size();i++) { if (E->get().methods[i].name==setter.operator String()) { - descr=E->get().methods[i].description.strip_edges().world_wrap(80); + descr=E->get().methods[i].description.strip_edges().word_wrap(80); } } } @@ -3182,6 +3182,7 @@ void PropertyEditor::update_tree() { item->set_cell_mode( 1, TreeItem::CELL_MODE_CHECK ); item->set_text(1,TTR("On")); + item->set_tooltip(1, obj->get(p.name) ? "True" : "False"); item->set_checked( 1, obj->get( p.name ) ); if (show_type_icons) item->set_icon( 0, get_icon("Bool","EditorIcons") ); @@ -3257,7 +3258,7 @@ void PropertyEditor::update_tree() { max=p.hint_string.get_slice(",",1).to_double(); } - if (p.type==Variant::REAL && c>=3) { + if (p.type!=PROPERTY_HINT_SPRITE_FRAME && c>=3) { step= p.hint_string.get_slice(",",2).to_double(); } @@ -3612,9 +3613,10 @@ void PropertyEditor::update_tree() { } break; case Variant::NODE_PATH: { - item->set_cell_mode( 1, TreeItem::CELL_MODE_CUSTOM ); + item->set_cell_mode(1, TreeItem::CELL_MODE_STRING); item->set_editable( 1, !read_only ); item->set_text(1,obj->get(p.name)); + item->add_button(1, get_icon("Collapse", "EditorIcons")); } break; case Variant::OBJECT: { @@ -3828,6 +3830,7 @@ void PropertyEditor::_item_edited() { case Variant::BOOL: { _edit_set(name,item->is_checked(1)); + item->set_tooltip(1, item->is_checked(1) ? "True" : "False"); } break; case Variant::INT: case Variant::REAL: { @@ -3890,6 +3893,7 @@ void PropertyEditor::_item_edited() { } break; case Variant::NODE_PATH: { + _edit_set(name, NodePath(item->get_text(1))); } break; @@ -4065,7 +4069,17 @@ void PropertyEditor::_edit_button(Object *p_item, int p_column, int p_button) { String n = d["name"]; String ht = d["hint_text"]; - if (t==Variant::STRING) { + if(t == Variant::NODE_PATH) { + + Variant v = obj->get(n); + custom_editor->edit(obj, n, (Variant::Type)t, v, h, ht); + Rect2 where = tree->get_item_rect(ti, 1); + where.pos -= tree->get_scroll(); + where.pos += tree->get_global_pos(); + custom_editor->set_pos(where.pos); + custom_editor->popup(); + + } else if (t==Variant::STRING) { Variant v = obj->get(n); diff --git a/tools/editor/scene_tree_dock.cpp b/tools/editor/scene_tree_dock.cpp index 9c4e641535..56f10ff7f8 100644 --- a/tools/editor/scene_tree_dock.cpp +++ b/tools/editor/scene_tree_dock.cpp @@ -227,7 +227,7 @@ void SceneTreeDock::_perform_instance_scenes(const Vector<String>& p_files,Node* editor_data->get_undo_redo().add_do_reference(instanced_scene); editor_data->get_undo_redo().add_undo_method(parent,"remove_child",instanced_scene); - String new_name = parent->validate_child_name(instanced_scene->get_name()); + String new_name = parent->validate_child_name(instanced_scene); ScriptEditorDebugger *sed = ScriptEditor::get_singleton()->get_debugger(); editor_data->get_undo_redo().add_do_method(sed,"live_debug_instance_node",edited_scene->get_path_to(parent),p_files[i],new_name); editor_data->get_undo_redo().add_undo_method(sed,"live_debug_remove_node",NodePath(String(edited_scene->get_path_to(parent))+"/"+new_name)); @@ -238,6 +238,34 @@ void SceneTreeDock::_perform_instance_scenes(const Vector<String>& p_files,Node* } +void SceneTreeDock::_replace_with_branch_scene(const String& p_file,Node* base) { + Ref<PackedScene> sdata = ResourceLoader::load(p_file); + if (!sdata.is_valid()) { + accept->get_ok()->set_text(TTR("Ugh")); + accept->set_text(vformat(TTR("Error loading scene from %s"),p_file)); + accept->popup_centered_minsize(); + return; + } + + Node *instanced_scene=sdata->instance(true); + if (!instanced_scene) { + accept->get_ok()->set_text(TTR("Ugh")); + accept->set_text(vformat(TTR("Error instancing scene from %s"),p_file)); + accept->popup_centered_minsize(); + return; + } + + Node *parent = base->get_parent(); + int pos = base->get_index(); + memdelete(base); + parent->add_child(instanced_scene); + parent->move_child(instanced_scene, pos); + instanced_scene->set_owner(edited_scene); + editor_selection->clear(); + editor_selection->add_node(instanced_scene); + scene_tree->set_selected(instanced_scene); +} + bool SceneTreeDock::_cyclical_dependency_exists(const String& p_target_scene_path, Node* p_desired_node) { int childCount = p_desired_node->get_child_count(); @@ -257,17 +285,6 @@ bool SceneTreeDock::_cyclical_dependency_exists(const String& p_target_scene_pat } -static String _get_name_num_separator() { - switch(EditorSettings::get_singleton()->get("scenetree_editor/duplicate_node_name_num_separator").operator int()) { - case 0: return ""; - case 1: return " "; - case 2: return "_"; - case 3: return "-"; - } - return " "; -} - - void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { current_option=p_tool; @@ -474,37 +491,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { if (selection.size()==1) dupsingle=dup; - String name = node->get_name(); - - String nums; - for(int i=name.length()-1;i>=0;i--) { - CharType n=name[i]; - if (n>='0' && n<='9') { - nums=String::chr(name[i])+nums; - } else { - break; - } - } - - int num=nums.to_int(); - if (num<1) - num=1; - else - num++; - - String nnsep = _get_name_num_separator(); - name = name.substr(0,name.length()-nums.length()).strip_edges(); - if ( name.substr(name.length()-nnsep.length(),nnsep.length()) == nnsep) { - name = name.substr(0,name.length()-nnsep.length()); - } - String attempt = (name + nnsep + itos(num)).strip_edges(); - - while(parent->has_node(attempt)) { - num++; - attempt = (name + nnsep + itos(num)).strip_edges(); - } - - dup->set_name(attempt); + dup->set_name(parent->validate_child_name(dup)); editor_data->get_undo_redo().add_do_method(parent,"_add_child_below_node",node, dup); for (List<Node*>::Element *F=owned.front();F;F=F->next()) { @@ -522,8 +509,8 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { ScriptEditorDebugger *sed = ScriptEditor::get_singleton()->get_debugger(); - editor_data->get_undo_redo().add_do_method(sed,"live_debug_duplicate_node",edited_scene->get_path_to(node),attempt); - editor_data->get_undo_redo().add_undo_method(sed,"live_debug_remove_node",NodePath(String(edited_scene->get_path_to(parent))+"/"+attempt)); + editor_data->get_undo_redo().add_do_method(sed,"live_debug_duplicate_node",edited_scene->get_path_to(node),dup->get_name()); + editor_data->get_undo_redo().add_undo_method(sed,"live_debug_remove_node",NodePath(String(edited_scene->get_path_to(parent))+"/"+dup->get_name())); //parent->add_child(dup); //reselect.push_back(dup); @@ -1109,6 +1096,7 @@ void SceneTreeDock::_do_reparent(Node* p_new_parent,int p_position_in_parent,Vec editor_data->get_undo_redo().create_action(TTR("Reparent Node")); List<Pair<NodePath,NodePath> > path_renames; + Vector<StringName> former_names; int inc=0; @@ -1118,6 +1106,7 @@ void SceneTreeDock::_do_reparent(Node* p_new_parent,int p_position_in_parent,Vec Node *node = p_nodes[ni]; fill_path_renames(node,new_parent,&path_renames); + former_names.push_back(node->get_name()); List<Node*> owned; node->get_owned_by(node->get_owner(),&owned); @@ -1140,7 +1129,7 @@ void SceneTreeDock::_do_reparent(Node* p_new_parent,int p_position_in_parent,Vec editor_data->get_undo_redo().add_do_method(new_parent,"move_child",node,p_position_in_parent+inc); ScriptEditorDebugger *sed = ScriptEditor::get_singleton()->get_debugger(); - String new_name = new_parent->validate_child_name(node->get_name()); + String new_name = new_parent->validate_child_name(node); editor_data->get_undo_redo().add_do_method(sed,"live_debug_reparent_node",edited_scene->get_path_to(node),edited_scene->get_path_to(new_parent),new_name,-1); editor_data->get_undo_redo().add_undo_method(sed,"live_debug_reparent_node",NodePath(String(edited_scene->get_path_to(new_parent))+"/"+new_name),edited_scene->get_path_to(node->get_parent()),node->get_name(),node->get_index()); @@ -1159,6 +1148,7 @@ void SceneTreeDock::_do_reparent(Node* p_new_parent,int p_position_in_parent,Vec editor_data->get_undo_redo().add_do_method(AnimationPlayerEditor::singleton->get_key_editor(),"set_root",node); editor_data->get_undo_redo().add_undo_method(new_parent,"remove_child",node); + editor_data->get_undo_redo().add_undo_method(node,"set_name",former_names[ni]); inc++; @@ -1360,7 +1350,7 @@ void SceneTreeDock::_create() { editor_data->get_undo_redo().add_undo_method(parent,"remove_child",child); - String new_name = parent->validate_child_name(child->get_type()); + String new_name = parent->validate_child_name(child); ScriptEditorDebugger *sed = ScriptEditor::get_singleton()->get_debugger(); editor_data->get_undo_redo().add_do_method(sed,"live_debug_create_node",edited_scene->get_path_to(parent),child->get_type(),new_name); editor_data->get_undo_redo().add_undo_method(sed,"live_debug_remove_node",NodePath(String(edited_scene->get_path_to(parent))+"/"+new_name)); @@ -1551,7 +1541,7 @@ void SceneTreeDock::_new_scene_from(String p_file) { accept->popup_centered_minsize(); return; } - + _replace_with_branch_scene(p_file, base); } else { accept->get_ok()->set_text(TTR("I see..")); accept->set_text(TTR("Error duplicating scene to save it.")); diff --git a/tools/editor/scene_tree_dock.h b/tools/editor/scene_tree_dock.h index 971013a568..8933a03883 100644 --- a/tools/editor/scene_tree_dock.h +++ b/tools/editor/scene_tree_dock.h @@ -153,6 +153,7 @@ class SceneTreeDock : public VBoxContainer { void _filter_changed(const String& p_filter); void _perform_instance_scenes(const Vector<String>& p_files,Node* parent,int p_pos); + void _replace_with_branch_scene(const String& p_file,Node* base); protected: diff --git a/tools/editor/scene_tree_editor.cpp b/tools/editor/scene_tree_editor.cpp index e5a97fa26e..53bfe8cc57 100644 --- a/tools/editor/scene_tree_editor.cpp +++ b/tools/editor/scene_tree_editor.cpp @@ -254,7 +254,7 @@ void SceneTreeEditor::_cell_button_pressed(Object *p_item,int p_column,int p_id) String config_err = n->get_configuration_warning(); if (config_err==String()) return; - config_err=config_err.world_wrap(80); + config_err=config_err.word_wrap(80); warning->set_text(config_err); warning->popup_centered_minsize(); diff --git a/tools/editor/script_editor_debugger.cpp b/tools/editor/script_editor_debugger.cpp index 7fba73ca08..c8170ca9a3 100644 --- a/tools/editor/script_editor_debugger.cpp +++ b/tools/editor/script_editor_debugger.cpp @@ -216,6 +216,8 @@ void ScriptEditorDebugger::debug_continue() { ERR_FAIL_COND(connection.is_null()); ERR_FAIL_COND(!connection->is_connected()); + OS::get_singleton()->enable_for_stealing_focus(EditorNode::get_singleton()->get_child_process_id()); + Array msg; msg.push_back("continue"); ppeer->put_var(msg); |