From 282c3924663128f6a2b7ecd86772b01a1b4c82f0 Mon Sep 17 00:00:00 2001 From: tommy3 Date: Thu, 14 May 2015 23:50:15 +0200 Subject: [PATCH 01/41] set initial flag 'show_hidden_files' for file dialogs in project manager initialization --- scene/gui/file_dialog.cpp | 2 +- tools/editor/project_manager.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp index 13cf87ac2ba..285de269b9e 100644 --- a/scene/gui/file_dialog.cpp +++ b/scene/gui/file_dialog.cpp @@ -692,7 +692,7 @@ void FileDialog::set_default_show_hidden_files(bool p_show) { FileDialog::FileDialog() { - show_hidden_files=true; + show_hidden_files=default_show_hidden_files; VBoxContainer *vbc = memnew( VBoxContainer ); add_child(vbc); diff --git a/tools/editor/project_manager.cpp b/tools/editor/project_manager.cpp index 00956919b73..f1eecd53b09 100644 --- a/tools/editor/project_manager.cpp +++ b/tools/editor/project_manager.cpp @@ -819,6 +819,7 @@ ProjectManager::ProjectManager() { if (!EditorSettings::get_singleton()) EditorSettings::create(); + FileDialog::set_default_show_hidden_files(EditorSettings::get_singleton()->get("file_dialog/show_hidden_files")); set_area_as_parent_rect(); Panel *panel = memnew( Panel ); From b459bc549698c9358050030519c487abb6882d8e Mon Sep 17 00:00:00 2001 From: Peace Sells Date: Sun, 24 May 2015 01:04:26 -0600 Subject: [PATCH 02/41] Setting build vs properties in scons. --- SConstruct | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/SConstruct b/SConstruct index 11b35e0b4bb..a1a32383057 100644 --- a/SConstruct +++ b/SConstruct @@ -360,6 +360,11 @@ if selected_platform in platform_list: AddToVSProject(env.scene_sources) AddToVSProject(env.servers_sources) AddToVSProject(env.tool_sources) + + #env['MSVS_VERSION']='9.0' + env['MSVSBUILDCOM'] = "scons platform=" + selected_platform + " target=" + env["target"] + " bits=" + env["bits"] + " tools=yes" + env['MSVSREBUILDCOM'] = "scons platform=" + selected_platform + " target=" + env["target"] + " bits=" + env["bits"] + " tools=yes" + env['MSVSCLEANCOM'] = "scons platform=" + selected_platform + " target=" + env["target"] + " bits=" + env["bits"] + " tools=yes" debug_variants = ['Debug|Win32']+['Debug|x64'] release_variants = ['Release|Win32']+['Release|x64'] From bb659fa875c24c5f708c70438d8bbd371a825e8b Mon Sep 17 00:00:00 2001 From: James McLean Date: Tue, 9 Jun 2015 10:55:23 -0400 Subject: [PATCH 03/41] Added rot/pos constructor for Matrix32 variant. --- core/variant_call.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/variant_call.cpp b/core/variant_call.cpp index 2f7e0205dc7..7dd0eb8a0c5 100644 --- a/core/variant_call.cpp +++ b/core/variant_call.cpp @@ -750,6 +750,12 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var r_ret=Rect2(*p_args[0],*p_args[1],*p_args[2],*p_args[3]); } + static void Matrix32_init2(Variant& r_ret,const Variant** p_args) { + + Matrix32 m(*p_args[0], *p_args[1]); + r_ret=m; + } + static void Matrix32_init3(Variant& r_ret,const Variant** p_args) { Matrix32 m; @@ -1544,6 +1550,7 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl _VariantCall::add_constructor(_VariantCall::Rect2_init1,Variant::RECT2,"pos",Variant::VECTOR2,"size",Variant::VECTOR2); _VariantCall::add_constructor(_VariantCall::Rect2_init2,Variant::RECT2,"x",Variant::REAL,"y",Variant::REAL,"width",Variant::REAL,"height",Variant::REAL); + _VariantCall::add_constructor(_VariantCall::Matrix32_init2,Variant::MATRIX32,"rot",Variant::REAL,"pos",Variant::VECTOR2); _VariantCall::add_constructor(_VariantCall::Matrix32_init3,Variant::MATRIX32,"x_axis",Variant::VECTOR2,"y_axis",Variant::VECTOR2,"origin",Variant::VECTOR2); _VariantCall::add_constructor(_VariantCall::Vector3_init1,Variant::VECTOR3,"x",Variant::REAL,"y",Variant::REAL,"z",Variant::REAL); From 5ffa3f4ff01352fe047cffeddc8681e71af264fc Mon Sep 17 00:00:00 2001 From: volzhs Date: Wed, 10 Jun 2015 02:23:47 +0900 Subject: [PATCH 04/41] add bind method for create_from_fnt (load fnt made by BMFont) --- scene/resources/font.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/scene/resources/font.cpp b/scene/resources/font.cpp index a598c690892..44fa7eadbd3 100644 --- a/scene/resources/font.cpp +++ b/scene/resources/font.cpp @@ -510,6 +510,7 @@ float Font::draw_char(RID p_canvas_item, const Point2& p_pos, const CharType& p_ void Font::_bind_methods() { + ObjectTypeDB::bind_method(_MD("create_from_fnt","path"),&Font::create_from_fnt); ObjectTypeDB::bind_method(_MD("set_height","px"),&Font::set_height); ObjectTypeDB::bind_method(_MD("get_height"),&Font::get_height); From 9bee9e7498c701f7dfbb0f68b69272143216693f Mon Sep 17 00:00:00 2001 From: volzhs Date: Wed, 10 Jun 2015 02:25:34 +0900 Subject: [PATCH 05/41] add bind method for create_from_fnt (load fnt made by BMFont) --- scene/resources/font.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scene/resources/font.cpp b/scene/resources/font.cpp index 44fa7eadbd3..2d93113b405 100644 --- a/scene/resources/font.cpp +++ b/scene/resources/font.cpp @@ -510,7 +510,7 @@ float Font::draw_char(RID p_canvas_item, const Point2& p_pos, const CharType& p_ void Font::_bind_methods() { - ObjectTypeDB::bind_method(_MD("create_from_fnt","path"),&Font::create_from_fnt); + ObjectTypeDB::bind_method(_MD("create_from_fnt","path"),&Font::create_from_fnt); ObjectTypeDB::bind_method(_MD("set_height","px"),&Font::set_height); ObjectTypeDB::bind_method(_MD("get_height"),&Font::get_height); From 394276c45f4e1b256d6450a3ae7341368ace5fca Mon Sep 17 00:00:00 2001 From: krzycho Date: Thu, 11 Jun 2015 04:36:11 +0200 Subject: [PATCH 06/41] ColorRamp new features: - hold alt and left-click to duplicate color - hold shift while grabbing color node to snap selected one to the nearest one if close enough --- scene/gui/color_ramp_edit.cpp | 52 +++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/scene/gui/color_ramp_edit.cpp b/scene/gui/color_ramp_edit.cpp index 382c0dc1031..c39893ac97f 100644 --- a/scene/gui/color_ramp_edit.cpp +++ b/scene/gui/color_ramp_edit.cpp @@ -73,6 +73,31 @@ void ColorRampEdit::_input_event(const InputEvent& p_event) { } } + //Hold alt key to duplicate selected color + if (p_event.type==InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index==1 && p_event.mouse_button.pressed && p_event.key.mod.alt ) { + + int x = p_event.mouse_button.x; + grabbed=_get_point_from_pos(x); + + if( grabbed != -1 ) { + int total_w = get_size().width-get_size().height-3; + ColorRamp::Point newPoint = points[grabbed]; + newPoint.offset=CLAMP(x/float(total_w),0,1); + + points.push_back(newPoint); + points.sort(); + for(int i=0;i Date: Thu, 11 Jun 2015 05:18:13 +0200 Subject: [PATCH 07/41] founded and fixed a bug that freezed godot when deleting while grabbing color in ColorRamp --- scene/gui/color_ramp_edit.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scene/gui/color_ramp_edit.cpp b/scene/gui/color_ramp_edit.cpp index c39893ac97f..14a48fe3d3d 100644 --- a/scene/gui/color_ramp_edit.cpp +++ b/scene/gui/color_ramp_edit.cpp @@ -48,6 +48,7 @@ void ColorRampEdit::_input_event(const InputEvent& p_event) { points.remove(grabbed); grabbed=-1; + grabbing=false; update(); emit_signal("ramp_changed"); accept_event(); @@ -67,6 +68,7 @@ void ColorRampEdit::_input_event(const InputEvent& p_event) { { points.remove(grabbed); grabbed=-1; + grabbing=false; update(); emit_signal("ramp_changed"); accept_event(); From 2287d030a25d8c52d1ebe2303794d6cfa740e6a0 Mon Sep 17 00:00:00 2001 From: krzycho Date: Thu, 11 Jun 2015 14:39:50 +0200 Subject: [PATCH 08/41] fixed problem with crashing godot when changing number of steps while no animation added --- tools/editor/animation_editor.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/editor/animation_editor.cpp b/tools/editor/animation_editor.cpp index bb6f7e9a6f7..d431af6c8d1 100644 --- a/tools/editor/animation_editor.cpp +++ b/tools/editor/animation_editor.cpp @@ -3319,7 +3319,8 @@ void AnimationKeyEditor::_insert_delay() { void AnimationKeyEditor::_step_changed(float p_len) { updating=true; - animation->set_step(p_len); + if (!animation.is_null()) + animation->set_step(p_len); updating=false; } From b19ed63eb6b3aa0fd9cdf54847deff96fd4830df Mon Sep 17 00:00:00 2001 From: James McLean Date: Thu, 11 Jun 2015 10:43:48 -0400 Subject: [PATCH 09/41] Implemented interpolation for affine transformations (Matrix32::interpolate_with) --- core/math/math_2d.cpp | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/core/math/math_2d.cpp b/core/math/math_2d.cpp index 0a3963f88f6..185241e90fb 100644 --- a/core/math/math_2d.cpp +++ b/core/math/math_2d.cpp @@ -622,9 +622,41 @@ float Matrix32::basis_determinant() const { } Matrix32 Matrix32::interpolate_with(const Matrix32& p_transform, float p_c) const { + + //extract parameters + Vector2 p1 = get_origin(); + Vector2 p2 = p_transform.get_origin(); + + float r1 = get_rotation(); + float r2 = p_transform.get_rotation(); + + Vector2 s1 = get_scale(); + Vector2 s2 = p_transform.get_scale(); + + //slerp rotation + Vector2 v1(Math::cos(r1), Math::sin(r1)); + Vector2 v2(Math::cos(r2), Math::sin(r2)); + + float dot = v1.dot(v2); + + dot = (dot < -1.0f) ? -1.0f : ((dot > 1.0f) ? 1.0f : dot); //clamp dot to [-1,1] + + Vector2 v; - - return Matrix32(); + if (dot > 0.9995f) { + v = Vector2::linear_interpolate(v1, v2, p_c); //linearly interpolate to avoid numerical precision issues + v.normalize(); + } else { + float angle = Math::acos(dot) * p_c; + Vector2 v3(v2 - v1 * dot); + v3.normalize(); + v = v1 * Math::cos(angle) + v3 * Math::sin(angle); + } + + //construct matrix + Matrix32 res(Math::atan2(v.y, v.x), Vector2::linear_interpolate(p1, p2, p_c)); + res.scale(Vector2::linear_interpolate(s1, s2, p_c)); + return res; } Matrix32::operator String() const { From c2181285eb225065a9b72f473c7a7a24949a7fe2 Mon Sep 17 00:00:00 2001 From: James McLean Date: Thu, 11 Jun 2015 13:44:04 -0400 Subject: [PATCH 10/41] Changed 'scale' to 'scale_basis' in 'interpolate_with'. --- core/math/math_2d.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/math/math_2d.cpp b/core/math/math_2d.cpp index 185241e90fb..cdb9363b9d2 100644 --- a/core/math/math_2d.cpp +++ b/core/math/math_2d.cpp @@ -655,7 +655,7 @@ Matrix32 Matrix32::interpolate_with(const Matrix32& p_transform, float p_c) cons //construct matrix Matrix32 res(Math::atan2(v.y, v.x), Vector2::linear_interpolate(p1, p2, p_c)); - res.scale(Vector2::linear_interpolate(s1, s2, p_c)); + res.scale_basis(Vector2::linear_interpolate(s1, s2, p_c)); return res; } From 2e6d3b7fadc524f8bdc19929659da365d14ad759 Mon Sep 17 00:00:00 2001 From: James McLean Date: Thu, 11 Jun 2015 21:37:54 -0400 Subject: [PATCH 11/41] Changed floats to 'real_t'. --- core/math/math_2d.cpp | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/core/math/math_2d.cpp b/core/math/math_2d.cpp index cdb9363b9d2..88717723ce1 100644 --- a/core/math/math_2d.cpp +++ b/core/math/math_2d.cpp @@ -627,8 +627,8 @@ Matrix32 Matrix32::interpolate_with(const Matrix32& p_transform, float p_c) cons Vector2 p1 = get_origin(); Vector2 p2 = p_transform.get_origin(); - float r1 = get_rotation(); - float r2 = p_transform.get_rotation(); + real_t r1 = get_rotation(); + real_t r2 = p_transform.get_rotation(); Vector2 s1 = get_scale(); Vector2 s2 = p_transform.get_scale(); @@ -637,20 +637,18 @@ Matrix32 Matrix32::interpolate_with(const Matrix32& p_transform, float p_c) cons Vector2 v1(Math::cos(r1), Math::sin(r1)); Vector2 v2(Math::cos(r2), Math::sin(r2)); - float dot = v1.dot(v2); + real_t dot = v1.dot(v2); - dot = (dot < -1.0f) ? -1.0f : ((dot > 1.0f) ? 1.0f : dot); //clamp dot to [-1,1] + dot = (dot < -1.0) ? -1.0 : ((dot > 1.0) ? 1.0 : dot); //clamp dot to [-1,1] Vector2 v; - if (dot > 0.9995f) { - v = Vector2::linear_interpolate(v1, v2, p_c); //linearly interpolate to avoid numerical precision issues - v.normalize(); + if (dot > 0.9995) { + v = Vector2::linear_interpolate(v1, v2, p_c).normalized(); //linearly interpolate to avoid numerical precision issues } else { - float angle = Math::acos(dot) * p_c; - Vector2 v3(v2 - v1 * dot); - v3.normalize(); - v = v1 * Math::cos(angle) + v3 * Math::sin(angle); + real_t angle = p_c*Math::acos(dot); + Vector2 v3 = (v2 - v1*dot).normalized(); + v = v1*Math::cos(angle) + v3*Math::sin(angle); } //construct matrix From 5a0de04eb739606a49ba828634c051c0e7552291 Mon Sep 17 00:00:00 2001 From: Bojidar Marinov Date: Sat, 13 Jun 2015 14:43:12 +0300 Subject: [PATCH 12/41] Resolved a merge conflict. --- demos/2d/motion/engine.cfg | 3 --- 1 file changed, 3 deletions(-) diff --git a/demos/2d/motion/engine.cfg b/demos/2d/motion/engine.cfg index 29c4d0da203..261111904ce 100644 --- a/demos/2d/motion/engine.cfg +++ b/demos/2d/motion/engine.cfg @@ -3,12 +3,9 @@ name="Motion Test" main_scene="res://motion.scn" -<<<<<<< HEAD -======= [display] width=800 height=600 stretch_mode="2d" stretch_aspect="keep" ->>>>>>> ab99671bb835a5fe24a092ec34afe1ad862ac254 From 852bf95c0c531ec1b0821dbfdb1c6f4744b8324d Mon Sep 17 00:00:00 2001 From: Bojidar Marinov Date: Sat, 13 Jun 2015 14:47:22 +0300 Subject: [PATCH 13/41] Delete .fscache from fog_of_war demo, closes #2079. --- demos/2d/fog_of_war/.fscache | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 demos/2d/fog_of_war/.fscache diff --git a/demos/2d/fog_of_war/.fscache b/demos/2d/fog_of_war/.fscache deleted file mode 100644 index ba5e3995f3e..00000000000 --- a/demos/2d/fog_of_war/.fscache +++ /dev/null @@ -1,11 +0,0 @@ -::res://::1422910453 -floor.png::ImageTexture::1422910453:: -fog.gd::GDScript::1422910025:: -fog.png::ImageTexture::1422908128:: -fog.scn::PackedScene::1422909435:: -fog.xml::TileSet::1422909324:: -icon.png::ImageTexture::1422811193:: -tile_edit.scn::PackedScene::1422909313:: -troll.gd::GDScript::1422909940:: -troll.png::ImageTexture::1418669358:: -troll.scn::PackedScene::1418669358:: From 7c0051beac315ad9c8896064d24ae362f5a65f7f Mon Sep 17 00:00:00 2001 From: Jaguar Date: Sat, 13 Jun 2015 14:10:06 -0400 Subject: [PATCH 14/41] Fixed variables being set before calling the setter method --- modules/gdscript/gd_script.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/gdscript/gd_script.cpp b/modules/gdscript/gd_script.cpp index ceca1ff2b9d..70a5fd985cd 100644 --- a/modules/gdscript/gd_script.cpp +++ b/modules/gdscript/gd_script.cpp @@ -2131,7 +2131,6 @@ bool GDInstance::set(const StringName& p_name, const Variant& p_value) { { const Map::Element *E = script->member_indices.find(p_name); if (E) { - members[E->get().index]=p_value; if (E->get().setter) { const Variant *val=&p_value; Variant::CallError err; @@ -2140,6 +2139,8 @@ bool GDInstance::set(const StringName& p_name, const Variant& p_value) { return true; //function exists, call was successful } } + else + members[E->get().index] = p_value; return true; } } From 839d69502c5c1769c662bb353e0f6db3517e2de2 Mon Sep 17 00:00:00 2001 From: volzhs Date: Mon, 15 Jun 2015 08:57:14 +0900 Subject: [PATCH 15/41] fix register Physics2DTestMotionResult --- servers/register_server_types.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/servers/register_server_types.cpp b/servers/register_server_types.cpp index d35b6e1e5fb..3634a03dbc6 100644 --- a/servers/register_server_types.cpp +++ b/servers/register_server_types.cpp @@ -55,7 +55,7 @@ void register_server_types() { ObjectTypeDB::register_virtual_type(); ObjectTypeDB::register_virtual_type(); ObjectTypeDB::register_virtual_type(); - ObjectTypeDB::register_virtual_type(); + ObjectTypeDB::register_type(); ObjectTypeDB::register_type(); ObjectTypeDB::register_type(); From 14cd70faf3b9e431821613b06397973f047cbfc0 Mon Sep 17 00:00:00 2001 From: sanikoyes Date: Tue, 16 Jun 2015 15:15:10 +0800 Subject: [PATCH 16/41] Script editor: restore line/column after script reload --- tools/editor/plugins/script_editor_plugin.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tools/editor/plugins/script_editor_plugin.cpp b/tools/editor/plugins/script_editor_plugin.cpp index f5ba6a08e64..c04f74475c3 100644 --- a/tools/editor/plugins/script_editor_plugin.cpp +++ b/tools/editor/plugins/script_editor_plugin.cpp @@ -286,8 +286,19 @@ void ScriptTextEditor::reload_text() { ERR_FAIL_COND(script.is_null()) ; - get_text_edit()->set_text(script->get_source_code()); - get_text_edit()->clear_undo_history(); + TextEdit *te = get_text_edit(); + int column = te->cursor_get_column(); + int row = te->cursor_get_line(); + int h = te->get_h_scroll(); + int v = te->get_v_scroll(); + + te->set_text(script->get_source_code()); + te->clear_undo_history(); + te->cursor_set_line(row); + te->cursor_set_column(column); + te->set_h_scroll(h); + te->set_v_scroll(v); + _line_col_changed(); } From aa4211d47773f7b2f3f20dad0166f9e30ff4c6d4 Mon Sep 17 00:00:00 2001 From: Peace Sells Date: Fri, 19 Jun 2015 21:40:38 -0600 Subject: [PATCH 17/41] Hide projects folder. --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index fbb3ba6cb42..613eff442a2 100644 --- a/.gitignore +++ b/.gitignore @@ -281,3 +281,5 @@ cscope.out cscope.in.out cscope.po.out godot.creator.* + +projects/ \ No newline at end of file From acbaefcc0274e17fc25736f0d7c6cd7feb176129 Mon Sep 17 00:00:00 2001 From: Guido Berhoerster Date: Sat, 20 Jun 2015 14:47:06 +0200 Subject: [PATCH 18/41] Fix typo that produced invalid markup for images --- tools/export/blender25/io_scene_dae/export_dae.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/export/blender25/io_scene_dae/export_dae.py b/tools/export/blender25/io_scene_dae/export_dae.py index 9568ccb6458..5245f32b82b 100644 --- a/tools/export/blender25/io_scene_dae/export_dae.py +++ b/tools/export/blender25/io_scene_dae/export_dae.py @@ -228,7 +228,7 @@ class DaeExporter: # imgpath="images/"+image.name+".png" self.writel(S_IMGS,1,'') - self.writel(S_IMGS,2,''+imgpath+'"/>') + self.writel(S_IMGS,2,''+imgpath+'') self.writel(S_IMGS,1,'') self.image_cache[image]=imgid return imgid From 6edbab0a9fed4a3ea9988b4054c42ce96a43d143 Mon Sep 17 00:00:00 2001 From: Peace Sells Date: Sun, 24 May 2015 01:04:26 -0600 Subject: [PATCH 19/41] Setting build vs properties in scons. --- SConstruct | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/SConstruct b/SConstruct index 11b35e0b4bb..a1a32383057 100644 --- a/SConstruct +++ b/SConstruct @@ -360,6 +360,11 @@ if selected_platform in platform_list: AddToVSProject(env.scene_sources) AddToVSProject(env.servers_sources) AddToVSProject(env.tool_sources) + + #env['MSVS_VERSION']='9.0' + env['MSVSBUILDCOM'] = "scons platform=" + selected_platform + " target=" + env["target"] + " bits=" + env["bits"] + " tools=yes" + env['MSVSREBUILDCOM'] = "scons platform=" + selected_platform + " target=" + env["target"] + " bits=" + env["bits"] + " tools=yes" + env['MSVSCLEANCOM'] = "scons platform=" + selected_platform + " target=" + env["target"] + " bits=" + env["bits"] + " tools=yes" debug_variants = ['Debug|Win32']+['Debug|x64'] release_variants = ['Release|Win32']+['Release|x64'] From d65455185a2e72bbbf5aaa8943643a49cd811fce Mon Sep 17 00:00:00 2001 From: krzycho Date: Sun, 21 Jun 2015 21:55:47 +0200 Subject: [PATCH 20/41] - added GDscript bidings for UndoRedo class mechanizm - registered UndoRedo --- core/undo_redo.cpp | 120 +++++++++++++++++++++++++++++++++++ core/undo_redo.h | 7 ++ doc/base/classes.xml | 2 +- tools/editor/editor_node.cpp | 1 + 4 files changed, 129 insertions(+), 1 deletion(-) diff --git a/core/undo_redo.cpp b/core/undo_redo.cpp index 5e7df3be7e6..a93e469f3fc 100644 --- a/core/undo_redo.cpp +++ b/core/undo_redo.cpp @@ -339,3 +339,123 @@ UndoRedo::~UndoRedo() { clear_history(); } + +Variant UndoRedo::_add_do_method(const Variant** p_args, int p_argcount, Variant::CallError& r_error) { + + if (p_argcount<1) { + r_error.error=Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS; + r_error.argument=0; + return Variant(); + } + + if (p_args[0]->get_type()!=Variant::OBJECT) { + r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT; + r_error.argument=0; + r_error.expected=Variant::OBJECT; + return Variant(); + } + + if (p_args[1]->get_type()!=Variant::STRING) { + r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT; + r_error.argument=1; + r_error.expected=Variant::STRING; + return Variant(); + } + + r_error.error=Variant::CallError::CALL_OK; + + Object* object = *p_args[0]; + String method = *p_args[1]; + + Variant v[VARIANT_ARG_MAX]; + + + for(int i=0;iget_type()!=Variant::OBJECT) { + r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT; + r_error.argument=0; + r_error.expected=Variant::OBJECT; + return Variant(); + } + + if (p_args[1]->get_type()!=Variant::STRING) { + r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT; + r_error.argument=1; + r_error.expected=Variant::STRING; + return Variant(); + } + + r_error.error=Variant::CallError::CALL_OK; + + Object* object = *p_args[0]; + String method = *p_args[1]; + + Variant v[VARIANT_ARG_MAX]; + + + for(int i=0;i defargs; + for(int i=0;i defargs; + for(int i=0;i - + diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp index 373c8aba737..ce96e0b6f53 100644 --- a/tools/editor/editor_node.cpp +++ b/tools/editor/editor_node.cpp @@ -3236,6 +3236,7 @@ void EditorNode::register_editor_types() { ObjectTypeDB::register_type(); ObjectTypeDB::register_type(); ObjectTypeDB::register_type(); + ObjectTypeDB::register_type(); //ObjectTypeDB::register_type(); From e9bbb97acccc08ae03fde41e4cc6d2dc6722021a Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Mon, 22 Jun 2015 00:03:19 -0300 Subject: [PATCH 21/41] Multiple scene editing *POTENTIALLY UNSTABLE* -ability to edit multiple scenes at the same time -resource internal IDs are now persistent, this makes multiple scene editing possible but maaaaay result in file corruption bugs (tested and could not find anything but possibility exists because core code changed, report immediately if you find this). -properly save settings, layout, etc when edited -script editing is independent from scene editing now -show a yellow box when a script belongs to the scene --- core/io/resource_format_binary.cpp | 50 +- core/io/resource_format_binary.h | 2 +- core/io/resource_format_xml.cpp | 48 +- core/io/resource_format_xml.h | 2 +- core/object.cpp | 58 +++ core/object.h | 7 + core/resource.cpp | 12 + core/resource.h | 4 + core/undo_redo.cpp | 5 +- demos/2d/space_shooter/level_tiles.scn | Bin 2148 -> 2168 bytes modules/gdscript/gd_editor.cpp | 2 +- scene/gui/item_list.cpp | 60 ++- scene/gui/item_list.h | 9 + scene/gui/tabs.cpp | 48 +- scene/gui/tabs.h | 16 + scene/gui/tree.h | 2 + scene/main/node.cpp | 10 + scene/main/node.h | 2 + scene/resources/default_theme/selection.png | Bin 338 -> 319 bytes .../resources/default_theme/selection_oof.png | Bin 338 -> 321 bytes scene/resources/default_theme/theme_data.h | 4 +- tools/editor/editor_data.cpp | 173 +++++++ tools/editor/editor_data.h | 44 ++ tools/editor/editor_node.cpp | 489 +++++++++++++++--- tools/editor/editor_node.h | 33 +- tools/editor/editor_plugin.cpp | 7 + tools/editor/editor_plugin.h | 4 +- tools/editor/editor_run_script.cpp | 2 +- tools/editor/editor_settings.cpp | 2 + tools/editor/icons/icon_panel_top.png | Bin 0 -> 195 bytes .../io_plugins/editor_mesh_import_plugin.cpp | 2 +- .../plugins/multimesh_editor_plugin.cpp | 2 +- tools/editor/plugins/script_editor_plugin.cpp | 393 ++++++++------ tools/editor/plugins/script_editor_plugin.h | 52 +- tools/editor/property_editor.cpp | 2 +- tools/editor/scene_tree_dock.h | 1 + tools/editor/scene_tree_editor.h | 5 +- 37 files changed, 1268 insertions(+), 284 deletions(-) create mode 100644 tools/editor/icons/icon_panel_top.png diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp index 9fb17bcffbb..0f6f8a74b11 100644 --- a/core/io/resource_format_binary.cpp +++ b/core/io/resource_format_binary.cpp @@ -663,14 +663,18 @@ Error ResourceInteractiveLoaderBinary::poll(){ //maybe it is loaded already String path; + int subindex=0; if (!main) { path=internal_resources[s].path; - if (path.begins_with("local://")) - path=path.replace("local://",res_path+"::"); + if (path.begins_with("local://")) { + path=path.replace_first("local://",""); + subindex = path.to_int(); + path=res_path+"::"+path; + } @@ -709,6 +713,7 @@ Error ResourceInteractiveLoaderBinary::poll(){ RES res = RES( r ); r->set_path(path); + r->set_subindex(subindex); int pc = f->get_32(); @@ -1434,14 +1439,14 @@ void ResourceFormatSaverBinaryInstance::write_variant(const Variant& p_property, save_unicode_string(path); } else { - if (!resource_map.has(res)) { + if (!resource_set.has(res)) { f->store_32(OBJECT_EMPTY); ERR_EXPLAIN("Resource was not pre cached for the resource section, bug?"); ERR_FAIL(); } f->store_32(OBJECT_INTERNAL_RESOURCE); - f->store_32(resource_map[res]); + f->store_32(res->get_subindex()); //internal resource } @@ -1598,7 +1603,7 @@ void ResourceFormatSaverBinaryInstance::_find_resources(const Variant& p_variant } - if (resource_map.has(res)) + if (resource_set.has(res)) return; List property_list; @@ -1613,7 +1618,7 @@ void ResourceFormatSaverBinaryInstance::_find_resources(const Variant& p_variant } } - resource_map[ res ] = saved_resources.size(); + resource_set.insert(res); saved_resources.push_back(res); } break; @@ -1846,11 +1851,42 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path,const RES& p_ // save internal resource table f->store_32(saved_resources.size()); //amount of internal resources Vector ofs_pos; + Set used_indices; + for(List::Element *E=saved_resources.front();E;E=E->next()) { RES r = E->get(); if (r->get_path()=="" || r->get_path().find("::")!=-1) { - save_unicode_string("local://"+itos(ofs_pos.size())); + + if (r->get_subindex()!=0) { + if (used_indices.has(r->get_subindex())) { + r->set_subindex(0); //repeated + } else { + used_indices.insert(r->get_subindex()); + } + } + } + + } + + + for(List::Element *E=saved_resources.front();E;E=E->next()) { + + + RES r = E->get(); + if (r->get_path()=="" || r->get_path().find("::")!=-1) { + if (r->get_subindex()==0) { + int new_subindex=1; + if (used_indices.size()) { + new_subindex=used_indices.back()->get()+1; + } + + r->set_subindex(new_subindex); + used_indices.insert(new_subindex); + + } + + save_unicode_string("local://"+itos(r->get_subindex())); if (takeover_paths) { r->set_path(p_path+"::"+itos(ofs_pos.size()),true); } diff --git a/core/io/resource_format_binary.h b/core/io/resource_format_binary.h index ab2e640a86f..da415d97a52 100644 --- a/core/io/resource_format_binary.h +++ b/core/io/resource_format_binary.h @@ -129,7 +129,7 @@ class ResourceFormatSaverBinaryInstance { int bin_meta_idx; FileAccess *f; String magic; - Map resource_map; + Set resource_set; Map string_map; Vector strings; diff --git a/core/io/resource_format_xml.cpp b/core/io/resource_format_xml.cpp index 3c100d375a0..36746a41118 100644 --- a/core/io/resource_format_xml.cpp +++ b/core/io/resource_format_xml.cpp @@ -1466,6 +1466,7 @@ Error ResourceInteractiveLoaderXML::poll() { String type; String path; + int subres=0; if (!main) { //loading resource @@ -1476,11 +1477,15 @@ Error ResourceInteractiveLoaderXML::poll() { ERR_EXPLAIN(local_path+":"+itos(get_current_line())+": missing 'type' field."); ERR_FAIL_COND_V(!tag->args.has("type"),ERR_FILE_CORRUPT); path=tag->args["path"]; + error=OK; if (path.begins_with("local://")) { //built-in resource (but really external) - path=path.replace("local://",local_path+"::"); + + path=path.replace("local://",""); + subres=path.to_int(); + path=local_path+"::"+path; } @@ -1519,6 +1524,7 @@ Error ResourceInteractiveLoaderXML::poll() { res = RES( r ); if (path!="") r->set_path(path); + r->set_subindex(subres); //load properties @@ -2029,9 +2035,9 @@ void ResourceFormatSaverXMLInstance::write_property(const String& p_name,const V //internal resource ERR_EXPLAIN("Resource was not pre cached for the resource section, bug?"); - ERR_FAIL_COND(!resource_map.has(res)); + ERR_FAIL_COND(!resource_set.has(res)); - params+=" path=\"local://"+itos(resource_map[res])+"\""; + params+=" path=\"local://"+itos(res->get_subindex())+"\""; } } break; @@ -2443,7 +2449,7 @@ void ResourceFormatSaverXMLInstance::_find_resources(const Variant& p_variant,bo return; } - if (resource_map.has(res)) + if (resource_set.has(res)) return; List property_list; @@ -2466,7 +2472,7 @@ void ResourceFormatSaverXMLInstance::_find_resources(const Variant& p_variant,bo I=I->next(); } - resource_map[ res ] = resource_map.size(); //saved after, so the childs it needs are available when loaded + resource_set.insert( res ); //saved after, so the childs it needs are available when loaded saved_resources.push_back(res); } break; @@ -2537,12 +2543,27 @@ Error ResourceFormatSaverXMLInstance::save(const String &p_path,const RES& p_res write_string("\n",false); } - + Set used_indices; for(List::Element *E=saved_resources.front();E;E=E->next()) { RES res = E->get(); - ERR_CONTINUE(!resource_map.has(res)); + if (E->next() && (res->get_path()=="" || res->get_path().find("::") != -1 )) { + + if (res->get_subindex()!=0) { + if (used_indices.has(res->get_subindex())) { + res->set_subindex(0); //repeated + } else { + used_indices.insert(res->get_subindex()); + } + } + } + } + + for(List::Element *E=saved_resources.front();E;E=E->next()) { + + RES res = E->get(); + ERR_CONTINUE(!resource_set.has(res)); bool main = (E->next()==NULL); write_tabs(); @@ -2552,7 +2573,18 @@ Error ResourceFormatSaverXMLInstance::save(const String &p_path,const RES& p_res else if (res->get_path().length() && res->get_path().find("::") == -1 ) enter_tag("resource","type=\""+res->get_type()+"\" path=\""+res->get_path()+"\""); //bundled else { - int idx = resource_map[res]; + + if (res->get_subindex()==0) { + int new_subindex=1; + if (used_indices.size()) { + new_subindex=used_indices.back()->get()+1; + } + + res->set_subindex(new_subindex); + used_indices.insert(new_subindex); + } + + int idx = res->get_subindex(); enter_tag("resource","type=\""+res->get_type()+"\" path=\"local://"+itos(idx)+"\""); if (takeover_paths) { res->set_path(p_path+"::"+itos(idx),true); diff --git a/core/io/resource_format_xml.h b/core/io/resource_format_xml.h index 711b6076680..d5ba9eb8001 100644 --- a/core/io/resource_format_xml.h +++ b/core/io/resource_format_xml.h @@ -123,7 +123,7 @@ class ResourceFormatSaverXMLInstance { bool skip_editor; FileAccess *f; int depth; - Map resource_map; + Set resource_set; List saved_resources; List external_resources; diff --git a/core/object.cpp b/core/object.cpp index 83a6dada802..cdb2c6517a4 100644 --- a/core/object.cpp +++ b/core/object.cpp @@ -34,6 +34,7 @@ #include "core_string_names.h" #include "translation.h" #include "os/os.h" +#include "resource.h" #ifdef DEBUG_ENABLED @@ -1464,6 +1465,63 @@ StringName Object::tr(const StringName& p_message) const { } + +void Object::_clear_internal_resource_paths(const Variant &p_var) { + + switch(p_var.get_type()) { + + case Variant::OBJECT: { + + RES r = p_var; + if (!r.is_valid()) + return; + + if (!r->get_path().begins_with("res://") || r->get_path().find("::")==-1) + return; //not an internal resource + + Object *object=p_var; + if (!object) + return; + + r->set_path(""); + r->clear_internal_resource_paths(); + } break; + case Variant::ARRAY: { + + Array a=p_var; + for(int i=0;i keys; + d.get_key_list(&keys); + + for (List::Element *E=keys.front();E;E=E->next()) { + + _clear_internal_resource_paths(E->get()); + _clear_internal_resource_paths(d[E->get()]); + } + } break; + } + +} + +void Object::clear_internal_resource_paths() { + + List pinfo; + + get_property_list(&pinfo); + + for(List::Element *E=pinfo.front();E;E=E->next()) { + + _clear_internal_resource_paths(get(E->get().name)); + } +} + void Object::_bind_methods() { ObjectTypeDB::bind_method(_MD("get_type"),&Object::get_type); diff --git a/core/object.h b/core/object.h index 8d1f8ebc5a5..9680af924a4 100644 --- a/core/object.h +++ b/core/object.h @@ -451,6 +451,8 @@ protected: Array _get_property_list_bind() const; Array _get_method_list_bind() const; + void _clear_internal_resource_paths(const Variant &p_var); + public: //should be protected, but bug in clang++ static void initialize_type(); _FORCE_INLINE_ static void register_custom_data_to_otdb() {}; @@ -599,6 +601,9 @@ public: _FORCE_INLINE_ void set_message_translation(bool p_enable) { _can_translate=p_enable; } _FORCE_INLINE_ bool can_translate_messages() const { return _can_translate; } + + void clear_internal_resource_paths(); + Object(); virtual ~Object(); @@ -651,6 +656,8 @@ public: #endif + + }; //needed by macros diff --git a/core/resource.cpp b/core/resource.cpp index 6e65693350c..6967599f96e 100644 --- a/core/resource.cpp +++ b/core/resource.cpp @@ -195,6 +195,17 @@ String Resource::get_path() const { return path_cache; } +void Resource::set_subindex(int p_sub_index) { + + subindex=p_sub_index; +} + +int Resource::get_subindex() const{ + + return subindex; +} + + void Resource::set_name(const String& p_name) { name=p_name; @@ -326,6 +337,7 @@ Resource::Resource() { last_modified_time=0; #endif + subindex=0; } diff --git a/core/resource.h b/core/resource.h index cf7ffcbd2c2..9d9c445e1d3 100644 --- a/core/resource.h +++ b/core/resource.h @@ -99,6 +99,7 @@ friend class ResourceCache; String name; String path_cache; + int subindex; virtual bool _use_builtin_script() const { return true; } @@ -132,6 +133,9 @@ public: void set_path(const String& p_path,bool p_take_over=false); String get_path() const; + void set_subindex(int p_sub_index); + int get_subindex() const; + Ref duplicate(bool p_subresources=false); void set_import_metadata(const Ref& p_metadata); diff --git a/core/undo_redo.cpp b/core/undo_redo.cpp index 5e7df3be7e6..90ca397275c 100644 --- a/core/undo_redo.cpp +++ b/core/undo_redo.cpp @@ -282,6 +282,7 @@ void UndoRedo::undo() { return; //nothing to redo _process_operation_list(actions[current_action].undo_ops.front()); current_action--; + version--; } void UndoRedo::clear_history() { @@ -292,7 +293,7 @@ void UndoRedo::clear_history() { while(actions.size()) _pop_history_tail(); - version++; + //version++; } String UndoRedo::get_current_action_name() const { @@ -326,7 +327,7 @@ void UndoRedo::set_commit_notify_callback(CommitNotifyCallback p_callback,void* UndoRedo::UndoRedo() { - version=0; + version=1; action_level=0; current_action=-1; max_steps=-1; diff --git a/demos/2d/space_shooter/level_tiles.scn b/demos/2d/space_shooter/level_tiles.scn index 3fb91d8cb3016445824c4fac710ecaccf474e9a4..4d1feea70f325680b188e1c284d6ed8e1f1a9c77 100644 GIT binary patch delta 448 zcmV;x0YCoa5cm)lQd2`i0000001yBG2@n7PO9%h}5de`AsR}Uw6kv|v1r-7^vBmEM z8N`PG5?~xaGr$1g0SiEhL1RaS26F%)005KF1r!3nS(E4m9RW*|1_t>7c9I7fe<%n* znIFNdYrX&g0X<1XK~z|U?Ud1O!Y~X)@3jks?LYV${+}OdpE0x{+QfGc1vKq-Mp>nt zrzDkPA2&9S$0OE^wNBszuXKUdfC3+^USP<*u9C%!Cy59BuElO$c!XG0#N7~e;~OB21g|YAHM8%M(#HRaK17kVo0oD3Pr?R ztDBJ~BE;n|A_U~uKV2PQ{5X$q@3@bgCF9roS3aQ!k_8Mv{Lb=O6Z8>r)qvyR3;M1&07*qoM6M4)V1fVuQd3ex000000000|Q$s_!wXZk; delta 429 zcmV;e0aE_>5abXNQd2`i0000001yBG@ecq1ObC${sR}Rv6kv|v1r-7@vB~cQ97Kme z000s|1Yk4306;&006>XBV@HJoa{wS96qC^f6a+w7Kns)S1swrDlLZF(0bY~;1{r@L z2tb)1=A$}x0003cNkl=Ug2A!2gATfv04C3*4#2=QC*a?J^1Y(l}VzYUHEb#ofC_H&xJC{w;zWeDs%mB=+-en(7)v4s- zfi*f9;T0%z^~#@NGH{tEZvZfiI2g9^gidWAi=rs2JqS^b!?<{(=zgUFgilSO&o8Lv zc@98@Ixl8M3Ky3(Mi9aU4#NNdU3U#v?A|{%|CLAru}R& p_texture,bool item.selectable=p_selectable; item.selected=false; item.disabled=false; + item.custom_bg=Color(0,0,0,0); items.push_back(item); update(); @@ -26,6 +27,7 @@ void ItemList::add_icon_item(const Ref& p_item,bool p_selectable){ item.selectable=p_selectable; item.selected=false; item.disabled=false; + item.custom_bg=Color(0,0,0,0); items.push_back(item); update(); @@ -85,6 +87,23 @@ Ref ItemList::get_item_icon(int p_idx) const{ } +void ItemList::set_item_custom_bg_color(int p_idx,const Color& p_custom_bg_color) { + + ERR_FAIL_INDEX(p_idx,items.size()); + + items[p_idx].custom_bg=p_custom_bg_color; + +} + +Color ItemList::get_item_custom_bg_color(int p_idx) const { + + ERR_FAIL_INDEX_V(p_idx,items.size(),Color()); + + return items[p_idx].custom_bg; + +} + + void ItemList::set_item_tag_icon(int p_idx,const Ref& p_tag_icon){ @@ -635,6 +654,7 @@ void ItemList::_notification(int p_what) { Ref font = get_font("font"); Color guide_color = get_color("guide_color"); Color font_color = get_color("font_color"); + Color font_color_selected = get_color("font_color_selected"); int font_height = font->get_height(); Vector line_size_cache; Vector line_limit_cache; @@ -781,6 +801,11 @@ void ItemList::_notification(int p_what) { if (current_columns==1) { rcache.size.width = width-rcache.pos.x; } + if (items[i].custom_bg.a>0.001) { + Rect2 r=rcache; + r.pos+=base_ofs; + draw_rect(r,items[i].custom_bg); + } if (items[i].selected) { Rect2 r=rcache; r.pos+=base_ofs; @@ -864,7 +889,7 @@ void ItemList::_notification(int p_what) { if (line>=max_text_lines) break; } - ofs+=font->draw_char(get_canvas_item(),text_ofs+Vector2(ofs+(max_len-line_size_cache[line])/2,line*(font_height+line_separation)).floor(),items[i].text[j],items[i].text[j+1],font_color); + ofs+=font->draw_char(get_canvas_item(),text_ofs+Vector2(ofs+(max_len-line_size_cache[line])/2,line*(font_height+line_separation)).floor(),items[i].text[j],items[i].text[j+1],items[i].selected?font_color_selected:font_color); } //special multiline mode @@ -884,7 +909,7 @@ void ItemList::_notification(int p_what) { text_ofs+=base_ofs; text_ofs+=items[i].rect_cache.pos; - draw_string(font,text_ofs,items[i].text,font_color,max_len+1); + draw_string(font,text_ofs,items[i].text,items[i].selected?font_color_selected:font_color,max_len+1); } @@ -954,6 +979,30 @@ String ItemList::get_tooltip(const Point2& p_pos) const { } +void ItemList::sort_items_by_text() { + items.sort(); + update(); + if (select_mode==SELECT_SINGLE) { + for(int i=0;i=tabs[i].ofs_cache && pos.xget_margin(MARGIN_RIGHT); - tabs[i].ofs_cache=w; + tabs[i].size_cache=w-tabs[i].ofs_cache; } @@ -195,7 +210,7 @@ void Tabs::set_current_tab(int p_current) { current=p_current; _change_notify("current_tab"); - emit_signal("tab_changed",current); + //emit_signal("tab_changed",current); update(); } @@ -249,6 +264,12 @@ void Tabs::add_tab(const String& p_str,const Ref& p_icon) { } +void Tabs::clear_tabs() { + tabs.clear(); + current=0; + update(); +} + void Tabs::remove_tab(int p_idx) { ERR_FAIL_INDEX(p_idx,tabs.size()); @@ -263,10 +284,21 @@ void Tabs::remove_tab(int p_idx) { if (current>=tabs.size()) current=tabs.size()-1; - emit_signal("tab_changed",current); + //emit_signal("tab_changed",current); } +void Tabs::set_tab_align(TabAlign p_align) { + + tab_align=p_align; + update(); +} + +Tabs::TabAlign Tabs::get_tab_align() const { + + return tab_align; +} + void Tabs::_bind_methods() { @@ -280,15 +312,21 @@ void Tabs::_bind_methods() { ObjectTypeDB::bind_method(_MD("get_tab_icon:Texture","tab_idx"),&Tabs::get_tab_icon); ObjectTypeDB::bind_method(_MD("remove_tab","tab_idx"),&Tabs::remove_tab); ObjectTypeDB::bind_method(_MD("add_tab","title","icon:Texture"),&Tabs::add_tab); + ObjectTypeDB::bind_method(_MD("set_tab_align","align"),&Tabs::set_tab_align); + ObjectTypeDB::bind_method(_MD("get_tab_align"),&Tabs::get_tab_align); ADD_SIGNAL(MethodInfo("tab_changed",PropertyInfo(Variant::INT,"tab"))); ADD_PROPERTY( PropertyInfo(Variant::INT, "current_tab", PROPERTY_HINT_RANGE,"-1,4096,1",PROPERTY_USAGE_EDITOR), _SCS("set_current_tab"), _SCS("get_current_tab") ); + BIND_CONSTANT( ALIGN_LEFT ); + BIND_CONSTANT( ALIGN_CENTER ); + BIND_CONSTANT( ALIGN_RIGHT ); } Tabs::Tabs() { current=0; + tab_align=ALIGN_CENTER; } diff --git a/scene/gui/tabs.h b/scene/gui/tabs.h index 4a969928ff2..8d4d0123f89 100644 --- a/scene/gui/tabs.h +++ b/scene/gui/tabs.h @@ -34,6 +34,14 @@ class Tabs : public Control { OBJ_TYPE( Tabs, Control ); +public: + + enum TabAlign { + + ALIGN_LEFT, + ALIGN_CENTER, + ALIGN_RIGHT + }; private: @@ -42,12 +50,14 @@ private: String text; Ref icon; int ofs_cache; + int size_cache; }; Vector tabs; int current; Control *_get_tab(int idx) const; int _get_top_margin() const; + TabAlign tab_align; protected: @@ -65,16 +75,22 @@ public: void set_tab_icon(int p_tab,const Ref& p_icon); Ref get_tab_icon(int p_tab) const; + void set_tab_align(TabAlign p_align); + TabAlign get_tab_align() const; + int get_tab_count() const; void set_current_tab(int p_current); int get_current_tab() const; void remove_tab(int p_idx); + void clear_tabs(); + Size2 get_minimum_size() const; Tabs(); }; +VARIANT_ENUM_CAST(Tabs::TabAlign); #endif // TABS_H diff --git a/scene/gui/tree.h b/scene/gui/tree.h index f03827f542f..8ddddd0630e 100644 --- a/scene/gui/tree.h +++ b/scene/gui/tree.h @@ -454,6 +454,8 @@ public: void set_cursor_can_exit_tree(bool p_enable); bool can_cursor_exit_tree() const; + VScrollBar *get_vscroll_bar() { return v_scroll; } + Tree(); ~Tree(); diff --git a/scene/main/node.cpp b/scene/main/node.cpp index 2530e3a36fd..b7fa5c8301c 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -1816,6 +1816,16 @@ void Node::get_argument_options(const StringName& p_function,int p_idx,Listclear_internal_tree_resource_paths(); + } + +} + void Node::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_name","name"),&Node::set_name); diff --git a/scene/main/node.h b/scene/main/node.h index a89a6abf33a..be91c6e1bbd 100644 --- a/scene/main/node.h +++ b/scene/main/node.h @@ -290,6 +290,8 @@ public: void get_argument_options(const StringName& p_function,int p_idx,List*r_options) const; + void clear_internal_tree_resource_paths(); + _FORCE_INLINE_ Viewport *get_viewport() const { return data.viewport; } /* CANVAS */ diff --git a/scene/resources/default_theme/selection.png b/scene/resources/default_theme/selection.png index 074c7a4d80b2865ddf3d17552b25e7a79783ae3a..3b1c810c400364b3414e8c26247600c7a9183a88 100644 GIT binary patch delta 286 zcmcb_w4Z5$R=p^LD1-QkTK9_#3=EtF9+AZi4BWyX%*Zfnjs#GUy~NYkmHj@Oh=`$7 z{PZJXKq1-8kcblJ{M_8syb>Unfx)>bHL)Z$MWH;iBtya7(>EYRFO?lAzSz^nF~s8Z z+sS*m4mk+4?BAVJ#K9QoeP8+H?{J~{&Km@D>P4PRI(;;a*-VW+Q)fy{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G` z2i^%05-JvjNQ)By000?uMObu0Z*6U5Zgc=ca%Ew3Wn>_CX>@2HM@dakSAh-}0002G zNkl5BQJp&AUy>XI0Hx9InURt&B7=CAR^`?Q}tF>QCM}8>7&z(DkopcG+u=%_k2v-7^Wj zY7(Ma67fh>@?>q#iXTV)IX|*j?Xk%yIMNW?c{=<3+3>s9%iTRdA#!&fIbW}XnYUv>3XLt+2s|0xEKWcJQ*62B9;>Ny(fy7etZj< kV)<~=hFQUq%S^VP3-7;g7%hG;vJT`IPgg&ebxsLQ0N^fj>;M1& delta 305 zcmV-10nYxx0@4DIDt}A>N&rrXDQdO=000SaNLh0L01FcU01FcV0GgZ_00007bV*G` z2i^$~6*3~56qX+V000?uMObu0Z*6U5Zgc=ca%Ew3Wn>_CX>@2HM@dakSAh-}0002G zNklR>2?D%W!pp#mg`}oIPJc~7agh$00@rq=G!$&P z+WAK-%_Q9579FmT%+H8#eBm=D@gwe#&jeI_;4LQS`-k<@y7Xle5wn2S+Bh7C*ZpCa z@E!p_idx) + current_edited_scene--; + else if (current_edited_scene==p_idx && current_edited_scene>0) { + current_edited_scene--; + } + + edited_scene.remove(p_idx); + +} +int EditorData::get_edited_scene() const { + + return current_edited_scene; +} +void EditorData::set_edited_scene(int p_idx){ + + ERR_FAIL_INDEX(p_idx,edited_scene.size()); + current_edited_scene=p_idx; + //swap +} +Node* EditorData::get_edited_scene_root(){ + + ERR_FAIL_INDEX_V(current_edited_scene,edited_scene.size(),NULL); + + return edited_scene[current_edited_scene].root; +} +void EditorData::set_edited_scene_root(Node* p_root) { + + ERR_FAIL_INDEX(current_edited_scene,edited_scene.size()); + edited_scene[current_edited_scene].root=p_root; +} + +int EditorData::get_edited_scene_count() const { + + return edited_scene.size(); +} + +void EditorData::set_edited_scene_version(uint64_t version) { + ERR_FAIL_INDEX(current_edited_scene,edited_scene.size()); + edited_scene[current_edited_scene].version=version; + +} + +uint64_t EditorData::get_edited_scene_version() const{ + + ERR_FAIL_INDEX_V(current_edited_scene,edited_scene.size(),0); + return edited_scene[current_edited_scene].version; + +} +uint64_t EditorData::get_scene_version(int p_idx) const{ + ERR_FAIL_INDEX_V(p_idx,edited_scene.size(),false); + return edited_scene[p_idx].version; +} + +String EditorData::get_scene_title(int p_idx) const { + ERR_FAIL_INDEX_V(p_idx,edited_scene.size(),String()); + if (!edited_scene[p_idx].root) + return "[empty]"; + if (edited_scene[p_idx].root->get_filename()=="") + return "[unsaved]"; + return edited_scene[p_idx].root->get_filename().get_file(); +} + + +String EditorData::get_scene_path(int p_idx) const { + + ERR_FAIL_INDEX_V(p_idx,edited_scene.size(),String()); + + if (!edited_scene[p_idx].root) + return ""; + return edited_scene[p_idx].root->get_filename(); + +} + +void EditorData::save_edited_scene_state(EditorSelection *p_selection, EditorHistory *p_history, const Dictionary& p_custom) { + + ERR_FAIL_INDEX(current_edited_scene,edited_scene.size()); + + EditedScene &es=edited_scene[current_edited_scene]; + es.selection = p_selection->get_selected_node_list(); + es.history_current=p_history->current; + es.history_stored=p_history->history; + es.editor_states=get_editor_states(); + es.custom_state=p_custom; + +} + +Dictionary EditorData::restore_edited_scene_state(EditorSelection *p_selection, EditorHistory *p_history) { + ERR_FAIL_INDEX_V(current_edited_scene,edited_scene.size(),Dictionary()); + + EditedScene &es=edited_scene[current_edited_scene]; + + p_history->current=es.history_current; + p_history->history=es.history_stored; + + + p_selection->clear(); + for(List::Element *E=es.selection.front();E;E=E->next()) { + p_selection->add_node(E->get()); + } + set_editor_states(es.editor_states); + + return es.custom_state; +} + + +void EditorData::set_edited_scene_import_metadata(Ref p_mdata) { + + ERR_FAIL_INDEX(current_edited_scene,edited_scene.size()); + edited_scene[current_edited_scene].medatata=p_mdata; + +} + +Ref EditorData::get_edited_scene_import_metadata() const{ + + ERR_FAIL_INDEX_V(current_edited_scene,edited_scene.size(),Ref()); + return edited_scene[current_edited_scene].medatata; +} + +void EditorData::clear_edited_scenes() { + + for(int i=0;i p_layout) { + for(int i=0;iset_window_layout(p_layout); + } +} + +void EditorData::get_plugin_window_layout(Ref p_layout) { + for(int i=0;iget_window_layout(p_layout); + } +} EditorData::EditorData() { + current_edited_scene=-1; + // load_imported_scenes_from_globals(); } diff --git a/tools/editor/editor_data.h b/tools/editor/editor_data.h index 42abb317d18..e3fdd52d015 100644 --- a/tools/editor/editor_data.h +++ b/tools/editor/editor_data.h @@ -55,6 +55,7 @@ class EditorHistory { Vector path; int level; }; +friend class EditorData; Vector history; int current; @@ -91,6 +92,8 @@ public: EditorHistory(); }; +class EditorSelection; + class EditorData { public: @@ -117,6 +120,21 @@ private: void _cleanup_history(); + struct EditedScene { + Node* root; + Dictionary editor_states; + Ref medatata; + List selection; + Vector history_stored; + int history_current; + Dictionary custom_state; + uint64_t version; + + + }; + + Vector edited_scene; + int current_edited_scene; public: @@ -146,6 +164,32 @@ public: void remove_custom_type(const String& p_type); const Map >& get_custom_types() const { return custom_types; } + + int add_edited_scene(int p_at_pos); + void move_edited_scene_index(int p_idx,int p_to_idx); + void remove_scene(int p_idx); + void set_edited_scene(int p_idx); + void set_edited_scene_root(Node* p_root); + void set_edited_scene_import_metadata(Ref p_mdata); + Ref get_edited_scene_import_metadata() const; + int get_edited_scene() const; + Node* get_edited_scene_root(); + int get_edited_scene_count() const; + String get_scene_title(int p_idx) const; + String get_scene_path(int p_idx) const; + void set_edited_scene_version(uint64_t version); + uint64_t get_edited_scene_version() const; + uint64_t get_scene_version(int p_idx) const; + void clear_edited_scenes(); + + + void set_plugin_window_layout(Ref p_layout); + void get_plugin_window_layout(Ref p_layout); + + void save_edited_scene_state(EditorSelection *p_selection,EditorHistory *p_history,const Dictionary& p_custom); + Dictionary restore_edited_scene_state(EditorSelection *p_selection, EditorHistory *p_history); + + EditorData(); }; diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp index 373c8aba737..d080ac3597b 100644 --- a/tools/editor/editor_node.cpp +++ b/tools/editor/editor_node.cpp @@ -105,11 +105,24 @@ EditorNode *EditorNode::singleton=NULL; +void EditorNode::_update_scene_tabs() { + + scene_tabs->clear_tabs(); + for(int i=0;iadd_tab(editor_data.get_scene_title(i)+(unsaved?"(*)":"")); + } + + 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) @@ -174,6 +187,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 @@ -231,6 +249,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); @@ -468,7 +493,7 @@ void EditorNode::_dialog_display_file_error(String p_file,Error p_error) { void EditorNode::_get_scene_metadata() { - Node *scene = edited_scene; + Node *scene = editor_data.get_edited_scene_root(); if (!scene) return; @@ -495,7 +520,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; @@ -718,7 +743,7 @@ void EditorNode::_save_edited_subresources(Node* scene,Map& processed, for(int i=0;iget_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); } @@ -727,7 +752,7 @@ void EditorNode::_save_edited_subresources(Node* scene,Map& processed, void EditorNode::_find_node_types(Node* p_node, int&count_2d, int&count_3d) { - if (p_node->is_type("Viewport") || (p_node!=get_edited_scene() && p_node->get_owner()!=get_edited_scene())) + 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")) @@ -748,7 +773,7 @@ void EditorNode::_save_scene_with_preview(String p_file) { EditorProgress save("save","Saving Scene",4); save.step("Analyzing",0); - _find_node_types(get_edited_scene(),c2d,c3d); + _find_node_types(editor_data.get_edited_scene_root(),c2d,c3d); RID viewport; bool is2d; @@ -799,11 +824,11 @@ void EditorNode::_save_scene_with_preview(String p_file) { img.save_png(pfile); Vector imgdata = FileAccess::get_file_as_array(pfile); - print_line("img data is "+itos(imgdata.size())); + //print_line("img data is "+itos(imgdata.size())); - if (scene_import_metadata.is_null()) - scene_import_metadata = Ref( memnew( ResourceImportMetadata ) ); - scene_import_metadata->set_option("thumbnail",imgdata); + if (editor_data.get_edited_scene_import_metadata().is_null()) + editor_data.set_edited_scene_import_metadata(Ref( memnew( ResourceImportMetadata ) ) ); + editor_data.get_edited_scene_import_metadata()->set_option("thumbnail",imgdata); //tamanio tel thumbnail if (screen!=-1) { @@ -817,7 +842,7 @@ void EditorNode::_save_scene_with_preview(String p_file) { void EditorNode::_save_scene(String p_file) { - Node *scene = edited_scene; + Node *scene = editor_data.get_edited_scene_root(); if (!scene) { @@ -851,7 +876,7 @@ void EditorNode::_save_scene(String p_file) { 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; @@ -867,7 +892,7 @@ void EditorNode::_save_scene(String p_file) { 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 { @@ -1055,7 +1080,7 @@ void EditorNode::_dialog_action(String p_file) { Node *base = selection.front()->get(); Map reown; - reown[get_edited_scene()]=base; + reown[editor_data.get_edited_scene_root()]=base; Node *copy = base->duplicate_and_reown(reown); if (copy) { @@ -1150,7 +1175,7 @@ void EditorNode::_dialog_action(String p_file) { ml = Ref( 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) { @@ -1184,7 +1209,7 @@ void EditorNode::_dialog_action(String p_file) { ml = Ref( 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) { @@ -1325,15 +1350,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); } - +*/ } @@ -1408,17 +1433,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) { + + 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;iset_current_tab(i); - break; + for(int i=0;iset_current_tab(i); + break; + } } } @@ -1527,10 +1557,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) { @@ -1592,7 +1622,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 @@ -1644,8 +1674,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(); @@ -1654,7 +1684,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()); @@ -1680,7 +1710,7 @@ void EditorNode::_cleanup_scene() { } _update_title(); - +#endif } void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { @@ -1693,16 +1723,20 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { 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_minsize(); break; - } + }*/ - _cleanup_scene(); + int idx = editor_data.add_edited_scene(-1); + _scene_tab_changed(idx); + + //_cleanup_scene(); } break; @@ -1722,7 +1756,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()); }; @@ -1754,11 +1788,26 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { opening_prev=true; 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()); @@ -1769,7 +1818,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { }; case FILE_SAVE_AS_SCENE: { - Node *scene = edited_scene; + Node *scene = editor_data.get_edited_scene_root(); if (!scene) { @@ -1831,7 +1880,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) { @@ -1875,7 +1924,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) { @@ -1902,7 +1951,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { 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; @@ -1936,7 +1985,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) { @@ -1998,7 +2047,7 @@ 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(); @@ -2043,7 +2092,7 @@ 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(); @@ -2569,30 +2618,54 @@ void EditorNode::remove_editor_import_plugin(const Ref& 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()) - edited_scene->cast_to()->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()) + p_scene->cast_to()->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& strings) { @@ -2818,6 +2891,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;iget_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()) + new_scene->cast_to()->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()) { @@ -2826,6 +3008,14 @@ Error EditorNode::load_scene(const String& p_scene) { } + for(int i=0;iclear(); String lpath = Globals::get_singleton()->localize_path(p_scene); @@ -2841,7 +3031,20 @@ Error EditorNode::load_scene(const String& p_scene) { 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); + } + + + + //_cleanup_scene(); // i'm sorry but this MUST happen to avoid modified resources to not be reloaded. Ref sdata = ResourceLoader::load(lpath); if (!sdata.is_valid()) { @@ -2852,6 +3055,11 @@ Error EditorNode::load_scene(const String& p_scene) { accept->set_text("Error loading scene."); accept->popup_centered_minsize(); opening_prev=false; + + if (prev!=-1) { + set_current_scene(prev); + editor_data.remove_scene(idx); + } return ERR_FILE_NOT_FOUND; } @@ -2859,15 +3067,23 @@ Error EditorNode::load_scene(const String& p_scene) { 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_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(); @@ -2880,16 +3096,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__")) { @@ -2919,8 +3142,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); } @@ -3058,15 +3282,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); } @@ -3110,12 +3335,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("/","::"); @@ -3325,7 +3544,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); @@ -3343,6 +3562,11 @@ void EditorNode::_bind_methods() { 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("_set_main_scene_state",&EditorNode::_set_main_scene_state); + ObjectTypeDB::bind_method("_update_scene_tabs",&EditorNode::_update_scene_tabs); @@ -3655,10 +3879,29 @@ void EditorNode::_save_docks() { } + 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(); @@ -3732,6 +3975,20 @@ void EditorNode::_load_docks() { 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;iget_tab_count() || dock_slot[i*2+1]->get_tab_count(); if (in_use) @@ -3747,6 +4004,38 @@ void EditorNode::_load_docks() { } } + editor_data.set_plugin_window_layout(config); + +} + + +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() { @@ -3754,6 +4043,8 @@ 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); @@ -3841,14 +4132,38 @@ 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 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); + 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); + + + + + 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"); + top_dark_vb->add_child(scene_tabs); //left left_l_hsplit = memnew( HSplitContainer ); main_vbox->add_child(left_l_hsplit); @@ -3912,6 +4227,12 @@ EditorNode::EditorNode() { 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); @@ -4101,7 +4422,9 @@ EditorNode::EditorNode() { 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); @@ -4791,8 +5114,8 @@ EditorNode::EditorNode() { } - edited_scene=NULL; - saved_version=0; + //edited_scene=NULL; + saved_version=1; unsaved_cache=true; _last_instanced_scene=NULL; @@ -4854,7 +5177,13 @@ EditorNode::EditorNode() { 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(); + + } diff --git a/tools/editor/editor_node.h b/tools/editor/editor_node.h index 2ef9332c844..293da2031df 100644 --- a/tools/editor/editor_node.h +++ b/tools/editor/editor_node.h @@ -125,6 +125,7 @@ class EditorNode : public Node { FILE_QUICK_OPEN_SCRIPT, FILE_RUN_SCRIPT, FILE_OPEN_PREV, + FILE_CLOSE, FILE_QUIT, FILE_EXTERNAL_OPEN_SCENE, EDIT_UNDO, @@ -183,16 +184,16 @@ class EditorNode : public Node { }; - Node *edited_scene; //scene being edited + //Node *edited_scene; //scene being edited Viewport *scene_root; //root of the scene being edited - Ref scene_import_metadata; + //Ref scene_import_metadata; Control* scene_root_parent; Control *gui_base; VBoxContainer *main_vbox; - + //split HSplitContainer *left_l_hsplit; VSplitContainer *left_l_vsplit; @@ -205,6 +206,9 @@ class EditorNode : public Node { VSplitContainer *center_split; + //main tabs + + Tabs *scene_tabs; int old_split_ofs; @@ -324,8 +328,10 @@ class EditorNode : public Node { bool reference_resource_mem; bool save_external_resources_mem; uint64_t saved_version; + uint64_t last_checked_version; bool unsaved_cache; String open_navigate; + bool changing_scene; uint32_t circle_step_msec; uint64_t circle_step_frame; @@ -375,6 +381,7 @@ class EditorNode : public Node { void _set_scene_metadata(); void _get_scene_metadata(); void _update_title(); + void _update_scene_tabs(); void _close_messages(); void _show_messages(); void _vp_resized(); @@ -402,7 +409,7 @@ class EditorNode : public Node { void _add_to_recent_scenes(const String& p_scene); void _update_recent_scenes(); void _open_recent_scene(int p_idx); - void _open_recent_scene_confirm(); + //void _open_recent_scene_confirm(); String _recent_scene; bool convert_old; @@ -431,7 +438,7 @@ class EditorNode : public Node { void _cleanup_scene(); - + void _remove_edited_scene(); bool _find_and_save_resource(RES p_res,Map& processed,int32_t flags); bool _find_and_save_edited_subresources(Object *obj,Map& processed,int32_t flags); void _save_edited_subresources(Node* scene,Map& processed,int32_t flags); @@ -461,6 +468,10 @@ class EditorNode : public Node { void _dock_pre_popup(int p_which); void _dock_split_dragged(int ofs); void _dock_popup_exit(); + void _scene_tab_changed(int p_tab); + + Dictionary _get_main_scene_state(); + void _set_main_scene_state(Dictionary p_state); void _save_docks(); void _load_docks(); @@ -498,7 +509,7 @@ public: void open_request(const String& p_path); - void set_edited_scene(Node *p_scene); + bool is_changing_scene() const; static EditorLog *get_log() { return singleton->log; } @@ -511,7 +522,9 @@ public: void hide_animation_player_editors(); void animation_panel_make_visible(bool p_visible); - Node *get_edited_scene() { return edited_scene; } + void set_edited_scene(Node *p_scene); + + Node *get_edited_scene() { return editor_data.get_edited_scene_root(); } Viewport *get_scene_root() { return scene_root; } //root of the scene being edited Error save_optimized_copy(const String& p_scene,const String& p_preset); @@ -520,6 +533,9 @@ public: Error load_scene(const String& p_scene); Error load_resource(const String& p_scene); + void set_current_version(uint64_t p_version); + void set_current_scene(int p_idx); + static EditorData& get_editor_data() { return singleton->editor_data; } static VSplitContainer *get_top_split() { return singleton->top_split; } @@ -566,6 +582,9 @@ public: bool is_scene_in_use(const String& p_path); void scan_import_changes(); + + void save_layout(); + EditorNode(); ~EditorNode(); void get_singleton(const char* arg1, bool arg2); diff --git a/tools/editor/editor_plugin.cpp b/tools/editor/editor_plugin.cpp index e6b8ee0993b..04c34d9a88e 100644 --- a/tools/editor/editor_plugin.cpp +++ b/tools/editor/editor_plugin.cpp @@ -197,6 +197,13 @@ bool EditorPlugin::get_remove_list(List *p_list) { void EditorPlugin::restore_global_state() {} void EditorPlugin::save_global_state() {} +void EditorPlugin::set_window_layout(Ref p_layout) { + +} + +void EditorPlugin::get_window_layout(Ref p_layout){ + +} void EditorPlugin::_bind_methods() { diff --git a/tools/editor/editor_plugin.h b/tools/editor/editor_plugin.h index a9e6b1be49d..0f3a1e2e3cd 100644 --- a/tools/editor/editor_plugin.h +++ b/tools/editor/editor_plugin.h @@ -32,7 +32,7 @@ #include "scene/main/node.h" #include "scene/resources/texture.h" #include "undo_redo.h" - +#include "io/config_file.h" /** @author Juan Linietsky */ @@ -90,6 +90,8 @@ public: virtual void apply_changes() ; // if changes are pending in editor, apply them virtual void get_breakpoints(List *p_breakpoints); virtual bool get_remove_list(List *p_list); + virtual void set_window_layout(Ref p_layout); + virtual void get_window_layout(Ref p_layout); virtual void restore_global_state(); virtual void save_global_state(); diff --git a/tools/editor/editor_run_script.cpp b/tools/editor/editor_run_script.cpp index 5f8598d0527..90581374f6f 100644 --- a/tools/editor/editor_run_script.cpp +++ b/tools/editor/editor_run_script.cpp @@ -18,7 +18,7 @@ void EditorScript::add_root_node(Node *p_node) { return; } - editor->set_edited_scene(p_node); +// editor->set_edited_scene(p_node); } Node *EditorScript::get_scene() { diff --git a/tools/editor/editor_settings.cpp b/tools/editor/editor_settings.cpp index 361a86b88ef..0df9fcadef1 100644 --- a/tools/editor/editor_settings.cpp +++ b/tools/editor/editor_settings.cpp @@ -433,9 +433,11 @@ void EditorSettings::_load_defaults() { set("text_editor/idle_parse_delay",2); set("text_editor/create_signal_callbacks",true); set("text_editor/autosave_interval_secs",0); + set("text_editor/font",""); hints["text_editor/font"]=PropertyInfo(Variant::STRING,"text_editor/font",PROPERTY_HINT_GLOBAL_FILE,"*.fnt"); set("text_editor/auto_brace_complete", false); + set("text_editor/restore_scripts_on_load",true); set("scenetree_editor/duplicate_node_name_num_separator",0); diff --git a/tools/editor/icons/icon_panel_top.png b/tools/editor/icons/icon_panel_top.png new file mode 100644 index 0000000000000000000000000000000000000000..20e67fad1af3070d9c0524bd79ee5a6a7229098d GIT binary patch literal 195 zcmeAS@N?(olHy`uVBq!ia0vp^93afW1|*O0@9PFqY)RhkE)1eTD1M^W{UT6=v%n*= zn1O*?7=#%aX3dcR3bL1Y`ns~;XX6uMv)*xGe<@H%HZvrm#5q4VH#M&W$Yo$~E=o-- zNlj5G&n(GMaQE~LNYP7W2a2nEx;TbNTuy%S`0?-a4eSPn0t_Vq2R?m&Z~uqu-=Ck& g@r|oDOUJP?=sjfr`E>t*lOVG^UHx3vIVCg!0OYVZ#{d8T literal 0 HcmV?d00001 diff --git a/tools/editor/io_plugins/editor_mesh_import_plugin.cpp b/tools/editor/io_plugins/editor_mesh_import_plugin.cpp index 2e5a6f8a819..21395130256 100644 --- a/tools/editor/io_plugins/editor_mesh_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_mesh_import_plugin.cpp @@ -105,7 +105,7 @@ public: _EditorMeshImportOptions() { generate_tangents=true; - generate_normals=true; + generate_normals=false; flip_faces=false; smooth_shading=false; weld_vertices=true; diff --git a/tools/editor/plugins/multimesh_editor_plugin.cpp b/tools/editor/plugins/multimesh_editor_plugin.cpp index d858f3b896e..0df906117eb 100644 --- a/tools/editor/plugins/multimesh_editor_plugin.cpp +++ b/tools/editor/plugins/multimesh_editor_plugin.cpp @@ -305,7 +305,7 @@ void MultiMeshEditor::edit(MultiMeshInstance *p_multimesh) { void MultiMeshEditor::_browse(bool p_source) { browsing_source=p_source; - std->get_tree()->set_marked(node,false); + std->get_scene_tree()->set_marked(node,false); std->popup_centered_ratio(); if (p_source) std->set_title("Select a Source Mesh:"); diff --git a/tools/editor/plugins/script_editor_plugin.cpp b/tools/editor/plugins/script_editor_plugin.cpp index f5ba6a08e64..cf934b988db 100644 --- a/tools/editor/plugins/script_editor_plugin.cpp +++ b/tools/editor/plugins/script_editor_plugin.cpp @@ -38,10 +38,12 @@ #include "os/file_access.h" #include "scene/main/viewport.h" #include "os/keyboard.h" +#include "os/input.h" + /*** SCRIPT EDITOR ****/ - +#define SORT_SCRIPT_LIST void ScriptEditorQuickOpen::popup(const Vector& p_functions, bool p_dontclear) { @@ -118,6 +120,8 @@ void ScriptEditorQuickOpen::_notification(int p_what) { if (p_what==NOTIFICATION_ENTER_TREE) { connect("confirmed",this,"_confirmed"); + + } } @@ -296,12 +300,11 @@ void ScriptTextEditor::_notification(int p_what) { if (p_what==NOTIFICATION_READY) { - _update_name(); + //emit_signal("name_changed"); } } -void ScriptTextEditor::_update_name() { - +String ScriptTextEditor::get_name() { String name; if (script->get_path().find("local://")==-1 && script->get_path().find("::")==-1) { @@ -314,22 +317,21 @@ void ScriptTextEditor::_update_name() { else name=script->get_type()+"("+itos(script->get_instance_ID())+")"; - - if (name!=String(get_name())) { - - set_name(name); - - } - - if (!has_meta("_tab_icon")) { - if (get_parent_control() && get_parent_control()->has_icon(script->get_type(),"EditorIcons")) { - set_meta("_tab_icon",get_parent_control()->get_icon(script->get_type(),"EditorIcons")); - } - } - + return name; } +Ref ScriptTextEditor::get_icon() { + + if (get_parent_control() && get_parent_control()->has_icon(script->get_type(),"EditorIcons")) { + return get_parent_control()->get_icon(script->get_type(),"EditorIcons"); + } + + return Ref(); +} + + + void ScriptTextEditor::set_edited_script(const Ref