summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2016-02-27 23:10:44 -0300
committerJuan Linietsky <reduzio@gmail.com>2016-02-27 23:12:27 -0300
commit6fc1c3a4d1cf0c865f7dfdb1221ef07a5d25f305 (patch)
treef3871d453b8dafac043cdb3a7488717f3170be77 /tools
parenta97c1ca8f9f22aca758ebc778d8eb34b3f9ccc39 (diff)
Completed the support for plugins! It is not possible to add plugins.
Not all APIs are provided yet, please request whathever you are missing. Some example plugins are provided in demos/plugins. Just copy them to a folder in your project named addons/ and then enable them from the project settings. Have fun!
Diffstat (limited to 'tools')
-rw-r--r--tools/doc/doc_data.cpp8
-rw-r--r--tools/editor/create_dialog.cpp29
-rw-r--r--tools/editor/editor_data.cpp12
-rw-r--r--tools/editor/editor_data.h3
-rw-r--r--tools/editor/editor_help.cpp80
-rw-r--r--tools/editor/editor_import_export.cpp31
-rw-r--r--tools/editor/editor_import_export.h4
-rw-r--r--tools/editor/editor_node.cpp184
-rw-r--r--tools/editor/editor_node.h38
-rw-r--r--tools/editor/editor_plugin.cpp79
-rw-r--r--tools/editor/editor_plugin.h30
-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.cpp217
-rw-r--r--tools/editor/editor_settings.h12
-rw-r--r--tools/editor/io_plugins/editor_font_import_plugin.cpp2
-rw-r--r--tools/editor/io_plugins/editor_scene_import_plugin.cpp11
-rw-r--r--tools/editor/io_plugins/editor_scene_import_plugin.h2
-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/spatial_editor_plugin.cpp29
-rw-r--r--tools/editor/plugins/spatial_editor_plugin.h4
-rw-r--r--tools/editor/project_settings.cpp12
-rw-r--r--tools/editor/project_settings.h10
-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.cpp63
-rw-r--r--tools/editor/spatial_editor_gizmos.h93
28 files changed, 820 insertions, 589 deletions
diff --git a/tools/doc/doc_data.cpp b/tools/doc/doc_data.cpp
index 3836fa710b..2d0d7617c2 100644
--- a/tools/doc/doc_data.cpp
+++ b/tools/doc/doc_data.cpp
@@ -190,7 +190,11 @@ void DocData::generate(bool p_basic_types) {
#ifdef DEBUG_METHODS_ENABLED
if (m && m->get_return_type()!=StringName())
method.return_type=m->get_return_type();
- else if (arginfo.type!=Variant::NIL) // {
+ else if (method.name.find(":")!=-1) {
+ method.return_type=method.name.get_slice(":",1);
+ method.name=method.name.get_slice(":",0);
+
+ } else if (arginfo.type!=Variant::NIL) // {
#endif
method.return_type=(arginfo.hint==PROPERTY_HINT_RESOURCE_TYPE)?arginfo.hint_string:Variant::get_type_name(arginfo.type);
// }
@@ -210,7 +214,7 @@ void DocData::generate(bool p_basic_types) {
} else if (arginfo.hint==PROPERTY_HINT_RESOURCE_TYPE) {
type_name=arginfo.hint_string;
} else if (arginfo.type==Variant::NIL)
- type_name="var";
+ type_name="Variant";
else
type_name=Variant::get_type_name(arginfo.type);
diff --git a/tools/editor/create_dialog.cpp b/tools/editor/create_dialog.cpp
index 0f39d72308..23b8cad9ce 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;
diff --git a/tools/editor/editor_data.cpp b/tools/editor/editor_data.cpp
index aa10d6c86f..6c1fc2ef05 100644
--- a/tools/editor/editor_data.cpp
+++ b/tools/editor/editor_data.cpp
@@ -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 ) {
@@ -852,8 +860,8 @@ 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","node"),&EditorSelection::add_node);
- ObjectTypeDB::bind_method(_MD("remove_node","node"),&EditorSelection::remove_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 9e46d6ec32..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();
diff --git a/tools/editor/editor_help.cpp b/tools/editor/editor_help.cpp
index ddcb634151..110e06f25b 100644
--- a/tools/editor/editor_help.cpp
+++ b/tools/editor/editor_help.cpp
@@ -1123,35 +1123,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 +1286,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 +1303,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_import_export.cpp b/tools/editor/editor_import_export.cpp
index 7dfae9cf40..39182bfd69 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::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,p_platform);
+ 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,7 @@ EditorImportPlugin::EditorImportPlugin() {
void EditorExportPlugin::_bind_methods() {
- MethodInfo mi = MethodInfo("custom_export",PropertyInfo(Variant::STRING,"name"),PropertyInfo(Variant::OBJECT,"platform",PROPERTY_HINT_RESOURCE_TYPE,"EditorExportPlatform"));
+ 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 );
@@ -144,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>());
@@ -1458,11 +1478,14 @@ 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);
}
diff --git a/tools/editor/editor_import_export.h b/tools/editor/editor_import_export.h
index e74a6d8277..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:
diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp
index 9bf8ece878..4666a49655 100644
--- a/tools/editor/editor_node.cpp
+++ b/tools/editor/editor_node.cpp
@@ -2952,16 +2952,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;
@@ -3955,9 +4048,9 @@ void EditorNode::register_editor_types() {
ObjectTypeDB::register_type<EditorScript>();
ObjectTypeDB::register_type<EditorSelection>();
ObjectTypeDB::register_type<EditorFileDialog>();
- ObjectTypeDB::register_type<EditorImportExport>();
+ //ObjectTypeDB::register_type<EditorImportExport>();
ObjectTypeDB::register_type<EditorSettings>();
- ObjectTypeDB::register_type<UndoRedo>();
+ ObjectTypeDB::register_type<EditorSpatialGizmo>();
//ObjectTypeDB::register_type<EditorImporter>();
@@ -4360,6 +4453,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++) {
@@ -4697,6 +4835,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() {
@@ -4787,6 +4950,7 @@ EditorNode::EditorNode() {
EditorHelp::generate_doc(); //before any editor classes are crated
SceneState::set_disable_placeholders(true);
+
InputDefault *id = Input::get_singleton()->cast_to<InputDefault>();
if (id) {
@@ -4802,6 +4966,7 @@ EditorNode::EditorNode() {
singleton=this;
last_checked_version=0;
changing_scene=false;
+ _initializing_addons=false;
FileAccess::set_backup_save(true);
@@ -6061,7 +6226,7 @@ EditorNode::EditorNode() {
}
- EditorSettings::get_singleton()->enable_plugins();
+
Node::set_human_readable_collision_renaming(true);
@@ -6077,6 +6242,19 @@ 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();
diff --git a/tools/editor/editor_node.h b/tools/editor/editor_node.h
index a83555d6e8..b5d3e536db 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
@@ -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);
diff --git a/tools/editor/editor_plugin.cpp b/tools/editor/editor_plugin.cpp
index 6b5533f6e5..89b9c59287 100644
--- a/tools/editor/editor_plugin.cpp
+++ b/tools/editor/editor_plugin.cpp
@@ -48,6 +48,19 @@ void EditorPlugin::add_control_to_bottom_dock(Control *p_control, const String &
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::add_control_to_container(CustomControlContainer p_location,Control *p_control) {
@@ -94,9 +107,13 @@ void EditorPlugin::add_control_to_container(CustomControlContainer p_location,Co
}
}
-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) {
@@ -218,27 +235,65 @@ EditorSelection* EditorPlugin::get_selection() {
return EditorNode::get_singleton()->get_editor_selection();
}
-EditorImportExport *EditorPlugin::get_import_export() {
- return EditorImportExport::get_singleton();
-}
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("add_control_to_container","container","control:Control"),&EditorPlugin::add_control_to_container);
ObjectTypeDB::bind_method(_MD("add_control_to_bottom_dock","control:Control","title"),&EditorPlugin::add_control_to_bottom_dock);
+ 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("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_import_export:EditorImportExport"),&EditorPlugin::get_import_export);
- ObjectTypeDB::bind_method(_MD("get_editor_settings:EditorSettings"),&EditorPlugin::get_import_export);
+ 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")));
@@ -257,6 +312,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 df03d37be4..75a3b3b26f 100644
--- a/tools/editor/editor_plugin.h
+++ b/tools/editor/editor_plugin.h
@@ -43,6 +43,9 @@ class Camera;
class EditorSelection;
class EditorImportExport;
class EditorSettings;
+class SpatialEditorGizmo;
+class EditorImportPlugin;
+class EditorExportPlugin;
class EditorPlugin : public Node {
@@ -73,12 +76,26 @@ 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_control_to_container(CustomControlContainer p_location, Control *p_control);
void add_control_to_bottom_dock(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);
- 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;
@@ -99,8 +116,16 @@ public:
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();
+ //EditorImportExport *get_import_export();
EditorSettings *get_editor_settings();
virtual void restore_global_state();
@@ -112,6 +137,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 d7df661473..47ef87cfb1 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() {
@@ -623,148 +545,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) {
diff --git a/tools/editor/editor_settings.h b/tools/editor/editor_settings.h
index d189403dc1..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;
@@ -111,10 +107,7 @@ public:
//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/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_scene_import_plugin.cpp b/tools/editor/io_plugins/editor_scene_import_plugin.cpp
index a3b6827cd4..322320780d 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() {
@@ -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/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/spatial_editor_plugin.cpp b/tools/editor/plugins/spatial_editor_plugin.cpp
index bc57fd7e44..1f264a2337 100644
--- a/tools/editor/plugins/spatial_editor_plugin.cpp
+++ b/tools/editor/plugins/spatial_editor_plugin.cpp
@@ -3655,35 +3655,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) {
diff --git a/tools/editor/plugins/spatial_editor_plugin.h b/tools/editor/plugins/spatial_editor_plugin.h
index b0e366b140..af1b6919a2 100644
--- a/tools/editor/plugins/spatial_editor_plugin.h
+++ b/tools/editor/plugins/spatial_editor_plugin.h
@@ -457,8 +457,6 @@ private:
Ref<Environment> viewport_environment;
- List<EditorPlugin*> gizmo_plugins;
-
Spatial *selected;
void _request_gizmo(Object* p_obj);
@@ -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();
diff --git a/tools/editor/project_settings.cpp b/tools/editor/project_settings.cpp
index fd76ea3087..69e09d6053 100644
--- a/tools/editor/project_settings.cpp
+++ b/tools/editor/project_settings.cpp
@@ -570,6 +570,7 @@ void ProjectSettings::popup_project_settings() {
globals_editor->edit(Globals::get_singleton());
_update_translations();
_update_autoload();
+ plugin_settings->update_plugins();
}
@@ -739,6 +740,10 @@ void ProjectSettings::_settings_changed() {
timer->start();
}
+void ProjectSettings::queue_save() {
+ _settings_changed();
+}
+
void ProjectSettings::_copy_to_platform(int p_which) {
@@ -1830,6 +1835,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..922608fb9a 100644
--- a/tools/editor/project_settings.h
+++ b/tools/editor/project_settings.h
@@ -34,6 +34,9 @@
#include "optimized_save_dialog.h"
#include "undo_redo.h"
#include "editor_data.h"
+
+#include "editor_plugin_settings.h"
+
//#include "project_export_settings.h"
class ProjectSettings : public AcceptDialog {
@@ -89,6 +92,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 +148,8 @@ class ProjectSettings : public AcceptDialog {
void _toggle_search_bar(bool p_pressed);
void _clear_search_box();
+
+
ProjectSettings();
@@ -157,6 +165,8 @@ public:
static ProjectSettings *get_singleton() { return singleton; }
void popup_project_settings();
+ void queue_save();
+
ProjectSettings(EditorData *p_data);
};
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..de35672278 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());
@@ -80,7 +88,7 @@ void SpatialGizmoTool::Instance::create_instance(Spatial *p_base) {
-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,39 @@ 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);
+
+ 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 );
+}
-SpatialGizmoTool::SpatialGizmoTool() {
+EditorSpatialGizmo::EditorSpatialGizmo() {
valid=false;
billboard_handle=false;
}
-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());
diff --git a/tools/editor/spatial_editor_gizmos.h b/tools/editor/spatial_editor_gizmos.h
index 669d3e2380..346e360225 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;