diff options
-rw-r--r-- | scene/2d/animated_sprite.cpp | 2 | ||||
-rw-r--r-- | scene/2d/sprite.cpp | 11 | ||||
-rw-r--r-- | scene/2d/sprite.h | 2 | ||||
-rw-r--r-- | scene/3d/sprite_3d.cpp | 11 | ||||
-rw-r--r-- | scene/3d/sprite_3d.h | 2 | ||||
-rw-r--r-- | scene/main/node.cpp | 22 | ||||
-rw-r--r-- | scene/main/node.h | 2 | ||||
-rw-r--r-- | scene/main/viewport.h | 1 | ||||
-rw-r--r-- | tools/editor/editor_node.cpp | 5 | ||||
-rw-r--r-- | tools/editor/editor_resource_preview.cpp | 4 | ||||
-rw-r--r-- | tools/editor/editor_resource_preview.h | 2 | ||||
-rw-r--r-- | tools/editor/plugins/script_editor_plugin.cpp | 77 | ||||
-rw-r--r-- | tools/editor/plugins/script_editor_plugin.h | 4 | ||||
-rw-r--r-- | tools/editor/project_manager.cpp | 4 | ||||
-rw-r--r-- | tools/editor/property_editor.cpp | 4 |
15 files changed, 139 insertions, 14 deletions
diff --git a/scene/2d/animated_sprite.cpp b/scene/2d/animated_sprite.cpp index c062a6d1fc..73774e12d9 100644 --- a/scene/2d/animated_sprite.cpp +++ b/scene/2d/animated_sprite.cpp @@ -318,7 +318,7 @@ void AnimatedSprite::_validate_property(PropertyInfo& property) const { if (property.name=="frame") { - property.hint=PROPERTY_HINT_RANGE; + property.hint=PROPERTY_HINT_SPRITE_FRAME; if (frames->has_animation(animation)) { property.hint_string="0,"+itos(frames->get_frame_count(animation)-1)+",1"; diff --git a/scene/2d/sprite.cpp b/scene/2d/sprite.cpp index 27aa08ec5b..c5b338bf59 100644 --- a/scene/2d/sprite.cpp +++ b/scene/2d/sprite.cpp @@ -288,6 +288,17 @@ Rect2 Sprite::get_item_rect() const { } + +void Sprite::_validate_property(PropertyInfo& property) const { + + if (property.name=="frame") { + + property.hint=PROPERTY_HINT_SPRITE_FRAME; + + property.hint_string="0,"+itos(vframes*hframes-1)+",1"; + } +} + void Sprite::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_texture","texture:Texture"),&Sprite::set_texture); diff --git a/scene/2d/sprite.h b/scene/2d/sprite.h index f789538b1d..32d3f476d1 100644 --- a/scene/2d/sprite.h +++ b/scene/2d/sprite.h @@ -61,6 +61,8 @@ protected: static void _bind_methods();; + virtual void _validate_property(PropertyInfo& property) const; + public: virtual void edit_set_pivot(const Point2& p_pivot); diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp index 8c86c4bf35..74cab30b17 100644 --- a/scene/3d/sprite_3d.cpp +++ b/scene/3d/sprite_3d.cpp @@ -585,6 +585,17 @@ Rect2 Sprite3D::get_item_rect() const { return Rect2(ofs,s); } + +void Sprite3D::_validate_property(PropertyInfo& property) const { + + if (property.name=="frame") { + + property.hint=PROPERTY_HINT_SPRITE_FRAME; + + property.hint_string="0,"+itos(vframes*hframes-1)+",1"; + } +} + void Sprite3D::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_texture","texture:Texture"),&Sprite3D::set_texture); diff --git a/scene/3d/sprite_3d.h b/scene/3d/sprite_3d.h index 41e6ba804a..31f8ec020f 100644 --- a/scene/3d/sprite_3d.h +++ b/scene/3d/sprite_3d.h @@ -158,6 +158,8 @@ class Sprite3D : public SpriteBase3D { protected: virtual void _draw(); static void _bind_methods(); + + virtual void _validate_property(PropertyInfo& property) const; public: diff --git a/scene/main/node.cpp b/scene/main/node.cpp index bea6e75aef..29851efaff 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -1513,7 +1513,7 @@ int Node::get_position_in_parent() const { -Node *Node::duplicate(bool p_use_instancing) const { +Node *Node::_duplicate(bool p_use_instancing) const { Node *node=NULL; @@ -1592,9 +1592,21 @@ Node *Node::duplicate(bool p_use_instancing) const { node->add_child(dup); } + return node; } +Node *Node::duplicate(bool p_use_instancing) const { + + Node* dupe = _duplicate(p_use_instancing); + + if (dupe) { + _duplicate_signals(this,dupe); + } + + return dupe; +} + void Node::_duplicate_and_reown(Node* p_new_parent, const Map<Node*,Node*>& p_reown_map) const { @@ -1664,12 +1676,13 @@ void Node::_duplicate_and_reown(Node* p_new_parent, const Map<Node*,Node*>& p_re void Node::_duplicate_signals(const Node* p_original,Node* p_copy) const { - if (this!=p_original && get_owner()!=p_original) + if (this!=p_original && (get_owner()!=p_original && get_owner()!=p_original->get_owner())) return; List<Connection> conns; get_all_signal_connections(&conns); + for (List<Connection>::Element *E=conns.front();E;E=E->next()) { if (E->get().flags&CONNECT_PERSIST) { @@ -1678,14 +1691,17 @@ void Node::_duplicate_signals(const Node* p_original,Node* p_copy) const { Node *copy = p_copy->get_node(p); Node *target = E->get().target->cast_to<Node>(); - if (!target) + if (!target) { continue; + } NodePath ptarget = p_original->get_path_to(target); Node *copytarget = p_copy->get_node(ptarget); + if (copy && copytarget) { copy->connect(E->get().signal,copytarget,E->get().method,E->get().binds,CONNECT_PERSIST); } + } } diff --git a/scene/main/node.h b/scene/main/node.h index dcc3829d15..10cfc5f9e6 100644 --- a/scene/main/node.h +++ b/scene/main/node.h @@ -138,6 +138,8 @@ private: void _duplicate_signals(const Node* p_original,Node* p_copy) const; void _duplicate_and_reown(Node* p_new_parent, const Map<Node*,Node*>& p_reown_map) const; + Node *_duplicate(bool p_use_instancing) const; + Array _get_children() const; Array _get_groups() const; diff --git a/scene/main/viewport.h b/scene/main/viewport.h index aaa640e0e6..22a97a9888 100644 --- a/scene/main/viewport.h +++ b/scene/main/viewport.h @@ -39,6 +39,7 @@ */ class Camera; +class Camera2D; class Listener; class Control; class CanvasItem; diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp index ae632ab381..56d745dee6 100644 --- a/tools/editor/editor_node.cpp +++ b/tools/editor/editor_node.cpp @@ -3133,6 +3133,11 @@ void EditorNode::_remove_edited_scene() { new_index=1; } + + + if (editor_data.get_scene_path(old_index)!=String()) { + ScriptEditor::get_singleton()->close_builtin_scripts_from_scene(editor_data.get_scene_path(old_index)); + } _scene_tab_changed(new_index); editor_data.remove_scene(old_index); editor_data.get_undo_redo().clear_history(); diff --git a/tools/editor/editor_resource_preview.cpp b/tools/editor/editor_resource_preview.cpp index 1a0e996110..6e38d6460b 100644 --- a/tools/editor/editor_resource_preview.cpp +++ b/tools/editor/editor_resource_preview.cpp @@ -336,7 +336,7 @@ void EditorResourcePreview::_bind_methods() { ADD_SIGNAL(MethodInfo("preview_invalidated",PropertyInfo(Variant::STRING,"path"))); } -bool EditorResourcePreview::check_for_invalidation(const String& p_path) { +void EditorResourcePreview::check_for_invalidation(const String& p_path) { preview_mutex->lock(); @@ -356,7 +356,7 @@ bool EditorResourcePreview::check_for_invalidation(const String& p_path) { call_deferred("emit_signal","preview_invalidated",p_path); } - return call_invalidated; + } diff --git a/tools/editor/editor_resource_preview.h b/tools/editor/editor_resource_preview.h index fed8f129ed..51a00965eb 100644 --- a/tools/editor/editor_resource_preview.h +++ b/tools/editor/editor_resource_preview.h @@ -121,7 +121,7 @@ public: void queue_edited_resource_preview(const Ref<Resource>& p_path, Object* p_receiver, const StringName& p_receiver_func, const Variant& p_userdata); void add_preview_generator(const Ref<EditorResourcePreviewGenerator>& p_generator); - bool check_for_invalidation(const String& p_path); + void check_for_invalidation(const String& p_path); EditorResourcePreview(); ~EditorResourcePreview(); diff --git a/tools/editor/plugins/script_editor_plugin.cpp b/tools/editor/plugins/script_editor_plugin.cpp index ee83b6b032..aa0f52d574 100644 --- a/tools/editor/plugins/script_editor_plugin.cpp +++ b/tools/editor/plugins/script_editor_plugin.cpp @@ -43,6 +43,28 @@ /*** SCRIPT EDITOR ****/ +static bool _can_open_in_editor(Script* p_script) { + + String path = p_script->get_path(); + + if (path.find("::")!=-1) { + //refuse handling this if it can't be edited + + bool valid=false; + for(int i=0;i<EditorNode::get_singleton()->get_editor_data().get_edited_scene_count();i++) { + if (path.begins_with(EditorNode::get_singleton()->get_editor_data().get_scene_path(i))) { + valid=true; + break; + } + } + + return valid; + } + + return true; +} + + class EditorScriptCodeCompletionCache : public ScriptCodeCompletionCache { @@ -747,9 +769,9 @@ void ScriptEditor::_go_to_tab(int p_idx) { _update_script_colors(); } -void ScriptEditor::_close_current_tab() { +void ScriptEditor::_close_tab(int p_idx) { - int selected = tab_container->get_current_tab(); + int selected = p_idx; if (selected<0 || selected>=tab_container->get_child_count()) return; @@ -795,6 +817,11 @@ void ScriptEditor::_close_current_tab() { _update_script_names(); EditorNode::get_singleton()->save_layout(); +} + +void ScriptEditor::_close_current_tab() { + + _close_tab(tab_container->get_current_tab()); } @@ -1681,6 +1708,33 @@ void ScriptEditor::_notification(int p_what) { } + +void ScriptEditor::close_builtin_scripts_from_scene(const String& p_scene) { + + + + for(int i=0;i<tab_container->get_child_count();i++) { + + ScriptTextEditor *ste = tab_container->get_child(i)->cast_to<ScriptTextEditor>(); + + if (ste) { + + Ref<Script> script = ste->get_edited_script(); + if (!script.is_valid()) + continue; + + if (script->get_path().find("::")!=-1 && script->get_path().begins_with(p_scene)) { //is an internal script and belongs to scene being closed + _close_tab(i); + i--; + + } + } + + } + + +} + void ScriptEditor::edited_scene_changed() { _update_modified_scripts_for_external_editor(); @@ -2059,11 +2113,18 @@ void ScriptEditor::_update_script_names() { } + + void ScriptEditor::edit(const Ref<Script>& p_script) { if (p_script.is_null()) return; + // refuse to open built-in if scene is not loaded + + + + // see if already has it bool open_dominant = EditorSettings::get_singleton()->get("text_editor/open_dominant_script_on_scene_change"); @@ -2527,7 +2588,7 @@ void ScriptEditor::set_scene_root_script( Ref<Script> p_script ) { if (bool(EditorSettings::get_singleton()->get("external_editor/use_external_editor"))) return; - if (open_dominant && p_script.is_valid()) { + if (open_dominant && p_script.is_valid() && _can_open_in_editor(p_script.ptr())) { edit(p_script); } } @@ -2915,6 +2976,16 @@ void ScriptEditorPlugin::edit(Object *p_object) { bool ScriptEditorPlugin::handles(Object *p_object) const { + if (p_object->cast_to<Script>()) { + + bool valid = _can_open_in_editor(p_object->cast_to<Script>()); + + if (!valid) { //user tried to open it by clicking + EditorNode::get_singleton()->show_warning(TTR("Built-in scripts can only be edited when the scene they belong to is loaded")); + } + return valid; + } + return p_object->is_type("Script"); } diff --git a/tools/editor/plugins/script_editor_plugin.h b/tools/editor/plugins/script_editor_plugin.h index 85412087b4..2e6e2c035c 100644 --- a/tools/editor/plugins/script_editor_plugin.h +++ b/tools/editor/plugins/script_editor_plugin.h @@ -234,6 +234,8 @@ class ScriptEditor : public VBoxContainer { bool _test_script_times_on_disk(Ref<Script> p_for_script=Ref<Script>()); + void _close_tab(int p_idx); + void _close_current_tab(); bool grab_focus_block; @@ -331,6 +333,8 @@ public: virtual void edited_scene_changed(); + void close_builtin_scripts_from_scene(const String& p_scene); + ScriptEditorDebugger *get_debugger() { return debugger; } void set_live_auto_reload_running_scripts(bool p_enabled); diff --git a/tools/editor/project_manager.cpp b/tools/editor/project_manager.cpp index 860af4888b..497ff43a4d 100644 --- a/tools/editor/project_manager.cpp +++ b/tools/editor/project_manager.cpp @@ -46,7 +46,7 @@ #include "io/resource_saver.h" #include "editor_themes.h" - +#include "editor_initialize_ssl.h" #include "editor_scale.h" class NewProjectDialog : public ConfirmationDialog { @@ -1103,6 +1103,8 @@ void ProjectListFilter::_bind_methods() { ProjectListFilter::ProjectListFilter() { + editor_initialize_certificates(); //for asset sharing + _current_filter = FILTER_NAME; filter_option = memnew(OptionButton); diff --git a/tools/editor/property_editor.cpp b/tools/editor/property_editor.cpp index e0dc76e733..4b3f245e44 100644 --- a/tools/editor/property_editor.cpp +++ b/tools/editor/property_editor.cpp @@ -2981,10 +2981,8 @@ void PropertyEditor::update_tree() { else item->set_cell_mode( 1, TreeItem::CELL_MODE_RANGE_EXPRESSION ); - if (p.hint==PROPERTY_HINT_SPRITE_FRAME) { - item->set_range_config(1,0,99999,1); - } else if (p.hint==PROPERTY_HINT_RANGE || p.hint==PROPERTY_HINT_EXP_RANGE) { + if (p.hint==PROPERTY_HINT_SPRITE_FRAME || p.hint==PROPERTY_HINT_RANGE || p.hint==PROPERTY_HINT_EXP_RANGE) { int c = p.hint_string.get_slice_count(","); float min=0,max=100,step=1; |