summaryrefslogtreecommitdiff
path: root/tools/editor/editor_node.cpp
diff options
context:
space:
mode:
authorAnton Yabchinskiy <arn@bestmx.ru>2015-07-29 23:01:36 +0300
committerAnton Yabchinskiy <arn@bestmx.ru>2015-07-29 23:01:36 +0300
commitdc8df8a91a995796f0f330bf6bb6b209f6dfce08 (patch)
tree46cfe09124703b07860754d6b44e0289422e0573 /tools/editor/editor_node.cpp
parent16746f157f83d666079ba3266acec13d35b84c3f (diff)
parent922356b903061cda7591090bf19e8346c3a78cf5 (diff)
Merge branch 'master' of github.com:okamstudio/godot
Diffstat (limited to 'tools/editor/editor_node.cpp')
-rw-r--r--tools/editor/editor_node.cpp1385
1 files changed, 1182 insertions, 203 deletions
diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp
index 41545b887a..7789008c62 100644
--- a/tools/editor/editor_node.cpp
+++ b/tools/editor/editor_node.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -54,7 +54,7 @@
#include "register_exporters.h"
#include "bind/core_bind.h"
#include "io/zip_io.h"
-
+#include "io/config_file.h"
// plugins
#include "plugins/sprite_frames_editor_plugin.h"
@@ -91,6 +91,8 @@
#include "plugins/polygon_2d_editor_plugin.h"
#include "plugins/navigation_polygon_editor_plugin.h"
#include "plugins/light_occluder_2d_editor_plugin.h"
+#include "plugins/color_ramp_editor_plugin.h"
+#include "plugins/collision_shape_2d_editor_plugin.h"
// end
#include "tools/editor/io_plugins/editor_texture_import_plugin.h"
#include "tools/editor/io_plugins/editor_scene_import_plugin.h"
@@ -99,15 +101,50 @@
#include "tools/editor/io_plugins/editor_translation_import_plugin.h"
#include "tools/editor/io_plugins/editor_mesh_import_plugin.h"
+#include "plugins/editor_preview_plugins.h"
EditorNode *EditorNode::singleton=NULL;
+void EditorNode::_update_scene_tabs() {
+
+ scene_tabs->clear_tabs();
+ Ref<Texture> script_icon = gui_base->get_icon("Script","EditorIcons");
+ for(int i=0;i<editor_data.get_edited_scene_count();i++) {
+
+ String type=editor_data.get_scene_type(i);
+ Ref<Texture> icon;
+ if (type!=String()) {
+
+ if (!gui_base->has_icon(type,"EditorIcons")) {
+ type="Node";
+ }
+
+ icon=gui_base->get_icon(type,"EditorIcons");
+
+ }
+
+
+
+ int current = editor_data.get_edited_scene();
+ bool unsaved = (i==current)?saved_version!=editor_data.get_undo_redo().get_version():editor_data.get_scene_version(i)!=0;
+ scene_tabs->add_tab(editor_data.get_scene_title(i)+(unsaved?"(*)":""),icon);
+
+ if (editor_data.get_scene_root_script(i).is_valid()) {
+ scene_tabs->set_tab_right_button(i,script_icon);
+ }
+
+ }
+
+ scene_tabs->set_current_tab(editor_data.get_edited_scene());
+
+}
+
void EditorNode::_update_title() {
String appname = Globals::get_singleton()->get("application/name");
String title = appname.empty()?String(VERSION_FULL_NAME):String(_MKSTR(VERSION_NAME) + String(" - ") + appname);
- String edited = edited_scene?edited_scene->get_filename():String();
+ String edited = editor_data.get_edited_scene_root()?editor_data.get_edited_scene_root()->get_filename():String();
if (!edited.empty())
title+=" - " + String(edited.get_file());
if (unsaved_cache)
@@ -144,6 +181,7 @@ void EditorNode::_unhandled_input(const InputEvent& p_event) {
void EditorNode::_notification(int p_what) {
if (p_what==NOTIFICATION_EXIT_TREE) {
+
editor_data.save_editor_external_data();
log->deinit(); // do not get messages anymore
@@ -171,6 +209,11 @@ void EditorNode::_notification(int p_what) {
_update_title();
}
+ if (last_checked_version!=editor_data.get_undo_redo().get_version()) {
+ _update_scene_tabs();
+ last_checked_version=editor_data.get_undo_redo().get_version();
+ }
+
//get_root_node()->set_rect(viewport->get_global_rect());
//update the circle
@@ -184,7 +227,7 @@ void EditorNode::_notification(int p_what) {
circle_step=0;
circle_step_msec=tick;
- circle_step_frame=frame+1;
+ circle_step_frame=frame+1;
update_menu->set_icon(gui_base->get_icon("Progress"+itos(circle_step+1),"EditorIcons"));
@@ -228,6 +271,13 @@ void EditorNode::_notification(int p_what) {
//import_monitor->scan_changes();
}
+
+ if (p_what==NOTIFICATION_EXIT_TREE) {
+
+
+ editor_data.clear_edited_scenes();
+
+ }
if (p_what==NOTIFICATION_READY) {
VisualServer::get_singleton()->viewport_set_hide_scenario(get_scene_root()->get_viewport(),true);
@@ -319,6 +369,11 @@ void EditorNode::_fs_changed() {
E->get()->invalidate();
}
+
+ for(Set<EditorFileDialog*>::Element *E=editor_file_dialogs.front();E;E=E->next()) {
+
+ E->get()->invalidate();
+ }
}
void EditorNode::_sources_changed(bool p_exist) {
@@ -385,7 +440,7 @@ void EditorNode::edit_node(Node *p_node) {
void EditorNode::open_resource(const String& p_type) {
- file->set_mode(FileDialog::MODE_OPEN_FILE);
+ file->set_mode(EditorFileDialog::MODE_OPEN_FILE);
List<String> extensions;
ResourceLoader::get_recognized_extensions_for_type(p_type,&extensions);
@@ -453,14 +508,14 @@ void EditorNode::_dialog_display_file_error(String p_file,Error p_error) {
}break;
}
- accept->popup_centered(Size2(300,70));;
+ accept->popup_centered_minsize();
}
}
void EditorNode::_get_scene_metadata() {
- Node *scene = edited_scene;
+ Node *scene = editor_data.get_edited_scene_root();
if (!scene)
return;
@@ -487,7 +542,7 @@ void EditorNode::_get_scene_metadata() {
void EditorNode::_set_scene_metadata() {
- Node *scene = edited_scene;
+ Node *scene = editor_data.get_edited_scene_root();
if (!scene)
return;
@@ -609,7 +664,42 @@ static Error _fix_imported_scene_paths(Node* node, Node* root, String save_path)
};
-bool EditorNode::_find_and_save_edited_subresources(Object *obj,Set<RES>& processed,int32_t flags) {
+bool EditorNode::_find_and_save_resource(RES res,Map<RES,bool>& processed,int32_t flags) {
+
+ if (res.is_null())
+ return false;
+
+ if (processed.has(res)) {
+
+ return processed[res];
+ }
+
+
+ bool changed = res->is_edited();
+ res->set_edited(false);
+
+ bool subchanged = _find_and_save_edited_subresources(res.ptr(),processed,flags);
+
+// print_line("checking if edited: "+res->get_type()+" :: "+res->get_name()+" :: "+res->get_path()+" :: "+itos(changed)+" :: SR "+itos(subchanged));
+
+ if (res->get_path().is_resource_file()) {
+ if (changed || subchanged) {
+ //save
+ print_line("Also saving modified external resource: "+res->get_path());
+ Error err = ResourceSaver::save(res->get_path(),res,flags);
+
+ }
+ processed[res]=false; //because it's a file
+ return false;
+ } else {
+
+
+ processed[res]=changed;
+ return changed;
+ }
+}
+
+bool EditorNode::_find_and_save_edited_subresources(Object *obj,Map<RES,bool>& processed,int32_t flags) {
bool ret_changed=false;
List<PropertyInfo> pi;
@@ -619,57 +709,45 @@ bool EditorNode::_find_and_save_edited_subresources(Object *obj,Set<RES>& proces
if (!(E->get().usage&PROPERTY_USAGE_STORAGE))
continue;
+
+
switch(E->get().type) {
case Variant::OBJECT: {
RES res = obj->get(E->get().name);
- if (res.is_null() || processed.has(res))
- break;
-
- processed.insert(res);
-
- bool changed = res->is_edited();
- res->set_edited(false);
-
- bool subchanged = _find_and_save_edited_subresources(res.ptr(),processed,flags);
-
- if (res->get_path().is_resource_file()) {
- if (changed || subchanged) {
- //save
- print_line("Also saving modified external resource: "+res->get_path());
- Error err = ResourceSaver::save(res->get_path(),res,flags);
-
- }
- } else {
-
+ if (_find_and_save_resource(res,processed,flags))
ret_changed=true;
- }
-
} break;
case Variant::ARRAY: {
- /*Array varray=p_variant;
+ Array varray= obj->get(E->get().name);
int len=varray.size();
for(int i=0;i<len;i++) {
Variant v=varray.get(i);
- _find_resources(v);
- }*/
+ RES res=v;
+ if (_find_and_save_resource(res,processed,flags))
+ ret_changed=true;
+
+ //_find_resources(v);
+ }
} break;
case Variant::DICTIONARY: {
- /*
- Dictionary d=p_variant;
+
+ Dictionary d=obj->get(E->get().name);;
List<Variant> keys;
d.get_key_list(&keys);
for(List<Variant>::Element *E=keys.front();E;E=E->next()) {
Variant v = d[E->get()];
- _find_resources(v);
- } */
+ RES res=v;
+ if (_find_and_save_resource(res,processed,flags))
+ ret_changed=true;
+ }
} break;
default: {}
}
@@ -680,23 +758,113 @@ bool EditorNode::_find_and_save_edited_subresources(Object *obj,Set<RES>& proces
}
-void EditorNode::_save_edited_subresources(Node* scene,Set<RES>& processed,int32_t flags) {
+void EditorNode::_save_edited_subresources(Node* scene,Map<RES,bool>& processed,int32_t flags) {
_find_and_save_edited_subresources(scene,processed,flags);
for(int i=0;i<scene->get_child_count();i++) {
Node *n = scene->get_child(i);
- if (n->get_owner()!=edited_scene)
+ if (n->get_owner()!=editor_data.get_edited_scene_root())
continue;
_save_edited_subresources(n,processed,flags);
}
}
+void EditorNode::_find_node_types(Node* p_node, int&count_2d, int&count_3d) {
+
+ if (p_node->is_type("Viewport") || (p_node!=editor_data.get_edited_scene_root() && p_node->get_owner()!=editor_data.get_edited_scene_root()))
+ return;
+
+ if (p_node->is_type("CanvasItem"))
+ count_2d++;
+ else if (p_node->is_type("Spatial"))
+ count_3d++;
+
+ for(int i=0;i<p_node->get_child_count();i++)
+ _find_node_types(p_node->get_child(i),count_2d,count_3d);
+
+}
+
+
+void EditorNode::_save_scene_with_preview(String p_file) {
+
+ int c2d=0;
+ int c3d=0;
+
+ EditorProgress save("save","Saving Scene",4);
+ save.step("Analyzing",0);
+ _find_node_types(editor_data.get_edited_scene_root(),c2d,c3d);
+
+ RID viewport;
+ bool is2d;
+ if (c3d<c2d) {
+ viewport=scene_root->get_viewport();
+ is2d=true;
+ } else {
+ viewport=SpatialEditor::get_singleton()->get_editor_viewport(0)->get_viewport_node()->get_viewport();
+ is2d=false;
+
+ }
+ save.step("Creating Thumbnail",1);
+ //current view?
+ int screen =-1;
+ for(int i=0;i<editor_table.size();i++) {
+ if (editor_plugin_screen==editor_table[i]) {
+ screen=i;
+ break;
+ }
+ }
+
+ _editor_select(is2d?0:1);
+
+ VS::get_singleton()->viewport_queue_screen_capture(viewport);
+ save.step("Creating Thumbnail",2);
+ save.step("Creating Thumbnail",3);
+ Image img = VS::get_singleton()->viewport_get_screen_capture(viewport);
+ int preview_size = EditorSettings::get_singleton()->get("file_dialog/thumbnail_size");;
+ int width,height;
+ if (img.get_width() > preview_size && img.get_width() >= img.get_height()) {
+
+ width=preview_size;
+ height = img.get_height() * preview_size / img.get_width();
+ } else if (img.get_height() > preview_size && img.get_height() >= img.get_width()) {
+
+ height=preview_size;
+ width = img.get_width() * preview_size / img.get_height();
+ } else {
+
+ width=img.get_width();
+ height=img.get_height();
+ }
+
+ img.convert(Image::FORMAT_RGB);
+ img.resize(width,height);
+
+ String pfile = EditorSettings::get_singleton()->get_settings_path().plus_file("tmp/last_scene_preview.png");
+ img.save_png(pfile);
+ Vector<uint8_t> imgdata = FileAccess::get_file_as_array(pfile);
+
+ //print_line("img data is "+itos(imgdata.size()));
+
+ if (editor_data.get_edited_scene_import_metadata().is_null())
+ editor_data.set_edited_scene_import_metadata(Ref<ResourceImportMetadata>( memnew( ResourceImportMetadata ) ) );
+ editor_data.get_edited_scene_import_metadata()->set_option("thumbnail",imgdata);
+
+ //tamanio tel thumbnail
+ if (screen!=-1) {
+ _editor_select(screen);
+ }
+ save.step("Saving Scene",4);
+ _save_scene(p_file);
+
+}
+
+
void EditorNode::_save_scene(String p_file) {
- Node *scene = edited_scene;
+ Node *scene = editor_data.get_edited_scene_root();
if (!scene) {
@@ -704,7 +872,7 @@ void EditorNode::_save_scene(String p_file) {
//accept->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(Size2(300,70));;
+ accept->popup_centered_minsize();
return;
}
@@ -726,11 +894,11 @@ void EditorNode::_save_scene(String p_file) {
//accept->get_cancel()->hide();
accept->get_ok()->set_text("I see..");
accept->set_text("Couldn't save scene. Likely dependencies (instances) couldn't be satisfied.");
- accept->popup_centered(Size2(300,70));;
+ accept->popup_centered_minsize();
return;
}
- sdata->set_import_metadata(scene_import_metadata);
+ sdata->set_import_metadata(editor_data.get_edited_scene_import_metadata());
int flg=0;
if (EditorSettings::get_singleton()->get("on_save/compress_binary_resources"))
flg|=ResourceSaver::FLAG_COMPRESS;
@@ -740,13 +908,13 @@ void EditorNode::_save_scene(String p_file) {
err = ResourceSaver::save(p_file,sdata,flg);
- Set<RES> processed;
+ Map<RES,bool> processed;
_save_edited_subresources(scene,processed,flg);
editor_data.save_editor_external_data();
if (err==OK) {
scene->set_filename( Globals::get_singleton()->localize_path(p_file) );
//EditorFileSystem::get_singleton()->update_file(p_file,sdata->get_type());
- saved_version=editor_data.get_undo_redo().get_version();
+ set_current_version(editor_data.get_undo_redo().get_version());
_update_title();
} else {
@@ -927,14 +1095,14 @@ void EditorNode::_dialog_action(String p_file) {
//confirmation->get_cancel()->hide();
accept->get_ok()->set_text("I see..");
accept->set_text("This operation requieres a single selected node.");
- accept->popup_centered(Size2(300,70));;
+ accept->popup_centered_minsize();
break;
}
Node *base = selection.front()->get();
Map<Node*,Node*> reown;
- reown[get_edited_scene()]=base;
+ reown[editor_data.get_edited_scene_root()]=base;
Node *copy = base->duplicate_and_reown(reown);
if (copy) {
@@ -949,7 +1117,7 @@ void EditorNode::_dialog_action(String p_file) {
//accept->get_cancel()->hide();
accept->get_ok()->set_text("I see..");
accept->set_text("Couldn't save subscene. Likely dependencies (instances) couldn't be satisfied.");
- accept->popup_centered(Size2(300,70));;
+ accept->popup_centered_minsize();
return;
}
@@ -967,7 +1135,7 @@ void EditorNode::_dialog_action(String p_file) {
//confirmation->get_cancel()->hide();
accept->get_ok()->set_text("I see..");
accept->set_text("Error saving scene.");
- accept->popup_centered(Size2(300,70));;
+ accept->popup_centered_minsize();
break;
}
//EditorFileSystem::get_singleton()->update_file(p_file,sdata->get_type());
@@ -978,7 +1146,7 @@ void EditorNode::_dialog_action(String p_file) {
//confirmation->get_cancel()->hide();
accept->get_ok()->set_text("I see..");
accept->set_text("Error duplicating scene to save it.");
- accept->popup_centered(Size2(300,70));;
+ accept->popup_centered_minsize();
break;
}
@@ -992,7 +1160,9 @@ void EditorNode::_dialog_action(String p_file) {
if (file->get_mode()==FileDialog::MODE_SAVE_FILE) {
- _save_scene(p_file);
+ //_save_scene(p_file);
+ _save_scene_with_preview(p_file);
+
}
} break;
@@ -1000,7 +1170,8 @@ void EditorNode::_dialog_action(String p_file) {
case FILE_SAVE_AND_RUN: {
if (file->get_mode()==FileDialog::MODE_SAVE_FILE) {
- _save_scene(p_file);
+ //_save_scene(p_file);
+ _save_scene_with_preview(p_file);
_run(false);
}
} break;
@@ -1016,7 +1187,7 @@ void EditorNode::_dialog_action(String p_file) {
//accept->get_cancel()->hide();
accept->get_ok()->set_text("I see..");
accept->set_text("Can't load MeshLibrary for merging!.");
- accept->popup_centered(Size2(300,70));;
+ accept->popup_centered_minsize();
return;
}
@@ -1026,14 +1197,14 @@ void EditorNode::_dialog_action(String p_file) {
ml = Ref<MeshLibrary>( memnew( MeshLibrary ));
}
- MeshLibraryEditor::update_library_file(edited_scene,ml,true);
+ MeshLibraryEditor::update_library_file(editor_data.get_edited_scene_root(),ml,true);
Error err = ResourceSaver::save(p_file,ml);
if (err) {
accept->get_ok()->set_text("I see..");
accept->set_text("Error saving MeshLibrary!.");
- accept->popup_centered(Size2(300,70));;
+ accept->popup_centered_minsize();
return;
}
@@ -1050,7 +1221,7 @@ void EditorNode::_dialog_action(String p_file) {
//accept->get_cancel()->hide();
accept->get_ok()->set_text("I see..");
accept->set_text("Can't load TileSet for merging!.");
- accept->popup_centered(Size2(300,70));;
+ accept->popup_centered_minsize();
return;
}
@@ -1060,14 +1231,14 @@ void EditorNode::_dialog_action(String p_file) {
ml = Ref<TileSet>( memnew( TileSet ));
}
- TileSetEditor::update_library_file(edited_scene,ml,true);
+ TileSetEditor::update_library_file(editor_data.get_edited_scene_root(),ml,true);
Error err = ResourceSaver::save(p_file,ml);
if (err) {
accept->get_ok()->set_text("I see..");
accept->set_text("Error saving TileSet!.");
- accept->popup_centered(Size2(300,70));;
+ accept->popup_centered_minsize();
return;
}
} break;
@@ -1084,7 +1255,7 @@ void EditorNode::_dialog_action(String p_file) {
//confirmation->get_cancel()->hide();
accept->get_ok()->set_text("I see..");
accept->set_text("Can't open export templates zip.");
- accept->popup_centered(Size2(300,70));;
+ accept->popup_centered_minsize();
return;
}
@@ -1153,7 +1324,8 @@ void EditorNode::_dialog_action(String p_file) {
if (file->get_mode()==FileDialog::MODE_SAVE_FILE) {
- _save_scene(p_file);
+ //_save_scene(p_file);
+ _save_scene_with_preview(p_file);
}
} break;
@@ -1200,15 +1372,15 @@ void EditorNode::_property_editor_back() {
void EditorNode::_imported(Node *p_node) {
- Node *scene = edited_scene;
- set_edited_scene(p_node);
-
+ Node *scene = editor_data.get_edited_scene_root();
+// add_edited_scene(p_node);
+/*
if (scene) {
String path = scene->get_filename();
p_node->set_filename(path);
memdelete(scene);
}
-
+*/
}
@@ -1252,7 +1424,7 @@ void EditorNode::_edit_current() {
object_menu->set_disabled(false);
resources_dock->add_resource(Ref<Resource>(current_res));
- top_pallete->set_current_tab(1);
+ //top_pallete->set_current_tab(1);
}
@@ -1269,7 +1441,7 @@ void EditorNode::_edit_current() {
scene_tree_dock->set_selected(current_node);
object_menu->get_popup()->clear();
- top_pallete->set_current_tab(0);
+ //top_pallete->set_current_tab(0);
}
@@ -1283,17 +1455,22 @@ void EditorNode::_edit_current() {
if (main_plugin!=editor_plugin_screen) {
// update screen main_plugin
- if (editor_plugin_screen)
- editor_plugin_screen->make_visible(false);
- editor_plugin_screen=main_plugin;
- editor_plugin_screen->edit(current_obj);
- editor_plugin_screen->make_visible(true);
+ if (!changing_scene) {
- for(int i=0;i<editor_table.size();i++) {
- if (editor_table[i]==main_plugin) {
- main_editor_tabs->set_current_tab(i);
- break;
+ if (editor_plugin_screen)
+ editor_plugin_screen->make_visible(false);
+ editor_plugin_screen=main_plugin;
+ editor_plugin_screen->edit(current_obj);
+
+ editor_plugin_screen->make_visible(true);
+
+
+ for(int i=0;i<editor_table.size();i++) {
+ if (editor_table[i]==main_plugin) {
+ main_editor_tabs->set_current_tab(i);
+ break;
+ }
}
}
@@ -1393,7 +1570,7 @@ void EditorNode::_run(bool p_current,const String& p_custom) {
}
play_button->set_pressed(false);
- pause_button->set_pressed(false);
+ //pause_button->set_pressed(false);
play_scene_button->set_pressed(false);
String current_filename;
@@ -1402,10 +1579,10 @@ void EditorNode::_run(bool p_current,const String& p_custom) {
- if (p_current || (edited_scene && p_custom==edited_scene->get_filename())) {
+ if (p_current || (editor_data.get_edited_scene_root() && p_custom==editor_data.get_edited_scene_root()->get_filename())) {
- Node *scene = edited_scene;
+ Node *scene = editor_data.get_edited_scene_root();
if (!scene) {
@@ -1413,7 +1590,7 @@ void EditorNode::_run(bool p_current,const String& p_custom) {
//accept->get_cancel()->hide();
accept->get_ok()->set_text("I see..");
accept->set_text("No scene to run exists.");
- accept->popup_centered(Size2(300,70));;
+ accept->popup_centered_minsize();
return;
}
@@ -1456,7 +1633,7 @@ void EditorNode::_run(bool p_current,const String& p_custom) {
//accept->get_cancel()->hide();
accept->get_ok()->set_text("I see..");
accept->set_text("No main scene has ever been defined.\nSelect one from \"Project Settings\" under the 'application' category.");
- accept->popup_centered(Size2(300,100));;
+ accept->popup_centered_minsize();
return;
}
@@ -1467,7 +1644,7 @@ void EditorNode::_run(bool p_current,const String& p_custom) {
if (unsaved_cache) {
- Node *scene = edited_scene;
+ Node *scene = editor_data.get_edited_scene_root();
if (scene) { //only autosave if there is a scene obviously
@@ -1477,11 +1654,12 @@ void EditorNode::_run(bool p_current,const String& p_custom) {
//accept->get_cancel()->hide();
accept->get_ok()->set_text("I see..");
accept->set_text("Current scene was never saved, please save scene before running.");
- accept->popup_centered(Size2(300,70));;
+ accept->popup_centered_minsize();
return;
}
- _save_scene(scene->get_filename());
+ //_save_scene(scene->get_filename());
+ _save_scene_with_preview(scene->get_filename());
}
}
@@ -1500,7 +1678,7 @@ void EditorNode::_run(bool p_current,const String& p_custom) {
//confirmation->get_cancel()->hide();
accept->get_ok()->set_text("I see..");
accept->set_text("Could not start subprocess!");
- accept->popup_centered(Size2(300,70));;
+ accept->popup_centered_minsize();
return;
}
@@ -1518,8 +1696,8 @@ void EditorNode::_run(bool p_current,const String& p_custom) {
void EditorNode::_cleanup_scene() {
-
- Node *scene = edited_scene;
+#if 0
+ Node *scene = editor_data.get_edited_scene_root();
editor_selection->clear();
editor_data.clear_editor_states();
editor_history.clear();
@@ -1528,7 +1706,7 @@ void EditorNode::_cleanup_scene() {
property_editor->edit(NULL);
resources_dock->cleanup();
scene_import_metadata.unref();
- set_edited_scene(NULL);
+ //set_edited_scene(NULL);
if (scene) {
if (scene->get_filename()!="") {
previous_scenes.push_back(scene->get_filename());
@@ -1554,27 +1732,33 @@ void EditorNode::_cleanup_scene() {
}
_update_title();
-
+#endif
}
void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
- current_option=(MenuOptions)p_option;
+ //print_line("option "+itos(p_option)+" confirm "+itos(p_confirmed));
+ if (!p_confirmed) //this may be a hack..
+ current_option=(MenuOptions)p_option;
switch( p_option ) {
case FILE_NEW_SCENE: {
+ /*
if (!p_confirmed) {
confirmation->get_ok()->set_text("Yes");
//confirmation->get_cancel()->show();
confirmation->set_text("Start a New Scene? (Current will be lost)");
- confirmation->popup_centered(Size2(300,70));
+ confirmation->popup_centered_minsize();
break;
- }
+ }*/
+
+ int idx = editor_data.add_edited_scene(-1);
+ _scene_tab_changed(idx);
- _cleanup_scene();
+ //_cleanup_scene();
} break;
@@ -1582,7 +1766,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
//print_tree();
- file->set_mode(FileDialog::MODE_OPEN_FILE);
+ file->set_mode(EditorFileDialog::MODE_OPEN_FILE);
//not for now?
List<String> extensions;
ResourceLoader::get_recognized_extensions_for_type("PackedScene",&extensions);
@@ -1594,7 +1778,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
//file->set_current_path(current_path);
- Node *scene = edited_scene;
+ Node *scene = editor_data.get_edited_scene_root();
if (scene) {
file->set_current_path(scene->get_filename());
};
@@ -1627,20 +1811,36 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
open_request(previous_scenes.back()->get());
} break;
+ case FILE_CLOSE: {
+
+ if (!p_confirmed) {
+ confirmation->get_ok()->set_text("Yes");
+ //confirmation->get_cancel()->show();
+ confirmation->set_text("Close scene? (Unsaved changes will be lost)");
+ confirmation->popup_centered_minsize();
+ break;
+ }
+
+ _remove_edited_scene();
+
+
+
+ } break;
case FILE_SAVE_SCENE: {
- Node *scene = edited_scene;
+ Node *scene = editor_data.get_edited_scene_root();
if (scene && scene->get_filename()!="") {
- _save_scene(scene->get_filename());
+ //_save_scene(scene->get_filename());
+ _save_scene_with_preview(scene->get_filename());
return;
};
// fallthrough to save_as
};
case FILE_SAVE_AS_SCENE: {
- Node *scene = edited_scene;
+ Node *scene = editor_data.get_edited_scene_root();
if (!scene) {
@@ -1648,11 +1848,11 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
//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(Size2(300,70));;
+ accept->popup_centered_minsize();
break;
}
- file->set_mode(FileDialog::MODE_SAVE_FILE);
+ file->set_mode(EditorFileDialog::MODE_SAVE_FILE);
bool relpaths = (scene->has_meta("__editor_relpaths__") && scene->get_meta("__editor_relpaths__").operator bool());
@@ -1692,7 +1892,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
if (!p_confirmed) {
accept->get_ok()->set_text("Yes");
accept->set_text("This scene has never been saved. Save before running?");
- accept->popup_centered(Size2(300, 70));
+ accept->popup_centered_minsize();
break;
}
@@ -1702,7 +1902,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
case FILE_DUMP_STRINGS: {
- Node *scene = edited_scene;
+ Node *scene = editor_data.get_edited_scene_root();
if (!scene) {
@@ -1710,7 +1910,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
//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(Size2(300,70));;
+ accept->popup_centered_minsize();
break;
}
@@ -1728,14 +1928,14 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
//confirmation->get_cancel()->hide();
accept->get_ok()->set_text("I see..");
accept->set_text("Please save the scene first.");
- accept->popup_centered(Size2(300,70));;
+ accept->popup_centered_minsize();
break;
}
bool relpaths = (scene->has_meta("__editor_relpaths__") && scene->get_meta("__editor_relpaths__").operator bool());
- file->set_mode(FileDialog::MODE_SAVE_FILE);
+ file->set_mode(EditorFileDialog::MODE_SAVE_FILE);
file->set_current_path(cpath);
file->set_title("Save Translatable Strings");
@@ -1746,7 +1946,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
case FILE_SAVE_SUBSCENE: {
- Node *scene = edited_scene;
+ Node *scene = editor_data.get_edited_scene_root();
if (!scene) {
@@ -1754,7 +1954,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
//confirmation->get_cancel()->hide();
accept->get_ok()->set_text("I see..");
accept->set_text("This operation can't be done without a scene.");
- accept->popup_centered(Size2(300,70));;
+ accept->popup_centered_minsize();
break;
}
@@ -1767,24 +1967,24 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
//confirmation->get_cancel()->hide();
accept->get_ok()->set_text("I see..");
accept->set_text("This operation requieres a single selected node.");
- accept->popup_centered(Size2(300,70));;
+ accept->popup_centered_minsize();
break;
}
Node *tocopy = selection.front()->get();
- if (tocopy!=edited_scene && tocopy->get_filename()!="") {
+ if (tocopy!=editor_data.get_edited_scene_root() && tocopy->get_filename()!="") {
current_option=-1;
//confirmation->get_cancel()->hide();
accept->get_ok()->set_text("I see..");
accept->set_text("This operation can't be done on instanced scenes.");
- accept->popup_centered(Size2(300,70));;
+ accept->popup_centered_minsize();
break;
}
- file->set_mode(FileDialog::MODE_SAVE_FILE);
+ file->set_mode(EditorFileDialog::MODE_SAVE_FILE);
List<String> extensions;
Ref<PackedScene> sd = memnew( PackedScene );
@@ -1807,7 +2007,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
file->set_title("Save Sub-Scene As..");
} break;
case FILE_SAVE_OPTIMIZED: {
- Node *scene = edited_scene;
+ Node *scene = editor_data.get_edited_scene_root();
#if 0
if (!scene) {
@@ -1869,13 +2069,13 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
case FILE_EXPORT_MESH_LIBRARY: {
- if (!edited_scene) {
+ if (!editor_data.get_edited_scene_root()) {
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 scene.");
- accept->popup_centered(Size2(300,70));;
+ accept->popup_centered_minsize();
break;
}
@@ -1914,13 +2114,13 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
//import_subscene->popup_centered_ratio();
- if (!edited_scene) {
+ if (!editor_data.get_edited_scene_root()) {
current_option=-1;
//accept->get_cancel()->hide();
accept->get_ok()->set_text("I see..");
accept->set_text("This operation can't be done without a selected node.");
- accept->popup_centered(Size2(300,70));;
+ accept->popup_centered_minsize();
break;
}
@@ -1930,14 +2130,17 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
case FILE_QUIT: {
+
if (!p_confirmed) {
+
confirmation->get_ok()->set_text("Quit");
//confirmation->get_cancel()->show();
confirmation->set_text("Exit the Editor?");
- confirmation->popup_centered(Size2(300,70));
+ confirmation->popup_centered(Size2(180,70));
break;
}
+
_menu_option_confirm(RUN_STOP,true);
get_tree()->quit();
@@ -1949,7 +2152,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
confirmation->get_ok()->set_text("Open");
//confirmation->get_cancel()->show();
confirmation->set_text("Current scene not saved. Open anyway?");
- confirmation->popup_centered(Size2(300,70));
+ confirmation->popup_centered_minsize();
break;
}
@@ -1996,7 +2199,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
if (unsaved_cache && !p_confirmed) {
confirmation->get_ok()->set_text("Revert");
confirmation->set_text("This action cannot be undone. Revert anyway?");
- confirmation->popup_centered(Size2(300,70));
+ confirmation->popup_centered_minsize();
break;
}
@@ -2116,7 +2319,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
}
editor_data.get_undo_redo().clear_history();
- if (editor_plugin_screen) { //reload editor plugin
+ if (editor_plugin_over) { //reload editor plugin
editor_plugin_over->edit(NULL);
editor_plugin_over->edit(current);
}
@@ -2152,7 +2355,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
editor_run.stop();
play_button->set_pressed(false);
play_scene_button->set_pressed(false);
- pause_button->set_pressed(false);
+ //pause_button->set_pressed(false);
emit_signal("stop_pressed");
} break;
@@ -2174,7 +2377,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
if (!p_confirmed) {
confirmation->get_ok()->set_text("Yes");
confirmation->set_text("Open Project Manager? \n(Unsaved changes will be lost)");
- confirmation->popup_centered(Size2(300,70));
+ confirmation->popup_centered_minsize();
break;
}
@@ -2437,30 +2640,54 @@ void EditorNode::remove_editor_import_plugin(const Ref<EditorImportPlugin>& p_ed
_rebuild_import_menu();
}
+void EditorNode::_remove_edited_scene() {
+ int new_index = editor_data.get_edited_scene();
+ int old_index=new_index;
+ if (new_index>0) {
+ new_index=new_index-1;
+ } else if (editor_data.get_edited_scene_count()>1) {
+ new_index=1;
+ } else {
+ editor_data.add_edited_scene(-1);
+ new_index=1;
+ }
+
+ _scene_tab_changed(new_index);
+ editor_data.remove_scene(old_index);
+ editor_data.get_undo_redo().clear_history();
+ _update_title();
+ _update_scene_tabs();
+
+ if (editor_data.get_edited_scene_count()==1) {
+ //make new scene appear saved
+ set_current_version(editor_data.get_undo_redo().get_version());
+ unsaved_cache=false;
+ }
+}
void EditorNode::set_edited_scene(Node *p_scene) {
- if (edited_scene) {
- if (edited_scene->get_parent()==scene_root)
- scene_root->remove_child(edited_scene);
+ if (get_editor_data().get_edited_scene_root()) {
+ if (get_editor_data().get_edited_scene_root()->get_parent()==scene_root)
+ scene_root->remove_child(get_editor_data().get_edited_scene_root());
animation_editor->set_root(NULL);
}
- edited_scene=p_scene;
- if (edited_scene && edited_scene->cast_to<Popup>())
- edited_scene->cast_to<Popup>()->show(); //show popups
- scene_tree_dock->set_edited_scene(edited_scene);
+ 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);
if (get_tree())
- get_tree()->set_edited_scene_root(edited_scene);
+ get_tree()->set_edited_scene_root(p_scene);
- if (edited_scene) {
+ if (p_scene) {
if (p_scene->get_parent()!=scene_root)
scene_root->add_child(p_scene);
animation_editor->set_root(p_scene);
}
-
-
}
+
void EditorNode::_fetch_translatable_strings(const Object *p_object,Set<StringName>& strings) {
@@ -2512,7 +2739,7 @@ Error EditorNode::save_translatable_strings(const String& p_to_file) {
OS::Time time = OS::get_singleton()->get_time();
f->store_line("# Translation Strings Dump.");
f->store_line("# Created By.");
- f->store_line("# \t"VERSION_FULL_NAME" (c) 2008-2014 Juan Linietsky, Ariel Manzur.");
+ f->store_line("# \t"VERSION_FULL_NAME" (c) 2008-2015 Juan Linietsky, Ariel Manzur.");
f->store_line("# From Scene: ");
f->store_line("# \t"+get_edited_scene()->get_filename());
f->store_line("");
@@ -2627,7 +2854,7 @@ Error EditorNode::save_optimized_copy(const String& p_scene,const String& p_pres
}
}
- ERR_EXPLAIN("Preset '"+p_preset+"' references unexisting saver: "+type);
+ ERR_EXPLAIN("Preset '"+p_preset+"' references nonexistent saver: "+type);
ERR_FAIL_COND_V(saver.is_null(),ERR_INVALID_DATA);
List<Variant> keys;
@@ -2686,6 +2913,115 @@ Error EditorNode::save_optimized_copy(const String& p_scene,const String& p_pres
return OK;
}
+
+Dictionary EditorNode::_get_main_scene_state() {
+
+ Dictionary state;
+ state["main_tab"]=main_editor_tabs->get_current_tab();
+ state["scene_tree_offset"]=scene_tree_dock->get_tree_editor()->get_scene_tree()->get_vscroll_bar()->get_val();
+ state["property_edit_offset"]=get_property_editor()->get_scene_tree()->get_vscroll_bar()->get_val();
+ state["saved_version"]=saved_version;
+ //print_line(" getting main tab: "+itos(state["main_tab"]));
+ return state;
+}
+
+void EditorNode::_set_main_scene_state(Dictionary p_state) {
+
+ //print_line("set current 7 ");
+
+ if (p_state.has("main_tab")) {
+ int idx = p_state["main_tab"];
+ int current=-1;
+ for(int i=0;i<editor_table.size();i++) {
+ if (editor_plugin_screen==editor_table[i]) {
+ current=i;
+ break;
+ }
+ }
+
+ if (idx<2 && current<2) {
+ //only set tab for 2D and 3D
+ _editor_select(p_state["main_tab"]);
+ //print_line(" setting main tab: "+itos(p_state["main_tab"]));
+ }
+ }
+
+ if (p_state.has("scene_tree_offset"))
+ scene_tree_dock->get_tree_editor()->get_scene_tree()->get_vscroll_bar()->set_val(p_state["scene_tree_offset"]);
+ if (p_state.has("property_edit_offset"))
+ get_property_editor()->get_scene_tree()->get_vscroll_bar()->set_val(p_state["property_edit_offset"]);
+
+ //print_line("set current 8 ");
+
+
+}
+
+void EditorNode::set_current_version(uint64_t p_version) {
+
+ saved_version=p_version;
+ editor_data.set_edited_scene_version(p_version);
+}
+
+bool EditorNode::is_changing_scene() const {
+ return changing_scene;
+}
+void EditorNode::set_current_scene(int p_idx) {
+
+ changing_scene=true;
+ editor_data.save_edited_scene_state(editor_selection,&editor_history,_get_main_scene_state());
+
+ if (get_editor_data().get_edited_scene_root()) {
+ if (get_editor_data().get_edited_scene_root()->get_parent()==scene_root)
+ scene_root->remove_child(get_editor_data().get_edited_scene_root());
+ animation_editor->set_root(NULL);
+ }
+
+ //print_line("set current 2 ");
+
+ editor_selection->clear();
+ editor_data.set_edited_scene(p_idx);
+
+ Node* new_scene = editor_data.get_edited_scene_root();
+
+ if (new_scene && new_scene->cast_to<Popup>())
+ new_scene->cast_to<Popup>()->show(); //show popups
+
+ //print_line("set current 3 ");
+
+ scene_tree_dock->set_edited_scene(new_scene);
+ if (get_tree())
+ get_tree()->set_edited_scene_root(new_scene);
+
+ if (new_scene) {
+ if (new_scene->get_parent()!=scene_root)
+ scene_root->add_child(new_scene);
+ animation_editor->set_root(new_scene);
+ }
+ //print_line("set current 4 ");
+
+
+ Dictionary state = editor_data.restore_edited_scene_state(editor_selection,&editor_history);
+ _edit_current();
+
+ /*if (!unsaved) {
+ saved_version=editor_data.get_undo_redo().get_version();
+ if (p_backwards)
+ saved_version--;
+ else
+ saved_version++;
+ print_line("was saved, updating version");
+ } else {
+ saved_version=state["saved_version"];
+ }*/
+ //_set_main_scene_state(state);
+
+ call_deferred("_set_main_scene_state",state); //do after everything else is done setting up
+ //print_line("set current 6 ");
+ changing_scene=false;
+
+
+}
+
Error EditorNode::load_scene(const String& p_scene) {
if (!is_inside_tree()) {
@@ -2694,6 +3030,14 @@ Error EditorNode::load_scene(const String& p_scene) {
}
+ for(int i=0;i<editor_data.get_edited_scene_count();i++) {
+
+ if (editor_data.get_scene_path(i)==p_scene) {
+ _scene_tab_changed(i);
+ return OK;
+ }
+ }
+
load_errors->clear();
String lpath = Globals::get_singleton()->localize_path(p_scene);
@@ -2704,38 +3048,66 @@ Error EditorNode::load_scene(const String& p_scene) {
//accept->get_cancel()->hide();
accept->get_ok()->set_text("Ugh");
accept->set_text("Error loading scene, it must be inside the project path. Use 'Import' to open the scene, then save it inside the project path.");
- accept->popup_centered(Size2(300,120));
+ accept->popup_centered_minsize();
opening_prev=false;
return ERR_FILE_NOT_FOUND;
}
- _cleanup_scene(); // i'm sorry but this MUST happen to avoid modified resources to not be reloaded.
+ int prev = editor_data.get_edited_scene();
+ int idx = editor_data.add_edited_scene(-1);
+ //print_line("load scene callback");
+ //set_current_scene(idx);
+
+ if (!editor_data.get_edited_scene_root() && editor_data.get_edited_scene_count()==2) {
+ _remove_edited_scene();
+ } else {
+ _scene_tab_changed(idx);
+ }
+
+
- Ref<PackedScene> sdata = ResourceLoader::load(lpath);
+ //_cleanup_scene(); // i'm sorry but this MUST happen to avoid modified resources to not be reloaded.
+
+ Ref<PackedScene> sdata = ResourceLoader::load(lpath,"",true);
if (!sdata.is_valid()) {
current_option=-1;
//accept->get_cancel()->hide();
accept->get_ok()->set_text("Ugh");
accept->set_text("Error loading scene.");
- accept->popup_centered(Size2(300,70));;
+ accept->popup_centered_minsize();
opening_prev=false;
+
+ if (prev!=-1) {
+ set_current_scene(prev);
+ editor_data.remove_scene(idx);
+ }
return ERR_FILE_NOT_FOUND;
}
+ sdata->set_path(lpath,true); //take over path
+
Node*new_scene=sdata->instance(true);
if (!new_scene) {
+ sdata.unref();
current_option=-1;
//accept->get_cancel()->hide();
accept->get_ok()->set_text("Ugh");
accept->set_text("Error loading scene.");
- accept->popup_centered(Size2(300,70));;
+ accept->popup_centered_minsize();
opening_prev=false;
+ if (prev!=-1) {
+ set_current_scene(prev);
+ editor_data.remove_scene(idx);
+ }
return ERR_FILE_NOT_FOUND;
}
+ //guess not needed in the end?
+ //new_scene->clear_internal_tree_resource_paths(); //make sure no internal tree paths to internal resources exist
+
/*
Node *old_scene = edited_scene;
_hide_top_editors();
@@ -2748,16 +3120,23 @@ Error EditorNode::load_scene(const String& p_scene) {
memdelete(old_scene);
}
*/
+
set_edited_scene(new_scene);
_get_scene_metadata();
+ /*
+ editor_data.set_edited_scene_root(new_scene);
+
scene_tree_dock->set_selected(new_scene, true);
property_editor->edit(new_scene);
- scene_import_metadata = sdata->get_import_metadata();
+ editor_data.set_edited_scene_root(new_scene);
+*/
+ editor_data.set_edited_scene_import_metadata( sdata->get_import_metadata() );
- editor_data.get_undo_redo().clear_history();
+
+// 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__")) {
@@ -2776,7 +3155,7 @@ Error EditorNode::load_scene(const String& p_scene) {
prev_scene->set_disabled(previous_scenes.size()==0);
opening_prev=false;
- top_pallete->set_current_tab(0); //always go to scene
+ //top_pallete->set_current_tab(0); //always go to scene
push_item(new_scene);
@@ -2787,8 +3166,9 @@ Error EditorNode::load_scene(const String& p_scene) {
void EditorNode::open_request(const String& p_path) {
- external_file=p_path;
- _menu_option_confirm(FILE_EXTERNAL_OPEN_SCENE,false);
+ load_scene(p_path); // as it will be opened in separate tab
+ //external_file=p_path;
+ //_menu_option_confirm(FILE_EXTERNAL_OPEN_SCENE,false);
}
@@ -2809,9 +3189,9 @@ void EditorNode::_instance_request(const String& p_path){
request_instance_scene(p_path);
}
-void EditorNode::_property_keyed(const String& p_keyed,const Variant& p_value) {
+void EditorNode::_property_keyed(const String& p_keyed,const Variant& p_value,bool p_advance) {
- animation_editor->insert_value_key(p_keyed,p_value);
+ animation_editor->insert_value_key(p_keyed,p_value,p_advance);
}
void EditorNode::_transform_keyed(Object *sp,const String& p_sub,const Transform& p_key) {
@@ -2849,15 +3229,15 @@ void EditorNode::_update_keying() {
void EditorNode::_close_messages() {
// left_split->set_dragger_visible(false);
- old_split_ofs = left_split->get_split_offset();
- left_split->set_split_offset(0);
+ old_split_ofs = center_split->get_split_offset();
+ center_split->set_split_offset(0);
// scene_root_parent->set_anchor_and_margin(MARGIN_BOTTOM,Control::ANCHOR_END,0);
}
void EditorNode::_show_messages() {
// left_split->set_dragger_visible(true);
- left_split->set_split_offset(old_split_ofs);
+ center_split->set_split_offset(old_split_ofs);
// scene_root_parent->set_anchor_and_margin(MARGIN_BOTTOM,Control::ANCHOR_END,log->get_margin(MARGIN_TOP));
}
@@ -2926,15 +3306,16 @@ void EditorNode::_open_recent_scene(int p_idx) {
String path = "res://"+rc[p_idx];
- if (unsaved_cache) {
+
+ /*if (unsaved_cache) {
_recent_scene=rc[p_idx];
open_recent_confirmation->set_text("Discard current scene and open:\n'"+rc[p_idx]+"'");
open_recent_confirmation->get_label()->set_align(Label::ALIGN_CENTER);
open_recent_confirmation->popup_centered(Size2(400,100));
return;
- }
+ }*/
- load_scene(rc[p_idx]);
+ load_scene(path);
}
@@ -2978,12 +3359,6 @@ void EditorNode::_save_optimized() {
#endif
}
-void EditorNode::_open_recent_scene_confirm() {
-
- load_scene(_recent_scene);
-
-}
-
void EditorNode::_update_recent_scenes() {
String base="_"+Globals::get_singleton()->get_resource_path().replace("\\","::").replace("/","::");
@@ -3023,7 +3398,7 @@ void EditorNode::notify_child_process_exited() {
play_button->set_pressed(false);
play_scene_button->set_pressed(false);
- pause_button->set_pressed(false);
+ //pause_button->set_pressed(false);
stop_button->set_pressed(false);
editor_run.stop();
@@ -3103,6 +3478,8 @@ void EditorNode::register_editor_types() {
ObjectTypeDB::register_type<EditorImportPlugin>();
ObjectTypeDB::register_type<EditorScenePostImport>();
ObjectTypeDB::register_type<EditorScript>();
+ ObjectTypeDB::register_type<EditorFileDialog>();
+ ObjectTypeDB::register_type<UndoRedo>();
//ObjectTypeDB::register_type<EditorImporter>();
@@ -3192,7 +3569,7 @@ void EditorNode::_bind_methods() {
//ObjectTypeDB::bind_method("_import",&EditorNode::_import);
// ObjectTypeDB::bind_method("_import_conflicts_solved",&EditorNode::_import_conflicts_solved);
ObjectTypeDB::bind_method("_open_recent_scene",&EditorNode::_open_recent_scene);
- ObjectTypeDB::bind_method("_open_recent_scene_confirm",&EditorNode::_open_recent_scene_confirm);
+// ObjectTypeDB::bind_method("_open_recent_scene_confirm",&EditorNode::_open_recent_scene_confirm);
ObjectTypeDB::bind_method("_save_optimized",&EditorNode::_save_optimized);
ObjectTypeDB::bind_method(_MD("animation_panel_make_visible","enable"),&EditorNode::animation_panel_make_visible);
@@ -3201,6 +3578,23 @@ void EditorNode::_bind_methods() {
ObjectTypeDB::bind_method("_sources_changed",&EditorNode::_sources_changed);
ObjectTypeDB::bind_method("_fs_changed",&EditorNode::_fs_changed);
+ ObjectTypeDB::bind_method("_dock_select_draw",&EditorNode::_dock_select_draw);
+ ObjectTypeDB::bind_method("_dock_select_input",&EditorNode::_dock_select_input);
+ ObjectTypeDB::bind_method("_dock_pre_popup",&EditorNode::_dock_pre_popup);
+ ObjectTypeDB::bind_method("_dock_split_dragged",&EditorNode::_dock_split_dragged);
+ ObjectTypeDB::bind_method("_save_docks",&EditorNode::_save_docks);
+ ObjectTypeDB::bind_method("_dock_popup_exit",&EditorNode::_dock_popup_exit);
+ ObjectTypeDB::bind_method("_dock_move_left",&EditorNode::_dock_move_left);
+ ObjectTypeDB::bind_method("_dock_move_right",&EditorNode::_dock_move_right);
+
+ ObjectTypeDB::bind_method("set_current_scene",&EditorNode::set_current_scene);
+ ObjectTypeDB::bind_method("set_current_version",&EditorNode::set_current_version);
+ ObjectTypeDB::bind_method("_scene_tab_changed",&EditorNode::_scene_tab_changed);
+ ObjectTypeDB::bind_method("_scene_tab_script_edited",&EditorNode::_scene_tab_script_edited);
+ ObjectTypeDB::bind_method("_set_main_scene_state",&EditorNode::_set_main_scene_state);
+ ObjectTypeDB::bind_method("_update_scene_tabs",&EditorNode::_update_scene_tabs);
+
+
ObjectTypeDB::bind_method(_MD("add_editor_import_plugin", "plugin"), &EditorNode::add_editor_import_plugin);
ObjectTypeDB::bind_method(_MD("remove_editor_import_plugin", "plugin"), &EditorNode::remove_editor_import_plugin);
@@ -3253,6 +3647,16 @@ void EditorNode::_file_dialog_unregister(FileDialog *p_dialog){
singleton->file_dialogs.erase(p_dialog);
}
+void EditorNode::_editor_file_dialog_register(EditorFileDialog *p_dialog) {
+
+ singleton->editor_file_dialogs.insert(p_dialog);
+}
+
+void EditorNode::_editor_file_dialog_unregister(EditorFileDialog *p_dialog){
+
+ singleton->editor_file_dialogs.erase(p_dialog);
+}
+
Vector<EditorNodeInitCallback> EditorNode::_init_callbacks;
Error EditorNode::export_platform(const String& p_platform, const String& p_path, bool p_debug,const String& p_password,bool p_quit_after) {
@@ -3271,12 +3675,409 @@ void EditorNode::show_warning(const String& p_text) {
warning->popup_centered_minsize();
}
+void EditorNode::_dock_select_input(const InputEvent& p_input) {
+
+ if (p_input.type==InputEvent::MOUSE_BUTTON || p_input.type==InputEvent::MOUSE_MOTION) {
+
+ Vector2 point(p_input.mouse_motion.x,p_input.mouse_motion.y);
+
+ int nrect = -1;
+ for(int i=0;i<DOCK_SLOT_MAX;i++) {
+ if (dock_select_rect[i].has_point(point)) {
+ nrect=i;
+ break;
+ }
+ }
+
+
+ if (nrect!=dock_select_rect_over) {
+ dock_select->update();
+ dock_select_rect_over=nrect;
+
+ }
+
+
+ if (nrect==-1)
+ return;
+
+ if (p_input.type==InputEvent::MOUSE_BUTTON && p_input.mouse_button.button_index==1 && p_input.mouse_button.pressed && dock_popup_selected!=nrect) {
+ Control *dock = dock_slot[dock_popup_selected]->get_current_tab_control();
+ if (dock) {
+ dock_slot[dock_popup_selected]->remove_child(dock);
+ }
+ if (dock_slot[dock_popup_selected]->get_tab_count()==0) {
+ dock_slot[dock_popup_selected]->hide();
+
+ } else {
+
+ dock_slot[dock_popup_selected]->set_current_tab(0);
+ }
+
+ print_line("performing reparent");
+ dock_slot[nrect]->add_child(dock);
+ dock_popup_selected=nrect;
+ dock_slot[nrect]->set_current_tab(dock_slot[nrect]->get_tab_count()-1);
+ dock_slot[nrect]->show();
+ dock_select->update();
+
+ VSplitContainer*splits[DOCK_SLOT_MAX/2]={
+ left_l_vsplit,
+ left_r_vsplit,
+ right_l_vsplit,
+ right_r_vsplit,
+ };
+
+ for(int i=0;i<4;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();
+ }
+
+ _save_docks();
+ }
+ }
+}
+
+void EditorNode::_dock_popup_exit() {
+
+ dock_select_rect_over=-1;
+ dock_select->update();
+}
+
+void EditorNode::_dock_pre_popup(int p_which) {
+
+
+ dock_popup_selected=p_which;
+}
+
+void EditorNode::_dock_move_left() {
+
+ if (dock_popup_selected<0 || dock_popup_selected>=DOCK_SLOT_MAX)
+ return;
+ Control *current = dock_slot[dock_popup_selected]->get_tab_control( dock_slot[dock_popup_selected]->get_current_tab() );
+ Control *prev = dock_slot[dock_popup_selected]->get_tab_control( dock_slot[dock_popup_selected]->get_current_tab()-1 );
+ if (!current || !prev)
+ return;
+ dock_slot[dock_popup_selected]->move_child(current,prev->get_index());
+ dock_slot[dock_popup_selected]->set_current_tab( dock_slot[dock_popup_selected]->get_current_tab()-1 );
+ dock_select->update();
+ _save_docks();
+
+
+}
+
+void EditorNode::_dock_move_right() {
+
+ Control *current = dock_slot[dock_popup_selected]->get_tab_control( dock_slot[dock_popup_selected]->get_current_tab() );
+ Control *next = dock_slot[dock_popup_selected]->get_tab_control( dock_slot[dock_popup_selected]->get_current_tab()+1 );
+ if (!current || !next)
+ return;
+ dock_slot[dock_popup_selected]->move_child(next,current->get_index());
+ dock_slot[dock_popup_selected]->set_current_tab( dock_slot[dock_popup_selected]->get_current_tab()+1 );
+ dock_select->update();
+ _save_docks();
+}
+
+void EditorNode::_dock_select_draw(){
+ Size2 s = dock_select->get_size();
+ s.y/=2.0;
+ s.x/=6.0;
+
+ Color used=Color(0.6,0.6,0.6,0.8);
+ Color used_selected=Color(0.8,0.8,0.8,0.8);
+ Color tab_selected=Color(1,1,1,1);
+ Color unused=used;
+ unused.a=0.4;
+ Color unusable=unused;
+ unusable.a=0.1;
+
+ Rect2 unr(s.x*2,0,s.x*2,s.y*2);
+ unr.pos+=Vector2(2,5);
+ unr.size-=Vector2(4,7);
+
+ dock_select->draw_rect(unr,unusable);
+
+ dock_tab_move_left->set_disabled(true);
+ dock_tab_move_right->set_disabled(true);
+
+ if (dock_popup_selected!=-1 && dock_slot[dock_popup_selected]->get_tab_count()) {
+
+ dock_tab_move_left->set_disabled(dock_slot[dock_popup_selected]->get_current_tab()==0);
+ dock_tab_move_right->set_disabled(dock_slot[dock_popup_selected]->get_current_tab()>=dock_slot[dock_popup_selected]->get_tab_count()-1);
+ }
+
+ for(int i=0;i<DOCK_SLOT_MAX;i++) {
+
+ Vector2 ofs;
+
+ switch(i) {
+ case DOCK_SLOT_LEFT_UL: {
+
+ } break;
+ case DOCK_SLOT_LEFT_BL: {
+ ofs.y+=s.y;
+ } break;
+ case DOCK_SLOT_LEFT_UR: {
+ ofs.x+=s.x;
+ } break;
+ case DOCK_SLOT_LEFT_BR: {
+ ofs+=s;
+ } break;
+ case DOCK_SLOT_RIGHT_UL: {
+ ofs.x+=s.x*4;
+ } break;
+ case DOCK_SLOT_RIGHT_BL: {
+ ofs.x+=s.x*4;
+ ofs.y+=s.y;
+
+ } break;
+ case DOCK_SLOT_RIGHT_UR: {
+ ofs.x+=s.x*4;
+ ofs.x+=s.x;
+
+ } break;
+ case DOCK_SLOT_RIGHT_BR: {
+ ofs.x+=s.x*4;
+ ofs+=s;
+
+ } break;
+ }
+
+ Rect2 r(ofs,s);
+ dock_select_rect[i]=r;
+ r.pos+=Vector2(2,5);
+ r.size-=Vector2(4,7);
+
+
+ if (i==dock_select_rect_over) {
+ dock_select->draw_rect(r,used_selected);
+ } else if (dock_slot[i]->get_child_count()==0) {
+ dock_select->draw_rect(r,unused);
+ } else {
+
+ dock_select->draw_rect(r,used);
+ }
+
+ for(int j=0;j<MIN(3,dock_slot[i]->get_child_count());j++) {
+ int xofs = (r.size.width/3)*j;
+ Color c = used;
+ if (i==dock_popup_selected && (dock_slot[i]->get_current_tab()>3 || dock_slot[i]->get_current_tab()==j))
+ c=tab_selected;
+ dock_select->draw_rect(Rect2(2+ofs.x+xofs,ofs.y,r.size.width/3-1,3),c);
+ }
+
+ }
+}
+
+void EditorNode::_save_docks() {
+
+ Ref<ConfigFile> config;
+ config.instance();
+
+ for(int i=0;i<DOCK_SLOT_MAX;i++) {
+ String names;
+ for(int j=0;j<dock_slot[i]->get_tab_count();j++) {
+ String name = dock_slot[i]->get_tab_control(j)->get_name();
+ if (names!="")
+ names+=",";
+ names+=name;
+ }
+
+ if (names!="") {
+ config->set_value("docks","dock_"+itos(i+1),names);
+ }
+ }
+
+ VSplitContainer*splits[DOCK_SLOT_MAX/2]={
+ left_l_vsplit,
+ left_r_vsplit,
+ right_l_vsplit,
+ right_r_vsplit,
+ };
+
+ for(int i=0;i<DOCK_SLOT_MAX/2;i++) {
+
+ if (splits[i]->is_visible()) {
+ config->set_value("docks","dock_split_"+itos(i+1),splits[i]->get_split_offset());
+ }
+ }
+
+
+ HSplitContainer *h_splits[4]={
+ left_l_hsplit,
+ left_r_hsplit,
+ main_hsplit,
+ right_hsplit,
+ };
+
+ for(int i=0;i<4;i++) {
+
+ config->set_value("docks","dock_hsplit_"+itos(i+1),h_splits[i]->get_split_offset());
+ }
+
+ editor_data.get_plugin_window_layout(config);
+
+ config->save(EditorSettings::get_singleton()->get_project_settings_path().plus_file("editor_layout.cfg"));
+
+}
+
+void EditorNode::save_layout() {
+
+ dock_drag_timer->start();
+}
+
+void EditorNode::_dock_split_dragged(int ofs) {
+
+ dock_drag_timer->start();
+}
+
+void EditorNode::_load_docks() {
+
+ Ref<ConfigFile> config;
+ config.instance();
+ Error err = config->load(EditorSettings::get_singleton()->get_project_settings_path().plus_file("editor_layout.cfg"));
+ if (err!=OK) {
+ return; //no config
+ }
+
+ for(int i=0;i<DOCK_SLOT_MAX;i++) {
+
+ if (!config->has_section_key("docks","dock_"+itos(i+1)))
+ continue;
+
+ Vector<String> names = String(config->get_value("docks","dock_"+itos(i+1))).split(",");
+
+ for(int j=0;j<names.size();j++) {
+
+ String name=names[j];
+ //find it, in a horribly inefficient way
+ int atidx=-1;
+ Control *node=NULL;
+ for(int k=0;k<DOCK_SLOT_MAX;k++) {
+ if (!dock_slot[k]->has_node(name))
+ continue;
+ node=dock_slot[k]->get_node(name)->cast_to<Control>();
+ if (!node)
+ continue;
+ atidx=k;
+ break;
+ }
+ if (atidx==-1) //well, it's not anywhere
+ continue;
+
+ if (atidx==j) {
+ node->raise();
+ continue;
+ }
+
+
+ dock_slot[atidx]->remove_child(node);
+
+ if (dock_slot[atidx]->get_tab_count()==0) {
+ dock_slot[atidx]->hide();
+
+ }
+ dock_slot[i]->add_child(node);
+ dock_slot[i]->show();
+ }
+
+ }
+
+ VSplitContainer*splits[DOCK_SLOT_MAX/2]={
+ left_l_vsplit,
+ left_r_vsplit,
+ right_l_vsplit,
+ right_r_vsplit,
+ };
+
+ for(int i=0;i<DOCK_SLOT_MAX/2;i++) {
+
+ if (!config->has_section_key("docks","dock_split_"+itos(i+1)))
+ continue;
+
+ int ofs = config->get_value("docks","dock_split_"+itos(i+1));
+ splits[i]->set_split_offset(ofs);
+ }
+
+ HSplitContainer *h_splits[4]={
+ left_l_hsplit,
+ left_r_hsplit,
+ main_hsplit,
+ right_hsplit,
+ };
+
+ for(int i=0;i<4;i++) {
+ if (!config->has_section_key("docks","dock_hsplit_"+itos(i+1)))
+ continue;
+ int ofs = config->get_value("docks","dock_hsplit_"+itos(i+1));
+ h_splits[i]->set_split_offset(ofs);
+ }
+
+ 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);
+ }
+ }
+
+ editor_data.set_plugin_window_layout(config);
+
+}
+
+
+void EditorNode::_scene_tab_script_edited(int p_tab) {
+
+ Ref<Script> script = editor_data.get_scene_root_script(p_tab);
+ if (script.is_valid())
+ edit_resource(script);
+}
+
+void EditorNode::_scene_tab_changed(int p_tab) {
+
+
+ //print_line("set current 1 ");
+ bool unsaved = (saved_version!=editor_data.get_undo_redo().get_version());
+ //print_line("version: "+itos(editor_data.get_undo_redo().get_version())+", saved "+itos(saved_version));
+
+ if (p_tab==editor_data.get_edited_scene())
+ return; //pointless
+
+ uint64_t next_scene_version = editor_data.get_scene_version(p_tab);
+
+
+
+ //print_line("scene tab changed???");
+ editor_data.get_undo_redo().create_action("Switch Scene Tab");
+ editor_data.get_undo_redo().add_do_method(this,"set_current_version",unsaved?saved_version:0);
+ editor_data.get_undo_redo().add_do_method(this,"set_current_scene",p_tab);
+ editor_data.get_undo_redo().add_do_method(scene_tabs,"set_current_tab",p_tab);
+ editor_data.get_undo_redo().add_do_method(this,"set_current_version",next_scene_version==0?editor_data.get_undo_redo().get_version()+1:next_scene_version);
+
+ editor_data.get_undo_redo().add_undo_method(this,"set_current_version",next_scene_version);
+ editor_data.get_undo_redo().add_undo_method(this,"set_current_scene",editor_data.get_edited_scene());
+ editor_data.get_undo_redo().add_undo_method(scene_tabs,"set_current_tab",editor_data.get_edited_scene());
+ editor_data.get_undo_redo().add_undo_method(this,"set_current_version",saved_version);
+ editor_data.get_undo_redo().commit_action();
+
+}
EditorNode::EditorNode() {
EditorHelp::generate_doc(); //before any editor classes are crated
singleton=this;
+ last_checked_version=0;
+ changing_scene=false;
FileAccess::set_backup_save(true);
@@ -3305,7 +4106,13 @@ EditorNode::EditorNode() {
FileDialog::register_func=_file_dialog_register;
FileDialog::unregister_func=_file_dialog_unregister;
+ EditorFileDialog::get_icon_func=_file_dialog_get_icon;
+ EditorFileDialog::register_func=_editor_file_dialog_register;
+ EditorFileDialog::unregister_func=_editor_file_dialog_unregister;
+
+
editor_import_export = memnew( EditorImportExport );
+ add_child(editor_import_export);
register_exporters();
@@ -3328,6 +4135,9 @@ EditorNode::EditorNode() {
editor_register_icons(theme);
editor_register_fonts(theme);
+ //theme->set_icon("folder","EditorFileDialog",Theme::get_default()->get_icon("folder","EditorFileDialog"));
+ //theme->set_color("files_disabled","EditorFileDialog",Color(0,0,0,0.7));
+
String global_font = EditorSettings::get_singleton()->get("global/font");
if (global_font!="") {
Ref<Font> fnt = ResourceLoader::load(global_font);
@@ -3346,6 +4156,8 @@ EditorNode::EditorNode() {
theme->set_stylebox("EditorFocus","EditorStyles",focus_sbt);
+ resource_preview = memnew( EditorResourcePreview );
+ add_child(resource_preview);
progress_dialog = memnew( ProgressDialog );
gui_base->add_child(progress_dialog);
@@ -3353,26 +4165,163 @@ EditorNode::EditorNode() {
gui_base->set_anchor( MARGIN_RIGHT, Control::ANCHOR_END );
gui_base->set_anchor( MARGIN_BOTTOM, Control::ANCHOR_END );
gui_base->set_end( Point2(0,0) );
-
+
main_vbox = memnew( VBoxContainer );
gui_base->add_child(main_vbox);
main_vbox->set_area_as_parent_rect(8);
- menu_hb = memnew( HBoxContainer );
- main_vbox->add_child(menu_hb);
+ PanelContainer *top_dark_panel = memnew( PanelContainer );
+ Ref<StyleBoxTexture> top_dark_sb;
+ top_dark_sb.instance();;
+ top_dark_sb->set_texture(theme->get_icon("PanelTop","EditorIcons"));
+ for(int i=0;i<4;i++) {
+ top_dark_sb->set_margin_size(Margin(i),3);
+ top_dark_sb->set_default_margin(Margin(i),0);
+ }
+ top_dark_sb->set_expand_margin_size(MARGIN_LEFT,20);
+ top_dark_sb->set_expand_margin_size(MARGIN_RIGHT,20);
- main_split = memnew( HSplitContainer );
- main_vbox->add_child(main_split);
- main_split->set_v_size_flags(Control::SIZE_EXPAND_FILL);
+ top_dark_panel->add_style_override("panel",top_dark_sb);
+ VBoxContainer *top_dark_vb = memnew( VBoxContainer );
+ main_vbox->add_child(top_dark_panel);
+ top_dark_panel->add_child(top_dark_vb);
- left_split = memnew( VSplitContainer );
- main_split->add_child(left_split);
- left_split->set_h_size_flags(Control::SIZE_EXPAND_FILL);
- left_split->set_collapsed(false);
+
+
+ menu_hb = memnew( HBoxContainer );
+ top_dark_vb->add_child(menu_hb);
+
+ scene_tabs=memnew( Tabs );
+ scene_tabs->add_tab("unsaved");
+ scene_tabs->set_tab_align(Tabs::ALIGN_CENTER);
+ scene_tabs->connect("tab_changed",this,"_scene_tab_changed");
+ scene_tabs->connect("right_button_pressed",this,"_scene_tab_script_edited");
+ top_dark_vb->add_child(scene_tabs);
+ //left
+ left_l_hsplit = memnew( HSplitContainer );
+ main_vbox->add_child(left_l_hsplit);
+
+ left_l_hsplit->set_v_size_flags(Control::SIZE_EXPAND_FILL);
+
+ left_l_vsplit = memnew( VSplitContainer );
+ left_l_hsplit->add_child(left_l_vsplit);
+ dock_slot[DOCK_SLOT_LEFT_UL]=memnew( TabContainer );
+ left_l_vsplit->add_child(dock_slot[DOCK_SLOT_LEFT_UL]);
+ dock_slot[DOCK_SLOT_LEFT_BL]=memnew( TabContainer );
+ left_l_vsplit->add_child(dock_slot[DOCK_SLOT_LEFT_BL]);
+ left_l_vsplit->hide();
+ dock_slot[DOCK_SLOT_LEFT_UL]->hide();
+ dock_slot[DOCK_SLOT_LEFT_BL]->hide();
+
+ left_r_hsplit = memnew( HSplitContainer );
+ left_l_hsplit->add_child(left_r_hsplit);
+ left_r_vsplit = memnew( VSplitContainer );
+ left_r_hsplit->add_child(left_r_vsplit);
+ dock_slot[DOCK_SLOT_LEFT_UR]=memnew( TabContainer );
+ left_r_vsplit->add_child(dock_slot[DOCK_SLOT_LEFT_UR]);
+ dock_slot[DOCK_SLOT_LEFT_BR]=memnew( TabContainer );
+ left_r_vsplit->add_child(dock_slot[DOCK_SLOT_LEFT_BR]);
+ //left_r_vsplit->hide();
+ //dock_slot[DOCK_SLOT_LEFT_UR]->hide();
+ //dock_slot[DOCK_SLOT_LEFT_BR]->hide();
+
+
+ main_hsplit = memnew( HSplitContainer );
+ left_r_hsplit->add_child(main_hsplit);
+ //main_split->set_v_size_flags(Control::SIZE_EXPAND_FILL);
+
+ center_split = memnew( VSplitContainer );
+ main_hsplit->add_child(center_split);
+ center_split->set_h_size_flags(Control::SIZE_EXPAND_FILL);
+ center_split->set_collapsed(false);
+
+ right_hsplit = memnew( HSplitContainer );
+ main_hsplit->add_child(right_hsplit);
+
+ right_l_vsplit = memnew( VSplitContainer );
+ right_hsplit->add_child(right_l_vsplit);
+ dock_slot[DOCK_SLOT_RIGHT_UL]=memnew( TabContainer );
+ right_l_vsplit->add_child(dock_slot[DOCK_SLOT_RIGHT_UL]);
+ dock_slot[DOCK_SLOT_RIGHT_BL]=memnew( TabContainer );
+ right_l_vsplit->add_child(dock_slot[DOCK_SLOT_RIGHT_BL]);
+
+ right_r_vsplit = memnew( VSplitContainer );
+ right_hsplit->add_child(right_r_vsplit);
+ dock_slot[DOCK_SLOT_RIGHT_UR]=memnew( TabContainer );
+ right_r_vsplit->add_child(dock_slot[DOCK_SLOT_RIGHT_UR]);
+ dock_slot[DOCK_SLOT_RIGHT_BR]=memnew( TabContainer );
+ right_r_vsplit->add_child(dock_slot[DOCK_SLOT_RIGHT_BR]);
+ right_r_vsplit->hide();
+ //dock_slot[DOCK_SLOT_RIGHT_UL]->hide();
+ //dock_slot[DOCK_SLOT_RIGHT_BL]->hide();
+
+ left_l_vsplit->connect("dragged",this,"_dock_split_dragged");
+ left_r_vsplit->connect("dragged",this,"_dock_split_dragged");
+ right_l_vsplit->connect("dragged",this,"_dock_split_dragged");
+ right_r_vsplit->connect("dragged",this,"_dock_split_dragged");
+
+ left_l_hsplit->connect("dragged",this,"_dock_split_dragged");
+ left_r_hsplit->connect("dragged",this,"_dock_split_dragged");
+ main_hsplit->connect("dragged",this,"_dock_split_dragged");
+ right_hsplit->connect("dragged",this,"_dock_split_dragged");
+
+
+
+ dock_select_popoup = memnew( PopupPanel );
+ gui_base->add_child(dock_select_popoup);
+ VBoxContainer *dock_vb = memnew( VBoxContainer );
+ dock_select_popoup->add_child(dock_vb);
+
+ HBoxContainer *dock_hb = memnew( HBoxContainer);
+ dock_tab_move_left = memnew( ToolButton );
+ dock_tab_move_left->set_icon(theme->get_icon("Back","EditorIcons"));
+ dock_tab_move_left->set_focus_mode(Control::FOCUS_NONE);
+ dock_tab_move_left->connect("pressed",this,"_dock_move_left");
+ //dock_tab_move_left->set_h_size_flags(Control::SIZE_EXPAND_FILL);
+ dock_hb->add_child(dock_tab_move_left);
+ dock_hb->add_spacer();
+ dock_tab_move_right = memnew( ToolButton );
+ dock_tab_move_right->set_icon(theme->get_icon("Forward","EditorIcons"));
+ dock_tab_move_right->set_focus_mode(Control::FOCUS_NONE);
+ dock_tab_move_right->connect("pressed",this,"_dock_move_right");
+
+ //dock_tab_move_right->set_h_size_flags(Control::SIZE_EXPAND_FILL);
+ dock_hb->add_child(dock_tab_move_right);
+ dock_vb->add_child(dock_hb);
+
+ dock_select = memnew( Control );
+ dock_select->set_custom_minimum_size(Size2(128,64));
+ dock_select->connect("input_event",this,"_dock_select_input");
+ dock_select->connect("draw",this,"_dock_select_draw");
+ dock_select->connect("mouse_exit",this,"_dock_popup_exit");
+ dock_select->set_v_size_flags(Control::SIZE_EXPAND_FILL);
+ dock_vb->add_child(dock_select);
+
+
+ dock_select_popoup->set_child_rect(dock_vb);
+ dock_select_popoup->set_as_minsize();
+ dock_select_rect_over=-1;
+ dock_popup_selected=-1;
+ //dock_select_popoup->set_(Size2(20,20));
+
+ for(int i=0;i<DOCK_SLOT_MAX;i++) {
+ dock_slot[i]->set_custom_minimum_size(Size2(230,220));
+ dock_slot[i]->set_v_size_flags(Control::SIZE_EXPAND_FILL);
+ dock_slot[i]->set_popup(dock_select_popoup);
+ dock_slot[i]->connect("pre_popup_pressed",this,"_dock_pre_popup",varray(i));
+
+ //dock_slot[i]->set_tab_align(TabContainer::ALIGN_LEFT);
+ }
+
+ dock_drag_timer = memnew( Timer );
+ add_child(dock_drag_timer);
+ dock_drag_timer->set_wait_time(0.5);
+ dock_drag_timer->set_one_shot(true);
+ dock_drag_timer->connect("timeout",this,"_save_docks");
top_split = memnew( VSplitContainer );
- left_split->add_child(top_split);
+ center_split->add_child(top_split);
top_split->set_v_size_flags(Control::SIZE_EXPAND_FILL);
top_split->set_collapsed(true);
@@ -3443,6 +4392,7 @@ EditorNode::EditorNode() {
animation_panel=pc;
animation_panel->hide();
+
HBoxContainer *animation_hb = memnew( HBoxContainer);
animation_vb->add_child(animation_hb);
@@ -3491,8 +4441,9 @@ EditorNode::EditorNode() {
prev_scene->set_disabled(true);
//left_menu_hb->add_child( prev_scene );
prev_scene->connect("pressed",this,"_menu_option",make_binds(FILE_OPEN_PREV));
- //gui_base->add_child(prev_scene);
+ gui_base->add_child(prev_scene);
prev_scene->set_pos(Point2(3,24));
+ prev_scene->hide();
Separator *vs=NULL;
@@ -3501,10 +4452,13 @@ EditorNode::EditorNode() {
p=file_menu->get_popup();
p->add_item("New Scene",FILE_NEW_SCENE);
p->add_item("Open Scene..",FILE_OPEN_SCENE,KEY_MASK_CMD+KEY_O);
+ p->add_separator();
p->add_item("Save Scene",FILE_SAVE_SCENE,KEY_MASK_CMD+KEY_S);
p->add_item("Save Scene As..",FILE_SAVE_AS_SCENE,KEY_MASK_SHIFT+KEY_MASK_CMD+KEY_S);
p->add_separator();
- p->add_item("Goto Prev. Scene",FILE_OPEN_PREV,KEY_MASK_SHIFT+KEY_MASK_CMD+KEY_P);
+ p->add_item("Close Scene",FILE_CLOSE,KEY_MASK_SHIFT+KEY_MASK_CTRL+KEY_W);
+ p->add_separator();
+ p->add_item("Close Goto Prev. Scene",FILE_OPEN_PREV,KEY_MASK_SHIFT+KEY_MASK_CMD+KEY_P);
p->add_submenu_item("Open Recent","RecentScenes",FILE_OPEN_RECENT);
p->add_separator();
p->add_item("Quick Open Scene..",FILE_QUICK_OPEN_SCENE,KEY_MASK_SHIFT+KEY_MASK_CMD+KEY_O);
@@ -3617,14 +4571,14 @@ EditorNode::EditorNode() {
- pause_button = memnew( ToolButton );
+ /*pause_button = memnew( ToolButton );
//menu_panel->add_child(pause_button); - not needed for now?
pause_button->set_toggle_mode(true);
pause_button->set_icon(gui_base->get_icon("Pause","EditorIcons"));
pause_button->set_focus_mode(Control::FOCUS_NONE);
pause_button->connect("pressed", this,"_menu_option",make_binds(RUN_PAUSE));
pause_button->set_tooltip("Pause the scene (F7).");
-
+*/
stop_button = memnew( ToolButton );
play_hb->add_child(stop_button);
//stop_button->set_toggle_mode(true);
@@ -3641,7 +4595,7 @@ EditorNode::EditorNode() {
native_play_button->hide();
native_play_button->get_popup()->connect("item_pressed",this,"_run_in_device");
- VSeparator *s1 = memnew( VSeparator );
+// VSeparator *s1 = memnew( VSeparator );
// play_hb->add_child(s1);
play_scene_button = memnew( ToolButton );
@@ -3677,13 +4631,14 @@ EditorNode::EditorNode() {
p->set_item_tooltip(p->get_item_index(RUN_DEPLOY_DUMB_CLIENTS),"Deploy dumb clients when the File Server is active.");
p->connect("item_pressed",this,"_menu_option");
+ /*
run_settings_button = memnew( ToolButton );
//menu_hb->add_child(run_settings_button);
//run_settings_button->set_toggle_mode(true);
run_settings_button->set_focus_mode(Control::FOCUS_NONE);
run_settings_button->set_icon(gui_base->get_icon("Run","EditorIcons"));
run_settings_button->connect("pressed", this,"_menu_option",make_binds(RUN_SCENE_SETTINGS));
-
+*/
/*
run_settings_button = memnew( ToolButton );
@@ -3737,45 +4692,47 @@ EditorNode::EditorNode() {
- editor_hsplit = memnew( HSplitContainer );
- main_split->add_child(editor_hsplit);
- editor_hsplit->set_v_size_flags(Control::SIZE_EXPAND_FILL);
+ //editor_hsplit = memnew( HSplitContainer );
+ //main_split->add_child(editor_hsplit);
+ //editor_hsplit->set_v_size_flags(Control::SIZE_EXPAND_FILL);
- editor_vsplit = memnew( VSplitContainer );
- editor_hsplit->add_child(editor_vsplit);
+ //editor_vsplit = memnew( VSplitContainer );
+ //editor_hsplit->add_child(editor_vsplit);
- top_pallete = memnew( TabContainer );
+ //top_pallete = memnew( TabContainer );
scene_tree_dock = memnew( SceneTreeDock(this,scene_root,editor_selection,editor_data) );
scene_tree_dock->set_name("Scene");
- top_pallete->add_child(scene_tree_dock);
+ //top_pallete->add_child(scene_tree_dock);
+ dock_slot[DOCK_SLOT_LEFT_UR]->add_child(scene_tree_dock);
resources_dock = memnew( ResourcesDock(this) );
resources_dock->set_name("Resources");
- top_pallete->add_child(resources_dock);
- top_pallete->set_v_size_flags(Control::SIZE_EXPAND_FILL);
+ //top_pallete->add_child(resources_dock);
+ dock_slot[DOCK_SLOT_RIGHT_BL]->add_child(resources_dock);
+ //top_pallete->set_v_size_flags(Control::SIZE_EXPAND_FILL);
- Control *editor_spacer = memnew( Control );
+ /*Control *editor_spacer = memnew( Control );
editor_spacer->set_custom_minimum_size(Size2(260,200));
editor_spacer->set_v_size_flags(Control::SIZE_EXPAND_FILL);
editor_vsplit->add_child( editor_spacer );
editor_spacer->add_child( top_pallete );
- top_pallete->set_area_as_parent_rect();
+ top_pallete->set_area_as_parent_rect();*/
- prop_pallete = memnew( TabContainer );
+ //prop_pallete = memnew( TabContainer );
- prop_pallete->set_v_size_flags(Control::SIZE_EXPAND_FILL);
+ //prop_pallete->set_v_size_flags(Control::SIZE_EXPAND_FILL);
- editor_spacer = memnew( Control );
+ /*editor_spacer = memnew( Control );
editor_spacer->set_custom_minimum_size(Size2(260,200));
editor_spacer->set_v_size_flags(Control::SIZE_EXPAND_FILL);
editor_vsplit->add_child( editor_spacer );
editor_spacer->add_child( prop_pallete );
- prop_pallete->set_area_as_parent_rect();
+ prop_pallete->set_area_as_parent_rect();*/
VBoxContainer *prop_editor_base = memnew( VBoxContainer );
prop_editor_base->set_name("Inspector"); // Properties?
- prop_pallete->add_child(prop_editor_base);
+ dock_slot[DOCK_SLOT_RIGHT_UL]->add_child(prop_editor_base);
HBoxContainer *prop_editor_hb = memnew( HBoxContainer );
prop_editor_base->add_child(prop_editor_hb);
@@ -3817,14 +4774,15 @@ EditorNode::EditorNode() {
scenes_dock = memnew( ScenesDock(this) );
scenes_dock->set_name("FileSystem");
- prop_pallete->add_child(scenes_dock);
+ dock_slot[DOCK_SLOT_LEFT_BR]->add_child(scenes_dock);
+ //prop_pallete->add_child(scenes_dock);
scenes_dock->connect("open",this,"open_request");
scenes_dock->connect("instance",this,"_instance_request");
log = memnew( EditorLog );
- left_split->add_child(log);
+ center_split->add_child(log);
log->connect("close_request",this,"_close_messages");
log->connect("show_request",this,"_show_messages");
//left_split->set_dragger_visible(false);
@@ -3840,7 +4798,7 @@ EditorNode::EditorNode() {
animation_vb->add_child(animation_editor);
- left_split->connect("resized",this,"_vp_resized");
+ center_split->connect("resized",this,"_vp_resized");
animation_editor->hide();
@@ -3974,7 +4932,7 @@ EditorNode::EditorNode() {
about->get_ok()->set_text("Thanks!");
about->set_hide_on_ok(true);
Label *about_text = memnew( Label );
- about_text->set_text(VERSION_FULL_NAME"\n(c) 2008-2014 Juan Linietsky, Ariel Manzur.\n");
+ about_text->set_text(VERSION_FULL_NAME"\n(c) 2008-2015 Juan Linietsky, Ariel Manzur.\n");
about_text->set_pos(Point2(gui_base->get_icon("Logo","EditorIcons")->get_size().width+30,20));
gui_base->add_child(about);
about->add_child(about_text);
@@ -3998,7 +4956,7 @@ EditorNode::EditorNode() {
file_templates->add_filter("*.tpz ; Template Package");
- file = memnew( FileDialog );
+ file = memnew( EditorFileDialog );
gui_base->add_child(file);
file->set_current_dir("res://");
@@ -4072,8 +5030,9 @@ EditorNode::EditorNode() {
editor_import_export->add_import_plugin( Ref<EditorTextureImportPlugin>( memnew(EditorTextureImportPlugin(this,EditorTextureImportPlugin::MODE_TEXTURE_2D) )));
- editor_import_export->add_import_plugin( Ref<EditorTextureImportPlugin>( memnew(EditorTextureImportPlugin(this,EditorTextureImportPlugin::MODE_TEXTURE_3D) )));
editor_import_export->add_import_plugin( Ref<EditorTextureImportPlugin>( memnew(EditorTextureImportPlugin(this,EditorTextureImportPlugin::MODE_ATLAS) )));
+ editor_import_export->add_import_plugin( Ref<EditorTextureImportPlugin>( memnew(EditorTextureImportPlugin(this,EditorTextureImportPlugin::MODE_LARGE) )));
+ editor_import_export->add_import_plugin( Ref<EditorTextureImportPlugin>( memnew(EditorTextureImportPlugin(this,EditorTextureImportPlugin::MODE_TEXTURE_3D) )));
Ref<EditorSceneImportPlugin> _scene_import = memnew(EditorSceneImportPlugin(this) );
Ref<EditorSceneImporterCollada> _collada_import = memnew( EditorSceneImporterCollada);
_scene_import->add_importer(_collada_import);
@@ -4111,7 +5070,7 @@ EditorNode::EditorNode() {
add_editor_plugin( memnew( ParticlesEditorPlugin(this) ) );
add_editor_plugin( memnew( ResourcePreloaderEditorPlugin(this) ) );
add_editor_plugin( memnew( ItemListEditorPlugin(this) ) );
- add_editor_plugin( memnew( RichTextEditorPlugin(this) ) );
+ //add_editor_plugin( memnew( RichTextEditorPlugin(this) ) );
add_editor_plugin( memnew( CollisionPolygonEditorPlugin(this) ) );
add_editor_plugin( memnew( CollisionPolygon2DEditorPlugin(this) ) );
add_editor_plugin( memnew( TileSetEditorPlugin(this) ) );
@@ -4124,10 +5083,20 @@ EditorNode::EditorNode() {
add_editor_plugin( memnew( Polygon2DEditorPlugin(this) ) );
add_editor_plugin( memnew( LightOccluder2DEditorPlugin(this) ) );
add_editor_plugin( memnew( NavigationPolygonEditorPlugin(this) ) );
+ add_editor_plugin( memnew( ColorRampEditorPlugin(this) ) );
+ add_editor_plugin( memnew( CollisionShape2DEditorPlugin(this) ) );
for(int i=0;i<EditorPlugins::get_plugin_count();i++)
add_editor_plugin( EditorPlugins::create(i,this) );
+
+ resource_preview->add_preview_generator( Ref<EditorTexturePreviewPlugin>( memnew(EditorTexturePreviewPlugin )));
+ resource_preview->add_preview_generator( Ref<EditorPackedScenePreviewPlugin>( memnew(EditorPackedScenePreviewPlugin )));
+ resource_preview->add_preview_generator( Ref<EditorMaterialPreviewPlugin>( memnew(EditorMaterialPreviewPlugin )));
+ resource_preview->add_preview_generator( Ref<EditorScriptPreviewPlugin>( memnew(EditorScriptPreviewPlugin )));
+ resource_preview->add_preview_generator( Ref<EditorSamplePreviewPlugin>( memnew(EditorSamplePreviewPlugin )));
+ resource_preview->add_preview_generator( Ref<EditorMeshPreviewPlugin>( memnew(EditorMeshPreviewPlugin )));
+
circle_step_msec=OS::get_singleton()->get_ticks_msec();
circle_step_frame=OS::get_singleton()->get_frames_drawn();;
circle_step=0;
@@ -4180,8 +5149,8 @@ EditorNode::EditorNode() {
}
- edited_scene=NULL;
- saved_version=0;
+ //edited_scene=NULL;
+ saved_version=1;
unsaved_cache=true;
_last_instanced_scene=NULL;
@@ -4235,17 +5204,27 @@ EditorNode::EditorNode() {
Node::set_human_readable_collision_renaming(true);
+
+
// Ref<ImageTexture> it = gui_base->get_icon("logo","Icons");
// OS::get_singleton()->set_icon( it->get_data() );
for(int i=0;i<_init_callbacks.size();i++)
_init_callbacks[i]();
+ editor_data.add_edited_scene(-1);
+ editor_data.set_edited_scene(0);
+ _update_scene_tabs();
+
+ _load_docks();
+
+
}
EditorNode::~EditorNode() {
+
memdelete(editor_selection);
memdelete(file_server);
EditorSettings::destroy();