summaryrefslogtreecommitdiff
path: root/tools/editor
diff options
context:
space:
mode:
Diffstat (limited to 'tools/editor')
-rw-r--r--tools/editor/SCsub28
-rw-r--r--tools/editor/addon_editor_plugin.cpp1273
-rw-r--r--tools/editor/addon_editor_plugin.h286
-rw-r--r--tools/editor/animation_editor.cpp8
-rw-r--r--tools/editor/animation_editor.h2
-rw-r--r--tools/editor/call_dialog.cpp134
-rw-r--r--tools/editor/call_dialog.h26
-rw-r--r--tools/editor/code_editor.cpp14
-rw-r--r--tools/editor/code_editor.h2
-rw-r--r--tools/editor/connections_dialog.cpp120
-rw-r--r--tools/editor/connections_dialog.h30
-rw-r--r--tools/editor/create_dialog.cpp111
-rw-r--r--tools/editor/create_dialog.h18
-rw-r--r--tools/editor/editor_asset_installer.cpp327
-rw-r--r--tools/editor/editor_asset_installer.h28
-rw-r--r--tools/editor/editor_data.cpp33
-rw-r--r--tools/editor/editor_data.h4
-rw-r--r--tools/editor/editor_file_dialog.cpp14
-rw-r--r--tools/editor/editor_file_dialog.h3
-rw-r--r--tools/editor/editor_file_system.cpp2
-rw-r--r--tools/editor/editor_help.cpp227
-rw-r--r--tools/editor/editor_help.h9
-rw-r--r--tools/editor/editor_import_export.cpp120
-rw-r--r--tools/editor/editor_import_export.h11
-rw-r--r--tools/editor/editor_initialize_ssl.cpp21
-rw-r--r--tools/editor/editor_initialize_ssl.h6
-rw-r--r--tools/editor/editor_node.cpp379
-rw-r--r--tools/editor/editor_node.h49
-rw-r--r--tools/editor/editor_plugin.cpp107
-rw-r--r--tools/editor/editor_plugin.h42
-rw-r--r--tools/editor/editor_plugin_settings.cpp188
-rw-r--r--tools/editor/editor_plugin_settings.h35
-rw-r--r--tools/editor/editor_settings.cpp258
-rw-r--r--tools/editor/editor_settings.h14
-rw-r--r--tools/editor/editor_sub_scene.cpp4
-rw-r--r--tools/editor/groups_editor.h2
-rw-r--r--tools/editor/icons/icon_godot_asset_default.pngbin0 -> 4167 bytes
-rw-r--r--tools/editor/icons/icon_h_t_t_p_request.pngbin0 -> 573 bytes
-rw-r--r--tools/editor/icons/icon_link_button.pngbin0 -> 376 bytes
-rw-r--r--tools/editor/icons/icon_rating_no_star.pngbin0 -> 288 bytes
-rw-r--r--tools/editor/icons/icon_rating_star.pngbin0 -> 289 bytes
-rw-r--r--tools/editor/icons/icon_thumbnail_wait.pngbin0 -> 2616 bytes
-rw-r--r--tools/editor/io_plugins/editor_font_import_plugin.cpp2
-rw-r--r--tools/editor/io_plugins/editor_import_collada.cpp8
-rw-r--r--tools/editor/io_plugins/editor_scene_import_plugin.cpp13
-rw-r--r--tools/editor/io_plugins/editor_scene_import_plugin.h2
-rw-r--r--tools/editor/io_plugins/editor_texture_import_plugin.cpp4
-rw-r--r--tools/editor/output_strings.cpp2
-rw-r--r--tools/editor/output_strings.h2
-rw-r--r--tools/editor/plugins/animation_player_editor_plugin.cpp6
-rw-r--r--tools/editor/plugins/animation_tree_editor_plugin.cpp4
-rw-r--r--tools/editor/plugins/baked_light_baker.h2
-rw-r--r--tools/editor/plugins/baked_light_editor_plugin.cpp4
-rw-r--r--tools/editor/plugins/canvas_item_editor_plugin.cpp18
-rw-r--r--tools/editor/plugins/canvas_item_editor_plugin.h14
-rw-r--r--tools/editor/plugins/collision_polygon_editor_plugin.cpp2
-rw-r--r--tools/editor/plugins/collision_shape_2d_editor_plugin.cpp4
-rw-r--r--tools/editor/plugins/color_ramp_editor_plugin.cpp4
-rw-r--r--tools/editor/plugins/control_editor_plugin.cpp56
-rw-r--r--tools/editor/plugins/control_editor_plugin.h24
-rw-r--r--tools/editor/plugins/cube_grid_theme_editor_plugin.cpp4
-rw-r--r--tools/editor/plugins/editor_preview_plugins.cpp6
-rw-r--r--tools/editor/plugins/item_list_editor_plugin.cpp12
-rw-r--r--tools/editor/plugins/multimesh_editor_plugin.cpp2
-rw-r--r--tools/editor/plugins/particles_2d_editor_plugin.cpp28
-rw-r--r--tools/editor/plugins/particles_2d_editor_plugin.h6
-rw-r--r--tools/editor/plugins/path_editor_plugin.cpp12
-rw-r--r--tools/editor/plugins/path_editor_plugin.h6
-rw-r--r--tools/editor/plugins/polygon_2d_editor_plugin.cpp4
-rw-r--r--tools/editor/plugins/resource_preloader_editor_plugin.cpp2
-rw-r--r--tools/editor/plugins/script_editor_plugin.cpp15
-rw-r--r--tools/editor/plugins/shader_editor_plugin.cpp8
-rw-r--r--tools/editor/plugins/spatial_editor_plugin.cpp78
-rw-r--r--tools/editor/plugins/spatial_editor_plugin.h24
-rw-r--r--tools/editor/progress_dialog.cpp4
-rw-r--r--tools/editor/progress_dialog.h2
-rw-r--r--tools/editor/project_settings.cpp56
-rw-r--r--tools/editor/project_settings.h14
-rw-r--r--tools/editor/property_editor.cpp71
-rw-r--r--tools/editor/property_editor.h11
-rw-r--r--tools/editor/reparent_dialog.cpp16
-rw-r--r--tools/editor/reparent_dialog.h16
-rw-r--r--tools/editor/run_settings_dialog.cpp2
-rw-r--r--tools/editor/scene_tree_editor.cpp64
-rw-r--r--tools/editor/scene_tree_editor.h16
-rw-r--r--tools/editor/scenes_dock.cpp6
-rw-r--r--tools/editor/scenes_dock.h2
-rw-r--r--tools/editor/script_create_dialog.cpp4
-rw-r--r--tools/editor/settings_config_dialog.cpp201
-rw-r--r--tools/editor/settings_config_dialog.h14
-rw-r--r--tools/editor/spatial_editor_gizmos.cpp69
-rw-r--r--tools/editor/spatial_editor_gizmos.h94
92 files changed, 3787 insertions, 1188 deletions
diff --git a/tools/editor/SCsub b/tools/editor/SCsub
index cd46ff8353..34651b36f2 100644
--- a/tools/editor/SCsub
+++ b/tools/editor/SCsub
@@ -26,6 +26,31 @@ def make_doc_header(target,source,env):
+def make_certs_header(target,source,env):
+
+ src = source[0].srcnode().abspath
+ dst = target[0].srcnode().abspath
+ f = open(src,"rb")
+ g = open(dst,"wb")
+ buf = f.read()
+ decomp_size = len(buf)
+ import zlib
+ buf = zlib.compress(buf)
+
+
+ g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
+ g.write("#ifndef _CERTS_RAW_H\n")
+ g.write("#define _CERTS_RAW_H\n")
+ g.write("static const int _certs_compressed_size="+str(len(buf))+";\n")
+ g.write("static const int _certs_uncompressed_size="+str(decomp_size)+";\n")
+ g.write("static const unsigned char _certs_compressed[]={\n")
+ for i in range(len(buf)):
+ g.write(str(ord(buf[i]))+",\n")
+ g.write("};\n")
+ g.write("#endif")
+
+
+
@@ -47,6 +72,9 @@ if (env["tools"]=="yes"):
env.Depends("#tools/editor/doc_data_compressed.h","#doc/base/classes.xml")
env.Command("#tools/editor/doc_data_compressed.h","#doc/base/classes.xml",make_doc_header)
+ env.Depends("#tools/editor/certs_compressed.h","#tools/certs/ca-certificates.crt")
+ env.Command("#tools/editor/certs_compressed.h","#tools/certs/ca-certificates.crt",make_certs_header)
+
#make_doc_header(env.File("#tools/editor/doc_data_raw.h").srcnode().abspath,env.File("#doc/base/classes.xml").srcnode().abspath,env)
env.add_source_files(env.tool_sources,"*.cpp")
diff --git a/tools/editor/addon_editor_plugin.cpp b/tools/editor/addon_editor_plugin.cpp
new file mode 100644
index 0000000000..4dfb8ff553
--- /dev/null
+++ b/tools/editor/addon_editor_plugin.cpp
@@ -0,0 +1,1273 @@
+#include "addon_editor_plugin.h"
+#include "editor_node.h"
+#include "editor_settings.h"
+
+
+
+
+void EditorAssetLibraryItem::configure(const String& p_title,int p_asset_id,const String& p_category,int p_category_id,const String& p_author,int p_author_id,int p_rating,const String& p_cost) {
+
+ title->set_text(p_title);
+ asset_id=p_asset_id;
+ category->set_text(p_category);
+ category_id=p_category_id;
+ author->set_text(p_author);
+ author_id=p_author_id;
+ price->set_text(p_cost);
+
+ for(int i=0;i<5;i++) {
+ if (i>2)
+ stars[i]->set_texture(get_icon("RatingNoStar","EditorIcons"));
+ else
+ stars[i]->set_texture(get_icon("RatingStar","EditorIcons"));
+ }
+
+
+}
+
+void EditorAssetLibraryItem::set_image(int p_type,int p_index,const Ref<Texture>& p_image) {
+
+ ERR_FAIL_COND(p_type!=EditorAddonLibrary::IMAGE_QUEUE_ICON);
+ ERR_FAIL_COND(p_index!=0);
+
+ icon->set_normal_texture(p_image);
+}
+
+void EditorAssetLibraryItem::_notification(int p_what) {
+
+ if (p_what==NOTIFICATION_ENTER_TREE) {
+
+ icon->set_normal_texture(get_icon("GodotAssetDefault","EditorIcons"));
+ category->add_color_override("font_color", Color(0.5,0.5,0.5) );
+ author->add_color_override("font_color", Color(0.5,0.5,0.5) );
+
+ }
+}
+
+void EditorAssetLibraryItem::_asset_clicked() {
+
+ emit_signal("asset_selected",asset_id);
+}
+
+void EditorAssetLibraryItem::_category_clicked(){
+
+ emit_signal("category_selected",category_id);
+}
+void EditorAssetLibraryItem::_author_clicked(){
+
+ emit_signal("author_selected",author_id);
+
+}
+
+void EditorAssetLibraryItem::_bind_methods() {
+
+ ObjectTypeDB::bind_method("set_image",&EditorAssetLibraryItem::set_image);
+ ObjectTypeDB::bind_method("_asset_clicked",&EditorAssetLibraryItem::_asset_clicked);
+ ObjectTypeDB::bind_method("_category_clicked",&EditorAssetLibraryItem::_category_clicked);
+ ObjectTypeDB::bind_method("_author_clicked",&EditorAssetLibraryItem::_author_clicked);
+ ADD_SIGNAL( MethodInfo("asset_selected"));
+ ADD_SIGNAL( MethodInfo("category_selected"));
+ ADD_SIGNAL( MethodInfo("author_selected"));
+
+
+}
+
+EditorAssetLibraryItem::EditorAssetLibraryItem() {
+
+ Ref<StyleBoxEmpty> border;
+ border.instance();
+ /*border->set_default_margin(MARGIN_LEFT,5);
+ border->set_default_margin(MARGIN_RIGHT,5);
+ border->set_default_margin(MARGIN_BOTTOM,5);
+ border->set_default_margin(MARGIN_TOP,5);*/
+ add_style_override("panel",border);
+
+ HBoxContainer *hb = memnew( HBoxContainer );
+ add_child(hb);
+
+ icon = memnew( TextureButton );
+ icon->set_default_cursor_shape(CURSOR_POINTING_HAND);
+ icon->connect("pressed",this,"_asset_clicked");
+
+ hb->add_child(icon);
+
+ VBoxContainer *vb = memnew( VBoxContainer );
+
+ hb->add_child(vb);
+ vb->set_h_size_flags(SIZE_EXPAND_FILL);
+
+ title = memnew( LinkButton );
+ title->set_text("My Awesome Addon");
+ title->set_underline_mode(LinkButton::UNDERLINE_MODE_ON_HOVER);
+ title->connect("pressed",this,"_asset_clicked");
+ vb->add_child(title);
+
+
+ category = memnew( LinkButton );
+ category->set_text("Editor Tools");
+ category->set_underline_mode(LinkButton::UNDERLINE_MODE_ON_HOVER);
+ title->connect("pressed",this,"_category_clicked");
+ vb->add_child(category);
+
+ author = memnew( LinkButton );
+ author->set_text("Johny Tolengo");
+ author->set_underline_mode(LinkButton::UNDERLINE_MODE_ON_HOVER);
+ title->connect("pressed",this,"_author_clicked");
+ vb->add_child(author);
+
+ HBoxContainer *rating_hb = memnew( HBoxContainer );
+ vb->add_child(rating_hb);
+
+ for(int i=0;i<5;i++) {
+ stars[i]=memnew(TextureFrame);
+ rating_hb->add_child(stars[i]);
+ }
+ price = memnew( Label );
+ price->set_text("Free");
+ vb->add_child(price);
+
+ set_custom_minimum_size(Size2(250,100));
+ set_h_size_flags(SIZE_EXPAND_FILL);
+
+ set_stop_mouse(false);
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
+
+void EditorAddonLibraryItemDescription::set_image(int p_type,int p_index,const Ref<Texture>& p_image) {
+
+ switch(p_type) {
+
+ case EditorAddonLibrary::IMAGE_QUEUE_ICON: {
+
+ item->call("set_image",p_type,p_index,p_image);
+ icon=p_image;
+ } break;
+ case EditorAddonLibrary::IMAGE_QUEUE_THUMBNAIL: {
+
+ for(int i=0;i<preview_images.size();i++) {
+ if (preview_images[i].id==p_index) {
+ preview_images[i].button->set_icon(p_image);
+ }
+ }
+ //item->call("set_image",p_type,p_index,p_image);
+ } break;
+ case EditorAddonLibrary::IMAGE_QUEUE_SCREENSHOT: {
+
+ for(int i=0;i<preview_images.size();i++) {
+ if (preview_images[i].id==p_index && preview_images[i].button->is_pressed()) {
+ preview->set_texture(p_image);
+ }
+ }
+ //item->call("set_image",p_type,p_index,p_image);
+ } break;
+ }
+}
+
+void EditorAddonLibraryItemDescription::_bind_methods() {
+ ObjectTypeDB::bind_method(_MD("set_image"),&EditorAddonLibraryItemDescription::set_image);
+ ObjectTypeDB::bind_method(_MD("_link_click"),&EditorAddonLibraryItemDescription::_link_click);
+
+}
+
+void EditorAddonLibraryItemDescription::_link_click(const String& p_url) {
+
+ ERR_FAIL_COND(!p_url.begins_with("http"));
+ OS::get_singleton()->shell_open(p_url);
+}
+
+void EditorAddonLibraryItemDescription::configure(const String& p_title,int p_asset_id,const String& p_category,int p_category_id,const String& p_author,int p_author_id,int p_rating,const String& p_cost,const String& p_version,const String& p_description,const String& p_download_url,const String& p_browse_url) {
+
+ asset_id=p_asset_id;
+ title=p_title;
+ download_url=p_download_url;
+ item->configure(p_title,p_asset_id,p_category,p_category_id,p_author,p_author_id,p_rating,p_cost);
+ description->clear();
+ description->add_text("Version: "+p_version+"\n");
+ description->add_text("Contents: ");
+ description->push_meta(p_browse_url);
+ description->add_text("View Files");
+ description->pop();
+ description->add_text("\nDescription:\n\n");
+ description->append_bbcode(p_description);
+ set_title(p_title);
+}
+
+void EditorAddonLibraryItemDescription::add_preview(int p_id, bool p_video,const String& p_url){
+
+ Preview preview;
+ preview.id=p_id;
+ preview.video_link=p_url;
+ preview.button = memnew( Button );
+ preview.button->set_flat(true);
+ preview.button->set_icon(get_icon("ThumbnailWait","EditorIcons"));
+ preview.button->set_toggle_mode(true);
+ preview_hb->add_child(preview.button);
+ if (preview_images.size()==0)
+ preview.button->set_pressed(true);
+ preview_images.push_back(preview);
+}
+
+EditorAddonLibraryItemDescription::EditorAddonLibraryItemDescription() {
+
+ VBoxContainer *vbox = memnew( VBoxContainer );
+ add_child(vbox);
+ set_child_rect(vbox);
+
+
+ HBoxContainer *hbox = memnew( HBoxContainer);
+ vbox->add_child(hbox);
+ vbox->add_constant_override("separation",15);
+ VBoxContainer *desc_vbox = memnew( VBoxContainer );
+ hbox->add_child(desc_vbox);
+ hbox->add_constant_override("separation",15);
+
+ item = memnew( EditorAssetLibraryItem );
+
+ desc_vbox->add_child(item);
+ desc_vbox->set_custom_minimum_size(Size2(300,0));
+
+
+ PanelContainer * desc_bg = memnew( PanelContainer );
+ desc_vbox->add_child(desc_bg);
+ desc_bg->set_v_size_flags(SIZE_EXPAND_FILL);
+
+ description = memnew( RichTextLabel );
+ description->connect("meta_clicked",this,"_link_click");
+ //desc_vbox->add_child(description);
+ desc_bg->add_child(description);
+ desc_bg->add_style_override("panel",get_stylebox("normal","TextEdit"));
+
+ preview = memnew( TextureFrame );
+ preview->set_custom_minimum_size(Size2(640,345));
+ hbox->add_child(preview);
+
+ PanelContainer * previews_bg = memnew( PanelContainer );
+ vbox->add_child(previews_bg);
+ previews_bg->set_custom_minimum_size(Size2(0,85));
+ previews_bg->add_style_override("panel",get_stylebox("normal","TextEdit"));
+
+ previews = memnew( ScrollContainer );
+ previews_bg->add_child(previews);
+ previews->set_enable_v_scroll(false);
+ previews->set_enable_h_scroll(true);
+ preview_hb = memnew( HBoxContainer );
+ preview_hb->set_v_size_flags(SIZE_EXPAND_FILL);
+
+ previews->add_child(preview_hb);
+ get_ok()->set_text("Install");
+ get_cancel()->set_text("Close");
+
+
+
+}
+///////////////////////////////////////////////////////////////////////////////////
+
+void EditorAddonLibraryItemDownload::_http_download_completed(int p_status, int p_code, const StringArray& headers, const ByteArray& p_data) {
+
+
+ String error_text;
+
+ switch(p_status) {
+
+ case HTTPRequest::RESULT_CANT_RESOLVE: {
+ error_text=("Can't resolve hostname: "+host);
+ status->set_text("Can't resolve.");
+ } break;
+ case HTTPRequest::RESULT_BODY_SIZE_LIMIT_EXCEEDED:
+ case HTTPRequest::RESULT_CONNECTION_ERROR:
+ case HTTPRequest::RESULT_CHUNKED_BODY_SIZE_MISMATCH: {
+ error_text=("Connection error, please try again.");
+ status->set_text("Can't connect.");
+ } break;
+ case HTTPRequest::RESULT_SSL_HANDSHAKE_ERROR:
+ case HTTPRequest::RESULT_CANT_CONNECT: {
+ error_text=("Can't connect to host: "+host);
+ status->set_text("Can't connect.");
+ } break;
+ case HTTPRequest::RESULT_NO_RESPONSE: {
+ error_text=("No response from host: "+host);
+ status->set_text("No response.");
+ } break;
+ case HTTPRequest::RESULT_REQUEST_FAILED: {
+ error_text=("Request failed, return code: "+itos(p_code));
+ status->set_text("Req. Failed.");
+ } break;
+ case HTTPRequest::RESULT_REDIRECT_LIMIT_REACHED: {
+ error_text=("Request failed, too many redirects");
+ status->set_text("Redirect Loop.");
+ } break;
+ default: {
+ if (p_code!=200) {
+ error_text=("Request failed, return code: "+itos(p_code));
+ status->set_text("Failed: "+itos(p_code));
+ } else {
+
+ //all good
+ }
+ } break;
+
+ }
+
+ if (error_text!=String()) {
+ download_error->set_text("Asset Download Error:\n"+error_text);
+ download_error->popup_centered_minsize();
+ return;
+
+ }
+
+ progress->set_max( download->get_body_size() );
+ progress->set_val(download->get_downloaded_bytes());
+
+ print_line("max: "+itos(download->get_body_size())+" bytes: "+itos(download->get_downloaded_bytes()));
+ install->set_disabled(false);
+
+ status->set_text("Success!");
+ set_process(false);
+}
+
+
+void EditorAddonLibraryItemDownload::configure(const String& p_title,int p_asset_id,const Ref<Texture>& p_preview, const String& p_download_url) {
+
+ title->set_text(p_title);
+ icon->set_texture(p_preview);
+ asset_id=p_asset_id;
+ if (!p_preview.is_valid())
+ icon->set_texture(get_icon("GodotAssetDefault","EditorIcons"));
+
+ host=p_download_url;
+ set_process(true);
+ download->set_download_file(EditorSettings::get_singleton()->get_settings_path().plus_file("tmp").plus_file("tmp_asset_"+itos(p_asset_id))+".zip");
+ Error err = download->request(p_download_url);
+ ERR_FAIL_COND(err!=OK);
+ asset_installer->connect("confirmed",this,"_close");
+ dismiss->set_normal_texture(get_icon("Close","EditorIcons"));
+
+
+}
+
+
+void EditorAddonLibraryItemDownload::_notification(int p_what) {
+
+ if (p_what==NOTIFICATION_PROCESS) {
+
+ progress->set_max( download->get_body_size() );
+ progress->set_val(download->get_downloaded_bytes());
+
+ int cstatus = download->get_http_client_status();
+ if (cstatus!=prev_status) {
+ switch(cstatus) {
+
+ case HTTPClient::STATUS_RESOLVING: {
+ status->set_text("Resolving..");
+ } break;
+ case HTTPClient::STATUS_CONNECTING: {
+ status->set_text("Connecting..");
+ } break;
+ case HTTPClient::STATUS_REQUESTING: {
+ status->set_text("Requesting..");
+ } break;
+ case HTTPClient::STATUS_BODY: {
+ status->set_text("Downloading..");
+ } break;
+ default: {}
+ }
+ prev_status=cstatus;
+ }
+
+ }
+}
+void EditorAddonLibraryItemDownload::_close() {
+
+ DirAccess *da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
+ da->remove(download->get_download_file()); //clean up removed file
+ memdelete(da);
+ queue_delete();
+}
+
+void EditorAddonLibraryItemDownload::_install() {
+
+ String file = download->get_download_file();
+ asset_installer->open(file,1);
+}
+
+void EditorAddonLibraryItemDownload::_bind_methods() {
+
+ ObjectTypeDB::bind_method("_http_download_completed",&EditorAddonLibraryItemDownload::_http_download_completed);
+ ObjectTypeDB::bind_method("_install",&EditorAddonLibraryItemDownload::_install);
+ ObjectTypeDB::bind_method("_close",&EditorAddonLibraryItemDownload::_close);
+
+}
+
+EditorAddonLibraryItemDownload::EditorAddonLibraryItemDownload() {
+
+ HBoxContainer *hb = memnew( HBoxContainer);
+ add_child(hb);
+ icon = memnew( TextureFrame );
+ hb->add_child(icon);
+
+ VBoxContainer *vb = memnew( VBoxContainer );
+ hb->add_child(vb);
+ vb->set_h_size_flags(SIZE_EXPAND_FILL);
+
+ HBoxContainer *title_hb = memnew( HBoxContainer);
+ vb->add_child(title_hb);
+ title = memnew( Label );
+ title_hb->add_child(title);
+ title->set_h_size_flags(SIZE_EXPAND_FILL);
+
+ dismiss = memnew( TextureButton );
+ dismiss->connect("pressed",this,"_close");
+ title_hb->add_child(dismiss);
+
+ title->set_clip_text(true);
+
+ vb->add_spacer();
+
+ status = memnew (Label("Idle"));
+ vb->add_child(status);
+ status->add_color_override("font_color", Color(0.5,0.5,0.5) );
+ progress = memnew( ProgressBar );
+ vb->add_child(progress);
+
+
+
+ HBoxContainer *hb2 = memnew( HBoxContainer );
+ vb->add_child(hb2);
+ hb2->add_spacer();
+
+ install = memnew( Button );
+ install->set_text("Install");
+ install->set_disabled(true);
+ install->connect("pressed",this,"_install");
+
+ hb2->add_child(install);
+ set_custom_minimum_size(Size2(250,0));
+
+ download = memnew( HTTPRequest );
+ add_child(download);
+ download->connect("request_completed",this,"_http_download_completed");
+
+ download_error = memnew( AcceptDialog );
+ add_child(download_error);
+ download_error->set_title("Download Error");
+
+ asset_installer = memnew( EditorAssetInstaller );
+ add_child(asset_installer);
+
+ prev_status=-1;
+
+
+}
+
+
+
+////////////////////////////////////////////////////////////////////////////////
+void EditorAddonLibrary::_notification(int p_what) {
+
+ if (p_what==NOTIFICATION_READY) {
+ TextureFrame *tf = memnew(TextureFrame);
+ tf->set_texture(get_icon("Error","EditorIcons"));
+ error_hb->add_child(tf);
+ error_label->raise();
+
+ _api_request("api/configure");
+ }
+
+ if (p_what==NOTIFICATION_PROCESS) {
+
+ HTTPClient::Status s = request->get_http_client_status();
+ bool visible = s!=HTTPClient::STATUS_DISCONNECTED;
+
+ if (visible != !load_status->is_hidden()) {
+ load_status->set_hidden(!visible);
+ }
+
+ if (visible) {
+ switch(s) {
+
+ case HTTPClient::STATUS_RESOLVING: {
+ load_status->set_val(0.1);
+ } break;
+ case HTTPClient::STATUS_CONNECTING: {
+ load_status->set_val(0.2);
+ } break;
+ case HTTPClient::STATUS_REQUESTING: {
+ load_status->set_val(0.3);
+ } break;
+ case HTTPClient::STATUS_BODY: {
+ load_status->set_val(0.4);
+ } break;
+ default: {}
+
+ }
+ }
+
+ bool no_downloads = downloads_hb->get_child_count()==0;
+ if (no_downloads != downloads_scroll->is_hidden()) {
+ downloads_scroll->set_hidden(no_downloads);
+ }
+ }
+
+}
+
+
+void EditorAddonLibrary::_install_asset() {
+
+ ERR_FAIL_COND(!description);
+
+ for(int i=0;i<downloads_hb->get_child_count();i++) {
+
+ EditorAddonLibraryItemDownload *d = downloads_hb->get_child(i)->cast_to<EditorAddonLibraryItemDownload>();
+ if (d && d->get_asset_id() == description->get_asset_id()) {
+
+ EditorNode::get_singleton()->show_warning("Download for this asset is already in progress!");
+ return;
+ }
+ }
+
+
+ EditorAddonLibraryItemDownload * download = memnew( EditorAddonLibraryItemDownload );
+ downloads_hb->add_child(download);
+ download->configure(description->get_title(),description->get_asset_id(),description->get_preview_icon(),description->get_download_url());
+
+}
+
+const char* EditorAddonLibrary::sort_key[SORT_MAX]={
+ "rating",
+ "downloads",
+ "name",
+ "cost",
+ "updated"
+};
+
+const char* EditorAddonLibrary::sort_text[SORT_MAX]={
+ "Rating",
+ "Downloads",
+ "Name",
+ "Cost",
+ "Updated"
+};
+
+
+void EditorAddonLibrary::_select_author(int p_id) {
+
+ //opemn author window
+}
+
+void EditorAddonLibrary::_select_category(int p_id){
+
+ for(int i=0;i<categories->get_item_count();i++) {
+
+ if (i==0)
+ continue;
+ int id = categories->get_item_metadata(i);
+ if (id==p_id) {
+ categories->select(i);
+ _search();
+ break;
+ }
+ }
+}
+void EditorAddonLibrary::_select_asset(int p_id){
+
+ _api_request("api/asset","?id="+itos(p_id));
+
+ /*
+ if (description) {
+ memdelete(description);
+ }
+
+
+ description = memnew( EditorAddonLibraryItemDescription );
+ add_child(description);
+ description->popup_centered_minsize();*/
+}
+
+
+
+void EditorAddonLibrary::_image_request_completed(int p_status, int p_code, const StringArray& headers, const ByteArray& p_data,int p_queue_id) {
+
+ ERR_FAIL_COND( !image_queue.has(p_queue_id) );
+
+ if (p_status==HTTPRequest::RESULT_SUCCESS) {
+
+
+ print_line("GOT IMAGE YAY!");
+ Object *obj = ObjectDB::get_instance(image_queue[p_queue_id].target);
+
+ if (obj) {
+ int len=p_data.size();
+ ByteArray::Read r=p_data.read();
+
+ Image image(r.ptr(),len);
+ if (!image.empty()) {
+ Ref<ImageTexture> tex;
+ tex.instance();
+ tex->create_from_image(image);
+
+ obj->call("set_image",image_queue[p_queue_id].image_type,image_queue[p_queue_id].image_index,tex);
+ }
+ }
+ } else {
+ WARN_PRINTS("Error getting PNG file for asset id "+itos(image_queue[p_queue_id].asset_id));
+ }
+
+ image_queue[p_queue_id].request->queue_delete();;
+ image_queue.erase(p_queue_id);
+
+ _update_image_queue();
+
+}
+
+void EditorAddonLibrary::_update_image_queue() {
+
+ int max_images=2;
+ int current_images=0;
+
+ List<int> to_delete;
+ for (Map<int,ImageQueue>::Element *E=image_queue.front();E;E=E->next()) {
+ if (!E->get().active && current_images<max_images) {
+
+ String api;
+ switch(E->get().image_type) {
+ case IMAGE_QUEUE_ICON: api="api/icon/icon.png"; break;
+ case IMAGE_QUEUE_SCREENSHOT: api="api/screenshot/screenshot.png"; break;
+ case IMAGE_QUEUE_THUMBNAIL: api="api/thumbnail/thumbnail.png"; break;
+ }
+
+ print_line("REQUEST ICON FOR: "+itos(E->get().asset_id));
+ Error err = E->get().request->request(host+"/"+api+"?asset_id="+itos(E->get().asset_id)+"&index="+itos(E->get().image_index));
+ if (err!=OK) {
+ to_delete.push_back(E->key());
+ } else {
+ E->get().active=true;
+ }
+ current_images++;
+ } else if (E->get().active) {
+ current_images++;
+ }
+ }
+
+ while(to_delete.size()) {
+ image_queue[to_delete.front()->get()].request->queue_delete();
+ image_queue.erase(to_delete.front()->get());
+ to_delete.pop_front();
+ }
+}
+
+void EditorAddonLibrary::_request_image(ObjectID p_for,int p_asset_id,ImageType p_type,int p_image_index) {
+
+
+ ImageQueue iq;
+ iq.asset_id=p_asset_id;
+ iq.image_index=p_image_index;
+ iq.image_type=p_type;
+ iq.request = memnew( HTTPRequest );
+
+ iq.target=p_for;
+ iq.queue_id=++last_queue_id;
+ iq.active=false;
+
+ iq.request->connect("request_completed",this,"_image_request_completed",varray(iq.queue_id));
+
+ image_queue[iq.queue_id]=iq;
+
+ add_child(iq.request);
+
+ _update_image_queue();
+
+
+}
+
+
+void EditorAddonLibrary::_search(int p_page) {
+
+ String args;
+
+ args=String()+"?sort="+sort_key[sort->get_selected()];
+
+ if (categories->get_selected()>0) {
+
+ args+="&category="+itos(categories->get_item_metadata(categories->get_selected()));
+ }
+
+ if (filter->get_text()!=String()) {
+ args+="&filter="+filter->get_text().http_escape();
+ }
+
+ if (p_page>0) {
+ args+="&page="+itos(p_page);
+ }
+
+ _api_request("api/search",args);
+}
+
+HBoxContainer* EditorAddonLibrary::_make_pages(int p_page,int p_max_page,int p_page_len,int p_total_items,int p_current_items) {
+
+ HBoxContainer * hbc = memnew( HBoxContainer );
+
+ //do the mario
+ int from = p_page-5;
+ if (from<0)
+ from=0;
+ int to = from+10;
+ if (to>p_max_page)
+ to=p_max_page;
+
+ Color gray = Color(0.65,0.65,0.65);
+
+ hbc->add_spacer();
+ hbc->add_constant_override("separation",10);
+
+ LinkButton *first = memnew( LinkButton );
+ first->set_text("first");
+ first->add_color_override("font_color", gray );
+ first->set_underline_mode(LinkButton::UNDERLINE_MODE_ON_HOVER);
+ first->connect("pressed",this,"_search",varray(0));
+ hbc->add_child(first);
+
+ if (p_page>0) {
+ LinkButton *prev = memnew( LinkButton );
+ prev->set_text("prev");
+ prev->add_color_override("font_color", gray );
+ prev->set_underline_mode(LinkButton::UNDERLINE_MODE_ON_HOVER);
+ prev->connect("pressed",this,"_search",varray(p_page-1));
+ hbc->add_child(prev);
+ }
+
+ for(int i=from;i<=to;i++) {
+
+ if (i==p_page) {
+
+ Label *current = memnew(Label);
+ current->set_text(itos(i));
+ hbc->add_child(current);
+ } else {
+
+ LinkButton *current = memnew( LinkButton );
+ current->add_color_override("font_color", gray );
+ current->set_underline_mode(LinkButton::UNDERLINE_MODE_ON_HOVER);
+ current->set_text(itos(i));
+ current->connect("pressed",this,"_search",varray(i));
+
+ hbc->add_child(current);
+
+ }
+ }
+
+ if (p_page<p_max_page) {
+ LinkButton *next = memnew( LinkButton );
+ next->set_text("next");
+ next->add_color_override("font_color", gray );
+ next->set_underline_mode(LinkButton::UNDERLINE_MODE_ON_HOVER);
+ next->connect("pressed",this,"_search",varray(p_page+1));
+
+ hbc->add_child(next);
+ }
+ LinkButton *last = memnew( LinkButton );
+ last->set_text("last");
+ last->add_color_override("font_color", gray );
+ last->set_underline_mode(LinkButton::UNDERLINE_MODE_ON_HOVER);
+ hbc->add_child(last);
+ last->connect("pressed",this,"_search",varray(p_max_page));
+
+ Label *totals = memnew( Label );
+ totals->set_text("( "+itos(from*p_page_len)+" - "+itos(from*p_page_len+p_current_items-1)+" / "+itos(p_total_items)+" )");
+ hbc->add_child(totals);
+
+ hbc->add_spacer();
+
+ return hbc;
+}
+
+
+void EditorAddonLibrary::_api_request(const String& p_request,const String& p_arguments) {
+
+ if (requesting!=REQUESTING_NONE) {
+ request->cancel_request();
+ }
+
+ error_hb->hide();
+ current_request=p_request;
+ request->request(host+"/"+p_request+p_arguments);
+}
+
+
+
+void EditorAddonLibrary::_http_request_completed(int p_status, int p_code, const StringArray& headers, const ByteArray& p_data) {
+
+
+ String str;
+
+ {
+ int datalen=p_data.size();
+ ByteArray::Read r = p_data.read();
+ str.parse_utf8((const char*)r.ptr(),datalen);
+ }
+
+ bool error_abort=true;
+
+ switch(p_status) {
+
+ case HTTPRequest::RESULT_CANT_RESOLVE: {
+ error_label->set_text("Can't resolve hostname: "+host);
+ } break;
+ case HTTPRequest::RESULT_BODY_SIZE_LIMIT_EXCEEDED:
+ case HTTPRequest::RESULT_CONNECTION_ERROR:
+ case HTTPRequest::RESULT_CHUNKED_BODY_SIZE_MISMATCH: {
+ error_label->set_text("Connection error, please try again.");
+ } break;
+ case HTTPRequest::RESULT_SSL_HANDSHAKE_ERROR:
+ case HTTPRequest::RESULT_CANT_CONNECT: {
+ error_label->set_text("Can't connect to host: "+host);
+ } break;
+ case HTTPRequest::RESULT_NO_RESPONSE: {
+ error_label->set_text("No response from host: "+host);
+ } break;
+ case HTTPRequest::RESULT_REQUEST_FAILED: {
+ error_label->set_text("Request failed, return code: "+itos(p_code));
+ } break;
+ case HTTPRequest::RESULT_REDIRECT_LIMIT_REACHED: {
+ error_label->set_text("Request failed, too many redirects");
+
+ } break;
+ default: {
+ if (p_code!=200) {
+ error_label->set_text("Request failed, return code: "+itos(p_code));
+ } else {
+
+ error_abort=false;
+ }
+ } break;
+
+ }
+
+
+ if (error_abort) {
+ error_hb->show();
+ return;
+ }
+
+ print_line("response: "+itos(p_status)+" code: "+itos(p_code));
+ Dictionary d;
+ d.parse_json(str);
+
+ print_line(Variant(d).get_construct_string());
+
+ if (current_request=="api/configure") {
+
+ categories->clear();
+ categories->add_item("All");
+ categories->set_item_metadata(0,0);
+ if (d.has("categories")) {
+ Array clist = d["categories"];
+ for(int i=0;i<clist.size();i++) {
+ Dictionary cat = clist[i];
+ if (!cat.has("name") || !cat.has("id"))
+ continue;
+ String name=cat["name"];
+ int id=cat["id"];
+ categories->add_item(name);
+ categories->set_item_metadata( categories->get_item_count() -1, id);
+ }
+ }
+
+ _search();
+ } else if (current_request=="api/search") {
+
+ if (asset_items) {
+ memdelete(asset_items);
+ }
+
+ if (asset_top_page) {
+ memdelete(asset_top_page);
+ }
+
+ if (asset_bottom_page) {
+ memdelete(asset_bottom_page);
+ }
+
+ int page=0;
+ int pages=1;
+ int page_len=10;
+ int total_items=1;
+ Array result;
+
+
+ if (d.has("page")) {
+ page=d["page"];
+ }
+ if (d.has("pages")) {
+ pages=d["pages"];
+ }
+ if (d.has("page_length")) {
+ page_len=d["page_length"];
+ }
+ if (d.has("total")) {
+ total_items=d["total"];
+ }
+ if (d.has("result")) {
+ result=d["result"];
+ }
+
+ asset_top_page = _make_pages(page,pages,page_len,total_items,result.size());
+ library_vb->add_child(asset_top_page);
+
+ asset_items = memnew( GridContainer );
+ asset_items->set_columns(2);
+ asset_items->add_constant_override("hseparation",10);
+ asset_items->add_constant_override("vseparation",10);
+
+ library_vb->add_child(asset_items);
+
+ asset_bottom_page = _make_pages(page,pages,page_len,total_items,result.size());
+ library_vb->add_child(asset_bottom_page);
+
+ for(int i=0;i<result.size();i++) {
+
+ Dictionary r = result[i];
+
+ ERR_CONTINUE(!r.has("title"));
+ ERR_CONTINUE(!r.has("asset_id"));
+ ERR_CONTINUE(!r.has("author"));
+ ERR_CONTINUE(!r.has("author_id"));
+ ERR_CONTINUE(!r.has("category"));
+ ERR_CONTINUE(!r.has("category_id"));
+ ERR_CONTINUE(!r.has("rating"));
+ ERR_CONTINUE(!r.has("cost"));
+
+
+ EditorAssetLibraryItem *item = memnew( EditorAssetLibraryItem );
+ asset_items->add_child(item);
+ item->configure(r["title"],r["asset_id"],r["category"],r["category_id"],r["author"],r["author_id"],r["rating"],r["cost"]);
+ item->connect("asset_selected",this,"_select_asset");
+ item->connect("author_selected",this,"_select_author");
+ item->connect("category_selected",this,"_category_selected");
+
+ _request_image(item->get_instance_ID(),r["asset_id"],IMAGE_QUEUE_ICON,0);
+ }
+ } else if (current_request=="api/asset") {
+
+ ERR_FAIL_COND(!d.has("info"));
+
+ Dictionary r = d["info"];
+
+ r["download_url"]="https://github.com/reduz/godot-test-addon/archive/master.zip";
+ r["browse_url"]="https://github.com/reduz/godot-test-addon";
+ r["version"]="1.1";
+
+ ERR_FAIL_COND(!r.has("title"));
+ ERR_FAIL_COND(!r.has("asset_id"));
+ ERR_FAIL_COND(!r.has("author"));
+ ERR_FAIL_COND(!r.has("author_id"));
+ ERR_FAIL_COND(!r.has("version"));
+ ERR_FAIL_COND(!r.has("category"));
+ ERR_FAIL_COND(!r.has("category_id"));
+ ERR_FAIL_COND(!r.has("rating"));
+ ERR_FAIL_COND(!r.has("cost"));
+ ERR_FAIL_COND(!r.has("description"));
+ ERR_FAIL_COND(!r.has("download_url"));
+ ERR_FAIL_COND(!r.has("browse_url"));
+
+
+ if (description) {
+ memdelete(description);
+ }
+
+ description = memnew( EditorAddonLibraryItemDescription );
+ add_child(description);
+ description->popup_centered_minsize();
+ description->connect("confirmed",this,"_install_asset");
+
+ description->configure(r["title"],r["asset_id"],r["category"],r["category_id"],r["author"],r["author_id"],r["rating"],r["cost"],r["version"],r["description"],r["download_url"],r["browse_url"]);
+ /*item->connect("asset_selected",this,"_select_asset");
+ item->connect("author_selected",this,"_select_author");
+ item->connect("category_selected",this,"_category_selected");*/
+
+ _request_image(description->get_instance_ID(),r["asset_id"],IMAGE_QUEUE_ICON,0);
+
+ if (d.has("previews")) {
+ Array previews = d["previews"];
+
+ for(int i=0;i<previews.size();i++) {
+
+
+ Dictionary p=previews[i];
+
+ ERR_CONTINUE(!p.has("id"));
+
+ bool is_video=p.has("type") && String(p["type"])=="video";
+ String video_url;
+ if (is_video && p.has("link")) {
+ video_url="link";
+ }
+
+ int id=p["id"];
+
+ description->add_preview(id,is_video,video_url);
+
+ _request_image(description->get_instance_ID(),r["asset_id"],IMAGE_QUEUE_THUMBNAIL,id);
+ if (i==0) {
+ _request_image(description->get_instance_ID(),r["asset_id"],IMAGE_QUEUE_SCREENSHOT,id);
+ }
+
+ }
+ }
+ }
+
+}
+
+
+void EditorAddonLibrary::_asset_file_selected(const String& p_file) {
+
+ if (asset_installer) {
+ memdelete( asset_installer );
+ asset_installer=NULL;
+ }
+
+ asset_installer = memnew( EditorAssetInstaller );
+ add_child(asset_installer);
+ asset_installer->open(p_file);
+
+
+}
+
+void EditorAddonLibrary::_asset_open() {
+
+ asset_open->popup_centered_ratio();
+}
+
+void EditorAddonLibrary::_manage_plugins() {
+
+ ProjectSettings::get_singleton()->popup_project_settings();
+ ProjectSettings::get_singleton()->set_plugins_page();
+}
+
+
+
+void EditorAddonLibrary::_bind_methods() {
+
+ ObjectTypeDB::bind_method("_http_request_completed",&EditorAddonLibrary::_http_request_completed);
+ ObjectTypeDB::bind_method("_select_asset",&EditorAddonLibrary::_select_asset);
+ ObjectTypeDB::bind_method("_select_author",&EditorAddonLibrary::_select_author);
+ ObjectTypeDB::bind_method("_select_category",&EditorAddonLibrary::_select_category);
+ ObjectTypeDB::bind_method("_image_request_completed",&EditorAddonLibrary::_image_request_completed);
+ ObjectTypeDB::bind_method("_search",&EditorAddonLibrary::_search,DEFVAL(0));
+ ObjectTypeDB::bind_method("_install_asset",&EditorAddonLibrary::_install_asset);
+ ObjectTypeDB::bind_method("_manage_plugins",&EditorAddonLibrary::_manage_plugins);
+ ObjectTypeDB::bind_method("_asset_open",&EditorAddonLibrary::_asset_open);
+ ObjectTypeDB::bind_method("_asset_file_selected",&EditorAddonLibrary::_asset_file_selected);
+
+}
+
+EditorAddonLibrary::EditorAddonLibrary() {
+
+
+ Ref<StyleBoxEmpty> border;
+ border.instance();
+ border->set_default_margin(MARGIN_LEFT,15);
+ border->set_default_margin(MARGIN_RIGHT,15);
+ border->set_default_margin(MARGIN_BOTTOM,5);
+ border->set_default_margin(MARGIN_TOP,5);
+
+ add_style_override("panel",border);
+
+ VBoxContainer *library_main = memnew( VBoxContainer );
+
+ add_child(library_main);
+
+ HBoxContainer *search_hb = memnew( HBoxContainer );
+
+ library_main->add_child(search_hb);
+ library_main->add_constant_override("separation",10);
+
+
+
+ search_hb->add_child( memnew( Label("Search: ")));
+ filter =memnew( LineEdit );
+ search_hb->add_child(filter);
+ filter->set_h_size_flags(SIZE_EXPAND_FILL);
+ filter->connect("text_entered",this,"_search");
+ search = memnew( Button("Search"));
+ search->connect("pressed",this,"_search");
+ search_hb->add_child(search);
+
+ search_hb->add_child(memnew( VSeparator ));
+
+ Button * open_asset = memnew( Button );
+ open_asset->set_text("Import");
+ search_hb->add_child(open_asset);
+ open_asset->connect("pressed",this,"_asset_open");
+
+ Button * plugins = memnew( Button );
+ plugins->set_text("Plugins");
+ search_hb->add_child(plugins);
+ plugins->connect("pressed",this,"_manage_plugins");
+
+
+ library_vb->add_child(search_hb);
+
+ HBoxContainer *search_hb2 = memnew( HBoxContainer );
+ library_main->add_child(search_hb2);
+
+ search_hb2->add_child( memnew( Label("Sort: ")));
+ sort = memnew( OptionButton );
+ for(int i=0;i<SORT_MAX;i++) {
+ sort->add_item(sort_text[i]);
+ }
+
+ search_hb2->add_child(sort);
+
+ sort->set_h_size_flags(SIZE_EXPAND_FILL);
+
+ reverse = memnew( CheckBox);
+ reverse->set_text("Reverse");
+ search_hb2->add_child(reverse);
+
+ search_hb2->add_child(memnew(VSeparator));
+
+ //search_hb2->add_spacer();
+
+ search_hb2->add_child( memnew( Label("Category: ")));
+ categories = memnew( OptionButton );
+ categories->add_item("All");
+ search_hb2->add_child(categories);
+ categories->set_h_size_flags(SIZE_EXPAND_FILL);
+ //search_hb2->add_spacer();
+
+ search_hb2->add_child(memnew(VSeparator));
+
+ search_hb2->add_child( memnew( Label("Site: ")));
+ repository = memnew( OptionButton );
+
+ repository->add_item("Godot");
+ search_hb2->add_child(repository);
+ repository->set_h_size_flags(SIZE_EXPAND_FILL);
+
+ /////////
+
+ PanelContainer * library_scroll_bg = memnew( PanelContainer );
+ library_main->add_child(library_scroll_bg);
+ library_scroll_bg->add_style_override("panel",get_stylebox("normal","TextEdit"));
+ library_scroll_bg->set_v_size_flags(SIZE_EXPAND_FILL);
+
+ library_scroll = memnew( ScrollContainer );
+ library_scroll->set_enable_v_scroll(true);
+ library_scroll->set_enable_h_scroll(false);
+
+ library_scroll_bg->add_child(library_scroll);
+
+
+ Ref<StyleBoxEmpty> border2;
+ border2.instance();
+ border2->set_default_margin(MARGIN_LEFT,15);
+ border2->set_default_margin(MARGIN_RIGHT,35);
+ border2->set_default_margin(MARGIN_BOTTOM,15);
+ border2->set_default_margin(MARGIN_TOP,15);
+
+
+ PanelContainer * library_vb_border = memnew( PanelContainer );
+ library_scroll->add_child(library_vb_border);
+ library_vb_border->add_style_override("panel",border2);
+ library_vb_border->set_h_size_flags(SIZE_EXPAND_FILL);
+ library_vb_border->set_stop_mouse(false);
+
+
+
+ library_vb = memnew( VBoxContainer );
+ library_vb->set_h_size_flags(SIZE_EXPAND_FILL);
+
+ library_vb_border->add_child(library_vb);
+// margin_panel->set_stop_mouse(false);
+
+ asset_top_page = memnew( HBoxContainer );
+ library_vb->add_child(asset_top_page);
+
+ asset_items = memnew( GridContainer );
+ asset_items->set_columns(2);
+ asset_items->add_constant_override("hseparation",10);
+ asset_items->add_constant_override("vseparation",10);
+
+ library_vb->add_child(asset_items);
+
+ asset_bottom_page = memnew( HBoxContainer );
+ library_vb->add_child(asset_bottom_page);
+
+ request = memnew( HTTPRequest );
+ add_child(request);
+ request->connect("request_completed",this,"_http_request_completed");
+
+
+ last_queue_id=0;
+
+ library_vb->add_constant_override("separation",20);
+
+ load_status = memnew( ProgressBar );
+ load_status->set_min(0);
+ load_status->set_max(1);
+ load_status->set_step(0.001);
+ library_main->add_child(load_status);
+
+ error_hb = memnew( HBoxContainer );
+ library_main->add_child(error_hb);
+ error_label = memnew( Label );
+ error_label->add_color_override("color",Color(1,0.4,0.3));
+ error_hb->add_child(error_label);
+
+ description = NULL;
+
+ //host="http://localhost:8000";
+ host="http://godotengine.org/addonlib";
+ set_process(true);
+
+ downloads_scroll = memnew( ScrollContainer );
+ downloads_scroll->set_enable_h_scroll(true);
+ downloads_scroll->set_enable_v_scroll(false);
+ library_main->add_child(downloads_scroll);
+ downloads_hb = memnew( HBoxContainer );
+ downloads_scroll->add_child(downloads_hb);
+
+ asset_open = memnew( EditorFileDialog );
+
+ asset_open->set_access(EditorFileDialog::ACCESS_FILESYSTEM);
+ asset_open->add_filter("*.zip ; Assets ZIP File");
+ asset_open->set_mode(EditorFileDialog::MODE_OPEN_FILE);
+ add_child(asset_open);
+ asset_open->connect("file_selected",this,"_asset_file_selected");
+
+ asset_installer=NULL;
+
+}
+
+
+///////
+
+
+void AddonEditorPlugin::make_visible(bool p_visible) {
+
+ if (p_visible) {
+
+ addon_library->show();
+ } else {
+
+ addon_library->hide();
+ }
+
+}
+
+AddonEditorPlugin::AddonEditorPlugin(EditorNode *p_node) {
+
+ editor=p_node;
+ addon_library = memnew( EditorAddonLibrary );
+ addon_library->set_v_size_flags(Control::SIZE_EXPAND_FILL);
+ editor->get_viewport()->add_child(addon_library);
+ addon_library->set_area_as_parent_rect();
+ addon_library->hide();
+
+}
+
+AddonEditorPlugin::~AddonEditorPlugin() {
+
+}
diff --git a/tools/editor/addon_editor_plugin.h b/tools/editor/addon_editor_plugin.h
new file mode 100644
index 0000000000..9cd604a319
--- /dev/null
+++ b/tools/editor/addon_editor_plugin.h
@@ -0,0 +1,286 @@
+#ifndef ADDON_EDITOR_PLUGIN_H
+#define ADDON_EDITOR_PLUGIN_H
+
+
+#include "editor_plugin.h"
+#include "scene/gui/box_container.h"
+#include "scene/gui/line_edit.h"
+#include "scene/gui/option_button.h"
+#include "scene/gui/tab_container.h"
+#include "scene/gui/panel_container.h"
+#include "scene/gui/link_button.h"
+#include "scene/gui/check_box.h"
+#include "scene/gui/progress_bar.h"
+#include "scene/gui/separator.h"
+
+#include "scene/gui/grid_container.h"
+#include "scene/gui/scroll_container.h"
+#include "scene/gui/texture_button.h"
+#include "scene/gui/rich_text_label.h"
+#include "editor_plugin_settings.h"
+
+#include "scene/main/http_request.h"
+#include "editor_asset_installer.h"
+
+class EditorAssetLibraryItem : public PanelContainer {
+
+ OBJ_TYPE( EditorAssetLibraryItem, PanelContainer );
+
+ TextureButton *icon;
+ LinkButton* title;
+ LinkButton* category;
+ LinkButton* author;
+ TextureFrame *stars[5];
+ Label* price;
+
+ int asset_id;
+ int category_id;
+ int author_id;
+
+
+ void _asset_clicked();
+ void _category_clicked();
+ void _author_clicked();
+
+
+ void set_image(int p_type,int p_index,const Ref<Texture>& p_image);
+
+protected:
+
+ void _notification(int p_what);
+ static void _bind_methods();
+public:
+
+ void configure(const String& p_title,int p_asset_id,const String& p_category,int p_category_id,const String& p_author,int p_author_id,int p_rating,const String& p_cost);
+
+
+ EditorAssetLibraryItem();
+};
+
+
+class EditorAddonLibraryItemDescription : public ConfirmationDialog {
+
+ OBJ_TYPE(EditorAddonLibraryItemDescription, ConfirmationDialog);
+
+ EditorAssetLibraryItem *item;
+ RichTextLabel *description;
+ ScrollContainer *previews;
+ HBoxContainer *preview_hb;
+
+ struct Preview {
+ int id;
+ String video_link;
+ Button *button;
+ };
+
+ Vector<Preview> preview_images;
+ TextureFrame *preview;
+
+ void set_image(int p_type,int p_index,const Ref<Texture>& p_image);
+
+ int asset_id;
+ String download_url;
+ String title;
+ Ref<Texture> icon;
+
+ void _link_click(const String& p_url);
+protected:
+
+ static void _bind_methods();
+public:
+
+ void configure(const String& p_title,int p_asset_id,const String& p_category,int p_category_id,const String& p_author,int p_author_id,int p_rating,const String& p_cost,const String& p_version,const String& p_description,const String& p_download_url,const String& p_browse_url);
+ void add_preview(int p_id, bool p_video,const String& p_url);
+
+ String get_title() { return title; }
+ Ref<Texture> get_preview_icon() { return icon; }
+ String get_download_url() { return download_url; }
+ int get_asset_id() { return asset_id; }
+ EditorAddonLibraryItemDescription();
+
+};
+
+class EditorAddonLibraryItemDownload : public PanelContainer {
+
+ OBJ_TYPE(EditorAddonLibraryItemDownload, PanelContainer);
+
+
+ TextureFrame *icon;
+ Label* title;
+ ProgressBar *progress;
+ Button *install;
+ TextureButton *dismiss;
+
+ AcceptDialog *download_error;
+ HTTPRequest *download;
+ String host;
+ Label *status;
+
+ int prev_status;
+
+ int asset_id;
+
+ EditorAssetInstaller *asset_installer;
+
+ void _close();
+ void _install();
+ void _http_download_completed(int p_status, int p_code, const StringArray& headers, const ByteArray& p_data);
+
+protected:
+
+ void _notification(int p_what);
+ static void _bind_methods();
+public:
+
+ int get_asset_id() { return asset_id; }
+ void configure(const String& p_title,int p_asset_id,const Ref<Texture>& p_preview, const String& p_download_url);
+ EditorAddonLibraryItemDownload();
+
+};
+
+class EditorAddonLibrary : public PanelContainer {
+ OBJ_TYPE(EditorAddonLibrary,PanelContainer);
+
+ String host;
+
+ EditorFileDialog *asset_open;
+ EditorAssetInstaller *asset_installer;
+
+
+ void _asset_open();
+ void _asset_file_selected(const String& p_file);
+
+
+ ScrollContainer *library_scroll;
+ VBoxContainer *library_vb;
+ LineEdit *filter;
+ OptionButton *categories;
+ OptionButton *repository;
+ OptionButton *sort;
+ CheckBox *reverse;
+ Button *search;
+ ProgressBar *load_status;
+ HBoxContainer *error_hb;
+ Label *error_label;
+
+ HBoxContainer *contents;
+
+ HBoxContainer *asset_top_page;
+ GridContainer *asset_items;
+ HBoxContainer *asset_bottom_page;
+
+ HTTPRequest *request;
+
+
+ enum SortOrder {
+ SORT_RATING,
+ SORT_DOWNLOADS,
+ SORT_NAME,
+ SORT_COST,
+ SORT_UPDATED,
+ SORT_MAX
+ };
+
+
+ static const char* sort_key[SORT_MAX];
+ static const char* sort_text[SORT_MAX];
+
+
+ ///MainListing
+
+ enum ImageType {
+ IMAGE_QUEUE_ICON,
+ IMAGE_QUEUE_THUMBNAIL,
+ IMAGE_QUEUE_SCREENSHOT,
+
+ };
+
+ struct ImageQueue {
+
+ bool active;
+ int queue_id;
+ int asset_id;
+ ImageType image_type;
+ int image_index;
+ HTTPRequest *request;
+ ObjectID target;
+ };
+
+ int last_queue_id;
+ Map<int,ImageQueue> image_queue;
+
+
+ void _image_request_completed(int p_status, int p_code, const StringArray& headers, const ByteArray& p_data, int p_queue_id);
+
+ void _request_image(ObjectID p_for,int p_asset_id,ImageType p_type,int p_image_index);
+ void _update_image_queue();
+
+ HBoxContainer* _make_pages(int p_page, int p_max_page, int p_page_len, int p_total_items, int p_current_items);
+
+ //
+ EditorAddonLibraryItemDescription *description;
+
+ String current_request;
+ //
+
+ enum RequestType {
+ REQUESTING_NONE,
+ REQUESTING_CONFIG,
+ };
+
+
+ RequestType requesting;
+
+
+ ScrollContainer *downloads_scroll;
+ HBoxContainer *downloads_hb;
+
+
+
+ void _install_asset();
+
+ void _select_author(int p_id);
+ void _select_category(int p_id);
+ void _select_asset(int p_id);
+
+ void _manage_plugins();
+
+ void _search(int p_page=0);
+ void _api_request(const String& p_request, const String &p_arguments="");
+ void _http_request_completed(int p_status, int p_code, const StringArray& headers, const ByteArray& p_data);
+ void _http_download_completed(int p_status, int p_code, const StringArray& headers, const ByteArray& p_data);
+
+friend class EditorAddonLibraryItemDescription;
+friend class EditorAssetLibraryItem;
+protected:
+
+ static void _bind_methods();
+ void _notification(int p_what);
+public:
+ EditorAddonLibrary();
+};
+
+class AddonEditorPlugin : public EditorPlugin {
+
+ OBJ_TYPE( AddonEditorPlugin, EditorPlugin );
+
+ EditorAddonLibrary *addon_library;
+ EditorNode *editor;
+
+public:
+
+ virtual String get_name() const { return "Addons"; }
+ bool has_main_screen() const { return true; }
+ virtual void edit(Object *p_object) {}
+ virtual bool handles(Object *p_object) const { return false; }
+ virtual void make_visible(bool p_visible);
+ //virtual bool get_remove_list(List<Node*> *p_list) { return canvas_item_editor->get_remove_list(p_list); }
+ //virtual Dictionary get_state() const;
+ //virtual void set_state(const Dictionary& p_state);
+
+ AddonEditorPlugin(EditorNode *p_node);
+ ~AddonEditorPlugin();
+
+};
+
+#endif // EDITORASSETLIBRARY_H
diff --git a/tools/editor/animation_editor.cpp b/tools/editor/animation_editor.cpp
index 668a135bc8..091bc701cc 100644
--- a/tools/editor/animation_editor.cpp
+++ b/tools/editor/animation_editor.cpp
@@ -479,7 +479,7 @@ public:
} break;
}
-
+
return false;
@@ -2207,7 +2207,7 @@ void AnimationKeyEditor::_track_editor_input_event(const InputEvent& p_input) {
if (ofsx < add_key_icon->get_width()) {
- Animation::TrackType tt = animation->track_get_type(idx);
+ Animation::TrackType tt = animation->track_get_type(idx);
float pos = timeline_pos;
int existing = animation->track_find_key(idx,pos,true);
@@ -3111,7 +3111,7 @@ void AnimationKeyEditor::_query_insert(const InsertData& p_id) {
if (p_id.track_idx==-1) {
if (bool(EDITOR_DEF("animation/confirm_insert_track",true))) {
- //potential new key, does not exist
+ //potential new key, does not exist
if (insert_data.size()==1)
insert_confirm->set_text("Create NEW track for "+p_id.query+" and insert key?");
else
@@ -3744,7 +3744,7 @@ void AnimationKeyEditor::_bind_methods() {
ObjectTypeDB::bind_method(_MD("_animation_loop_changed"),&AnimationKeyEditor::_animation_loop_changed);
- ObjectTypeDB::bind_method(_MD("_animation_len_changed"),&AnimationKeyEditor::_animation_len_changed);
+ ObjectTypeDB::bind_method(_MD("_animation_len_changed"),&AnimationKeyEditor::_animation_len_changed);
ObjectTypeDB::bind_method(_MD("_create_value_item"),&AnimationKeyEditor::_create_value_item);
ObjectTypeDB::bind_method(_MD("_pane_drag"),&AnimationKeyEditor::_pane_drag);
diff --git a/tools/editor/animation_editor.h b/tools/editor/animation_editor.h
index cd22dc3106..413c73b4b9 100644
--- a/tools/editor/animation_editor.h
+++ b/tools/editor/animation_editor.h
@@ -212,7 +212,7 @@ class AnimationKeyEditor : public VBoxContainer {
ConfirmationDialog *scale_dialog;
SpinBox *scale;
- PropertyEditor *key_editor;
+ PropertyEditor *key_editor;
SceneTreeDialog *call_select;
diff --git a/tools/editor/call_dialog.cpp b/tools/editor/call_dialog.cpp
index edcd7371f2..c5e9cdfa0d 100644
--- a/tools/editor/call_dialog.cpp
+++ b/tools/editor/call_dialog.cpp
@@ -39,22 +39,22 @@ class CallDialogParams : public Object {
public:
bool _set(const StringName& p_name, const Variant& p_value) {
-
+
values[p_name]=p_value;
return true;
}
-
+
bool _get(const StringName& p_name,Variant &r_ret) const {
-
+
if (values.has(p_name)) {
r_ret=values[p_name];
return true;
}
return false;
}
-
+
void _get_property_list( List<PropertyInfo> *p_list) const {
-
+
for(int i=0;i<method.arguments.size();i++)
p_list->push_back(method.arguments[i]);
}
@@ -67,9 +67,9 @@ public:
void CallDialog::_notification(int p_what) {
-
+
if (p_what==NOTIFICATION_READY) {
-
+
call->connect("pressed", this,"_call");
cancel->connect("pressed", this,"_cancel");
//filter->get_path()->connect("text_changed", this,"_text_changed");
@@ -86,35 +86,35 @@ void CallDialog::_notification(int p_what) {
}
if (p_what==NOTIFICATION_DRAW) {
-
+
RID ci = get_canvas_item();
- get_stylebox("panel","PopupMenu")->draw(ci,Rect2(Point2(),get_size()));
- }
+ get_stylebox("panel","PopupMenu")->draw(ci,Rect2(Point2(),get_size()));
+ }
}
void CallDialog::_call() {
-
+
if (!tree->get_selected())
return;
-
+
TreeItem* item=tree->get_selected();
ERR_FAIL_COND(!item);
int idx=item->get_metadata(0);
ERR_FAIL_INDEX(idx,methods.size());
MethodInfo &m = methods[idx];
-
+
Variant args[VARIANT_ARG_MAX];
-
+
for(int i=0;i<VARIANT_ARG_MAX;i++) {
-
+
if (i>=m.arguments.size())
continue;
-
+
if (call_params->values.has(m.arguments[i].name))
args[i]=call_params->values[m.arguments[i].name];
}
-
+
Variant ret = object->call(m.name,args[0],args[1],args[2],args[3],args[4]);
if (ret.get_type()!=Variant::NIL)
return_value->set_text(ret);
@@ -123,7 +123,7 @@ void CallDialog::_call() {
}
void CallDialog::_cancel() {
-
+
hide();
}
@@ -132,23 +132,23 @@ void CallDialog::_item_selected() {
TreeItem* item=tree->get_selected();
ERR_FAIL_COND(!item);
-
+
if (item->get_metadata(0).get_type()==Variant::NIL) {
-
+
call->set_disabled(true);
return;
}
-
+
call->set_disabled(false);
-
+
int idx=item->get_metadata(0);
ERR_FAIL_INDEX(idx,methods.size());
-
+
MethodInfo &m = methods[idx];
call_params->values.clear();
call_params->method=m;
-
+
property_editor->edit(call_params);
property_editor->update_tree();
@@ -156,38 +156,38 @@ void CallDialog::_item_selected() {
}
void CallDialog::_update_method_list() {
-
+
tree->clear();
if (!object)
return;
-
+
TreeItem *root = tree->create_item();
-
+
List<MethodInfo> method_list;
object->get_method_list(&method_list);
method_list.sort();
methods.clear();
-
+
List<String> inheritance_list;
-
+
String type = object->get_type();
-
- while(type!="") {
+
+ while(type!="") {
inheritance_list.push_back( type );
type=ObjectTypeDB::type_inherits_from(type);
}
-
+
TreeItem *selected_item=NULL;
-
+
for(int i=0;i<inheritance_list.size();i++) {
-
+
String type=inheritance_list[i];
String parent_type=ObjectTypeDB::type_inherits_from(type);
TreeItem *type_item=NULL;
-
+
List<MethodInfo>::Element *N,*E=method_list.front();
-
+
while(E) {
N=E->next();
@@ -196,38 +196,38 @@ void CallDialog::_update_method_list() {
E=N;
continue;
}
-
+
if (!type_item) {
type_item=tree->create_item(root);
type_item->set_text(0,type);
if (has_icon(type,"EditorIcons"))
type_item->set_icon(0,get_icon(type,"EditorIcons"));
}
-
+
TreeItem *method_item = tree->create_item(type_item);
method_item->set_text(0,E->get().name);
method_item->set_metadata(0,methods.size());
if (E->get().name==selected)
selected_item=method_item;
methods.push_back( E->get() );
-
+
method_list.erase(E);
E=N;
}
}
-
-
-
+
+
+
if (selected_item)
selected_item->select(0);
}
void CallDialog::_bind_methods() {
-
+
ObjectTypeDB::bind_method("_call",&CallDialog::_call);
ObjectTypeDB::bind_method("_cancel",&CallDialog::_cancel);
ObjectTypeDB::bind_method("_item_selected", &CallDialog::_item_selected);
-
+
}
void CallDialog::set_object(Object *p_object,StringName p_selected) {
@@ -252,22 +252,22 @@ CallDialog::CallDialog() {
call->set_anchor( MARGIN_RIGHT, ANCHOR_END );
call->set_anchor( MARGIN_BOTTOM, ANCHOR_END );
call->set_begin( Point2( 70, 29 ) );
- call->set_end( Point2( 15, 15 ) );
+ call->set_end( Point2( 15, 15 ) );
call->set_text("Call");
-
+
add_child(call);
-
+
cancel = memnew( Button );
cancel->set_anchor( MARGIN_TOP, ANCHOR_END );
cancel->set_anchor( MARGIN_BOTTOM, ANCHOR_END );
cancel->set_begin( Point2( 15, 29 ) );
- cancel->set_end( Point2( 70, 15 ) );
+ cancel->set_end( Point2( 70, 15 ) );
cancel->set_text("Close");
-
+
add_child(cancel);
-
+
tree = memnew( Tree );
-
+
tree->set_anchor( MARGIN_RIGHT, ANCHOR_RATIO );
tree->set_anchor( MARGIN_BOTTOM, ANCHOR_END );
tree->set_begin( Point2( 20,50 ) );
@@ -275,60 +275,60 @@ CallDialog::CallDialog() {
tree->set_margin(MARGIN_RIGHT, 0.5 );
tree->set_select_mode( Tree::SELECT_ROW );
add_child(tree);
-
+
tree->connect("item_selected", this,"_item_selected");
tree->set_hide_root(true);
-
+
property_editor = memnew( PropertyEditor );
-
+
property_editor->set_anchor_and_margin( MARGIN_RIGHT, ANCHOR_END, 15 );
property_editor->set_anchor_and_margin( MARGIN_TOP, ANCHOR_BEGIN, 50 );
property_editor->set_anchor_and_margin( MARGIN_LEFT, ANCHOR_RATIO, 0.55 );
property_editor->set_anchor_and_margin( MARGIN_BOTTOM, ANCHOR_END, 90 );
property_editor->get_scene_tree()->set_hide_root( true );
property_editor->hide_top_label();
-
+
add_child(property_editor);
method_label = memnew( Label );
method_label->set_pos( Point2( 15,25) );
method_label->set_text("Method List:");
-
+
add_child(method_label);
-
+
Label *label = memnew( Label );
label->set_anchor_and_margin( MARGIN_LEFT, ANCHOR_RATIO, 0.53 );
label->set_anchor_and_margin( MARGIN_TOP, ANCHOR_BEGIN, 25 );
label->set_text("Arguments:");
-
+
add_child(label);
-
+
return_label = memnew( Label );
return_label->set_anchor_and_margin( MARGIN_LEFT, ANCHOR_RATIO, 0.53 );
return_label->set_anchor_and_margin( MARGIN_TOP, ANCHOR_END, 85 );
return_label->set_text("Return:");
-
+
add_child(return_label);
-
+
return_value = memnew( LineEdit );
return_value->set_anchor_and_margin( MARGIN_LEFT, ANCHOR_RATIO, 0.55 );
- return_value->set_anchor_and_margin( MARGIN_RIGHT, ANCHOR_END, 15 );
+ return_value->set_anchor_and_margin( MARGIN_RIGHT, ANCHOR_END, 15 );
return_value->set_anchor_and_margin( MARGIN_TOP, ANCHOR_END, 65 );
-
+
add_child(return_value);
-
+
/*
label = memnew( Label );
label->set_anchor( MARGIN_TOP, ANCHOR_END );
label->set_anchor( MARGIN_BOTTOM, ANCHOR_END );
-
+
label->set_begin( Point2( 15,54) );
label->set_end( Point2( 16,44) );
label->set_text("Parameters:");
-
+
add_child(label);
*/
-
+
call_params = memnew( CallDialogParams );
set_as_toplevel(true);
}
diff --git a/tools/editor/call_dialog.h b/tools/editor/call_dialog.h
index 2d04e7b6cd..a2ca925ff1 100644
--- a/tools/editor/call_dialog.h
+++ b/tools/editor/call_dialog.h
@@ -43,39 +43,39 @@
class CallDialogParams;
class CallDialog : public Popup {
-
+
OBJ_TYPE( CallDialog, Popup );
-
+
Label* method_label;
Tree *tree;
Button *call;
Button *cancel;
-
+
CallDialogParams *call_params;
PropertyEditor *property_editor;
-
+
Label *return_label;
LineEdit *return_value;
- Object *object;
+ Object *object;
StringName selected;
-
+
Vector<MethodInfo> methods;
-
-
+
+
void _item_selected();
void _update_method_list();
void _call();
void _cancel();
-
+
protected:
- static void _bind_methods();
+ static void _bind_methods();
void _notification(int p_what);
public:
-
+
void set_object(Object *p_object,StringName p_selected="");
-
- CallDialog();
+
+ CallDialog();
~CallDialog();
};
diff --git a/tools/editor/code_editor.cpp b/tools/editor/code_editor.cpp
index fe863bfebc..968d02dfa5 100644
--- a/tools/editor/code_editor.cpp
+++ b/tools/editor/code_editor.cpp
@@ -85,7 +85,7 @@ void FindReplaceDialog::popup_search() {
skip->hide();
popup_centered(Point2(300,190));
get_ok()->set_text("Find");
- search_text->grab_focus();
+ search_text->grab_focus();
if (text_edit->is_selection_active() && ( text_edit->get_selection_from_line() == text_edit->get_selection_to_line())) {
search_text->set_text( text_edit->get_selection_text() );
@@ -544,7 +544,7 @@ void CodeTextEditor::set_error(const String& p_error) {
}
void CodeTextEditor::_on_settings_change() {
-
+
// FONTS
String editor_font = EDITOR_DEF("text_editor/font", "");
bool font_overrode = false;
@@ -557,8 +557,8 @@ void CodeTextEditor::_on_settings_change() {
}
if(!font_overrode)
text_editor->add_font_override("font",get_font("source","Fonts"));
-
- // AUTO BRACE COMPLETION
+
+ // AUTO BRACE COMPLETION
text_editor->set_auto_brace_completion(
EDITOR_DEF("text_editor/auto_brace_complete", true)
);
@@ -568,6 +568,12 @@ void CodeTextEditor::_on_settings_change() {
);
enable_complete_timer = EDITOR_DEF("text_editor/enable_code_completion_delay",true);
+
+ // call hint settings
+ text_editor->set_callhint_settings(
+ EDITOR_DEF("text_editor/put_callhint_tooltip_below_current_line", true),
+ EDITOR_DEF("text_editor/callhint_tooltip_offset", Vector2())
+ );
}
void CodeTextEditor::_text_changed_idle_timeout() {
diff --git a/tools/editor/code_editor.h b/tools/editor/code_editor.h
index 5ed7ce9052..e28517c601 100644
--- a/tools/editor/code_editor.h
+++ b/tools/editor/code_editor.h
@@ -55,7 +55,7 @@ public:
void set_text_editor(TextEdit *p_text_editor);
- GotoLineDialog();
+ GotoLineDialog();
};
diff --git a/tools/editor/connections_dialog.cpp b/tools/editor/connections_dialog.cpp
index 1e530b21c2..962062ae01 100644
--- a/tools/editor/connections_dialog.cpp
+++ b/tools/editor/connections_dialog.cpp
@@ -30,7 +30,7 @@
#include "scene/gui/label.h"
-
+
#include "print_string.h"
#include "editor_settings.h"
@@ -91,11 +91,11 @@ public:
};
void ConnectDialog::_notification(int p_what) {
-
+
if (p_what==NOTIFICATION_DRAW) {
-
+
RID ci = get_canvas_item();
- get_stylebox("panel","PopupMenu")->draw(ci,Rect2(Point2(),get_size()));
+ get_stylebox("panel","PopupMenu")->draw(ci,Rect2(Point2(),get_size()));
}
if (p_what==NOTIFICATION_ENTER_TREE) {
@@ -104,7 +104,7 @@ void ConnectDialog::_notification(int p_what) {
}
void ConnectDialog::_tree_node_selected() {
-
+
//dst_method_list->get_popup()->clear();
Node *current=tree->get_selected();
@@ -151,17 +151,17 @@ void ConnectDialog::_tree_node_selected() {
}
void ConnectDialog::_dst_method_list_selected(int p_idx) {
-
+
//dst_method->set_text( dst_method_list->get_popup()->get_item_text(p_idx));
}
void ConnectDialog::edit(Node *p_node) {
-
+
node=p_node;
-
+
//dst_method_list->get_popup()->clear();
-
-
+
+
tree->set_selected(NULL);
tree->set_marked(node,true);
dst_path->set_text("");
@@ -173,7 +173,7 @@ void ConnectDialog::edit(Node *p_node) {
}
void ConnectDialog::ok_pressed() {
-
+
if (dst_method->get_text()=="") {
error->set_text("Method in target Node must be specified!");
@@ -185,13 +185,13 @@ void ConnectDialog::ok_pressed() {
}
void ConnectDialog::_cancel_pressed() {
-
+
hide();
}
NodePath ConnectDialog::get_dst_path() const {
-
+
return dst_path->get_text();
}
@@ -207,11 +207,11 @@ bool ConnectDialog::get_oneshot() const {
}
StringName ConnectDialog::get_dst_method() const {
-
+
String txt=dst_method->get_text();
if (txt.find("(")!=-1)
txt=txt.left( txt.find("(")).strip_edges();
- return txt;
+ return txt;
}
@@ -280,7 +280,7 @@ void ConnectDialog::set_dst_method(const StringName& p_method) {
}
void ConnectDialog::_bind_methods() {
-
+
//ObjectTypeDB::bind_method("_ok",&ConnectDialog::_ok_pressed);
ObjectTypeDB::bind_method("_cancel",&ConnectDialog::_cancel_pressed);
//ObjectTypeDB::bind_method("_dst_method_list_selected",&ConnectDialog::_dst_method_list_selected);
@@ -293,17 +293,17 @@ void ConnectDialog::_bind_methods() {
}
ConnectDialog::ConnectDialog() {
-
+
int margin = get_constant("margin","Dialogs");
int button_margin = get_constant("button_margin","Dialogs");
-
-
+
+
Label * label = memnew( Label );
label->set_pos( Point2( 8,11) );
label->set_text("Connect To Node:");
-
- add_child(label);
+
+ add_child(label);
label = memnew( Label );
label->set_anchor( MARGIN_LEFT, ANCHOR_RATIO );
label->set_pos( Point2( 0.5,11) );
@@ -379,7 +379,7 @@ ConnectDialog::ConnectDialog() {
label->set_begin( Point2( 8,124) );
label->set_end( Point2( 15,99) );
label->set_text("Path To Node:");
-
+
add_child(label);
dst_path = memnew(LineEdit);
@@ -390,11 +390,11 @@ ConnectDialog::ConnectDialog() {
dst_path->set_end( Point2( 15,80 ) );
add_child(dst_path);
-
+
label = memnew( Label );
label->set_anchor( MARGIN_TOP, ANCHOR_END );
label->set_anchor( MARGIN_RIGHT, ANCHOR_END );
- label->set_anchor( MARGIN_BOTTOM, ANCHOR_END );
+ label->set_anchor( MARGIN_BOTTOM, ANCHOR_END );
label->set_begin( Point2( 8,78 ) );
label->set_end( Point2( 15,52 ) );
label->set_text("Method In Node:");
@@ -420,7 +420,7 @@ ConnectDialog::ConnectDialog() {
dst_method_list->set_anchor( MARGIN_RIGHT, ANCHOR_END );
dst_method_list->set_anchor( MARGIN_LEFT, ANCHOR_END );
dst_method_list->set_anchor( MARGIN_TOP, ANCHOR_END );
- dst_method_list->set_anchor( MARGIN_BOTTOM, ANCHOR_END );
+ dst_method_list->set_anchor( MARGIN_BOTTOM, ANCHOR_END );
dst_method_list->set_begin( Point2( 70,59) );
dst_method_list->set_end( Point2( 15,39 ) );
*/
@@ -446,14 +446,14 @@ ConnectDialog::ConnectDialog() {
realtime->set_anchor( MARGIN_BOTTOM, ANCHOR_END );
realtime->set_anchor( MARGIN_RIGHT, ANCHOR_END );
realtime->set_begin( Point2( 120, button_margin-10 ) );
- realtime->set_end( Point2( 80, margin ) );
+ realtime->set_end( Point2( 80, margin ) );
realtime->set_text("Realtime");
add_child(realtime);
*/
-
-
+
+
// dst_method_list->get_popup()->connect("item_pressed", this,"_dst_method_list_selected");
tree->connect("node_selected", this,"_tree_node_selected");
@@ -468,8 +468,8 @@ ConnectDialog::ConnectDialog() {
// error->get_cancel()->set_text("Close");
-
-
+
+
}
@@ -481,21 +481,21 @@ ConnectDialog::~ConnectDialog()
void ConnectionsDialog::_notification(int p_what) {
-
+
if (p_what==NOTIFICATION_DRAW) {
-
+
RID ci = get_canvas_item();
- get_stylebox("panel","PopupMenu")->draw(ci,Rect2(Point2(),get_size()));
- }
+ get_stylebox("panel","PopupMenu")->draw(ci,Rect2(Point2(),get_size()));
+ }
}
void ConnectionsDialog::_close() {
-
- hide();
+
+ hide();
}
void ConnectionsDialog::_connect() {
-
+
TreeItem *it = tree->get_selected();
ERR_FAIL_COND(!it);
String signal=it->get_metadata(0).operator Dictionary()["name"];
@@ -534,7 +534,7 @@ void ConnectionsDialog::_connect() {
void ConnectionsDialog::ok_pressed() {
-
+
TreeItem *item = tree->get_selected();
if (!item) {
@@ -585,31 +585,31 @@ void ConnectionsDialog::ok_pressed() {
}
/*
void ConnectionsDialog::_remove() {
-
+
if (!tree->get_selected())
return;
-
+
TreeItem *selected=tree->get_selected();
if (!selected)
return;
-
+
Dictionary meta=selected->get_metadata(0);
-
+
remove_confirm->set_text(String()+"Remove Connection \""+meta["from_event"].operator String()+"\" ?");
remove_confirm->popup_centered(Size2(340,80));
}
*/
/*
void ConnectionsDialog::_remove_confirm() {
-
+
if (!tree->get_selected())
return;
TreeItem *selected=tree->get_selected();
if (!selected)
return;
-
+
Dictionary meta=selected->get_metadata(0);
-
+
undo_redo->create_action("Remove Subscription");
undo_redo->add_do_method(node,"unsubscribe_path_event",meta["from_event"].operator String(),meta["from_path"].operator NodePath(),meta["to_method"].operator String());
undo_redo->add_undo_method(node,"subscribe_path_event_persist",meta["from_event"].operator String(),meta["from_path"].operator NodePath(),meta["to_method"].operator String(),Array(),false);
@@ -628,14 +628,14 @@ struct _ConnectionsDialogMethodInfoSort {
};
void ConnectionsDialog::update_tree() {
-
+
if (!is_visible())
return; //don't update if not visible, of course
tree->clear();
-
+
if (!node)
return;
-
+
TreeItem *root=tree->create_item();
@@ -779,7 +779,7 @@ void ConnectionsDialog::update_tree() {
}
void ConnectionsDialog::set_node(Node* p_node) {
-
+
node=p_node;
update_tree();
}
@@ -806,7 +806,7 @@ void ConnectionsDialog::_something_selected() {
}
void ConnectionsDialog::_bind_methods() {
-
+
ObjectTypeDB::bind_method("_connect",&ConnectionsDialog::_connect);
ObjectTypeDB::bind_method("_something_selected",&ConnectionsDialog::_something_selected);
@@ -814,11 +814,11 @@ void ConnectionsDialog::_bind_methods() {
// ObjectTypeDB::bind_method("_remove_confirm",&ConnectionsDialog::_remove_confirm);
ObjectTypeDB::bind_method("update_tree",&ConnectionsDialog::update_tree);
-
+
}
ConnectionsDialog::ConnectionsDialog(EditorNode *p_editor) {
-
+
editor=p_editor;
set_title("Edit Connections..");
set_hide_on_ok(false);
@@ -828,28 +828,28 @@ ConnectionsDialog::ConnectionsDialog(EditorNode *p_editor) {
set_child_rect(vbc);
-
+
tree = memnew( Tree );
tree->set_columns(1);
tree->set_select_mode(Tree::SELECT_ROW);
tree->set_hide_root(true);
vbc->add_margin_child("Connections:",tree,true);
-
+
// add_child(tree);
-
+
connect_dialog = memnew( ConnectDialog );
connect_dialog->set_as_toplevel(true);
add_child(connect_dialog);
-
+
remove_confirm = memnew( ConfirmationDialog );
remove_confirm->set_as_toplevel(true);
add_child(remove_confirm);
-
- /*
+
+ /*
node_only->set_anchor( MARGIN_TOP, ANCHOR_END );
node_only->set_anchor( MARGIN_BOTTOM, ANCHOR_END );
node_only->set_anchor( MARGIN_RIGHT, ANCHOR_END );
-
+
node_only->set_begin( Point2( 20,51) );
node_only->set_end( Point2( 10,44) );
*/
@@ -859,7 +859,7 @@ ConnectionsDialog::ConnectionsDialog(EditorNode *p_editor) {
connect_dialog->connect("connected", this,"_connect");
tree->connect("item_selected", this,"_something_selected");
get_cancel()->set_text("Close");
-
+
}
diff --git a/tools/editor/connections_dialog.h b/tools/editor/connections_dialog.h
index d5e228e799..575bcf54d7 100644
--- a/tools/editor/connections_dialog.h
+++ b/tools/editor/connections_dialog.h
@@ -47,9 +47,9 @@
class ConnectDialogBinds;
class ConnectDialog : public ConfirmationDialog {
-
+
OBJ_TYPE( ConnectDialog, ConfirmationDialog );
-
+
ConfirmationDialog *error;
LineEdit *dst_path;
@@ -69,34 +69,34 @@ class ConnectDialog : public ConfirmationDialog {
void _dst_method_list_selected(int p_idx);
void _add_bind();
void _remove_bind();
-
+
protected:
void _notification(int p_what);
- static void _bind_methods();
+ static void _bind_methods();
public:
-
+
bool get_make_callback() { return !make_callback->is_hidden() && make_callback->is_pressed(); }
NodePath get_dst_path() const;
- StringName get_dst_method() const;
+ StringName get_dst_method() const;
bool get_deferred() const;
bool get_oneshot() const;
Vector<Variant> get_binds() const;
void set_dst_method(const StringName& p_method);
void set_dst_node(Node* p_node);
-
+
// Button *get_ok() { return ok; }
// Button *get_cancel() { return cancel; }
void edit(Node *p_node);
-
+
ConnectDialog();
~ConnectDialog();
-
+
};
class ConnectionsDialog : public ConfirmationDialog {
-
+
OBJ_TYPE( ConnectionsDialog , ConfirmationDialog );
EditorNode *editor;
@@ -104,7 +104,7 @@ class ConnectionsDialog : public ConfirmationDialog {
Tree *tree;
ConfirmationDialog *remove_confirm;
ConnectDialog *connect_dialog;
-
+
void update_tree();
void _close();
@@ -113,20 +113,20 @@ class ConnectionsDialog : public ConfirmationDialog {
UndoRedo *undo_redo;
protected:
-
+
virtual void ok_pressed();
void _notification(int p_what);
static void _bind_methods();
public:
-
+
void set_undoredo(UndoRedo *p_undo_redo) { undo_redo=p_undo_redo; }
void set_node(Node* p_node);
String get_selected_type();
-
+
ConnectionsDialog(EditorNode *p_editor=NULL);
~ConnectionsDialog();
-
+
};
#endif
diff --git a/tools/editor/create_dialog.cpp b/tools/editor/create_dialog.cpp
index 0f39d72308..35688917fb 100644
--- a/tools/editor/create_dialog.cpp
+++ b/tools/editor/create_dialog.cpp
@@ -171,6 +171,7 @@ void CreateDialog::_update_search() {
if (EditorNode::get_editor_data().get_custom_types().has(type)) {
//there are custom types based on this... cool.
+ //print_line("there are custom types");
const Vector<EditorData::CustomType> &ct = EditorNode::get_editor_data().get_custom_types()[type];
@@ -259,7 +260,33 @@ Object *CreateDialog::instance_selected() {
TreeItem *selected = search_options->get_selected();
if (selected) {
- return ObjectTypeDB::instance(selected->get_text(0));
+ String custom = selected->get_metadata(0);
+ if (custom!=String()) {
+ if (EditorNode::get_editor_data().get_custom_types().has(custom)) {
+
+ for(int i=0;i<EditorNode::get_editor_data().get_custom_types()[custom].size();i++) {
+ if (EditorNode::get_editor_data().get_custom_types()[custom][i].name==selected->get_text(0)) {
+ Ref<Texture> icon = EditorNode::get_editor_data().get_custom_types()[custom][i].icon;
+ Ref<Script> script = EditorNode::get_editor_data().get_custom_types()[custom][i].script;
+ String name = selected->get_text(0);
+
+ Object *ob = ObjectTypeDB::instance(custom);
+ ERR_FAIL_COND_V(!ob,NULL);
+ if (ob->is_type("Node")) {
+ ob->call("set_name",name);
+ }
+ ob->set_script(script.get_ref_ptr());
+ if (icon.is_valid())
+ ob->set_meta("_editor_icon",icon);
+ return ob;
+
+ }
+ }
+
+ }
+ } else {
+ return ObjectTypeDB::instance(selected->get_text(0));
+ }
}
return NULL;
@@ -310,116 +337,116 @@ CreateDialog::CreateDialog() {
//old create dialog, disabled
void CreateDialog::_notification(int p_what) {
-
+
if (p_what==NOTIFICATION_READY) {
connect("confirmed",this,"_create");
update_tree();
}
if (p_what==NOTIFICATION_DRAW) {
-
+
//RID ci = get_canvas_item();
//get_stylebox("panel","PopupMenu")->draw(ci,Rect2(Point2(),get_size()));
- }
+ }
}
void CreateDialog::_create() {
-
+
if (tree->get_selected())
emit_signal("create");
hide();
}
void CreateDialog::_cancel() {
-
+
hide();
}
void CreateDialog::_text_changed(String p_text) {
-
+
update_tree();
}
void CreateDialog::add_type(const String& p_type,HashMap<String,TreeItem*>& p_types,TreeItem *p_root) {
-
+
if (p_types.has(p_type))
return;
if (!ObjectTypeDB::is_type(p_type,base) || p_type==base)
return;
-
+
String inherits=ObjectTypeDB::type_inherits_from(p_type);
-
+
TreeItem *parent=p_root;
-
+
if (inherits.length()) {
-
+
if (!p_types.has(inherits)) {
-
+
add_type(inherits,p_types,p_root);
}
-
+
if (p_types.has(inherits) )
- parent=p_types[inherits];
- }
-
+ parent=p_types[inherits];
+ }
+
TreeItem *item = tree->create_item(parent);
item->set_text(0,p_type);
if (!ObjectTypeDB::can_instance(p_type)) {
item->set_custom_color(0, Color(0.5,0.5,0.5) );
item->set_selectable(0,false);
}
-
-
+
+
if (has_icon(p_type,"EditorIcons")) {
-
+
item->set_icon(0, get_icon(p_type,"EditorIcons"));
}
-
+
p_types[p_type]=item;
}
void CreateDialog::update_tree() {
tree->clear();
-
+
List<String> type_list;
- ObjectTypeDB::get_type_list(&type_list);
-
+ ObjectTypeDB::get_type_list(&type_list);
+
HashMap<String,TreeItem*> types;
-
+
TreeItem *root = tree->create_item();
-
+
root->set_text(0,base);
List<String>::Element *I=type_list.front();
-
+
for(;I;I=I->next()) {
-
-
+
+
String type=I->get();
-
+
if (!ObjectTypeDB::can_instance(type))
continue; // cant create what can't be instanced
if (filter->get_text()=="")
add_type(type,types,root);
else {
-
+
bool found=false;
String type=I->get();
- while(type!="" && ObjectTypeDB::is_type(type,base) && type!=base) {
+ while(type!="" && ObjectTypeDB::is_type(type,base) && type!=base) {
if (type.findn(filter->get_text())!=-1) {
-
+
found=true;
break;
}
-
+
type=ObjectTypeDB::type_inherits_from(type);
}
-
+
if (found)
add_type(I->get(),types,root);
@@ -501,12 +528,12 @@ Object *CreateDialog::instance_selected() {
void CreateDialog::_bind_methods() {
-
+
ObjectTypeDB::bind_method("_create",&CreateDialog::_create);
ObjectTypeDB::bind_method("_cancel",&CreateDialog::_cancel);
ObjectTypeDB::bind_method("_text_changed", &CreateDialog::_text_changed);
ADD_SIGNAL( MethodInfo("create"));
-
+
}
@@ -520,7 +547,7 @@ void CreateDialog::set_base_type(const String& p_base) {
return;
base=p_base;
if (is_inside_scene())
- update_tree();
+ update_tree();
}
String CreateDialog::get_base_type() const {
@@ -536,14 +563,14 @@ CreateDialog::CreateDialog() {
set_child_rect(vbc);
get_ok()->set_text("Create");
-
+
tree = memnew( Tree );
vbc->add_margin_child("Type:",tree,true);
//tree->set_hide_root(true);
-
- filter = memnew( LineEdit );
+
+ filter = memnew( LineEdit );
vbc->add_margin_child("Filter:",filter);
-
+
base="Node";
set_as_toplevel(true);
diff --git a/tools/editor/create_dialog.h b/tools/editor/create_dialog.h
index 6f959fd467..a46ff5ae06 100644
--- a/tools/editor/create_dialog.h
+++ b/tools/editor/create_dialog.h
@@ -82,37 +82,37 @@ public:
//old create dialog, disabled
class CreateDialog : public ConfirmationDialog {
-
+
OBJ_TYPE( CreateDialog, ConfirmationDialog );
-
+
Tree *tree;
Button *create;
Button *cancel;
LineEdit *filter;
-
+
void update_tree();
void _create();
void _cancel();
- void add_type(const String& p_type,HashMap<String,TreeItem*>& p_types,TreeItem
+ void add_type(const String& p_type,HashMap<String,TreeItem*>& p_types,TreeItem
*p_root);
-
+
String base;
void _text_changed(String p_text);
virtual void _post_popup() { tree->grab_focus();}
protected:
- static void _bind_methods();
+ static void _bind_methods();
void _notification(int p_what);
public:
-
+
Object *instance_selected();
-
+
void set_base_type(const String& p_base);
String get_base_type() const;
- CreateDialog();
+ CreateDialog();
~CreateDialog();
};
diff --git a/tools/editor/editor_asset_installer.cpp b/tools/editor/editor_asset_installer.cpp
new file mode 100644
index 0000000000..2967abbc0a
--- /dev/null
+++ b/tools/editor/editor_asset_installer.cpp
@@ -0,0 +1,327 @@
+#include "editor_asset_installer.h"
+#include "io/zip_io.h"
+#include "os/dir_access.h"
+#include "os/file_access.h"
+#include "editor_node.h"
+void EditorAssetInstaller::_update_subitems(TreeItem* p_item,bool p_check,bool p_first) {
+
+
+ if (p_check) {
+ if (p_item->get_custom_color(0)==Color()) {
+ p_item->set_checked(0,true);
+ }
+ } else {
+ p_item->set_checked(0,false);
+
+ }
+
+ if (p_item->get_children()) {
+ _update_subitems(p_item->get_children(),p_check);
+ }
+
+ if (!p_first && p_item->get_next()) {
+ _update_subitems(p_item->get_next(),p_check);
+ }
+
+}
+
+void EditorAssetInstaller::_item_edited() {
+
+
+ if (updating)
+ return;
+
+ TreeItem *item = tree->get_edited();
+ if (!item)
+ return;
+
+
+ String path=item->get_metadata(0);
+
+ updating=true;
+ if (path==String()) { //a dir
+ _update_subitems(item,item->is_checked(0),true);
+ }
+
+ if (item->is_checked(0)) {
+ while(item) {
+ item->set_checked(0,true);
+ item=item->get_parent();
+ }
+
+ }
+ updating=false;
+
+}
+
+void EditorAssetInstaller::open(const String& p_path,int p_depth) {
+
+
+ package_path=p_path;
+ Set<String> files_sorted;
+
+ FileAccess *src_f=NULL;
+ zlib_filefunc_def io = zipio_create_io_from_file(&src_f);
+
+ unzFile pkg = unzOpen2(p_path.utf8().get_data(), &io);
+ if (!pkg) {
+
+ error->set_text("Error opening package file, not in zip format.");
+ return;
+ }
+
+ int ret = unzGoToFirstFile(pkg);
+
+
+ while(ret==UNZ_OK) {
+
+ //get filename
+ unz_file_info info;
+ char fname[16384];
+ ret = unzGetCurrentFileInfo(pkg,&info,fname,16384,NULL,0,NULL,0);
+
+ String name=fname;
+ files_sorted.insert(name);
+
+ ret = unzGoToNextFile(pkg);
+ }
+
+
+ Map<String,Ref<Texture> > extension_guess;
+ {
+ extension_guess["png"]=get_icon("Texture","EditorIcons");
+ extension_guess["jpg"]=get_icon("Texture","EditorIcons");
+ extension_guess["tex"]=get_icon("Texture","EditorIcons");
+ extension_guess["atex"]=get_icon("Texture","EditorIcons");
+ extension_guess["dds"]=get_icon("Texture","EditorIcons");
+ extension_guess["scn"]=get_icon("PackedScene","EditorIcons");
+ extension_guess["tscn"]=get_icon("PackedScene","EditorIcons");
+ extension_guess["xml"]=get_icon("PackedScene","EditorIcons");
+ extension_guess["xscn"]=get_icon("PackedScene","EditorIcons");
+ extension_guess["mtl"]=get_icon("Material","EditorIcons");
+ extension_guess["shd"]=get_icon("Shader","EditorIcons");
+ extension_guess["gd"]=get_icon("GDScript","EditorIcons");
+ }
+
+ Ref<Texture> generic_extension = get_icon("Object","EditorIcons");
+
+
+ unzClose(pkg);
+
+ updating=true;
+ tree->clear();
+ TreeItem *root=tree->create_item();
+ root->set_cell_mode(0,TreeItem::CELL_MODE_CHECK);
+ root->set_checked(0,true);
+ root->set_icon(0,get_icon("folder","FileDialog"));
+ root->set_text(0,"res://");
+ root->set_editable(0,true);
+ Map<String,TreeItem*> dir_map;
+
+ for(Set<String>::Element *E=files_sorted.front();E;E=E->next()) {
+
+ String path = E->get();
+ int depth=p_depth;
+ bool skip=false;
+ while(depth>0) {
+ int pp = path.find("/");
+ if (pp==-1) {
+ skip=true;
+ break;
+ }
+ path=path.substr(pp+1,path.length());
+ depth--;
+ }
+
+ if (skip || path==String())
+ continue;
+
+ bool isdir=false;
+
+ if (path.ends_with("/")) {
+ //a directory
+ path=path.substr(0,path.length()-1);
+ isdir=true;
+ }
+
+ int pp = path.find_last("/");
+
+
+ TreeItem *parent;
+ if (pp==-1) {
+ parent=root;
+ } else {
+ String ppath=path.substr(0,pp);
+ print_line("PPATH IS: "+ppath);
+ ERR_CONTINUE(!dir_map.has(ppath));
+ parent=dir_map[ppath];
+
+ }
+
+ TreeItem *ti = tree->create_item(parent);
+ ti->set_cell_mode(0,TreeItem::CELL_MODE_CHECK);
+ ti->set_checked(0,true);
+ ti->set_editable(0,true);
+ if (isdir) {
+ dir_map[path]=ti;
+ ti->set_text(0,path.get_file()+"/");
+ ti->set_icon(0,get_icon("folder","FileDialog"));
+ } else {
+ String file = path.get_file();
+ String extension = file.extension().to_lower();
+ if (extension_guess.has(extension)) {
+ ti->set_icon(0,extension_guess[extension]);
+ } else {
+ ti->set_icon(0,generic_extension);
+ }
+ ti->set_text(0,file);
+
+
+ String res_path = "res://"+path;
+ if (FileAccess::exists(res_path)) {
+ ti->set_custom_color(0,Color(1,0.3,0.2));
+ ti->set_tooltip(0,res_path+" (Already Exists)");
+ ti->set_checked(0,false);
+ } else {
+ ti->set_tooltip(0,res_path);
+
+ }
+
+ ti->set_metadata(0,res_path);
+
+ }
+
+ status_map[E->get()]=ti;
+
+
+
+ }
+ popup_centered_ratio();
+ updating=false;
+
+}
+
+void EditorAssetInstaller::ok_pressed() {
+
+ FileAccess *src_f=NULL;
+ zlib_filefunc_def io = zipio_create_io_from_file(&src_f);
+
+ unzFile pkg = unzOpen2(package_path.utf8().get_data(), &io);
+ if (!pkg) {
+
+ error->set_text("Error opening package file, not in zip format.");
+ return;
+ }
+
+ int ret = unzGoToFirstFile(pkg);
+
+ Vector<String> failed_files;
+
+ ProgressDialog::get_singleton()->add_task("uncompress","Uncompressing Assets",status_map.size());
+
+ int idx=0;
+ while(ret==UNZ_OK) {
+
+ //get filename
+ unz_file_info info;
+ char fname[16384];
+ ret = unzGetCurrentFileInfo(pkg,&info,fname,16384,NULL,0,NULL,0);
+
+ String name=fname;
+
+ if (status_map.has(name) && status_map[name]->is_checked(0)) {
+
+ String path = status_map[name]->get_metadata(0);
+ if (path==String()) { // a dir
+
+ String dirpath;
+ TreeItem *t = status_map[name];
+ while(t) {
+ dirpath=t->get_text(0)+dirpath;
+ t=t->get_parent();
+ }
+
+ if (dirpath.ends_with("/")) {
+ dirpath=dirpath.substr(0,dirpath.length()-1);
+ }
+
+ DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
+ da->make_dir(dirpath);
+ memdelete(da);
+
+ } else {
+
+ Vector<uint8_t> data;
+ data.resize(info.uncompressed_size);
+
+ //read
+ unzOpenCurrentFile(pkg);
+ unzReadCurrentFile(pkg,data.ptr(),data.size());
+ unzCloseCurrentFile(pkg);
+
+ FileAccess *f=FileAccess::open(path,FileAccess::WRITE);
+ if (f) {
+ f->store_buffer(data.ptr(),data.size());
+ memdelete(f);
+ } else {
+ failed_files.push_back(path);
+ }
+
+ ProgressDialog::get_singleton()->task_step("uncompress",path,idx);
+ }
+
+ }
+
+ idx++;
+ ret = unzGoToNextFile(pkg);
+ }
+
+ ProgressDialog::get_singleton()->end_task("uncompress");
+ unzClose(pkg);
+
+ if (failed_files.size()) {
+ String msg="The following files failed extraction from package:\n\n";
+ for(int i=0;i<failed_files.size();i++) {
+
+ if (i>15) {
+ msg+="\nAnd "+itos(failed_files.size()-i)+" more files.";
+ break;
+ }
+ msg+=failed_files[i];
+ }
+ EditorNode::get_singleton()->show_warning(msg);
+ } else {
+ EditorNode::get_singleton()->show_warning("Package Installed Successfully!","Success!");
+ }
+
+
+
+
+}
+
+void EditorAssetInstaller::_bind_methods() {
+
+ ObjectTypeDB::bind_method("_item_edited",&EditorAssetInstaller::_item_edited);
+
+}
+
+EditorAssetInstaller::EditorAssetInstaller() {
+
+ VBoxContainer *vb = memnew( VBoxContainer );
+ add_child(vb);
+ set_child_rect(vb);
+
+ tree = memnew( Tree );
+ vb->add_margin_child("Package Contents:",tree,true);
+ tree->connect("item_edited",this,"_item_edited");
+
+ error = memnew( AcceptDialog) ;
+ add_child(error);
+ get_ok()->set_text("Install");
+ set_title("Package Installer");
+
+ updating=false;
+
+ set_hide_on_ok(true);
+}
+
diff --git a/tools/editor/editor_asset_installer.h b/tools/editor/editor_asset_installer.h
new file mode 100644
index 0000000000..713c5f14f1
--- /dev/null
+++ b/tools/editor/editor_asset_installer.h
@@ -0,0 +1,28 @@
+#ifndef EDITORASSETINSTALLER_H
+#define EDITORASSETINSTALLER_H
+
+
+#include "scene/gui/dialogs.h"
+#include "scene/gui/tree.h"
+class EditorAssetInstaller : public ConfirmationDialog {
+
+ OBJ_TYPE( EditorAssetInstaller, ConfirmationDialog );
+
+ Tree *tree;
+ String package_path;
+ AcceptDialog *error;
+ Map<String,TreeItem*> status_map;
+ bool updating;
+ void _update_subitems(TreeItem* p_item,bool p_check,bool p_first=false);
+ void _item_edited();
+ virtual void ok_pressed();
+protected:
+
+ static void _bind_methods();
+public:
+
+ void open(const String& p_path,int p_depth=0);
+ EditorAssetInstaller();
+};
+
+#endif // EDITORASSETINSTALLER_H
diff --git a/tools/editor/editor_data.cpp b/tools/editor/editor_data.cpp
index c872b1c3ca..f78ab93c30 100644
--- a/tools/editor/editor_data.cpp
+++ b/tools/editor/editor_data.cpp
@@ -261,13 +261,13 @@ EditorPlugin* EditorData::get_subeditor(Object *p_object) {
}
EditorPlugin* EditorData::get_editor(String p_name) {
-
+
for(int i=0;i<editor_plugins.size();i++) {
-
+
if (editor_plugins[i]->get_name()==p_name)
return editor_plugins[i];
}
-
+
return NULL;
}
@@ -422,6 +422,14 @@ void EditorData::add_editor_plugin(EditorPlugin *p_plugin) {
editor_plugins.push_back(p_plugin);
}
+int EditorData::get_editor_plugin_count() const {
+ return editor_plugins.size();
+}
+EditorPlugin *EditorData::get_editor_plugin(int p_idx) {
+
+ ERR_FAIL_INDEX_V(p_idx,editor_plugins.size(),NULL);
+ return editor_plugins[p_idx];
+}
void EditorData::add_custom_type(const String& p_type, const String& p_inherits,const Ref<Script>& p_script,const Ref<Texture>& p_icon ) {
@@ -791,6 +799,8 @@ void EditorSelection::_node_removed(Node *p_node) {
void EditorSelection::add_node(Node *p_node) {
+ ERR_FAIL_NULL(p_node);
+
if (selection.has(p_node))
return;
@@ -814,6 +824,8 @@ void EditorSelection::add_node(Node *p_node) {
void EditorSelection::remove_node(Node *p_node) {
+ ERR_FAIL_NULL(p_node);
+
if (!selection.has(p_node))
return;
@@ -832,12 +844,25 @@ bool EditorSelection::is_selected(Node * p_node) const {
}
+Array EditorSelection::_get_selected_nodes() {
+
+ Array ret;
+
+ for (List<Node*>::Element *E=selected_node_list.front();E;E=E->next()) {
+
+ ret.push_back(E->get());
+ }
+
+ return ret;
+}
void EditorSelection::_bind_methods() {
ObjectTypeDB::bind_method(_MD("_node_removed"),&EditorSelection::_node_removed);
ObjectTypeDB::bind_method(_MD("clear"),&EditorSelection::clear);
- ObjectTypeDB::bind_method(_MD("add_node"),&EditorSelection::add_node);
+ ObjectTypeDB::bind_method(_MD("add_node","node:Node"),&EditorSelection::add_node);
+ ObjectTypeDB::bind_method(_MD("remove_node","node:Node"),&EditorSelection::remove_node);
+ ObjectTypeDB::bind_method(_MD("get_selected_nodes"),&EditorSelection::_get_selected_nodes);
ADD_SIGNAL( MethodInfo("selection_changed") );
}
diff --git a/tools/editor/editor_data.h b/tools/editor/editor_data.h
index fcc8ccef06..5814ae8f5c 100644
--- a/tools/editor/editor_data.h
+++ b/tools/editor/editor_data.h
@@ -165,6 +165,9 @@ public:
void add_editor_plugin(EditorPlugin *p_plugin);
void remove_editor_plugin(EditorPlugin *p_plugin);
+ int get_editor_plugin_count() const;
+ EditorPlugin *get_editor_plugin(int p_idx);
+
UndoRedo &get_undo_redo();
void save_editor_global_states();
@@ -228,6 +231,7 @@ public:
List<Node*> selected_node_list;
void _update_nl();
+ Array _get_selected_nodes();
protected:
static void _bind_methods();
diff --git a/tools/editor/editor_file_dialog.cpp b/tools/editor/editor_file_dialog.cpp
index a9b23767f1..8e83726f96 100644
--- a/tools/editor/editor_file_dialog.cpp
+++ b/tools/editor/editor_file_dialog.cpp
@@ -273,13 +273,11 @@ void EditorFileDialog::_action_pressed() {
String f=dir_access->get_current_dir().plus_file(file->get_text());
- if (mode==MODE_OPEN_FILE && dir_access->file_exists(f)) {
+ if ((mode==MODE_OPEN_ANY || mode==MODE_OPEN_FILE) && dir_access->file_exists(f)) {
_save_to_recent();
emit_signal("file_selected",f);
hide();
- }
-
- if (mode==MODE_OPEN_DIR) {
+ }else if (mode==MODE_OPEN_ANY || mode==MODE_OPEN_DIR) {
String path=dir_access->get_current_dir();
@@ -413,7 +411,7 @@ void EditorFileDialog::_item_dc_selected(int p_item) {
//print_line("change dir: "+String(d["name"]));
dir_access->change_dir(d["name"]);
- if (mode==MODE_OPEN_FILE || mode==MODE_OPEN_FILES || mode==MODE_OPEN_DIR)
+ if (mode==MODE_OPEN_FILE || mode==MODE_OPEN_FILES || mode==MODE_OPEN_DIR || MODE_OPEN_ANY)
file->set_text("");
call_deferred("_update_file_list");
call_deferred("_update_dir");
@@ -590,7 +588,7 @@ void EditorFileDialog::update_file_list() {
if (get_icon_func) {
-
+
Ref<Texture> icon = get_icon_func(base_dir.plus_file(files.front()->get()));
//ti->set_icon(0,icon);
if (display_mode==DISPLAY_THUMBNAILS) {
@@ -771,8 +769,9 @@ void EditorFileDialog::set_mode(Mode p_mode) {
case MODE_OPEN_FILE: get_ok()->set_text("Open"); set_title("Open a File"); makedir->hide(); break;
case MODE_OPEN_FILES: get_ok()->set_text("Open"); set_title("Open File(s)"); makedir->hide(); break;
- case MODE_SAVE_FILE: get_ok()->set_text("Save"); set_title("Save a File"); makedir->show(); break;
case MODE_OPEN_DIR: get_ok()->set_text("Open"); set_title("Open a Directory"); makedir->show(); break;
+ case MODE_OPEN_ANY: get_ok()->set_text("Open"); set_title("Open a File or Directory"); makedir->show(); break;
+ case MODE_SAVE_FILE: get_ok()->set_text("Save"); set_title("Save a File"); makedir->show(); break;
}
if (mode==MODE_OPEN_FILES) {
@@ -1149,6 +1148,7 @@ void EditorFileDialog::_bind_methods() {
BIND_CONSTANT( MODE_OPEN_FILE );
BIND_CONSTANT( MODE_OPEN_FILES );
BIND_CONSTANT( MODE_OPEN_DIR );
+ BIND_CONSTANT( MODE_OPEN_ANY );
BIND_CONSTANT( MODE_SAVE_FILE );
BIND_CONSTANT( ACCESS_RESOURCES );
diff --git a/tools/editor/editor_file_dialog.h b/tools/editor/editor_file_dialog.h
index 3590964a51..d37856e556 100644
--- a/tools/editor/editor_file_dialog.h
+++ b/tools/editor/editor_file_dialog.h
@@ -66,7 +66,8 @@ public:
MODE_OPEN_FILE,
MODE_OPEN_FILES,
MODE_OPEN_DIR,
- MODE_SAVE_FILE,
+ MODE_OPEN_ANY,
+ MODE_SAVE_FILE
};
typedef Ref<Texture> (*GetIconFunc)(const String&);
diff --git a/tools/editor/editor_file_system.cpp b/tools/editor/editor_file_system.cpp
index ad59efc46f..05e8a559b7 100644
--- a/tools/editor/editor_file_system.cpp
+++ b/tools/editor/editor_file_system.cpp
@@ -463,7 +463,7 @@ void EditorFileSystem::scan() {
filesystem=new_filesystem;
new_filesystem=NULL;
_update_scan_actions();
- scanning=false;
+ scanning=false;
emit_signal("filesystem_changed");
emit_signal("sources_changed",sources_changed.size()>0);
diff --git a/tools/editor/editor_help.cpp b/tools/editor/editor_help.cpp
index ddcb634151..238b2d1cb8 100644
--- a/tools/editor/editor_help.cpp
+++ b/tools/editor/editor_help.cpp
@@ -405,29 +405,98 @@ void EditorHelpIndex::select_class(const String& p_class) {
class_list->ensure_cursor_is_visible();
}
+void EditorHelpIndex::popup() {
+
+ popup_centered_ratio(0.6);
+
+ search_box->set_text("");
+ _update_class_list();
+}
+
void EditorHelpIndex::_notification(int p_what) {
if (p_what==NOTIFICATION_ENTER_TREE) {
- class_list->clear();
- tree_item_map.clear();
- TreeItem *root = class_list->create_item();
- class_list->set_hide_root(true);
+ _update_class_list();
+
connect("confirmed",this,"_tree_item_selected");
+ } else if (p_what==NOTIFICATION_POST_POPUP) {
+
+ search_box->call_deferred("grab_focus");
+ }
+}
+
+void EditorHelpIndex::_text_changed(const String& p_text) {
+
+ _update_class_list();
+}
+
+void EditorHelpIndex::_update_class_list() {
+
+ class_list->clear();
+ tree_item_map.clear();
+ TreeItem *root = class_list->create_item();
+ class_list->set_hide_root(true);
- for(Map<String,DocData::ClassDoc>::Element *E=EditorHelp::get_doc_data()->class_list.front();E;E=E->next()) {
+ String filter = search_box->get_text().strip_edges();
+ String to_select = "";
+ for(Map<String,DocData::ClassDoc>::Element *E=EditorHelp::get_doc_data()->class_list.front();E;E=E->next()) {
+ if (filter == "") {
add_type(E->key(),tree_item_map,root);
+ } else {
+
+ bool found = false;
+ String type = E->key();
+
+ while(type != "") {
+ if (type.findn(filter)!=-1) {
+
+ if (to_select.empty()) {
+ to_select = type;
+ }
+
+ found=true;
+ break;
+ }
+
+ type = EditorHelp::get_doc_data()->class_list[type].inherits;
+ }
+
+ if (found) {
+ add_type(E->key(),tree_item_map,root);
+ }
}
+ }
+ if (tree_item_map.has(filter)) {
+ select_class(filter);
+ } else if (to_select != "") {
+ select_class(to_select);
+ }
+}
+
+
+void EditorHelpIndex::_sbox_input(const InputEvent& p_ie) {
+
+ if (p_ie.type==InputEvent::KEY && (
+ p_ie.key.scancode == KEY_UP ||
+ p_ie.key.scancode == KEY_DOWN ||
+ p_ie.key.scancode == KEY_PAGEUP ||
+ p_ie.key.scancode == KEY_PAGEDOWN ) ) {
+
+ class_list->call("_input_event",p_ie);
+ search_box->accept_event();
}
}
void EditorHelpIndex::_bind_methods() {
ObjectTypeDB::bind_method("_tree_item_selected",&EditorHelpIndex::_tree_item_selected);
+ ObjectTypeDB::bind_method("_text_changed",&EditorHelpIndex::_text_changed);
+ ObjectTypeDB::bind_method("_sbox_input",&EditorHelpIndex::_sbox_input);
ObjectTypeDB::bind_method("select_class",&EditorHelpIndex::select_class);
ADD_SIGNAL( MethodInfo("open_class"));
}
@@ -436,19 +505,25 @@ void EditorHelpIndex::_bind_methods() {
EditorHelpIndex::EditorHelpIndex() {
-
VBoxContainer *vbc = memnew( VBoxContainer );
add_child(vbc);
set_child_rect(vbc);
+ search_box = memnew( LineEdit );
+ vbc->add_margin_child("Search:", search_box);
+ search_box->set_h_size_flags(SIZE_EXPAND_FILL);
+
+ register_text_enter(search_box);
+
+ search_box->connect("text_changed", this, "_text_changed");
+ search_box->connect("input_event", this, "_sbox_input");
+
class_list = memnew( Tree );
- vbc->add_margin_child("Class List: ",class_list,true);
+ vbc->add_margin_child("Class List: ", class_list, true);
class_list->set_v_size_flags(SIZE_EXPAND_FILL);
-
class_list->connect("item_activated",this,"_tree_item_selected");
-
get_ok()->set_text("Open");
}
@@ -650,14 +725,64 @@ Error EditorHelp::_goto_desc(const String& p_class,int p_vscr) {
class_desc->add_text("Inherits: ");
class_desc->pop();
class_desc->pop();
+
+ String inherits = cd.inherits;
+
class_desc->push_font(doc_font);
- _add_type(cd.inherits);
+
+ while (inherits != "") {
+ _add_type(inherits);
+
+ inherits = doc->class_list[inherits].inherits;
+
+ if (inherits != "") {
+ class_desc->add_text(" , ");
+ }
+ }
+
class_desc->pop();
class_desc->add_newline();
- class_desc->add_newline();
+ }
+
+ if (ObjectTypeDB::type_exists(cd.name)) {
+
+ bool found = false;
+ bool prev = false;
+
+ for (Map<String,DocData::ClassDoc>::Element *E=doc->class_list.front();E;E=E->next()) {
+
+ if (E->get().inherits == cd.name) {
+
+ if (!found) {
+ class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/keyword_color"));
+ class_desc->push_font(doc_title_font);
+ class_desc->add_text("Inherited by: ");
+ class_desc->pop();
+ class_desc->pop();
+
+ found = true;
+ class_desc->push_font(doc_font);
+ }
+
+ if (prev) {
+
+ class_desc->add_text(" , ");
+ prev = false;
+ }
+
+ _add_type(E->get().name);
+ prev = true;
+ }
+ }
+
+ if (found)
+ class_desc->pop();
+ class_desc->add_newline();
}
+ class_desc->add_newline();
+
if (cd.brief_description!="") {
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/keyword_color"));
@@ -1123,35 +1248,87 @@ void EditorHelp::_add_text(const String& p_bbcode) {
class_desc->push_indent(1);*/
int pos = 0;
+ String bbcode=p_bbcode.replace("\t"," ").replace("\r"," ").strip_edges();
+
+ //find double newlines, keep them
+ for(int i=0;i<bbcode.length();i++) {
+
+ //find valid newlines (double)
+ if (bbcode[i]=='\n') {
+ bool dnl=false;
+ int j=i+1;
+ for(;j<p_bbcode.length();j++) {
+ if (bbcode[j]==' ')
+ continue;
+ if (bbcode[j]=='\n') {
+ dnl=true;
+ break;
+ }
+ break;
+ }
+
+ if (dnl) {
+ bbcode[i]=0xFFFF;
+ i=j;
+ } else {
+ bbcode[i]=' ';
+ i=j-1;
+ }
+ }
+ }
+
+ //remove double spaces or spaces after newlines
+ for(int i=0;i<bbcode.length();i++) {
+
+ if (bbcode[i]==' ' || bbcode[i]==0xFFFF) {
+
+ for(int j=i+1;j<p_bbcode.length();j++) {
+ if (bbcode[j]==' ') {
+ bbcode.remove(j);
+ j--;
+ continue;
+ } else {
+ break;
+ }
+ }
+ }
+ }
+
+ //change newlines to double newlines
+
+ CharType dnls[2]={0xFFFF,0};
+ bbcode=bbcode.replace(dnls,"\n");
+
+
List<String> tag_stack;
- while(pos < p_bbcode.length()) {
+ while(pos < bbcode.length()) {
- int brk_pos = p_bbcode.find("[",pos);
+ int brk_pos = bbcode.find("[",pos);
if (brk_pos<0)
- brk_pos=p_bbcode.length();
+ brk_pos=bbcode.length();
if (brk_pos > pos) {
- class_desc->add_text(p_bbcode.substr(pos,brk_pos-pos));
+ class_desc->add_text(bbcode.substr(pos,brk_pos-pos));
}
- if (brk_pos==p_bbcode.length())
+ if (brk_pos==bbcode.length())
break; //nothing else o add
- int brk_end = p_bbcode.find("]",brk_pos+1);
+ int brk_end = bbcode.find("]",brk_pos+1);
if (brk_end==-1) {
//no close, add the rest
- class_desc->add_text(p_bbcode.substr(brk_pos,p_bbcode.length()-brk_pos));
+ class_desc->add_text(bbcode.substr(brk_pos,bbcode.length()-brk_pos));
break;
}
- String tag = p_bbcode.substr(brk_pos+1,brk_end-brk_pos-1);
+ String tag = bbcode.substr(brk_pos+1,brk_end-brk_pos-1);
if (tag.begins_with("/")) {
@@ -1234,10 +1411,10 @@ void EditorHelp::_add_text(const String& p_bbcode) {
} else if (tag=="url") {
//use strikethrough (not supported underline instead)
- int end=p_bbcode.find("[",brk_end);
+ int end=bbcode.find("[",brk_end);
if (end==-1)
- end=p_bbcode.length();
- String url = p_bbcode.substr(brk_end+1,end-brk_end-1);
+ end=bbcode.length();
+ String url = bbcode.substr(brk_end+1,end-brk_end-1);
class_desc->push_meta(url);
pos=brk_end+1;
@@ -1251,10 +1428,10 @@ void EditorHelp::_add_text(const String& p_bbcode) {
} else if (tag=="img") {
//use strikethrough (not supported underline instead)
- int end=p_bbcode.find("[",brk_end);
+ int end=bbcode.find("[",brk_end);
if (end==-1)
- end=p_bbcode.length();
- String image = p_bbcode.substr(brk_end+1,end-brk_end-1);
+ end=bbcode.length();
+ String image = bbcode.substr(brk_end+1,end-brk_end-1);
Ref<Texture> texture = ResourceLoader::load(base_path+"/"+image,"Texture");
if (texture.is_valid())
diff --git a/tools/editor/editor_help.h b/tools/editor/editor_help.h
index 059a7ae11d..f6dda9f545 100644
--- a/tools/editor/editor_help.h
+++ b/tools/editor/editor_help.h
@@ -77,11 +77,16 @@ public:
class EditorHelpIndex : public ConfirmationDialog {
OBJ_TYPE( EditorHelpIndex, ConfirmationDialog );
-
+ LineEdit *search_box;
Tree *class_list;
HashMap<String,TreeItem*> tree_item_map;
void _tree_item_selected();
+ void _text_changed(const String& p_text);
+ void _sbox_input(const InputEvent& p_ie);
+
+ void _update_class_list();
+
void add_type(const String& p_type,HashMap<String,TreeItem*>& p_types,TreeItem *p_root);
protected:
@@ -92,6 +97,8 @@ public:
void select_class(const String& p_class);
+ void popup();
+
EditorHelpIndex();
};
diff --git a/tools/editor/editor_import_export.cpp b/tools/editor/editor_import_export.cpp
index b845eba66b..e02ffd337b 100644
--- a/tools/editor/editor_import_export.cpp
+++ b/tools/editor/editor_import_export.cpp
@@ -63,13 +63,30 @@ String EditorImportPlugin::expand_source_path(const String& p_path) {
}
}
+
+String EditorImportPlugin::_validate_source_path(const String& p_path) {
+
+ return validate_source_path(p_path);
+}
+
+String EditorImportPlugin::_expand_source_path(const String& p_path) {
+
+ return expand_source_path(p_path);
+}
+
void EditorImportPlugin::_bind_methods() {
+
+ ObjectTypeDB::bind_method(_MD("validate_source_path","path"),&EditorImportPlugin::_validate_source_path);
+ ObjectTypeDB::bind_method(_MD("expand_source_path","path"),&EditorImportPlugin::_expand_source_path);
+
ObjectTypeDB::add_virtual_method(get_type_static(),MethodInfo(Variant::STRING,"get_name"));
ObjectTypeDB::add_virtual_method(get_type_static(),MethodInfo(Variant::STRING,"get_visible_name"));
ObjectTypeDB::add_virtual_method(get_type_static(),MethodInfo("import_dialog",PropertyInfo(Variant::STRING,"from")));
- ObjectTypeDB::add_virtual_method(get_type_static(),MethodInfo(Variant::INT,"import",PropertyInfo(Variant::STRING,"path"),PropertyInfo(Variant::OBJECT,"from",PROPERTY_HINT_RESOURCE_TYPE,"ResourceImportMetaData")));
- ObjectTypeDB::add_virtual_method(get_type_static(),MethodInfo(Variant::RAW_ARRAY,"custom_export",PropertyInfo(Variant::STRING,"path")));
+ ObjectTypeDB::add_virtual_method(get_type_static(),MethodInfo(Variant::INT,"import",PropertyInfo(Variant::STRING,"path"),PropertyInfo(Variant::OBJECT,"from",PROPERTY_HINT_RESOURCE_TYPE,"ResourceImportMetadata")));
+ ObjectTypeDB::add_virtual_method(get_type_static(),MethodInfo(Variant::RAW_ARRAY,"custom_export",PropertyInfo(Variant::STRING,"path"),PropertyInfo(Variant::OBJECT,"platform",PROPERTY_HINT_RESOURCE_TYPE,"EditorExportPlatform")));
+
+// BIND_VMETHOD( mi );
}
String EditorImportPlugin::get_name() const {
@@ -113,8 +130,8 @@ Error EditorImportPlugin::import(const String& p_path, const Ref<ResourceImportM
Vector<uint8_t> EditorImportPlugin::custom_export(const String& p_path, const Ref<EditorExportPlatform> &p_platform) {
- if (get_script_instance() && get_script_instance()->has_method("custom_export")) {
- get_script_instance()->call("custom_export",p_path);
+ if (get_script_instance() && get_script_instance()->has_method("_custom_export")) {
+ get_script_instance()->call("_custom_export",p_path,p_platform);
}
return Vector<uint8_t>();
@@ -130,7 +147,10 @@ EditorImportPlugin::EditorImportPlugin() {
void EditorExportPlugin::_bind_methods() {
- BIND_VMETHOD( MethodInfo("custom_export:Dictionary",PropertyInfo(Variant::STRING,"name",PROPERTY_HINT_RESOURCE_TYPE,"EditorExportPlatformPC")) );
+ MethodInfo mi = MethodInfo("custom_export:Variant",PropertyInfo(Variant::STRING,"name"),PropertyInfo(Variant::OBJECT,"platform",PROPERTY_HINT_RESOURCE_TYPE,"EditorExportPlatform"));
+ mi.return_val.type=Variant::RAW_ARRAY;
+
+ BIND_VMETHOD( mi );
}
@@ -141,6 +161,9 @@ Vector<uint8_t> EditorExportPlugin::custom_export(String& p_path,const Ref<Edito
Variant d = get_script_instance()->call("custom_export",p_path,p_platform);
if (d.get_type()==Variant::NIL)
return Vector<uint8_t>();
+ if (d.get_type()==Variant::RAW_ARRAY)
+ return d;
+
ERR_FAIL_COND_V(d.get_type()!=Variant::DICTIONARY,Vector<uint8_t>());
Dictionary dict=d;
ERR_FAIL_COND_V(!dict.has("name"),Vector<uint8_t>());
@@ -258,6 +281,7 @@ static void _edit_filter_list(Set<StringName>& r_list,const String& p_filter,boo
}
DirAccess *da = DirAccess::open("res://");
+ ERR_FAIL_NULL(da);
_edit_files_with_filter(da,filters,r_list,exclude);
memdelete(da);
}
@@ -648,7 +672,7 @@ Error EditorExportPlatform::export_project_files(EditorExportSaveFunction p_func
} break; //use default
case EditorImportExport::IMAGE_ACTION_COMPRESS_RAM: {
group_format=EditorTextureImportPlugin::IMAGE_FORMAT_COMPRESS_RAM;
- } break; //use default
+ } break; //use default
}
String image_list_md5;
@@ -1455,9 +1479,17 @@ Ref<EditorImportPlugin> EditorImportExport::get_import_plugin_by_name(const Stri
void EditorImportExport::add_export_plugin(const Ref<EditorExportPlugin>& p_plugin) {
+ ERR_FAIL_COND( p_plugin.is_null() );
+
export_plugins.push_back(p_plugin);
}
+void EditorImportExport::remove_export_plugin(const Ref<EditorExportPlugin>& p_plugin) {
+
+ ERR_FAIL_COND( p_plugin.is_null() );
+ export_plugins.erase(p_plugin);
+}
+
int EditorImportExport::get_export_plugin_count() const{
return export_plugins.size();
@@ -2068,9 +2100,61 @@ bool EditorImportExport::sample_get_trim() const{
return sample_action_trim;
}
+DVector<String> EditorImportExport::_get_export_file_list() {
+
+ DVector<String> fl;
+ for (Map<StringName,FileAction>::Element *E=files.front();E;E=E->next()) {
+
+ fl.push_back(E->key());
+ }
+
+ return fl;
+}
+
+DVector<String> EditorImportExport::_get_export_platforms() {
+
+ DVector<String> ep;
+ for (Map<StringName,Ref<EditorExportPlatform> >::Element *E=exporters.front();E;E=E->next()) {
+
+ ep.push_back(E->key());
+ }
+
+ return ep;
+
+}
void EditorImportExport::_bind_methods() {
+ ObjectTypeDB::bind_method(_MD("add_import_plugin","plugin:EditorImportPlugin"),&EditorImportExport::add_import_plugin);
+ ObjectTypeDB::bind_method(_MD("remove_import_plugin","plugin:EditorImportPlugin"),&EditorImportExport::remove_import_plugin);
+ ObjectTypeDB::bind_method(_MD("get_import_plugin_count"),&EditorImportExport::get_import_plugin_count);
+ ObjectTypeDB::bind_method(_MD("get_import_plugin:EditorImportPlugin","idx"),&EditorImportExport::get_import_plugin);
+ ObjectTypeDB::bind_method(_MD("get_import_plugin_by_name:EditorImportPlugin","name"),&EditorImportExport::get_import_plugin_by_name);
+
+ ObjectTypeDB::bind_method(_MD("add_export_plugin","plugin:EditorExportPlugin"),&EditorImportExport::add_export_plugin);
+ ObjectTypeDB::bind_method(_MD("remove_export_plugin","plugin:EditorExportPlugin"),&EditorImportExport::remove_export_plugin);
+ ObjectTypeDB::bind_method(_MD("get_export_plugin_count"),&EditorImportExport::get_export_plugin_count);
+ ObjectTypeDB::bind_method(_MD("get_export_plugin:EditorExportPlugin","idx"),&EditorImportExport::get_export_plugin);
+
+ ObjectTypeDB::bind_method(_MD("set_export_file_action","file","action"),&EditorImportExport::set_export_file_action);
+ ObjectTypeDB::bind_method(_MD("get_export_file_action","file"),&EditorImportExport::get_export_file_action);
+ ObjectTypeDB::bind_method(_MD("get_export_file_list"),&EditorImportExport::_get_export_file_list);
+
+ ObjectTypeDB::bind_method(_MD("add_export_platform","platform:EditorExportplatform"),&EditorImportExport::add_export_platform);
+ //ObjectTypeDB::bind_method(_MD("remove_export_platform","platform:EditorExportplatform"),&EditorImportExport::add_export_platform);
+ ObjectTypeDB::bind_method(_MD("get_export_platform:EditorExportPlatform","name"),&EditorImportExport::get_export_platform);
+ ObjectTypeDB::bind_method(_MD("get_export_platforms"),&EditorImportExport::_get_export_platforms);
+
+ ObjectTypeDB::bind_method(_MD("set_export_filter","filter"),&EditorImportExport::set_export_filter);
+ ObjectTypeDB::bind_method(_MD("get_export_filter"),&EditorImportExport::get_export_filter);
+
+ ObjectTypeDB::bind_method(_MD("set_export_custom_filter","filter"),&EditorImportExport::set_export_custom_filter);
+ ObjectTypeDB::bind_method(_MD("get_export_custom_filter"),&EditorImportExport::get_export_custom_filter);
+
+ ObjectTypeDB::bind_method(_MD("set_export_custom_filter_exclude","filter_exclude"),&EditorImportExport::set_export_custom_filter_exclude);
+ ObjectTypeDB::bind_method(_MD("get_export_custom_filter_exclude"),&EditorImportExport::get_export_custom_filter_exclude);
+
+
ObjectTypeDB::bind_method(_MD("image_export_group_create"),&EditorImportExport::image_export_group_create);
ObjectTypeDB::bind_method(_MD("image_export_group_remove"),&EditorImportExport::image_export_group_remove);
ObjectTypeDB::bind_method(_MD("image_export_group_set_image_action"),&EditorImportExport::image_export_group_set_image_action);
@@ -2085,7 +2169,27 @@ void EditorImportExport::_bind_methods() {
ObjectTypeDB::bind_method(_MD("script_get_action"),&EditorImportExport::script_get_action);
ObjectTypeDB::bind_method(_MD("script_get_encryption_key"),&EditorImportExport::script_get_encryption_key);
-}
+
+
+ BIND_CONSTANT( ACTION_NONE );
+ BIND_CONSTANT( ACTION_COPY );
+ BIND_CONSTANT( ACTION_BUNDLE );
+
+ BIND_CONSTANT( EXPORT_SELECTED );
+ BIND_CONSTANT( EXPORT_RESOURCES );
+ BIND_CONSTANT( EXPORT_ALL );
+
+ BIND_CONSTANT( IMAGE_ACTION_NONE );
+ BIND_CONSTANT( IMAGE_ACTION_COMPRESS_DISK );
+ BIND_CONSTANT( IMAGE_ACTION_COMPRESS_RAM );
+ BIND_CONSTANT( IMAGE_ACTION_KEEP );
+
+ BIND_CONSTANT( SCRIPT_ACTION_NONE );
+ BIND_CONSTANT( SCRIPT_ACTION_COMPILE );
+ BIND_CONSTANT( SCRIPT_ACTION_ENCRYPT );
+};
+
+
EditorImportExport::EditorImportExport() {
@@ -2114,5 +2218,3 @@ EditorImportExport::~EditorImportExport() {
}
-
-
diff --git a/tools/editor/editor_import_export.h b/tools/editor/editor_import_export.h
index 60b7f919d8..fc8ad58bd9 100644
--- a/tools/editor/editor_import_export.h
+++ b/tools/editor/editor_import_export.h
@@ -46,6 +46,10 @@ protected:
static void _bind_methods();
+ String _validate_source_path(const String& p_path);
+ String _expand_source_path(const String& p_path);
+
+
public:
@@ -303,6 +307,9 @@ protected:
static EditorImportExport* singleton;
+ DVector<String> _get_export_file_list();
+ DVector<String> _get_export_platforms();
+
static void _bind_methods();
public:
@@ -315,6 +322,7 @@ public:
Ref<EditorImportPlugin> get_import_plugin_by_name(const String& p_string) const;
void add_export_plugin(const Ref<EditorExportPlugin>& p_plugin);
+ void remove_export_plugin(const Ref<EditorExportPlugin>& p_plugin);
int get_export_plugin_count() const;
Ref<EditorExportPlugin> get_export_plugin(int p_idx) const;
@@ -391,7 +399,10 @@ public:
~EditorImportExport();
};
+VARIANT_ENUM_CAST(EditorImportExport::FileAction);
+VARIANT_ENUM_CAST(EditorImportExport::ExportFilter);
VARIANT_ENUM_CAST(EditorImportExport::ImageAction);
VARIANT_ENUM_CAST(EditorImportExport::ScriptAction);
+VARIANT_ENUM_CAST(EditorImportExport::SampleAction);
#endif // EDITOR_IMPORT_EXPORT_H
diff --git a/tools/editor/editor_initialize_ssl.cpp b/tools/editor/editor_initialize_ssl.cpp
new file mode 100644
index 0000000000..e0602a88c7
--- /dev/null
+++ b/tools/editor/editor_initialize_ssl.cpp
@@ -0,0 +1,21 @@
+#include "editor_initialize_ssl.h"
+#include "certs_compressed.h"
+#include "io/stream_peer_ssl.h"
+#include "io/compression.h"
+
+void editor_initialize_certificates() {
+
+
+ ByteArray data;
+ data.resize(_certs_uncompressed_size);
+ {
+ ByteArray::Write w = data.write();
+ Compression::decompress(w.ptr(),_certs_uncompressed_size,_certs_compressed,_certs_compressed_size,Compression::MODE_DEFLATE);
+ }
+
+ StreamPeerSSL::load_certs_from_memory(data);
+
+
+}
+
+
diff --git a/tools/editor/editor_initialize_ssl.h b/tools/editor/editor_initialize_ssl.h
new file mode 100644
index 0000000000..4eaf387a0a
--- /dev/null
+++ b/tools/editor/editor_initialize_ssl.h
@@ -0,0 +1,6 @@
+#ifndef EDITOR_INITIALIZE_SSL_H
+#define EDITOR_INITIALIZE_SSL_H
+
+void editor_initialize_certificates();
+
+#endif // EDITOR_INITIALIZE_SSL_H
diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp
index 7fa85c4476..02b0e9447a 100644
--- a/tools/editor/editor_node.cpp
+++ b/tools/editor/editor_node.cpp
@@ -61,6 +61,7 @@
#include "plugins/sprite_frames_editor_plugin.h"
#include "plugins/sprite_region_editor_plugin.h"
#include "plugins/canvas_item_editor_plugin.h"
+#include "addon_editor_plugin.h"
#include "plugins/spatial_editor_plugin.h"
#include "plugins/sample_editor_plugin.h"
#include "plugins/sample_library_editor_plugin.h"
@@ -106,7 +107,7 @@
#include "tools/editor/io_plugins/editor_export_scene.h"
#include "plugins/editor_preview_plugins.h"
-
+#include "editor_initialize_ssl.h"
#include "script_editor_debugger.h"
EditorNode *EditorNode::singleton=NULL;
@@ -204,8 +205,8 @@ void EditorNode::_notification(int p_what) {
log->deinit(); // do not get messages anymore
}
if (p_what==NOTIFICATION_PROCESS) {
-
- //force the whole tree viewport
+
+ //force the whole tree viewport
#if 0
{
Rect2 grect = scene_root_base->get_global_rect();
@@ -274,13 +275,13 @@ void EditorNode::_notification(int p_what) {
}
}
-
+
}
if (p_what==NOTIFICATION_ENTER_TREE) {
//MessageQueue::get_singleton()->push_call(this,"_get_scene_metadata");
- get_tree()->set_editor_hint(true);
+ get_tree()->set_editor_hint(true);
get_tree()->get_root()->set_as_audio_listener(false);
get_tree()->get_root()->set_as_audio_listener_2d(false);
get_tree()->set_auto_accept_quit(false);
@@ -568,12 +569,12 @@ void EditorNode::save_resource_as(const Ref<Resource>& p_resource) {
void EditorNode::_menu_option(int p_option) {
-
+
_menu_option_confirm(p_option,false);
}
void EditorNode::_menu_confirm_current() {
-
+
_menu_option_confirm(current_option,true);
}
@@ -582,27 +583,27 @@ void EditorNode::_dialog_display_file_error(String p_file,Error p_error) {
if (p_error) {
-
+
current_option=-1;
//accept->"()->hide();
accept->get_ok()->set_text("I see..");
-
+
switch(p_error) {
-
+
case ERR_FILE_CANT_WRITE: {
accept->set_text("Can't open file for writing: "+p_file.extension());
} break;
case ERR_FILE_UNRECOGNIZED: {
-
+
accept->set_text("File format requested unknown: "+p_file.extension());
} break;
default: {
-
+
accept->set_text("Error Saving.");
}break;
}
-
+
accept->popup_centered_minsize();
}
@@ -980,11 +981,6 @@ void EditorNode::_save_scene(String p_file) {
editor_data.apply_changes_in_editors();
- if (editor_plugin_screen) {
- scene->set_meta("__editor_plugin_screen__",editor_plugin_screen->get_name());
- }
-
-
_set_scene_metadata(p_file);
@@ -1148,10 +1144,10 @@ void EditorNode::_import(const String &p_file) {
}
void EditorNode::_dialog_action(String p_file) {
-
+
switch(current_option) {
-
+
case RESOURCE_LOAD: {
RES res = ResourceLoader::load(p_file);
@@ -1166,7 +1162,7 @@ void EditorNode::_dialog_action(String p_file) {
push_item(res.operator->() );
- } break;
+ } break;
case FILE_NEW_INHERITED_SCENE: {
@@ -1271,23 +1267,20 @@ void EditorNode::_dialog_action(String p_file) {
if (FileAccess::exists(p_file)) {
ml=ResourceLoader::load(p_file,"TileSet");
- if (!file_export_lib_merge->is_pressed()) {
+ if (ml.is_null()) {
+ if (file_export_lib_merge->is_pressed()) {
+ current_option=-1;
+ //accept->get_cancel()->hide();
+ accept->get_ok()->set_text("I see..");
+ accept->set_text("Can't load TileSet for merging!.");
+ accept->popup_centered_minsize();
+ return;
+ }
+ } else if (!file_export_lib_merge->is_pressed()) {
ml->clear();
}
- }
-
- if (ml.is_null()) {
-
- if (file_export_lib_merge->is_pressed()) {
- current_option=-1;
- //accept->get_cancel()->hide();
- accept->get_ok()->set_text("I see..");
- accept->set_text("Can't load TileSet for merging!.");
- accept->popup_centered_minsize();
- return;
- }
-
+ } else {
ml = Ref<TileSet>( memnew( TileSet ));
}
@@ -1452,13 +1445,13 @@ void EditorNode::_dialog_action(String p_file) {
} break;
default: { //save scene?
-
+
if (file->get_mode()==FileDialog::MODE_SAVE_FILE) {
//_save_scene(p_file);
_save_scene_with_preview(p_file);
}
-
+
} break;
}
}
@@ -1552,13 +1545,13 @@ void EditorNode::_property_editor_forward() {
if (editor_history.next())
_edit_current();
-
+
}
void EditorNode::_property_editor_back() {
-
+
if (editor_history.previous())
_edit_current();
-
+
}
@@ -1588,7 +1581,7 @@ void EditorNode::_hide_top_editors() {
}
void EditorNode::_edit_current() {
-
+
uint32_t current = editor_history.get_current();
Object *current_obj = current>0 ? ObjectDB::get_instance(current) : NULL;
@@ -1600,7 +1593,7 @@ void EditorNode::_edit_current() {
if (!current_obj) {
-
+
scene_tree_dock->set_selected(NULL);
property_editor->edit( NULL );
object_menu->set_disabled(true);
@@ -1774,7 +1767,7 @@ void EditorNode::_resource_created() {
}
void EditorNode::_resource_selected(const RES& p_res,const String& p_property) {
-
+
if (p_res.is_null())
return;
@@ -1967,13 +1960,13 @@ void EditorNode::_cleanup_scene() {
}
}
-
+
_update_title();
#endif
}
void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
-
+
//print_line("option "+itos(p_option)+" confirm "+itos(p_confirmed));
if (!p_confirmed) //this may be a hack..
current_option=(MenuOptions)p_option;
@@ -1998,12 +1991,12 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
//_cleanup_scene();
-
+
} break;
case FILE_NEW_INHERITED_SCENE:
case FILE_OPEN_SCENE: {
-
-
+
+
//print_tree();
file->set_mode(EditorFileDialog::MODE_OPEN_FILE);
//not for now?
@@ -2011,10 +2004,10 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
ResourceLoader::get_recognized_extensions_for_type("PackedScene",&extensions);
file->clear_filters();
for(int i=0;i<extensions.size();i++) {
-
+
file->add_filter("*."+extensions[i]+" ; "+extensions[i].to_upper());
}
-
+
//file->set_current_path(current_path);
Node *scene = editor_data.get_edited_scene_root();
@@ -2023,7 +2016,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
};
file->set_title(p_option==FILE_OPEN_SCENE?"Open Scene":"Open Base Scene");
file->popup_centered_ratio();
-
+
} break;
case FILE_QUICK_OPEN_SCENE: {
@@ -2090,19 +2083,19 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
// fallthrough to save_as
};
case FILE_SAVE_AS_SCENE: {
-
+
Node *scene = editor_data.get_edited_scene_root();
-
+
if (!scene) {
-
+
current_option=-1;
//confirmation->get_cancel()->hide();
accept->get_ok()->set_text("I see..");
accept->set_text("This operation can't be done without a tree root.");
accept->popup_centered_minsize();
- break;
+ break;
}
-
+
file->set_mode(EditorFileDialog::MODE_SAVE_FILE);
bool relpaths = (scene->has_meta("__editor_relpaths__") && scene->get_meta("__editor_relpaths__").operator bool());
@@ -2115,7 +2108,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
file->add_filter("*."+extensions[i]+" ; "+extensions[i].to_upper());
}
-
+
//file->set_current_path(current_path);
if (scene->get_filename()!="") {
file->set_current_path(scene->get_filename());
@@ -2136,7 +2129,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
}
file->popup_centered_ratio();
file->set_title("Save Scene As..");
-
+
} break;
case FILE_SAVE_BEFORE_RUN: {
@@ -2316,7 +2309,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
} break;
case FILE_QUIT: {
-
+
if (!p_confirmed) {
@@ -2330,7 +2323,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
_menu_option_confirm(RUN_STOP,true);
get_tree()->quit();
-
+
} break;
case FILE_EXTERNAL_OPEN_SCENE: {
@@ -2539,13 +2532,13 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
} break;
case OBJECT_COPY_PARAMS: {
-
+
editor_data.apply_changes_in_editors();;
if (current)
editor_data.copy_object_params(current);
} break;
case OBJECT_PASTE_PARAMS: {
-
+
editor_data.apply_changes_in_editors();;
if (current)
editor_data.paste_object_params(current);
@@ -2593,7 +2586,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
} break;
case OBJECT_CALL_METHOD: {
-
+
editor_data.apply_changes_in_editors();;
call_dialog->set_object(current);
call_dialog->popup_centered_ratio();
@@ -2671,8 +2664,9 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
String exec = OS::get_singleton()->get_executable_path();
List<String> args;
- args.push_back ( "-path" );
- args.push_back (exec.get_base_dir() );
+ //args.push_back ( "-path" );
+ //args.push_back (exec.get_base_dir() );
+ args.push_back("-pm");
OS::ProcessID pid=0;
Error err = OS::get_singleton()->execute(exec,args,false,&pid);
@@ -2837,7 +2831,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
} break;
default: {
-
+
if (p_option>=OBJECT_METHOD_BASE) {
ERR_FAIL_COND(!current);
@@ -2861,12 +2855,12 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
}
}
- }
+ }
}
Control* EditorNode::get_viewport() {
-
+
return viewport;
}
@@ -2911,7 +2905,7 @@ void EditorNode::add_editor_plugin(EditorPlugin *p_editor) {
if (p_editor->has_main_screen()) {
-
+
ToolButton *tb = memnew( ToolButton );
tb->set_toggle_mode(true);
tb->connect("pressed",singleton,"_editor_select",varray(singleton->main_editor_buttons.size()));
@@ -2951,16 +2945,109 @@ void EditorNode::remove_editor_plugin(EditorPlugin *p_editor) {
void EditorNode::add_editor_import_plugin(const Ref<EditorImportPlugin>& p_editor_import) {
+ ERR_FAIL_COND( p_editor_import.is_null() );
editor_import_export->add_import_plugin(p_editor_import);
_rebuild_import_menu();
}
void EditorNode::remove_editor_import_plugin(const Ref<EditorImportPlugin>& p_editor_import) {
+ ERR_FAIL_COND( p_editor_import.is_null() );
editor_import_export->remove_import_plugin(p_editor_import);
_rebuild_import_menu();
}
+
+void EditorNode::_update_addon_config() {
+
+ if (_initializing_addons)
+ return;
+
+ Vector<String> enabled_addons;
+
+ for(Map<String,EditorPlugin*>::Element *E=plugin_addons.front();E;E=E->next()) {
+ enabled_addons.push_back(E->key());
+ }
+
+ if (enabled_addons.size()==0) {
+ Globals::get_singleton()->set("editor_plugins/enabled",Variant());
+ Globals::get_singleton()->set_persisting("editor_plugins/enabled",false);
+ } else {
+ Globals::get_singleton()->set("editor_plugins/enabled",enabled_addons);
+ Globals::get_singleton()->set_persisting("editor_plugins/enabled",true);
+ }
+
+ project_settings->queue_save();
+
+}
+
+void EditorNode::set_addon_plugin_enabled(const String& p_addon,bool p_enabled) {
+
+ ERR_FAIL_COND(p_enabled && plugin_addons.has(p_addon));
+ ERR_FAIL_COND(!p_enabled && !plugin_addons.has(p_addon));
+
+ if (!p_enabled) {
+
+ EditorPlugin *addon = plugin_addons[p_addon];
+ memdelete(addon); //bye
+ plugin_addons.erase(p_addon);
+ _update_addon_config();
+ return;
+ }
+
+
+ Ref<ConfigFile> cf;
+ cf.instance();
+ String addon_path = "res://addons/"+p_addon+"/plugin.cfg";
+ Error err = cf->load(addon_path);
+ if (err!=OK) {
+ show_warning("Unable to enable addon plugin at: '"+addon_path+"' parsing of config failed.");
+ return;
+ }
+
+ if (!cf->has_section_key("plugin","script")) {
+ show_warning("Unable to find script field for addon plugin at: 'res://addons/"+p_addon+"''.");
+ return;
+ }
+
+ String path = cf->get_value("plugin","script");
+ path="res://addons/"+p_addon+"/"+path;
+
+ Ref<Script> script = ResourceLoader::load(path);
+
+
+ if (script.is_null()) {
+ show_warning("Unable to load addon script from path: '"+path+"'.");
+ return;
+ }
+
+ //could check inheritance..
+ if (String(script->get_instance_base_type())!="EditorPlugin") {
+ show_warning("Unable to load addon script from path: '"+path+"' Base type is not EditorPlugin.");
+ return;
+ }
+
+ if (!script->is_tool()) {
+ show_warning("Unable to load addon script from path: '"+path+"' Script is does not support tool mode.");
+ return;
+ }
+
+ EditorPlugin *ep = memnew( EditorPlugin );
+ ep->set_script(script.get_ref_ptr());
+ plugin_addons[p_addon]=ep;
+ add_editor_plugin(ep);
+
+ _update_addon_config();
+
+
+}
+
+bool EditorNode::is_addon_plugin_enabled(const String& p_addon) const {
+
+ return plugin_addons.has(p_addon);
+}
+
+
void EditorNode::_remove_edited_scene() {
int new_index = editor_data.get_edited_scene();
int old_index=new_index;
@@ -3006,9 +3093,9 @@ void EditorNode::set_edited_scene(Node *p_scene) {
if (get_editor_data().get_edited_scene_root()->get_parent()==scene_root)
scene_root->remove_child(get_editor_data().get_edited_scene_root());
- }
+ }
get_editor_data().set_edited_scene_root(p_scene);
-
+
if (p_scene && p_scene->cast_to<Popup>())
p_scene->cast_to<Popup>()->show(); //show popups
scene_tree_dock->set_edited_scene(p_scene);
@@ -3577,7 +3664,7 @@ Error EditorNode::load_scene(const String& p_scene, bool p_ignore_broken_deps,bo
if (p_set_inherited) {
Ref<SceneState> state = sdata->get_state();
- state->set_path(lpath);
+ state->set_path(lpath);
new_scene->set_scene_inherited_state(state);
new_scene->set_filename(String());
//if (new_scene->get_scene_instance_state().is_valid())
@@ -3597,26 +3684,12 @@ Error EditorNode::load_scene(const String& p_scene, bool p_ignore_broken_deps,bo
*/
editor_data.set_edited_scene_import_metadata( sdata->get_import_metadata() );
-
// editor_data.get_undo_redo().clear_history();
saved_version=editor_data.get_undo_redo().get_version();
_update_title();
_update_scene_tabs();
_add_to_recent_scenes(lpath);
- if (new_scene->has_meta("__editor_plugin_screen__")) {
-
- String editor = new_scene->get_meta("__editor_plugin_screen__");
-
- for(int i=0;i<editor_table.size();i++) {
-
- if (editor_table[i]->get_name()==editor) {
- _editor_select(i);
- break;
- }
- }
- }
-
prev_scene->set_disabled(previous_scenes.size()==0);
opening_prev=false;
@@ -3728,7 +3801,7 @@ void EditorNode::animation_editor_make_visible(bool p_visible) {
if (p_visible) {
- animation_editor->show();
+ animation_editor->show();
animation_vb->get_parent_control()->minimum_size_changed();
//pd_anim->show();
top_split->set_collapsed(false);
@@ -3949,10 +4022,14 @@ void EditorNode::register_editor_types() {
ObjectTypeDB::register_type<EditorPlugin>();
ObjectTypeDB::register_type<EditorImportPlugin>();
+ ObjectTypeDB::register_type<EditorExportPlugin>();
ObjectTypeDB::register_type<EditorScenePostImport>();
ObjectTypeDB::register_type<EditorScript>();
+ ObjectTypeDB::register_type<EditorSelection>();
ObjectTypeDB::register_type<EditorFileDialog>();
- ObjectTypeDB::register_type<UndoRedo>();
+ //ObjectTypeDB::register_type<EditorImportExport>();
+ ObjectTypeDB::register_type<EditorSettings>();
+ ObjectTypeDB::register_type<EditorSpatialGizmo>();
//ObjectTypeDB::register_type<EditorImporter>();
@@ -4068,9 +4145,10 @@ Error EditorNode::export_platform(const String& p_platform, const String& p_path
return OK;
}
-void EditorNode::show_warning(const String& p_text) {
+void EditorNode::show_warning(const String& p_text, const String &p_title) {
warning->set_text(p_text);
+ warning->set_title(p_title);
warning->popup_centered_minsize();
}
@@ -4146,7 +4224,7 @@ void EditorNode::_dock_popup_exit() {
}
void EditorNode::_dock_pre_popup(int p_which) {
-
+
dock_popup_selected=p_which;
}
@@ -4355,6 +4433,51 @@ void EditorNode::_load_docks() {
}
+
+void EditorNode::_update_dock_slots_visibility() {
+
+ VSplitContainer*splits[DOCK_SLOT_MAX/2]={
+ left_l_vsplit,
+ left_r_vsplit,
+ right_l_vsplit,
+ right_r_vsplit,
+ };
+
+
+ HSplitContainer*h_splits[4]={
+ left_l_hsplit,
+ left_r_hsplit,
+ main_hsplit,
+ right_hsplit,
+ };
+
+ for(int i=0;i<DOCK_SLOT_MAX;i++) {
+
+ if (dock_slot[i]->get_tab_count())
+ dock_slot[i]->show();
+ else
+ dock_slot[i]->hide();
+
+ }
+
+
+ for(int i=0;i<DOCK_SLOT_MAX/2;i++) {
+ bool in_use = dock_slot[i*2+0]->get_tab_count() || dock_slot[i*2+1]->get_tab_count();
+ if (in_use)
+ splits[i]->show();
+ else
+ splits[i]->hide();
+ }
+
+ for(int i=0;i<DOCK_SLOT_MAX;i++) {
+
+ if (!dock_slot[i]->is_hidden() && dock_slot[i]->get_tab_count()) {
+ dock_slot[i]->set_current_tab(0);
+ }
+ }
+}
+
+
void EditorNode::_load_docks_from_config(Ref<ConfigFile> p_layout, const String& p_section) {
for(int i=0;i<DOCK_SLOT_MAX;i++) {
@@ -4539,7 +4662,7 @@ void EditorNode::_scene_tab_closed(int p_tab) {
}
else {
_remove_scene(p_tab);
- //_update_scene_tabs();
+ _update_scene_tabs();
}
}
@@ -4667,6 +4790,28 @@ void EditorNode::raise_bottom_panel_item(Control *p_item) {
}
+void EditorNode::remove_bottom_panel_item(Control *p_item) {
+
+ for(int i=0;i<bottom_panel_items.size();i++) {
+
+ if (bottom_panel_items[i].control==p_item) {
+ if (p_item->is_visible()) {
+ _bottom_panel_switch(false,0);
+ }
+ bottom_panel_vb->remove_child(bottom_panel_items[i].control);
+ bottom_panel_hb->remove_child(bottom_panel_items[i].button);
+ memdelete( bottom_panel_items[i].button );
+ bottom_panel_items.remove(i);
+ break;
+ }
+ }
+
+ for(int i=0;i<bottom_panel_items.size();i++) {
+ bottom_panel_items[i].button->disconnect("toggled",this,"_bottom_panel_switch");
+ bottom_panel_items[i].button->connect("toggled",this,"_bottom_panel_switch",varray(i));
+ }
+}
+
void EditorNode::_bottom_panel_switch(bool p_enable,int p_idx) {
ERR_FAIL_INDEX(p_idx,bottom_panel_items.size());
@@ -4692,6 +4837,31 @@ void EditorNode::_bottom_panel_switch(bool p_enable,int p_idx) {
}
}
+
+void EditorNode::add_control_to_dock(DockSlot p_slot,Control* p_control) {
+ ERR_FAIL_INDEX(p_slot,DOCK_SLOT_MAX);
+ dock_slot[p_slot]->add_child(p_control);
+ _update_dock_slots_visibility();
+
+}
+
+void EditorNode::remove_control_from_dock(Control* p_control) {
+
+ Control *dock=NULL;
+ for(int i=0;i<DOCK_SLOT_MAX;i++) {
+ if (p_control->get_parent()==dock_slot[i]) {
+ dock=dock_slot[i];
+ break;
+ }
+ }
+
+ ERR_EXPLAIN("Control was not in dock");
+ ERR_FAIL_COND(!dock);
+
+ dock->remove_child(p_control);
+ _update_dock_slots_visibility();
+}
+
void EditorNode::_bind_methods() {
@@ -4781,6 +4951,8 @@ EditorNode::EditorNode() {
EditorHelp::generate_doc(); //before any editor classes are crated
SceneState::set_disable_placeholders(true);
+ editor_initialize_certificates(); //for asset sharing
+
InputDefault *id = Input::get_singleton()->cast_to<InputDefault>();
@@ -4797,6 +4969,7 @@ EditorNode::EditorNode() {
singleton=this;
last_checked_version=0;
changing_scene=false;
+ _initializing_addons=false;
FileAccess::set_backup_save(true);
@@ -5692,7 +5865,7 @@ EditorNode::EditorNode() {
-
+
call_dialog = memnew( CallDialog );
call_dialog->hide();
gui_base->add_child( call_dialog );
@@ -5745,7 +5918,7 @@ EditorNode::EditorNode() {
dependency_fixer = memnew( DependencyEditor );
gui_base->add_child( dependency_fixer );
-
+
settings_config_dialog = memnew( EditorSettingsDialog );
gui_base->add_child(settings_config_dialog);
@@ -5855,7 +6028,7 @@ EditorNode::EditorNode() {
property_forward->connect("pressed", this,"_property_editor_forward");
property_back->connect("pressed", this,"_property_editor_back");
-
+
file_menu->get_popup()->connect("item_pressed", this,"_menu_option");
@@ -5901,6 +6074,7 @@ EditorNode::EditorNode() {
add_editor_plugin( memnew( CanvasItemEditorPlugin(this) ) );
add_editor_plugin( memnew( SpatialEditorPlugin(this) ) );
add_editor_plugin( memnew( ScriptEditorPlugin(this) ) );
+ //add_editor_plugin( memnew( AddonEditorPlugin(this) ) );
//more visually meaningful to have this later
raise_bottom_panel_item(AnimationPlayerEditor::singleton);
@@ -6056,7 +6230,7 @@ EditorNode::EditorNode() {
}
- EditorSettings::get_singleton()->enable_plugins();
+
Node::set_human_readable_collision_renaming(true);
@@ -6072,13 +6246,26 @@ EditorNode::EditorNode() {
editor_data.set_edited_scene(0);
_update_scene_tabs();
+ {
+
+ _initializing_addons=true;
+ Vector<String> addons = Globals::get_singleton()->get("editor_plugins/enabled");
+
+ for(int i=0;i<addons.size();i++) {
+ set_addon_plugin_enabled(addons[i],true);
+ }
+ _initializing_addons=false;
+ }
+
+
+
_load_docks();
}
-EditorNode::~EditorNode() {
+EditorNode::~EditorNode() {
memdelete( EditorHelp::get_doc_data() );
diff --git a/tools/editor/editor_node.h b/tools/editor/editor_node.h
index a83555d6e8..b8fabb4c55 100644
--- a/tools/editor/editor_node.h
+++ b/tools/editor/editor_node.h
@@ -101,6 +101,19 @@ class EditorNode : public Node {
OBJ_TYPE( EditorNode, Node );
+public:
+ enum DockSlot {
+ DOCK_SLOT_LEFT_UL,
+ DOCK_SLOT_LEFT_BL,
+ DOCK_SLOT_LEFT_UR,
+ DOCK_SLOT_LEFT_BR,
+ DOCK_SLOT_RIGHT_UL,
+ DOCK_SLOT_RIGHT_BL,
+ DOCK_SLOT_RIGHT_UR,
+ DOCK_SLOT_RIGHT_BR,
+ DOCK_SLOT_MAX
+ };
+private:
enum {
HISTORY_SIZE=64
};
@@ -182,17 +195,6 @@ class EditorNode : public Node {
OBJECT_METHOD_BASE=500
};
- enum DockSlot {
- DOCK_SLOT_LEFT_UL,
- DOCK_SLOT_LEFT_BL,
- DOCK_SLOT_LEFT_UR,
- DOCK_SLOT_LEFT_BR,
- DOCK_SLOT_RIGHT_UL,
- DOCK_SLOT_RIGHT_BL,
- DOCK_SLOT_RIGHT_UR,
- DOCK_SLOT_RIGHT_BR,
- DOCK_SLOT_MAX
- };
//Node *edited_scene; //scene being edited
@@ -400,13 +402,13 @@ class EditorNode : public Node {
String external_file;
List<String> previous_scenes;
bool opening_prev;
-
+
void _dialog_action(String p_file);
void _edit_current();
void _dialog_display_file_error(String p_file,Error p_error);
-
+
int current_option;
//void _animation_visibility_toggle();
void _resource_created();
@@ -421,7 +423,7 @@ class EditorNode : public Node {
void _select_history(int p_idx);
void _prepare_history();
-
+
void _fs_changed();
void _sources_changed(bool p_exist);
void _imported(Node *p_node);
@@ -479,6 +481,10 @@ class EditorNode : public Node {
Map<String,Ref<Texture> > icon_type_cache;
+ bool _initializing_addons;
+ Map<String,EditorPlugin*> plugin_addons;
+
+
static Ref<Texture> _file_dialog_get_icon(const String& p_path);
static void _file_dialog_register(FileDialog *p_dialog);
static void _file_dialog_unregister(FileDialog *p_dialog);
@@ -541,6 +547,8 @@ class EditorNode : public Node {
void _load_docks();
void _save_docks_to_config(Ref<ConfigFile> p_layout, const String& p_section);
void _load_docks_from_config(Ref<ConfigFile> p_layout, const String& p_section);
+ void _update_dock_slots_visibility();
+
void _update_layouts_menu();
void _layout_menu_option(int p_idx);
@@ -549,6 +557,9 @@ class EditorNode : public Node {
void _clear_search_box();
void _clear_undo_history();
+ void _update_addon_config();
+
+
protected:
void _notification(int p_what);
static void _bind_methods();
@@ -570,9 +581,14 @@ public:
static void add_editor_plugin(EditorPlugin *p_editor);
static void remove_editor_plugin(EditorPlugin *p_editor);
+ void add_control_to_dock(DockSlot p_slot,Control* p_control);
+ void remove_control_from_dock(Control* p_control);
+
void add_editor_import_plugin(const Ref<EditorImportPlugin>& p_editor_import);
void remove_editor_import_plugin(const Ref<EditorImportPlugin>& p_editor_import);
+ void set_addon_plugin_enabled(const String& p_addon,bool p_enabled);
+ bool is_addon_plugin_enabled(const String &p_addon) const;
void edit_node(Node *p_node);
void edit_resource(const Ref<Resource>& p_resource);
@@ -639,7 +655,7 @@ public:
Ref<Theme> get_editor_theme() const { return theme; }
- void show_warning(const String& p_text);
+ void show_warning(const String& p_text,const String& p_title="Warning!");
Error export_platform(const String& p_platform, const String& p_path, bool p_debug,const String& p_password,bool p_quit_after=false);
@@ -675,8 +691,9 @@ public:
void make_bottom_panel_item_visible(Control *p_item);
void raise_bottom_panel_item(Control *p_item);
void hide_bottom_panel();
+ void remove_bottom_panel_item(Control *p_item);
- EditorNode();
+ EditorNode();
~EditorNode();
void get_singleton(const char* arg1, bool arg2);
diff --git a/tools/editor/editor_plugin.cpp b/tools/editor/editor_plugin.cpp
index b7ccb452e9..dc46361251 100644
--- a/tools/editor/editor_plugin.cpp
+++ b/tools/editor/editor_plugin.cpp
@@ -29,6 +29,8 @@
#include "editor_plugin.h"
#include "plugins/canvas_item_editor_plugin.h"
#include "plugins/spatial_editor_plugin.h"
+#include "tools/editor/editor_node.h"
+#include "tools/editor/editor_settings.h"
void EditorPlugin::add_custom_type(const String& p_type, const String& p_base,const Ref<Script>& p_script, const Ref<Texture>& p_icon) {
@@ -41,8 +43,33 @@ void EditorPlugin::remove_custom_type(const String& p_type){
}
+void EditorPlugin::add_control_to_bottom_panel(Control *p_control, const String &p_title) {
-void EditorPlugin::add_custom_control(CustomControlContainer p_location,Control *p_control) {
+ EditorNode::get_singleton()->add_bottom_panel_item(p_title,p_control);
+}
+
+void EditorPlugin::add_control_to_dock(DockSlot p_slot,Control *p_control) {
+
+ ERR_FAIL_NULL(p_control);
+ EditorNode::get_singleton()->add_control_to_dock(EditorNode::DockSlot(p_slot),p_control);
+
+}
+
+void EditorPlugin::remove_control_from_docks(Control *p_control) {
+
+ ERR_FAIL_NULL(p_control);
+ EditorNode::get_singleton()->remove_control_from_dock(p_control);
+
+}
+
+void EditorPlugin::remove_control_from_bottom_panel(Control *p_control) {
+
+ ERR_FAIL_NULL(p_control);
+ EditorNode::get_singleton()->remove_bottom_panel_item(p_control);
+
+}
+
+void EditorPlugin::add_control_to_container(CustomControlContainer p_location,Control *p_control) {
switch(p_location) {
@@ -50,6 +77,7 @@ void EditorPlugin::add_custom_control(CustomControlContainer p_location,Control
EditorNode::get_menu_hb()->add_child(p_control);
} break;
+
case CONTAINER_SPATIAL_EDITOR_MENU: {
SpatialEditor::get_singleton()->add_control_to_menu_panel(p_control);
@@ -86,9 +114,13 @@ void EditorPlugin::add_custom_control(CustomControlContainer p_location,Control
}
}
-bool EditorPlugin::create_spatial_gizmo(Spatial* p_spatial) {
+Ref<SpatialEditorGizmo> EditorPlugin::create_spatial_gizmo(Spatial* p_spatial) {
//??
- return false;
+ if (get_script_instance() && get_script_instance()->has_method("create_spatial_gizmo")) {
+ return get_script_instance()->call("create_spatial_gizmo",p_spatial);
+ }
+
+ return Ref<SpatialEditorGizmo>();
}
bool EditorPlugin::forward_input_event(const InputEvent& p_event) {
@@ -206,15 +238,70 @@ void EditorPlugin::get_window_layout(Ref<ConfigFile> p_layout){
}
+EditorSelection* EditorPlugin::get_selection() {
+ return EditorNode::get_singleton()->get_editor_selection();
+}
+
+
+EditorSettings *EditorPlugin::get_editor_settings() {
+ return EditorSettings::get_singleton();
+}
+
+void EditorPlugin::add_import_plugin(const Ref<EditorImportPlugin>& p_editor_import) {
+
+ EditorNode::get_singleton()->add_editor_import_plugin(p_editor_import);
+}
+
+void EditorPlugin::remove_import_plugin(const Ref<EditorImportPlugin>& p_editor_import){
+
+ EditorNode::get_singleton()->remove_editor_import_plugin(p_editor_import);
+
+}
+
+void EditorPlugin::add_export_plugin(const Ref<EditorExportPlugin>& p_editor_export){
+
+ EditorImportExport::get_singleton()->add_export_plugin(p_editor_export);
+}
+void EditorPlugin::remove_export_plugin(const Ref<EditorExportPlugin>& p_editor_export){
+
+ EditorImportExport::get_singleton()->remove_export_plugin(p_editor_export);
+
+}
+
+Control *EditorPlugin::get_base_control() {
+
+ return EditorNode::get_singleton()->get_gui_base();
+}
+
+
void EditorPlugin::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("get_undo_redo"),&EditorPlugin::_get_undo_redo);
- ObjectTypeDB::bind_method(_MD("add_custom_control","container","control"),&EditorPlugin::add_custom_control);
+ ObjectTypeDB::bind_method(_MD("add_control_to_container","container","control:Control"),&EditorPlugin::add_control_to_container);
+ ObjectTypeDB::bind_method(_MD("add_control_to_bottom_panel","control:Control","title"),&EditorPlugin::add_control_to_bottom_panel);
+ ObjectTypeDB::bind_method(_MD("add_control_to_dock","slot","control:Control"),&EditorPlugin::add_control_to_dock);
+ ObjectTypeDB::bind_method(_MD("remove_control_from_docks","control:Control"),&EditorPlugin::remove_control_from_docks);
+ ObjectTypeDB::bind_method(_MD("remove_control_from_bottom_panel","control:Control"),&EditorPlugin::remove_control_from_bottom_panel);
ObjectTypeDB::bind_method(_MD("add_custom_type","type","base","script:Script","icon:Texture"),&EditorPlugin::add_custom_type);
ObjectTypeDB::bind_method(_MD("remove_custom_type","type"),&EditorPlugin::remove_custom_type);
+ ObjectTypeDB::bind_method(_MD("add_import_plugin","plugin:EditorImportPlugin"),&EditorPlugin::add_import_plugin);
+ ObjectTypeDB::bind_method(_MD("remove_import_plugin","plugin:EditorImportPlugin"),&EditorPlugin::remove_import_plugin);
+
+ ObjectTypeDB::bind_method(_MD("add_export_plugin","plugin:EditorExportPlugin"),&EditorPlugin::add_export_plugin);
+ ObjectTypeDB::bind_method(_MD("remove_export_plugin","plugin:EditorExportPlugin"),&EditorPlugin::remove_export_plugin);
+
+
+ ObjectTypeDB::bind_method(_MD("get_base_control:Control"),&EditorPlugin::get_base_control);
+ ObjectTypeDB::bind_method(_MD("get_undo_redo:UndoRedo"),&EditorPlugin::_get_undo_redo);
+ ObjectTypeDB::bind_method(_MD("get_selection:EditorSelection"),&EditorPlugin::get_selection);
+ ObjectTypeDB::bind_method(_MD("get_editor_settings:EditorSettings"),&EditorPlugin::get_editor_settings);
+
ObjectTypeDB::add_virtual_method(get_type_static(),MethodInfo(Variant::BOOL,"forward_input_event",PropertyInfo(Variant::INPUT_EVENT,"event")));
ObjectTypeDB::add_virtual_method(get_type_static(),MethodInfo(Variant::BOOL,"forward_spatial_input_event",PropertyInfo(Variant::OBJECT,"camera",PROPERTY_HINT_RESOURCE_TYPE,"Camera"),PropertyInfo(Variant::INPUT_EVENT,"event")));
+ MethodInfo gizmo = MethodInfo(Variant::OBJECT,"create_spatial_gizmo",PropertyInfo(Variant::OBJECT,"for_spatial:Spatial"));
+ gizmo.return_val.hint=PROPERTY_HINT_RESOURCE_TYPE;
+ gizmo.return_val.hint_string="EditorSpatialGizmo";
+ ObjectTypeDB::add_virtual_method(get_type_static(),gizmo);
ObjectTypeDB::add_virtual_method(get_type_static(),MethodInfo(Variant::STRING,"get_name"));
ObjectTypeDB::add_virtual_method(get_type_static(),MethodInfo(Variant::BOOL,"has_main_screen"));
ObjectTypeDB::add_virtual_method(get_type_static(),MethodInfo("make_visible",PropertyInfo(Variant::BOOL,"visible")));
@@ -233,6 +320,16 @@ void EditorPlugin::_bind_methods() {
BIND_CONSTANT( CONTAINER_CANVAS_EDITOR_MENU );
BIND_CONSTANT( CONTAINER_CANVAS_EDITOR_SIDE );
+ BIND_CONSTANT( DOCK_SLOT_LEFT_UL );
+ BIND_CONSTANT( DOCK_SLOT_LEFT_BL );
+ BIND_CONSTANT( DOCK_SLOT_LEFT_UR );
+ BIND_CONSTANT( DOCK_SLOT_LEFT_BR );
+ BIND_CONSTANT( DOCK_SLOT_RIGHT_UL );
+ BIND_CONSTANT( DOCK_SLOT_RIGHT_BL );
+ BIND_CONSTANT( DOCK_SLOT_RIGHT_UR );
+ BIND_CONSTANT( DOCK_SLOT_RIGHT_BR );
+ BIND_CONSTANT( DOCK_SLOT_MAX );
+
}
EditorPlugin::EditorPlugin()
diff --git a/tools/editor/editor_plugin.h b/tools/editor/editor_plugin.h
index bf1e185a37..c572ab210e 100644
--- a/tools/editor/editor_plugin.h
+++ b/tools/editor/editor_plugin.h
@@ -40,9 +40,15 @@
class EditorNode;
class Spatial;
class Camera;
+class EditorSelection;
+class EditorImportExport;
+class EditorSettings;
+class SpatialEditorGizmo;
+class EditorImportPlugin;
+class EditorExportPlugin;
class EditorPlugin : public Node {
-
+
OBJ_TYPE( EditorPlugin, Node );
friend class EditorData;
UndoRedo *undo_redo;
@@ -70,11 +76,27 @@ public:
CONTAINER_CANVAS_EDITOR_BOTTOM
};
+ enum DockSlot {
+ DOCK_SLOT_LEFT_UL,
+ DOCK_SLOT_LEFT_BL,
+ DOCK_SLOT_LEFT_UR,
+ DOCK_SLOT_LEFT_BR,
+ DOCK_SLOT_RIGHT_UL,
+ DOCK_SLOT_RIGHT_BL,
+ DOCK_SLOT_RIGHT_UR,
+ DOCK_SLOT_RIGHT_BR,
+ DOCK_SLOT_MAX
+ };
+
//TODO: send a resoucre for editing to the editor node?
- void add_custom_control(CustomControlContainer p_location,Control *p_control);
+ void add_control_to_container(CustomControlContainer p_location, Control *p_control);
+ void add_control_to_bottom_panel(Control *p_control, const String &p_title);
+ void add_control_to_dock(DockSlot p_slot,Control *p_control);
+ void remove_control_from_docks(Control *p_control);
+ void remove_control_from_bottom_panel(Control *p_control);
- virtual bool create_spatial_gizmo(Spatial* p_spatial);
+ virtual Ref<SpatialEditorGizmo> create_spatial_gizmo(Spatial* p_spatial);
virtual bool forward_input_event(const InputEvent& p_event);
virtual bool forward_spatial_input_event(Camera* p_camera,const InputEvent& p_event);
virtual String get_name() const;
@@ -94,6 +116,19 @@ public:
virtual void get_window_layout(Ref<ConfigFile> p_layout);
virtual void edited_scene_changed(){}; // if changes are pending in editor, apply them
+
+ Control *get_base_control();
+
+ void add_import_plugin(const Ref<EditorImportPlugin>& p_editor_import);
+ void remove_import_plugin(const Ref<EditorImportPlugin>& p_editor_import);
+
+ void add_export_plugin(const Ref<EditorExportPlugin>& p_editor_export);
+ void remove_export_plugin(const Ref<EditorExportPlugin>& p_editor_export);
+
+ EditorSelection* get_selection();
+ //EditorImportExport *get_import_export();
+ EditorSettings *get_editor_settings();
+
virtual void restore_global_state();
virtual void save_global_state();
@@ -103,6 +138,7 @@ public:
};
VARIANT_ENUM_CAST( EditorPlugin::CustomControlContainer );
+VARIANT_ENUM_CAST( EditorPlugin::DockSlot );
typedef EditorPlugin* (*EditorPluginCreateFunc)(EditorNode *);
diff --git a/tools/editor/editor_plugin_settings.cpp b/tools/editor/editor_plugin_settings.cpp
new file mode 100644
index 0000000000..d78e43c578
--- /dev/null
+++ b/tools/editor/editor_plugin_settings.cpp
@@ -0,0 +1,188 @@
+#include "editor_plugin_settings.h"
+#include "scene/gui/margin_container.h"
+#include "io/config_file.h"
+#include "os/file_access.h"
+#include "os/main_loop.h"
+#include "globals.h"
+#include "editor_node.h"
+
+void EditorPluginSettings::_notification(int p_what) {
+
+ if (p_what==MainLoop::NOTIFICATION_WM_FOCUS_IN) {
+ update_plugins();
+ }
+}
+
+void EditorPluginSettings::update_plugins() {
+
+
+ plugin_list->clear();
+
+ DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
+ Error err = da->change_dir("res://addons");
+ if (err!=OK) {
+ memdelete(da);
+ return;
+ }
+
+ updating=true;
+
+ TreeItem *root = plugin_list->create_item();
+
+ da->list_dir_begin();
+
+ String d = da->get_next();
+
+ Vector<String> plugins;
+
+ while(d!=String()) {
+
+ bool dir = da->current_is_dir();
+ String path = "res://addons/"+d+"/plugin.cfg";
+
+ if (dir && FileAccess::exists(path)) {
+
+ plugins.push_back(d);
+ }
+
+ d = da->get_next();
+ }
+
+ da->list_dir_end();
+ memdelete(da);
+
+ plugins.sort();
+
+ Vector<String> active_plugins = Globals::get_singleton()->get("plugins/active");
+
+ for(int i=0;i<plugins.size();i++) {
+
+ Ref<ConfigFile> cf;
+ cf.instance();
+ String path = "res://addons/"+plugins[i]+"/plugin.cfg";
+
+ Error err = cf->load(path);
+
+ if (err!=OK) {
+ WARN_PRINTS("Can't load plugin config: "+path);
+ } else if (!cf->has_section_key("plugin","name")) {
+ WARN_PRINTS("Plugin misses plugin/name: "+path);
+ } else if (!cf->has_section_key("plugin","author")) {
+ WARN_PRINTS("Plugin misses plugin/author: "+path);
+ } else if (!cf->has_section_key("plugin","version")) {
+ WARN_PRINTS("Plugin misses plugin/version: "+path);
+ } else if (!cf->has_section_key("plugin","description")) {
+ WARN_PRINTS("Plugin misses plugin/description: "+path);
+ } else if (!cf->has_section_key("plugin","script")) {
+ WARN_PRINTS("Plugin misses plugin/script: "+path);
+ } else {
+
+ String d = plugins[i];
+ String name = cf->get_value("plugin","name");
+ String author = cf->get_value("plugin","author");
+ String version = cf->get_value("plugin","version");
+ String description = cf->get_value("plugin","description");
+ String script = cf->get_value("plugin","script");
+
+ TreeItem *item = plugin_list->create_item(root);
+ item->set_text(0,name);
+ item->set_tooltip(0,"Name: "+name+"\nPath: "+path+"\nMain Script: "+script);
+ item->set_metadata(0,d);
+ item->set_text(1,version);
+ item->set_metadata(1,script);
+ item->set_text(2,author);
+ item->set_metadata(2,description);
+ item->set_cell_mode(3,TreeItem::CELL_MODE_RANGE);
+ item->set_range_config(3,0,1,1);
+ item->set_text(3,"Inactive,Active");
+ item->set_editable(3,true);
+
+ if (EditorNode::get_singleton()->is_addon_plugin_enabled(d)) {
+ item->set_custom_color(3,Color(0.2,1,0.2));
+ item->set_range(3,1);
+ } else {
+ item->set_custom_color(3,Color(1,0.2,0.2));
+ item->set_range(3,0);
+ }
+ }
+
+ }
+
+ updating=false;
+
+}
+
+
+void EditorPluginSettings::_plugin_activity_changed() {
+
+ if (updating)
+ return;
+
+ TreeItem *ti=plugin_list->get_edited();
+ ERR_FAIL_COND(!ti);
+ bool active = ti->get_range(3);
+ String name = ti->get_metadata(0);
+
+ EditorNode::get_singleton()->set_addon_plugin_enabled(name,active);
+
+ bool is_active = EditorNode::get_singleton()->is_addon_plugin_enabled(name);
+
+ if (is_active!=active) {
+ updating=true;
+ ti->set_range(3,is_active?1:0);
+ updating=false;
+ }
+
+ if (is_active)
+ ti->set_custom_color(3,Color(0.2,1,0.2));
+ else
+ ti->set_custom_color(3,Color(1,0.2,0.2));
+
+
+}
+
+void EditorPluginSettings::_bind_methods() {
+
+ ObjectTypeDB::bind_method("update_plugins",&EditorPluginSettings::update_plugins);
+ ObjectTypeDB::bind_method("_plugin_activity_changed",&EditorPluginSettings::_plugin_activity_changed);
+}
+
+EditorPluginSettings::EditorPluginSettings() {
+
+ HBoxContainer *title_hb = memnew( HBoxContainer );
+ title_hb->add_child(memnew( Label("Installed Plugins:")));
+ title_hb->add_spacer();
+ update_list = memnew( Button("Update") );
+ update_list->connect("pressed",this,"update_plugins");
+ title_hb->add_child(update_list);
+ add_child(title_hb);
+
+ plugin_list = memnew( Tree );
+ plugin_list->set_v_size_flags(SIZE_EXPAND_FILL);
+ plugin_list->set_columns(4);
+ plugin_list->set_column_titles_visible(true);
+ plugin_list->set_column_title(0,"Name:");
+ plugin_list->set_column_title(1,"Version:");
+ plugin_list->set_column_title(2,"Author:");
+ plugin_list->set_column_title(3,"Status:");
+ plugin_list->set_column_expand(0,true);
+ plugin_list->set_column_expand(1,false);
+ plugin_list->set_column_expand(2,false);
+ plugin_list->set_column_expand(3,false);
+ plugin_list->set_column_min_width(1,100);
+ plugin_list->set_column_min_width(2,250);
+ plugin_list->set_column_min_width(3,80);
+ plugin_list->set_hide_root(true);
+ plugin_list->connect("item_edited",this,"_plugin_activity_changed");
+
+
+ MarginContainer *mc = memnew( MarginContainer );
+ mc->add_child(plugin_list);
+ mc->set_v_size_flags(SIZE_EXPAND_FILL);
+
+ add_child(mc);
+
+ updating=false;
+
+}
+
diff --git a/tools/editor/editor_plugin_settings.h b/tools/editor/editor_plugin_settings.h
new file mode 100644
index 0000000000..4f3c5b8268
--- /dev/null
+++ b/tools/editor/editor_plugin_settings.h
@@ -0,0 +1,35 @@
+#ifndef EDITORPLUGINSETTINGS_H
+#define EDITORPLUGINSETTINGS_H
+
+
+#include "scene/gui/dialogs.h"
+#include "property_editor.h"
+#include "optimized_save_dialog.h"
+#include "undo_redo.h"
+#include "editor_data.h"
+
+class EditorPluginSettings : public VBoxContainer {
+
+ OBJ_TYPE(EditorPluginSettings,VBoxContainer);
+
+ Button* update_list;
+ Tree *plugin_list;
+ bool updating;
+
+
+ void _plugin_activity_changed();
+protected:
+
+ void _notification(int p_what);
+
+ static void _bind_methods();
+
+
+public:
+
+ void update_plugins();
+
+ EditorPluginSettings();
+};
+
+#endif // EDITORPLUGINSETTINGS_H
diff --git a/tools/editor/editor_settings.cpp b/tools/editor/editor_settings.cpp
index 78fde9950d..1133acb48c 100644
--- a/tools/editor/editor_settings.cpp
+++ b/tools/editor/editor_settings.cpp
@@ -228,13 +228,6 @@ void EditorSettings::create() {
dir->change_dir("..");
}
- if (dir->change_dir("plugins")!=OK) {
- dir->make_dir("plugins");
- } else {
-
- dir->change_dir("..");
- }
-
if (dir->change_dir("config")!=OK) {
dir->make_dir("config");
} else {
@@ -287,7 +280,6 @@ void EditorSettings::create() {
singleton->setup_network();
singleton->load_favorites();
- singleton->scan_plugins();
return;
@@ -312,7 +304,6 @@ void EditorSettings::create() {
singleton->settings_path=config_path+"/"+config_dir;
singleton->_load_defaults(extra_config);
singleton->setup_network();
- singleton->scan_plugins();
}
@@ -323,35 +314,6 @@ String EditorSettings::get_settings_path() const {
}
-Error EditorSettings::_load_plugin(const String& p_path, Plugin &plugin) {
-
- if (!FileAccess::exists(p_path))
- return ERR_FILE_NOT_FOUND;
-
- Ref<ConfigFile> cf = memnew(ConfigFile);
- Error err = cf->load(p_path);
- ERR_EXPLAIN("Error loading plugin description for: "+p_path);
- ERR_FAIL_COND_V(err!=OK,ERR_CANT_OPEN);
-
- plugin.instance=NULL;
- ERR_FAIL_COND_V(!cf->has_section_key("plugin","name"),ERR_INVALID_DATA);
- ERR_FAIL_COND_V(!cf->has_section_key("plugin","installs"),ERR_INVALID_DATA);
- ERR_FAIL_COND_V(!cf->has_section_key("plugin","author"),ERR_INVALID_DATA);
- ERR_FAIL_COND_V(!cf->has_section_key("plugin","version"),ERR_INVALID_DATA);
- ERR_FAIL_COND_V(!cf->has_section_key("plugin","script"),ERR_INVALID_DATA);
- plugin.name=cf->get_value("plugin","name");
- plugin.author=cf->get_value("plugin","author");
- plugin.version=cf->get_value("plugin","version");
- plugin.script=cf->get_value("plugin","script");
-
- if (cf->has_section_key("plugin","description"))
- plugin.description=cf->get_value("plugin","description");
- plugin.installs=cf->get_value("plugin","installs");
- if (cf->has_section_key("plugin","install_files"))
- plugin.install_files=cf->get_value("plugin","install_files");
-
- return OK;
-}
void EditorSettings::setup_network() {
@@ -382,46 +344,6 @@ void EditorSettings::setup_network() {
}
-void EditorSettings::scan_plugins() {
-
- Map<String,Plugin> new_plugins;
-
- new_plugins.clear();
- DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
- Error err = d->change_dir(get_settings_path().plus_file("plugins"));
- if (err!=OK) {
- memdelete(d);
- ERR_EXPLAIN("Plugin dir does not exist!")
- ERR_FAIL_COND(err!=OK);
- }
- d->list_dir_begin();
-
- String base = d->get_current_dir();
- //print_line("list diring on: "+base);
- while(true) {
- String p = d->get_next();
- if (p=="")
- break;
- if (!d->current_is_dir() || p.begins_with("."))
- continue;
-
- String cfpath=d->get_current_dir().plus_file(p+"/plugin.cfg");
-
- Plugin plugin;
- Error err = _load_plugin(cfpath,plugin);
- ERR_CONTINUE(err!=OK);
-
- if (plugins.has(p))
- plugin.instance=plugins[p].instance;
-
- new_plugins[p]=plugin;
- }
-
-
- plugins=new_plugins;
-
- memdelete(d);
-}
void EditorSettings::save() {
@@ -482,6 +404,11 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
set("text_editor/brace_mismatch_color",Color(1,0.2,0.2));
set("text_editor/current_line_color",Color(0.3,0.5,0.8,0.15));
+ set("text_editor/scroll_past_end_of_file", false);
+
+ set("text_editor/tab_size", 4);
+ 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/idle_parse_delay",2);
set("text_editor/create_signal_callbacks",true);
set("text_editor/autosave_interval_secs",0);
@@ -564,13 +491,29 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
set("resources/save_compressed_resources",true);
set("resources/auto_reload_modified_images",true);
- if (p_extra_config.is_valid() && p_extra_config->has_section("init_projects") && p_extra_config->has_section_key("init_projects", "list")) {
+ if (p_extra_config.is_valid()) {
- Vector<String> list = p_extra_config->get_value("init_projects", "list");
- for (int i=0; i<list.size(); i++) {
+ if (p_extra_config->has_section("init_projects") && p_extra_config->has_section_key("init_projects", "list")) {
+
+ Vector<String> list = p_extra_config->get_value("init_projects", "list");
+ for (int i=0; i<list.size(); i++) {
- String name = list[i].replace("/", "::");
- set("projects/"+name, list[i]);
+ String name = list[i].replace("/", "::");
+ set("projects/"+name, list[i]);
+ };
+ };
+
+ if (p_extra_config->has_section("presets")) {
+
+ List<String> keys;
+ p_extra_config->get_section_keys("presets", &keys);
+
+ for (List<String>::Element *E=keys.front();E;E=E->next()) {
+
+ String key = E->get();
+ Variant val = p_extra_config->get_value("presets", key);
+ set(key, val);
+ };
};
};
@@ -607,148 +550,9 @@ void EditorSettings::add_property_hint(const PropertyInfo& p_hint) {
}
-bool EditorSettings::is_plugin_enabled(const String& p_plugin) {
-
- if (!has("_plugins/enabled"))
- return false;
-
- StringArray sa=get("_plugins/enabled");
-
- for(int i=0;i<sa.size();i++) {
-
- String plugin = sa[i];
- if (!plugins.has(plugin))
- continue;
- if (plugin==p_plugin)
- return true;
- }
-
- return false;
-
-}
-
-void EditorSettings::enable_plugins() {
-
- // editor plugins
- if (has("_plugins/enabled")) {
- StringArray sa=get("_plugins/enabled");
- for(int i=0;i<sa.size();i++) {
-
- String plugin = sa[i];
- if (!plugins.has(plugin))
- continue;
- if (plugins[plugin].installs)
- continue; //not configured here
- set_plugin_enabled(plugin,true);
- }
- }
-
- // installed plugins
- List<PropertyInfo> pi;
- Globals::get_singleton()->get_property_list(&pi);
- for (List<PropertyInfo>::Element *E=pi.front();E;E=E->next()) {
-
- String p = E->get().name;
-
- if (p.begins_with("plugins/")) {
- load_installed_plugin(p.replace_first("plugins/",""));
- }
- }
-
-}
-
-void EditorSettings::load_installed_plugin(const String& p_plugin) {
-
- ERR_FAIL_COND( !Globals::get_singleton()->has("plugins/"+p_plugin) );
- String path = Globals::get_singleton()->get("plugins/"+p_plugin);
-
- Plugin plugin;
- Error err = _load_plugin(path.plus_file("plugin.cfg"),plugin);
-
- if (err)
- return;
-
- print_line("installing plugin...");
- EditorPlugin *ep=_load_plugin_editor(path.plus_file(plugin.script));
- ERR_FAIL_COND(!ep);
- print_line("load!");
- EditorNode::add_editor_plugin(ep);
-
-}
-
-
-EditorPlugin *EditorSettings::_load_plugin_editor(const String& p_path) {
-
- Ref<Script> script = ResourceLoader::load(p_path);
- ERR_EXPLAIN("Invalid Script for plugin: "+p_path);
- ERR_FAIL_COND_V(script.is_null(),NULL);
- ERR_EXPLAIN("Script has errors: "+p_path);
- ERR_FAIL_COND_V(!script->can_instance(),NULL);
- ERR_EXPLAIN("Script does not inherit EditorPlugin: "+p_path);
- ERR_FAIL_COND_V(script->get_instance_base_type().operator String()!="EditorPlugin",NULL);
-
- EditorPlugin *ep = memnew( EditorPlugin );
- ep->set_script(script.get_ref_ptr());
- if (!ep->get_script_instance()) {
- memdelete(ep);
- ERR_EXPLAIN("Script could't load: "+p_path);
- ERR_FAIL_V(NULL);
- }
- return ep;
-}
-
-void EditorSettings::set_plugin_enabled(const String& p_plugin, bool p_enabled) {
-
- ERR_FAIL_COND(!plugins.has(p_plugin));
- if (p_enabled == (plugins[p_plugin].instance!=NULL)) //already enabled or disabled
- return;
-
- print_line("REQUEST "+p_plugin+" to "+itos(p_enabled));
- StringArray sa;
- if (has("_plugins/enabled"))
- sa=get("_plugins/enabled");
-
- int idx=-1;
- for(int i=0;i<sa.size();i++) {
-
- if (sa[i]==p_plugin) {
- idx=i;
- break;
- }
- }
-
- if (p_enabled) {
-
-
- String ppath = get_settings_path().plus_file("plugins/"+p_plugin+"/"+plugins[p_plugin].script);
- EditorPlugin *ep=_load_plugin_editor(ppath);
- if (!ep)
- return;
- plugins[p_plugin].instance=ep;
- EditorNode::add_editor_plugin(ep);
-
- if (idx==-1)
- sa.push_back(p_plugin);
- } else {
-
- print_line("DISABLING");
- EditorNode::remove_editor_plugin(plugins[p_plugin].instance);
- memdelete(plugins[p_plugin].instance);
- plugins[p_plugin].instance=NULL;
- if (idx!=-1)
- sa.remove(idx);
-
- }
-
- if (sa.size()==0)
- set("_plugins/enabled",Variant());
- else
- set("_plugins/enabled",sa);
-
-}
void EditorSettings::set_favorite_dirs(const Vector<String>& p_favorites) {
@@ -818,6 +622,16 @@ void EditorSettings::load_favorites() {
void EditorSettings::_bind_methods() {
+ ObjectTypeDB::bind_method(_MD("erase","property"),&EditorSettings::erase);
+ ObjectTypeDB::bind_method(_MD("get_settings_path"),&EditorSettings::get_settings_path);
+ ObjectTypeDB::bind_method(_MD("get_project_settings_path"),&EditorSettings::get_project_settings_path);
+
+ ObjectTypeDB::bind_method(_MD("set_favorite_dirs","dirs"),&EditorSettings::set_favorite_dirs);
+ ObjectTypeDB::bind_method(_MD("get_favorite_dirs"),&EditorSettings::get_favorite_dirs);
+
+ ObjectTypeDB::bind_method(_MD("set_recent_dirs","dirs"),&EditorSettings::set_recent_dirs);
+ ObjectTypeDB::bind_method(_MD("get_recent_dirs"),&EditorSettings::get_recent_dirs);
+
ADD_SIGNAL(MethodInfo("settings_changed"));
}
diff --git a/tools/editor/editor_settings.h b/tools/editor/editor_settings.h
index 40aa00015e..ae5bbcca89 100644
--- a/tools/editor/editor_settings.h
+++ b/tools/editor/editor_settings.h
@@ -57,7 +57,6 @@ public:
Vector<String> install_files;
};
private:
- Map<String,Plugin> plugins;
struct VariantContainer {
int order;
@@ -84,9 +83,6 @@ private:
Ref<Resource> clipboard;
- EditorPlugin *_load_plugin_editor(const String& p_path);
- Error _load_plugin(const String& p_path,Plugin& plugin);
-
void _load_defaults(Ref<ConfigFile> p_extra_config = NULL);
String project_config_path;
@@ -108,13 +104,10 @@ public:
static EditorSettings *get_singleton();
void erase(String p_var);
String get_settings_path() const;
- String get_global_settings_path() const;
+ //String get_global_settings_path() const;
String get_project_settings_path() const;
- const Map<String,Plugin>& get_plugins() const { return plugins; }
- void scan_plugins();
- void enable_plugins();
void setup_network();
void raise_order(const String& p_name);
@@ -124,11 +117,6 @@ public:
void notify_changes();
- void set_plugin_enabled(const String& p_plugin,bool p_enabled);
- bool is_plugin_enabled(const String& p_plugin);
-
- void load_installed_plugin(const String& p_plugin);
-
void set_resource_clipboard(const Ref<Resource>& p_resource) { clipboard=p_resource; }
Ref<Resource> get_resource_clipboard() const { return clipboard; }
diff --git a/tools/editor/editor_sub_scene.cpp b/tools/editor/editor_sub_scene.cpp
index e58e2c1351..c5a4f6d58b 100644
--- a/tools/editor/editor_sub_scene.cpp
+++ b/tools/editor/editor_sub_scene.cpp
@@ -147,7 +147,7 @@ void EditorSubScene::move(Node* p_new_parent, Node* p_new_owner) {
}
TreeItem *s = tree->get_selected();
if (!s) {
- return;
+ return;
}
Node *selnode = s->get_metadata(0);
@@ -219,7 +219,7 @@ EditorSubScene::EditorSubScene() {
tree = memnew( Tree );
tree->set_v_size_flags(SIZE_EXPAND_FILL);
vb->add_margin_child("Import From Node:",tree,true);
- tree->connect("item_activated",this,"_ok");
+ tree->connect("item_activated",this,"_ok",make_binds(),CONNECT_DEFERRED);
file_dialog = memnew( EditorFileDialog );
List<String> extensions;
diff --git a/tools/editor/groups_editor.h b/tools/editor/groups_editor.h
index b5bccb2766..6a897d0cbb 100644
--- a/tools/editor/groups_editor.h
+++ b/tools/editor/groups_editor.h
@@ -63,7 +63,7 @@ public:
void set_undo_redo(UndoRedo *p_undoredo) { undo_redo=p_undoredo; }
void set_current(Node* p_node);
- GroupsEditor();
+ GroupsEditor();
~GroupsEditor();
};
diff --git a/tools/editor/icons/icon_godot_asset_default.png b/tools/editor/icons/icon_godot_asset_default.png
new file mode 100644
index 0000000000..7478399e8b
--- /dev/null
+++ b/tools/editor/icons/icon_godot_asset_default.png
Binary files differ
diff --git a/tools/editor/icons/icon_h_t_t_p_request.png b/tools/editor/icons/icon_h_t_t_p_request.png
new file mode 100644
index 0000000000..6c7f1885ce
--- /dev/null
+++ b/tools/editor/icons/icon_h_t_t_p_request.png
Binary files differ
diff --git a/tools/editor/icons/icon_link_button.png b/tools/editor/icons/icon_link_button.png
new file mode 100644
index 0000000000..b6b9868e11
--- /dev/null
+++ b/tools/editor/icons/icon_link_button.png
Binary files differ
diff --git a/tools/editor/icons/icon_rating_no_star.png b/tools/editor/icons/icon_rating_no_star.png
new file mode 100644
index 0000000000..76f1127ccc
--- /dev/null
+++ b/tools/editor/icons/icon_rating_no_star.png
Binary files differ
diff --git a/tools/editor/icons/icon_rating_star.png b/tools/editor/icons/icon_rating_star.png
new file mode 100644
index 0000000000..ff52bddba0
--- /dev/null
+++ b/tools/editor/icons/icon_rating_star.png
Binary files differ
diff --git a/tools/editor/icons/icon_thumbnail_wait.png b/tools/editor/icons/icon_thumbnail_wait.png
new file mode 100644
index 0000000000..96a7d424e3
--- /dev/null
+++ b/tools/editor/icons/icon_thumbnail_wait.png
Binary files differ
diff --git a/tools/editor/io_plugins/editor_font_import_plugin.cpp b/tools/editor/io_plugins/editor_font_import_plugin.cpp
index 9b4ca246e7..ff126a8e8c 100644
--- a/tools/editor/io_plugins/editor_font_import_plugin.cpp
+++ b/tools/editor/io_plugins/editor_font_import_plugin.cpp
@@ -540,7 +540,7 @@ class EditorFontImportDialog : public ConfirmationDialog {
return;
}
- //_import_inc(dest->get_line_edit()->get_text());
+ _import_inc(dest->get_line_edit()->get_text());
hide();
}
diff --git a/tools/editor/io_plugins/editor_import_collada.cpp b/tools/editor/io_plugins/editor_import_collada.cpp
index 7de9d978f2..f008c4a736 100644
--- a/tools/editor/io_plugins/editor_import_collada.cpp
+++ b/tools/editor/io_plugins/editor_import_collada.cpp
@@ -1372,7 +1372,7 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize,Ref<Mesh>& p_mesh,con
DVector<float> tangents;
print_line("vertex source id: "+vertex_src_id);
if(md.vertices[vertex_src_id].sources.has("NORMAL")){
- //has normals
+ //has normals
normals.resize(vlen);
//std::cout << "has normals" << std::endl;
String normal_src_id = md.vertices[vertex_src_id].sources["NORMAL"];
@@ -1386,7 +1386,7 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize,Ref<Mesh>& p_mesh,con
if (stride==0)
stride=3;
-
+
//read normals from morph target
DVector<Vector3>::Write vertw = normals.write();
@@ -1421,7 +1421,7 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize,Ref<Mesh>& p_mesh,con
}
}
}
-
+
print_line("using built-in normals");
}else{
print_line("generating normals");
@@ -2070,7 +2070,7 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones
animation->add_track(Animation::TYPE_TRANSFORM);
- int track = animation->get_track_count() -1;
+ int track = animation->get_track_count() -1;
animation->track_set_path( track , path );
Vector<float> snapshots = base_snapshots;
diff --git a/tools/editor/io_plugins/editor_scene_import_plugin.cpp b/tools/editor/io_plugins/editor_scene_import_plugin.cpp
index a3b6827cd4..15e7a70111 100644
--- a/tools/editor/io_plugins/editor_scene_import_plugin.cpp
+++ b/tools/editor/io_plugins/editor_scene_import_plugin.cpp
@@ -57,11 +57,12 @@ void EditorScenePostImport::_bind_methods() {
}
-Error EditorScenePostImport::post_import(Node* p_scene) {
+Node *EditorScenePostImport::post_import(Node* p_scene) {
if (get_script_instance())
- return Error(int(get_script_instance()->call("post_import",p_scene)));
- return OK;
+ return get_script_instance()->call("post_import",p_scene);
+
+ return p_scene;
}
EditorScenePostImport::EditorScenePostImport() {
@@ -461,7 +462,7 @@ EditorImportAnimationOptions::EditorImportAnimationOptions() {
items.push_back(ti);
fname++;
fdescr++;
- }
+ }
TreeItem *fps_base = flags->create_item(root);
@@ -2748,8 +2749,8 @@ Error EditorSceneImportPlugin::import2(Node *scene, const String& p_dest_path, c
if (post_import_script.is_valid()) {
- err = post_import_script->post_import(scene);
- if (err) {
+ scene = post_import_script->post_import(scene);
+ if (!scene) {
EditorNode::add_io_error("Error running Post-Import script: '"+post_import_script_path);
return err;
}
diff --git a/tools/editor/io_plugins/editor_scene_import_plugin.h b/tools/editor/io_plugins/editor_scene_import_plugin.h
index 1f3b73fe7f..a1a090de7e 100644
--- a/tools/editor/io_plugins/editor_scene_import_plugin.h
+++ b/tools/editor/io_plugins/editor_scene_import_plugin.h
@@ -87,7 +87,7 @@ protected:
static void _bind_methods();
public:
- virtual Error post_import(Node* p_scene);
+ virtual Node* post_import(Node* p_scene);
EditorScenePostImport();
};
diff --git a/tools/editor/io_plugins/editor_texture_import_plugin.cpp b/tools/editor/io_plugins/editor_texture_import_plugin.cpp
index 29273ebd06..ea7242c185 100644
--- a/tools/editor/io_plugins/editor_texture_import_plugin.cpp
+++ b/tools/editor/io_plugins/editor_texture_import_plugin.cpp
@@ -1549,7 +1549,7 @@ Vector<uint8_t> EditorTextureImportPlugin::custom_export(const String& p_path, c
}
uint32_t flags = rimd->get_option("flags");
- uint8_t shrink = rimd->has_option("shrink") ? rimd->get_option("shrink"): Variant(1);
+ uint8_t shrink = rimd->has_option("shrink") ? rimd->get_option("shrink"): Variant(1);
uint8_t format = rimd->get_option("format");
uint8_t comp = (format==EditorTextureImportPlugin::IMAGE_FORMAT_COMPRESS_RAM)?uint8_t(p_platform->get_image_compression()):uint8_t(255);
@@ -1633,7 +1633,7 @@ EditorTextureImportPlugin::EditorTextureImportPlugin(EditorNode *p_editor, Mode
singleton[p_mode]=this;
editor=p_editor;
- mode=p_mode;
+ mode=p_mode;
dialog = memnew( EditorTextureImportDialog(this,p_mode==MODE_TEXTURE_2D || p_mode==MODE_ATLAS || p_mode==MODE_LARGE,p_mode==MODE_ATLAS,p_mode==MODE_LARGE) );
editor->get_gui_base()->add_child(dialog);
diff --git a/tools/editor/output_strings.cpp b/tools/editor/output_strings.cpp
index a19352f4ec..f1b49d2326 100644
--- a/tools/editor/output_strings.cpp
+++ b/tools/editor/output_strings.cpp
@@ -84,7 +84,7 @@ void OutputStrings::_notification(int p_what) {
Ref<Texture> icon_warning = get_icon("Warning","EditorIcons");
// int lines = (size_height-(int)margin.y) / font_height;
- Point2 ofs=tree_st->get_offset();
+ Point2 ofs=tree_st->get_offset();
LineMap::Element *E = line_map.find(v_scroll->get_val());
float h_ofs = (int)h_scroll->get_val();
diff --git a/tools/editor/output_strings.h b/tools/editor/output_strings.h
index 3d5deb1646..29c6ea799f 100644
--- a/tools/editor/output_strings.h
+++ b/tools/editor/output_strings.h
@@ -81,7 +81,7 @@ protected:
public:
- void add_line(const String& p_text, const Variant& p_meta=Variant(), const LineType p_type=LINE_NORMAL);
+ void add_line(const String& p_text, const Variant& p_meta=Variant(), const LineType p_type=LINE_NORMAL);
OutputStrings();
};
diff --git a/tools/editor/plugins/animation_player_editor_plugin.cpp b/tools/editor/plugins/animation_player_editor_plugin.cpp
index 010753e88c..0b06aab447 100644
--- a/tools/editor/plugins/animation_player_editor_plugin.cpp
+++ b/tools/editor/plugins/animation_player_editor_plugin.cpp
@@ -731,7 +731,7 @@ void AnimationPlayerEditor::_dialog_action(String p_file) {
String current = animation->get_item_text(animation->get_selected());
if (current != "") {
Ref<Animation> anim = player->get_animation(current);
-
+
ERR_FAIL_COND(!anim->cast_to<Resource>())
RES current_res = RES(anim->cast_to<Resource>());
@@ -1424,7 +1424,7 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor) {
add_child(error_dialog);
name_dialog->connect("confirmed", this,"_animation_name_edited");
-
+
blend_editor.dialog = memnew( AcceptDialog );
add_child(blend_editor.dialog);
blend_editor.dialog->get_ok()->set_text("Close");
@@ -1441,7 +1441,7 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor) {
updating_blends=false;
blend_editor.tree->connect("item_edited",this,"_blend_edited");
-
+
autoplay->connect("pressed", this,"_autoplay_pressed");
autoplay->set_toggle_mode(true);
diff --git a/tools/editor/plugins/animation_tree_editor_plugin.cpp b/tools/editor/plugins/animation_tree_editor_plugin.cpp
index d85553b4db..08c2a1c3ae 100644
--- a/tools/editor/plugins/animation_tree_editor_plugin.cpp
+++ b/tools/editor/plugins/animation_tree_editor_plugin.cpp
@@ -593,7 +593,7 @@ void AnimationTreeEditor::_draw_node(const StringName& p_node) {
} break;
case AnimationTreePlayer::NODE_ONESHOT:
- case AnimationTreePlayer::NODE_MIX:
+ case AnimationTreePlayer::NODE_MIX:
case AnimationTreePlayer::NODE_BLEND2:
case AnimationTreePlayer::NODE_BLEND3:
case AnimationTreePlayer::NODE_BLEND4:
@@ -1155,7 +1155,7 @@ StringName AnimationTreeEditor::_add_node(int p_item) {
anim_tree->node_set_pos(name,Point2(last_x,last_y));
order.push_back(name);
last_x+=10;
- last_y+=10;
+ last_y+=10;
last_x=last_x % (int)get_size().width;
last_y=last_y % (int)get_size().height;
update();
diff --git a/tools/editor/plugins/baked_light_baker.h b/tools/editor/plugins/baked_light_baker.h
index 8fbeeddc6a..5c172f79c6 100644
--- a/tools/editor/plugins/baked_light_baker.h
+++ b/tools/editor/plugins/baked_light_baker.h
@@ -96,7 +96,7 @@ public:
struct Triangle {
- AABB aabb;
+ AABB aabb;
Vector3 vertices[3];
Vector2 uvs[3];
Vector2 bake_uvs[3];
diff --git a/tools/editor/plugins/baked_light_editor_plugin.cpp b/tools/editor/plugins/baked_light_editor_plugin.cpp
index 26524b2437..56aabaf6d9 100644
--- a/tools/editor/plugins/baked_light_editor_plugin.cpp
+++ b/tools/editor/plugins/baked_light_editor_plugin.cpp
@@ -131,7 +131,7 @@ void BakedLightEditor::_notification(int p_option) {
last_rays_time=rays_snap;
bake_info->set_text("rays/s: "+itos(rays_sec));
- update_timeout=1;
+ update_timeout=1;
print_line("MSUPDATE: "+itos(OS::get_singleton()->get_ticks_msec()-t));
t=OS::get_singleton()->get_ticks_msec();
node->get_baked_light()->set_octree(octree_texture);
@@ -332,7 +332,7 @@ BakedLightEditorPlugin::BakedLightEditorPlugin(EditorNode *p_node) {
editor=p_node;
baked_light_editor = memnew( BakedLightEditor );
editor->get_viewport()->add_child(baked_light_editor);
- add_custom_control(CONTAINER_SPATIAL_EDITOR_MENU,baked_light_editor->bake_hbox);
+ add_control_to_container(CONTAINER_SPATIAL_EDITOR_MENU,baked_light_editor->bake_hbox);
baked_light_editor->hide();
baked_light_editor->bake_hbox->hide();
}
diff --git a/tools/editor/plugins/canvas_item_editor_plugin.cpp b/tools/editor/plugins/canvas_item_editor_plugin.cpp
index f8bc97a433..6eb26542be 100644
--- a/tools/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/tools/editor/plugins/canvas_item_editor_plugin.cpp
@@ -49,10 +49,10 @@ friend class CanvasItemEditor;
SpinBox *grid_offset_x;
SpinBox *grid_offset_y;
SpinBox *grid_step_x;
- SpinBox *grid_step_y;
- SpinBox *rotation_offset;
+ SpinBox *grid_step_y;
+ SpinBox *rotation_offset;
SpinBox *rotation_step;
-
+
public:
SnapDialog() : ConfirmationDialog() {
const int SPIN_BOX_GRID_RANGE = 256;
@@ -134,7 +134,7 @@ public:
rotation_step->set_suffix("deg");
child_container->add_child(rotation_step);
}
-
+
void set_fields(const Point2 p_grid_offset, const Size2 p_grid_step, const float p_rotation_offset, const float p_rotation_step) {
grid_offset_x->set_val(p_grid_offset.x);
grid_offset_y->set_val(p_grid_offset.y);
@@ -143,7 +143,7 @@ public:
rotation_offset->set_val(p_rotation_offset * (180 / Math_PI));
rotation_step->set_val(p_rotation_step * (180 / Math_PI));
}
-
+
void get_fields(Point2 &p_grid_offset, Size2 &p_grid_step, float &p_rotation_offset, float &p_rotation_step) {
p_grid_offset.x = grid_offset_x->get_val();
p_grid_offset.y = grid_offset_y->get_val();
@@ -1328,7 +1328,7 @@ void CanvasItemEditor::_viewport_input_event(const InputEvent& p_event) {
first=false;
}
- BoneIK bik;
+ BoneIK bik;
bik.node=b;
bik.len=len;
bik.orig_state=b->edit_get_state();
@@ -2670,7 +2670,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
}
#endif
} break;
-
+
case SPACE_HORIZONTAL: {
//space_selected_items< proj_vector2_x, compare_items_x >();
} break;
@@ -3164,7 +3164,7 @@ bool CanvasItemEditor::box_selection_end() {
SWAP(bsfrom.x,bsto.x);
if (bsfrom.y>bsto.y)
SWAP(bsfrom.y,bsto.y);
-
+
if ( bsfrom.distance_to( bsto ) < 3 ) {
print_line( "box selection too small" );
box_selecting=false;
@@ -3183,7 +3183,7 @@ bool CanvasItemEditor::box_selection_end() {
box_selecting=false;
viewport->update();
-
+
return true;
}
#endif
diff --git a/tools/editor/plugins/canvas_item_editor_plugin.h b/tools/editor/plugins/canvas_item_editor_plugin.h
index df24734fd7..301c67756c 100644
--- a/tools/editor/plugins/canvas_item_editor_plugin.h
+++ b/tools/editor/plugins/canvas_item_editor_plugin.h
@@ -302,11 +302,11 @@ class CanvasItemEditor : public VBoxContainer {
bool _select(CanvasItem *item, Point2 p_click_pos, bool p_append, bool p_drag=true);
ConfirmationDialog *snap_dialog;
-
+
AcceptDialog *value_dialog;
Label *dialog_label;
SpinBox *dialog_val;
-
+
CanvasItem *ref_item;
void _edit_set_pivot(const Vector2& mouse_pos);
@@ -369,29 +369,29 @@ protected:
bool box_selection_end();
HBoxContainer *get_panel_hb() { return hb; }
-
+
struct compare_items_x {
bool operator()( const CanvasItem *a, const CanvasItem *b ) const {
return a->get_global_transform().elements[2].x < b->get_global_transform().elements[2].x;
}
};
-
+
struct compare_items_y {
bool operator()( const CanvasItem *a, const CanvasItem *b ) const {
return a->get_global_transform().elements[2].y < b->get_global_transform().elements[2].y;
}
};
-
+
struct proj_vector2_x {
float get( const Vector2 &v ) { return v.x; }
void set( Vector2 &v, float f ) { v.x = f; }
};
-
+
struct proj_vector2_y {
float get( const Vector2 &v ) { return v.y; }
void set( Vector2 &v, float f ) { v.y = f; }
};
-
+
template< class P, class C > void space_selected_items();
static CanvasItemEditor *singleton;
diff --git a/tools/editor/plugins/collision_polygon_editor_plugin.cpp b/tools/editor/plugins/collision_polygon_editor_plugin.cpp
index d4198f3166..44854e655f 100644
--- a/tools/editor/plugins/collision_polygon_editor_plugin.cpp
+++ b/tools/editor/plugins/collision_polygon_editor_plugin.cpp
@@ -40,7 +40,7 @@ void CollisionPolygonEditor::_notification(int p_what) {
case NOTIFICATION_READY: {
button_create->set_icon( get_icon("Edit","EditorIcons"));
- button_edit->set_icon( get_icon("MovePoint","EditorIcons"));
+ button_edit->set_icon( get_icon("MovePoint","EditorIcons"));
button_edit->set_pressed(true);
get_tree()->connect("node_removed",this,"_node_removed");
diff --git a/tools/editor/plugins/collision_shape_2d_editor_plugin.cpp b/tools/editor/plugins/collision_shape_2d_editor_plugin.cpp
index 7e5d52d17d..1916d55ee1 100644
--- a/tools/editor/plugins/collision_shape_2d_editor_plugin.cpp
+++ b/tools/editor/plugins/collision_shape_2d_editor_plugin.cpp
@@ -451,11 +451,11 @@ void CollisionShape2DEditor::_canvas_draw() {
case LINE_SHAPE: {
Ref<LineShape2D> shape = node->get_shape();
-
+
handles.resize(2);
handles[0] = shape->get_normal() * shape->get_d();
handles[1] = shape->get_normal() * (shape->get_d() + 30.0);
-
+
c->draw_texture(h,gt.xform(handles[0])-size);
c->draw_texture(h,gt.xform(handles[1])-size);
diff --git a/tools/editor/plugins/color_ramp_editor_plugin.cpp b/tools/editor/plugins/color_ramp_editor_plugin.cpp
index 42ff1b1de9..133775115d 100644
--- a/tools/editor/plugins/color_ramp_editor_plugin.cpp
+++ b/tools/editor/plugins/color_ramp_editor_plugin.cpp
@@ -13,9 +13,9 @@ ColorRampEditorPlugin::ColorRampEditorPlugin(EditorNode *p_node, bool p_2d) {
_2d=p_2d;
if (p_2d)
- add_custom_control(CONTAINER_CANVAS_EDITOR_BOTTOM,ramp_editor);
+ add_control_to_container(CONTAINER_CANVAS_EDITOR_BOTTOM,ramp_editor);
else
- add_custom_control(CONTAINER_SPATIAL_EDITOR_BOTTOM,ramp_editor);
+ add_control_to_container(CONTAINER_SPATIAL_EDITOR_BOTTOM,ramp_editor);
ramp_editor->set_custom_minimum_size(Size2(100, 48));
ramp_editor->hide();
diff --git a/tools/editor/plugins/control_editor_plugin.cpp b/tools/editor/plugins/control_editor_plugin.cpp
index 375622a89c..9dff5e6ce4 100644
--- a/tools/editor/plugins/control_editor_plugin.cpp
+++ b/tools/editor/plugins/control_editor_plugin.cpp
@@ -80,16 +80,16 @@ void ControlEditor::_node_removed(Node *p_node) {
// slow as hell
Control* ControlEditor::_select_control_at_pos(const Point2& p_pos,Node* p_node) {
-
+
for (int i=p_node->get_child_count()-1;i>=0;i--) {
-
+
Control *r=_select_control_at_pos(p_pos,p_node->get_child(i));
if (r)
return r;
}
-
+
Control *c=p_node->cast_to<Control>();
-
+
if (c) {
Rect2 rect = c->get_window_rect();
if (c->get_window()==current_window) {
@@ -123,9 +123,9 @@ void ControlEditor::_key_move(const Vector2& p_dir, bool p_snap) {
void ControlEditor::_input_event(InputEvent p_event) {
-
+
if (p_event.type==InputEvent::MOUSE_BUTTON) {
-
+
const InputEventMouseButton &b=p_event.mouse_button;
if (b.button_index==BUTTON_RIGHT) {
@@ -146,12 +146,12 @@ void ControlEditor::_input_event(InputEvent p_event) {
}
//if (!controls.size())
// return;
-
+
if (b.button_index!=BUTTON_LEFT)
return;
if (!b.pressed) {
-
+
if (drag!=DRAG_NONE) {
if (undo_redo) {
@@ -321,11 +321,11 @@ void ControlEditor::_input_event(InputEvent p_event) {
}
}
-
+
if (p_event.type==InputEvent::MOUSE_MOTION) {
-
+
const InputEventMouseMotion &m=p_event.mouse_motion;
-
+
if (drag==DRAG_NONE || !current_window)
return;
@@ -449,7 +449,7 @@ void ControlEditor::_input_event(InputEvent p_event) {
}
-
+
}
@@ -492,9 +492,9 @@ void ControlEditor::_update_scroll(float) {
}
void ControlEditor::_notification(int p_what) {
-
+
if (p_what==NOTIFICATION_PROCESS) {
-
+
for(ControlMap::Element *E=controls.front();E;E=E->next()) {
Control *control = E->key();
@@ -504,16 +504,16 @@ void ControlEditor::_notification(int p_what) {
E->get().last_rect=r;
}
}
-
+
}
-
+
if (p_what==NOTIFICATION_CHILDREN_CONFIGURED) {
-
+
get_scene()->connect("node_removed",this,"_node_removed");
}
-
+
if (p_what==NOTIFICATION_DRAW) {
-
+
// TODO fetch the viewport?
/*
if (!control) {
@@ -572,11 +572,11 @@ VisualServer::get_singleton()->canvas_item_add_rect(ci,m_rect,m_color);
//DRAW_EMPTY_RECT( Rect2( current_window->get_scroll()-Point2(1,1), get_size()+Size2(2,2)), Color(0.8,0.8,1.0,0.8) );
E->get().last_rect = rect;
}
- }
+ }
}
void ControlEditor::edit(Control *p_control) {
-
+
drag=DRAG_NONE;
_clear_controls();
@@ -727,9 +727,9 @@ void ControlEditor::_popup_callback(int p_op) {
}
void ControlEditor::_bind_methods() {
-
+
ObjectTypeDB::bind_method("_input_event",&ControlEditor::_input_event);
- ObjectTypeDB::bind_method("_node_removed",&ControlEditor::_node_removed);
+ ObjectTypeDB::bind_method("_node_removed",&ControlEditor::_node_removed);
ObjectTypeDB::bind_method("_update_scroll",&ControlEditor::_update_scroll);
ObjectTypeDB::bind_method("_popup_callback",&ControlEditor::_popup_callback);
ObjectTypeDB::bind_method("_visibility_changed",&ControlEditor::_visibility_changed);
@@ -781,13 +781,13 @@ ControlEditor::ControlEditor(EditorNode *p_editor) {
void ControlEditorPlugin::edit(Object *p_object) {
-
+
control_editor->set_undo_redo(&get_undo_redo());
control_editor->edit(p_object->cast_to<Control>());
}
bool ControlEditorPlugin::handles(Object *p_object) const {
-
+
return p_object->is_type("Control");
}
@@ -797,7 +797,7 @@ void ControlEditorPlugin::make_visible(bool p_visible) {
control_editor->show();
control_editor->set_process(true);
} else {
-
+
control_editor->hide();
control_editor->set_process(false);
}
@@ -805,14 +805,14 @@ void ControlEditorPlugin::make_visible(bool p_visible) {
}
ControlEditorPlugin::ControlEditorPlugin(EditorNode *p_node) {
-
+
editor=p_node;
control_editor = memnew( ControlEditor(editor) );
editor->get_viewport()->add_child(control_editor);
control_editor->set_area_as_parent_rect();
control_editor->hide();
-
+
}
diff --git a/tools/editor/plugins/control_editor_plugin.h b/tools/editor/plugins/control_editor_plugin.h
index 94cffc8d8d..6234698ee8 100644
--- a/tools/editor/plugins/control_editor_plugin.h
+++ b/tools/editor/plugins/control_editor_plugin.h
@@ -37,9 +37,9 @@
#if 0
class ControlEditor : public Control {
-
- OBJ_TYPE(ControlEditor, Control );
-
+
+ OBJ_TYPE(ControlEditor, Control );
+
EditorNode *editor;
enum {
@@ -103,13 +103,13 @@ class ControlEditor : public Control {
void _find_controls_span(Node *p_node, Rect2& r_rect);
-protected:
+protected:
void _notification(int p_what);
- void _input_event(InputEvent p_event);
+ void _input_event(InputEvent p_event);
void _node_removed(Node *p_node);
static void _bind_methods();
-public:
-
+public:
+
bool get_remove_list(List<Node*> *p_list);
void set_undo_redo(UndoRedo *p_undo_redo) {undo_redo=p_undo_redo; }
void edit(Control *p_control);
@@ -117,14 +117,14 @@ public:
};
class ControlEditorPlugin : public EditorPlugin {
-
+
OBJ_TYPE( ControlEditorPlugin, EditorPlugin );
-
+
ControlEditor *control_editor;
EditorNode *editor;
-
+
public:
-
+
virtual String get_name() const { return "GUI"; }
bool has_main_screen() const { return true; }
virtual void edit(Object *p_object);
@@ -132,7 +132,7 @@ public:
virtual void make_visible(bool p_visible);
virtual bool get_remove_list(List<Node*> *p_list) { return control_editor->get_remove_list(p_list); }
-
+
ControlEditorPlugin(EditorNode *p_node);
~ControlEditorPlugin();
diff --git a/tools/editor/plugins/cube_grid_theme_editor_plugin.cpp b/tools/editor/plugins/cube_grid_theme_editor_plugin.cpp
index c861a5841a..ab4f14b806 100644
--- a/tools/editor/plugins/cube_grid_theme_editor_plugin.cpp
+++ b/tools/editor/plugins/cube_grid_theme_editor_plugin.cpp
@@ -27,7 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "cube_grid_theme_editor_plugin.h"
-
+
#include "scene/3d/mesh_instance.h"
#include "scene/3d/physics_body.h"
#include "scene/main/viewport.h"
@@ -337,7 +337,7 @@ MeshLibraryEditorPlugin::MeshLibraryEditorPlugin(EditorNode *p_node) {
theme_editor->set_anchor( MARGIN_RIGHT, Control::ANCHOR_END );
theme_editor->set_anchor( MARGIN_BOTTOM, Control::ANCHOR_BEGIN );
theme_editor->set_end( Point2(0,22) );
- theme_editor->hide();
+ theme_editor->hide();
}
diff --git a/tools/editor/plugins/editor_preview_plugins.cpp b/tools/editor/plugins/editor_preview_plugins.cpp
index f3b5272571..12d50cd4b8 100644
--- a/tools/editor/plugins/editor_preview_plugins.cpp
+++ b/tools/editor/plugins/editor_preview_plugins.cpp
@@ -725,7 +725,11 @@ Ref<Texture> EditorSamplePreviewPlugin::generate(const RES& p_from) {
} else {
half=1;
ofs=h/2;
- v = ((j-(h/2))/(float)(h/2)) * 2.0 - 1.0;
+ if( (float)(h/2) != 0 ) {
+ v = ((j-(h/2))/(float)(h/2)) * 2.0 - 1.0;
+ } else {
+ v = ((j-(h/2))/(float)(1/2)) * 2.0 - 1.0;
+ }
}
uint8_t* imgofs = &imgw[(j*w+i)*3];
diff --git a/tools/editor/plugins/item_list_editor_plugin.cpp b/tools/editor/plugins/item_list_editor_plugin.cpp
index 6f0db959ba..08af1a0643 100644
--- a/tools/editor/plugins/item_list_editor_plugin.cpp
+++ b/tools/editor/plugins/item_list_editor_plugin.cpp
@@ -119,7 +119,7 @@ void ItemListOptionButtonPlugin::set_object(Object *p_object) {
bool ItemListOptionButtonPlugin::handles(Object *p_object) const {
- return p_object->is_type("OptionButton");
+ return p_object->is_type("OptionButton");
}
int ItemListOptionButtonPlugin::get_flags() const {
@@ -130,23 +130,23 @@ int ItemListOptionButtonPlugin::get_flags() const {
void ItemListOptionButtonPlugin::add_item() {
ob->add_item( "Item "+itos(ob->get_item_count()));
- _change_notify();
+ _change_notify();
}
int ItemListOptionButtonPlugin::get_item_count() const {
- return ob->get_item_count();
+ return ob->get_item_count();
}
void ItemListOptionButtonPlugin::erase(int p_idx) {
- ob->remove_item(p_idx);
+ ob->remove_item(p_idx);
_change_notify();
}
ItemListOptionButtonPlugin::ItemListOptionButtonPlugin() {
- ob=NULL;
+ ob=NULL;
}
///////////////////////////////////////////////////////////////
@@ -259,7 +259,7 @@ void ItemListEditor::edit(Node *p_item_list) {
item_plugins[i]->set_object(p_item_list);
property_editor->edit(item_plugins[i]);
-
+
if (has_icon(item_list->get_type(), "EditorIcons"))
toolbar_button->set_icon(get_icon(item_list->get_type(), "EditorIcons"));
else
diff --git a/tools/editor/plugins/multimesh_editor_plugin.cpp b/tools/editor/plugins/multimesh_editor_plugin.cpp
index 3f63ef706b..15df9a6262 100644
--- a/tools/editor/plugins/multimesh_editor_plugin.cpp
+++ b/tools/editor/plugins/multimesh_editor_plugin.cpp
@@ -326,7 +326,7 @@ MultiMeshEditor::MultiMeshEditor() {
options = memnew( MenuButton );
SpatialEditor::get_singleton()->add_control_to_menu_panel(options);
-
+
options->set_text("MultiMesh");
options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("MultiMeshInstance","EditorIcons"));
diff --git a/tools/editor/plugins/particles_2d_editor_plugin.cpp b/tools/editor/plugins/particles_2d_editor_plugin.cpp
index 2488c4cdd9..297145f408 100644
--- a/tools/editor/plugins/particles_2d_editor_plugin.cpp
+++ b/tools/editor/plugins/particles_2d_editor_plugin.cpp
@@ -26,10 +26,11 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "particles_2d_editor_plugin.h"
#include "canvas_item_editor_plugin.h"
#include "io/image_loader.h"
-
+#include "scene/gui/separator.h"
void Particles2DEditorPlugin::edit(Object *p_object) {
@@ -49,12 +50,10 @@ void Particles2DEditorPlugin::make_visible(bool p_visible) {
if (p_visible) {
- sep->show();
- menu->show();
+ toolbar->show();
} else {
- menu->hide();
- sep->hide();
+ toolbar->hide();
}
}
@@ -164,35 +163,36 @@ Particles2DEditorPlugin::Particles2DEditorPlugin(EditorNode *p_node) {
particles=NULL;
editor=p_node;
undo_redo=editor->get_undo_redo();
- sep = memnew( VSeparator );
- CanvasItemEditor::get_singleton()->add_control_to_menu_panel(sep);
- sep->hide();
+
+ toolbar = memnew( HBoxContainer );
+ add_control_to_container(CONTAINER_CANVAS_EDITOR_MENU, toolbar);
+ toolbar->hide();
+
+ toolbar->add_child( memnew( VSeparator ) );
menu = memnew( MenuButton );
menu->get_popup()->add_item("Load Emission Mask",MENU_LOAD_EMISSION_MASK);
menu->get_popup()->add_item("Clear Emission Mask",MENU_CLEAR_EMISSION_MASK);
menu->set_text("Particles");
+ toolbar->add_child(menu);
- file = memnew(EditorFileDialog);
- add_child(file);
+ file = memnew( EditorFileDialog );
List<String> ext;
ImageLoader::get_recognized_extensions(&ext);
for(List<String>::Element *E=ext.front();E;E=E->next()) {
file->add_filter("*."+E->get()+"; "+E->get().to_upper());
}
file->set_mode(EditorFileDialog::MODE_OPEN_FILE);
- CanvasItemEditor::get_singleton()->add_control_to_menu_panel(menu);
+ toolbar->add_child(file);
+
epoints = memnew( SpinBox );
epoints->set_min(1);
epoints->set_max(8192);
epoints->set_step(1);
epoints->set_val(512);
file->get_vbox()->add_margin_child("Generated Point Count:",epoints);
- menu->hide();
-
}
-
Particles2DEditorPlugin::~Particles2DEditorPlugin()
{
}
diff --git a/tools/editor/plugins/particles_2d_editor_plugin.h b/tools/editor/plugins/particles_2d_editor_plugin.h
index f70a0e7b76..ce2056b482 100644
--- a/tools/editor/plugins/particles_2d_editor_plugin.h
+++ b/tools/editor/plugins/particles_2d_editor_plugin.h
@@ -33,7 +33,7 @@
#include "tools/editor/editor_node.h"
#include "scene/2d/collision_polygon_2d.h"
-#include "scene/gui/separator.h"
+#include "scene/gui/box_container.h"
#include "scene/gui/file_dialog.h"
#include "scene/2d/particles_2d.h"
@@ -47,14 +47,14 @@ class Particles2DEditorPlugin : public EditorPlugin {
MENU_CLEAR_EMISSION_MASK
};
+ Particles2D *particles;
EditorFileDialog *file;
EditorNode *editor;
+ HBoxContainer *toolbar;
MenuButton *menu;
- VSeparator *sep;
- Particles2D *particles;
SpinBox *epoints;
UndoRedo *undo_redo;
diff --git a/tools/editor/plugins/path_editor_plugin.cpp b/tools/editor/plugins/path_editor_plugin.cpp
index b99e632604..3c4428bdb0 100644
--- a/tools/editor/plugins/path_editor_plugin.cpp
+++ b/tools/editor/plugins/path_editor_plugin.cpp
@@ -267,17 +267,15 @@ PathSpatialGizmo::PathSpatialGizmo(Path* p_path){
}
-bool PathEditorPlugin::create_spatial_gizmo(Spatial* p_spatial) {
+Ref<SpatialEditorGizmo> PathEditorPlugin::create_spatial_gizmo(Spatial* p_spatial) {
- if (p_spatial->cast_to<Path>()) {
+ if (p_spatial->cast_to<Path>()) {
- Ref<PathSpatialGizmo> psg = memnew( PathSpatialGizmo(p_spatial->cast_to<Path>()));
- p_spatial->set_gizmo(psg);
- return true;
+ return memnew( PathSpatialGizmo(p_spatial->cast_to<Path>()));
}
- return false;
+ return Ref<SpatialEditorGizmo>();
}
bool PathEditorPlugin::forward_spatial_input_event(Camera* p_camera,const InputEvent& p_event) {
@@ -538,7 +536,7 @@ PathEditorPlugin::PathEditorPlugin(EditorNode *p_node) {
path_thin_material->set_flag(Material::FLAG_DOUBLE_SIDED,true);
path_thin_material->set_flag(Material::FLAG_UNSHADED,true);
- SpatialEditor::get_singleton()->add_gizmo_plugin(this);
+// SpatialEditor::get_singleton()->add_gizmo_plugin(this);
sep = memnew( VSeparator);
sep->hide();
diff --git a/tools/editor/plugins/path_editor_plugin.h b/tools/editor/plugins/path_editor_plugin.h
index 18bad23bd1..0afd957af7 100644
--- a/tools/editor/plugins/path_editor_plugin.h
+++ b/tools/editor/plugins/path_editor_plugin.h
@@ -32,9 +32,9 @@
#include "tools/editor/spatial_editor_gizmos.h"
#include "scene/3d/path.h"
-class PathSpatialGizmo : public SpatialGizmoTool {
+class PathSpatialGizmo : public EditorSpatialGizmo {
- OBJ_TYPE(PathSpatialGizmo,SpatialGizmoTool);
+ OBJ_TYPE(PathSpatialGizmo,EditorSpatialGizmo);
Path* path;
mutable Vector3 original;
@@ -83,7 +83,7 @@ public:
virtual bool forward_spatial_input_event(Camera* p_camera,const InputEvent& p_event);
// virtual bool forward_input_event(const InputEvent& p_event) { return collision_polygon_editor->forward_input_event(p_event); }
- virtual bool create_spatial_gizmo(Spatial* p_spatial);
+ virtual Ref<SpatialEditorGizmo> create_spatial_gizmo(Spatial* p_spatial);
virtual String get_name() const { return "Path"; }
bool has_main_screen() const { return false; }
virtual void edit(Object *p_node);
diff --git a/tools/editor/plugins/polygon_2d_editor_plugin.cpp b/tools/editor/plugins/polygon_2d_editor_plugin.cpp
index 3e9c58d604..849fe82645 100644
--- a/tools/editor/plugins/polygon_2d_editor_plugin.cpp
+++ b/tools/editor/plugins/polygon_2d_editor_plugin.cpp
@@ -69,7 +69,7 @@ void Polygon2DEditor::_node_removed(Node *p_node) {
if(p_node==node) {
edit(NULL);
hide();
-
+
canvas_item_editor->get_viewport_control()->update();
}
@@ -760,7 +760,7 @@ void Polygon2DEditor::edit(Node *p_collision_polygon) {
node=p_collision_polygon->cast_to<Polygon2D>();
if (!canvas_item_editor->get_viewport_control()->is_connected("draw",this,"_canvas_draw"))
canvas_item_editor->get_viewport_control()->connect("draw",this,"_canvas_draw");
-
+
wip.clear();
wip_active=false;
edited_point=-1;
diff --git a/tools/editor/plugins/resource_preloader_editor_plugin.cpp b/tools/editor/plugins/resource_preloader_editor_plugin.cpp
index 8490f63ff0..442046b069 100644
--- a/tools/editor/plugins/resource_preloader_editor_plugin.cpp
+++ b/tools/editor/plugins/resource_preloader_editor_plugin.cpp
@@ -46,7 +46,7 @@ void ResourcePreloaderEditor::_notification(int p_what) {
}
if (p_what==NOTIFICATION_ENTER_TREE) {
- load->set_icon( get_icon("Folder","EditorIcons") );
+ load->set_icon( get_icon("Folder","EditorIcons") );
_delete->set_icon( get_icon("Del","EditorIcons") );
}
diff --git a/tools/editor/plugins/script_editor_plugin.cpp b/tools/editor/plugins/script_editor_plugin.cpp
index 8d0527cff7..03db293959 100644
--- a/tools/editor/plugins/script_editor_plugin.cpp
+++ b/tools/editor/plugins/script_editor_plugin.cpp
@@ -711,7 +711,7 @@ void ScriptEditor::_close_current_tab() {
int selected = tab_container->get_current_tab();
if (selected<0 || selected>=tab_container->get_child_count())
return;
-
+
Node *tselected = tab_container->get_child(selected);
ScriptTextEditor *current = tab_container->get_child(selected)->cast_to<ScriptTextEditor>();
if (current) {
@@ -971,7 +971,7 @@ void ScriptEditor::_menu_option(int p_option) {
}
}
- help_index->popup_centered_ratio(0.6);
+ help_index->popup();
if (current!="") {
help_index->call_deferred("select_class",current);
@@ -1784,7 +1784,8 @@ void ScriptEditor::_update_script_colors() {
if (h>hist_size) {
continue;
}
- float v = Math::ease((edit_pass-pass)/float(hist_size),0.4);
+ int non_zero_hist_size = ( hist_size == 0 ) ? 1 : hist_size;
+ float v = Math::ease((edit_pass-pass)/float(non_zero_hist_size),0.4);
script_list->set_item_custom_bg_color(i,hot_color.linear_interpolate(cold_color,v));
@@ -1927,7 +1928,12 @@ void ScriptEditor::edit(const Ref<Script>& p_script) {
ScriptTextEditor *ste = memnew( ScriptTextEditor );
ste->set_edited_script(p_script);
ste->get_text_edit()->set_tooltip_request_func(this,"_get_debug_tooltip",ste);
+ ste->get_text_edit()->set_scroll_pass_end_of_file(EditorSettings::get_singleton()->get("text_editor/scroll_past_end_of_file"));
ste->get_text_edit()->set_auto_brace_completion(EditorSettings::get_singleton()->get("text_editor/auto_brace_complete"));
+ ste->get_text_edit()->set_tab_size(EditorSettings::get_singleton()->get("text_editor/tab_size"));
+ ste->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"));
tab_container->add_child(ste);
_go_to_tab(tab_container->get_tab_count()-1);
@@ -2061,6 +2067,8 @@ void ScriptEditor::_editor_settings_changed() {
continue;
ste->get_text_edit()->set_auto_brace_completion(EditorSettings::get_singleton()->get("text_editor/auto_brace_complete"));
+ ste->get_text_edit()->set_scroll_pass_end_of_file(EditorSettings::get_singleton()->get("text_editor/scroll_past_end_of_file"));
+ ste->get_text_edit()->set_tab_size(EditorSettings::get_singleton()->get("text_editor/tab_size"));
}
}
@@ -2699,4 +2707,3 @@ ScriptEditorPlugin::ScriptEditorPlugin(EditorNode *p_node) {
ScriptEditorPlugin::~ScriptEditorPlugin()
{
}
-
diff --git a/tools/editor/plugins/shader_editor_plugin.cpp b/tools/editor/plugins/shader_editor_plugin.cpp
index 18d8f5efc0..2d3100ac0d 100644
--- a/tools/editor/plugins/shader_editor_plugin.cpp
+++ b/tools/editor/plugins/shader_editor_plugin.cpp
@@ -28,7 +28,7 @@
/*************************************************************************/
#include "shader_editor_plugin.h"
#include "tools/editor/editor_settings.h"
-
+
#include "spatial_editor_plugin.h"
#include "io/resource_loader.h"
#include "io/resource_saver.h"
@@ -52,7 +52,7 @@ Ref<Shader> ShaderTextEditor::get_edited_shader() const {
}
void ShaderTextEditor::set_edited_shader(const Ref<Shader>& p_shader,ShaderLanguage::ShaderType p_type) {
- shader=p_shader;
+ shader=p_shader;
type=p_type;
_load_theme_settings();
@@ -578,9 +578,9 @@ ShaderEditorPlugin::ShaderEditorPlugin(EditorNode *p_node, bool p_2d) {
shader_editor = memnew( ShaderEditor );
_2d=p_2d;
if (p_2d)
- add_custom_control(CONTAINER_CANVAS_EDITOR_BOTTOM,shader_editor);
+ add_control_to_container(CONTAINER_CANVAS_EDITOR_BOTTOM,shader_editor);
else
- add_custom_control(CONTAINER_SPATIAL_EDITOR_BOTTOM,shader_editor);
+ add_control_to_container(CONTAINER_SPATIAL_EDITOR_BOTTOM,shader_editor);
// editor->get_viewport()->add_child(shader_editor);
// shader_editor->set_area_as_parent_rect();
diff --git a/tools/editor/plugins/spatial_editor_plugin.cpp b/tools/editor/plugins/spatial_editor_plugin.cpp
index bc57fd7e44..79ff78ca0d 100644
--- a/tools/editor/plugins/spatial_editor_plugin.cpp
+++ b/tools/editor/plugins/spatial_editor_plugin.cpp
@@ -1265,7 +1265,7 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) {
} else if (m.button_mask&1) {
if (nav_scheme == NAVIGATION_MAYA && m.mod.alt) {
- nav_mode = NAVIGATION_ORBIT;
+ nav_mode = NAVIGATION_ORBIT;
} else if (nav_scheme == NAVIGATION_MODO && m.mod.alt && m.mod.shift) {
nav_mode = NAVIGATION_PAN;
} else if (nav_scheme == NAVIGATION_MODO && m.mod.alt && m.mod.control) {
@@ -2084,7 +2084,9 @@ void SpatialEditorViewport::_menu_option(int p_option) {
count++;
}
- center/=float(count);
+ if( count != 0 ) {
+ center/=float(count);
+ }
cursor.pos=center;
} break;
@@ -2196,7 +2198,7 @@ void SpatialEditorViewport::_init_gizmo_instance(int p_idx) {
VS::get_singleton()->instance_set_scenario(move_gizmo_instance[i],get_tree()->get_root()->get_world()->get_scenario());
VS::get_singleton()->instance_geometry_set_flag(move_gizmo_instance[i],VS::INSTANCE_FLAG_VISIBLE,false);
//VS::get_singleton()->instance_geometry_set_flag(move_gizmo_instance[i],VS::INSTANCE_FLAG_DEPH_SCALE,true);
- VS::get_singleton()->instance_geometry_set_flag(move_gizmo_instance[i],VS::INSTANCE_FLAG_CAST_SHADOW,false);
+ VS::get_singleton()->instance_geometry_set_cast_shadows_setting(move_gizmo_instance[i], VS::SHADOW_CASTING_SETTING_OFF);
VS::get_singleton()->instance_set_layer_mask(move_gizmo_instance[i],layer);
rotate_gizmo_instance[i]=VS::get_singleton()->instance_create();
@@ -2204,7 +2206,7 @@ void SpatialEditorViewport::_init_gizmo_instance(int p_idx) {
VS::get_singleton()->instance_set_scenario(rotate_gizmo_instance[i],get_tree()->get_root()->get_world()->get_scenario());
VS::get_singleton()->instance_geometry_set_flag(rotate_gizmo_instance[i],VS::INSTANCE_FLAG_VISIBLE,false);
//VS::get_singleton()->instance_geometry_set_flag(rotate_gizmo_instance[i],VS::INSTANCE_FLAG_DEPH_SCALE,true);
- VS::get_singleton()->instance_geometry_set_flag(rotate_gizmo_instance[i],VS::INSTANCE_FLAG_CAST_SHADOW,false);
+ VS::get_singleton()->instance_geometry_set_cast_shadows_setting(rotate_gizmo_instance[i], VS::SHADOW_CASTING_SETTING_OFF);
VS::get_singleton()->instance_set_layer_mask(rotate_gizmo_instance[i],layer);
}
@@ -2585,7 +2587,7 @@ Object *SpatialEditor::_get_editor_data(Object *p_what) {
si->sp=sp;
si->sbox_instance=VisualServer::get_singleton()->instance_create2(selection_box->get_rid(),sp->get_world()->get_scenario());
- VS::get_singleton()->instance_geometry_set_flag(si->sbox_instance,VS::INSTANCE_FLAG_CAST_SHADOW,false);
+ VS::get_singleton()->instance_geometry_set_cast_shadows_setting(si->sbox_instance, VS::SHADOW_CASTING_SETTING_OFF);
RID inst = sp->call("_get_visual_instance_rid");
@@ -2606,15 +2608,15 @@ void SpatialEditor::_generate_selection_box() {
aabb.grow_by( aabb.get_longest_axis_size()/20.0 );
Ref<SurfaceTool> st = memnew( SurfaceTool );
-
+
st->begin(Mesh::PRIMITIVE_LINES);
for (int i=0;i<12;i++) {
-
+
Vector3 a,b;
- aabb.get_edge(i,a,b);
-
+ aabb.get_edge(i,a,b);
+
/*Vector<Vector3> points;
- Vector<Color> colors;
+ Vector<Color> colors;
points.push_back(a);
points.push_back(b);*/
@@ -2804,7 +2806,7 @@ void SpatialEditor::set_state(const Dictionary& p_state) {
void SpatialEditor::edit(Spatial *p_spatial) {
-
+
if (p_spatial!=selected) {
if (selected) {
@@ -2836,8 +2838,8 @@ void SpatialEditor::edit(Spatial *p_spatial) {
// should become the selection
}
-
-
+
+
}
void SpatialEditor::_xform_dialog_action() {
@@ -3272,8 +3274,8 @@ void SpatialEditor::_init_indicators() {
grid_visible[i]=false;
grid_enable[i]=false;
VisualServer::get_singleton()->instance_geometry_set_flag(grid_instance[i],VS::INSTANCE_FLAG_VISIBLE,false);
- VisualServer::get_singleton()->instance_geometry_set_flag(grid_instance[i],VS::INSTANCE_FLAG_CAST_SHADOW,false);
- VS::get_singleton()->instance_set_layer_mask(grid_instance[i],1<<SpatialEditorViewport::GIZMO_GRID_LAYER);
+ VisualServer::get_singleton()->instance_geometry_set_cast_shadows_setting(grid_instance[i], VS::SHADOW_CASTING_SETTING_OFF);
+ VS::get_singleton()->instance_set_layer_mask(grid_instance[i], 1 << SpatialEditorViewport::GIZMO_GRID_LAYER);
}
@@ -3294,7 +3296,7 @@ void SpatialEditor::_init_indicators() {
origin_instance = VisualServer::get_singleton()->instance_create2(origin,get_tree()->get_root()->get_world()->get_scenario());
VS::get_singleton()->instance_set_layer_mask(origin_instance,1<<SpatialEditorViewport::GIZMO_GRID_LAYER);
- VisualServer::get_singleton()->instance_geometry_set_flag(origin_instance,VS::INSTANCE_FLAG_CAST_SHADOW,false);
+ VisualServer::get_singleton()->instance_geometry_set_cast_shadows_setting(origin_instance, VS::SHADOW_CASTING_SETTING_OFF);
@@ -3331,7 +3333,7 @@ void SpatialEditor::_init_indicators() {
cursor_instance = VisualServer::get_singleton()->instance_create2(cursor_mesh,get_tree()->get_root()->get_world()->get_scenario());
VS::get_singleton()->instance_set_layer_mask(cursor_instance,1<<SpatialEditorViewport::GIZMO_GRID_LAYER);
- VisualServer::get_singleton()->instance_geometry_set_flag(cursor_instance,VS::INSTANCE_FLAG_CAST_SHADOW,false);
+ VisualServer::get_singleton()->instance_geometry_set_cast_shadows_setting(cursor_instance, VS::SHADOW_CASTING_SETTING_OFF);
}
@@ -3655,35 +3657,32 @@ void SpatialEditor::_request_gizmo(Object* p_obj) {
Spatial *sp=p_obj->cast_to<Spatial>();
if (!sp)
return;
- if (editor->get_edited_scene() && (sp==editor->get_edited_scene() || sp->get_owner()==editor->get_edited_scene())) {
+ if (editor->get_edited_scene() && (sp==editor->get_edited_scene() || sp->get_owner()==editor->get_edited_scene() || editor->get_edited_scene()->is_editable_instance(sp->get_owner()))) {
- Ref<SpatialEditorGizmo> seg = gizmos->get_gizmo(sp);
+ Ref<SpatialEditorGizmo> seg;
- if (seg.is_valid()) {
- sp->set_gizmo(seg);
- }
-
- for (List<EditorPlugin*>::Element *E=gizmo_plugins.front();E;E=E->next()) {
+ for(int i=0;i<EditorNode::get_singleton()->get_editor_data().get_editor_plugin_count();i++) {
- if (E->get()->create_spatial_gizmo(sp)) {
+ seg = EditorNode::get_singleton()->get_editor_data().get_editor_plugin(i)->create_spatial_gizmo(sp);
+ if (seg.is_valid())
+ break;
+ }
- seg = sp->get_gizmo();
- if (sp==selected && seg.is_valid()) {
+ if (!seg.is_valid()) {
+ seg = gizmos->get_gizmo(sp);
+ }
- seg->set_selected(true);
- selected->update_gizmo();
- }
- return;
- }
+ if (seg.is_valid()) {
+ sp->set_gizmo(seg);
}
+
if (seg.is_valid() && sp==selected) {
seg->set_selected(true);
selected->update_gizmo();
}
}
-
}
void SpatialEditor::_toggle_maximize_view(Object* p_viewport) {
@@ -4170,7 +4169,7 @@ SpatialEditor::~SpatialEditor() {
void SpatialEditorPlugin::make_visible(bool p_visible) {
if (p_visible) {
-
+
spatial_editor->show();
spatial_editor->set_process(true);
@@ -4178,7 +4177,7 @@ void SpatialEditorPlugin::make_visible(bool p_visible) {
spatial_editor->grab_focus();
} else {
-
+
spatial_editor->hide();
spatial_editor->set_process(false);
//VisualServer::get_singleton()->viewport_set_hide_scenario(editor->get_scene_root()->get_viewport(),true);
@@ -4192,7 +4191,7 @@ void SpatialEditorPlugin::edit(Object *p_object) {
}
bool SpatialEditorPlugin::handles(Object *p_object) const {
-
+
return p_object->is_type("Spatial");
}
@@ -4226,7 +4225,7 @@ void SpatialEditorPlugin::snap_cursor_to_plane(const Plane& p_plane) {
SpatialEditorPlugin::SpatialEditorPlugin(EditorNode *p_node) {
-
+
editor=p_node;
spatial_editor = memnew( SpatialEditor(p_node) );
spatial_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL);
@@ -4241,8 +4240,5 @@ SpatialEditorPlugin::SpatialEditorPlugin(EditorNode *p_node) {
SpatialEditorPlugin::~SpatialEditorPlugin() {
-
-}
-
-
+}
diff --git a/tools/editor/plugins/spatial_editor_plugin.h b/tools/editor/plugins/spatial_editor_plugin.h
index b0e366b140..54086b0031 100644
--- a/tools/editor/plugins/spatial_editor_plugin.h
+++ b/tools/editor/plugins/spatial_editor_plugin.h
@@ -278,7 +278,7 @@ public:
};
class SpatialEditor : public VBoxContainer {
-
+
OBJ_TYPE(SpatialEditor, VBoxContainer );
public:
@@ -338,7 +338,7 @@ private:
Ref<Mesh> selection_box;
RID indicators;
- RID indicators_instance;
+ RID indicators_instance;
RID cursor_mesh;
RID cursor_instance;
RID indicator_mat;
@@ -352,7 +352,7 @@ private:
Spatial *sp;
RID poly_instance;
};
-
+
Map<uint32_t,Selected> selected;
*/
struct Gizmo {
@@ -361,8 +361,8 @@ private:
float scale;
Transform transform;
} gizmo;
-
-
+
+
enum MenuOption {
@@ -457,8 +457,6 @@ private:
Ref<Environment> viewport_environment;
- List<EditorPlugin*> gizmo_plugins;
-
Spatial *selected;
void _request_gizmo(Object* p_obj);
@@ -473,7 +471,7 @@ private:
void _update_default_light_angle();
void _default_light_angle_input(const InputEvent& p_event);
-protected:
+protected:
@@ -483,7 +481,7 @@ protected:
void _unhandled_key_input(InputEvent p_event);
static void _bind_methods();
-public:
+public:
static SpatialEditor *get_singleton() { return singleton; }
@@ -518,8 +516,6 @@ public:
UndoRedo *get_undo_redo() { return undo_redo; }
- void add_gizmo_plugin(EditorPlugin* p_plugin) { gizmo_plugins.push_back(p_plugin); }
-
void add_control_to_menu_panel(Control *p_control);
VSplitContainer *get_shader_split();
@@ -545,9 +541,9 @@ public:
};
class SpatialEditorPlugin : public EditorPlugin {
-
+
OBJ_TYPE( SpatialEditorPlugin, EditorPlugin );
-
+
SpatialEditor *spatial_editor;
EditorNode *editor;
protected:
@@ -559,7 +555,7 @@ public:
SpatialEditor *get_spatial_editor() { return spatial_editor; }
virtual String get_name() const { return "3D"; }
bool has_main_screen() const { return true; }
- virtual void make_visible(bool p_visible);
+ virtual void make_visible(bool p_visible);
virtual void edit(Object *p_object);
virtual bool handles(Object *p_object) const;
diff --git a/tools/editor/progress_dialog.cpp b/tools/editor/progress_dialog.cpp
index d072ce7f83..2814101a27 100644
--- a/tools/editor/progress_dialog.cpp
+++ b/tools/editor/progress_dialog.cpp
@@ -140,6 +140,9 @@ void BackgroundProgress::end_task(const String& p_task){
////////////////////////////////////////////////
+
+ProgressDialog *ProgressDialog::singleton=NULL;
+
void ProgressDialog::_notification(int p_what) {
switch(p_what) {
@@ -237,4 +240,5 @@ ProgressDialog::ProgressDialog() {
main->set_area_as_parent_rect();
set_exclusive(true);
last_progress_tick=0;
+ singleton=this;
}
diff --git a/tools/editor/progress_dialog.h b/tools/editor/progress_dialog.h
index 539eaa8737..c254d45753 100644
--- a/tools/editor/progress_dialog.h
+++ b/tools/editor/progress_dialog.h
@@ -86,12 +86,14 @@ class ProgressDialog : public Popup {
VBoxContainer *main;
uint64_t last_progress_tick;
+ static ProgressDialog *singleton;
void _popup();
protected:
void _notification(int p_what);
public:
+ static ProgressDialog *get_singleton() { return singleton; }
void add_task(const String& p_task,const String& p_label, int p_steps);
void task_step(const String& p_task, const String& p_state, int p_step=-1, bool p_force_redraw=true);
void end_task(const String& p_task);
diff --git a/tools/editor/project_settings.cpp b/tools/editor/project_settings.cpp
index fd76ea3087..34bc31d20c 100644
--- a/tools/editor/project_settings.cpp
+++ b/tools/editor/project_settings.cpp
@@ -60,6 +60,8 @@ void ProjectSettings::_notification(int p_what) {
if (p_what==NOTIFICATION_ENTER_TREE) {
+ globals_editor->edit(Globals::get_singleton());
+
search_button->set_icon(get_icon("Zoom","EditorIcons"));
clear_button->set_icon(get_icon("Close","EditorIcons"));
@@ -566,10 +568,10 @@ void ProjectSettings::popup_project_settings() {
//popup_centered(Size2(500,400));
popup_centered_ratio();
- globals_editor->edit(NULL);
- globals_editor->edit(Globals::get_singleton());
+ globals_editor->update_category_list();
_update_translations();
_update_autoload();
+ plugin_settings->update_plugins();
}
@@ -604,37 +606,45 @@ void ProjectSettings::_item_add() {
case 3: value=""; break;
}
- String catname = category->get_text();
+ String catname = category->get_text().strip_edges();
/*if (!catname.is_valid_identifier()) {
message->set_text("Invalid Category.\nValid characters: a-z,A-Z,0-9 or _");
message->popup_centered(Size2(300,100));
return;
}*/
- String propname = property->get_text();
+ String propname = property->get_text().strip_edges();
/*if (!propname.is_valid_identifier()) {
message->set_text("Invalid Property.\nValid characters: a-z,A-Z,0-9 or _");
message->popup_centered(Size2(300,100));
return;
}*/
- String name = catname+"/"+propname;
+ String name = catname!="" ? catname+"/"+propname : propname;
+
Globals::get_singleton()->set(name,value);
- globals_editor->edit(NULL);
- globals_editor->edit(Globals::get_singleton());
+
+ globals_editor->set_current_section(catname);
+ globals_editor->update_category_list();
+
+ _settings_changed();
}
void ProjectSettings::_item_del() {
- String catname = category->get_text();
+ String catname = category->get_text().strip_edges();
//ERR_FAIL_COND(!catname.is_valid_identifier());
- String propname = property->get_text();
+ String propname = property->get_text().strip_edges();
//ERR_FAIL_COND(!propname.is_valid_identifier());
- String name = catname+"/"+propname;
+ String name = catname!="" ? catname+"/"+propname : propname;
+
Globals::get_singleton()->set(name,Variant());
- globals_editor->get_property_editor()->update_tree();
+ globals_editor->set_current_section(catname);
+ globals_editor->update_category_list();
+
+ _settings_changed();
}
void ProjectSettings::_action_adds(String) {
@@ -739,6 +749,10 @@ void ProjectSettings::_settings_changed() {
timer->start();
}
+void ProjectSettings::queue_save() {
+ _settings_changed();
+}
+
void ProjectSettings::_copy_to_platform(int p_which) {
@@ -952,7 +966,7 @@ void ProjectSettings::_autoload_delete(Object *p_item,int p_column, int p_button
undo_redo->commit_action();
} else {
- TreeItem *swap;
+ TreeItem *swap = NULL;
if (p_button==1) {
swap=ti->get_prev();
@@ -998,7 +1012,7 @@ void ProjectSettings::_translation_delete(Object *p_item,int p_column, int p_but
undo_redo->create_action("Remove Translation");
undo_redo->add_do_property(Globals::get_singleton(),"locale/translations",translations);
- undo_redo->add_undo_property(Globals::get_singleton(),"locale/translations",Globals::get_singleton()->get("locale/translations"));
+ undo_redo->add_undo_property(Globals::get_singleton(),"locale/translations",Globals::get_singleton()->get("locale/translations"));
undo_redo->add_do_method(this,"_update_translations");
undo_redo->add_undo_method(this,"_update_translations");
undo_redo->add_do_method(this,"_settings_changed");
@@ -1112,7 +1126,7 @@ void ProjectSettings::_translation_res_option_changed() {
ERR_FAIL_COND(!remaps.has(key));
- StringArray r = remaps[key];
+ StringArray r = remaps[key];
ERR_FAIL_INDEX(idx,r.size());
r.set(idx,path+":"+langs[which]);
remaps[key]=r;
@@ -1382,6 +1396,11 @@ void ProjectSettings::_clear_search_box() {
globals_editor->get_property_editor()->update_tree();
}
+void ProjectSettings::set_plugins_page() {
+
+ tab_container->set_current_tab( plugin_settings->get_index() );
+}
+
void ProjectSettings::_bind_methods() {
ObjectTypeDB::bind_method(_MD("_item_selected"),&ProjectSettings::_item_selected);
@@ -1438,7 +1457,7 @@ ProjectSettings::ProjectSettings(EditorData *p_data) {
data=p_data;
- TabContainer *tab_container = memnew( TabContainer );
+ tab_container = memnew( TabContainer );
add_child(tab_container);
set_child_rect(tab_container);
@@ -1830,6 +1849,13 @@ ProjectSettings::ProjectSettings(EditorData *p_data) {
}
+ {
+
+ plugin_settings = memnew( EditorPluginSettings );
+ plugin_settings->set_name("Plugins");
+ tab_container->add_child(plugin_settings);
+ }
+
timer = memnew( Timer );
timer->set_wait_time(1.5);
timer->connect("timeout",Globals::get_singleton(),"save");
diff --git a/tools/editor/project_settings.h b/tools/editor/project_settings.h
index fd56fc1478..113cc49b7c 100644
--- a/tools/editor/project_settings.h
+++ b/tools/editor/project_settings.h
@@ -34,11 +34,17 @@
#include "optimized_save_dialog.h"
#include "undo_redo.h"
#include "editor_data.h"
+#include "scene/gui/tab_container.h"
+#include "editor_plugin_settings.h"
+
//#include "project_export_settings.h"
class ProjectSettings : public AcceptDialog {
OBJ_TYPE( ProjectSettings, AcceptDialog );
+
+ TabContainer *tab_container;
+
Timer *timer;
InputEvent::Type add_type;
String add_at;
@@ -89,6 +95,9 @@ class ProjectSettings : public AcceptDialog {
LineEdit *autoload_add_name;
LineEdit *autoload_add_path;
+
+ EditorPluginSettings *plugin_settings;
+
void _update_autoload();
void _autoload_file_callback(const String& p_path);
void _autoload_add();
@@ -142,6 +151,8 @@ class ProjectSettings : public AcceptDialog {
void _toggle_search_bar(bool p_pressed);
void _clear_search_box();
+
+
ProjectSettings();
@@ -156,6 +167,9 @@ public:
void add_translation(const String& p_translation);
static ProjectSettings *get_singleton() { return singleton; }
void popup_project_settings();
+ void set_plugins_page();
+
+ void queue_save();
ProjectSettings(EditorData *p_data);
diff --git a/tools/editor/property_editor.cpp b/tools/editor/property_editor.cpp
index 303604c2fc..1340670db1 100644
--- a/tools/editor/property_editor.cpp
+++ b/tools/editor/property_editor.cpp
@@ -2162,7 +2162,7 @@ void PropertyEditor::_check_reload_status(const String&p_name, TreeItem* item) {
//}
- }
+ }
}
@@ -3840,14 +3840,34 @@ void SectionedPropertyEditor::_section_selected(int p_which) {
filter->set_section( sections->get_item_metadata(p_which) );
}
+void SectionedPropertyEditor::set_current_section(const String& p_section) {
+
+ int section_idx = sections->find_metadata(p_section);
+
+ if (section_idx==sections->get_current())
+ return;
+
+ if (section_idx!=-1) {
+ sections->select(section_idx);
+ _section_selected(section_idx);
+ } else if (sections->get_item_count()) {
+ sections->select(0);
+ _section_selected(0);
+ }
+}
+
String SectionedPropertyEditor::get_current_section() const {
- return sections->get_item_metadata( sections->get_current() );
+ if (sections->get_current()!=-1)
+ return sections->get_item_metadata( sections->get_current() );
+ else
+ return "";
}
String SectionedPropertyEditor::get_full_item_path(const String& p_item) {
- String base = sections->get_item_metadata( sections->get_current() );
+ String base = get_current_section();
+
if (base!="")
return base+"/"+p_item;
else
@@ -3856,17 +3876,44 @@ String SectionedPropertyEditor::get_full_item_path(const String& p_item) {
void SectionedPropertyEditor::edit(Object* p_object) {
- List<PropertyInfo> pinfo;
- if (p_object)
- p_object->get_property_list(&pinfo);
+ if (p_object) {
+ obj=p_object->get_instance_ID();
+ update_category_list();
+ } else {
+ sections->clear();
+ }
+
+ filter->set_edited(p_object);
+ editor->edit(filter);
+
+ sections->select(0);
+ _section_selected(0);
+
+}
+
+void SectionedPropertyEditor::update_category_list() {
+
+ String selected_category=get_current_section();
sections->clear();
+ Object *o = ObjectDB::get_instance(obj);
+
+ if (!o)
+ return;
+
+ List<PropertyInfo> pinfo;
+ o->get_property_list(&pinfo);
+
Set<String> existing_sections;
for (List<PropertyInfo>::Element *E=pinfo.front();E;E=E->next()) {
PropertyInfo pi=E->get();
+
if (pi.usage&PROPERTY_USAGE_CATEGORY)
continue;
+ else if ( !(pi.usage&PROPERTY_USAGE_EDITOR) )
+ continue;
+
if (pi.name.find(":")!=-1 || pi.name=="script/script")
continue;
int sp = pi.name.find("/");
@@ -3885,19 +3932,9 @@ void SectionedPropertyEditor::edit(Object* p_object) {
sections->set_item_metadata(sections->get_item_count()-1,"");
}
}
-
-
}
- //sections->sort_items_by_text();
-
-
- filter->set_edited(p_object);
- editor->edit(filter);
-
- sections->select(0);
- _section_selected(0);
-
+ set_current_section(selected_category);
}
PropertyEditor *SectionedPropertyEditor::get_property_editor() {
diff --git a/tools/editor/property_editor.h b/tools/editor/property_editor.h
index 63ad090901..b870a618e9 100644
--- a/tools/editor/property_editor.h
+++ b/tools/editor/property_editor.h
@@ -174,7 +174,7 @@ class PropertyEditor : public Control {
Map<StringName,Map<StringName,String> > descr_cache;
Map<StringName,String > class_descr_cache;
-
+
CustomPropertyEditor *custom_editor;
void _resource_edit_request();
@@ -245,7 +245,7 @@ public:
void set_subsection_selectable(bool p_selectable);
- PropertyEditor();
+ PropertyEditor();
~PropertyEditor();
};
@@ -257,6 +257,9 @@ class SectionedPropertyEditor : public HBoxContainer {
OBJ_TYPE(SectionedPropertyEditor,HBoxContainer);
+
+ ObjectID obj;
+
ItemList *sections;
SectionedPropertyEditorFilter *filter;
PropertyEditor *editor;
@@ -270,8 +273,12 @@ public:
PropertyEditor *get_property_editor();
void edit(Object* p_object);
String get_full_item_path(const String& p_item);
+
+ void set_current_section(const String& p_section);
String get_current_section() const;
+ void update_category_list();
+
SectionedPropertyEditor();
~SectionedPropertyEditor();
};
diff --git a/tools/editor/reparent_dialog.cpp b/tools/editor/reparent_dialog.cpp
index 97b27603b2..2a886b85fa 100644
--- a/tools/editor/reparent_dialog.cpp
+++ b/tools/editor/reparent_dialog.cpp
@@ -47,19 +47,19 @@ void ReparentDialog::_notification(int p_what) {
}
if (p_what==NOTIFICATION_DRAW) {
-
+
//RID ci = get_canvas_item();
//get_stylebox("panel","PopupMenu")->draw(ci,Rect2(Point2(),get_size()));
- }
+ }
}
void ReparentDialog::_cancel() {
-
+
hide();
-
+
}
void ReparentDialog::_reparent() {
-
+
if (tree->get_selected()) {
emit_signal("reparent",tree->get_selected()->get_path(),keep_transform->is_pressed());
@@ -68,14 +68,14 @@ void ReparentDialog::_reparent() {
}
void ReparentDialog::set_current(const Set<Node*>& p_selection) {
-
+
tree->set_marked(p_selection,false,false);
//tree->set_selected(p_node->get_parent());
}
void ReparentDialog::_bind_methods() {
-
- ObjectTypeDB::bind_method("_reparent",&ReparentDialog::_reparent);
+
+ ObjectTypeDB::bind_method("_reparent",&ReparentDialog::_reparent);
ObjectTypeDB::bind_method("_cancel",&ReparentDialog::_cancel);
ADD_SIGNAL( MethodInfo("reparent",PropertyInfo(Variant::NODE_PATH,"path"),PropertyInfo(Variant::BOOL,"keep_global_xform")));
diff --git a/tools/editor/reparent_dialog.h b/tools/editor/reparent_dialog.h
index 296102e4b9..1c0fbd2459 100644
--- a/tools/editor/reparent_dialog.h
+++ b/tools/editor/reparent_dialog.h
@@ -39,30 +39,30 @@
@author Juan Linietsky <reduzio@gmail.com>
*/
class ReparentDialog : public ConfirmationDialog {
-
+
OBJ_TYPE( ReparentDialog, ConfirmationDialog );
-
+
SceneTreeEditor *tree;
CheckBox *keep_transform;
-
+
void update_tree();
void _reparent();
void _cancel();
protected:
-
+
void _notification(int p_what);
static void _bind_methods();
public:
-
+
void set_current(const Set<Node*>& p_selection);
String get_selected_type();
-
- ReparentDialog();
+
+ ReparentDialog();
~ReparentDialog();
-
+
};
#endif
diff --git a/tools/editor/run_settings_dialog.cpp b/tools/editor/run_settings_dialog.cpp
index e8c509d79d..9dc4d703fc 100644
--- a/tools/editor/run_settings_dialog.cpp
+++ b/tools/editor/run_settings_dialog.cpp
@@ -84,7 +84,7 @@ RunSettingsDialog::RunSettingsDialog() {
run_mode->add_item("Main Scene");
run_mode->connect("item_selected",this,"_run_mode_changed");
arguments = memnew( LineEdit );
- vbc->add_margin_child("Main Scene Arguments:",arguments);
+ vbc->add_margin_child("Main Scene Arguments:",arguments);
arguments->set_editable(false);
get_ok()->set_text("Close");
diff --git a/tools/editor/scene_tree_editor.cpp b/tools/editor/scene_tree_editor.cpp
index 45eecacb6b..c16152ae44 100644
--- a/tools/editor/scene_tree_editor.cpp
+++ b/tools/editor/scene_tree_editor.cpp
@@ -211,7 +211,7 @@ void SceneTreeEditor::_cell_button_pressed(Object *p_item,int p_column,int p_id)
}
void SceneTreeEditor::_add_nodes(Node *p_node,TreeItem *p_parent) {
-
+
if (!p_node)
return;
@@ -252,7 +252,7 @@ void SceneTreeEditor::_add_nodes(Node *p_node,TreeItem *p_parent) {
else
icon=get_icon( (has_icon(p_node->get_type(),"EditorIcons")?p_node->get_type():String("Object")),"EditorIcons");
item->set_icon(0, icon );
- item->set_metadata( 0,p_node->get_path() );
+ item->set_metadata( 0,p_node->get_path() );
if (part_of_subscene) {
@@ -260,7 +260,7 @@ void SceneTreeEditor::_add_nodes(Node *p_node,TreeItem *p_parent) {
item->set_custom_color(0,Color(0.8,0.4,0.20));
} else if (marked.has(p_node)) {
-
+
item->set_selectable(0,marked_selectable);
item->set_custom_color(0,Color(0.8,0.1,0.10));
} else if (!marked_selectable && !marked_children_selectable) {
@@ -344,9 +344,9 @@ void SceneTreeEditor::_add_nodes(Node *p_node,TreeItem *p_parent) {
item->select(0);
item->set_as_cursor(0);
}
-
+
for (int i=0;i<p_node->get_child_count();i++) {
-
+
_add_nodes(p_node->get_child(i),item);
}
}
@@ -406,7 +406,7 @@ void SceneTreeEditor::_node_script_changed(Node *p_node) {
}
void SceneTreeEditor::_node_removed(Node *p_node) {
-
+
if (p_node->is_connected("script_changed",this,"_node_script_changed"))
p_node->disconnect("script_changed",this,"_node_script_changed");
@@ -419,8 +419,8 @@ void SceneTreeEditor::_node_removed(Node *p_node) {
selected=NULL;
emit_signal("node_selected");
}
-
-
+
+
}
void SceneTreeEditor::_update_tree() {
@@ -492,11 +492,11 @@ void SceneTreeEditor::_tree_changed() {
void SceneTreeEditor::_selected_changed() {
-
+
TreeItem *s = tree->get_selected();
ERR_FAIL_COND(!s);
NodePath np = s->get_metadata(0);
-
+
Node *n=get_node(np);
@@ -509,8 +509,8 @@ void SceneTreeEditor::_selected_changed() {
blocked++;
emit_signal("node_selected");
blocked--;
-
-
+
+
}
@@ -540,7 +540,7 @@ void SceneTreeEditor::_cell_multi_selected(Object *p_object,int p_cell,bool p_se
}
void SceneTreeEditor::_notification(int p_what) {
-
+
if (p_what==NOTIFICATION_ENTER_TREE) {
get_tree()->connect("tree_changed",this,"_tree_changed");
@@ -570,20 +570,20 @@ TreeItem* SceneTreeEditor::_find(TreeItem *p_node,const NodePath& p_path) {
if (!p_node)
return NULL;
-
+
NodePath np=p_node->get_metadata(0);
if (np==p_path)
return p_node;
-
+
TreeItem *children=p_node->get_children();
while(children) {
-
+
TreeItem *n=_find(children,p_path);
if (n)
return n;
children=children->get_next();
}
-
+
return NULL;
}
@@ -598,24 +598,24 @@ void SceneTreeEditor::set_selected(Node *p_node,bool p_emit_selected) {
if (selected==p_node)
return;
-
-
+
+
TreeItem* item=p_node?_find(tree->get_root(),p_node->get_path()):NULL;
if (item) {
item->select(0);
item->set_as_cursor(0);
- selected=p_node;
+ selected=p_node;
tree->ensure_cursor_is_visible();
} else {
if (!p_node)
selected=NULL;
_update_tree();
- selected=p_node;
+ selected=p_node;
if (p_emit_selected)
emit_signal("node_selected");
}
-
+
}
void SceneTreeEditor::_rename_node(ObjectID p_node,const String& p_name) {
@@ -787,10 +787,10 @@ void SceneTreeEditor::_cell_collapsed(Object *p_obj) {
void SceneTreeEditor::_bind_methods() {
-
+
ObjectTypeDB::bind_method("_tree_changed",&SceneTreeEditor::_tree_changed);
ObjectTypeDB::bind_method("_update_tree",&SceneTreeEditor::_update_tree);
- ObjectTypeDB::bind_method("_node_removed",&SceneTreeEditor::_node_removed);
+ ObjectTypeDB::bind_method("_node_removed",&SceneTreeEditor::_node_removed);
ObjectTypeDB::bind_method("_selected_changed",&SceneTreeEditor::_selected_changed);
ObjectTypeDB::bind_method("_renamed",&SceneTreeEditor::_renamed);
ObjectTypeDB::bind_method("_rename_node",&SceneTreeEditor::_rename_node);
@@ -817,7 +817,7 @@ void SceneTreeEditor::_bind_methods() {
SceneTreeEditor::SceneTreeEditor(bool p_label,bool p_can_rename, bool p_can_open_instance) {
-
+
undo_redo=NULL;
tree_dirty=true;
@@ -829,23 +829,23 @@ SceneTreeEditor::SceneTreeEditor(bool p_label,bool p_can_rename, bool p_can_open
can_open_instance=p_can_open_instance;
display_foreign=false;
editor_selection=NULL;
-
+
if (p_label) {
Label *label = memnew( Label );
label->set_pos( Point2(10, 0));
label->set_text("Scene Tree (Nodes):");
-
+
add_child(label);
}
-
+
tree = memnew( Tree );
tree->set_anchor( MARGIN_RIGHT, ANCHOR_END );
- tree->set_anchor( MARGIN_BOTTOM, ANCHOR_END );
+ tree->set_anchor( MARGIN_BOTTOM, ANCHOR_END );
tree->set_begin( Point2(0,p_label?18:0 ));
tree->set_end( Point2(0,0 ));
-
+
add_child( tree );
-
+
tree->connect("cell_selected", this,"_selected_changed");
tree->connect("item_edited", this,"_renamed",varray(),CONNECT_DEFERRED);
tree->connect("multi_selected",this,"_cell_multi_selected");
@@ -889,7 +889,7 @@ SceneTreeEditor::SceneTreeEditor(bool p_label,bool p_can_rename, bool p_can_open
SceneTreeEditor::~SceneTreeEditor() {
-
+
}
diff --git a/tools/editor/scene_tree_editor.h b/tools/editor/scene_tree_editor.h
index 334debc148..27ccaaae01 100644
--- a/tools/editor/scene_tree_editor.h
+++ b/tools/editor/scene_tree_editor.h
@@ -38,7 +38,7 @@
@author Juan Linietsky <reduzio@gmail.com>
*/
class SceneTreeEditor : public Control {
-
+
OBJ_TYPE( SceneTreeEditor, Control );
EditorSelection *editor_selection;
@@ -70,7 +70,7 @@ class SceneTreeEditor : public Control {
ConfirmationDialog *clear_inherit_confirm;
int blocked;
-
+
void _compute_hash(Node *p_node,uint64_t &hash);
void _add_nodes(Node *p_node,TreeItem *p_parent);
@@ -78,7 +78,7 @@ class SceneTreeEditor : public Control {
void _update_tree();
void _tree_changed();
void _node_removed(Node *p_node);
-
+
TreeItem* _find(TreeItem *p_node,const NodePath& p_path);
void _notification(int p_what);
void _selected_changed();
@@ -92,17 +92,17 @@ class SceneTreeEditor : public Control {
bool can_open_instance;
bool updating_tree;
bool show_enabled_subscene;
-
+
void _renamed();
UndoRedo *undo_redo;
-
+
Set<Node*> marked;
bool marked_selectable;
bool marked_children_selectable;
bool display_foreign;
bool tree_dirty;
bool pending_test_update;
- static void _bind_methods();
+ static void _bind_methods();
void _cell_button_pressed(Object *p_item,int p_column,int p_id);
void _cell_multi_selected(Object *p_object,int p_cel,bool p_selected);
@@ -119,7 +119,7 @@ public:
void set_undo_redo(UndoRedo *p_undo_redo) { undo_redo=p_undo_redo; };
void set_display_foreign_nodes(bool p_display);
bool get_display_foreign_nodes() const;
-
+
void set_marked(const Set<Node*>& p_marked,bool p_selectable=false,bool p_children_selectable=true);
void set_marked(Node *p_marked,bool p_selectable=false,bool p_children_selectable=true);
void set_selected(Node *p_node,bool p_emit_selected=true);
@@ -150,7 +150,7 @@ class SceneTreeDialog : public ConfirmationDialog {
void update_tree();
void _select();
- void _cancel();
+ void _cancel();
protected:
diff --git a/tools/editor/scenes_dock.cpp b/tools/editor/scenes_dock.cpp
index 5abc4992df..e2b17f5e64 100644
--- a/tools/editor/scenes_dock.cpp
+++ b/tools/editor/scenes_dock.cpp
@@ -1122,7 +1122,7 @@ ScenesDock::ScenesDock(EditorNode *p_editor) {
button_reload = memnew( Button );
button_reload->set_flat(true);
- button_reload->connect("pressed",this,"_rescan");
+ button_reload->connect("pressed",this,"_rescan");
toolbar_hbc->add_child(button_reload);
button_reload->set_focus_mode(FOCUS_NONE);
button_reload->set_tooltip("Re-Scan Filesystem");
@@ -1238,10 +1238,10 @@ ScenesDock::ScenesDock(EditorNode *p_editor) {
add_child(remove_dialog);
move_dialog = memnew( EditorDirDialog );
- add_child(move_dialog);
+ add_child(move_dialog);
move_dialog->connect("dir_selected",this,"_move_operation");
move_dialog->get_ok()->set_text("Move");
-
+
rename_dialog = memnew( EditorFileDialog );
rename_dialog->set_mode(EditorFileDialog::MODE_SAVE_FILE);
rename_dialog->connect("file_selected",this,"_rename_operation");
diff --git a/tools/editor/scenes_dock.h b/tools/editor/scenes_dock.h
index a1978a3ca4..a630d2506d 100644
--- a/tools/editor/scenes_dock.h
+++ b/tools/editor/scenes_dock.h
@@ -138,7 +138,7 @@ class ScenesDock : public VBoxContainer {
void _rescan();
void _set_scannig_mode();
- void _favorites_pressed();
+ void _favorites_pressed();
void _instance_pressed();
void _open_pressed();
diff --git a/tools/editor/script_create_dialog.cpp b/tools/editor/script_create_dialog.cpp
index 409e8be870..34d9204061 100644
--- a/tools/editor/script_create_dialog.cpp
+++ b/tools/editor/script_create_dialog.cpp
@@ -138,7 +138,7 @@ void ScriptCreateDialog::ok_pressed() {
return;
}
- Error err = ResourceSaver::save(lpath,scr,ResourceSaver::FLAG_CHANGE_PATH);
+ Error err = ResourceSaver::save(lpath,scr,ResourceSaver::FLAG_CHANGE_PATH);
if (err!=OK) {
alert->set_text("Could not create script in filesystem: "+String(""));
@@ -195,7 +195,7 @@ void ScriptCreateDialog::_browse_path() {
file_browse->add_filter("*."+E->get());
}
- file_browse->set_current_path(file_path->get_text());
+ file_browse->set_current_path(file_path->get_text());
file_browse->popup_centered_ratio();
}
diff --git a/tools/editor/settings_config_dialog.cpp b/tools/editor/settings_config_dialog.cpp
index 86a3ab7001..6b7c2eb9b7 100644
--- a/tools/editor/settings_config_dialog.cpp
+++ b/tools/editor/settings_config_dialog.cpp
@@ -80,173 +80,6 @@ void EditorSettingsDialog::popup_edit_settings() {
}
-void EditorSettingsDialog::_plugin_install() {
-
- EditorSettings::Plugin plugin = EditorSettings::get_singleton()->get_plugins()[plugin_setting_edit];
-
- DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
- da->change_dir("res://");
- if (da->change_dir("plugins")!=OK) {
-
- Error err = da->make_dir("plugins");
- if (err)
- memdelete(da);
- ERR_FAIL_COND(err!=OK);
- err = da->change_dir("plugins");
- if (err)
- memdelete(da);
- ERR_FAIL_COND(err!=OK);
- }
-
- if (da->change_dir(plugin_setting_edit)!=OK) {
-
- Error err = da->make_dir(plugin_setting_edit);
- if (err)
- memdelete(da);
- ERR_FAIL_COND(err!=OK);
- err = da->change_dir(plugin_setting_edit);
- if (err)
- memdelete(da);
- ERR_FAIL_COND(err!=OK);
- }
-
- Vector<String> ifiles=plugin.install_files;
-
- if (ifiles.find("plugin.cfg")==-1) {
- ifiles.push_back("plugin.cfg");
- }
-
- if (ifiles.find(plugin.script)==-1) {
- ifiles.push_back(plugin.script);
- }
-
- for(int i=0;i<ifiles.size();i++) {
-
- String target = "res://plugins/"+plugin_setting_edit+"/"+ifiles[i];
- Error err = da->copy(EditorSettings::get_singleton()->get_settings_path().plus_file("plugins/"+plugin_setting_edit+"/"+ifiles[i]),target);
- if (err)
- memdelete(da);
- ERR_EXPLAIN("Error copying to file "+target);
- ERR_FAIL_COND(err!=OK);
- EditorFileSystem::get_singleton()->update_file(target);
- }
-
- memdelete(da);
-
- Globals::get_singleton()->set("plugins/"+plugin_setting_edit,"res://plugins/"+plugin_setting_edit);
- Globals::get_singleton()->set_persisting("plugins/"+plugin_setting_edit,true);
- EditorSettings::get_singleton()->load_installed_plugin(plugin_setting_edit);
- Globals::get_singleton()->save();
-
-
- _update_plugins();
-}
-
-void EditorSettingsDialog::_rescan_plugins() {
-
- EditorSettings::get_singleton()->scan_plugins();
- _update_plugins();
-}
-
-void EditorSettingsDialog::_plugin_edited() {
-
- if (updating)
- return;
-
- TreeItem *ti=plugins->get_edited();
- if (!ti)
- return;
-
- String plugin = ti->get_metadata(0);
- bool enabled = ti->is_checked(0);
-
- EditorSettings::get_singleton()->set_plugin_enabled(plugin,enabled);
-}
-
-void EditorSettingsDialog::_plugin_settings(Object *p_obj,int p_cell,int p_index) {
-
- TreeItem *ti=p_obj->cast_to<TreeItem>();
-
- EditorSettings::Plugin plugin = EditorSettings::get_singleton()->get_plugins()[ti->get_metadata(0)];
-
- plugin_description->clear();
- plugin_description->parse_bbcode(plugin.description);
- plugin_setting_edit = ti->get_metadata(0);
- if (plugin.installs) {
- if (Globals::get_singleton()->has("plugins/"+plugin_setting_edit))
- plugin_setting->get_ok()->set_text("Re-Install to Project");
- else
- plugin_setting->get_ok()->set_text("Install to Project");
- plugin_setting->get_ok()->show();
- plugin_setting->get_cancel()->set_text("Close");
- } else {
- plugin_setting->get_ok()->hide();
- plugin_setting->get_cancel()->set_text("Close");
- }
-
- plugin_setting->set_title(plugin.name);
- plugin_setting->popup_centered(Size2(300,200));
-}
-
-void EditorSettingsDialog::_update_plugins() {
-
-
- updating=true;
-
- plugins->clear();
- TreeItem *root = plugins->create_item(NULL);
- plugins->set_hide_root(true);
-
- Color sc = get_color("prop_subsection","Editor");
- TreeItem *editor = plugins->create_item(root);
- editor->set_text(0,"Editor Plugins");
- editor->set_custom_bg_color(0,sc);
- editor->set_custom_bg_color(1,sc);
- editor->set_custom_bg_color(2,sc);
-
- TreeItem *install = plugins->create_item(root);
- install->set_text(0,"Installable Plugins");
- install->set_custom_bg_color(0,sc);
- install->set_custom_bg_color(1,sc);
- install->set_custom_bg_color(2,sc);
-
- for (const Map<String,EditorSettings::Plugin>::Element *E=EditorSettings::get_singleton()->get_plugins().front();E;E=E->next()) {
-
-
- TreeItem *ti = plugins->create_item(E->get().installs?install:editor);
- if (!E->get().installs) {
- ti->set_cell_mode(0,TreeItem::CELL_MODE_CHECK);
- ti->set_editable(0,true);
- if (EditorSettings::get_singleton()->is_plugin_enabled(E->key()))
- ti->set_checked(0,true);
-
- ti->set_text(0,E->get().name);
- } else {
-
- if (Globals::get_singleton()->has("plugins/"+E->key())) {
-
- ti->set_text(0,E->get().name+" (Installed)");
- } else {
- ti->set_text(0,E->get().name);
- }
- }
-
-
- ti->add_button(0,get_icon("Tools","EditorIcons"),0);
- ti->set_text(1,E->get().author);
- ti->set_text(2,E->get().version);
- ti->set_metadata(0,E->key());
-
- }
-
- if (!editor->get_children())
- memdelete(editor);
- if (!install->get_children())
- memdelete(install);
-
- updating=false;
-
-}
void EditorSettingsDialog::_clear_search_box() {
@@ -261,9 +94,7 @@ void EditorSettingsDialog::_notification(int p_what) {
if (p_what==NOTIFICATION_ENTER_TREE) {
- rescan_plugins->set_icon(get_icon("Reload","EditorIcons"));
clear_button->set_icon(get_icon("Close","EditorIcons"));
- _update_plugins();
}
}
@@ -271,10 +102,6 @@ void EditorSettingsDialog::_bind_methods() {
ObjectTypeDB::bind_method(_MD("_settings_save"),&EditorSettingsDialog::_settings_save);
ObjectTypeDB::bind_method(_MD("_settings_changed"),&EditorSettingsDialog::_settings_changed);
- ObjectTypeDB::bind_method(_MD("_rescan_plugins"),&EditorSettingsDialog::_rescan_plugins);
- ObjectTypeDB::bind_method(_MD("_plugin_settings"),&EditorSettingsDialog::_plugin_settings);
- ObjectTypeDB::bind_method(_MD("_plugin_edited"),&EditorSettingsDialog::_plugin_edited);
- ObjectTypeDB::bind_method(_MD("_plugin_install"),&EditorSettingsDialog::_plugin_install);
ObjectTypeDB::bind_method(_MD("_clear_search_box"),&EditorSettingsDialog::_clear_search_box);
}
@@ -324,32 +151,6 @@ EditorSettingsDialog::EditorSettingsDialog() {
//Button *load = memnew( Button );
//load->set_text("Load..");
//hbc->add_child(load);
- Button *rescan = memnew( Button );
- rescan_plugins=rescan;
- rescan_plugins->connect("pressed",this,"_rescan_plugins");
- hbc->add_child(rescan);
- plugins = memnew( Tree );
- MarginContainer *mc = memnew( MarginContainer);
- vbc->add_child(mc);
- mc->add_child(plugins);
- mc->set_v_size_flags(SIZE_EXPAND_FILL);
- plugins->set_columns(3);
- plugins->set_column_title(0,"Name");
- plugins->set_column_title(1,"Author");
- plugins->set_column_title(2,"Version");
- plugins->set_column_expand(2,false);
- plugins->set_column_min_width(2,100);
- plugins->set_column_titles_visible(true);
- plugins->connect("button_pressed",this,"_plugin_settings");
- plugins->connect("item_edited",this,"_plugin_edited");
-
- plugin_setting = memnew( ConfirmationDialog );
- add_child(plugin_setting);
- plugin_description = memnew( RichTextLabel );
- plugin_setting->add_child(plugin_description);
- plugin_setting->set_child_rect(plugin_description);
- plugin_setting->connect("confirmed",this,"_plugin_install");
-
//get_ok()->set_text("Apply");
@@ -363,8 +164,6 @@ EditorSettingsDialog::EditorSettingsDialog() {
add_child(timer);
EditorSettings::get_singleton()->connect("settings_changed",this,"_settings_changed");
get_ok()->set_text("Close");
- install_confirm = memnew( ConfirmationDialog );
- add_child(install_confirm);
updating=false;
diff --git a/tools/editor/settings_config_dialog.h b/tools/editor/settings_config_dialog.h
index e1c3238a64..5085132108 100644
--- a/tools/editor/settings_config_dialog.h
+++ b/tools/editor/settings_config_dialog.h
@@ -40,17 +40,10 @@ class EditorSettingsDialog : public AcceptDialog {
- ConfirmationDialog *install_confirm;
bool updating;
- ConfirmationDialog *plugin_setting;
- String plugin_setting_edit;
-
- RichTextLabel *plugin_description;
TabContainer *tabs;
- Button *rescan_plugins;
- Tree *plugins;
LineEdit *search_box;
ToolButton *clear_button;
SectionedPropertyEditor *property_editor;
@@ -60,18 +53,11 @@ class EditorSettingsDialog : public AcceptDialog {
virtual void cancel_pressed();
virtual void ok_pressed();
- void _plugin_edited();
-
- void _plugin_settings(Object *p_obj,int p_cell,int p_index);
void _settings_changed();
void _settings_save();
- void _plugin_install();
-
void _notification(int p_what);
- void _rescan_plugins();
- void _update_plugins();
void _clear_search_box();
diff --git a/tools/editor/spatial_editor_gizmos.cpp b/tools/editor/spatial_editor_gizmos.cpp
index 320b0c3a70..3414e80482 100644
--- a/tools/editor/spatial_editor_gizmos.cpp
+++ b/tools/editor/spatial_editor_gizmos.cpp
@@ -43,7 +43,7 @@
#define HANDLE_HALF_SIZE 0.05
-void SpatialGizmoTool::clear() {
+void EditorSpatialGizmo::clear() {
for(int i=0;i<instances.size();i++) {
@@ -61,7 +61,15 @@ void SpatialGizmoTool::clear() {
secondary_handles.clear();
}
-void SpatialGizmoTool::Instance::create_instance(Spatial *p_base) {
+void EditorSpatialGizmo::redraw() {
+
+ if (get_script_instance() && get_script_instance()->has_method("redraw"))
+ get_script_instance()->call("redraw");
+
+
+}
+
+void EditorSpatialGizmo::Instance::create_instance(Spatial *p_base) {
instance = VS::get_singleton()->instance_create2(mesh->get_rid(),p_base->get_world()->get_scenario());
VS::get_singleton()->instance_attach_object_instance_ID(instance,p_base->get_instance_ID());
@@ -73,14 +81,14 @@ void SpatialGizmoTool::Instance::create_instance(Spatial *p_base) {
VS::get_singleton()->instance_attach_skeleton(instance,skeleton);
if (extra_margin)
VS::get_singleton()->instance_set_extra_visibility_margin(instance,1);
- VS::get_singleton()->instance_geometry_set_flag(instance,VS::INSTANCE_FLAG_CAST_SHADOW,false);
+ VS::get_singleton()->instance_geometry_set_cast_shadows_setting(instance,VS::SHADOW_CASTING_SETTING_OFF);
VS::get_singleton()->instance_geometry_set_flag(instance,VS::INSTANCE_FLAG_RECEIVE_SHADOWS,false);
VS::get_singleton()->instance_set_layer_mask(instance,1<<SpatialEditorViewport::GIZMO_EDIT_LAYER); //gizmos are 26
}
-void SpatialGizmoTool::add_mesh(const Ref<Mesh>& p_mesh,bool p_billboard, const RID &p_skeleton) {
+void EditorSpatialGizmo::add_mesh(const Ref<Mesh>& p_mesh,bool p_billboard, const RID &p_skeleton) {
ERR_FAIL_COND(!spatial_node);
Instance ins;
@@ -97,7 +105,7 @@ void SpatialGizmoTool::add_mesh(const Ref<Mesh>& p_mesh,bool p_billboard, const
}
-void SpatialGizmoTool::add_lines(const Vector<Vector3> &p_lines, const Ref<Material> &p_material,bool p_billboard){
+void EditorSpatialGizmo::add_lines(const Vector<Vector3> &p_lines, const Ref<Material> &p_material,bool p_billboard){
ERR_FAIL_COND(!spatial_node);
Instance ins;
@@ -150,7 +158,7 @@ void SpatialGizmoTool::add_lines(const Vector<Vector3> &p_lines, const Ref<Mater
}
-void SpatialGizmoTool::add_unscaled_billboard(const Ref<Material>& p_material,float p_scale) {
+void EditorSpatialGizmo::add_unscaled_billboard(const Ref<Material>& p_material,float p_scale) {
ERR_FAIL_COND(!spatial_node);
Instance ins;
@@ -201,12 +209,12 @@ void SpatialGizmoTool::add_unscaled_billboard(const Ref<Material>& p_material,fl
}
-void SpatialGizmoTool::add_collision_triangles(const Ref<TriangleMesh>& p_tmesh) {
+void EditorSpatialGizmo::add_collision_triangles(const Ref<TriangleMesh>& p_tmesh) {
collision_mesh=p_tmesh;
}
-void SpatialGizmoTool::add_collision_segments(const Vector<Vector3> &p_lines) {
+void EditorSpatialGizmo::add_collision_segments(const Vector<Vector3> &p_lines) {
int from=collision_segments.size();
collision_segments.resize(from+p_lines.size());
@@ -217,7 +225,7 @@ void SpatialGizmoTool::add_collision_segments(const Vector<Vector3> &p_lines) {
}
-void SpatialGizmoTool::add_handles(const Vector<Vector3> &p_handles, bool p_billboard,bool p_secondary){
+void EditorSpatialGizmo::add_handles(const Vector<Vector3> &p_handles, bool p_billboard,bool p_secondary){
billboard_handle=p_billboard;
@@ -354,13 +362,14 @@ void SpatialGizmoTool::add_handles(const Vector<Vector3> &p_handles, bool p_bill
}
-void SpatialGizmoTool::set_spatial_node(Spatial *p_node){
+void EditorSpatialGizmo::set_spatial_node(Spatial *p_node){
+ ERR_FAIL_NULL(p_node);
spatial_node=p_node;
}
-bool SpatialGizmoTool::intersect_frustum(const Camera *p_camera,const Vector<Plane> &p_frustum) {
+bool EditorSpatialGizmo::intersect_frustum(const Camera *p_camera,const Vector<Plane> &p_frustum) {
ERR_FAIL_COND_V(!spatial_node,false);
ERR_FAIL_COND_V(!valid,false);
@@ -401,7 +410,7 @@ bool SpatialGizmoTool::intersect_frustum(const Camera *p_camera,const Vector<Pla
}
-bool SpatialGizmoTool::intersect_ray(const Camera *p_camera,const Point2& p_point, Vector3& r_pos, Vector3& r_normal,int *r_gizmo_handle,bool p_sec_first) {
+bool EditorSpatialGizmo::intersect_ray(const Camera *p_camera,const Point2& p_point, Vector3& r_pos, Vector3& r_normal,int *r_gizmo_handle,bool p_sec_first) {
ERR_FAIL_COND_V(!spatial_node,false);
ERR_FAIL_COND_V(!valid,false);
@@ -631,7 +640,7 @@ bool SpatialGizmoTool::intersect_ray(const Camera *p_camera,const Point2& p_poin
-void SpatialGizmoTool::create() {
+void EditorSpatialGizmo::create() {
ERR_FAIL_COND(!spatial_node);
ERR_FAIL_COND(valid);
@@ -646,7 +655,7 @@ void SpatialGizmoTool::create() {
}
-void SpatialGizmoTool::transform(){
+void EditorSpatialGizmo::transform(){
ERR_FAIL_COND(!spatial_node);
ERR_FAIL_COND(!valid);
@@ -657,7 +666,7 @@ void SpatialGizmoTool::transform(){
}
-void SpatialGizmoTool::free(){
+void EditorSpatialGizmo::free(){
ERR_FAIL_COND(!spatial_node);
ERR_FAIL_COND(!valid);
@@ -675,19 +684,40 @@ void SpatialGizmoTool::free(){
}
+void EditorSpatialGizmo::_bind_methods() {
+
+ ObjectTypeDB::bind_method(_MD("add_lines","lines","material:Material","billboard"),&EditorSpatialGizmo::add_lines,DEFVAL(false));
+ ObjectTypeDB::bind_method(_MD("add_mesh","mesh:Mesh","billboard","skeleton"),&EditorSpatialGizmo::add_mesh,DEFVAL(false),DEFVAL(RID()));
+ ObjectTypeDB::bind_method(_MD("add_collision_segments","segments"),&EditorSpatialGizmo::add_collision_segments);
+ ObjectTypeDB::bind_method(_MD("add_collision_triangles","triangles:TriangleMesh"),&EditorSpatialGizmo::add_collision_triangles);
+ ObjectTypeDB::bind_method(_MD("add_unscaled_billboard","material:Material","default_scale"),&EditorSpatialGizmo::add_unscaled_billboard,DEFVAL(1));
+ ObjectTypeDB::bind_method(_MD("add_handles","handles","billboard","secondary"),&EditorSpatialGizmo::add_handles,DEFVAL(false),DEFVAL(false));
+ ObjectTypeDB::bind_method(_MD("set_spatial_node","node:Spatial"),&EditorSpatialGizmo::_set_spatial_node);
-SpatialGizmoTool::SpatialGizmoTool() {
+ BIND_VMETHOD( MethodInfo("redraw"));
+ BIND_VMETHOD( MethodInfo(Variant::STRING,"get_handle_name",PropertyInfo(Variant::INT,"index")));
+ {
+ BIND_VMETHOD( MethodInfo("get_handle_value:Variant",PropertyInfo(Variant::INT,"index")));
+ }
+ BIND_VMETHOD( MethodInfo("set_handle",PropertyInfo(Variant::INT,"index"),PropertyInfo(Variant::OBJECT,"camera:Camera"),PropertyInfo(Variant::VECTOR2,"point")));
+ MethodInfo cm = MethodInfo("commit_handle",PropertyInfo(Variant::INT,"index"),PropertyInfo(Variant::NIL,"restore:Variant"),PropertyInfo(Variant::BOOL,"cancel"));
+ cm.default_arguments.push_back(false);
+ BIND_VMETHOD( cm );
+}
+
+EditorSpatialGizmo::EditorSpatialGizmo() {
valid=false;
billboard_handle=false;
-
+ base=NULL;
+ spatial_node=NULL;
}
-SpatialGizmoTool::~SpatialGizmoTool(){
+EditorSpatialGizmo::~EditorSpatialGizmo(){
clear();
}
-Vector3 SpatialGizmoTool::get_handle_pos(int p_idx) const {
+Vector3 EditorSpatialGizmo::get_handle_pos(int p_idx) const {
ERR_FAIL_INDEX_V(p_idx,handles.size(),Vector3());
@@ -3190,4 +3220,3 @@ SpatialEditorGizmos::SpatialEditorGizmos() {
}
-
diff --git a/tools/editor/spatial_editor_gizmos.h b/tools/editor/spatial_editor_gizmos.h
index 669d3e2380..0162bcbf79 100644
--- a/tools/editor/spatial_editor_gizmos.h
+++ b/tools/editor/spatial_editor_gizmos.h
@@ -52,9 +52,9 @@
class Camera;
-class SpatialGizmoTool : public SpatialEditorGizmo {
+class EditorSpatialGizmo : public SpatialEditorGizmo {
- OBJ_TYPE(SpatialGizmoTool,SpatialGizmo);
+ OBJ_TYPE(EditorSpatialGizmo,SpatialGizmo);
struct Instance{
@@ -93,6 +93,8 @@ class SpatialGizmoTool : public SpatialEditorGizmo {
Spatial *base;
Vector<Instance> instances;
Spatial *spatial_node;
+
+ void _set_spatial_node(Node *p_node) { set_spatial_node(p_node->cast_to<Spatial>()); }
protected:
void add_lines(const Vector<Vector3> &p_lines,const Ref<Material>& p_material,bool p_billboard=false);
void add_mesh(const Ref<Mesh>& p_mesh,bool p_billboard=false,const RID& p_skeleton=RID());
@@ -103,6 +105,7 @@ protected:
void set_spatial_node(Spatial *p_node);
+ static void _bind_methods();
public:
virtual Vector3 get_handle_pos(int p_idx) const;
@@ -112,18 +115,18 @@ public:
void clear();
void create();
void transform();
- //void redraw();
+ virtual void redraw();
void free();
- SpatialGizmoTool();
- ~SpatialGizmoTool();
+ EditorSpatialGizmo();
+ ~EditorSpatialGizmo();
};
-class LightSpatialGizmo : public SpatialGizmoTool {
+class LightSpatialGizmo : public EditorSpatialGizmo {
- OBJ_TYPE(LightSpatialGizmo,SpatialGizmoTool);
+ OBJ_TYPE(LightSpatialGizmo,EditorSpatialGizmo);
Light* light;
@@ -140,9 +143,9 @@ public:
};
-class CameraSpatialGizmo : public SpatialGizmoTool {
+class CameraSpatialGizmo : public EditorSpatialGizmo {
- OBJ_TYPE(CameraSpatialGizmo,SpatialGizmoTool);
+ OBJ_TYPE(CameraSpatialGizmo,EditorSpatialGizmo);
Camera* camera;
@@ -161,9 +164,9 @@ public:
-class MeshInstanceSpatialGizmo : public SpatialGizmoTool {
+class MeshInstanceSpatialGizmo : public EditorSpatialGizmo {
- OBJ_TYPE(MeshInstanceSpatialGizmo,SpatialGizmoTool);
+ OBJ_TYPE(MeshInstanceSpatialGizmo,EditorSpatialGizmo);
MeshInstance* mesh;
@@ -174,9 +177,9 @@ public:
};
-class Position3DSpatialGizmo : public SpatialGizmoTool {
+class Position3DSpatialGizmo : public EditorSpatialGizmo {
- OBJ_TYPE(Position3DSpatialGizmo,SpatialGizmoTool);
+ OBJ_TYPE(Position3DSpatialGizmo,EditorSpatialGizmo);
Position3D* p3d;
@@ -187,9 +190,9 @@ public:
};
-class SkeletonSpatialGizmo : public SpatialGizmoTool {
+class SkeletonSpatialGizmo : public EditorSpatialGizmo {
- OBJ_TYPE(SkeletonSpatialGizmo,SpatialGizmoTool);
+ OBJ_TYPE(SkeletonSpatialGizmo,EditorSpatialGizmo);
Skeleton* skel;
@@ -203,9 +206,9 @@ public:
-class SpatialPlayerSpatialGizmo : public SpatialGizmoTool {
+class SpatialPlayerSpatialGizmo : public EditorSpatialGizmo {
- OBJ_TYPE(SpatialPlayerSpatialGizmo,SpatialGizmoTool);
+ OBJ_TYPE(SpatialPlayerSpatialGizmo,EditorSpatialGizmo);
SpatialPlayer* splayer;
@@ -218,9 +221,9 @@ public:
-class TestCubeSpatialGizmo : public SpatialGizmoTool {
+class TestCubeSpatialGizmo : public EditorSpatialGizmo {
- OBJ_TYPE(TestCubeSpatialGizmo,SpatialGizmoTool);
+ OBJ_TYPE(TestCubeSpatialGizmo,EditorSpatialGizmo);
TestCube* tc;
@@ -231,9 +234,9 @@ public:
};
-class RoomSpatialGizmo : public SpatialGizmoTool {
+class RoomSpatialGizmo : public EditorSpatialGizmo {
- OBJ_TYPE(RoomSpatialGizmo,SpatialGizmoTool);
+ OBJ_TYPE(RoomSpatialGizmo,EditorSpatialGizmo);
struct _EdgeKey {
@@ -256,9 +259,9 @@ public:
};
-class PortalSpatialGizmo : public SpatialGizmoTool {
+class PortalSpatialGizmo : public EditorSpatialGizmo {
- OBJ_TYPE(PortalSpatialGizmo,SpatialGizmoTool);
+ OBJ_TYPE(PortalSpatialGizmo,EditorSpatialGizmo);
Portal* portal;
@@ -270,9 +273,9 @@ public:
};
-class VisibilityNotifierGizmo : public SpatialGizmoTool {
+class VisibilityNotifierGizmo : public EditorSpatialGizmo {
- OBJ_TYPE(VisibilityNotifierGizmo ,SpatialGizmoTool);
+ OBJ_TYPE(VisibilityNotifierGizmo ,EditorSpatialGizmo);
VisibilityNotifier* notifier;
@@ -291,9 +294,9 @@ public:
-class CollisionShapeSpatialGizmo : public SpatialGizmoTool {
+class CollisionShapeSpatialGizmo : public EditorSpatialGizmo {
- OBJ_TYPE(CollisionShapeSpatialGizmo,SpatialGizmoTool);
+ OBJ_TYPE(CollisionShapeSpatialGizmo,EditorSpatialGizmo);
CollisionShape* cs;
@@ -308,9 +311,9 @@ public:
};
-class CollisionPolygonSpatialGizmo : public SpatialGizmoTool {
+class CollisionPolygonSpatialGizmo : public EditorSpatialGizmo {
- OBJ_TYPE(CollisionPolygonSpatialGizmo,SpatialGizmoTool);
+ OBJ_TYPE(CollisionPolygonSpatialGizmo,EditorSpatialGizmo);
CollisionPolygon* polygon;
@@ -322,9 +325,9 @@ public:
};
-class RayCastSpatialGizmo : public SpatialGizmoTool {
+class RayCastSpatialGizmo : public EditorSpatialGizmo {
- OBJ_TYPE(RayCastSpatialGizmo,SpatialGizmoTool);
+ OBJ_TYPE(RayCastSpatialGizmo,EditorSpatialGizmo);
RayCast* raycast;
@@ -337,9 +340,9 @@ public:
-class VehicleWheelSpatialGizmo : public SpatialGizmoTool {
+class VehicleWheelSpatialGizmo : public EditorSpatialGizmo {
- OBJ_TYPE(VehicleWheelSpatialGizmo,SpatialGizmoTool);
+ OBJ_TYPE(VehicleWheelSpatialGizmo,EditorSpatialGizmo);
VehicleWheel* car_wheel;
@@ -351,9 +354,9 @@ public:
};
-class NavigationMeshSpatialGizmo : public SpatialGizmoTool {
+class NavigationMeshSpatialGizmo : public EditorSpatialGizmo {
- OBJ_TYPE(NavigationMeshSpatialGizmo,SpatialGizmoTool);
+ OBJ_TYPE(NavigationMeshSpatialGizmo,EditorSpatialGizmo);
struct _EdgeKey {
@@ -376,9 +379,9 @@ public:
};
-class PinJointSpatialGizmo : public SpatialGizmoTool {
+class PinJointSpatialGizmo : public EditorSpatialGizmo {
- OBJ_TYPE(PinJointSpatialGizmo,SpatialGizmoTool);
+ OBJ_TYPE(PinJointSpatialGizmo,EditorSpatialGizmo);
PinJoint* p3d;
@@ -390,9 +393,9 @@ public:
};
-class HingeJointSpatialGizmo : public SpatialGizmoTool {
+class HingeJointSpatialGizmo : public EditorSpatialGizmo {
- OBJ_TYPE(HingeJointSpatialGizmo,SpatialGizmoTool);
+ OBJ_TYPE(HingeJointSpatialGizmo,EditorSpatialGizmo);
HingeJoint* p3d;
@@ -403,9 +406,9 @@ public:
};
-class SliderJointSpatialGizmo : public SpatialGizmoTool {
+class SliderJointSpatialGizmo : public EditorSpatialGizmo {
- OBJ_TYPE(SliderJointSpatialGizmo,SpatialGizmoTool);
+ OBJ_TYPE(SliderJointSpatialGizmo,EditorSpatialGizmo);
SliderJoint* p3d;
@@ -416,9 +419,9 @@ public:
};
-class ConeTwistJointSpatialGizmo : public SpatialGizmoTool {
+class ConeTwistJointSpatialGizmo : public EditorSpatialGizmo {
- OBJ_TYPE(ConeTwistJointSpatialGizmo,SpatialGizmoTool);
+ OBJ_TYPE(ConeTwistJointSpatialGizmo,EditorSpatialGizmo);
ConeTwistJoint* p3d;
@@ -430,9 +433,9 @@ public:
};
-class Generic6DOFJointSpatialGizmo : public SpatialGizmoTool {
+class Generic6DOFJointSpatialGizmo : public EditorSpatialGizmo {
- OBJ_TYPE(Generic6DOFJointSpatialGizmo,SpatialGizmoTool);
+ OBJ_TYPE(Generic6DOFJointSpatialGizmo,EditorSpatialGizmo);
Generic6DOFJoint* p3d;
@@ -488,4 +491,3 @@ public:
};
#endif // SPATIAL_EDITOR_GIZMOS_H
-