diff options
author | MarianoGNU <marianognu.easyrpg@gmail.com> | 2015-10-24 11:55:00 -0300 |
---|---|---|
committer | MarianoGNU <marianognu.easyrpg@gmail.com> | 2015-10-24 11:55:00 -0300 |
commit | 754908844ae52c04ed68ef27c02481479f1e2ab4 (patch) | |
tree | 90b95accfabc9bc12a6479c004183ff7d28b6fcd /tools/editor | |
parent | 6df7d923797908ecf38684c0008c0e4b6475d884 (diff) | |
parent | 4baf65dab78b6e8062de760010338c316c628394 (diff) |
Merge branch 'master' of https://github.com/okamstudio/godot into posta
Diffstat (limited to 'tools/editor')
-rw-r--r-- | tools/editor/editor_node.cpp | 21 | ||||
-rw-r--r-- | tools/editor/editor_node.h | 1 | ||||
-rw-r--r-- | tools/editor/io_plugins/editor_texture_import_plugin.cpp | 20 | ||||
-rw-r--r-- | tools/editor/scene_tree_dock.cpp | 3 | ||||
-rw-r--r-- | tools/editor/script_editor_debugger.cpp | 80 | ||||
-rw-r--r-- | tools/editor/script_editor_debugger.h | 5 |
6 files changed, 119 insertions, 11 deletions
diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp index 34e2510791..a3d7cbd7cf 100644 --- a/tools/editor/editor_node.cpp +++ b/tools/editor/editor_node.cpp @@ -2946,6 +2946,20 @@ void EditorNode::_remove_edited_scene() { unsaved_cache=false; } } + +void EditorNode::_remove_scene(int index) { +// printf("Attempting to remove scene %d (current is %d)\n", index, editor_data.get_edited_scene()); + if (editor_data.get_edited_scene() == index) { + //Scene to remove is current scene + _remove_edited_scene(); + } + else { + // Scene to remove is not active scene."); + editor_data.remove_scene(index); + editor_data.get_undo_redo().clear_history(); + } +} + void EditorNode::set_edited_scene(Node *p_scene) { if (get_editor_data().get_edited_scene_root()) { @@ -4390,12 +4404,7 @@ void EditorNode::_scene_tab_script_edited(int p_tab) { } void EditorNode::_scene_tab_closed(int p_tab) { - set_current_scene(p_tab); - bool p_confirmed = true; - if (unsaved_cache) - p_confirmed = false; - - _menu_option_confirm(FILE_CLOSE, p_confirmed); + _remove_scene(p_tab); _update_scene_tabs(); } diff --git a/tools/editor/editor_node.h b/tools/editor/editor_node.h index 978e8390dc..56e455c9c0 100644 --- a/tools/editor/editor_node.h +++ b/tools/editor/editor_node.h @@ -461,6 +461,7 @@ class EditorNode : public Node { void _cleanup_scene(); void _remove_edited_scene(); + void _remove_scene(int index); bool _find_and_save_resource(RES p_res,Map<RES,bool>& processed,int32_t flags); bool _find_and_save_edited_subresources(Object *obj,Map<RES,bool>& processed,int32_t flags); void _save_edited_subresources(Node* scene,Map<RES,bool>& processed,int32_t flags); diff --git a/tools/editor/io_plugins/editor_texture_import_plugin.cpp b/tools/editor/io_plugins/editor_texture_import_plugin.cpp index c0887ab40a..8d5a4f1dcf 100644 --- a/tools/editor/io_plugins/editor_texture_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_texture_import_plugin.cpp @@ -1180,8 +1180,15 @@ Error EditorTextureImportPlugin::import2(const String& p_path, const Ref<Resourc ep.step("Blitting Images",sources.size()+2); + bool blit_to_po2=tex_flags&Texture::FLAG_MIPMAPS; + int atlas_w=dst_size.width; + int atlas_h=dst_size.height; + if (blit_to_po2) { + atlas_w=nearest_power_of_2(dst_size.width); + atlas_h=nearest_power_of_2(dst_size.height); + } Image atlas; - atlas.create(nearest_power_of_2(dst_size.width),nearest_power_of_2(dst_size.height),0,alpha?Image::FORMAT_RGBA:Image::FORMAT_RGB); + atlas.create(atlas_w,atlas_h,0,alpha?Image::FORMAT_RGBA:Image::FORMAT_RGB); atlases.resize(from->get_source_count()); @@ -1210,16 +1217,21 @@ Error EditorTextureImportPlugin::import2(const String& p_path, const Ref<Resourc ERR_CONTINUE( !source_map.has(i) ); for (List<int>::Element *E=source_map[i].front();E;E=E->next()) { - Ref<AtlasTexture> at = memnew( AtlasTexture ); + String apath = p_path.get_base_dir().plus_file(from->get_source_path(E->get()).get_file().basename()+".atex"); + + Ref<AtlasTexture> at; + if (ResourceCache::has(apath)) { + at = Ref<AtlasTexture>( ResourceCache::get(apath)->cast_to<AtlasTexture>() ); + } else { + at = Ref<AtlasTexture>( memnew( AtlasTexture ) ); + } at->set_region(region); at->set_margin(margin); - String apath = p_path.get_base_dir().plus_file(from->get_source_path(E->get()).get_file().basename()+".atex"); at->set_path(apath); atlases[E->get()]=at; print_line("Atlas Tex: "+apath); - } } if (ResourceCache::has(p_path)) { diff --git a/tools/editor/scene_tree_dock.cpp b/tools/editor/scene_tree_dock.cpp index 510517de6f..08aa68d792 100644 --- a/tools/editor/scene_tree_dock.cpp +++ b/tools/editor/scene_tree_dock.cpp @@ -1088,7 +1088,8 @@ void SceneTreeDock::_delete_confirm() { void SceneTreeDock::_update_tool_buttons() { Node *sel = scene_tree->get_selected(); - bool disable = !sel || (sel!=edited_scene && sel->get_owner()!=edited_scene) || (edited_scene->get_scene_instance_state().is_valid() && edited_scene->get_scene_instance_state()->find_node_by_path(edited_scene->get_path_to(sel))>=0); + bool disable = !sel || (sel!=edited_scene && sel->get_owner()!=edited_scene); + disable = disable || (edited_scene->get_scene_inherited_state().is_valid() && edited_scene->get_scene_inherited_state()->find_node_by_path(edited_scene->get_path_to(sel))>=0); bool disable_root = disable || sel->get_parent()==scene_root; bool disable_edit = !sel; diff --git a/tools/editor/script_editor_debugger.cpp b/tools/editor/script_editor_debugger.cpp index 2e1fa2814e..8e0e7ddb49 100644 --- a/tools/editor/script_editor_debugger.cpp +++ b/tools/editor/script_editor_debugger.cpp @@ -169,6 +169,17 @@ void ScriptEditorDebugger::_scene_tree_request() { } +void ScriptEditorDebugger::_video_mem_request() { + + ERR_FAIL_COND(connection.is_null()); + ERR_FAIL_COND(!connection->is_connected()); + + Array msg; + msg.push_back("request_video_mem"); + ppeer->put_var(msg); + +} + Size2 ScriptEditorDebugger::get_minimum_size() const { Size2 ms = Control::get_minimum_size(); @@ -244,6 +255,31 @@ void ScriptEditorDebugger::_parse_message(const String& p_msg,const Array& p_dat le_clear->set_disabled(false); le_set->set_disabled(false); + } else if (p_msg=="message:video_mem") { + + vmem_tree->clear(); + TreeItem* root=vmem_tree->create_item(); + + int total=0; + + for(int i=0;i<p_data.size();i+=4) { + + TreeItem *it = vmem_tree->create_item(root); + String type=p_data[i+1]; + int bytes=p_data[i+3].operator int(); + it->set_text(0,p_data[i+0]); //path + it->set_text(1,type); //type + it->set_text(2,p_data[i+2]); //type + it->set_text(3,String::humanize_size(bytes)); //type + total+=bytes; + + if (has_icon(type,"EditorIcons")) + it->set_icon(0,get_icon(type,"EditorIcons")); + } + + vmem_total->set_tooltip("Bytes: "+itos(total)); + vmem_total->set_text(String::humanize_size(total)); + } else if (p_msg=="stack_dump") { stack_dump->clear(); @@ -506,6 +542,7 @@ void ScriptEditorDebugger::_notification(int p_what) { le_clear->connect("pressed",this,"_live_edit_clear"); error_list->connect("item_selected",this,"_error_selected"); error_stack->connect("item_selected",this,"_error_stack_selected"); + vmem_refresh->set_icon( get_icon("Reload","EditorIcons")); } break; case NOTIFICATION_PROCESS: { @@ -1136,6 +1173,7 @@ void ScriptEditorDebugger::_bind_methods() { ObjectTypeDB::bind_method(_MD("_performance_draw"),&ScriptEditorDebugger::_performance_draw); ObjectTypeDB::bind_method(_MD("_performance_select"),&ScriptEditorDebugger::_performance_select); ObjectTypeDB::bind_method(_MD("_scene_tree_request"),&ScriptEditorDebugger::_scene_tree_request); + ObjectTypeDB::bind_method(_MD("_video_mem_request"),&ScriptEditorDebugger::_video_mem_request); ObjectTypeDB::bind_method(_MD("_live_edit_set"),&ScriptEditorDebugger::_live_edit_set); ObjectTypeDB::bind_method(_MD("_live_edit_clear"),&ScriptEditorDebugger::_live_edit_clear); @@ -1322,6 +1360,48 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor){ } + VBoxContainer *vmem_vb = memnew( VBoxContainer ); + HBoxContainer *vmem_hb = memnew( HBoxContainer ); + Label *vmlb = memnew(Label("List of Video Memory Usage by Resource: ") ); + vmlb->set_h_size_flags(SIZE_EXPAND_FILL); + vmem_hb->add_child( vmlb ); + vmem_hb->add_child( memnew(Label("Total: ")) ); + vmem_total = memnew( LineEdit ); + vmem_total->set_editable(false); + vmem_total->set_custom_minimum_size(Size2(100,1)); + vmem_hb->add_child(vmem_total); + vmem_refresh = memnew( Button ); + vmem_hb->add_child(vmem_refresh); + vmem_vb->add_child(vmem_hb); + vmem_refresh->connect("pressed",this,"_video_mem_request"); + + MarginContainer *vmmc = memnew( MarginContainer ); + vmmc = memnew( MarginContainer ); + vmem_tree = memnew( Tree ); + vmem_tree->set_v_size_flags(SIZE_EXPAND_FILL); + vmem_tree->set_h_size_flags(SIZE_EXPAND_FILL); + vmmc->add_child(vmem_tree); + vmmc->set_v_size_flags(SIZE_EXPAND_FILL); + vmem_vb->add_child(vmmc); + + vmem_vb->set_name("Video Mem"); + vmem_tree->set_columns(4); + vmem_tree->set_column_titles_visible(true); + vmem_tree->set_column_title(0,"Resource Path"); + vmem_tree->set_column_expand(0,true); + vmem_tree->set_column_expand(1,false); + vmem_tree->set_column_title(1,"Type"); + vmem_tree->set_column_min_width(1,100); + vmem_tree->set_column_expand(2,false); + vmem_tree->set_column_title(2,"Format"); + vmem_tree->set_column_min_width(2,150); + vmem_tree->set_column_expand(3,false); + vmem_tree->set_column_title(3,"Usage"); + vmem_tree->set_column_min_width(3,80); + vmem_tree->set_hide_root(true); + + tabs->add_child(vmem_vb); + info = memnew( HSplitContainer ); info->set_name("Info"); tabs->add_child(info); diff --git a/tools/editor/script_editor_debugger.h b/tools/editor/script_editor_debugger.h index 3c66dde340..6b66a62dd5 100644 --- a/tools/editor/script_editor_debugger.h +++ b/tools/editor/script_editor_debugger.h @@ -96,6 +96,10 @@ class ScriptEditorDebugger : public Control { Tree *perf_monitors; Control *perf_draw; + Tree *vmem_tree; + Button *vmem_refresh; + LineEdit *vmem_total; + Tree *stack_dump; PropertyEditor *inspector; @@ -127,6 +131,7 @@ class ScriptEditorDebugger : public Control { void _scene_tree_request(); void _parse_message(const String& p_msg,const Array& p_data); + void _video_mem_request(); int _get_node_path_cache(const NodePath& p_path); |