summaryrefslogtreecommitdiff
path: root/tools/editor
diff options
context:
space:
mode:
Diffstat (limited to 'tools/editor')
-rw-r--r--tools/editor/animation_editor.cpp230
-rw-r--r--tools/editor/animation_editor.h14
-rw-r--r--tools/editor/array_property_edit.cpp19
-rw-r--r--tools/editor/array_property_edit.h2
-rw-r--r--tools/editor/call_dialog.cpp2
-rw-r--r--tools/editor/call_dialog.h2
-rw-r--r--tools/editor/code_editor.cpp3
-rw-r--r--tools/editor/code_editor.h2
-rw-r--r--tools/editor/connections_dialog.cpp9
-rw-r--r--tools/editor/connections_dialog.h2
-rw-r--r--tools/editor/console.cpp386
-rw-r--r--tools/editor/create_dialog.cpp2
-rw-r--r--tools/editor/create_dialog.h2
-rw-r--r--tools/editor/default_saver.cpp2
-rw-r--r--tools/editor/default_saver.h2
-rw-r--r--tools/editor/doc_code_font.h2
-rw-r--r--tools/editor/doc_font.h2
-rw-r--r--tools/editor/doc_title_font.h2
-rw-r--r--tools/editor/editor_data.cpp110
-rw-r--r--tools/editor/editor_data.h7
-rw-r--r--tools/editor/editor_dir_dialog.cpp19
-rw-r--r--tools/editor/editor_dir_dialog.h2
-rw-r--r--tools/editor/editor_file_dialog.cpp90
-rw-r--r--tools/editor/editor_file_dialog.h7
-rw-r--r--tools/editor/editor_file_system.cpp950
-rw-r--r--tools/editor/editor_file_system.h89
-rw-r--r--tools/editor/editor_fonts.cpp2
-rw-r--r--tools/editor/editor_fonts.h2
-rw-r--r--tools/editor/editor_help.cpp24
-rw-r--r--tools/editor/editor_help.h2
-rw-r--r--tools/editor/editor_icons.h2
-rw-r--r--tools/editor/editor_import_export.cpp200
-rw-r--r--tools/editor/editor_import_export.h30
-rw-r--r--tools/editor/editor_log.cpp57
-rw-r--r--tools/editor/editor_log.h12
-rw-r--r--tools/editor/editor_name_dialog.cpp89
-rw-r--r--tools/editor/editor_name_dialog.h (renamed from tools/editor/console.h)93
-rw-r--r--tools/editor/editor_node.cpp948
-rw-r--r--tools/editor/editor_node.h81
-rw-r--r--tools/editor/editor_path.cpp2
-rw-r--r--tools/editor/editor_path.h2
-rw-r--r--tools/editor/editor_plugin.cpp2
-rw-r--r--tools/editor/editor_plugin.h3
-rw-r--r--tools/editor/editor_reimport_dialog.cpp2
-rw-r--r--tools/editor/editor_reimport_dialog.h2
-rw-r--r--tools/editor/editor_run.cpp2
-rw-r--r--tools/editor/editor_run.h2
-rw-r--r--tools/editor/editor_run_native.cpp2
-rw-r--r--tools/editor/editor_run_native.h2
-rw-r--r--tools/editor/editor_selection.cpp2
-rw-r--r--tools/editor/editor_selection.h2
-rw-r--r--tools/editor/editor_settings.cpp4
-rw-r--r--tools/editor/editor_settings.h3
-rw-r--r--tools/editor/editor_sub_scene.cpp14
-rw-r--r--tools/editor/editor_sub_scene.h2
-rw-r--r--tools/editor/editor_vu.cpp2
-rw-r--r--tools/editor/editor_vu.h2
-rw-r--r--tools/editor/file_type_cache.cpp2
-rw-r--r--tools/editor/file_type_cache.h2
-rw-r--r--tools/editor/groups_editor.cpp167
-rw-r--r--tools/editor/groups_editor.h38
-rw-r--r--tools/editor/icons/icon_add_track.pngbin446 -> 165 bytes
-rw-r--r--tools/editor/icons/icon_console.pngbin0 -> 640 bytes
-rw-r--r--tools/editor/icons/icon_create_new_scene_from.pngbin0 -> 588 bytes
-rw-r--r--tools/editor/icons/icon_edit_pivot.pngbin0 -> 407 bytes
-rw-r--r--tools/editor/icons/icon_key_invalid.pngbin0 -> 239 bytes
-rw-r--r--tools/editor/icons/icon_key_invalid_hover.pngbin0 -> 239 bytes
-rw-r--r--tools/editor/icons/icon_list_select.pngbin0 -> 470 bytes
-rw-r--r--tools/editor/icons/icon_pin.pngbin381 -> 428 bytes
-rw-r--r--tools/editor/import_settings.cpp2
-rw-r--r--tools/editor/import_settings.h2
-rw-r--r--tools/editor/io_plugins/editor_atlas.cpp2
-rw-r--r--tools/editor/io_plugins/editor_atlas.h2
-rw-r--r--tools/editor/io_plugins/editor_export_scene.cpp112
-rw-r--r--tools/editor/io_plugins/editor_export_scene.h16
-rw-r--r--tools/editor/io_plugins/editor_font_import_plugin.cpp28
-rw-r--r--tools/editor/io_plugins/editor_font_import_plugin.h2
-rw-r--r--tools/editor/io_plugins/editor_import_collada.cpp45
-rw-r--r--tools/editor/io_plugins/editor_import_collada.h2
-rw-r--r--tools/editor/io_plugins/editor_sample_import_plugin.cpp4
-rw-r--r--tools/editor/io_plugins/editor_sample_import_plugin.h2
-rw-r--r--tools/editor/io_plugins/editor_scene_import_plugin.cpp2
-rw-r--r--tools/editor/io_plugins/editor_scene_import_plugin.h2
-rw-r--r--tools/editor/io_plugins/editor_texture_import_plugin.cpp6
-rw-r--r--tools/editor/io_plugins/editor_texture_import_plugin.h2
-rw-r--r--tools/editor/io_plugins/editor_translation_import_plugin.cpp2
-rw-r--r--tools/editor/io_plugins/editor_translation_import_plugin.h2
-rw-r--r--tools/editor/optimized_save_dialog.cpp2
-rw-r--r--tools/editor/optimized_save_dialog.h2
-rw-r--r--tools/editor/output_strings.cpp2
-rw-r--r--tools/editor/output_strings.h2
-rw-r--r--tools/editor/pane_drag.cpp2
-rw-r--r--tools/editor/pane_drag.h2
-rw-r--r--tools/editor/plugins/animation_data_editor_plugin.cpp2
-rw-r--r--tools/editor/plugins/animation_data_editor_plugin.h2
-rw-r--r--tools/editor/plugins/animation_player_editor_plugin.cpp318
-rw-r--r--tools/editor/plugins/animation_player_editor_plugin.h21
-rw-r--r--tools/editor/plugins/animation_tree_editor_plugin.cpp25
-rw-r--r--tools/editor/plugins/animation_tree_editor_plugin.h3
-rw-r--r--tools/editor/plugins/camera_editor_plugin.cpp2
-rw-r--r--tools/editor/plugins/camera_editor_plugin.h2
-rw-r--r--tools/editor/plugins/canvas_item_editor_plugin.cpp329
-rw-r--r--tools/editor/plugins/canvas_item_editor_plugin.h11
-rw-r--r--tools/editor/plugins/collision_polygon_editor_plugin.cpp2
-rw-r--r--tools/editor/plugins/collision_polygon_editor_plugin.h2
-rw-r--r--tools/editor/plugins/color_ramp_editor_plugin.cpp17
-rw-r--r--tools/editor/plugins/color_ramp_editor_plugin.h3
-rw-r--r--tools/editor/plugins/control_editor_plugin.cpp2
-rw-r--r--tools/editor/plugins/control_editor_plugin.h2
-rw-r--r--tools/editor/plugins/cube_grid_theme_editor_plugin.cpp2
-rw-r--r--tools/editor/plugins/cube_grid_theme_editor_plugin.h2
-rw-r--r--tools/editor/plugins/editor_preview_plugins.cpp95
-rw-r--r--tools/editor/plugins/editor_preview_plugins.h11
-rw-r--r--tools/editor/plugins/item_list_editor_plugin.cpp367
-rw-r--r--tools/editor/plugins/item_list_editor_plugin.h140
-rw-r--r--tools/editor/plugins/mesh_editor_plugin.cpp134
-rw-r--r--tools/editor/plugins/mesh_editor_plugin.h13
-rw-r--r--tools/editor/plugins/multimesh_editor_plugin.cpp2
-rw-r--r--tools/editor/plugins/multimesh_editor_plugin.h2
-rw-r--r--tools/editor/plugins/particles_2d_editor_plugin.cpp2
-rw-r--r--tools/editor/plugins/particles_2d_editor_plugin.h2
-rw-r--r--tools/editor/plugins/particles_editor_plugin.cpp2
-rw-r--r--tools/editor/plugins/particles_editor_plugin.h2
-rw-r--r--tools/editor/plugins/path_2d_editor_plugin.cpp4
-rw-r--r--tools/editor/plugins/path_2d_editor_plugin.h2
-rw-r--r--tools/editor/plugins/path_editor_plugin.cpp2
-rw-r--r--tools/editor/plugins/path_editor_plugin.h2
-rw-r--r--tools/editor/plugins/polygon_2d_editor_plugin.cpp3
-rw-r--r--tools/editor/plugins/resource_preloader_editor_plugin.cpp20
-rw-r--r--tools/editor/plugins/resource_preloader_editor_plugin.h3
-rw-r--r--tools/editor/plugins/rich_text_editor_plugin.cpp2
-rw-r--r--tools/editor/plugins/rich_text_editor_plugin.h2
-rw-r--r--tools/editor/plugins/sample_editor_plugin.cpp2
-rw-r--r--tools/editor/plugins/sample_editor_plugin.h2
-rw-r--r--tools/editor/plugins/sample_library_editor_plugin.cpp22
-rw-r--r--tools/editor/plugins/sample_library_editor_plugin.h3
-rw-r--r--tools/editor/plugins/sample_player_editor_plugin.cpp2
-rw-r--r--tools/editor/plugins/sample_player_editor_plugin.h2
-rw-r--r--tools/editor/plugins/script_editor_plugin.cpp198
-rw-r--r--tools/editor/plugins/script_editor_plugin.h13
-rw-r--r--tools/editor/plugins/shader_editor_plugin.cpp12
-rw-r--r--tools/editor/plugins/shader_editor_plugin.h2
-rw-r--r--tools/editor/plugins/shader_graph_editor_plugin.cpp6
-rw-r--r--tools/editor/plugins/shader_graph_editor_plugin.h4
-rw-r--r--tools/editor/plugins/spatial_editor_plugin.cpp234
-rw-r--r--tools/editor/plugins/spatial_editor_plugin.h11
-rw-r--r--tools/editor/plugins/sprite_frames_editor_plugin.cpp21
-rw-r--r--tools/editor/plugins/sprite_frames_editor_plugin.h3
-rw-r--r--tools/editor/plugins/sprite_region_editor_plugin.cpp59
-rw-r--r--tools/editor/plugins/sprite_region_editor_plugin.h12
-rw-r--r--tools/editor/plugins/stream_editor_plugin.cpp2
-rw-r--r--tools/editor/plugins/stream_editor_plugin.h2
-rw-r--r--tools/editor/plugins/style_box_editor_plugin.cpp21
-rw-r--r--tools/editor/plugins/style_box_editor_plugin.h3
-rw-r--r--tools/editor/plugins/theme_editor_plugin.cpp17
-rw-r--r--tools/editor/plugins/theme_editor_plugin.h3
-rw-r--r--tools/editor/plugins/tile_map_editor_plugin.cpp46
-rw-r--r--tools/editor/plugins/tile_map_editor_plugin.h2
-rw-r--r--tools/editor/plugins/tile_set_editor_plugin.cpp49
-rw-r--r--tools/editor/plugins/tile_set_editor_plugin.h9
-rw-r--r--tools/editor/progress_dialog.cpp14
-rw-r--r--tools/editor/progress_dialog.h5
-rw-r--r--tools/editor/project_export.cpp52
-rw-r--r--tools/editor/project_export.h3
-rw-r--r--tools/editor/project_manager.cpp28
-rw-r--r--tools/editor/project_manager.h3
-rw-r--r--tools/editor/project_settings.cpp295
-rw-r--r--tools/editor/project_settings.h10
-rw-r--r--tools/editor/property_editor.cpp516
-rw-r--r--tools/editor/property_editor.h36
-rw-r--r--tools/editor/pvrtc_compress.cpp2
-rw-r--r--tools/editor/pvrtc_compress.h2
-rw-r--r--tools/editor/quick_open.cpp76
-rw-r--r--tools/editor/quick_open.h7
-rw-r--r--tools/editor/register_exporters.h2
-rw-r--r--tools/editor/reparent_dialog.cpp31
-rw-r--r--tools/editor/reparent_dialog.h9
-rw-r--r--tools/editor/resources_dock.cpp2
-rw-r--r--tools/editor/resources_dock.h2
-rw-r--r--tools/editor/run_settings_dialog.cpp2
-rw-r--r--tools/editor/run_settings_dialog.h2
-rw-r--r--tools/editor/scene_tree_dock.cpp190
-rw-r--r--tools/editor/scene_tree_dock.h8
-rw-r--r--tools/editor/scene_tree_editor.cpp16
-rw-r--r--tools/editor/scene_tree_editor.h2
-rw-r--r--tools/editor/scenes.cpp2
-rw-r--r--tools/editor/scenes.h2
-rw-r--r--tools/editor/scenes_dock.cpp14
-rw-r--r--tools/editor/scenes_dock.h3
-rw-r--r--tools/editor/script_create_dialog.cpp2
-rw-r--r--tools/editor/script_create_dialog.h2
-rw-r--r--tools/editor/script_editor_debugger.cpp46
-rw-r--r--tools/editor/script_editor_debugger.h10
-rw-r--r--tools/editor/settings_config_dialog.cpp14
-rw-r--r--tools/editor/settings_config_dialog.h4
-rw-r--r--tools/editor/spatial_editor_gizmos.cpp6
-rw-r--r--tools/editor/spatial_editor_gizmos.h2
197 files changed, 4946 insertions, 2806 deletions
diff --git a/tools/editor/animation_editor.cpp b/tools/editor/animation_editor.cpp
index ace6fda696..cdce910665 100644
--- a/tools/editor/animation_editor.cpp
+++ b/tools/editor/animation_editor.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -34,6 +34,7 @@
#include "pair.h"
#include "scene/gui/separator.h"
#include "editor_node.h"
+#include "tools/editor/plugins/animation_player_editor_plugin.h"
/* Missing to fix:
*Set
@@ -903,6 +904,23 @@ void AnimationKeyEditor::_menu_track(int p_type) {
optimize_dialog->popup_centered(Size2(250,180));
} break;
+ case TRACK_MENU_CLEAN_UP: {
+
+ cleanup_dialog->popup_centered_minsize(Size2(300,0));
+ } break;
+ case TRACK_MENU_CLEAN_UP_CONFIRM: {
+
+ if (cleanup_all->is_pressed()) {
+ List<StringName> names;
+ AnimationPlayerEditor::singleton->get_player()->get_animation_list(&names);
+ for (List<StringName>::Element *E=names.front();E;E=E->next()) {
+ _cleanup_animation(AnimationPlayerEditor::singleton->get_player()->get_animation(E->get()));
+ }
+ } else {
+ _cleanup_animation(animation);
+
+ }
+ } break;
case CURVE_SET_LINEAR: {
curve_edit->force_transition(1.0);
@@ -933,6 +951,57 @@ void AnimationKeyEditor::_menu_track(int p_type) {
}
+void AnimationKeyEditor::_cleanup_animation(Ref<Animation> p_animation) {
+
+
+ for(int i=0;i<p_animation->get_track_count();i++) {
+
+ bool prop_exists=false;
+ Variant::Type valid_type=Variant::NIL;
+ Object *obj=NULL;
+
+ RES res;
+ Node *node = root->get_node_and_resource(p_animation->track_get_path(i),res);
+
+ if (res.is_valid()) {
+ obj=res.ptr();
+ } else if (node) {
+ obj=node;
+ }
+
+ if (obj && p_animation->track_get_type(i)==Animation::TYPE_VALUE) {
+ valid_type=obj->get_static_property_type(p_animation->track_get_path(i).get_property(),&prop_exists);
+ }
+
+ if (!obj && cleanup_tracks->is_pressed()) {
+
+ p_animation->remove_track(i);
+ i--;
+ continue;
+ }
+
+ if (!prop_exists || p_animation->track_get_type(i)!=Animation::TYPE_VALUE || cleanup_keys->is_pressed()==false)
+ continue;
+
+ for(int j=0;j<p_animation->track_get_key_count(i);j++) {
+
+ Variant v = p_animation->track_get_key_value(i,j);
+
+ if (!Variant::can_convert(v.get_type(),valid_type)) {
+ p_animation->track_remove_key(i,j);
+ j--;
+ }
+ }
+
+ if (p_animation->track_get_key_count(i)==0 && cleanup_tracks->is_pressed()) {
+ p_animation->remove_track(i);
+ i--;
+ }
+ }
+
+ undo_redo->clear_history();
+ _update_paths();
+}
void AnimationKeyEditor::_animation_optimize() {
@@ -1016,6 +1085,7 @@ void AnimationKeyEditor::_track_editor_draw() {
move_up_button->set_disabled(true);
move_down_button->set_disabled(true);
remove_button->set_disabled(true);
+
return;
}
@@ -1042,6 +1112,7 @@ void AnimationKeyEditor::_track_editor_draw() {
timecolor = Color::html("ff4a414f");
Color hover_color = Color(1,1,1,0.05);
Color select_color = Color(1,1,1,0.1);
+ Color invalid_path_color = Color(1,0.6,0.4,0.5);
Color track_select_color =Color::html("ffbd8e8e");
Ref<Texture> remove_icon = get_icon("Remove","EditorIcons");
@@ -1068,6 +1139,9 @@ void AnimationKeyEditor::_track_editor_draw() {
get_icon("KeyCall","EditorIcons")
};
+ Ref<Texture> invalid_icon = get_icon("KeyInvalid","EditorIcons");
+ Ref<Texture> invalid_icon_hover = get_icon("KeyInvalidHover","EditorIcons");
+
Ref<Texture> hsize_icon = get_icon("Hsize","EditorIcons");
Ref<Texture> type_hover=get_icon("KeyHover","EditorIcons");
@@ -1254,6 +1328,23 @@ void AnimationKeyEditor::_track_editor_draw() {
break;
int y = h+i*h+sep;
+ bool prop_exists=false;
+ Variant::Type valid_type=Variant::NIL;
+ Object *obj=NULL;
+
+ RES res;
+ Node *node = root->get_node_and_resource(animation->track_get_path(idx),res);
+
+ if (res.is_valid()) {
+ obj=res.ptr();
+ } else if (node) {
+ obj=node;
+ }
+
+ if (obj && animation->track_get_type(idx)==Animation::TYPE_VALUE) {
+ valid_type=obj->get_static_property_type(animation->track_get_path(idx).get_property(),&prop_exists);
+ }
+
if (/*mouse_over.over!=MouseOver::OVER_NONE &&*/ idx==mouse_over.track) {
Color sepc=hover_color;
@@ -1274,6 +1365,8 @@ void AnimationKeyEditor::_track_editor_draw() {
ncol=track_select_color;
te->draw_string(font,Point2(ofs+Point2(type_icon[0]->get_width()+sep,y+font->get_ascent()+(sep/2))).floor(),np,ncol,name_limit-(type_icon[0]->get_width()+sep)-5);
+ if (!obj)
+ te->draw_line(ofs+Point2(0,y+h/2),ofs+Point2(name_limit,y+h/2),invalid_path_color);
te->draw_line(ofs+Point2(0,y+h),ofs+Point2(size.width,y+h),sepcolor);
@@ -1339,6 +1432,8 @@ void AnimationKeyEditor::_track_editor_draw() {
int kc=animation->track_get_key_count(idx);
bool first=true;
+
+
for(int i=0;i<kc;i++) {
@@ -1386,7 +1481,21 @@ void AnimationKeyEditor::_track_editor_draw() {
}
- te->draw_texture(tex,ofs+Point2(x,y+key_vofs).floor());
+ if (prop_exists && !Variant::can_convert(value.get_type(),valid_type)) {
+ te->draw_texture(invalid_icon,ofs+Point2(x,y+key_vofs).floor());
+ }
+
+ if (prop_exists && !Variant::can_convert(value.get_type(),valid_type)) {
+ if (tex==type_hover)
+ te->draw_texture(invalid_icon_hover,ofs+Point2(x,y+key_vofs).floor());
+ else
+ te->draw_texture(invalid_icon,ofs+Point2(x,y+key_vofs).floor());
+ } else {
+
+ te->draw_texture(tex,ofs+Point2(x,y+key_vofs).floor());
+ }
+
+
first=false;
}
@@ -1594,7 +1703,7 @@ bool AnimationKeyEditor::_edit_if_single_selection() {
if (selection.size()==0) {
curve_edit->set_mode(AnimationCurveEdit::MODE_DISABLED);
- print_line("disable");
+ //print_line("disable");
} else {
curve_edit->set_mode(AnimationCurveEdit::MODE_MULTIPLE);
@@ -1605,13 +1714,13 @@ bool AnimationKeyEditor::_edit_if_single_selection() {
curve_edit->set_multiple(animation->track_get_key_transition(E->key().track,E->key().key));
}
- print_line("multiple");
+ //print_line("multiple");
}
return false;
}
curve_edit->set_mode(AnimationCurveEdit::MODE_SINGLE);
- print_line("regular");
+ //print_line("regular");
int idx = selection.front()->key().track;
int key = selection.front()->key().key;
@@ -2555,6 +2664,8 @@ void AnimationKeyEditor::_track_editor_input_event(const InputEvent& p_input) {
String text;
text="time: "+rtos(animation->track_get_key_time(idx,mouse_over.over_key))+"\n";
+
+
switch(animation->track_get_type(idx)) {
case Animation::TYPE_TRANSFORM: {
@@ -2569,8 +2680,33 @@ void AnimationKeyEditor::_track_editor_input_event(const InputEvent& p_input) {
} break;
case Animation::TYPE_VALUE: {
- Variant v = animation->track_get_key_value(idx,mouse_over.over_key);
- text+="value: "+String(v)+"\n";
+ Variant v = animation->track_get_key_value(idx,mouse_over.over_key);;
+ //text+="value: "+String(v)+"\n";
+
+ bool prop_exists=false;
+ Variant::Type valid_type=Variant::NIL;
+ Object *obj=NULL;
+
+ RES res;
+ Node *node = root->get_node_and_resource(animation->track_get_path(idx),res);
+
+ if (res.is_valid()) {
+ obj=res.ptr();
+ } else if (node) {
+ obj=node;
+ }
+
+ if (obj) {
+ valid_type=obj->get_static_property_type(animation->track_get_path(idx).get_property(),&prop_exists);
+ }
+
+ text+="type: "+Variant::get_type_name(v.get_type())+"\n";
+ if (prop_exists && !Variant::can_convert(v.get_type(),valid_type)) {
+ text+="value: "+String(v)+" (Invalid, expected type: "+Variant::get_type_name(valid_type)+")\n";
+ } else {
+ text+="value: "+String(v)+"\n";
+ }
+
} break;
case Animation::TYPE_METHOD: {
@@ -2593,6 +2729,9 @@ void AnimationKeyEditor::_track_editor_input_event(const InputEvent& p_input) {
} break;
}
text+="easing: "+rtos(animation->track_get_key_transition(idx,mouse_over.over_key));
+
+
+
track_editor->set_tooltip(text);
return;
@@ -2668,9 +2807,15 @@ void AnimationKeyEditor::_notification(int p_what) {
switch(p_what) {
+ case NOTIFICATION_VISIBILITY_CHANGED: {
+
+ EditorNode::get_singleton()->update_keying();
+ } break;
case NOTIFICATION_ENTER_TREE: {
+ key_editor->edit(key_edit);
+
zoomicon->set_texture( get_icon("Zoom","EditorIcons") );
menu_add_track->set_icon(get_icon("AddTrack","EditorIcons"));
@@ -2703,6 +2848,7 @@ void AnimationKeyEditor::_notification(int p_what) {
//menu_track->get_popup()->add_submenu_item("Set Transitions..","Transitions");
//menu_track->get_popup()->add_separator();
menu_track->get_popup()->add_item("Optimize Animation",TRACK_MENU_OPTIMIZE);
+ menu_track->get_popup()->add_item("Clean-Up Animation",TRACK_MENU_CLEAN_UP);
curve_linear->set_icon(get_icon("CurveLinear","EditorIcons"));
curve_in->set_icon(get_icon("CurveIn","EditorIcons"));
@@ -2849,6 +2995,8 @@ void AnimationKeyEditor::set_animation(const Ref<Animation>& p_anim) {
_update_menu();
selected_track=-1;
_edit_if_single_selection();
+
+ EditorNode::get_singleton()->update_keying();
}
void AnimationKeyEditor::set_root(Node *p_root) {
@@ -2878,13 +3026,13 @@ void AnimationKeyEditor::set_keying(bool p_enabled) {
keying=p_enabled;
_update_menu();
- emit_signal("keying_changed",p_enabled);
+ emit_signal("keying_changed");
}
bool AnimationKeyEditor::has_keying() const {
- return keying;
+ return is_visible() && animation.is_valid();
}
void AnimationKeyEditor::_query_insert(const InsertData& p_id) {
@@ -3213,6 +3361,7 @@ Ref<Animation> AnimationKeyEditor::get_current_animation() const {
void AnimationKeyEditor::_animation_len_changed(float p_len) {
+
if (updating)
return;
@@ -3340,8 +3489,10 @@ void AnimationKeyEditor::_insert_delay() {
void AnimationKeyEditor::_step_changed(float p_len) {
updating=true;
- if (!animation.is_null())
+ if (!animation.is_null()) {
animation->set_step(p_len);
+ emit_signal("animation_step_changed",animation->get_step());
+ }
updating=false;
}
@@ -3552,21 +3703,33 @@ void AnimationKeyEditor::_bind_methods() {
ADD_SIGNAL( MethodInfo("keying_changed" ) );
ADD_SIGNAL( MethodInfo("timeline_changed", PropertyInfo(Variant::REAL,"pos") ) );
ADD_SIGNAL( MethodInfo("animation_len_changed", PropertyInfo(Variant::REAL,"len") ) );
+ ADD_SIGNAL( MethodInfo("animation_step_changed", PropertyInfo(Variant::REAL,"step") ) );
ADD_SIGNAL( MethodInfo("key_edited", PropertyInfo(Variant::INT,"track"), PropertyInfo(Variant::INT,"key") ) );
}
-AnimationKeyEditor::AnimationKeyEditor(UndoRedo *p_undo_redo, EditorHistory *p_history,EditorSelection *p_selection) {
+AnimationKeyEditor::AnimationKeyEditor() {
alc="animation_len_changed";
- editor_selection=p_selection;
+ editor_selection=EditorNode::get_singleton()->get_editor_selection();
selected_track=-1;
updating=false;
te_drawing=false;
- undo_redo=p_undo_redo;
- history=p_history;
+ undo_redo=EditorNode::get_singleton()->get_undo_redo();
+ history=EditorNode::get_singleton()->get_editor_history();
+
+ ec = memnew (Control);
+ ec->set_custom_minimum_size(Size2(0,150));
+ add_child(ec);
+ ec->set_v_size_flags(SIZE_EXPAND_FILL);
+
+ h_scroll = memnew( HScrollBar );
+ h_scroll->connect("value_changed",this,"_scroll_changed");
+ add_child(h_scroll);
+ h_scroll->set_val(0);
+
HBoxContainer *hb = memnew( HBoxContainer );
add_child(hb);
@@ -3724,10 +3887,6 @@ AnimationKeyEditor::AnimationKeyEditor(UndoRedo *p_undo_redo, EditorHistory *p_h
// menu->get_popup()->connect("item_pressed",this,"_menu_callback");
- ec = memnew (Control);
- ec->set_custom_minimum_size(Size2(0,150));
- add_child(ec);
- ec->set_v_size_flags(SIZE_EXPAND_FILL);
hb = memnew( HBoxContainer);
hb->set_area_as_parent_rect();
@@ -3767,7 +3926,7 @@ AnimationKeyEditor::AnimationKeyEditor(UndoRedo *p_undo_redo, EditorHistory *p_h
key_edit = memnew( AnimationKeyEdit );
key_edit->undo_redo=undo_redo;
//key_edit->ke_dialog=key_edit_dialog;
- key_editor->edit(key_edit);
+
type_menu = memnew( PopupMenu );
add_child(type_menu);
for(int i=0;i<Variant::VARIANT_MAX;i++)
@@ -3804,12 +3963,6 @@ AnimationKeyEditor::AnimationKeyEditor(UndoRedo *p_undo_redo, EditorHistory *p_h
curve_edit->set_v_size_flags(SIZE_EXPAND_FILL);
key_editor_tab->add_child(curve_vb);
- h_scroll = memnew( HScrollBar );
- h_scroll->connect("value_changed",this,"_scroll_changed");
- add_child(h_scroll);
- h_scroll->set_val(0);
-
-
track_name = memnew( LineEdit );
track_name->set_as_toplevel(true);
track_name->hide();
@@ -3862,6 +4015,33 @@ AnimationKeyEditor::AnimationKeyEditor(UndoRedo *p_undo_redo, EditorHistory *p_h
add_child(call_select);
call_select->set_title("Call Functions in Which Node?");
+ cleanup_dialog = memnew( ConfirmationDialog );
+ add_child(cleanup_dialog);
+ VBoxContainer *cleanup_vb = memnew( VBoxContainer );
+ cleanup_dialog->add_child(cleanup_vb);
+ cleanup_dialog->set_child_rect(cleanup_vb);
+ cleanup_keys = memnew( CheckButton );
+ cleanup_keys->set_text("Remove invalid keys");
+ cleanup_keys->set_pressed(true);
+ cleanup_vb->add_child(cleanup_keys);
+
+ cleanup_tracks = memnew( CheckButton );
+ cleanup_tracks->set_text("Remove unresolved and empty tracks");
+ cleanup_tracks->set_pressed(true);
+ cleanup_vb->add_child(cleanup_tracks);
+
+ cleanup_all = memnew( CheckButton );
+ cleanup_all->set_text("Clean-Up all animations");
+ cleanup_vb->add_child(cleanup_all);
+
+ cleanup_dialog->set_title("Clean up Animation(s) (NO UNDO!)");
+ cleanup_dialog->get_ok()->set_text("Clean-Up");
+
+ cleanup_dialog->connect("confirmed",this,"_menu_track",varray(TRACK_MENU_CLEAN_UP_CONFIRM));
+
+ add_constant_override("separation",get_constant("separation","VBoxContainer"));
+
+
}
AnimationKeyEditor::~AnimationKeyEditor() {
diff --git a/tools/editor/animation_editor.h b/tools/editor/animation_editor.h
index 629377d78e..c8a539179e 100644
--- a/tools/editor/animation_editor.h
+++ b/tools/editor/animation_editor.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -89,6 +89,8 @@ class AnimationKeyEditor : public VBoxContainer {
TRACK_MENU_NEXT_STEP,
TRACK_MENU_PREV_STEP,
TRACK_MENU_OPTIMIZE,
+ TRACK_MENU_CLEAN_UP,
+ TRACK_MENU_CLEAN_UP_CONFIRM,
CURVE_SET_LINEAR,
CURVE_SET_IN,
CURVE_SET_OUT,
@@ -190,6 +192,11 @@ class AnimationKeyEditor : public VBoxContainer {
SpinBox *optimize_angular_error;
SpinBox *optimize_max_angle;
+ ConfirmationDialog *cleanup_dialog;
+ CheckButton *cleanup_keys;
+ CheckButton *cleanup_tracks;
+ CheckButton *cleanup_all;
+
SpinBox *step;
MenuButton *menu_add_track;
@@ -255,7 +262,7 @@ class AnimationKeyEditor : public VBoxContainer {
EditorSelection *editor_selection;
- AnimationKeyEditor();
+
float _get_zoom_scale() const;
@@ -284,6 +291,7 @@ class AnimationKeyEditor : public VBoxContainer {
void _animation_changed();
void _animation_optimize();
+ void _cleanup_animation(Ref<Animation> p_animation);
void _scroll_changed(double);
@@ -326,7 +334,7 @@ public:
void insert_value_key(const String& p_property, const Variant& p_value, bool p_advance);
void insert_transform_key(Spatial *p_node,const String& p_sub,const Transform& p_xform);
- AnimationKeyEditor(UndoRedo *p_undo_redo, EditorHistory *p_history, EditorSelection *p_selection);
+ AnimationKeyEditor();
~AnimationKeyEditor();
};
diff --git a/tools/editor/array_property_edit.cpp b/tools/editor/array_property_edit.cpp
index 9cd443270b..66c2782da5 100644
--- a/tools/editor/array_property_edit.cpp
+++ b/tools/editor/array_property_edit.cpp
@@ -72,6 +72,15 @@ bool ArrayPropertyEdit::_set(const StringName& p_name, const Variant& p_value){
ur->add_undo_method(this,"_set_value",i,arr.get(i));
}
+ } else if (newsize>size && size) {
+
+ Variant init;
+ Variant::CallError ce;
+ init = Variant::construct(arr.get(size-1).get_type(),NULL,0,ce);
+ for(int i=size;i<newsize;i++) {
+ ur->add_do_method(this,"_set_value",i,init);
+ }
+
}
ur->add_do_method(this,"_notif_change");
ur->add_undo_method(this,"_notif_change");
@@ -83,6 +92,7 @@ bool ArrayPropertyEdit::_set(const StringName& p_name, const Variant& p_value){
_change_notify();
return true;
}
+
} else if (pn.begins_with("indices")) {
if (pn.find("_")!=-1) {
@@ -209,6 +219,15 @@ void ArrayPropertyEdit::edit(Object* p_obj,const StringName& p_prop,Variant::Typ
}
+Node *ArrayPropertyEdit::get_node() {
+
+ Object *o = ObjectDB::get_instance(obj);
+ if (!o)
+ return NULL;
+
+ return o->cast_to<Node>();
+}
+
void ArrayPropertyEdit::_bind_methods() {
ObjectTypeDB::bind_method(_MD("_set_size"),&ArrayPropertyEdit::_set_size);
diff --git a/tools/editor/array_property_edit.h b/tools/editor/array_property_edit.h
index acfb8e68ed..948b2a71a3 100644
--- a/tools/editor/array_property_edit.h
+++ b/tools/editor/array_property_edit.h
@@ -30,6 +30,8 @@ public:
void edit(Object* p_obj, const StringName& p_prop, Variant::Type p_deftype);
+ Node *get_node();
+
ArrayPropertyEdit();
};
diff --git a/tools/editor/call_dialog.cpp b/tools/editor/call_dialog.cpp
index 0e3abcf4ef..edcd7371f2 100644
--- a/tools/editor/call_dialog.cpp
+++ b/tools/editor/call_dialog.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/call_dialog.h b/tools/editor/call_dialog.h
index fe69847796..2d04e7b6cd 100644
--- a/tools/editor/call_dialog.h
+++ b/tools/editor/call_dialog.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/code_editor.cpp b/tools/editor/code_editor.cpp
index 0728b3b7c1..fe863bfebc 100644
--- a/tools/editor/code_editor.cpp
+++ b/tools/editor/code_editor.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -612,6 +612,7 @@ CodeTextEditor::CodeTextEditor() {
if (!font_overrode)
text_editor->add_font_override("font",get_font("source","Fonts"));
+
text_editor->set_show_line_numbers(true);
text_editor->set_brace_matching(true);
text_editor->set_auto_indent(true);
diff --git a/tools/editor/code_editor.h b/tools/editor/code_editor.h
index 0c32aeb68f..5ed7ce9052 100644
--- a/tools/editor/code_editor.h
+++ b/tools/editor/code_editor.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/connections_dialog.cpp b/tools/editor/connections_dialog.cpp
index d4937d7114..1e530b21c2 100644
--- a/tools/editor/connections_dialog.cpp
+++ b/tools/editor/connections_dialog.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -96,7 +96,11 @@ void ConnectDialog::_notification(int p_what) {
RID ci = get_canvas_item();
get_stylebox("panel","PopupMenu")->draw(ci,Rect2(Point2(),get_size()));
- }
+ }
+
+ if (p_what==NOTIFICATION_ENTER_TREE) {
+ bind_editor->edit(cdbinds);
+ }
}
void ConnectDialog::_tree_node_selected() {
@@ -456,7 +460,6 @@ ConnectDialog::ConnectDialog() {
set_as_toplevel(true);
cdbinds = memnew( ConnectDialogBinds );
- bind_editor->edit(cdbinds);
error = memnew( ConfirmationDialog );
add_child(error);
diff --git a/tools/editor/connections_dialog.h b/tools/editor/connections_dialog.h
index 4a1c3f189c..d5e228e799 100644
--- a/tools/editor/connections_dialog.h
+++ b/tools/editor/connections_dialog.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/console.cpp b/tools/editor/console.cpp
deleted file mode 100644
index 0c98f05706..0000000000
--- a/tools/editor/console.cpp
+++ /dev/null
@@ -1,386 +0,0 @@
-/*************************************************************************/
-/* console.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-#include "console.h"
-#include "os/os.h"
-#include "os/keyboard.h"
-
-#include "editor_icons.h"
-#include "scene/gui/label.h"
-#include "globals.h"
-
-
-void Console::_stats_update_timer_callback() {
-
- if (!status->is_visible())
- return;
-
- VisualServer *vs = VisualServer::get_singleton();
-
- stats.render_objects_in_frame->set_text(1,String::num(vs->get_render_info( VisualServer::INFO_OBJECTS_IN_FRAME ) ) );
- stats.material_changes_in_frame->set_text(1,String::num(vs->get_render_info( VisualServer::INFO_MATERIAL_CHANGES_IN_FRAME ) ) );
-
- int64_t total_vmem = vs->get_render_info( VisualServer::INFO_USAGE_VIDEO_MEM_TOTAL );
- if (total_vmem<0)
- stats.usage_video_mem_total->set_text(1, "Unknown");
- else
- stats.usage_video_mem_total->set_text(1,String::humanize_size( total_vmem ) );
-
- stats.usage_video_mem_used->set_text(1,String::humanize_size( vs->get_render_info( VisualServer::INFO_VIDEO_MEM_USED ) ) );
- stats.usage_texture_mem_used->set_text(1,String::humanize_size( vs->get_render_info( VisualServer::INFO_TEXTURE_MEM_USED ) ) );
- stats.usage_vertex_mem_used->set_text(1,String::humanize_size( vs->get_render_info( VisualServer::INFO_VERTEX_MEM_USED ) ) );
-
-
- stats.usage_static_memory_total->set_text(1,String::humanize_size( Memory::get_static_mem_available() ) );
- stats.usage_static_memory->set_text(1,String::humanize_size( Memory::get_static_mem_usage() ) );
- stats.usage_dynamic_memory_total->set_text(1,String::humanize_size( Memory::get_dynamic_mem_available() ) );
- stats.usage_dynamic_memory->set_text(1,String::humanize_size( Memory::get_dynamic_mem_usage() ) );
- stats.usage_objects_instanced->set_text(1,String::num( ObjectDB::get_object_count()) );
-
-
-}
-
-void Console::_print_handle(void *p_this,const String& p_string) {
-
-
- return;
- Console *self = (Console*)p_this;
-
- OutputQueue oq;
- oq.text=p_string;
- oq.type=OutputStrings::LINE_NORMAL;
-
-
- if (self->output_queue_mutex)
- self->output_queue_mutex->lock();
-
- self->output_queue.push_back(oq);
-
- if (self->output_queue_mutex)
- self->output_queue_mutex->unlock();
-
-}
-void Console::_error_handle(void *p_this,const char*p_function,const char* p_file,int p_line,const char *p_error, const char *p_explanation,ErrorHandlerType p_type) {
-
-
- Console *self = (Console*)p_this;
-
- OutputQueue oq;
- oq.text="ERROR: "+String(p_file)+":"+itos(p_line)+", in function: "+String(p_function);
- oq.text+="\n "+String(p_error)+".";
- if (p_explanation && p_explanation[0])
- oq.text+="\n Reason: "+String(p_explanation);
- oq.text+="\n";
- oq.type=OutputStrings::LINE_ERROR;
-
-
- if (self->output_queue_mutex)
- self->output_queue_mutex->lock();
-
- self->output_queue.push_back(oq);
-
- if (self->output_queue_mutex)
- self->output_queue_mutex->unlock();
-
-
-}
-
-void Console::_window_input_event(InputEvent p_event) {
-
- Control::_window_input_event(p_event);
-
- if (p_event.type==InputEvent::KEY && p_event.key.pressed) {
-
- if (p_event.key.scancode==KEY_QUOTELEFT && p_event.key.mod.control) {
-
- if (is_visible())
- hide();
- else {
- globals_property_editor->edit( NULL );
- globals_property_editor->edit( Globals::get_singleton() );
- show();
- };
- }
-
- if (p_event.key.scancode==KEY_ESCAPE && !window_has_modal_stack() && is_visible()) {
- hide();
- get_tree()->call_group(0,"windows","_cancel_input_ID",p_event.ID);
- }
-
-
- }
-}
-
-void Console::_window_resize_event() {
-
-// Control::_window_resize_event();
- _resized();
-}
-
-
-void Console::_resized() {
-
- set_pos( Point2( 0, OS::get_singleton()->get_video_mode().height-height) );
- set_size( Size2( OS::get_singleton()->get_video_mode().width, height) );
-}
-
-void Console::_notification(int p_what) {
-
- switch(p_what) {
-
- case NOTIFICATION_ENTER_TREE: {
-
- _resized();
- show();
- globals_property_editor->edit( Globals::get_singleton() );
-
- } break;
-
- case NOTIFICATION_PROCESS: {
- //pop messies
-
- if (output_queue_mutex)
- output_queue_mutex->lock();
-
- while(output_queue.size()) {
-
- OutputQueue q = output_queue.front()->get();
- if (q.type==OutputStrings::LINE_ERROR || q.type==OutputStrings::LINE_WARNING)
- errors->add_line(q.text,q.meta,q.type);
- output->add_line(q.text,q.meta,q.type);
- output_queue.pop_front();
- }
-
- if (output_queue_mutex)
- output_queue_mutex->unlock();
-
- } break;
- case NOTIFICATION_DRAW: {
-
- RID ci = get_canvas_item();
- get_stylebox("panel","Panel")->draw(ci,Rect2(Point2(),get_size()));
-
- } break;
- }
-}
-
-
-void Console::_close_pressed() {
-
- hide();
-}
-
-void Console::_inspector_node_selected() {
-
-
- Node *node = inspect_tree_editor->get_selected();
-
- if (!node)
- inspect_property_editor->edit(NULL);
- else {
-
- inspect_history.add_object(node->get_instance_ID());
-
- inspect_property_editor->edit(node);
- }
-
-}
-
-void Console::_bind_methods() {
-
- ObjectTypeDB::bind_method("_stats_update_timer_callback",&Console::_stats_update_timer_callback);
- ObjectTypeDB::bind_method("_close_pressed",&Console::_close_pressed);
- ObjectTypeDB::bind_method("_inspector_node_selected",&Console::_inspector_node_selected);
-}
-
-
-Console::Console() {
-
- Ref<Theme> theme( memnew( Theme ) );
- set_theme( theme );
- editor_register_icons(theme);
-
- height=300;
- tabs = memnew( TabContainer );
- tabs->set_tab_align(TabContainer::ALIGN_LEFT);
- add_child(tabs);
- tabs->set_area_as_parent_rect();
-
- output = memnew( OutputStrings );
- output->set_name("Output");
- tabs->add_child(output);
- errors = memnew( OutputStrings );
- errors->set_name("Errors");
- tabs->add_child(errors);
- status = memnew( Control );
- status->set_name("Stats");
- tabs->add_child(status);
- inspect = memnew( Control );
- inspect->set_name("Inspect");
- tabs->add_child(inspect);
- globals = memnew( Control );
- globals->set_name("Globals");
- tabs->add_child(globals);
-
- // stats
-
- stats_tree = memnew( Tree );
- stats_tree->set_hide_root(true);
- stats_tree->set_columns(2);
- status->add_child(stats_tree);
- stats_tree->set_anchor( MARGIN_BOTTOM, ANCHOR_END );
- stats_tree->set_anchor( MARGIN_RIGHT, ANCHOR_RATIO );
- stats_tree->set_margin( MARGIN_RIGHT, 0.5 );
- stats_tree->set_begin( Point2( 20,25 ) );
- stats_tree->set_end( Point2( 0.5,5 ) );
-
- Label *stats_label = memnew( Label );
- stats_label->set_text("Engine Statistics:");
- stats_label->set_pos( Point2( 5,5 ) );
- status->add_child(stats_label);
-
- TreeItem *stats_tree_root = stats_tree->create_item(NULL);
-
- {
- //system items
- TreeItem *system_item = stats_tree->create_item(stats_tree_root);
- system_item->set_text(0,"System");
-
- stats.usage_static_memory_total = stats_tree->create_item(system_item);
- stats.usage_static_memory_total->set_text(0,"Total Static Mem");;
- stats.usage_static_memory = stats_tree->create_item(system_item);
- stats.usage_static_memory->set_text(0,"Static Mem Usage");;
- stats.usage_dynamic_memory_total = stats_tree->create_item(system_item);
- stats.usage_dynamic_memory_total->set_text(0,"Total Dynamic Mem");;
- stats.usage_dynamic_memory = stats_tree->create_item(system_item);
- stats.usage_dynamic_memory->set_text(0,"Dynamic Mem Usage");
- stats.usage_objects_instanced = stats_tree->create_item(system_item);
- stats.usage_objects_instanced->set_text(0,"Instanced Objects");
-
- //render items
- TreeItem *render_item = stats_tree->create_item(stats_tree_root);
- render_item->set_text(0,"Render");
- stats.render_objects_in_frame = stats_tree->create_item(render_item);
- stats.render_objects_in_frame->set_text(0,"Visible Objects");
- stats.material_changes_in_frame = stats_tree->create_item(render_item);
- stats.material_changes_in_frame->set_text(0,"Material Changes");
- stats.usage_video_mem_total = stats_tree->create_item(render_item);
- stats.usage_video_mem_total->set_text(0,"Total Video Mem");
- stats.usage_texture_mem_used = stats_tree->create_item(render_item);
- stats.usage_texture_mem_used->set_text(0,"Texture Mem Usage");
- stats.usage_vertex_mem_used = stats_tree->create_item(render_item);
- stats.usage_vertex_mem_used->set_text(0,"Vertex Mem Usage");
- stats.usage_video_mem_used = stats_tree->create_item(render_item);
- stats.usage_video_mem_used->set_text(0,"Combined Mem Usage");
- }
-
- {
-
- inspect_tree_editor = memnew( SceneTreeEditor );
- inspect_tree_editor->set_anchor( MARGIN_RIGHT, ANCHOR_RATIO );
- inspect_tree_editor->set_anchor( MARGIN_BOTTOM, ANCHOR_END );
- inspect_tree_editor->set_begin( Point2( 20, 5 ) );
- inspect_tree_editor->set_end( Point2( 0.49, 5 ) );
- inspect->add_child(inspect_tree_editor);
-
- inspect_property_editor = memnew( PropertyEditor );
- inspect_property_editor->set_anchor( MARGIN_LEFT, ANCHOR_RATIO );
- inspect_property_editor->set_anchor( MARGIN_RIGHT, ANCHOR_END );
- inspect_property_editor->set_anchor( MARGIN_BOTTOM, ANCHOR_END );
- inspect_property_editor->set_begin( Point2( 0.51, 5 ) );
- inspect_property_editor->set_end( Point2( 5, 5 ) );
- inspect->add_child(inspect_property_editor);
- }
-
-
- { //globals
-
- globals_property_editor = memnew( PropertyEditor );
- globals_property_editor->set_anchor( MARGIN_RIGHT, ANCHOR_END );
- globals_property_editor->set_anchor( MARGIN_BOTTOM, ANCHOR_END );
- globals_property_editor->set_begin( Point2( 15, 5 ) );
- globals_property_editor->set_end( Point2( 5, 5 ) );
- globals_property_editor->get_top_label()->set_text("Globals Editor:");
- globals->add_child(globals_property_editor);
-
- }
-
-
-#ifndef NO_THREADS
- output_queue_mutex = Mutex::create();
-#else
- output_queue_mutex = NULL;
-#endif
-
-
- hide();
- set_process(true);
-
- close = memnew( Button );
- add_child(close);
- close->set_anchor( MARGIN_LEFT, ANCHOR_END);
- close->set_anchor( MARGIN_RIGHT, ANCHOR_END);
- close->set_begin( Point2( 25, 3 ) );
- close->set_end( Point2( 5, 3 ) );
- close->set_flat(true);
- close->connect("pressed", this,"_close_pressed");
-
-
- close->set_icon( get_icon("close","Icons") );
-// force_top_viewport(true);
-
-
- err_handler.userdata=this;
- err_handler.errfunc=_error_handle;
- add_error_handler(&err_handler);
-
- print_handler.userdata=this;
- print_handler.printfunc=_print_handle;
- add_print_handler(&print_handler);
-
- Timer *timer = memnew( Timer );
- add_child(timer);
- timer->set_wait_time(1);
- timer->start();
- timer->connect("timeout", this,"_stats_update_timer_callback");
- inspect_tree_editor->connect("node_selected", this,"_inspector_node_selected");
-
-
-
-}
-
-
-Console::~Console() {
-
- if (output_queue_mutex)
- memdelete(output_queue_mutex);
-
- remove_error_handler(&err_handler);
- remove_print_handler(&print_handler);
-
-}
diff --git a/tools/editor/create_dialog.cpp b/tools/editor/create_dialog.cpp
index a9119349c8..0f39d72308 100644
--- a/tools/editor/create_dialog.cpp
+++ b/tools/editor/create_dialog.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/create_dialog.h b/tools/editor/create_dialog.h
index f200e1caf5..6f959fd467 100644
--- a/tools/editor/create_dialog.h
+++ b/tools/editor/create_dialog.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/default_saver.cpp b/tools/editor/default_saver.cpp
index c865adb1eb..611232e04b 100644
--- a/tools/editor/default_saver.cpp
+++ b/tools/editor/default_saver.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/default_saver.h b/tools/editor/default_saver.h
index 4e11ff5592..2b1a1edb23 100644
--- a/tools/editor/default_saver.h
+++ b/tools/editor/default_saver.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/doc_code_font.h b/tools/editor/doc_code_font.h
index 91f67c4a41..879c873ea1 100644
--- a/tools/editor/doc_code_font.h
+++ b/tools/editor/doc_code_font.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/doc_font.h b/tools/editor/doc_font.h
index f2e5e7950b..a3c3b58b21 100644
--- a/tools/editor/doc_font.h
+++ b/tools/editor/doc_font.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/doc_title_font.h b/tools/editor/doc_title_font.h
index fb6b4eaf5b..75a3f049f0 100644
--- a/tools/editor/doc_title_font.h
+++ b/tools/editor/doc_title_font.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/editor_data.cpp b/tools/editor/editor_data.cpp
index 673ee30adb..c872b1c3ca 100644
--- a/tools/editor/editor_data.cpp
+++ b/tools/editor/editor_data.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -31,6 +31,9 @@
#include "editor_settings.h"
#include "os/dir_access.h"
#include "io/resource_loader.h"
+#include "scene/resources/packed_scene.h"
+#include "os/file_access.h"
+#include "editor_node.h"
void EditorHistory::_cleanup_history() {
@@ -338,6 +341,14 @@ void EditorData::set_editor_states(const Dictionary& p_states) {
}
+void EditorData::notify_edited_scene_changed() {
+
+ for(int i=0;i<editor_plugins.size();i++) {
+
+ editor_plugins[i]->edited_scene_changed();
+ }
+}
+
void EditorData::clear_editor_states() {
for(int i=0;i<editor_plugins.size();i++) {
@@ -485,6 +496,93 @@ void EditorData::remove_scene(int p_idx){
edited_scene.remove(p_idx);
}
+
+bool EditorData::_find_updated_instances(Node* p_root,Node *p_node,Set<String> &checked_paths) {
+
+// if (p_root!=p_node && p_node->get_owner()!=p_root && !p_root->is_editable_instance(p_node->get_owner()))
+// return false;
+
+ Ref<SceneState> ss;
+
+ if (p_node==p_root) {
+ ss=p_node->get_scene_inherited_state();
+ } else if (p_node->get_filename()!=String()){
+ ss=p_node->get_scene_instance_state();
+ }
+
+ if (ss.is_valid()) {
+ String path = ss->get_path();
+
+ if (!checked_paths.has(path)) {
+
+ uint64_t modified_time = FileAccess::get_modified_time(path);
+ if (modified_time!=ss->get_last_modified_time()) {
+ return true; //external scene changed
+ }
+
+ checked_paths.insert(path);
+ }
+
+ }
+
+ for(int i=0;i<p_node->get_child_count();i++) {
+
+ bool found = _find_updated_instances(p_root,p_node->get_child(i),checked_paths);
+ if (found)
+ return true;
+ }
+
+ return false;
+}
+
+
+bool EditorData::check_and_update_scene(int p_idx) {
+
+ ERR_FAIL_INDEX_V(p_idx,edited_scene.size(),false);
+ if (!edited_scene[p_idx].root)
+ return false;
+
+ Set<String> checked_scenes;
+
+
+ bool must_reload = _find_updated_instances(edited_scene[p_idx].root,edited_scene[p_idx].root,checked_scenes);
+
+ if (must_reload) {
+ Ref<PackedScene> pscene;
+ pscene.instance();
+
+ EditorProgress ep("update_scene","Updating Scene",2);
+ ep.step("Storing local changes..",0);
+ //pack first, so it stores diffs to previous version of saved scene
+ Error err = pscene->pack(edited_scene[p_idx].root);
+ ERR_FAIL_COND_V(err!=OK,false);
+ ep.step("Updating scene..",1);
+ Node *new_scene = pscene->instance(true);
+ ERR_FAIL_COND_V(!new_scene,false);
+
+ //transfer selection
+ List<Node*> new_selection;
+ for (List<Node*>::Element *E=edited_scene[p_idx].selection.front();E;E=E->next()) {
+ NodePath p = edited_scene[p_idx].root->get_path_to(E->get());
+ Node *new_node = new_scene->get_node(p);
+ if (new_node)
+ new_selection.push_back(new_node);
+ }
+
+ new_scene->set_filename( edited_scene[p_idx].root->get_filename() );
+
+ memdelete(edited_scene[p_idx].root);
+ edited_scene[p_idx].root=new_scene;
+ edited_scene[p_idx].selection=new_selection;
+
+ return true;
+
+ }
+
+ return false;
+
+}
+
int EditorData::get_edited_scene() const {
return current_edited_scene;
@@ -537,6 +635,16 @@ String EditorData::get_scene_type(int p_idx) const {
return edited_scene[p_idx].root->get_type();
}
+void EditorData::move_edited_scene_to_index(int p_idx) {
+
+ ERR_FAIL_INDEX(current_edited_scene,edited_scene.size());
+ ERR_FAIL_INDEX(p_idx,edited_scene.size());
+
+ EditedScene es=edited_scene[current_edited_scene];
+ edited_scene.remove(current_edited_scene);
+ edited_scene.insert(p_idx,es);
+ current_edited_scene=p_idx;
+}
Ref<Script> EditorData::get_scene_root_script(int p_idx) const {
diff --git a/tools/editor/editor_data.h b/tools/editor/editor_data.h
index c5ee83ae63..fcc8ccef06 100644
--- a/tools/editor/editor_data.h
+++ b/tools/editor/editor_data.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -144,6 +144,8 @@ private:
Vector<EditedScene> edited_scene;
int current_edited_scene;
+ bool _find_updated_instances(Node* p_root,Node *p_node,Set<String> &checked_paths);
+
public:
EditorPlugin* get_editor(Object *p_object);
@@ -193,6 +195,8 @@ public:
void clear_edited_scenes();
void set_edited_scene_live_edit_root(const NodePath& p_root);
NodePath get_edited_scene_live_edit_root();
+ bool check_and_update_scene(int p_idx);
+ void move_edited_scene_to_index(int p_idx);
void set_plugin_window_layout(Ref<ConfigFile> p_layout);
@@ -200,6 +204,7 @@ public:
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);
+ void notify_edited_scene_changed();
EditorData();
diff --git a/tools/editor/editor_dir_dialog.cpp b/tools/editor/editor_dir_dialog.cpp
index a8421acff8..8512154485 100644
--- a/tools/editor/editor_dir_dialog.cpp
+++ b/tools/editor/editor_dir_dialog.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -205,31 +205,36 @@ void EditorDirDialog::_bind_methods() {
EditorDirDialog::EditorDirDialog() {
+ updating=false;
+
set_title("Choose a Directory");
+ set_hide_on_ok(false);
+
tree = memnew( Tree );
add_child(tree);
set_child_rect(tree);
- updating=false;
- get_ok()->set_text("Choose");
- set_hide_on_ok(false);
-
-
+ tree->connect("item_activated",this,"_ok");
makedir = add_button("Create Folder",OS::get_singleton()->get_swap_ok_cancel()?true:false,"makedir");
makedir->connect("pressed",this,"_make_dir");
makedialog = memnew( ConfirmationDialog );
makedialog->set_title("Create Folder");
+ add_child(makedialog);
+
VBoxContainer *makevb= memnew( VBoxContainer );
makedialog->add_child(makevb);
makedialog->set_child_rect(makevb);
+
makedirname = memnew( LineEdit );
makevb->add_margin_child("Name:",makedirname);
- add_child(makedialog);
makedialog->register_text_enter(makedirname);
makedialog->connect("confirmed",this,"_make_dir_confirm");
+
mkdirerr = memnew( AcceptDialog );
mkdirerr->set_text("Could not create folder.");
add_child(mkdirerr);
+ get_ok()->set_text("Choose");
+
}
diff --git a/tools/editor/editor_dir_dialog.h b/tools/editor/editor_dir_dialog.h
index 8ac83b86e8..1c2593219c 100644
--- a/tools/editor/editor_dir_dialog.h
+++ b/tools/editor/editor_dir_dialog.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/editor_file_dialog.cpp b/tools/editor/editor_file_dialog.cpp
index c62347d129..a9b23767f1 100644
--- a/tools/editor/editor_file_dialog.cpp
+++ b/tools/editor/editor_file_dialog.cpp
@@ -6,6 +6,8 @@
#include "editor_resource_preview.h"
#include "editor_settings.h"
#include "scene/gui/margin_container.h"
+#include "os/file_access.h"
+
EditorFileDialog::GetIconFunc EditorFileDialog::get_icon_func=NULL;
EditorFileDialog::GetIconFunc EditorFileDialog::get_large_icon_func=NULL;
@@ -27,14 +29,14 @@ void EditorFileDialog::_notification(int p_what) {
dir_prev->set_icon(get_icon("ArrowLeft","EditorIcons"));
dir_next->set_icon(get_icon("ArrowRight","EditorIcons"));
dir_up->set_icon(get_icon("ArrowUp","EditorIcons"));
+ refresh->set_icon(get_icon("Reload","EditorIcons"));
favorite->set_icon(get_icon("Favorites","EditorIcons"));
fav_up->set_icon(get_icon("MoveUp","EditorIcons"));
fav_down->set_icon(get_icon("MoveDown","EditorIcons"));
fav_rm->set_icon(get_icon("RemoveSmall","EditorIcons"));
- }
- if (p_what==NOTIFICATION_PROCESS) {
+ } else if (p_what==NOTIFICATION_PROCESS) {
if (preview_waiting) {
preview_wheel_timeout-=get_process_delta_time();
@@ -47,12 +49,57 @@ void EditorFileDialog::_notification(int p_what) {
preview_wheel_timeout=0.1;
}
}
- }
-
- if (p_what==NOTIFICATION_DRAW) {
+ } else if (p_what==NOTIFICATION_DRAW) {
//RID ci = get_canvas_item();
//get_stylebox("panel","PopupMenu")->draw(ci,Rect2(Point2(),get_size()));
+ } else if (p_what==NOTIFICATION_POPUP_HIDE) {
+
+ set_process_unhandled_input(false);
+
+ } else if (p_what==EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) {
+
+ bool show_hidden=EditorSettings::get_singleton()->get("file_dialog/show_hidden_files");
+ if (show_hidden_files!=show_hidden)
+ set_show_hidden_files(show_hidden);
+ set_display_mode((DisplayMode)EditorSettings::get_singleton()->get("file_dialog/display_mode").operator int());
+ }
+}
+
+void EditorFileDialog::_unhandled_input(const InputEvent& p_event) {
+
+ if (p_event.type==InputEvent::KEY && is_window_modal_on_top()) {
+
+ const InputEventKey &k=p_event.key;
+
+ if (k.pressed) {
+
+ bool handled=true;
+
+ switch (k.scancode) {
+
+ case KEY_H: {
+
+ if (k.mod.command) {
+
+ bool show=!show_hidden_files;
+ set_show_hidden_files(show);
+ EditorSettings::get_singleton()->set("file_dialog/show_hidden_files",show);
+ } else {
+ handled=false;
+ }
+
+ } break;
+ case KEY_F5: {
+
+ invalidate();
+ } break;
+ default: { handled=false; }
+ }
+
+ if (handled)
+ accept_event();
+ }
}
}
@@ -147,6 +194,8 @@ void EditorFileDialog::_post_popup() {
_update_favorites();
}
+ set_process_unhandled_input(true);
+
}
void EditorFileDialog::_thumbnail_result(const String& p_path,const Ref<Texture>& p_preview, const Variant& p_udata) {
@@ -189,6 +238,9 @@ void EditorFileDialog::_thumbnail_done(const String& p_path,const Ref<Texture>&
void EditorFileDialog::_request_single_thumbnail(const String& p_path) {
+ if (!FileAccess::exists(p_path))
+ return;
+
EditorResourcePreview::get_singleton()->queue_resource_preview(p_path,this,"_thumbnail_done",p_path);
//print_line("want file "+p_path);
set_process(true);
@@ -430,6 +482,8 @@ void EditorFileDialog::update_file_list() {
}
+ String cdir = dir_access->get_current_dir();
+ bool skip_pp = access==ACCESS_RESOURCES && cdir=="res://";
dir_access->list_dir_begin();
@@ -450,7 +504,7 @@ void EditorFileDialog::update_file_list() {
if (show_hidden || !ishidden) {
if (!isdir)
files.push_back(item);
- else
+ else if (item!=".." || !skip_pp)
dirs.push_back(item);
}
}
@@ -1012,7 +1066,9 @@ void EditorFileDialog::_go_forward(){
}
-bool EditorFileDialog::default_show_hidden_files=true;
+bool EditorFileDialog::default_show_hidden_files=false;
+
+EditorFileDialog::DisplayMode EditorFileDialog::default_display_mode=DISPLAY_THUMBNAILS;
void EditorFileDialog::set_display_mode(DisplayMode p_mode) {
@@ -1038,6 +1094,8 @@ EditorFileDialog::DisplayMode EditorFileDialog::get_display_mode() const{
void EditorFileDialog::_bind_methods() {
+ ObjectTypeDB::bind_method(_MD("_unhandled_input"),&EditorFileDialog::_unhandled_input);
+
ObjectTypeDB::bind_method(_MD("_item_selected"),&EditorFileDialog::_item_selected);
ObjectTypeDB::bind_method(_MD("_item_db_selected"),&EditorFileDialog::_item_dc_selected);
ObjectTypeDB::bind_method(_MD("_dir_entered"),&EditorFileDialog::_dir_entered);
@@ -1060,7 +1118,7 @@ void EditorFileDialog::_bind_methods() {
ObjectTypeDB::bind_method(_MD("get_vbox:VBoxContainer"),&EditorFileDialog::get_vbox);
ObjectTypeDB::bind_method(_MD("set_access","access"),&EditorFileDialog::set_access);
ObjectTypeDB::bind_method(_MD("get_access"),&EditorFileDialog::get_access);
- ObjectTypeDB::bind_method(_MD("set_show_hidden_files"),&EditorFileDialog::set_show_hidden_files);
+ ObjectTypeDB::bind_method(_MD("set_show_hidden_files","show"),&EditorFileDialog::set_show_hidden_files);
ObjectTypeDB::bind_method(_MD("is_showing_hidden_files"),&EditorFileDialog::is_showing_hidden_files);
ObjectTypeDB::bind_method(_MD("_select_drive"),&EditorFileDialog::_select_drive);
ObjectTypeDB::bind_method(_MD("_make_dir"),&EditorFileDialog::_make_dir);
@@ -1113,6 +1171,10 @@ void EditorFileDialog::set_default_show_hidden_files(bool p_show) {
default_show_hidden_files=p_show;
}
+void EditorFileDialog::set_default_display_mode(DisplayMode p_mode) {
+ default_display_mode=p_mode;
+}
+
void EditorFileDialog::_save_to_recent() {
String dir = get_current_dir();
@@ -1141,8 +1203,8 @@ void EditorFileDialog::_save_to_recent() {
EditorFileDialog::EditorFileDialog() {
- show_hidden_files=true;
- display_mode=DISPLAY_THUMBNAILS;
+ show_hidden_files=default_show_hidden_files;
+ display_mode=default_display_mode;
local_history_pos=0;
VBoxContainer *vbc = memnew( VBoxContainer );
@@ -1170,6 +1232,10 @@ EditorFileDialog::EditorFileDialog() {
pathhb->add_child(dir);
dir->set_h_size_flags(SIZE_EXPAND_FILL);
+ refresh = memnew( ToolButton );
+ refresh->connect("pressed",this,"_update_file_list");
+ pathhb->add_child(refresh);
+
favorite = memnew( ToolButton );
favorite->set_toggle_mode(true);
favorite->connect("toggled",this,"_favorite_toggled");
@@ -1178,11 +1244,13 @@ EditorFileDialog::EditorFileDialog() {
mode_thumbnails = memnew( ToolButton );
mode_thumbnails->connect("pressed",this,"set_display_mode",varray(DISPLAY_THUMBNAILS));
mode_thumbnails->set_toggle_mode(true);
- mode_thumbnails->set_pressed(true);
+ mode_thumbnails->set_pressed(display_mode==DISPLAY_THUMBNAILS);
pathhb->add_child(mode_thumbnails);
+
mode_list = memnew( ToolButton );
mode_list->connect("pressed",this,"set_display_mode",varray(DISPLAY_LIST));
mode_list->set_toggle_mode(true);
+ mode_list->set_pressed(display_mode==DISPLAY_LIST);
pathhb->add_child(mode_list);
drives = memnew( OptionButton );
diff --git a/tools/editor/editor_file_dialog.h b/tools/editor/editor_file_dialog.h
index 6cfd970516..3590964a51 100644
--- a/tools/editor/editor_file_dialog.h
+++ b/tools/editor/editor_file_dialog.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -108,6 +108,7 @@ private:
ToolButton *mode_list;
+ ToolButton *refresh;
ToolButton *favorite;
ToolButton *fav_up;
@@ -127,6 +128,7 @@ private:
int preview_wheel_index;
float preview_wheel_timeout;
static bool default_show_hidden_files;
+ static DisplayMode default_display_mode;
bool show_hidden_files;
DisplayMode display_mode;
@@ -174,6 +176,8 @@ private:
void _thumbnail_done(const String& p_path,const Ref<Texture>& p_preview, const Variant& p_udata);
void _request_single_thumbnail(const String& p_path);
+ void _unhandled_input(const InputEvent& p_event);
+
protected:
void _notification(int p_what);
@@ -210,6 +214,7 @@ public:
bool is_showing_hidden_files() const;
static void set_default_show_hidden_files(bool p_show);
+ static void set_default_display_mode(DisplayMode p_mode);
void invalidate();
diff --git a/tools/editor/editor_file_system.cpp b/tools/editor/editor_file_system.cpp
index 33e4a15c85..c7c1a48e34 100644
--- a/tools/editor/editor_file_system.cpp
+++ b/tools/editor/editor_file_system.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -37,6 +37,31 @@
EditorFileSystem *EditorFileSystem::singleton=NULL;
+void EditorFileSystemDirectory::sort_files() {
+
+ files.sort_custom<FileInfoSort>();
+}
+
+int EditorFileSystemDirectory::find_file_index(const String& p_file) const {
+
+ for(int i=0;i<files.size();i++) {
+ if (files[i]->file==p_file)
+ return i;
+ }
+ return -1;
+
+}
+int EditorFileSystemDirectory::find_dir_index(const String& p_dir) const{
+
+
+ for(int i=0;i<subdirs.size();i++) {
+ if (subdirs[i]->name==p_dir)
+ return i;
+ }
+
+ return -1;
+}
+
int EditorFileSystemDirectory::get_subdir_count() const {
@@ -59,7 +84,7 @@ String EditorFileSystemDirectory::get_file(int p_idx) const{
ERR_FAIL_INDEX_V(p_idx,files.size(),"");
- return files[p_idx].file;
+ return files[p_idx]->file;
}
String EditorFileSystemDirectory::get_path() const {
@@ -91,22 +116,22 @@ String EditorFileSystemDirectory::get_file_path(int p_idx) const {
bool EditorFileSystemDirectory::get_file_meta(int p_idx) const {
ERR_FAIL_INDEX_V(p_idx,files.size(),"");
- return files[p_idx].meta.enabled;
+ return files[p_idx]->meta.enabled;
}
Vector<String> EditorFileSystemDirectory::get_file_deps(int p_idx) const {
ERR_FAIL_INDEX_V(p_idx,files.size(),Vector<String>());
- return files[p_idx].meta.deps;
+ return files[p_idx]->meta.deps;
}
Vector<String> EditorFileSystemDirectory::get_missing_sources(int p_idx) const {
ERR_FAIL_INDEX_V(p_idx,files.size(),Vector<String>());
Vector<String> missing;
- for(int i=0;i<files[p_idx].meta.sources.size();i++) {
- if (files[p_idx].meta.sources[i].missing)
- missing.push_back(files[p_idx].meta.sources[i].path);
+ for(int i=0;i<files[p_idx]->meta.sources.size();i++) {
+ if (files[p_idx]->meta.sources[i].missing)
+ missing.push_back(files[p_idx]->meta.sources[i].path);
}
return missing;
@@ -116,8 +141,8 @@ Vector<String> EditorFileSystemDirectory::get_missing_sources(int p_idx) const {
bool EditorFileSystemDirectory::is_missing_sources(int p_idx) const {
ERR_FAIL_INDEX_V(p_idx,files.size(),false);
- for(int i=0;i<files[p_idx].meta.sources.size();i++) {
- if (files[p_idx].meta.sources[i].missing)
+ for(int i=0;i<files[p_idx]->meta.sources.size();i++) {
+ if (files[p_idx]->meta.sources[i].missing)
return true;
}
@@ -127,7 +152,7 @@ bool EditorFileSystemDirectory::is_missing_sources(int p_idx) const {
StringName EditorFileSystemDirectory::get_file_type(int p_idx) const {
ERR_FAIL_INDEX_V(p_idx,files.size(),"");
- return files[p_idx].type;
+ return files[p_idx]->type;
}
String EditorFileSystemDirectory::get_name() {
@@ -157,11 +182,17 @@ void EditorFileSystemDirectory::_bind_methods() {
EditorFileSystemDirectory::EditorFileSystemDirectory() {
+ modified_time=0;
parent=NULL;
}
EditorFileSystemDirectory::~EditorFileSystemDirectory() {
+ for(int i=0;i<files.size();i++) {
+
+ memdelete(files[i]);
+ }
+
for(int i=0;i<subdirs.size();i++) {
memdelete(subdirs[i]);
@@ -173,19 +204,6 @@ EditorFileSystemDirectory::~EditorFileSystemDirectory() {
-
-
-EditorFileSystem::DirItem::~DirItem() {
-
- for(int i=0;i<dirs.size();i++) {
- memdelete(dirs[i]);
- }
-
- for(int i=0;i<files.size();i++) {
- memdelete(files[i]);
- }
-}
-
EditorFileSystemDirectory::ImportMeta EditorFileSystem::_get_meta(const String& p_path) {
Ref<ResourceImportMetadata> imd = ResourceLoader::load_import_metadata(p_path);
@@ -214,160 +232,16 @@ EditorFileSystemDirectory::ImportMeta EditorFileSystem::_get_meta(const String&
return m;
}
-EditorFileSystem::DirItem* EditorFileSystem::_scan_dir(DirAccess *da,Set<String> &extensions,String p_name,float p_from,float p_range,const String& p_path,HashMap<String,FileCache> &file_cache,HashMap<String,DirCache> &dir_cache,EditorProgressBG& p_prog) {
- if (abort_scan)
- return NULL;
-
- if (p_path!=String()) {
- if (FileAccess::exists(("res://"+p_path).plus_file("engine.cfg"))) {
- return NULL;
- }
- }
-
- List<String> dirs;
- List<String> files;
- Set<String> pngs;
-
- String path=p_path;
- if (path.ends_with("/"))
- path=path.substr(0,path.length()-1);
- String global_path = Globals::get_singleton()->get_resource_path().plus_file(path);
-
- path="res://"+path;
- uint64_t mtime = FileAccess::get_modified_time(global_path);
-
- DirCache *dc = dir_cache.getptr(path);
-
-
- if (false && dc && dc->modification_time==mtime) {
- //use the cached files, since directory did not change
- for (Set<String>::Element *E=dc->subdirs.front();E;E=E->next()) {
- dirs.push_back(E->get());
- }
- for (Set<String>::Element *E=dc->files.front();E;E=E->next()) {
- files.push_back(E->get());
- }
-
- } else {
- //use the filesystem, some files may have changed
- Error err = da->change_dir(global_path);
- if (err!=OK) {
- print_line("Can't change to: "+path);
- ERR_FAIL_COND_V(err!=OK,NULL);
- }
+void EditorFileSystem::_scan_filesystem() {
-
- da->list_dir_begin();
- while (true) {
-
- bool isdir;
- String f = da->get_next(&isdir);
- if (f=="")
- break;
- if (isdir) {
- dirs.push_back(f);
- } else {
- String ext = f.extension().to_lower();
- if (extensions.has(ext))
- files.push_back(f);
-
- }
-
- }
-
- da->list_dir_end();
- files.sort();
- dirs.sort();
-
- }
-
-
-
- //print_line(da->get_current_dir()+": dirs: "+itos(dirs.size())+" files:"+itos(files.size()) );
-
- //find subdirs
- Vector<DirItem*> subdirs;
-
- //String current = da->get_current_dir();
- float idx=0;
- for (List<String>::Element *E=dirs.front();E;E=E->next(),idx+=1.0) {
-
- String d = E->get();
- if (d.begins_with(".")) //ignore hidden and . / ..
- continue;
-
- //ERR_CONTINUE( da->change_dir(d)!= OK );
- DirItem *sdi = _scan_dir(da,extensions,d,p_from+(idx/dirs.size())*p_range,p_range/dirs.size(),p_path+d+"/",file_cache,dir_cache,p_prog);
- if (sdi) {
- subdirs.push_back(sdi);
- }
- //da->change_dir(current);
- }
-
-
- if (subdirs.empty() && files.empty()) {
- total=p_from+p_range;
- p_prog.step(total*100);
- return NULL; //give up, nothing to do here
- }
-
- DirItem *di = memnew( DirItem );
- di->path=path;
- di->name=p_name;
- di->dirs=subdirs;
- di->modified_time=mtime;
-
- //add files
- for (List<String>::Element *E=files.front();E;E=E->next()) {
-
- SceneItem * si = memnew( SceneItem );
- si->file=E->get();
- si->path="res://"+p_path+si->file;
- FileCache *fc = file_cache.getptr(si->path);
- uint64_t mt = FileAccess::get_modified_time(si->path);
-
- if (fc && fc->modification_time == mt) {
-
- si->meta=fc->meta;
- si->type=fc->type;
- si->modified_time=fc->modification_time;
- } else {
- si->meta=_get_meta(si->path);
- si->type=ResourceLoader::get_resource_type(si->path);
- si->modified_time=mt;
-
- }
-
- if (si->meta.enabled) {
- md_count++;
- if (_check_meta_sources(si->meta)) {
- sources_changed.push_back(si->path);
- }
- }
- di->files.push_back(si);
- }
-
- total=p_from+p_range;
- p_prog.step(total*100);
-
- return di;
-}
-
-
-void EditorFileSystem::_scan_scenes() {
-
- ERR_FAIL_COND(!scanning || scandir);
+ ERR_FAIL_COND(!scanning || new_filesystem);
//read .fscache
- HashMap<String,FileCache> file_cache;
- HashMap<String,DirCache> dir_cache;
- DirCache *dc=NULL;
String cpath;
sources_changed.clear();
-
-
+ file_cache.clear();
String project=Globals::get_singleton()->get_resource_path();
@@ -387,26 +261,7 @@ void EditorFileSystem::_scan_scenes() {
ERR_CONTINUE( split.size() != 3);
String name = split[1];
- dir_cache[name]=DirCache();
- dc=&dir_cache[name];
- dc->modification_time=split[2].to_int64();
-
- if (name!="res://") {
-
- cpath=name+"/";
-
- int sp=name.find_last("/");
- if (sp==5)
- sp=6;
- String pd = name.substr(0,sp);
- DirCache *dcp = dir_cache.getptr(pd);
- ERR_CONTINUE(!dcp);
- dcp->subdirs.insert(name.get_file());
- } else {
-
- cpath=name;
- }
-
+ cpath=name;
} else {
Vector<String> split = l.split("::");
@@ -414,12 +269,8 @@ void EditorFileSystem::_scan_scenes() {
String name = split[0];
String file;
- if (!name.begins_with("res://")) {
- file=name;
- name=cpath+name;
- } else {
- file=name.get_file();
- }
+ file=name;
+ name=cpath.plus_file(name);
FileCache fc;
fc.type=split[1];
@@ -453,8 +304,6 @@ void EditorFileSystem::_scan_scenes() {
file_cache[name]=fc;
- ERR_CONTINUE(!dc);
- dc->files.insert(file);
}
}
@@ -465,39 +314,31 @@ void EditorFileSystem::_scan_scenes() {
+ EditorProgressBG scan_progress("efs","ScanFS",1000);
+ ScanProgress sp;
+ sp.low=0;
+ sp.hi=1;
+ sp.progress=&scan_progress;
- total=0;
- DirAccess *da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
- //da->change_dir( Globals::get_singleton()->get_resource_path() );
+ new_filesystem = memnew( EditorFileSystemDirectory );
+ new_filesystem->parent=NULL;
+ DirAccess *d = DirAccess::create(DirAccess::ACCESS_RESOURCES);
+ d->change_dir("res://");
+ _scan_new_dir(new_filesystem,d,sp);
- List<String> extensionsl;
- ResourceLoader::get_recognized_extensions_for_type("",&extensionsl);
- Set<String> extensions;
- for(List<String>::Element *E = extensionsl.front();E;E=E->next()) {
+ file_cache.clear(); //clear caches, no longer needed
- extensions.insert(E->get());
- }
-
- EditorProgressBG scan_progress("efs","ScanFS",100);
-
- md_count=0;
- scandir=_scan_dir(da,extensions,"",0,1,"",file_cache,dir_cache,scan_progress);
- memdelete(da);
- if (abort_scan && scandir) {
- memdelete(scandir);
- scandir=NULL;
-
- }
+ memdelete(d);
//save back the findings
// String fscache = EditorSettings::get_singleton()->get_project_settings_path().plus_file("file_cache");
f=FileAccess::open(fscache,FileAccess::WRITE);
- _save_type_cache_fs(scandir,f);
+ _save_filesystem_cache(new_filesystem,f);
f->close();
memdelete(f);
@@ -510,7 +351,95 @@ void EditorFileSystem::_scan_scenes() {
void EditorFileSystem::_thread_func(void *_userdata) {
EditorFileSystem *sd = (EditorFileSystem*)_userdata;
- sd->_scan_scenes();
+ sd->_scan_filesystem();
+
+}
+
+bool EditorFileSystem::_update_scan_actions() {
+
+ sources_changed.clear();
+
+ bool fs_changed=false;
+
+ for (List<ItemAction>::Element *E=scan_actions.front();E;E=E->next()) {
+
+ ItemAction&ia = E->get();
+
+ switch(ia.action) {
+ case ItemAction::ACTION_NONE: {
+
+ } break;
+ case ItemAction::ACTION_DIR_ADD: {
+
+ //print_line("*ACTION ADD DIR: "+ia.new_dir->get_name());
+ int idx=0;
+ for(int i=0;i<ia.dir->subdirs.size();i++) {
+
+ if (ia.new_dir->name<ia.dir->subdirs[i]->name)
+ break;
+ idx++;
+ }
+ if (idx==ia.dir->subdirs.size()) {
+ ia.dir->subdirs.push_back(ia.new_dir);
+ } else {
+ ia.dir->subdirs.insert(idx,ia.new_dir);
+ }
+
+ fs_changed=true;
+ } break;
+ case ItemAction::ACTION_DIR_REMOVE: {
+
+ ERR_CONTINUE(!ia.dir->parent);
+ //print_line("*ACTION REMOVE DIR: "+ia.dir->get_name());
+ ia.dir->parent->subdirs.erase(ia.dir);
+ memdelete( ia.dir );
+ fs_changed=true;
+ } break;
+ case ItemAction::ACTION_FILE_ADD: {
+
+ int idx=0;
+ for(int i=0;i<ia.dir->files.size();i++) {
+
+ if (ia.new_file->file<ia.dir->files[i]->file)
+ break;
+ idx++;
+ }
+ if (idx==ia.dir->files.size()) {
+ ia.dir->files.push_back(ia.new_file);
+ } else {
+ ia.dir->files.insert(idx,ia.new_file);
+ }
+
+ fs_changed=true;
+ //print_line("*ACTION ADD FILE: "+ia.new_file->file);
+
+ } break;
+ case ItemAction::ACTION_FILE_REMOVE: {
+
+ int idx = ia.dir->find_file_index(ia.file);
+ ERR_CONTINUE(idx==-1);
+ memdelete( ia.dir->files[idx] );
+ ia.dir->files.remove(idx);
+
+ fs_changed=true;
+ //print_line("*ACTION REMOVE FILE: "+ia.file);
+
+ } break;
+ case ItemAction::ACTION_FILE_SOURCES_CHANGED: {
+
+ int idx = ia.dir->find_file_index(ia.file);
+ ERR_CONTINUE(idx==-1);
+ String full_path = ia.dir->get_file_path(idx);
+ sources_changed.push_back(full_path);
+
+ } break;
+
+ }
+ }
+
+ scan_actions.clear();
+
+ return fs_changed;
}
@@ -526,19 +455,15 @@ void EditorFileSystem::scan() {
abort_scan=false;
if (!use_threads) {
scanning=true;
- _scan_scenes();
- if (rootdir)
- memdelete(rootdir);
- rootdir=scandir;
+ scan_total=0;
+ _scan_filesystem();
if (filesystem)
memdelete(filesystem);
// file_type_cache.clear();
- filesystem=_update_tree(rootdir);
-
- if (rootdir)
- memdelete(rootdir);
- rootdir=NULL;
- scanning=false;
+ filesystem=new_filesystem;
+ new_filesystem=NULL;
+ _update_scan_actions();
+ scanning=false;
emit_signal("filesystem_changed");
emit_signal("sources_changed",sources_changed.size()>0);
@@ -548,6 +473,7 @@ void EditorFileSystem::scan() {
set_process(true);
Thread::Settings s;
scanning=true;
+ scan_total=0;
s.priority=Thread::PRIORITY_LOW;
thread = Thread::create(_thread_func,this,s);
//tree->hide();
@@ -559,14 +485,10 @@ void EditorFileSystem::scan() {
}
-bool EditorFileSystem::_check_meta_sources(EditorFileSystemDirectory::ImportMeta & p_meta,EditorProgressBG *ep) {
+bool EditorFileSystem::_check_meta_sources(EditorFileSystemDirectory::ImportMeta & p_meta) {
if (p_meta.enabled) {
- if (ep) {
- ep->step(ss_amount++);
- }
-
for(int j=0;j<p_meta.sources.size();j++) {
@@ -584,9 +506,9 @@ bool EditorFileSystem::_check_meta_sources(EditorFileSystemDirectory::ImportMeta
if (mt!=p_meta.sources[j].modified_time) {
//scan
String md5 = FileAccess::get_md5(src);
- print_line("checking: "+src);
- print_line("md5: "+md5);
- print_line("vs: "+p_meta.sources[j].md5);
+ //print_line("checking: "+src);
+ //print_line("md5: "+md5);
+ //print_line("vs: "+p_meta.sources[j].md5);
if (md5!=p_meta.sources[j].md5) {
//really changed
return true;
@@ -599,18 +521,300 @@ bool EditorFileSystem::_check_meta_sources(EditorFileSystemDirectory::ImportMeta
return false;
}
-void EditorFileSystem::_scan_sources(EditorFileSystemDirectory *p_dir,EditorProgressBG *ep) {
+void EditorFileSystem::ScanProgress::update(int p_current,int p_total) const {
+
+ float ratio = low + ((hi-low)/p_total)*p_current;
+ progress->step(ratio*1000);
+ EditorFileSystem::singleton->scan_total=ratio;
+}
+
+EditorFileSystem::ScanProgress EditorFileSystem::ScanProgress::get_sub(int p_current,int p_total) const{
+
+ ScanProgress sp=*this;
+ float slice = (sp.hi-sp.low)/p_total;
+ sp.low+=slice*p_current;
+ sp.hi=slice;
+ return sp;
+
+
+}
+
+
+void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir,DirAccess *da,const ScanProgress& p_progress) {
+
+ List<String> dirs;
+ List<String> files;
+
+ String cd = da->get_current_dir();
+
+ p_dir->modified_time = FileAccess::get_modified_time(cd);
+
+
+ da->list_dir_begin();
+ while (true) {
+
+ bool isdir;
+ String f = da->get_next(&isdir);
+ if (f=="")
+ break;
+
+ if (isdir) {
+
+ if (f.begins_with(".")) //ignore hidden and . / ..
+ continue;
+
+ if (FileAccess::exists(cd.plus_file(f).plus_file("engine.cfg"))) // skip if another project inside this
+ continue;
+
+ dirs.push_back(f);
+
+ } else {
+
+ files.push_back(f);
+ }
+
+ }
+
+ da->list_dir_end();
+
+ dirs.sort();
+ files.sort();
+
+ int total = dirs.size()+files.size();
+ int idx=0;
+
+ for (List<String>::Element *E=dirs.front();E;E=E->next(),idx++) {
+
+ if (da->change_dir(E->get())==OK) {
+
+ EditorFileSystemDirectory *efd = memnew( EditorFileSystemDirectory );
+
+ efd->parent=p_dir;
+ efd->name=E->get();
+
+ _scan_new_dir(efd,da,p_progress.get_sub(idx,total));
+
+ int idx=0;
+ for(int i=0;i<p_dir->subdirs.size();i++) {
+
+ if (efd->name<p_dir->subdirs[i]->name)
+ break;
+ idx++;
+ }
+ if (idx==p_dir->subdirs.size()) {
+ p_dir->subdirs.push_back(efd);
+ } else {
+ p_dir->subdirs.insert(idx,efd);
+ }
+
+ da->change_dir("..");
+ } else {
+ ERR_PRINTS("Can't go into subdir: "+E->get());
+ }
+
+ p_progress.update(idx,total);
+
+ }
+
+ for (List<String>::Element*E=files.front();E;E=E->next(),idx++) {
+
+ String ext = E->get().extension().to_lower();
+ if (!valid_extensions.has(ext))
+ continue; //invalid
+
+ EditorFileSystemDirectory::FileInfo *fi = memnew( EditorFileSystemDirectory::FileInfo );
+ fi->file=E->get();
+
+ String path = cd.plus_file(fi->file);
+
+ FileCache *fc = file_cache.getptr(path);
+ uint64_t mt = FileAccess::get_modified_time(path);
+
+ if (fc && fc->modification_time == mt) {
+
+ fi->meta=fc->meta;
+ fi->type=fc->type;
+ fi->modified_time=fc->modification_time;
+ } else {
+ fi->meta=_get_meta(path);
+ fi->type=ResourceLoader::get_resource_type(path);
+ fi->modified_time=mt;
+
+ }
+
+ if (fi->meta.enabled) {
+ if (_check_meta_sources(fi->meta)) {
+ ItemAction ia;
+ ia.action=ItemAction::ACTION_FILE_SOURCES_CHANGED;
+ ia.dir=p_dir;
+ ia.file=E->get();
+ scan_actions.push_back(ia);
+ }
+ }
+
+ p_dir->files.push_back(fi);
+ p_progress.update(idx,total);
+ }
+
+}
+
+
+void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir,const ScanProgress& p_progress) {
+
+ uint64_t current_mtime = FileAccess::get_modified_time(p_dir->get_path());
+
+ bool updated_dir=false;
+
+ //print_line("dir: "+p_dir->get_path()+" MODTIME: "+itos(p_dir->modified_time)+" CTIME: "+itos(current_mtime));
+
+ if (current_mtime!=p_dir->modified_time) {
+
+ updated_dir=true;
+ p_dir->modified_time=current_mtime;
+ //ooooops, dir changed, see what's going on
+
+ //first mark everything as veryfied
+
+ for(int i=0;i<p_dir->files.size();i++) {
+
+ p_dir->files[i]->verified=false;
+ }
+
+ for(int i=0;i<p_dir->subdirs.size();i++) {
+
+ p_dir->get_subdir(i)->verified=false;
+ }
+
+ //then scan files and directories and check what's different
+
+ DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
+ String cd = p_dir->get_path();
+ da->change_dir(cd);
+ da->list_dir_begin();
+ while (true) {
+
+ bool isdir;
+ String f = da->get_next(&isdir);
+ if (f=="")
+ break;
+
+ if (isdir) {
+
+ if (f.begins_with(".")) //ignore hidden and . / ..
+ continue;
+
+ int idx = p_dir->find_dir_index(f);
+ if (idx==-1) {
+
+ if (FileAccess::exists(cd.plus_file(f).plus_file("engine.cfg"))) // skip if another project inside this
+ continue;
+
+ EditorFileSystemDirectory *efd = memnew( EditorFileSystemDirectory );
+
+ efd->parent=p_dir;
+ efd->name=f;
+ DirAccess *d = DirAccess::create(DirAccess::ACCESS_RESOURCES);
+ d->change_dir(cd.plus_file(f));
+ _scan_new_dir(efd,d,p_progress.get_sub(1,1));
+ memdelete(d);
+
+
+ ItemAction ia;
+ ia.action=ItemAction::ACTION_DIR_ADD;
+ ia.dir=p_dir;
+ ia.file=f;
+ ia.new_dir=efd;
+ scan_actions.push_back(ia);
+ } else {
+ p_dir->subdirs[idx]->verified=true;
+ }
+
+
+ } else {
+ String ext = f.extension().to_lower();
+ if (!valid_extensions.has(ext))
+ continue; //invalid
+
+ int idx = p_dir->find_file_index(f);
+
+ if (idx==-1) {
+ //never seen this file, add actition to add it
+ EditorFileSystemDirectory::FileInfo *fi = memnew( EditorFileSystemDirectory::FileInfo );
+ fi->file=f;
+
+ String path = cd.plus_file(fi->file);
+ fi->modified_time=FileAccess::get_modified_time(path);
+ fi->meta=_get_meta(path);
+ fi->type=ResourceLoader::get_resource_type(path);
+
+ {
+ ItemAction ia;
+ ia.action=ItemAction::ACTION_FILE_ADD;
+ ia.dir=p_dir;
+ ia.file=f;
+ ia.new_file=fi;
+ scan_actions.push_back(ia);
+ }
+
+ //take the chance and scan sources
+ if (_check_meta_sources(fi->meta)) {
+
+ ItemAction ia;
+ ia.action=ItemAction::ACTION_FILE_SOURCES_CHANGED;
+ ia.dir=p_dir;
+ ia.file=f;
+ scan_actions.push_back(ia);
+ }
+
+ } else {
+ p_dir->files[idx]->verified=true;
+ }
+
+
+ }
+
+ }
+ da->list_dir_end();
+ memdelete(da);
+
+
+
+
+ }
for(int i=0;i<p_dir->files.size();i++) {
- if (_check_meta_sources(p_dir->files[i].meta,ep)) {
- sources_changed.push_back(p_dir->get_file_path(i));
+ if (updated_dir && !p_dir->files[i]->verified) {
+ //this file was removed, add action to remove it
+ ItemAction ia;
+ ia.action=ItemAction::ACTION_FILE_REMOVE;
+ ia.dir=p_dir;
+ ia.file=p_dir->files[i]->file;
+ scan_actions.push_back(ia);
+ continue;
+
+ }
+ if (_check_meta_sources(p_dir->files[i]->meta)) {
+ ItemAction ia;
+ ia.action=ItemAction::ACTION_FILE_SOURCES_CHANGED;
+ ia.dir=p_dir;
+ ia.file=p_dir->files[i]->file;
+ scan_actions.push_back(ia);
}
}
for(int i=0;i<p_dir->subdirs.size();i++) {
- _scan_sources(p_dir->get_subdir(i),ep);
+ if (updated_dir && !p_dir->subdirs[i]->verified) {
+ //this directory was removed, add action to remove it
+ ItemAction ia;
+ ia.action=ItemAction::ACTION_DIR_REMOVE;
+ ia.dir=p_dir->subdirs[i];
+ scan_actions.push_back(ia);
+ continue;
+
+ }
+ _scan_fs_changes(p_dir->get_subdir(i),p_progress);
}
}
@@ -619,9 +823,12 @@ void EditorFileSystem::_thread_func_sources(void *_userdata) {
EditorFileSystem *efs = (EditorFileSystem*)_userdata;
if (efs->filesystem) {
- EditorProgressBG pr("sources","ScanSources",efs->md_count);
- efs->ss_amount=0;
- efs->_scan_sources(efs->filesystem,&pr);
+ EditorProgressBG pr("sources","ScanSources",1000);
+ ScanProgress sp;
+ sp.progress=&pr;
+ sp.hi=1;
+ sp.low=0;
+ efs->_scan_fs_changes(efs->filesystem,sp);
}
efs->scanning_sources_done=true;
}
@@ -643,8 +850,17 @@ void EditorFileSystem::scan_sources() {
abort_scan=false;
if (!use_threads) {
- if (filesystem)
- _scan_sources(filesystem,NULL);
+ if (filesystem) {
+ EditorProgressBG pr("sources","ScanSources",1000);
+ ScanProgress sp;
+ sp.progress=&pr;
+ sp.hi=1;
+ sp.low=0;
+ scan_total=0;
+ _scan_fs_changes(filesystem,sp);
+ if (_update_scan_actions())
+ emit_signal("filesystem_changed");
+ }
scanning_sources=false;
scanning_sources_done=true;
emit_signal("sources_changed",sources_changed.size()>0);
@@ -652,8 +868,8 @@ void EditorFileSystem::scan_sources() {
ERR_FAIL_COND(thread_sources);
set_process(true);
+ scan_total=0;
Thread::Settings s;
- ss_amount=0;
s.priority=Thread::PRIORITY_LOW;
thread_sources = Thread::create(_thread_func_sources,this,s);
//tree->hide();
@@ -665,53 +881,14 @@ void EditorFileSystem::scan_sources() {
}
-EditorFileSystemDirectory* EditorFileSystem::_update_tree(DirItem *p_item) {
-
- EditorFileSystemDirectory *efd = memnew( EditorFileSystemDirectory );
-
- if (!p_item)
- return efd; //empty likely
- efd->name=p_item->name;
-
- for(int i=0;i<p_item->files.size();i++) {
-
- String s = p_item->files[i]->type;
- //if (p_item->files[i]->meta)
- // s="*"+s;
-
-// file_type_cache[p_item->files[i]->path]=s;
- if (p_item->files[i]->type=="")
- continue; //ignore because it's invalid
- EditorFileSystemDirectory::FileInfo fi;
- fi.file=p_item->files[i]->file;
- fi.type=p_item->files[i]->type;
- fi.meta=p_item->files[i]->meta;
- fi.modified_time=p_item->files[i]->modified_time;
-
- efd->files.push_back(fi);
-
- }
-
- for(int i=0;i<p_item->dirs.size();i++) {
-
- EditorFileSystemDirectory *efsd =_update_tree(p_item->dirs[i]);
- efsd->parent=efd;
- efd->subdirs.push_back( efsd );
-
- }
-
-
- return efd;
-}
-
void EditorFileSystem::_notification(int p_what) {
switch(p_what) {
case NOTIFICATION_ENTER_TREE: {
- _load_type_cache();
- scan();
+
+ scan();
} break;
case NOTIFICATION_EXIT_TREE: {
if (use_threads && thread) {
@@ -727,13 +904,13 @@ void EditorFileSystem::_notification(int p_what) {
set_process(false);
}
- if (rootdir)
- memdelete(rootdir);
- rootdir=NULL;
if (filesystem)
memdelete(filesystem);
+ if (new_filesystem)
+ memdelete(new_filesystem);
filesystem=NULL;
+ new_filesystem=NULL;
} break;
case NOTIFICATION_PROCESS: {
@@ -751,6 +928,8 @@ void EditorFileSystem::_notification(int p_what) {
Thread::wait_to_finish(thread_sources);
memdelete(thread_sources);
thread_sources=NULL;
+ if (_update_scan_actions())
+ emit_signal("filesystem_changed");
//print_line("sources changed: "+itos(sources_changed.size()));
emit_signal("sources_changed",sources_changed.size()>0);
}
@@ -758,21 +937,14 @@ void EditorFileSystem::_notification(int p_what) {
set_process(false);
- if (rootdir)
- memdelete(rootdir);
if (filesystem)
memdelete(filesystem);
- rootdir=scandir;
- scandir=NULL;
-// file_type_cache.clear();
- filesystem=_update_tree(rootdir);
-
- if (rootdir)
- memdelete(rootdir);
- rootdir=NULL;
+ filesystem=new_filesystem;
+ new_filesystem=NULL;
Thread::wait_to_finish(thread);
memdelete(thread);
thread=NULL;
+ _update_scan_actions();
emit_signal("filesystem_changed");
emit_signal("sources_changed",sources_changed.size()>0);
//print_line("initial sources changed: "+itos(sources_changed.size()));
@@ -794,7 +966,7 @@ bool EditorFileSystem::is_scanning() const {
}
float EditorFileSystem::get_scanning_progress() const {
- return total;
+ return scan_total;
}
EditorFileSystemDirectory *EditorFileSystem::get_filesystem() {
@@ -802,12 +974,12 @@ EditorFileSystemDirectory *EditorFileSystem::get_filesystem() {
return filesystem;
}
-void EditorFileSystem::_save_type_cache_fs(DirItem *p_dir,FileAccess *p_file) {
+void EditorFileSystem::_save_filesystem_cache(EditorFileSystemDirectory*p_dir,FileAccess *p_file) {
if (!p_dir)
return; //none
- p_file->store_line("::"+p_dir->path+"::"+String::num(p_dir->modified_time));
+ p_file->store_line("::"+p_dir->get_path()+"::"+String::num(p_dir->modified_time));
for(int i=0;i<p_dir->files.size();i++) {
@@ -832,126 +1004,96 @@ void EditorFileSystem::_save_type_cache_fs(DirItem *p_dir,FileAccess *p_file) {
p_file->store_line(s);
}
- for(int i=0;i<p_dir->dirs.size();i++) {
+ for(int i=0;i<p_dir->subdirs.size();i++) {
- _save_type_cache_fs(p_dir->dirs[i],p_file);
+ _save_filesystem_cache(p_dir->subdirs[i],p_file);
}
}
-void EditorFileSystem::_load_type_cache(){
-
- GLOBAL_LOCK_FUNCTION
-
-
-#if 0
- //this is not good, removed for now as it interferes with metadata stored in files
-
- String project=Globals::get_singleton()->get_resource_path();
- FileAccess *f =FileAccess::open(project+"/types.cache",FileAccess::READ);
-
- if (!f) {
-
- WARN_PRINT("Can't open types.cache.");
- return;
- }
-
- file_type_cache.clear();
- while(!f->eof_reached()) {
-
- String path=f->get_line();
- if (f->eof_reached())
- break;
- String type=f->get_line();
- file_type_cache[path]=type;
- }
-
- memdelete(f);
-#endif
-}
bool EditorFileSystem::_find_file(const String& p_file,EditorFileSystemDirectory ** r_d, int &r_file_pos) const {
//todo make faster
- if (!filesystem || scanning)
- return false;
+ if (!filesystem || scanning)
+ return false;
- String f = Globals::get_singleton()->localize_path(p_file);
+ String f = Globals::get_singleton()->localize_path(p_file);
- if (!f.begins_with("res://"))
- return false;
- f=f.substr(6,f.length());
- f=f.replace("\\","/");
+ if (!f.begins_with("res://"))
+ return false;
+ f=f.substr(6,f.length());
+ f=f.replace("\\","/");
- Vector<String> path = f.split("/");
+ Vector<String> path = f.split("/");
- if (path.size()==0)
- return false;
- String file=path[path.size()-1];
- path.resize(path.size()-1);
+ if (path.size()==0)
+ return false;
+ String file=path[path.size()-1];
+ path.resize(path.size()-1);
- EditorFileSystemDirectory *fs=filesystem;
+ EditorFileSystemDirectory *fs=filesystem;
- for(int i=0;i<path.size();i++) {
+ for(int i=0;i<path.size();i++) {
- int idx=-1;
- for(int j=0;j<fs->get_subdir_count();j++) {
+ int idx=-1;
+ for(int j=0;j<fs->get_subdir_count();j++) {
- if (fs->get_subdir(j)->get_name()==path[i]) {
- idx=j;
- break;
- }
- }
+ if (fs->get_subdir(j)->get_name()==path[i]) {
+ idx=j;
+ break;
+ }
+ }
- if (idx==-1) {
- //does not exist, create i guess?
- EditorFileSystemDirectory *efsd = memnew( EditorFileSystemDirectory );
- efsd->name=path[i];
- int idx2=0;
- for(int j=0;j<fs->get_subdir_count();j++) {
+ if (idx==-1) {
+ //does not exist, create i guess?
+ EditorFileSystemDirectory *efsd = memnew( EditorFileSystemDirectory );
+ efsd->name=path[i];
+ int idx2=0;
+ for(int j=0;j<fs->get_subdir_count();j++) {
- if (efsd->name<fs->get_subdir(j)->get_name())
- break;
- idx2++;
- }
+ if (efsd->name<fs->get_subdir(j)->get_name())
+ break;
+ idx2++;
+ }
- if (idx2==fs->get_subdir_count())
- fs->subdirs.push_back(efsd);
- else
- fs->subdirs.insert(idx2,efsd);
- fs=efsd;
- } else {
+ if (idx2==fs->get_subdir_count())
+ fs->subdirs.push_back(efsd);
+ else
+ fs->subdirs.insert(idx2,efsd);
+ fs=efsd;
+ } else {
- fs=fs->get_subdir(idx);
+ fs=fs->get_subdir(idx);
+ }
}
- }
- int cpos=-1;
- for(int i=0;i<fs->files.size();i++) {
+ int cpos=-1;
+ for(int i=0;i<fs->files.size();i++) {
- if (fs->files[i].file==file) {
- cpos=i;
- break;
+ if (fs->files[i]->file==file) {
+ cpos=i;
+ break;
+ }
}
- }
r_file_pos=cpos;
*r_d=fs;
- if (cpos!=-1) {
+ if (cpos!=-1) {
- return true;
- } else {
+ return true;
+ } else {
- return false;
- }
+ return false;
+ }
}
@@ -967,7 +1109,7 @@ String EditorFileSystem::get_file_type(const String& p_file) const {
}
- return fs->files[cpos].type;
+ return fs->files[cpos]->type;
}
@@ -1024,16 +1166,16 @@ EditorFileSystemDirectory *EditorFileSystem::get_path(const String& p_path) {
void EditorFileSystem::_resource_saved(const String& p_path){
- print_line("resource saved: "+p_path);
+ //print_line("resource saved: "+p_path);
EditorFileSystem::get_singleton()->update_file(p_path);
}
String EditorFileSystem::_find_first_from_source(EditorFileSystemDirectory* p_dir,const String &p_src) const {
for(int i=0;i<p_dir->files.size();i++) {
- for(int j=0;j<p_dir->files[i].meta.sources.size();j++) {
+ for(int j=0;j<p_dir->files[i]->meta.sources.size();j++) {
- if (p_dir->files[i].meta.sources[j].path==p_src)
+ if (p_dir->files[i]->meta.sources[j].path==p_src)
return p_dir->get_file_path(i);
}
}
@@ -1070,6 +1212,7 @@ void EditorFileSystem::update_file(const String& p_file) {
if (!FileAccess::exists(p_file)) {
//was removed
+ memdelete( fs->files[cpos] );
fs->files.remove(cpos);
call_deferred("emit_signal","filesystem_changed"); //update later
return;
@@ -1083,13 +1226,13 @@ void EditorFileSystem::update_file(const String& p_file) {
int idx=0;
for(int i=0;i<fs->files.size();i++) {
- if (p_file<fs->files[i].file)
+ if (p_file<fs->files[i]->file)
break;
idx++;
}
- EditorFileSystemDirectory::FileInfo fi;
- fi.file=p_file.get_file();
+ EditorFileSystemDirectory::FileInfo *fi = memnew( EditorFileSystemDirectory::FileInfo );
+ fi->file=p_file.get_file();
if (idx==fs->files.size()) {
fs->files.push_back(fi);
@@ -1102,10 +1245,10 @@ void EditorFileSystem::update_file(const String& p_file) {
}
- print_line("UPDATING: "+p_file);
- fs->files[cpos].type=type;
- fs->files[cpos].modified_time=FileAccess::get_modified_time(p_file);
- fs->files[cpos].meta=_get_meta(p_file);
+ //print_line("UPDATING: "+p_file);
+ fs->files[cpos]->type=type;
+ fs->files[cpos]->modified_time=FileAccess::get_modified_time(p_file);
+ fs->files[cpos]->meta=_get_meta(p_file);
call_deferred("emit_signal","filesystem_changed"); //update later
@@ -1128,15 +1271,22 @@ EditorFileSystem::EditorFileSystem() {
thread = NULL;
scanning=false;
- scandir=NULL;
- rootdir=NULL;
use_threads=true;
thread_sources=NULL;
+ new_filesystem=NULL;
scanning_sources=false;
ResourceSaver::set_save_callback(_resource_saved);
+ List<String> extensionsl;
+ ResourceLoader::get_recognized_extensions_for_type("",&extensionsl);
+ for(List<String>::Element *E = extensionsl.front();E;E=E->next()) {
+
+ valid_extensions.insert(E->get());
+ }
+
+ scan_total=0;
}
EditorFileSystem::~EditorFileSystem() {
diff --git a/tools/editor/editor_file_system.h b/tools/editor/editor_file_system.h
index f79dd209ef..d11fa0cfb1 100644
--- a/tools/editor/editor_file_system.h
+++ b/tools/editor/editor_file_system.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -42,6 +42,8 @@ class EditorFileSystemDirectory : public Object {
OBJ_TYPE( EditorFileSystemDirectory,Object );
String name;
+ uint64_t modified_time;
+ bool verified; //used for checking changes
EditorFileSystemDirectory *parent;
Vector<EditorFileSystemDirectory*> subdirs;
@@ -68,11 +70,20 @@ class EditorFileSystemDirectory : public Object {
String file;
StringName type;
uint64_t modified_time;
-
ImportMeta meta;
+ bool verified; //used for checking changes
+
+ };
+
+ struct FileInfoSort {
+ bool operator()(const FileInfo *p_a,const FileInfo *p_b) const {
+ return p_a->file<p_b->file;
+ }
};
- Vector<FileInfo> files;
+ void sort_files();
+
+ Vector<FileInfo*> files;
static void _bind_methods();
@@ -96,6 +107,9 @@ public:
EditorFileSystemDirectory *get_parent();
+ int find_file_index(const String& p_file) const;
+ int find_dir_index(const String& p_dir) const;
+
EditorFileSystemDirectory();
~EditorFileSystemDirectory();
@@ -107,45 +121,47 @@ class EditorFileSystem : public Node {
_THREAD_SAFE_CLASS_
- struct SceneItem {
+
+ struct ItemAction {
+
+ enum Action {
+ ACTION_NONE,
+ ACTION_DIR_ADD,
+ ACTION_DIR_REMOVE,
+ ACTION_FILE_ADD,
+ ACTION_FILE_REMOVE,
+ ACTION_FILE_SOURCES_CHANGED
+ };
+
+ Action action;
+ EditorFileSystemDirectory *dir;
String file;
- String path;
- String type;
- uint64_t modified_time;
- EditorFileSystemDirectory::ImportMeta meta;
- };
+ EditorFileSystemDirectory *new_dir;
+ EditorFileSystemDirectory::FileInfo *new_file;
- struct DirItem {
+ ItemAction() { action=ACTION_NONE; dir=NULL; new_dir=NULL; new_file=NULL; }
- uint64_t modified_time;
- String path;
- String name;
- Vector<DirItem*> dirs;
- Vector<SceneItem*> files;
- ~DirItem();
};
- float total;
bool use_threads;
Thread *thread;
static void _thread_func(void *_userdata);
- DirItem *scandir;
- DirItem *rootdir;
+ EditorFileSystemDirectory *new_filesystem;
bool abort_scan;
bool scanning;
+ float scan_total;
- EditorFileSystemDirectory* _update_tree(DirItem *p_item);
- void _scan_scenes();
- void _load_type_cache();
+ void _scan_filesystem();
EditorFileSystemDirectory *filesystem;
static EditorFileSystem *singleton;
+ /* Used for reading the filesystem cache file */
struct FileCache {
String type;
@@ -154,34 +170,43 @@ class EditorFileSystem : public Node {
Vector<String> deps;
};
- struct DirCache {
+ HashMap<String,FileCache> file_cache;
- uint64_t modification_time;
- Set<String> files;
- Set<String> subdirs;
- };
+ struct ScanProgress {
+ float low;
+ float hi;
+ mutable EditorProgressBG *progress;
+ void update(int p_current,int p_total) const;
+ ScanProgress get_sub(int p_current,int p_total) const;
+ };
static EditorFileSystemDirectory::ImportMeta _get_meta(const String& p_path);
- bool _check_meta_sources(EditorFileSystemDirectory::ImportMeta & p_meta,EditorProgressBG *ep=NULL);
+ bool _check_meta_sources(EditorFileSystemDirectory::ImportMeta & p_meta);
- DirItem* _scan_dir(DirAccess *da,Set<String> &extensions,String p_name,float p_from,float p_range,const String& p_path,HashMap<String,FileCache> &file_cache,HashMap<String,DirCache> &dir_cache,EditorProgressBG& p_prog);
- void _save_type_cache_fs(DirItem *p_dir,FileAccess *p_file);
+ void _save_filesystem_cache(EditorFileSystemDirectory *p_dir,FileAccess *p_file);
bool _find_file(const String& p_file,EditorFileSystemDirectory ** r_d, int &r_file_pos) const;
- void _scan_sources(EditorFileSystemDirectory *p_dir,EditorProgressBG *ep);
+ void _scan_fs_changes(EditorFileSystemDirectory *p_dir, const ScanProgress &p_progress);
int md_count;
+ Set<String> valid_extensions;
+
+ void _scan_new_dir(EditorFileSystemDirectory *p_dir,DirAccess *da,const ScanProgress& p_progress);
Thread *thread_sources;
bool scanning_sources;
bool scanning_sources_done;
- int ss_amount;
+
static void _thread_func_sources(void *_userdata);
+
List<String> sources_changed;
+ List<ItemAction> scan_actions;
+
+ bool _update_scan_actions();
static void _resource_saved(const String& p_path);
String _find_first_from_source(EditorFileSystemDirectory* p_dir,const String &p_src) const;
diff --git a/tools/editor/editor_fonts.cpp b/tools/editor/editor_fonts.cpp
index f145f1ddef..b12b041f16 100644
--- a/tools/editor/editor_fonts.cpp
+++ b/tools/editor/editor_fonts.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/editor_fonts.h b/tools/editor/editor_fonts.h
index cc990a560c..3b2422c3e3 100644
--- a/tools/editor/editor_fonts.h
+++ b/tools/editor/editor_fonts.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/editor_help.cpp b/tools/editor/editor_help.cpp
index a5a3890129..2ece518f8d 100644
--- a/tools/editor/editor_help.cpp
+++ b/tools/editor/editor_help.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -690,16 +690,28 @@ Error EditorHelp::_goto_desc(const String& p_class,int p_vscr) {
class_desc->pop();
//class_desc->add_newline();
- class_desc->add_newline();
+// class_desc->add_newline();
class_desc->push_indent(1);
+ class_desc->push_table(2);
+ class_desc->set_table_column_expand(1,1);
for(int i=0;i<cd.methods.size();i++) {
+ class_desc->push_cell();
+
+
method_line[cd.methods[i].name]=class_desc->get_line_count()-2; //gets overriden if description
+ class_desc->push_align(RichTextLabel::ALIGN_RIGHT);
class_desc->push_font(doc_code_font);
_add_type(cd.methods[i].return_type);
- class_desc->add_text(" ");
+ //class_desc->add_text(" ");
+ class_desc->pop(); //align
+ class_desc->pop(); //font
+ class_desc->pop(); //cell
+ class_desc->push_cell();
+ class_desc->push_font(doc_code_font);
+
if (cd.methods[i].description!="") {
method_descr=true;
class_desc->push_meta("@"+cd.methods[i].name);
@@ -742,12 +754,14 @@ Error EditorHelp::_goto_desc(const String& p_class,int p_vscr) {
}
class_desc->pop();//monofont
- class_desc->add_newline();
+// class_desc->add_newline();
+ class_desc->pop(); //cell
}
-
+ class_desc->pop(); //table
class_desc->pop();
class_desc->add_newline();
+ class_desc->add_newline();
}
diff --git a/tools/editor/editor_help.h b/tools/editor/editor_help.h
index 04ac4d35ff..059a7ae11d 100644
--- a/tools/editor/editor_help.h
+++ b/tools/editor/editor_help.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/editor_icons.h b/tools/editor/editor_icons.h
index 910febc895..191b908682 100644
--- a/tools/editor/editor_icons.h
+++ b/tools/editor/editor_icons.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/editor_import_export.cpp b/tools/editor/editor_import_export.cpp
index f52c6e67a2..77331256f3 100644
--- a/tools/editor/editor_import_export.cpp
+++ b/tools/editor/editor_import_export.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -41,6 +41,8 @@
#include "io/md5.h"
#include "io_plugins/editor_texture_import_plugin.h"
#include "tools/editor/plugins/script_editor_plugin.h"
+#include "io/zip_io.h"
+
String EditorImportPlugin::validate_source_path(const String& p_path) {
@@ -399,6 +401,40 @@ Vector<StringName> EditorExportPlatform::get_dependencies(bool p_bundles) const
}
+String EditorExportPlatform::find_export_template(String template_file_name, String *err) const {
+ String user_file = EditorSettings::get_singleton()->get_settings_path()
+ +"/templates/"+template_file_name;
+ String system_file=OS::get_singleton()->get_installed_templates_path();
+ bool has_system_path=(system_file!="");
+ system_file+=template_file_name;
+
+ // Prefer user file
+ if (FileAccess::exists(user_file)) {
+ return user_file;
+ }
+
+ // Now check system file
+ if (has_system_path) {
+ if (FileAccess::exists(system_file)) {
+ return system_file;
+ }
+ }
+
+ // Not found
+ if (err) {
+ *err+="No export template found at \""+user_file+"\"";
+ if (has_system_path)
+ *err+="\n or \""+system_file+"\".";
+ else
+ *err+=".";
+ }
+ return "";
+}
+
+bool EditorExportPlatform::exists_export_template(String template_file_name, String *err) const {
+ return find_export_template(template_file_name,err)!="";
+}
+
///////////////////////////////////////
@@ -419,6 +455,9 @@ bool EditorExportPlatformPC::_set(const StringName& p_name, const Variant& p_val
} else if (n=="resources/pack_mode") {
export_mode=ExportMode(int(p_value));
+ } else if (n=="resources/bundle_dependencies_(for_optical_disc)") {
+
+ bundle=p_value;
} else if (n=="binary/64_bits") {
use64=p_value;
@@ -442,6 +481,9 @@ bool EditorExportPlatformPC::_get(const StringName& p_name,Variant &r_ret) const
} else if (n=="resources/pack_mode") {
r_ret=export_mode;
+ } else if (n=="resources/bundle_dependencies_(for_optical_disc)") {
+
+ r_ret=bundle;
} else if (n=="binary/64_bits") {
r_ret=use64;
@@ -456,7 +498,8 @@ void EditorExportPlatformPC::_get_property_list( List<PropertyInfo> *p_list) con
p_list->push_back( PropertyInfo( Variant::STRING, "custom_binary/debug", PROPERTY_HINT_GLOBAL_FILE,binary_extension));
p_list->push_back( PropertyInfo( Variant::STRING, "custom_binary/release", PROPERTY_HINT_GLOBAL_FILE,binary_extension));
- p_list->push_back( PropertyInfo( Variant::INT, "resources/pack_mode", PROPERTY_HINT_ENUM,"Single Exec.,Exec+Pack (.pck),Copy,Bundles (Optical)"));
+ p_list->push_back( PropertyInfo( Variant::INT, "resources/pack_mode", PROPERTY_HINT_ENUM,"Pack into executable,Pack into binary file (.pck),Pack into archive file (.zip)"));
+ p_list->push_back( PropertyInfo( Variant::BOOL, "resources/bundle_dependencies_(for_optical_disc)"));
p_list->push_back( PropertyInfo( Variant::BOOL, "binary/64_bits"));
}
@@ -957,6 +1000,9 @@ void EditorExportPlatform::gen_export_flags(Vector<String> &r_flags, int p_flags
String host = EditorSettings::get_singleton()->get("network/debug_host");
+ if (p_flags&EXPORT_REMOTE_DEBUG_LOCALHOST)
+ host="localhost";
+
if (p_flags&EXPORT_DUMB_CLIENT) {
int port = EditorSettings::get_singleton()->get("file_server/port");
String passwd = EditorSettings::get_singleton()->get("file_server/password");
@@ -971,6 +1017,7 @@ void EditorExportPlatform::gen_export_flags(Vector<String> &r_flags, int p_flags
if (p_flags&EXPORT_REMOTE_DEBUG) {
r_flags.push_back("-rdebug");
+
r_flags.push_back(host+":"+String::num(GLOBAL_DEF("debug/debug_port", 6007)));
List<String> breakpoints;
@@ -1028,7 +1075,7 @@ Error EditorExportPlatform::save_pack_file(void *p_userdata,const String& p_path
MD5Final(&ctx);
pd->f->store_buffer(ctx.digest,16);
}
- pd->ep->step("Storing File: "+p_path,2+p_file*100/p_total);
+ pd->ep->step("Storing File: "+p_path,2+p_file*100/p_total,false);
pd->count++;
pd->ftmp->store_buffer(p_data.ptr(),p_data.size());
if (pd->alignment > 1) {
@@ -1043,6 +1090,58 @@ Error EditorExportPlatform::save_pack_file(void *p_userdata,const String& p_path
}
+Error EditorExportPlatform::save_zip_file(void *p_userdata,const String& p_path, const Vector<uint8_t>& p_data,int p_file,int p_total) {
+
+
+ String path=p_path.replace_first("res://","");
+
+ ZipData *zd = (ZipData*)p_userdata;
+
+ zipFile zip=(zipFile)zd->zip;
+
+ zipOpenNewFileInZip(zip,
+ path.utf8().get_data(),
+ NULL,
+ NULL,
+ 0,
+ NULL,
+ 0,
+ NULL,
+ Z_DEFLATED,
+ Z_DEFAULT_COMPRESSION);
+
+ zipWriteInFileInZip(zip,p_data.ptr(),p_data.size());
+ zipCloseFileInZip(zip);
+
+ zd->ep->step("Storing File: "+p_path,2+p_file*100/p_total,false);
+ zd->count++;
+ return OK;
+
+}
+
+Error EditorExportPlatform::save_zip(const String& p_path, bool p_make_bundles) {
+
+ EditorProgress ep("savezip","Packing",102);
+
+ //FileAccess *tmp = FileAccess::open(tmppath,FileAccess::WRITE);
+
+ FileAccess *src_f;
+ zlib_filefunc_def io = zipio_create_io_from_file(&src_f);
+ zipFile zip=zipOpen2(p_path.utf8().get_data(),APPEND_STATUS_CREATE,NULL,&io);
+
+ ZipData zd;
+ zd.count=0;
+ zd.ep=&ep;
+ zd.zip=zip;
+
+
+ Error err = export_project_files(save_zip_file,&zd,p_make_bundles);
+
+ zipClose(zip,NULL);
+
+ return err;
+}
+
Error EditorExportPlatform::save_pack(FileAccess *dst,bool p_make_bundles, int p_alignment) {
EditorProgress ep("savepack","Packing",102);
@@ -1131,19 +1230,32 @@ Error EditorExportPlatformPC::export_project(const String& p_path, bool p_debug,
ep.step("Setting Up..",0);
- String exe_path = EditorSettings::get_singleton()->get_settings_path()+"/templates/";
- if (use64) {
- if (p_debug)
- exe_path=custom_debug_binary!=""?custom_debug_binary:exe_path+debug_binary64;
- else
- exe_path=custom_release_binary!=""?custom_release_binary:exe_path+release_binary64;
- } else {
+ String exe_path="";
- if (p_debug)
- exe_path=custom_debug_binary!=""?custom_debug_binary:exe_path+debug_binary32;
- else
- exe_path=custom_release_binary!=""?custom_release_binary:exe_path+release_binary32;
+ if (p_debug)
+ exe_path=custom_debug_binary;
+ else
+ exe_path=custom_release_binary;
+ if (exe_path=="") {
+ String fname;
+ if (use64) {
+ if (p_debug)
+ fname=debug_binary64;
+ else
+ fname=release_binary64;
+ } else {
+ if (p_debug)
+ fname=debug_binary32;
+ else
+ fname=release_binary32;
+ }
+ String err="";
+ exe_path=find_export_template(fname,&err);
+ if (exe_path=="") {
+ EditorNode::add_io_error(err);
+ return ERR_FILE_CANT_READ;
+ }
}
FileAccess *src_exe=FileAccess::open(exe_path,FileAccess::READ);
@@ -1173,26 +1285,32 @@ Error EditorExportPlatformPC::export_project(const String& p_path, bool p_debug,
}
}
+ String dstfile = p_path.replace_first("res://","").replace("\\","/");
if (export_mode!=EXPORT_EXE) {
- String dstfile=p_path.replace_first("res://","").replace("\\","/");
+ String dstfile_extension=export_mode==EXPORT_ZIP?".zip":".pck";
if (dstfile.find("/")!=-1)
- dstfile=dstfile.get_base_dir()+"/data.pck";
+ dstfile=dstfile.get_base_dir()+"/data"+dstfile_extension;
else
- dstfile="data.pck";
+ dstfile="data"+dstfile_extension;
+ if (export_mode==EXPORT_PACK) {
- memdelete(dst);
- dst=FileAccess::open(dstfile,FileAccess::WRITE);
- if (!dst) {
+ memdelete(dst);
- EditorNode::add_io_error("Can't write data pack to:\n "+p_path);
- return ERR_FILE_CANT_WRITE;
+ dst=FileAccess::open(dstfile,FileAccess::WRITE);
+ if (!dst) {
+
+ EditorNode::add_io_error("Can't write data pack to:\n "+p_path);
+ return ERR_FILE_CANT_WRITE;
+ }
}
}
+
+
memdelete(src_exe);
- Error err = save_pack(dst,export_mode==EXPORT_BUNDLES);
+ Error err = export_mode==EXPORT_ZIP?save_zip(dstfile,bundle):save_pack(dst,bundle);
memdelete(dst);
return err;
}
@@ -1207,14 +1325,12 @@ bool EditorExportPlatformPC::can_export(String *r_error) const {
String err;
bool valid=true;
- String exe_path = EditorSettings::get_singleton()->get_settings_path()+"/templates/";
-
- if (use64 && (!FileAccess::exists(exe_path+debug_binary64) || !FileAccess::exists(exe_path+release_binary64))) {
+ if (use64 && (!exists_export_template(debug_binary64)) || !exists_export_template(release_binary64)) {
valid=false;
err="No 64 bits export templates found.\nDownload and install export templates.\n";
}
- if (!use64 && (!FileAccess::exists(exe_path+debug_binary32) || !FileAccess::exists(exe_path+release_binary32))) {
+ if (!use64 && (!exists_export_template(debug_binary32) || !exists_export_template(release_binary32))) {
valid=false;
err="No 32 bits export templates found.\nDownload and install export templates.\n";
}
@@ -1562,6 +1678,17 @@ void EditorImportExport::image_export_get_images_in_group(const StringName& p_gr
}
}
+void EditorImportExport::set_convert_text_scenes(bool p_convert) {
+
+ convert_text_scenes=p_convert;
+}
+
+bool EditorImportExport::get_convert_text_scenes() const{
+
+ return convert_text_scenes;
+}
+
+
void EditorImportExport::load_config() {
Ref<ConfigFile> cf = memnew( ConfigFile );
@@ -1604,6 +1731,12 @@ void EditorImportExport::load_config() {
}
}
+ if (cf->has_section("convert_scenes")) {
+
+ convert_text_scenes = cf->get_value("convert_scenes","convert_text_scenes");
+ }
+
+
if (cf->has_section("export_filter_files")) {
@@ -1720,6 +1853,15 @@ void EditorImportExport::load_config() {
if (cf->has_section("convert_samples")) {
+ if (cf->has_section_key("convert_samples","action")) {
+ String action = cf->get_value("convert_samples","action");
+ if (action=="none") {
+ sample_action=SAMPLE_ACTION_NONE;
+ } else if (action=="compress_ram") {
+ sample_action=SAMPLE_ACTION_COMPRESS_RAM;
+ }
+ }
+
if (cf->has_section_key("convert_samples","max_hz"))
sample_action_max_hz=cf->get_value("convert_samples","max_hz");
@@ -1837,6 +1979,8 @@ void EditorImportExport::save_config() {
case SCRIPT_ACTION_ENCRYPT: cf->set_value("script","action","encrypt"); break;
}
+ cf->set_value("convert_scenes","convert_text_scenes",convert_text_scenes);
+
cf->set_value("script","encrypt_key",script_key);
switch(sample_action) {
@@ -1935,6 +2079,8 @@ EditorImportExport::EditorImportExport() {
sample_action_max_hz=44100;
sample_action_trim=false;
+ convert_text_scenes=true;
+
}
diff --git a/tools/editor/editor_import_export.h b/tools/editor/editor_import_export.h
index 1a3171e66b..272464d9b0 100644
--- a/tools/editor/editor_import_export.h
+++ b/tools/editor/editor_import_export.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -33,6 +33,7 @@
#include "scene/main/node.h"
#include "scene/resources/texture.h"
+
class EditorExportPlatform;
class FileAccess;
class EditorProgress;
@@ -86,6 +87,8 @@ protected:
Vector<uint8_t> get_exported_file_default(String& p_fname) const;
virtual Vector<uint8_t> get_exported_file(String& p_fname) const;
virtual Vector<StringName> get_dependencies(bool p_bundles) const;
+ virtual String find_export_template(String template_file_name, String *err=NULL) const;
+ virtual bool exists_export_template(String template_file_name, String *err=NULL) const;
struct TempData {
@@ -105,8 +108,17 @@ protected:
};
+ struct ZipData {
+
+ void* zip;
+ EditorProgress *ep;
+ int count;
+
+ };
+
void gen_export_flags(Vector<String> &r_flags, int p_flags);
static Error save_pack_file(void *p_userdata,const String& p_path, const Vector<uint8_t>& p_data,int p_file,int p_total);
+ static Error save_zip_file(void *p_userdata,const String& p_path, const Vector<uint8_t>& p_data,int p_file,int p_total);
public:
@@ -124,14 +136,17 @@ public:
enum ExportFlags {
EXPORT_DUMB_CLIENT=1,
EXPORT_REMOTE_DEBUG=2,
- EXPORT_VIEW_COLLISONS=4,
- EXPORT_VIEW_NAVIGATION=8
+ EXPORT_REMOTE_DEBUG_LOCALHOST=4,
+ EXPORT_VIEW_COLLISONS=8,
+ EXPORT_VIEW_NAVIGATION=16,
};
Error export_project_files(EditorExportSaveFunction p_func, void* p_udata,bool p_make_bundles);
Error save_pack(FileAccess *p_where, bool p_make_bundles=false, int p_alignment = 1);
+ Error save_zip(const String& p_path, bool p_make_bundles=false);
+
virtual String get_name() const =0;
virtual ImageCompression get_image_compression() const=0;
virtual Ref<Texture> get_logo() const =0;
@@ -161,8 +176,7 @@ public:
enum ExportMode {
EXPORT_EXE,
EXPORT_PACK,
- EXPORT_COPY,
- EXPORT_BUNDLES
+ EXPORT_ZIP
};
@@ -184,6 +198,7 @@ private:
Ref<Texture> logo;
ExportMode export_mode;
+ bool bundle;
protected:
bool _set(const StringName& p_name, const Variant& p_value);
@@ -284,6 +299,8 @@ protected:
int sample_action_max_hz;
bool sample_action_trim;
+ bool convert_text_scenes;
+
static EditorImportExport* singleton;
static void _bind_methods();
@@ -362,6 +379,9 @@ public:
void sample_set_trim(bool p_trim);
bool sample_get_trim() const;
+ void set_convert_text_scenes(bool p_convert);
+ bool get_convert_text_scenes() const;
+
void load_config();
void save_config();
diff --git a/tools/editor/editor_log.cpp b/tools/editor/editor_log.cpp
index 264117eecd..bcdafbb06a 100644
--- a/tools/editor/editor_log.cpp
+++ b/tools/editor/editor_log.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -79,8 +79,6 @@ void EditorLog::_notification(int p_what) {
if (p_what==NOTIFICATION_ENTER_TREE) {
log->add_color_override("default_color",get_color("font_color","Tree"));
- tb->set_normal_texture( get_icon("Collapse","EditorIcons"));
- tb->set_hover_texture( get_icon("CollapseHl","EditorIcons"));
//button->set_icon(get_icon("Console","EditorIcons"));
}
@@ -98,11 +96,6 @@ void EditorLog::_notification(int p_what) {
}
-void EditorLog::_close_request() {
-
- _flip_request();
-
-}
void EditorLog::_clear_request() {
@@ -122,17 +115,17 @@ void EditorLog::add_message(const String& p_msg,bool p_error) {
if (p_error) {
Ref<Texture> icon = get_icon("Error","EditorIcons");
log->add_image( icon );
- button->set_icon(icon);
+ //button->set_icon(icon);
log->push_color(get_color("fg_error","Editor"));
} else {
- button->set_icon(Ref<Texture>());
+ //button->set_icon(Ref<Texture>());
}
log->add_newline();
log->add_text(p_msg);
- button->set_text(p_msg);
+// button->set_text(p_msg);
if (p_error)
log->pop();
@@ -156,21 +149,7 @@ void EditorLog::_dragged(const Point2& p_ofs) {
*/
-Button *EditorLog::get_button() {
- return button;
-}
-
-void EditorLog::_flip_request() {
-
- if (is_visible()) {
- hide();
- button->show();
- } else {
- show();
- button->hide();
- }
-}
void EditorLog::_undo_redo_cbk(void *p_self,const String& p_name) {
@@ -181,21 +160,16 @@ void EditorLog::_undo_redo_cbk(void *p_self,const String& p_name) {
void EditorLog::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_close_request"),&EditorLog::_close_request );
- ObjectTypeDB::bind_method(_MD("_flip_request"),&EditorLog::_flip_request );
ObjectTypeDB::bind_method(_MD("_clear_request"),&EditorLog::_clear_request );
//ObjectTypeDB::bind_method(_MD("_dragged"),&EditorLog::_dragged );
- ADD_SIGNAL( MethodInfo("close_request"));
- ADD_SIGNAL( MethodInfo("show_request"));
ADD_SIGNAL( MethodInfo("clear_request"));
}
EditorLog::EditorLog() {
- VBoxContainer *vb = memnew( VBoxContainer);
- add_child(vb);
- vb->set_v_size_flags(SIZE_EXPAND_FILL);
+ VBoxContainer *vb = this;
+ add_constant_override("separation",get_constant("separation","VBoxContainer"));
HBoxContainer *hb = memnew( HBoxContainer );
vb->add_child(hb);
@@ -204,14 +178,6 @@ EditorLog::EditorLog() {
title->set_h_size_flags(SIZE_EXPAND_FILL);
hb->add_child(title);
-
- button = memnew( Button );
- button->set_text_align(Button::ALIGN_LEFT);
- button->connect("pressed",this,"_flip_request");
- button->set_focus_mode(FOCUS_NONE);
- button->set_clip_text(true);
- button->set_tooltip("Open/Close output panel.");
-
//pd = memnew( PaneDrag );
//hb->add_child(pd);
//pd->connect("dragged",this,"_dragged");
@@ -222,14 +188,9 @@ EditorLog::EditorLog() {
clearbutton->set_text("Clear");
clearbutton->connect("pressed", this,"_clear_request");
- tb = memnew( TextureButton );
- hb->add_child(tb);
- tb->connect("pressed",this,"_close_request");
-
-
ec = memnew( Control);
vb->add_child(ec);
- ec->set_custom_minimum_size(Size2(0,100));
+ ec->set_custom_minimum_size(Size2(0,180));
ec->set_v_size_flags(SIZE_EXPAND_FILL);
@@ -243,9 +204,8 @@ EditorLog::EditorLog() {
log->set_selection_enabled(true);
log->set_focus_mode(FOCUS_CLICK);
pc->add_child(log);
- add_message(VERSION_FULL_NAME" (c) 2008-2015 Juan Linietsky, Ariel Manzur.");
+ add_message(VERSION_FULL_NAME" (c) 2008-2016 Juan Linietsky, Ariel Manzur.");
//log->add_text("Initialization Complete.\n"); //because it looks cool.
- add_style_override("panel",get_stylebox("panelf","Panel"));
eh.errfunc=_error_handler;
eh.userdata=this;
@@ -255,7 +215,6 @@ EditorLog::EditorLog() {
EditorNode::get_undo_redo()->set_commit_notify_callback(_undo_redo_cbk,this);
- hide();
}
diff --git a/tools/editor/editor_log.h b/tools/editor/editor_log.h
index 93044f9a2d..699be710d8 100644
--- a/tools/editor/editor_log.h
+++ b/tools/editor/editor_log.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -40,15 +40,13 @@
#include "scene/gui/tool_button.h"
#include "pane_drag.h"
#include "os/thread.h"
-class EditorLog : public PanelContainer {
+class EditorLog : public VBoxContainer {
- OBJ_TYPE( EditorLog, PanelContainer );
+ OBJ_TYPE( EditorLog, VBoxContainer );
- Button *button;
Button *clearbutton;
Label *title;
RichTextLabel *log;
- TextureButton *tb;
HBoxContainer *title_hb;
// PaneDrag *pd;
Control *ec;
@@ -60,8 +58,6 @@ class EditorLog : public PanelContainer {
Thread::ID current;
// void _dragged(const Point2& p_ofs);
- void _close_request();
- void _flip_request();
void _clear_request();
static void _undo_redo_cbk(void *p_self,const String& p_name);
protected:
@@ -73,7 +69,7 @@ public:
void add_message(const String& p_msg, bool p_error=false);
void deinit();
- Button *get_button();
+
void clear();
EditorLog();
~EditorLog();
diff --git a/tools/editor/editor_name_dialog.cpp b/tools/editor/editor_name_dialog.cpp
new file mode 100644
index 0000000000..c221b908e0
--- /dev/null
+++ b/tools/editor/editor_name_dialog.cpp
@@ -0,0 +1,89 @@
+/*************************************************************************/
+/* editor_name_dialog.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#include "editor_name_dialog.h"
+#include "object_type_db.h"
+#include "os/keyboard.h"
+
+void EditorNameDialog::_line_input_event(const InputEvent& p_event) {
+
+ if (p_event.type == InputEvent::KEY) {
+
+ if (!p_event.key.pressed)
+ return;
+
+ switch (p_event.key.scancode) {
+ case KEY_ENTER:
+ case KEY_RETURN: {
+
+ if (get_hide_on_ok())
+ hide();
+ ok_pressed();
+ accept_event();
+ } break;
+ case KEY_ESCAPE: {
+
+ hide();
+ accept_event();
+ } break;
+ }
+ }
+}
+
+void EditorNameDialog::_post_popup() {
+
+ ConfirmationDialog::_post_popup();
+ name->clear();
+ name->grab_focus();
+}
+
+void EditorNameDialog::ok_pressed() {
+
+ if (name->get_text()!="") {
+ emit_signal("name_confirmed", name->get_text());
+ }
+}
+
+void EditorNameDialog::_bind_methods() {
+
+ ObjectTypeDB::bind_method("_line_input_event",&EditorNameDialog::_line_input_event);
+
+ ADD_SIGNAL(MethodInfo("name_confirmed",PropertyInfo( Variant::STRING,"name")));
+}
+
+EditorNameDialog::EditorNameDialog()
+{
+ name = memnew( LineEdit );
+ add_child(name);
+ move_child(name, get_label()->get_index()+1);
+ name->set_margin(MARGIN_TOP,5);
+ name->set_anchor_and_margin(MARGIN_LEFT,ANCHOR_BEGIN,5);
+ name->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_END,5);
+ name->connect("input_event", this, "_line_input_event");
+}
diff --git a/tools/editor/console.h b/tools/editor/editor_name_dialog.h
index aff425fcde..9e66908899 100644
--- a/tools/editor/console.h
+++ b/tools/editor/editor_name_dialog.h
@@ -1,11 +1,11 @@
/*************************************************************************/
-/* console.h */
+/* editor_name_dialog.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -26,91 +26,32 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef CONSOLE_H
-#define CONSOLE_H
-#include "scene/gui/popup.h"
-#include "scene/gui/button.h"
-#include "scene/gui/tab_container.h"
-#include "scene/gui/tree.h"
-#include "scene/main/timer.h"
-#include "output_strings.h"
-#include "property_editor.h"
-#include "scene_tree_editor.h"
-#include "editor_data.h"
+#ifndef EDITOR_NAME_DIALOG_H
+#define EDITOR_NAME_DIALOG_H
-class Console : public Popup {
+#include "scene/gui/dialogs.h"
+#include "scene/gui/line_edit.h"
- OBJ_TYPE( Console, Popup );
+class EditorNameDialog : public ConfirmationDialog {
- TabContainer *tabs;
- OutputStrings *output;
- OutputStrings *errors;
- Control *status;
- Control *inspect;
- Control *globals;
- Button *close;
- int height;
+ OBJ_TYPE( EditorNameDialog, ConfirmationDialog );
- EditorHistory inspect_history;
- SceneTreeEditor *inspect_tree_editor;
- PropertyEditor *inspect_property_editor;
- PropertyEditor *globals_property_editor;
+ LineEdit *name;
- Tree *stats_tree;
-
- struct StatsItems {
-
- TreeItem *render_objects_in_frame;
- TreeItem *material_changes_in_frame;
-
- TreeItem *usage_video_mem_total;
- TreeItem *usage_video_mem_used;
- TreeItem *usage_texture_mem_used;
- TreeItem *usage_vertex_mem_used;
-
- TreeItem *usage_static_memory_total;
- TreeItem *usage_static_memory;
- TreeItem *usage_dynamic_memory_total;
- TreeItem *usage_dynamic_memory;
- TreeItem *usage_objects_instanced;
-
- } stats;
-
- struct OutputQueue {
-
- OutputStrings::LineType type;
- Variant meta;
- String text;
- };
-
- Mutex *output_queue_mutex;
- List<OutputQueue> output_queue;
-
-
- ErrorHandlerList err_handler;
- PrintHandlerList print_handler;
-
- void _inspector_node_selected();
-
- static void _error_handle(void *p_this,const char*p_function,const char* p_file,int p_line,const char *p_error, const char *p_explanation,ErrorHandlerType p_type);
- static void _print_handle(void *p_this,const String& p_string);
+ void _line_input_event(const InputEvent& p_event);
protected:
- virtual void _window_input_event(InputEvent p_event);
- virtual void _window_resize_event();
+ static void _bind_methods();
+ virtual void ok_pressed();
+ virtual void _post_popup();
- void _stats_update_timer_callback();
- void _resized();
- void _close_pressed();
+public:
- void _notification(int p_what);
+ LineEdit* get_line_edit() { return name; }
- static void _bind_methods();
-public:
- Console();
- ~Console();
+ EditorNameDialog();
};
-#endif // CONSOLE_H
+#endif // EDITOR_NAME_DIALOG_H
diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp
index 7b96db56f2..9fe76a738a 100644
--- a/tools/editor/editor_node.cpp
+++ b/tools/editor/editor_node.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -55,6 +55,7 @@
#include "bind/core_bind.h"
#include "io/zip_io.h"
#include "io/config_file.h"
+#include "animation_editor.h"
// plugins
#include "plugins/sprite_frames_editor_plugin.h"
@@ -102,6 +103,7 @@
#include "tools/editor/io_plugins/editor_sample_import_plugin.h"
#include "tools/editor/io_plugins/editor_translation_import_plugin.h"
#include "tools/editor/io_plugins/editor_mesh_import_plugin.h"
+#include "tools/editor/io_plugins/editor_export_scene.h"
#include "plugins/editor_preview_plugins.h"
@@ -142,6 +144,7 @@ void EditorNode::_update_scene_tabs() {
}
scene_tabs->set_current_tab(editor_data.get_edited_scene());
+ scene_tabs->ensure_tab_visible(editor_data.get_edited_scene());
}
@@ -161,7 +164,7 @@ void EditorNode::_update_title() {
void EditorNode::_unhandled_input(const InputEvent& p_event) {
- if (p_event.type==InputEvent::KEY && p_event.key.pressed && !p_event.key.echo) {
+ if (p_event.type==InputEvent::KEY && p_event.key.pressed && !p_event.key.echo && !gui_base->get_viewport()->gui_has_modal_stack()) {
switch(p_event.key.scancode) {
@@ -414,7 +417,7 @@ void EditorNode::_rebuild_import_menu()
{
PopupMenu* p = import_menu->get_popup();
p->clear();
- p->add_item("Sub-Scene", FILE_IMPORT_SUBSCENE);
+ p->add_item("Node from scene", FILE_IMPORT_SUBSCENE);
p->add_separator();
for (int i = 0; i < editor_import_export->get_import_plugin_count(); i++) {
p->add_item(editor_import_export->get_import_plugin(i)->get_visible_name(), IMPORT_PLUGIN_BASE + i);
@@ -510,13 +513,21 @@ void EditorNode::save_resource_as(const Ref<Resource>& p_resource) {
file->set_mode(EditorFileDialog::MODE_SAVE_FILE);
bool relpaths = (p_resource->has_meta("__editor_relpaths__") && p_resource->get_meta("__editor_relpaths__").operator bool());
+ current_option=RESOURCE_SAVE_AS;
List<String> extensions;
Ref<PackedScene> sd = memnew( PackedScene );
ResourceSaver::get_recognized_extensions(p_resource,&extensions);
file->clear_filters();
+
+ List<String> preferred;
for(int i=0;i<extensions.size();i++) {
+ if (p_resource->is_type("Script") && (extensions[i]=="tres" || extensions[i]=="res" || extensions[i]=="xml")) {
+ //this serves no purpose and confused people
+ continue;
+ }
file->add_filter("*."+extensions[i]+" ; "+extensions[i].to_upper());
+ preferred.push_back(extensions[i]);
}
//file->set_current_path(current_path);
@@ -528,11 +539,11 @@ void EditorNode::save_resource_as(const Ref<Resource>& p_resource) {
file->set_current_path(p_resource->get_path().replacen("."+ext,"."+extensions.front()->get()));
}
}
- } else {
+ } else if (preferred.size()) {
String existing;
if (extensions.size()) {
- existing="new_"+p_resource->get_type().to_lower()+"."+extensions.front()->get().to_lower();
+ existing="new_"+p_resource->get_type().to_lower()+"."+preferred.front()->get().to_lower();
}
file->set_current_path(existing);
@@ -542,7 +553,6 @@ void EditorNode::save_resource_as(const Ref<Resource>& p_resource) {
}
-
void EditorNode::_menu_option(int p_option) {
_menu_option_confirm(p_option,false);
@@ -584,59 +594,66 @@ void EditorNode::_dialog_display_file_error(String p_file,Error p_error) {
}
-void EditorNode::_get_scene_metadata() {
+void EditorNode::_get_scene_metadata(const String& p_file) {
Node *scene = editor_data.get_edited_scene_root();
if (!scene)
return;
+ String path = EditorSettings::get_singleton()->get_project_settings_path().plus_file(p_file.get_file()+"-editstate-"+p_file.md5_text()+".cfg");
- if (scene->has_meta("__editor_plugin_states__")) {
+ Ref<ConfigFile> cf;
+ cf.instance();
- Dictionary md = scene->get_meta("__editor_plugin_states__");
- editor_data.set_editor_states(md);
+ Error err = cf->load(path);
+ if (err!=OK)
+ return; //must not exist
- }
+ List<String> esl;
+ cf->get_section_keys("editor_states",&esl);
- if (scene->has_meta("__editor_run_settings__")) {
+ Dictionary md;
+ for (List<String>::Element *E=esl.front();E;E=E->next()) {
- Dictionary md = scene->get_meta("__editor_run_settings__");
- if (md.has("run_mode"))
- run_settings_dialog->set_run_mode(md["run_mode"]);
- if (md.has("custom_args"))
- run_settings_dialog->set_custom_arguments(md["custom_args"]);
+ Variant st=cf->get_value("editor_states",E->get());
+ if (st.get_type()) {
+ md[E->get()]=st;
+ }
}
+
+ editor_data.set_editor_states(md);
+
}
-void EditorNode::_set_scene_metadata() {
+void EditorNode::_set_scene_metadata(const String& p_file) {
Node *scene = editor_data.get_edited_scene_root();
if (!scene)
return;
- { /* Editor States */
- Dictionary md = editor_data.get_editor_states();
-
- if (!md.empty()) {
- scene->set_meta("__editor_plugin_states__",md);
- }
- }
+ scene->set_meta("__editor_run_settings__",Variant()); //clear it (no point in keeping it)
+ scene->set_meta("__editor_plugin_states__",Variant());
- { /* Run Settings */
+ String path = EditorSettings::get_singleton()->get_project_settings_path().plus_file(p_file.get_file()+"-editstate-"+p_file.md5_text()+".cfg");
+ Ref<ConfigFile> cf;
+ cf.instance();
- Dictionary md;
- md["run_mode"]=run_settings_dialog->get_run_mode();
- md["custom_args"]=run_settings_dialog->get_custom_arguments();
- scene->set_meta("__editor_run_settings__",md);
- }
+ Dictionary md = editor_data.get_editor_states();
+ List<Variant> keys;
+ md.get_key_list(&keys);
+ for(List<Variant>::Element *E=keys.front();E;E=E->next()) {
+ cf->set_value("editor_states",E->get(),md[E->get()]);
+ }
+ Error err = cf->save(path);
+ ERR_FAIL_COND(err!=OK);
}
@@ -954,8 +971,24 @@ void EditorNode::_save_scene(String p_file) {
}
- _set_scene_metadata();
- Ref<PackedScene> sdata = memnew( PackedScene );
+ _set_scene_metadata(p_file);
+
+
+ Ref<PackedScene> sdata;
+
+ if (ResourceCache::has(p_file)) {
+ // something may be referencing this resource and we are good with that.
+ // we must update it, but also let the previous scene state go, as
+ // old version still work for referencing changes in instanced or inherited scenes
+
+ sdata = Ref<PackedScene>( ResourceCache::get(p_file)->cast_to<PackedScene>() );
+ if (sdata.is_valid())
+ sdata->recreate_state();
+ else
+ sdata.instance();
+ } else {
+ sdata.instance();
+ }
Error err = sdata->pack(scene);
@@ -1162,75 +1195,6 @@ void EditorNode::_dialog_action(String p_file) {
save_translatable_strings(p_file);
} break;
- case FILE_SAVE_SUBSCENE: {
-
- List<Node*> selection = editor_selection->get_selected_node_list();
-
- if (selection.size()!=1) {
-
- current_option=-1;
- //confirmation->get_cancel()->hide();
- accept->get_ok()->set_text("I see..");
- accept->set_text("This operation requieres a single selected node.");
- accept->popup_centered_minsize();
- break;
- }
-
- Node *base = selection.front()->get();
-
- Map<Node*,Node*> reown;
- reown[editor_data.get_edited_scene_root()]=base;
- Node *copy = base->duplicate_and_reown(reown);
- if (copy) {
-
- Ref<PackedScene> sdata = memnew( PackedScene );
- Error err = sdata->pack(copy);
- memdelete(copy);
-
- if (err!=OK) {
-
-
- current_option=-1;
- //accept->get_cancel()->hide();
- accept->get_ok()->set_text("I see..");
- accept->set_text("Couldn't save subscene. Likely dependencies (instances) couldn't be satisfied.");
- accept->popup_centered_minsize();
- return;
- }
-
- int flg=0;
- if (EditorSettings::get_singleton()->get("on_save/compress_binary_resources"))
- flg|=ResourceSaver::FLAG_COMPRESS;
- if (EditorSettings::get_singleton()->get("on_save/save_paths_as_relative"))
- flg|=ResourceSaver::FLAG_RELATIVE_PATHS;
-
-
- err = ResourceSaver::save(p_file,sdata,flg);
- if (err!=OK) {
-
- current_option=-1;
- //confirmation->get_cancel()->hide();
- accept->get_ok()->set_text("I see..");
- accept->set_text("Error saving scene.");
- accept->popup_centered_minsize();
- break;
- }
- //EditorFileSystem::get_singleton()->update_file(p_file,sdata->get_type());
-
- } else {
-
- current_option=-1;
- //confirmation->get_cancel()->hide();
- accept->get_ok()->set_text("I see..");
- accept->set_text("Error duplicating scene to save it.");
- accept->popup_centered_minsize();
- break;
-
- }
-
-
- } break;
-
case FILE_SAVE_SCENE:
case FILE_SAVE_AS_SCENE: {
@@ -1290,10 +1254,18 @@ void EditorNode::_dialog_action(String p_file) {
case FILE_EXPORT_TILESET: {
Ref<TileSet> ml;
- if (file_export_lib_merge->is_pressed() && FileAccess::exists(p_file)) {
+ if (FileAccess::exists(p_file)) {
ml=ResourceLoader::load(p_file,"TileSet");
- if (ml.is_null()) {
+ if (!file_export_lib_merge->is_pressed()) {
+ ml->clear();
+ }
+
+ }
+
+ if (ml.is_null()) {
+
+ if (file_export_lib_merge->is_pressed()) {
current_option=-1;
//accept->get_cancel()->hide();
accept->get_ok()->set_text("I see..");
@@ -1302,9 +1274,6 @@ void EditorNode::_dialog_action(String p_file) {
return;
}
- }
-
- if (ml.is_null()) {
ml = Ref<TileSet>( memnew( TileSet ));
}
@@ -1409,6 +1378,65 @@ void EditorNode::_dialog_action(String p_file) {
save_resource_in_path(current_res,p_file);
} break;
+ case SETTINGS_LAYOUT_SAVE: {
+
+ if (p_file.empty())
+ return;
+
+ Ref<ConfigFile> config;
+ config.instance();
+ Error err = config->load(EditorSettings::get_singleton()->get_settings_path().plus_file("editor_layouts.cfg"));
+
+ if (err==ERR_CANT_OPEN) {
+ config.instance(); // new config
+ } else if (err!=OK) {
+ show_warning("Error trying to save layout!");
+ return;
+ }
+
+ _save_docks_to_config(config, p_file);
+
+ config->save(EditorSettings::get_singleton()->get_settings_path().plus_file("editor_layouts.cfg"));
+
+ layout_dialog->hide();
+ _update_layouts_menu();
+
+ if (p_file=="Default") {
+ show_warning("Default editor layout overridden.");
+ }
+
+ } break;
+ case SETTINGS_LAYOUT_DELETE: {
+
+ if (p_file.empty())
+ return;
+
+ Ref<ConfigFile> config;
+ config.instance();
+ Error err = config->load(EditorSettings::get_singleton()->get_settings_path().plus_file("editor_layouts.cfg"));
+
+ if (err!=OK || !config->has_section(p_file)) {
+ show_warning("Layout name not found!");
+ return;
+ }
+
+ // erase
+ List<String> keys;
+ config->get_section_keys(p_file, &keys);
+ for (List<String>::Element *E=keys.front();E;E=E->next()) {
+ config->set_value(p_file, E->get(), Variant());
+ }
+
+ config->save(EditorSettings::get_singleton()->get_settings_path().plus_file("editor_layouts.cfg"));
+
+ layout_dialog->hide();
+ _update_layouts_menu();
+
+ if (p_file=="Default") {
+ show_warning("Restored Default layout to base settings.");
+ }
+
+ } break;
default: { //save scene?
if (file->get_mode()==FileDialog::MODE_SAVE_FILE) {
@@ -1562,6 +1590,10 @@ void EditorNode::_edit_current() {
scene_tree_dock->set_selected(NULL);
property_editor->edit( NULL );
object_menu->set_disabled(true);
+
+ if (editor_plugin_over)
+ editor_plugin_over->make_visible(false);
+
return;
}
@@ -1710,7 +1742,7 @@ void EditorNode::_edit_current() {
//p->add_item("All Methods",OBJECT_CALL_METHOD);
- _update_keying();
+ update_keying();
}
void EditorNode::_resource_created() {
@@ -1749,7 +1781,7 @@ void EditorNode::_run(bool p_current,const String& p_custom) {
}
play_button->set_pressed(false);
- play_button->set_icon(gui_base->get_icon("Play","EditorIcons"));
+ play_button->set_icon(gui_base->get_icon("MainPlay","EditorIcons"));
//pause_button->set_pressed(false);
play_scene_button->set_pressed(false);
play_scene_button->set_icon(gui_base->get_icon("PlayScene","EditorIcons"));
@@ -1976,21 +2008,21 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
} break;
case FILE_QUICK_OPEN_SCENE: {
- quick_open->popup("PackedScene");
+ quick_open->popup("PackedScene", true);
quick_open->set_title("Quick Open Scene..");
} break;
case FILE_QUICK_OPEN_SCRIPT: {
- quick_open->popup("Script");
+ quick_open->popup("Script", true);
quick_open->set_title("Quick Open Script..");
} break;
case FILE_QUICK_OPEN_FILE: {
- quick_open->popup("Resource",false,true);
+ quick_open->popup("Resource", false, true);
quick_open->set_title("Quick Search File..");
} break;
@@ -2008,7 +2040,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
} break;
case FILE_CLOSE: {
- if (!p_confirmed) {
+ if (!p_confirmed && unsaved_cache) {
confirmation->get_ok()->set_text("Yes");
//confirmation->get_cancel()->show();
confirmation->set_text("Close scene? (Unsaved changes will be lost)");
@@ -2037,7 +2069,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
return;
};
// fallthrough to save_as
- } break;
+ };
case FILE_SAVE_AS_SCENE: {
Node *scene = editor_data.get_edited_scene_root();
@@ -2141,70 +2173,6 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
file->set_title("Save Translatable Strings");
file->popup_centered_ratio();
-
- } break;
-
- case FILE_SAVE_SUBSCENE: {
-
- Node *scene = editor_data.get_edited_scene_root();
-
- if (!scene) {
-
- current_option=-1;
- //confirmation->get_cancel()->hide();
- accept->get_ok()->set_text("I see..");
- accept->set_text("This operation can't be done without a scene.");
- accept->popup_centered_minsize();
- break;
- }
-
-
- List<Node*> selection = editor_selection->get_selected_node_list();
-
- if (selection.size()!=1) {
-
- current_option=-1;
- //confirmation->get_cancel()->hide();
- accept->get_ok()->set_text("I see..");
- accept->set_text("This operation requieres a single selected node.");
- accept->popup_centered_minsize();
- break;
- }
-
- Node *tocopy = selection.front()->get();
-
- if (tocopy!=editor_data.get_edited_scene_root() && tocopy->get_filename()!="") {
-
-
- current_option=-1;
- //confirmation->get_cancel()->hide();
- accept->get_ok()->set_text("I see..");
- accept->set_text("This operation can't be done on instanced scenes.");
- accept->popup_centered_minsize();
- break;
- }
-
- file->set_mode(EditorFileDialog::MODE_SAVE_FILE);
-
- List<String> extensions;
- Ref<PackedScene> sd = memnew( PackedScene );
- ResourceSaver::get_recognized_extensions(sd,&extensions);
- file->clear_filters();
- for(int i=0;i<extensions.size();i++) {
-
- file->add_filter("*."+extensions[i]+" ; "+extensions[i].to_upper());
- }
-
-
- String existing;
- if (extensions.size()) {
- existing="new_scene."+extensions.front()->get().to_lower();
- }
- file->set_current_path(existing);
-
-
- file->popup_centered_ratio();
- file->set_title("Save Sub-Scene As..");
} break;
case FILE_SAVE_OPTIMIZED: {
Node *scene = editor_data.get_edited_scene_root();
@@ -2399,7 +2367,14 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
if (!scene)
break;
-
+
+ String filename = scene->get_filename();
+
+ if (filename==String()) {
+ show_warning("Can't reload a scene that was never saved..");
+ break;
+ }
+
if (unsaved_cache && !p_confirmed) {
confirmation->get_ok()->set_text("Revert");
confirmation->set_text("This action cannot be undone. Revert anyway?");
@@ -2407,7 +2382,13 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
break;
}
- Error err = load_scene(scene->get_filename());
+
+ int cur_idx = editor_data.get_edited_scene();
+ _remove_edited_scene();
+ Error err = load_scene(filename);
+ editor_data.move_edited_scene_to_index(cur_idx);
+ get_undo_redo()->clear_history();
+ scene_tabs->set_current_tab(cur_idx);
} break;
@@ -2621,7 +2602,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
editor_run.stop();
play_button->set_pressed(false);
- play_button->set_icon(gui_base->get_icon("Play","EditorIcons"));
+ play_button->set_icon(gui_base->get_icon("MainPlay","EditorIcons"));
play_scene_button->set_pressed(false);
play_scene_button->set_icon(gui_base->get_icon("PlayScene","EditorIcons"));
//pause_button->set_pressed(false);
@@ -2746,11 +2727,6 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
//optimized_presets->popup_centered_ratio();
} break;
- case SETTINGS_SHOW_ANIMATION: {
-
- animation_panel_make_visible( ! animation_panel->is_visible() );
-
- } break;
case SETTINGS_LOAD_EXPORT_TEMPLATES: {
@@ -3000,7 +2976,7 @@ void EditorNode::set_edited_scene(Node *p_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);
+
}
get_editor_data().set_edited_scene_root(p_scene);
@@ -3013,7 +2989,7 @@ void EditorNode::set_edited_scene(Node *p_scene) {
if (p_scene) {
if (p_scene->get_parent()!=scene_root)
scene_root->add_child(p_scene);
- animation_editor->set_root(p_scene);
+
}
}
@@ -3069,7 +3045,7 @@ Error EditorNode::save_translatable_strings(const String& p_to_file) {
OS::Time time = OS::get_singleton()->get_time();
f->store_line("# Translation Strings Dump.");
f->store_line("# Created By.");
- f->store_line("# \t" VERSION_FULL_NAME " (c) 2008-2015 Juan Linietsky, Ariel Manzur.");
+ f->store_line("# \t" VERSION_FULL_NAME " (c) 2008-2016 Juan Linietsky, Ariel Manzur.");
f->store_line("# From Scene: ");
f->store_line("# \t"+get_edited_scene()->get_filename());
f->store_line("");
@@ -3332,6 +3308,8 @@ void EditorNode::_set_main_scene_state(Dictionary p_state) {
//changing_scene=true; //avoid script change from opening editor
ScriptEditor::get_singleton()->get_debugger()->update_live_edit_root();
ScriptEditor::get_singleton()->set_scene_root_script( editor_data.get_scene_root_script(editor_data.get_edited_scene()) );
+ editor_data.notify_edited_scene_changed();
+
//changing_scene=false;
}
@@ -3345,15 +3323,25 @@ void EditorNode::set_current_version(uint64_t p_version) {
bool EditorNode::is_changing_scene() const {
return changing_scene;
}
+
+void EditorNode::_clear_undo_history() {
+
+ get_undo_redo()->clear_history();
+}
+
void EditorNode::set_current_scene(int p_idx) {
+ if (editor_data.check_and_update_scene(p_idx)) {
+ call_deferred("_clear_undo_history");
+ }
+
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 ");
@@ -3375,7 +3363,7 @@ void EditorNode::set_current_scene(int p_idx) {
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 ");
@@ -3423,11 +3411,13 @@ Error EditorNode::load_scene(const String& p_scene, bool p_ignore_broken_deps,bo
}
- for(int i=0;i<editor_data.get_edited_scene_count();i++) {
+ if(!p_set_inherited) {
+ for(int i=0;i<editor_data.get_edited_scene_count();i++) {
- if (editor_data.get_scene_path(i)==p_scene) {
- _scene_tab_changed(i);
- return OK;
+ if (editor_data.get_scene_path(i)==p_scene) {
+ _scene_tab_changed(i);
+ return OK;
+ }
}
}
@@ -3509,7 +3499,18 @@ Error EditorNode::load_scene(const String& p_scene, bool p_ignore_broken_deps,bo
add_io_error(txt);
}
- sdata->set_path(lpath,true); //take over path
+ if (ResourceCache::has(lpath)) {
+ //used from somewhere else? no problem! update state and replace sdata
+ Ref<PackedScene> ps = Ref<PackedScene>( ResourceCache::get(lpath)->cast_to<PackedScene>() );
+ if (ps.is_valid()) {
+ ps->replace_state( sdata->get_state() );
+ ps->set_last_modified_time( sdata->get_last_modified_time() );
+ sdata=ps;
+ }
+
+ } else {
+ sdata->set_path(lpath,true); //take over path
+ }
Node*new_scene=sdata->instance(true);
@@ -3557,7 +3558,7 @@ Error EditorNode::load_scene(const String& p_scene, bool p_ignore_broken_deps,bo
new_scene->set_scene_instance_state(Ref<SceneState>());
set_edited_scene(new_scene);
- _get_scene_metadata();
+ _get_scene_metadata(p_scene);
/*
editor_data.set_edited_scene_root(new_scene);
@@ -3628,7 +3629,7 @@ void EditorNode::_instance_request(const String& p_path){
void EditorNode::_property_keyed(const String& p_keyed,const Variant& p_value,bool p_advance) {
- animation_editor->insert_value_key(p_keyed,p_value,p_advance);
+ AnimationPlayerEditor::singleton->get_key_editor()->insert_value_key(p_keyed,p_value,p_advance);
}
void EditorNode::_transform_keyed(Object *sp,const String& p_sub,const Transform& p_key) {
@@ -3636,16 +3637,16 @@ void EditorNode::_transform_keyed(Object *sp,const String& p_sub,const Transform
Spatial *s=sp->cast_to<Spatial>();
if (!s)
return;
- animation_editor->insert_transform_key(s,p_sub,p_key);
+ AnimationPlayerEditor::singleton->get_key_editor()->insert_transform_key(s,p_sub,p_key);
}
-void EditorNode::_update_keying() {
+void EditorNode::update_keying() {
//print_line("KR: "+itos(p_enabled));
bool valid=false;
- if (animation_editor->has_keying()) {
+ if (AnimationPlayerEditor::singleton->get_key_editor()->has_keying()) {
if (editor_history.get_path_size()>=1) {
@@ -3679,6 +3680,7 @@ void EditorNode::_show_messages() {
}
+#if 0
void EditorNode::animation_panel_make_visible(bool p_visible) {
if (!p_visible) {
@@ -3691,6 +3693,7 @@ void EditorNode::animation_panel_make_visible(bool p_visible) {
settings_menu->get_popup()->set_item_checked(idx,p_visible);
}
+
void EditorNode::animation_editor_make_visible(bool p_visible) {
if (p_visible) {
@@ -3712,10 +3715,9 @@ void EditorNode::animation_editor_make_visible(bool p_visible) {
}
animation_editor->set_keying(p_visible);
- _update_keying();
}
-
+#endif
void EditorNode::_add_to_recent_scenes(const String& p_scene) {
String base="_"+Globals::get_singleton()->get_resource_path().replace("\\","::").replace("/","::");
@@ -3808,24 +3810,26 @@ void EditorNode::_update_recent_scenes() {
}
-void EditorNode::hide_animation_player_editors() {
-
- emit_signal("hide_animation_player_editors");
-}
-
-void EditorNode::_quick_opened(const String& p_resource) {
+void EditorNode::_quick_opened() {
if (current_option==FILE_QUICK_OPEN_FILE) {
- scenes_dock->open(p_resource);
+ String res_path = quick_open->get_selected();
+
+ scenes_dock->open(res_path);
return;
}
- if (quick_open->get_base_type()=="PackedScene") {
- open_request(p_resource);
- } else {
- load_resource(p_resource);
- }
+ Vector<String> files = quick_open->get_selected_files();
+
+ for (int i = 0; i < files.size(); i++) {
+ String res_path = files[i];
+ if (quick_open->get_base_type()=="PackedScene") {
+ open_request(res_path);
+ } else {
+ load_resource(res_path);
+ }
+ }
}
void EditorNode::_quick_run(const String& p_resource) {
@@ -3945,9 +3949,9 @@ void EditorNode::progress_add_task(const String& p_task,const String& p_label, i
singleton->progress_dialog->add_task(p_task,p_label,p_steps);
}
-void EditorNode::progress_task_step(const String& p_task, const String& p_state, int p_step) {
+void EditorNode::progress_task_step(const String& p_task, const String& p_state, int p_step,bool p_force_redraw) {
- singleton->progress_dialog->task_step(p_task,p_state,p_step);
+ singleton->progress_dialog->task_step(p_task,p_state,p_step,p_force_redraw);
}
@@ -3976,87 +3980,6 @@ void EditorNode::progress_end_task_bg(const String& p_task) {
}
-void EditorNode::_bind_methods() {
-
-
- ObjectTypeDB::bind_method("_menu_option",&EditorNode::_menu_option);
- ObjectTypeDB::bind_method("_menu_confirm_current",&EditorNode::_menu_confirm_current);
- ObjectTypeDB::bind_method("_dialog_action",&EditorNode::_dialog_action);
- ObjectTypeDB::bind_method("_resource_selected",&EditorNode::_resource_selected,DEFVAL(""));
- ObjectTypeDB::bind_method("_property_editor_forward",&EditorNode::_property_editor_forward);
- ObjectTypeDB::bind_method("_property_editor_back",&EditorNode::_property_editor_back);
- ObjectTypeDB::bind_method("_editor_select",&EditorNode::_editor_select);
- ObjectTypeDB::bind_method("_node_renamed",&EditorNode::_node_renamed);
- ObjectTypeDB::bind_method("edit_node",&EditorNode::edit_node);
- ObjectTypeDB::bind_method("_imported",&EditorNode::_imported);
- ObjectTypeDB::bind_method("_unhandled_input",&EditorNode::_unhandled_input);
-
- ObjectTypeDB::bind_method("_get_scene_metadata",&EditorNode::_get_scene_metadata);
- ObjectTypeDB::bind_method("set_edited_scene",&EditorNode::set_edited_scene);
- ObjectTypeDB::bind_method("open_request",&EditorNode::open_request);
- ObjectTypeDB::bind_method("_instance_request",&EditorNode::_instance_request);
- ObjectTypeDB::bind_method("_update_keying",&EditorNode::_update_keying);
- ObjectTypeDB::bind_method("_property_keyed",&EditorNode::_property_keyed);
- ObjectTypeDB::bind_method("_transform_keyed",&EditorNode::_transform_keyed);
- ObjectTypeDB::bind_method("_close_messages",&EditorNode::_close_messages);
- ObjectTypeDB::bind_method("_show_messages",&EditorNode::_show_messages);
- ObjectTypeDB::bind_method("_vp_resized",&EditorNode::_vp_resized);
- ObjectTypeDB::bind_method("_quick_opened",&EditorNode::_quick_opened);
- ObjectTypeDB::bind_method("_quick_run",&EditorNode::_quick_run);
-
- ObjectTypeDB::bind_method("_resource_created",&EditorNode::_resource_created);
-
- ObjectTypeDB::bind_method("_import_action",&EditorNode::_import_action);
- //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("_save_optimized",&EditorNode::_save_optimized);
- ObjectTypeDB::bind_method(_MD("animation_panel_make_visible","enable"),&EditorNode::animation_panel_make_visible);
-
- ObjectTypeDB::bind_method("stop_child_process",&EditorNode::stop_child_process);
-
- ObjectTypeDB::bind_method("_sources_changed",&EditorNode::_sources_changed);
- ObjectTypeDB::bind_method("_fs_changed",&EditorNode::_fs_changed);
- ObjectTypeDB::bind_method("_dock_select_draw",&EditorNode::_dock_select_draw);
- ObjectTypeDB::bind_method("_dock_select_input",&EditorNode::_dock_select_input);
- ObjectTypeDB::bind_method("_dock_pre_popup",&EditorNode::_dock_pre_popup);
- ObjectTypeDB::bind_method("_dock_split_dragged",&EditorNode::_dock_split_dragged);
- ObjectTypeDB::bind_method("_save_docks",&EditorNode::_save_docks);
- ObjectTypeDB::bind_method("_dock_popup_exit",&EditorNode::_dock_popup_exit);
- ObjectTypeDB::bind_method("_dock_move_left",&EditorNode::_dock_move_left);
- ObjectTypeDB::bind_method("_dock_move_right",&EditorNode::_dock_move_right);
-
- ObjectTypeDB::bind_method("set_current_scene",&EditorNode::set_current_scene);
- ObjectTypeDB::bind_method("set_current_version",&EditorNode::set_current_version);
- ObjectTypeDB::bind_method("_scene_tab_changed",&EditorNode::_scene_tab_changed);
- ObjectTypeDB::bind_method("_scene_tab_closed",&EditorNode::_scene_tab_closed);
- ObjectTypeDB::bind_method("_scene_tab_script_edited",&EditorNode::_scene_tab_script_edited);
- ObjectTypeDB::bind_method("_set_main_scene_state",&EditorNode::_set_main_scene_state);
- ObjectTypeDB::bind_method("_update_scene_tabs",&EditorNode::_update_scene_tabs);
-
- ObjectTypeDB::bind_method("_prepare_history",&EditorNode::_prepare_history);
- ObjectTypeDB::bind_method("_select_history",&EditorNode::_select_history);
-
- ObjectTypeDB::bind_method("_toggle_search_bar",&EditorNode::_toggle_search_bar);
- ObjectTypeDB::bind_method("_clear_search_box",&EditorNode::_clear_search_box);
-
- ObjectTypeDB::bind_method(_MD("add_editor_import_plugin", "plugin"), &EditorNode::add_editor_import_plugin);
- ObjectTypeDB::bind_method(_MD("remove_editor_import_plugin", "plugin"), &EditorNode::remove_editor_import_plugin);
- ObjectTypeDB::bind_method(_MD("get_gui_base"), &EditorNode::get_gui_base);
-
- ADD_SIGNAL( MethodInfo("play_pressed") );
- ADD_SIGNAL( MethodInfo("pause_pressed") );
- ADD_SIGNAL( MethodInfo("stop_pressed") );
- ADD_SIGNAL( MethodInfo("hide_animation_player_editors") );
- ADD_SIGNAL( MethodInfo("request_help") );
- ADD_SIGNAL( MethodInfo("script_add_function_request",PropertyInfo(Variant::OBJECT,"obj"),PropertyInfo(Variant::STRING,"function"),PropertyInfo(Variant::STRING_ARRAY,"args")) );
- ADD_SIGNAL( MethodInfo("resource_saved",PropertyInfo(Variant::OBJECT,"obj")) );
-
-
-
-}
Ref<Texture> EditorNode::_file_dialog_get_icon(const String& p_path) {
@@ -4322,6 +4245,15 @@ void EditorNode::_save_docks() {
Ref<ConfigFile> config;
config.instance();
+ _save_docks_to_config(config, "docks");
+ editor_data.get_plugin_window_layout(config);
+
+ config->save(EditorSettings::get_singleton()->get_project_settings_path().plus_file("editor_layout.cfg"));
+
+}
+
+void EditorNode::_save_docks_to_config(Ref<ConfigFile> p_layout, const String& p_section) {
+
for(int i=0;i<DOCK_SLOT_MAX;i++) {
String names;
for(int j=0;j<dock_slot[i]->get_tab_count();j++) {
@@ -4332,7 +4264,7 @@ void EditorNode::_save_docks() {
}
if (names!="") {
- config->set_value("docks","dock_"+itos(i+1),names);
+ p_layout->set_value(p_section,"dock_"+itos(i+1),names);
}
}
@@ -4346,7 +4278,7 @@ void EditorNode::_save_docks() {
for(int i=0;i<DOCK_SLOT_MAX/2;i++) {
if (splits[i]->is_visible()) {
- config->set_value("docks","dock_split_"+itos(i+1),splits[i]->get_split_offset());
+ p_layout->set_value(p_section,"dock_split_"+itos(i+1),splits[i]->get_split_offset());
}
}
@@ -4360,13 +4292,9 @@ void EditorNode::_save_docks() {
for(int i=0;i<4;i++) {
- config->set_value("docks","dock_hsplit_"+itos(i+1),h_splits[i]->get_split_offset());
+ p_layout->set_value(p_section,"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() {
@@ -4385,15 +4313,26 @@ void EditorNode::_load_docks() {
config.instance();
Error err = config->load(EditorSettings::get_singleton()->get_project_settings_path().plus_file("editor_layout.cfg"));
if (err!=OK) {
- return; //no config
+ //no config
+ if (overridden_default_layout>=0) {
+ _layout_menu_option(overridden_default_layout);
+ }
+ return;
}
+ _load_docks_from_config(config, "docks");
+ editor_data.set_plugin_window_layout(config);
+
+}
+
+void EditorNode::_load_docks_from_config(Ref<ConfigFile> p_layout, const String& p_section) {
+
for(int i=0;i<DOCK_SLOT_MAX;i++) {
- if (!config->has_section_key("docks","dock_"+itos(i+1)))
+ if (!p_layout->has_section_key(p_section,"dock_"+itos(i+1)))
continue;
- Vector<String> names = String(config->get_value("docks","dock_"+itos(i+1))).split(",");
+ Vector<String> names = String(p_layout->get_value(p_section,"dock_"+itos(i+1))).split(",");
for(int j=0;j<names.size();j++) {
@@ -4413,7 +4352,7 @@ void EditorNode::_load_docks() {
if (atidx==-1) //well, it's not anywhere
continue;
- if (atidx==j) {
+ if (atidx==i) {
node->raise();
continue;
}
@@ -4428,7 +4367,6 @@ void EditorNode::_load_docks() {
dock_slot[i]->add_child(node);
dock_slot[i]->show();
}
-
}
VSplitContainer*splits[DOCK_SLOT_MAX/2]={
@@ -4440,14 +4378,14 @@ void EditorNode::_load_docks() {
for(int i=0;i<DOCK_SLOT_MAX/2;i++) {
- if (!config->has_section_key("docks","dock_split_"+itos(i+1)))
+ if (!p_layout->has_section_key(p_section,"dock_split_"+itos(i+1)))
continue;
- int ofs = config->get_value("docks","dock_split_"+itos(i+1));
+ int ofs = p_layout->get_value(p_section,"dock_split_"+itos(i+1));
splits[i]->set_split_offset(ofs);
}
- HSplitContainer *h_splits[4]={
+ HSplitContainer*h_splits[4]={
left_l_hsplit,
left_r_hsplit,
main_hsplit,
@@ -4455,9 +4393,9 @@ void EditorNode::_load_docks() {
};
for(int i=0;i<4;i++) {
- if (!config->has_section_key("docks","dock_hsplit_"+itos(i+1)))
+ if (!p_layout->has_section_key(p_section,"dock_hsplit_"+itos(i+1)))
continue;
- int ofs = config->get_value("docks","dock_hsplit_"+itos(i+1));
+ int ofs = p_layout->get_value(p_section,"dock_hsplit_"+itos(i+1));
h_splits[i]->set_split_offset(ofs);
}
@@ -4475,8 +4413,80 @@ void EditorNode::_load_docks() {
dock_slot[i]->set_current_tab(0);
}
}
+}
- editor_data.set_plugin_window_layout(config);
+
+void EditorNode::_update_layouts_menu() {
+
+ editor_layouts->clear();
+ overridden_default_layout=-1;
+
+ editor_layouts->set_size(Vector2());
+ editor_layouts->add_item("Save Layout", SETTINGS_LAYOUT_SAVE);
+ editor_layouts->add_item("Delete Layout", SETTINGS_LAYOUT_DELETE);
+ editor_layouts->add_separator();
+ editor_layouts->add_item("Default", SETTINGS_LAYOUT_DEFAULT);
+
+ Ref<ConfigFile> config;
+ config.instance();
+ Error err = config->load(EditorSettings::get_singleton()->get_settings_path().plus_file("editor_layouts.cfg"));
+ if (err!=OK) {
+ return; //no config
+ }
+
+ List<String> layouts;
+ config.ptr()->get_sections(&layouts);
+
+ for (List<String>::Element *E=layouts.front();E;E=E->next()) {
+
+ String layout=E->get();
+
+ if (layout=="Default") {
+ editor_layouts->remove_item(editor_layouts->get_item_index(SETTINGS_LAYOUT_DEFAULT));
+ overridden_default_layout=editor_layouts->get_item_count();
+ }
+
+ editor_layouts->add_item(layout);
+ }
+
+}
+
+void EditorNode::_layout_menu_option(int p_id) {
+
+ switch (p_id) {
+
+ case SETTINGS_LAYOUT_SAVE: {
+
+ current_option=p_id;
+ layout_dialog->set_title("Save Layout");
+ layout_dialog->get_ok()->set_text("Save");
+ layout_dialog->popup_centered();
+ } break;
+ case SETTINGS_LAYOUT_DELETE: {
+
+ current_option=p_id;
+ layout_dialog->set_title("Delete Layout");
+ layout_dialog->get_ok()->set_text("Delete");
+ layout_dialog->popup_centered();
+ } break;
+ case SETTINGS_LAYOUT_DEFAULT: {
+
+ _load_docks_from_config(default_layout, "docks");
+ _save_docks();
+ } break;
+ default: {
+
+ Ref<ConfigFile> config;
+ config.instance();
+ Error err = config->load(EditorSettings::get_singleton()->get_settings_path().plus_file("editor_layouts.cfg"));
+ if (err!=OK) {
+ return; //no config
+ }
+
+ _load_docks_from_config(config, editor_layouts->get_item_text(p_id));
+ _save_docks();
+ }
+ }
}
@@ -4523,12 +4533,14 @@ void EditorNode::_scene_tab_changed(int p_tab) {
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(scene_tabs,"set_current_tab",p_tab);
+ //editor_data.get_undo_redo().add_do_method(scene_tabs,"ensure_tab_visible",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(scene_tabs,"set_current_tab",editor_data.get_edited_scene());
+ //editor_data.get_undo_redo().add_undo_method(scene_tabs,"ensure_tab_visible",p_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();
@@ -4558,6 +4570,173 @@ void EditorNode::_clear_search_box() {
property_editor->update_tree();
}
+ToolButton *EditorNode::add_bottom_panel_item(String p_text,Control *p_item) {
+
+ ToolButton *tb = memnew( ToolButton );
+ tb->connect("toggled",this,"_bottom_panel_switch",varray(bottom_panel_items.size()));
+ tb->set_text(p_text);
+ tb->set_toggle_mode(true);
+ tb->set_focus_mode(Control::FOCUS_NONE);
+ bottom_panel_vb->add_child(p_item);
+ bottom_panel_hb->raise();
+ bottom_panel_hb->add_child(tb);
+ p_item->set_v_size_flags(Control::SIZE_EXPAND_FILL);
+ p_item->hide();
+ BottomPanelItem bpi;
+ bpi.button=tb;
+ bpi.control=p_item;
+ bpi.name=p_text;
+ bottom_panel_items.push_back(bpi);
+
+ return tb;
+
+}
+
+void EditorNode::hide_bottom_panel() {
+
+ _bottom_panel_switch(false,0);
+
+}
+
+void EditorNode::make_bottom_panel_item_visible(Control *p_item) {
+
+ for(int i=0;i<bottom_panel_items.size();i++) {
+
+ if (bottom_panel_items[i].control==p_item) {
+ _bottom_panel_switch(true,i);
+ break;
+ }
+ }
+}
+
+void EditorNode::raise_bottom_panel_item(Control *p_item) {
+
+ for(int i=0;i<bottom_panel_items.size();i++) {
+
+ if (bottom_panel_items[i].control==p_item) {
+ bottom_panel_items[i].button->raise();
+ SWAP( bottom_panel_items[i], bottom_panel_items[bottom_panel_items.size()-1]);
+ break;
+ }
+ }
+
+ for(int i=0;i<bottom_panel_items.size();i++) {
+ bottom_panel_items[i].button->disconnect("toggled",this,"_bottom_panel_switch");
+ bottom_panel_items[i].button->connect("toggled",this,"_bottom_panel_switch",varray(i));
+ }
+
+}
+
+void EditorNode::_bottom_panel_switch(bool p_enable,int p_idx) {
+
+ ERR_FAIL_INDEX(p_idx,bottom_panel_items.size());
+
+
+
+ if (p_enable) {
+ for(int i=0;i<bottom_panel_items.size();i++) {
+
+ bottom_panel_items[i].button->set_pressed(i==p_idx);
+ bottom_panel_items[i].control->set_hidden(i!=p_idx);
+ }
+ center_split->set_dragger_visibility(SplitContainer::DRAGGER_VISIBLE);
+ center_split->set_collapsed(false);
+ } else {
+ for(int i=0;i<bottom_panel_items.size();i++) {
+
+ bottom_panel_items[i].button->set_pressed(false);
+ bottom_panel_items[i].control->set_hidden(true);
+ }
+ center_split->set_dragger_visibility(SplitContainer::DRAGGER_HIDDEN);
+ center_split->set_collapsed(true);
+ }
+}
+
+void EditorNode::_bind_methods() {
+
+
+ ObjectTypeDB::bind_method("_menu_option",&EditorNode::_menu_option);
+ ObjectTypeDB::bind_method("_menu_confirm_current",&EditorNode::_menu_confirm_current);
+ ObjectTypeDB::bind_method("_dialog_action",&EditorNode::_dialog_action);
+ ObjectTypeDB::bind_method("_resource_selected",&EditorNode::_resource_selected,DEFVAL(""));
+ ObjectTypeDB::bind_method("_property_editor_forward",&EditorNode::_property_editor_forward);
+ ObjectTypeDB::bind_method("_property_editor_back",&EditorNode::_property_editor_back);
+ ObjectTypeDB::bind_method("_editor_select",&EditorNode::_editor_select);
+ ObjectTypeDB::bind_method("_node_renamed",&EditorNode::_node_renamed);
+ ObjectTypeDB::bind_method("edit_node",&EditorNode::edit_node);
+ ObjectTypeDB::bind_method("_imported",&EditorNode::_imported);
+ ObjectTypeDB::bind_method("_unhandled_input",&EditorNode::_unhandled_input);
+
+ ObjectTypeDB::bind_method("_get_scene_metadata",&EditorNode::_get_scene_metadata);
+ ObjectTypeDB::bind_method("set_edited_scene",&EditorNode::set_edited_scene);
+ ObjectTypeDB::bind_method("open_request",&EditorNode::open_request);
+ ObjectTypeDB::bind_method("_instance_request",&EditorNode::_instance_request);
+ ObjectTypeDB::bind_method("update_keying",&EditorNode::update_keying);
+ ObjectTypeDB::bind_method("_property_keyed",&EditorNode::_property_keyed);
+ ObjectTypeDB::bind_method("_transform_keyed",&EditorNode::_transform_keyed);
+ ObjectTypeDB::bind_method("_close_messages",&EditorNode::_close_messages);
+ ObjectTypeDB::bind_method("_show_messages",&EditorNode::_show_messages);
+ ObjectTypeDB::bind_method("_vp_resized",&EditorNode::_vp_resized);
+ ObjectTypeDB::bind_method("_quick_opened",&EditorNode::_quick_opened);
+ ObjectTypeDB::bind_method("_quick_run",&EditorNode::_quick_run);
+
+ ObjectTypeDB::bind_method("_resource_created",&EditorNode::_resource_created);
+
+ ObjectTypeDB::bind_method("_import_action",&EditorNode::_import_action);
+ //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("_save_optimized",&EditorNode::_save_optimized);
+
+ ObjectTypeDB::bind_method("stop_child_process",&EditorNode::stop_child_process);
+
+ ObjectTypeDB::bind_method("_sources_changed",&EditorNode::_sources_changed);
+ ObjectTypeDB::bind_method("_fs_changed",&EditorNode::_fs_changed);
+ ObjectTypeDB::bind_method("_dock_select_draw",&EditorNode::_dock_select_draw);
+ ObjectTypeDB::bind_method("_dock_select_input",&EditorNode::_dock_select_input);
+ ObjectTypeDB::bind_method("_dock_pre_popup",&EditorNode::_dock_pre_popup);
+ ObjectTypeDB::bind_method("_dock_split_dragged",&EditorNode::_dock_split_dragged);
+ ObjectTypeDB::bind_method("_save_docks",&EditorNode::_save_docks);
+ ObjectTypeDB::bind_method("_dock_popup_exit",&EditorNode::_dock_popup_exit);
+ ObjectTypeDB::bind_method("_dock_move_left",&EditorNode::_dock_move_left);
+ ObjectTypeDB::bind_method("_dock_move_right",&EditorNode::_dock_move_right);
+
+ ObjectTypeDB::bind_method("_layout_menu_option",&EditorNode::_layout_menu_option);
+
+ ObjectTypeDB::bind_method("set_current_scene",&EditorNode::set_current_scene);
+ ObjectTypeDB::bind_method("set_current_version",&EditorNode::set_current_version);
+ ObjectTypeDB::bind_method("_scene_tab_changed",&EditorNode::_scene_tab_changed);
+ ObjectTypeDB::bind_method("_scene_tab_closed",&EditorNode::_scene_tab_closed);
+ ObjectTypeDB::bind_method("_scene_tab_script_edited",&EditorNode::_scene_tab_script_edited);
+ ObjectTypeDB::bind_method("_set_main_scene_state",&EditorNode::_set_main_scene_state);
+ ObjectTypeDB::bind_method("_update_scene_tabs",&EditorNode::_update_scene_tabs);
+
+ ObjectTypeDB::bind_method("_prepare_history",&EditorNode::_prepare_history);
+ ObjectTypeDB::bind_method("_select_history",&EditorNode::_select_history);
+
+ ObjectTypeDB::bind_method("_toggle_search_bar",&EditorNode::_toggle_search_bar);
+ ObjectTypeDB::bind_method("_clear_search_box",&EditorNode::_clear_search_box);
+ ObjectTypeDB::bind_method("_clear_undo_history",&EditorNode::_clear_undo_history);
+
+ ObjectTypeDB::bind_method(_MD("add_editor_import_plugin", "plugin"), &EditorNode::add_editor_import_plugin);
+ ObjectTypeDB::bind_method(_MD("remove_editor_import_plugin", "plugin"), &EditorNode::remove_editor_import_plugin);
+ ObjectTypeDB::bind_method(_MD("get_gui_base"), &EditorNode::get_gui_base);
+ ObjectTypeDB::bind_method(_MD("_bottom_panel_switch"), &EditorNode::_bottom_panel_switch);
+
+
+ ADD_SIGNAL( MethodInfo("play_pressed") );
+ ADD_SIGNAL( MethodInfo("pause_pressed") );
+ ADD_SIGNAL( MethodInfo("stop_pressed") );
+ ADD_SIGNAL( MethodInfo("request_help") );
+ ADD_SIGNAL( MethodInfo("script_add_function_request",PropertyInfo(Variant::OBJECT,"obj"),PropertyInfo(Variant::STRING,"function"),PropertyInfo(Variant::STRING_ARRAY,"args")) );
+ ADD_SIGNAL( MethodInfo("resource_saved",PropertyInfo(Variant::OBJECT,"obj")) );
+
+
+
+}
+
EditorNode::EditorNode() {
EditorHelp::generate_doc(); //before any editor classes are crated
@@ -4589,6 +4768,8 @@ EditorNode::EditorNode() {
ResourceLoader::set_abort_on_missing_resources(false);
FileDialog::set_default_show_hidden_files(EditorSettings::get_singleton()->get("file_dialog/show_hidden_files"));
+ EditorFileDialog::set_default_show_hidden_files(EditorSettings::get_singleton()->get("file_dialog/show_hidden_files"));
+ EditorFileDialog::set_default_display_mode((EditorFileDialog::DisplayMode)EditorSettings::get_singleton()->get("file_dialog/display_mode").operator int());
ResourceLoader::set_error_notify_func(this,_load_error_notify);
ResourceLoader::set_dependency_error_notify_func(this,_dependency_error_report);
@@ -4842,7 +5023,7 @@ EditorNode::EditorNode() {
scene_tabs=memnew( Tabs );
scene_tabs->add_tab("unsaved");
scene_tabs->set_tab_align(Tabs::ALIGN_CENTER);
- scene_tabs->set_tab_close_display_policy(Tabs::SHOW_ACTIVE_ONLY);
+ scene_tabs->set_tab_close_display_policy(Tabs::CLOSE_BUTTON_SHOW_ACTIVE_ONLY);
scene_tabs->connect("tab_changed",this,"_scene_tab_changed");
scene_tabs->connect("right_button_pressed",this,"_scene_tab_script_edited");
scene_tabs->connect("tab_close", this, "_scene_tab_closed");
@@ -4872,8 +5053,9 @@ EditorNode::EditorNode() {
//scene_root_base->add_child(scene_root);
- scene_root->set_meta("_editor_disable_input",true);
+ //scene_root->set_meta("_editor_disable_input",true);
VisualServer::get_singleton()->viewport_set_hide_scenario(scene_root->get_viewport(),true);
+ scene_root->set_disable_input(true);
scene_root->set_as_audio_listener_2d(true);
scene_root->set_size_override(true,Size2(Globals::get_singleton()->get("display/width"),Globals::get_singleton()->get("display/height")));
@@ -4888,44 +5070,6 @@ EditorNode::EditorNode() {
scene_root_parent->add_child(viewport);
- PanelContainer *pc = memnew( PanelContainer );
- top_split->add_child(pc);
- animation_vb = memnew( VBoxContainer );
- animation_vb->set_v_size_flags(Control::SIZE_EXPAND_FILL);
- pc->add_child(animation_vb);
- animation_panel=pc;
- animation_panel->hide();
-
-
- HBoxContainer *animation_hb = memnew( HBoxContainer);
- animation_vb->add_child(animation_hb);
-
- Label *l= memnew( Label );
- l->set_text("Animation:");
- //l->set_h_size_flags(Control::SIZE_);
- animation_hb->add_child(l);
-
- animation_panel_hb = memnew( HBoxContainer );
- animation_hb->add_child(animation_panel_hb);
- animation_panel_hb->set_h_size_flags(Control::SIZE_EXPAND_FILL);
-
-
- /*pd_anim = memnew( PaneDrag );
- animation_hb->add_child(pd_anim);
- pd_anim->connect("dragged",this,"_dragged");
- pd_anim->set_default_cursor_shape(Control::CURSOR_MOVE);
- pd_anim->hide();*/
-
- anim_close = memnew( TextureButton );
- animation_hb->add_child(anim_close);
- anim_close->connect("pressed",this,"animation_panel_make_visible",make_binds(false));
- anim_close->set_normal_texture( anim_close->get_icon("Close","EditorIcons"));
- anim_close->set_hover_texture( anim_close->get_icon("CloseHover","EditorIcons"));
- anim_close->set_pressed_texture( anim_close->get_icon("Close","EditorIcons"));
-
-
-
-
PanelContainer *top_region = memnew( PanelContainer );
top_region->add_style_override("panel",gui_base->get_stylebox("hover","Button"));
HBoxContainer *left_menu_hb = memnew( HBoxContainer );
@@ -4977,7 +5121,6 @@ EditorNode::EditorNode() {
pm_export->set_name("Export");
p->add_child(pm_export);
p->add_submenu_item("Convert To..","Export");
- pm_export->add_item("Subscene..",FILE_SAVE_SUBSCENE);
pm_export->add_item("Translatable Strings..",FILE_DUMP_STRINGS);
pm_export->add_separator();
pm_export->add_item("MeshLibrary..",FILE_EXPORT_MESH_LIBRARY);
@@ -4994,7 +5137,11 @@ EditorNode::EditorNode() {
p->add_separator();
p->add_item("Revert Scene",EDIT_REVERT);
p->add_separator();
- p->add_item("Quit to Project List",RUN_PROJECT_MANAGER,KEY_MASK_SHIFT+KEY_MASK_CMD+KEY_Q);
+#ifdef OSX_ENABLED
+ p->add_item("Quit to Project List",RUN_PROJECT_MANAGER,KEY_MASK_SHIFT+KEY_MASK_ALT+KEY_Q);
+#else
+ p->add_item("Quit to Project List",RUN_PROJECT_MANAGER,KEY_MASK_SHIFT+KEY_MASK_CTRL+KEY_Q);
+#endif
p->add_item("Quit",FILE_QUIT,KEY_MASK_CMD+KEY_Q);
recent_scenes = memnew( PopupMenu );
@@ -5231,17 +5378,25 @@ EditorNode::EditorNode() {
right_menu_hb->add_child( settings_menu );
p=settings_menu->get_popup();
-
//p->add_item("Export Settings",SETTINGS_EXPORT_PREFERENCES);
p->add_item("Editor Settings",SETTINGS_PREFERENCES);
//p->add_item("Optimization Presets",SETTINGS_OPTIMIZED_PRESETS);
p->add_separator();
- p->add_check_item("Show Animation",SETTINGS_SHOW_ANIMATION,KEY_MASK_CMD+KEY_N);
+ editor_layouts = memnew( PopupMenu );
+ editor_layouts->set_name("Layouts");
+ p->add_child(editor_layouts);
+ editor_layouts->connect("item_pressed",this,"_layout_menu_option");
+ p->add_submenu_item("Editor Layout", "Layouts");
p->add_separator();
p->add_item("Install Export Templates",SETTINGS_LOAD_EXPORT_TEMPLATES);
p->add_separator();
p->add_item("About",SETTINGS_ABOUT);
+ layout_dialog = memnew( EditorNameDialog );
+ gui_base->add_child(layout_dialog);
+ layout_dialog->set_hide_on_ok(false);
+ layout_dialog->set_size(Size2(175, 70));
+ layout_dialog->connect("name_confirmed", this,"_dialog_action");
sources_button = memnew( ToolButton );
right_menu_hb->add_child(sources_button);
@@ -5396,7 +5551,7 @@ EditorNode::EditorNode() {
prop_editor_base->add_child(search_bar);
search_bar->hide();
- l = memnew( Label("Search: ") );
+ Label *l = memnew( Label("Search: ") );
search_bar->add_child(l);
search_box = memnew( LineEdit );
@@ -5423,44 +5578,61 @@ EditorNode::EditorNode() {
scenes_dock = memnew( ScenesDock(this) );
scenes_dock->set_name("FileSystem");
+ scenes_dock->set_use_thumbnails(int(EditorSettings::get_singleton()->get("file_dialog/display_mode"))==EditorFileDialog::DISPLAY_THUMBNAILS);
dock_slot[DOCK_SLOT_LEFT_BR]->add_child(scenes_dock);
//prop_pallete->add_child(scenes_dock);
scenes_dock->connect("open",this,"open_request");
scenes_dock->connect("instance",this,"_instance_request");
+ const String docks_section = "docks";
+ overridden_default_layout=-1;
+ default_layout.instance();
+ default_layout->set_value(docks_section, "dock_3", "Scene");
+ default_layout->set_value(docks_section, "dock_4", "FileSystem");
+ default_layout->set_value(docks_section, "dock_5", "Inspector");
- log = memnew( EditorLog );
- center_split->add_child(log);
- log->connect("close_request",this,"_close_messages");
- log->connect("show_request",this,"_show_messages");
- //left_split->set_dragger_visible(false);
+ for(int i=0;i<DOCK_SLOT_MAX/2;i++)
+ default_layout->set_value(docks_section, "dock_hsplit_"+itos(i+1), 0);
+ for(int i=0;i<DOCK_SLOT_MAX/2;i++)
+ default_layout->set_value(docks_section, "dock_split_"+itos(i+1), 0);
+ _update_layouts_menu();
- old_split_ofs=0;
+ bottom_panel = memnew( PanelContainer );
+ bottom_panel->add_style_override("panel",gui_base->get_stylebox("panelf","Panel"));
+ center_split->add_child(bottom_panel);
+ center_split->set_dragger_visibility(SplitContainer::DRAGGER_HIDDEN);
+ bottom_panel_vb = memnew( VBoxContainer );
+ bottom_panel->add_child(bottom_panel_vb);
+ //bottom_panel_vb->set_v_size_flags(Control::SIZE_EXPAND_FILL);
- animation_editor = memnew( AnimationKeyEditor(get_undo_redo(),&editor_history,editor_selection) );
- animation_editor->set_anchor_and_margin(MARGIN_RIGHT,Control::ANCHOR_END,0);
- animation_editor->set_margin(MARGIN_BOTTOM,200);
- animation_editor->connect("keying_changed",this,"_update_keying");
+ bottom_panel_hb = memnew( HBoxContainer );
+ bottom_panel_vb->add_child(bottom_panel_hb);
- animation_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL);
- animation_vb->add_child(animation_editor);
- center_split->connect("resized",this,"_vp_resized");
+ log = memnew( EditorLog );
+
+ add_bottom_panel_item("Output",log);
+
+ //left_split->set_dragger_visible(false);
- animation_editor->hide();
+ old_split_ofs=0;
+
+ center_split->connect("resized",this,"_vp_resized");
+
/*PanelContainer *bottom_pc = memnew( PanelContainer );
srt->add_child(bottom_pc);
bottom_hb = memnew( HBoxContainer );
bottom_pc->add_child(bottom_hb);*/
- center_vb->add_child( log->get_button() );
- log->get_button()->set_h_size_flags(Control::SIZE_EXPAND_FILL);
+
+// center_vb->add_child( log->get_button() );
+// log->get_button()->set_h_size_flags(Control::SIZE_EXPAND_FILL);
//progress_hb->set_h_size_flags(Control::SIZE_EXPAND_FILL);
@@ -5569,7 +5741,7 @@ EditorNode::EditorNode() {
about->get_ok()->set_text("Thanks!");
about->set_hide_on_ok(true);
Label *about_text = memnew( Label );
- about_text->set_text(VERSION_FULL_NAME"\n(c) 2008-2015 Juan Linietsky, Ariel Manzur.\n");
+ about_text->set_text(VERSION_FULL_NAME"\n(c) 2008-2016 Juan Linietsky, Ariel Manzur.\n");
about_text->set_pos(Point2(gui_base->get_icon("Logo","EditorIcons")->get_size().width+30,20));
gui_base->add_child(about);
about->add_child(about_text);
@@ -5660,7 +5832,7 @@ EditorNode::EditorNode() {
file_templates->connect("file_selected", this,"_dialog_action");
property_editor->connect("resource_selected", this,"_resource_selected");
property_editor->connect("property_keyed", this,"_property_keyed");
- animation_editor->connect("resource_selected", this,"_resource_selected");
+
//plugin stuff
file_server = memnew( EditorFileServer );
@@ -5684,11 +5856,17 @@ EditorNode::EditorNode() {
editor_import_export->add_export_plugin( Ref<EditorTextureExportPlugin>( memnew(EditorTextureExportPlugin)));
editor_import_export->add_export_plugin( Ref<EditorSampleExportPlugin>( memnew(EditorSampleExportPlugin)));
+ editor_import_export->add_export_plugin( Ref<EditorSceneExportPlugin>( memnew(EditorSceneExportPlugin)));
+
+ add_editor_plugin( memnew( AnimationPlayerEditorPlugin(this) ) );
add_editor_plugin( memnew( CanvasItemEditorPlugin(this) ) );
add_editor_plugin( memnew( SpatialEditorPlugin(this) ) );
add_editor_plugin( memnew( ScriptEditorPlugin(this) ) );
- add_editor_plugin( memnew( AnimationPlayerEditorPlugin(this) ) );
+
+ //more visually meaningful to have this later
+ raise_bottom_panel_item(AnimationPlayerEditor::singleton);
+
add_editor_plugin( memnew( ShaderGraphEditorPlugin(this,true) ) );
add_editor_plugin( memnew( ShaderGraphEditorPlugin(this,false) ) );
add_editor_plugin( memnew( ShaderEditorPlugin(this,true) ) );
@@ -5721,7 +5899,8 @@ EditorNode::EditorNode() {
add_editor_plugin( memnew( Polygon2DEditorPlugin(this) ) );
add_editor_plugin( memnew( LightOccluder2DEditorPlugin(this) ) );
add_editor_plugin( memnew( NavigationPolygonEditorPlugin(this) ) );
- add_editor_plugin( memnew( ColorRampEditorPlugin(this) ) );
+ add_editor_plugin( memnew( ColorRampEditorPlugin(this,true) ) );
+ add_editor_plugin( memnew( ColorRampEditorPlugin(this,false) ) );
add_editor_plugin( memnew( CollisionShape2DEditorPlugin(this) ) );
for(int i=0;i<EditorPlugins::get_plugin_count();i++)
@@ -5734,9 +5913,10 @@ EditorNode::EditorNode() {
resource_preview->add_preview_generator( Ref<EditorScriptPreviewPlugin>( memnew(EditorScriptPreviewPlugin )));
resource_preview->add_preview_generator( Ref<EditorSamplePreviewPlugin>( memnew(EditorSamplePreviewPlugin )));
resource_preview->add_preview_generator( Ref<EditorMeshPreviewPlugin>( memnew(EditorMeshPreviewPlugin )));
+ resource_preview->add_preview_generator( Ref<EditorBitmapPreviewPlugin>( memnew(EditorBitmapPreviewPlugin )));
circle_step_msec=OS::get_singleton()->get_ticks_msec();
- circle_step_frame=OS::get_singleton()->get_frames_drawn();;
+ circle_step_frame=OS::get_singleton()->get_frames_drawn();
circle_step=0;
_rebuild_import_menu();
diff --git a/tools/editor/editor_node.h b/tools/editor/editor_node.h
index 5cc9d9eaa2..4dc942c023 100644
--- a/tools/editor/editor_node.h
+++ b/tools/editor/editor_node.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -56,7 +56,7 @@
#include "tools/editor/editor_run.h"
#include "tools/editor/pane_drag.h"
-#include "tools/editor/animation_editor.h"
+
#include "tools/editor/script_create_dialog.h"
#include "tools/editor/run_settings_dialog.h"
#include "tools/editor/project_settings.h"
@@ -76,6 +76,7 @@
#include "editor_reimport_dialog.h"
#include "import_settings.h"
#include "tools/editor/editor_plugin.h"
+#include "tools/editor/editor_name_dialog.h"
#include "fileserver/editor_file_server.h"
#include "editor_resource_preview.h"
@@ -99,13 +100,12 @@ typedef void (*EditorNodeInitCallback)();
class EditorNode : public Node {
OBJ_TYPE( EditorNode, Node );
-
+
enum {
-
- HISTORY_SIZE=64
+ HISTORY_SIZE=64
};
+
enum MenuOptions {
-
FILE_NEW_SCENE,
FILE_NEW_INHERITED_SCENE,
FILE_OPEN_SCENE,
@@ -118,7 +118,6 @@ class EditorNode : public Node {
FILE_EXPORT_MESH_LIBRARY,
FILE_EXPORT_TILESET,
FILE_SAVE_OPTIMIZED,
- FILE_SAVE_SUBSCENE,
FILE_DUMP_STRINGS,
FILE_OPEN_RECENT,
FILE_OPEN_OLD_SCENE,
@@ -167,7 +166,9 @@ class EditorNode : public Node {
SETTINGS_EXPORT_PREFERENCES,
SETTINGS_PREFERENCES,
SETTINGS_OPTIMIZED_PRESETS,
- SETTINGS_SHOW_ANIMATION,
+ SETTINGS_LAYOUT_SAVE,
+ SETTINGS_LAYOUT_DELETE,
+ SETTINGS_LAYOUT_DEFAULT,
SETTINGS_LOAD_EXPORT_TEMPLATES,
SETTINGS_HELP,
SETTINGS_ABOUT,
@@ -228,7 +229,6 @@ class EditorNode : public Node {
Control *vp_base;
PaneDrag *pd;
//PaneDrag *pd_anim;
- TextureButton *anim_close;
Panel *menu_panel;
@@ -248,7 +248,6 @@ class EditorNode : public Node {
ToolButton *pause_button;
ToolButton *stop_button;
ToolButton *run_settings_button;
- ToolButton *animation_menu;
ToolButton *play_scene_button;
ToolButton *play_custom_scene_button;
MenuButton *debug_button;
@@ -284,6 +283,11 @@ class EditorNode : public Node {
AcceptDialog *about;
AcceptDialog *warning;
+ int overridden_default_layout;
+ Ref<ConfigFile> default_layout;
+ PopupMenu *editor_layouts;
+ EditorNameDialog *layout_dialog;
+
//OptimizedPresetsDialog *optimized_presets;
EditorSettingsDialog *settings_config_dialog;
RunSettingsDialog *run_settings_dialog;
@@ -309,15 +313,12 @@ class EditorNode : public Node {
String defer_export_platform;
bool defer_export_debug;
Node *_last_instanced_scene;
- PanelContainer *animation_panel;
- HBoxContainer *animation_panel_hb;
- VBoxContainer *animation_vb;
EditorPath *editor_path;
ToolButton *resource_new_button;
ToolButton *resource_load_button;
MenuButton *resource_save_button;
MenuButton *editor_history_menu;
- AnimationKeyEditor *animation_editor;
+
EditorLog *log;
CenterContainer *tabs_center;
EditorQuickOpen *quick_open;
@@ -380,6 +381,21 @@ class EditorNode : public Node {
EditorFileServer *file_server;
+
+ struct BottomPanelItem {
+ String name;
+ Control *control;
+ ToolButton *button;
+ };
+
+ Vector<BottomPanelItem> bottom_panel_items;
+
+ PanelContainer *bottom_panel;
+ HBoxContainer *bottom_panel_hb;
+ VBoxContainer *bottom_panel_vb;
+
+ void _bottom_panel_switch(bool p_enable, int p_idx);
+
String external_file;
List<String> previous_scenes;
bool opening_prev;
@@ -411,8 +427,8 @@ class EditorNode : public Node {
void _node_renamed();
void _editor_select(int p_which);
- void _set_scene_metadata();
- void _get_scene_metadata();
+ void _set_scene_metadata(const String &p_file);
+ void _get_scene_metadata(const String& p_file);
void _update_title();
void _update_scene_tabs();
void _close_messages();
@@ -429,9 +445,8 @@ class EditorNode : public Node {
void _property_keyed(const String& p_keyed, const Variant& p_value, bool p_advance);
void _transform_keyed(Object *sp,const String& p_sub,const Transform& p_key);
- void _update_keying();
void _hide_top_editors();
- void _quick_opened(const String& p_resource);
+ void _quick_opened();
void _quick_run(const String& p_resource);
void _run(bool p_current=false, const String &p_custom="");
@@ -523,13 +538,19 @@ class EditorNode : public Node {
void _save_docks();
void _load_docks();
+ void _save_docks_to_config(Ref<ConfigFile> p_layout, const String& p_section);
+ void _load_docks_from_config(Ref<ConfigFile> p_layout, const String& p_section);
+
+ void _update_layouts_menu();
+ void _layout_menu_option(int p_idx);
void _toggle_search_bar(bool p_pressed);
void _clear_search_box();
+ void _clear_undo_history();
protected:
void _notification(int p_what);
- static void _bind_methods();
+ static void _bind_methods();
public:
enum EditorTable {
@@ -573,13 +594,10 @@ public:
static EditorLog *get_log() { return singleton->log; }
Control* get_viewport();
- AnimationKeyEditor *get_animation_editor() const { return animation_editor; }
- Control *get_animation_panel() { return animation_vb; }
- HBoxContainer *get_animation_panel_hb() { return animation_panel_hb; }
- void animation_editor_make_visible(bool p_visible);
- void hide_animation_player_editors();
- void animation_panel_make_visible(bool p_visible);
+ //void animation_editor_make_visible(bool p_visible);
+ //void hide_animation_player_editors();
+ //void animation_panel_make_visible(bool p_visible);
void set_edited_scene(Node *p_scene);
@@ -599,6 +617,7 @@ public:
void set_current_scene(int p_idx);
static EditorData& get_editor_data() { return singleton->editor_data; }
+ EditorHistory * get_editor_history() { return &editor_history; }
static VSplitContainer *get_top_split() { return singleton->top_split; }
@@ -632,7 +651,7 @@ public:
static void add_io_error(const String& p_error);
static void progress_add_task(const String& p_task,const String& p_label, int p_steps);
- static void progress_task_step(const String& p_task,const String& p_state, int p_step=-1);
+ static void progress_task_step(const String& p_task,const String& p_state, int p_step=-1,bool p_force_refresh=true);
static void progress_end_task(const String& p_task);
static void progress_add_task_bg(const String& p_task,const String& p_label, int p_steps);
@@ -647,6 +666,14 @@ public:
void save_layout();
+ void update_keying();
+
+
+ ToolButton* add_bottom_panel_item(String p_text,Control *p_item);
+ void make_bottom_panel_item_visible(Control *p_item);
+ void raise_bottom_panel_item(Control *p_item);
+ void hide_bottom_panel();
+
EditorNode();
~EditorNode();
void get_singleton(const char* arg1, bool arg2);
@@ -659,7 +686,7 @@ public:
struct EditorProgress {
String task;
- void step(const String& p_state, int p_step=-1) { EditorNode::progress_task_step(task,p_state,p_step); }
+ void step(const String& p_state, int p_step=-1,bool p_force_refresh=true) { EditorNode::progress_task_step(task,p_state,p_step,p_force_refresh); }
EditorProgress(const String& p_task,const String& p_label,int p_amount) { EditorNode::progress_add_task(p_task,p_label,p_amount); task=p_task; }
~EditorProgress() { EditorNode::progress_end_task(task); }
};
diff --git a/tools/editor/editor_path.cpp b/tools/editor/editor_path.cpp
index 94e2efe346..4cf98e832c 100644
--- a/tools/editor/editor_path.cpp
+++ b/tools/editor/editor_path.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/editor_path.h b/tools/editor/editor_path.h
index 2edaeb92a3..11e1005ba3 100644
--- a/tools/editor/editor_path.h
+++ b/tools/editor/editor_path.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/editor_plugin.cpp b/tools/editor/editor_plugin.cpp
index 7417d707bb..b7ccb452e9 100644
--- a/tools/editor/editor_plugin.cpp
+++ b/tools/editor/editor_plugin.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/editor_plugin.h b/tools/editor/editor_plugin.h
index 0f3a1e2e3c..bf1e185a37 100644
--- a/tools/editor/editor_plugin.h
+++ b/tools/editor/editor_plugin.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -92,6 +92,7 @@ public:
virtual bool get_remove_list(List<Node*> *p_list);
virtual void set_window_layout(Ref<ConfigFile> p_layout);
virtual void get_window_layout(Ref<ConfigFile> p_layout);
+ virtual void edited_scene_changed(){}; // if changes are pending in editor, apply them
virtual void restore_global_state();
virtual void save_global_state();
diff --git a/tools/editor/editor_reimport_dialog.cpp b/tools/editor/editor_reimport_dialog.cpp
index 8842a485b3..eab5a5e32d 100644
--- a/tools/editor/editor_reimport_dialog.cpp
+++ b/tools/editor/editor_reimport_dialog.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/editor_reimport_dialog.h b/tools/editor/editor_reimport_dialog.h
index 9726bac805..0c2d0eb52c 100644
--- a/tools/editor/editor_reimport_dialog.h
+++ b/tools/editor/editor_reimport_dialog.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/editor_run.cpp b/tools/editor/editor_run.cpp
index b635cea84b..fb0f24c084 100644
--- a/tools/editor/editor_run.cpp
+++ b/tools/editor/editor_run.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/editor_run.h b/tools/editor/editor_run.h
index e1b0b081c7..0b96a2c91c 100644
--- a/tools/editor/editor_run.h
+++ b/tools/editor/editor_run.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/editor_run_native.cpp b/tools/editor/editor_run_native.cpp
index 2eedba93dc..234dd03087 100644
--- a/tools/editor/editor_run_native.cpp
+++ b/tools/editor/editor_run_native.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/editor_run_native.h b/tools/editor/editor_run_native.h
index 77d6dc198e..04dad6b6aa 100644
--- a/tools/editor/editor_run_native.h
+++ b/tools/editor/editor_run_native.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/editor_selection.cpp b/tools/editor/editor_selection.cpp
index d8fd8735fc..f3fbdba907 100644
--- a/tools/editor/editor_selection.cpp
+++ b/tools/editor/editor_selection.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/editor_selection.h b/tools/editor/editor_selection.h
index f10f313a4e..d238d86567 100644
--- a/tools/editor/editor_selection.h
+++ b/tools/editor/editor_selection.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/editor_settings.cpp b/tools/editor/editor_settings.cpp
index 15de6e7266..4195ba97e6 100644
--- a/tools/editor/editor_settings.cpp
+++ b/tools/editor/editor_settings.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -515,6 +515,8 @@ void EditorSettings::_load_defaults() {
set("text_editor/create_signal_callbacks",true);
set("file_dialog/show_hidden_files", false);
+ set("file_dialog/display_mode", 0);
+ hints["file_dialog/display_mode"]=PropertyInfo(Variant::INT,"file_dialog/display_mode",PROPERTY_HINT_ENUM,"Thumbnails,List");
set("file_dialog/thumbnail_size", 64);
hints["file_dialog/thumbnail_size"]=PropertyInfo(Variant::INT,"file_dialog/thumbnail_size",PROPERTY_HINT_RANGE,"32,128,16");
diff --git a/tools/editor/editor_settings.h b/tools/editor/editor_settings.h
index 4ba940cd1c..d1a11360af 100644
--- a/tools/editor/editor_settings.h
+++ b/tools/editor/editor_settings.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -107,6 +107,7 @@ public:
static EditorSettings *get_singleton();
void erase(String p_var);
String get_settings_path() const;
+ String get_global_settings_path() const;
String get_project_settings_path() const;
const Map<String,Plugin>& get_plugins() const { return plugins; }
diff --git a/tools/editor/editor_sub_scene.cpp b/tools/editor/editor_sub_scene.cpp
index 2a6eba2554..e58e2c1351 100644
--- a/tools/editor/editor_sub_scene.cpp
+++ b/tools/editor/editor_sub_scene.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -196,7 +196,11 @@ void EditorSubScene::_bind_methods() {
EditorSubScene::EditorSubScene() {
+ scene=NULL;
+
set_title("Select Sub-Scene..");
+ set_hide_on_ok(false);
+
VBoxContainer *vb = memnew( VBoxContainer );
add_child(vb);
set_child_rect(vb);
@@ -211,9 +215,11 @@ EditorSubScene::EditorSubScene() {
hb->add_child(b);
b->connect("pressed",this,"_path_browse");
vb->add_margin_child("Scene Path:",hb);
+
tree = memnew( Tree );
tree->set_v_size_flags(SIZE_EXPAND_FILL);
- vb->add_margin_child("Import From Node:",tree)->set_v_size_flags(SIZE_EXPAND_FILL);
+ vb->add_margin_child("Import From Node:",tree,true);
+ tree->connect("item_activated",this,"_ok");
file_dialog = memnew( EditorFileDialog );
List<String> extensions;
@@ -228,8 +234,4 @@ EditorSubScene::EditorSubScene() {
add_child(file_dialog);
file_dialog->connect("file_selected",this,"_path_selected");
- scene=NULL;
-
- set_hide_on_ok(false);
-
}
diff --git a/tools/editor/editor_sub_scene.h b/tools/editor/editor_sub_scene.h
index dfd6c531e2..3dd86eefda 100644
--- a/tools/editor/editor_sub_scene.h
+++ b/tools/editor/editor_sub_scene.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/editor_vu.cpp b/tools/editor/editor_vu.cpp
index ac11aceb21..7a133c9736 100644
--- a/tools/editor/editor_vu.cpp
+++ b/tools/editor/editor_vu.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/editor_vu.h b/tools/editor/editor_vu.h
index 4c51ac31c0..78fe3eda86 100644
--- a/tools/editor/editor_vu.h
+++ b/tools/editor/editor_vu.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/file_type_cache.cpp b/tools/editor/file_type_cache.cpp
index a86400a560..7044a9900c 100644
--- a/tools/editor/file_type_cache.cpp
+++ b/tools/editor/file_type_cache.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/file_type_cache.h b/tools/editor/file_type_cache.h
index efc6d22b25..18451cbe19 100644
--- a/tools/editor/file_type_cache.h
+++ b/tools/editor/file_type_cache.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/groups_editor.cpp b/tools/editor/groups_editor.cpp
index 2e82854014..6840a8b205 100644
--- a/tools/editor/groups_editor.cpp
+++ b/tools/editor/groups_editor.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -27,151 +27,130 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "groups_editor.h"
-#include "scene/gui/box_container.h"
+#include "scene/gui/box_container.h"
#include "scene/gui/label.h"
+void GroupsEditor::_add_group(const String& p_group) {
-#include "print_string.h"
+ if (!node)
+ return;
-void GroupsEditor::_notification(int p_what) {
-
- if (p_what==NOTIFICATION_ENTER_TREE) {
- connect("confirmed", this,"_close");
- }
- if (p_what==NOTIFICATION_EXIT_TREE) {
- disconnect("confirmed", this,"_close");
- }
-}
+ String name = group_name->get_text();
+ if (name.strip_edges()=="")
+ return;
-void GroupsEditor::_close() {
-
- hide();
-
-}
-void GroupsEditor::_add() {
-
- if (!node)
+ if (node->is_in_group(name))
return;
-
- undo_redo->create_action("Add To Group");
- undo_redo->add_do_method(node,"add_to_group",group_name->get_text(),true);
- undo_redo->add_undo_method(node,"remove_from_group",group_name->get_text());
+ undo_redo->create_action("Add to Group");
+
+ undo_redo->add_do_method(node,"add_to_group",name,true);
undo_redo->add_do_method(this,"update_tree");
+ undo_redo->add_undo_method(node,"remove_from_group",name,get_text());
undo_redo->add_undo_method(this,"update_tree");
undo_redo->commit_action();
}
+void GroupsEditor::_remove_group(Object *p_item, int p_column, int p_id) {
-void GroupsEditor::_remove() {
-
- if (!tree->get_selected())
- return;
if (!node)
return;
- TreeItem *sel = tree->get_selected();
- if (!sel)
+ TreeItem *ti = p_item->cast_to<TreeItem>();
+ if (!ti)
return;
-
- node->remove_from_group( sel->get_text(0) );
- update_tree();
+
+ String name = ti->get_text(0);
+
+ undo_redo->create_action("Remove from Group");
+
+ undo_redo->add_do_method(node,"remove_from_group",name);
+ undo_redo->add_do_method(this,"update_tree");
+ undo_redo->add_undo_method(node,"add_to_group",name,true);
+ undo_redo->add_undo_method(this,"update_tree");
+
+ undo_redo->commit_action();
}
+struct _GroupInfoComparator {
+
+ bool operator()(const Node::GroupInfo& p_a, const Node::GroupInfo& p_b) const {
+ return p_a.name.operator String() < p_b.name.operator String();
+ }
+};
+
void GroupsEditor::update_tree() {
-
tree->clear();
-
+
if (!node)
return;
-
- List<GroupInfo> groups;
+
+ List<Node::GroupInfo> groups;
node->get_groups(&groups);
-
+ groups.sort_custom<_GroupInfoComparator>();
+
TreeItem *root=tree->create_item();
-
+
for(List<GroupInfo>::Element *E=groups.front();E;E=E->next()) {
-
- if (!E->get().persistent)
+
+ Node::GroupInfo gi = E->get();
+ if (!gi.persistent)
continue;
+
TreeItem *item=tree->create_item(root);
- item->set_text(0, E->get().name);
-
+ item->set_text(0, gi.name);
+ item->add_button(0, get_icon("Remove", "EditorIcons"), 0);
}
-
}
void GroupsEditor::set_current(Node* p_node) {
-
+
node=p_node;
update_tree();
-
}
void GroupsEditor::_bind_methods() {
-
- ObjectTypeDB::bind_method("_add",&GroupsEditor::_add);
- ObjectTypeDB::bind_method("_close",&GroupsEditor::_close);
- ObjectTypeDB::bind_method("_remove",&GroupsEditor::_remove);
+
+ ObjectTypeDB::bind_method("_add_group",&GroupsEditor::_add_group);
+ ObjectTypeDB::bind_method("_remove_group",&GroupsEditor::_remove_group);
ObjectTypeDB::bind_method("update_tree",&GroupsEditor::update_tree);
}
GroupsEditor::GroupsEditor() {
+ node=NULL;
+
set_title("Group Editor");
-
- Label * label = memnew( Label );
- label->set_pos( Point2( 8,11) );
- label->set_text("Groups:");
-
- add_child(label);
-
- group_name = memnew(LineEdit);
- group_name->set_anchor( MARGIN_RIGHT, ANCHOR_END );
- group_name->set_begin( Point2( 15,28) );
- group_name->set_end( Point2( 94,48 ) );
-
- add_child(group_name);
-
- tree = memnew( Tree );
- tree->set_anchor( MARGIN_RIGHT, ANCHOR_END );
- tree->set_anchor( MARGIN_BOTTOM, ANCHOR_END );
- tree->set_begin( Point2( 15,52) );
- tree->set_end( Point2( 94,42 ) );
- tree->set_hide_root(true);
- add_child(tree);
-
+
+ VBoxContainer *vbc = memnew( VBoxContainer );
+ add_child(vbc);
+ set_child_rect(vbc);
+
+ HBoxContainer *hbc = memnew( HBoxContainer );
+ vbc->add_margin_child("Group", hbc);
+
+ group_name = memnew( LineEdit );
+ group_name->set_h_size_flags(SIZE_EXPAND_FILL);
+ hbc->add_child(group_name);
+ group_name->connect("text_entered",this,"_add_group");
+
add = memnew( Button );
- add->set_anchor( MARGIN_LEFT, ANCHOR_END );
- add->set_anchor( MARGIN_RIGHT, ANCHOR_END );
- add->set_begin( Point2( 90, 28 ) );
- add->set_end( Point2( 15, 48 ) );
add->set_text("Add");
-
- add_child(add);
-
- remove = memnew( Button );
- remove->set_anchor( MARGIN_LEFT, ANCHOR_END );
- remove->set_anchor( MARGIN_RIGHT, ANCHOR_END );
- remove->set_begin( Point2( 90, 52 ) );
- remove->set_end( Point2( 15, 72 ) );
- remove->set_text("Remove");
-
- add_child(remove);
+ hbc->add_child(add);
+ add->connect("pressed", this,"_add_group", varray(String()));
- get_ok()->set_text("Close");
-
- add->connect("pressed", this,"_add");
- remove->connect("pressed", this,"_remove");
+ tree = memnew( Tree );
+ tree->set_hide_root(true);
+ tree->set_v_size_flags(SIZE_EXPAND_FILL);
+ vbc->add_margin_child("Node Group(s)", tree, true);
+ tree->connect("button_pressed",this,"_remove_group");
-
- node=NULL;
+ get_ok()->set_text("Close");
}
-
GroupsEditor::~GroupsEditor()
{
}
diff --git a/tools/editor/groups_editor.h b/tools/editor/groups_editor.h
index 09883a150f..b5bccb2766 100644
--- a/tools/editor/groups_editor.h
+++ b/tools/editor/groups_editor.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -29,42 +29,42 @@
#ifndef GROUPS_EDITOR_H
#define GROUPS_EDITOR_H
-
#include "scene/gui/dialogs.h"
#include "scene/gui/button.h"
#include "scene/gui/tree.h"
#include "scene/gui/line_edit.h"
#include "undo_redo.h"
+
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
-class GroupsEditor : public ConfirmationDialog {
-
- OBJ_TYPE( GroupsEditor, ConfirmationDialog );
-
+
+class GroupsEditor : public AcceptDialog {
+
+ OBJ_TYPE(GroupsEditor,AcceptDialog);
+
+ Node *node;
+
LineEdit *group_name;
- Tree *tree;
Button *add;
- Button *remove;
- Node *node;
+ Tree *tree;
+
UndoRedo *undo_redo;
-
+
void update_tree();
- void _add();
- void _remove();
+ void _add_group(const String& p_group="");
+ void _remove_group(Object *p_item, int p_column, int p_id);
void _close();
-
protected:
-
- void _notification(int p_what);
- static void _bind_methods();
+
+ static void _bind_methods();
public:
-
+
void set_undo_redo(UndoRedo *p_undoredo) { undo_redo=p_undoredo; }
void set_current(Node* p_node);
-
+
GroupsEditor();
~GroupsEditor();
-
};
+
#endif
diff --git a/tools/editor/icons/icon_add_track.png b/tools/editor/icons/icon_add_track.png
index 3862597828..6a90950173 100644
--- a/tools/editor/icons/icon_add_track.png
+++ b/tools/editor/icons/icon_add_track.png
Binary files differ
diff --git a/tools/editor/icons/icon_console.png b/tools/editor/icons/icon_console.png
new file mode 100644
index 0000000000..7dc7407ef7
--- /dev/null
+++ b/tools/editor/icons/icon_console.png
Binary files differ
diff --git a/tools/editor/icons/icon_create_new_scene_from.png b/tools/editor/icons/icon_create_new_scene_from.png
new file mode 100644
index 0000000000..e747c4f59f
--- /dev/null
+++ b/tools/editor/icons/icon_create_new_scene_from.png
Binary files differ
diff --git a/tools/editor/icons/icon_edit_pivot.png b/tools/editor/icons/icon_edit_pivot.png
new file mode 100644
index 0000000000..d68f7bbf25
--- /dev/null
+++ b/tools/editor/icons/icon_edit_pivot.png
Binary files differ
diff --git a/tools/editor/icons/icon_key_invalid.png b/tools/editor/icons/icon_key_invalid.png
new file mode 100644
index 0000000000..e8e6c87180
--- /dev/null
+++ b/tools/editor/icons/icon_key_invalid.png
Binary files differ
diff --git a/tools/editor/icons/icon_key_invalid_hover.png b/tools/editor/icons/icon_key_invalid_hover.png
new file mode 100644
index 0000000000..6f0396d96a
--- /dev/null
+++ b/tools/editor/icons/icon_key_invalid_hover.png
Binary files differ
diff --git a/tools/editor/icons/icon_list_select.png b/tools/editor/icons/icon_list_select.png
new file mode 100644
index 0000000000..cbe81d4328
--- /dev/null
+++ b/tools/editor/icons/icon_list_select.png
Binary files differ
diff --git a/tools/editor/icons/icon_pin.png b/tools/editor/icons/icon_pin.png
index 037352137d..4862ee8f71 100644
--- a/tools/editor/icons/icon_pin.png
+++ b/tools/editor/icons/icon_pin.png
Binary files differ
diff --git a/tools/editor/import_settings.cpp b/tools/editor/import_settings.cpp
index 36d7828be0..2bbd1e3805 100644
--- a/tools/editor/import_settings.cpp
+++ b/tools/editor/import_settings.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/import_settings.h b/tools/editor/import_settings.h
index 31237dd8cf..5a383a1a1a 100644
--- a/tools/editor/import_settings.h
+++ b/tools/editor/import_settings.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/io_plugins/editor_atlas.cpp b/tools/editor/io_plugins/editor_atlas.cpp
index 7e9acd193d..f894e7e8b2 100644
--- a/tools/editor/io_plugins/editor_atlas.cpp
+++ b/tools/editor/io_plugins/editor_atlas.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/io_plugins/editor_atlas.h b/tools/editor/io_plugins/editor_atlas.h
index 716faff0c6..0135e76622 100644
--- a/tools/editor/io_plugins/editor_atlas.h
+++ b/tools/editor/io_plugins/editor_atlas.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/io_plugins/editor_export_scene.cpp b/tools/editor/io_plugins/editor_export_scene.cpp
new file mode 100644
index 0000000000..dff41a59ed
--- /dev/null
+++ b/tools/editor/io_plugins/editor_export_scene.cpp
@@ -0,0 +1,112 @@
+#include "editor_export_scene.h"
+#include "io/resource_loader.h"
+#include "io/resource_saver.h"
+#include "os/dir_access.h"
+#include "os/file_access.h"
+#include "tools/editor/editor_settings.h"
+#include "scene/resources/packed_scene.h"
+#include "globals.h"
+
+Vector<uint8_t> EditorSceneExportPlugin::custom_export(String& p_path,const Ref<EditorExportPlatform> &p_platform) {
+
+ if (!EditorImportExport::get_singleton()->get_convert_text_scenes()) {
+ return Vector<uint8_t>();
+ }
+
+
+ String extension = p_path.extension();
+
+ //step 1 check if scene
+
+ if (extension=="xml" || extension=="xres") {
+
+ String type = ResourceLoader::get_resource_type(p_path);
+
+ if (type!="PackedScene")
+ return Vector<uint8_t>();
+
+ } else if (extension!="tscn" && extension!="xscn") {
+ return Vector<uint8_t>();
+ }
+
+ //step 2 check if cached
+
+ uint64_t sd=0;
+ String smd5;
+ String gp = Globals::get_singleton()->globalize_path(p_path);
+ String md5=gp.md5_text();
+ String tmp_path = EditorSettings::get_singleton()->get_settings_path().plus_file("tmp/");
+
+ bool valid=false;
+ {
+ //if existing, make sure it's valid
+ FileAccessRef f = FileAccess::open(tmp_path+"scnexp-"+md5+".txt",FileAccess::READ);
+ if (f) {
+
+ uint64_t d = f->get_line().strip_edges().to_int64();
+ sd = FileAccess::get_modified_time(p_path);
+
+ if (d==sd) {
+ valid=true;
+ } else {
+ String cmd5 = f->get_line().strip_edges();
+ smd5 = FileAccess::get_md5(p_path);
+ if (cmd5==smd5) {
+ valid=true;
+ }
+ }
+
+
+ }
+ }
+
+ if (!valid) {
+ //cache failed, convert
+ DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
+
+ String copy = p_path+".convert."+extension;
+
+ // a copy will allow loading the internal resources without conflicting with opened scenes
+ da->copy(p_path,copy);
+
+ //@todo for tscn use something more efficient
+
+ Ref<PackedScene> copyres = ResourceLoader::load(copy,"PackedScene");
+
+ da->remove(copy);
+
+ memdelete(da);
+
+ ERR_FAIL_COND_V(!copyres.is_valid(),Vector<uint8_t>());
+
+ Error err = ResourceSaver::save(tmp_path+"scnexp-"+md5+".scn",copyres);
+
+ copyres=Ref<PackedScene>();
+
+ ERR_FAIL_COND_V(err!=OK,Vector<uint8_t>());
+
+ FileAccessRef f = FileAccess::open(tmp_path+"scnexp-"+md5+".txt",FileAccess::WRITE);
+
+ if (sd==0)
+ sd = FileAccess::get_modified_time(p_path);
+ if (smd5==String())
+ smd5 = FileAccess::get_md5(p_path);
+
+ f->store_line(String::num(sd));
+ f->store_line(smd5);
+ f->store_line(gp); //source path for reference
+ }
+
+
+ Vector<uint8_t> ret = FileAccess::get_file_as_array(tmp_path+"scnexp-"+md5+".scn");
+
+ p_path+=".converted.scn";
+
+ return ret;
+
+}
+
+
+EditorSceneExportPlugin::EditorSceneExportPlugin()
+{
+}
diff --git a/tools/editor/io_plugins/editor_export_scene.h b/tools/editor/io_plugins/editor_export_scene.h
new file mode 100644
index 0000000000..134da6c234
--- /dev/null
+++ b/tools/editor/io_plugins/editor_export_scene.h
@@ -0,0 +1,16 @@
+#ifndef EDITOR_EXPORT_SCENE_H
+#define EDITOR_EXPORT_SCENE_H
+
+#include "tools/editor/editor_import_export.h"
+
+
+class EditorSceneExportPlugin : public EditorExportPlugin {
+ OBJ_TYPE( EditorSceneExportPlugin, EditorExportPlugin );
+public:
+
+ virtual Vector<uint8_t> custom_export(String& p_path,const Ref<EditorExportPlatform> &p_platform);
+
+ EditorSceneExportPlugin();
+};
+
+#endif // EDITOR_EXPORT_SCENE_H
diff --git a/tools/editor/io_plugins/editor_font_import_plugin.cpp b/tools/editor/io_plugins/editor_font_import_plugin.cpp
index 10a3877529..9b4ca246e7 100644
--- a/tools/editor/io_plugins/editor_font_import_plugin.cpp
+++ b/tools/editor/io_plugins/editor_font_import_plugin.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -520,6 +520,10 @@ class EditorFontImportDialog : public ConfirmationDialog {
return;
}
+ if (dest->get_line_edit()->get_text().get_file()==".fnt") {
+ dest->get_line_edit()->set_text(dest->get_line_edit()->get_text().get_base_dir() + "/" + source->get_line_edit()->get_text().get_file().basename() + ".fnt" );
+ }
+
Ref<ResourceImportMetadata> rimd = get_rimd();
if (rimd.is_null()) {
@@ -617,6 +621,7 @@ public:
source->get_file_dialog()->set_mode(EditorFileDialog::MODE_OPEN_FILE);
source->get_file_dialog()->add_filter("*.ttf;TrueType");
source->get_file_dialog()->add_filter("*.otf;OpenType");
+ source->get_file_dialog()->add_filter("*.fnt;BMFont");
source->get_line_edit()->connect("text_entered",this,"_src_changed");
vbl->add_margin_child("Source Font:",source);
@@ -872,10 +877,31 @@ static unsigned char get_SDF_radial(
Ref<Font> EditorFontImportPlugin::generate_font(const Ref<ResourceImportMetadata>& p_from, const String &p_existing) {
+
+
Ref<ResourceImportMetadata> from = p_from;
ERR_FAIL_COND_V(from->get_source_count()!=1,Ref<Font>());
String src_path = EditorImportPlugin::expand_source_path(from->get_source_path(0));
+
+ if (src_path.extension().to_lower()=="fnt") {
+
+ if (ResourceLoader::load(src_path).is_valid()) {
+ EditorNode::get_singleton()->show_warning("Path: "+src_path+"\nIs a Godot font file, please supply a BMFont type file instead.");
+ return Ref<Font>();
+ }
+
+ Ref<Font> font;
+ font.instance();
+ Error err = font->create_from_fnt(src_path);
+ if (err) {
+ EditorNode::get_singleton()->show_warning("Path: "+src_path+"\nFailed opening as BMFont file.");
+ return Ref<Font>();
+ }
+
+ return font;
+ }
+
int size = from->get_option("font/size");
#ifdef FREETYPE_ENABLED
diff --git a/tools/editor/io_plugins/editor_font_import_plugin.h b/tools/editor/io_plugins/editor_font_import_plugin.h
index 451f01080e..814897c5f0 100644
--- a/tools/editor/io_plugins/editor_font_import_plugin.h
+++ b/tools/editor/io_plugins/editor_font_import_plugin.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/io_plugins/editor_import_collada.cpp b/tools/editor/io_plugins/editor_import_collada.cpp
index d57cff850e..7de9d978f2 100644
--- a/tools/editor/io_plugins/editor_import_collada.cpp
+++ b/tools/editor/io_plugins/editor_import_collada.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -68,6 +68,7 @@ struct ColladaImport {
Map<String,NodeMap> node_map; //map from collada node to engine node
+ Map<String,String> node_name_map; //map from collada node to engine node
Map<String, Ref<Mesh> > mesh_cache;
Map<String, Ref<Curve3D> > curve_cache;
Map<String, Ref<Material> > material_cache;
@@ -124,6 +125,7 @@ Error ColladaImport::_populate_skeleton(Skeleton *p_skeleton,Collada::Node *p_no
nm.node=p_skeleton;
nm.bone = r_bone;
node_map[p_node->id]=nm;
+ node_name_map[p_node->name]=p_node->id;
skeleton_bone_map[p_skeleton][joint->sid]=r_bone;
@@ -345,6 +347,7 @@ Error ColladaImport::_create_scene(Collada::Node *p_node, Spatial *p_parent) {
NodeMap nm;
nm.node=node;
node_map[p_node->id]=nm;
+ node_name_map[p_node->name]=p_node->id;
Transform xf = p_node->default_transform;
xf = collada.fix_transform( xf ) * p_node->post_transform;
@@ -1906,9 +1909,20 @@ void ColladaImport::create_animations(bool p_make_tracks_in_all_bones) {
Collada::AnimationTrack &at = collada.state.animation_tracks[i];
//print_line("CHANNEL: "+at.target+" PARAM: "+at.param);
+
+ String node;
+
if (!node_map.has(at.target)) {
- print_line("Coudlnt find node: "+at.target);
- continue;
+
+ if (node_name_map.has(at.target)) {
+
+ node=node_name_map[at.target];
+ } else {
+ print_line("Coudlnt find node: "+at.target);
+ continue;
+ }
+ } else {
+ node=at.target;
}
@@ -1917,8 +1931,9 @@ void ColladaImport::create_animations(bool p_make_tracks_in_all_bones) {
valid_animated_properties.push_back(i);
} else {
- node_map[at.target].anim_tracks.push_back(i);
- valid_animated_nodes.insert(at.target);
+
+ node_map[node].anim_tracks.push_back(i);
+ valid_animated_nodes.insert(node);
}
}
@@ -1934,6 +1949,7 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones
Ref<Animation> animation = Ref<Animation>( memnew( Animation ));
+
if (p_clip==-1) {
//print_line("default");
@@ -2007,10 +2023,12 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones
while(f<anim_length) {
base_snapshots.push_back(f);
+
f+=snapshot_interval;
if (f>=anim_length) {
base_snapshots.push_back(anim_length);
+
}
}
@@ -2019,11 +2037,17 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones
bool tracks_found=false;
+
+
for(Set<String>::Element* E=valid_animated_nodes.front();E;E=E->next()) {
// take snapshots
- if (!collada.state.scene_map.has(E->get()))
+
+
+ if (!collada.state.scene_map.has(E->get())) {
+
continue;
+ }
NodeMap &nm = node_map[E->get()];
String path = scene->get_path_to(nm.node);
@@ -2039,7 +2063,7 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones
Collada::Node *cn = collada.state.scene_map[E->get()];
if (cn->ignore_anim) {
- //print_line("warning, ignoring animation on node: "+path);
+
continue;
}
@@ -2058,20 +2082,23 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones
for(int i=0;i<at.keys.size();i++)
snapshots.push_back(at.keys[i].time);
- print_line("using anim snapshots");
}
for(int i=0;i<snapshots.size();i++) {
+
for(List<int>::Element *ET=nm.anim_tracks.front();ET;ET=ET->next()) {
//apply tracks
+
if (p_clip==-1) {
- if (track_filter.has(ET->get()))
+ if (track_filter.has(ET->get())) {
+
continue;
+ }
} else {
if (!track_filter.has(ET->get()))
diff --git a/tools/editor/io_plugins/editor_import_collada.h b/tools/editor/io_plugins/editor_import_collada.h
index 243cd043a0..de45dc38f4 100644
--- a/tools/editor/io_plugins/editor_import_collada.h
+++ b/tools/editor/io_plugins/editor_import_collada.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/io_plugins/editor_sample_import_plugin.cpp b/tools/editor/io_plugins/editor_sample_import_plugin.cpp
index 7888246956..b81c88c817 100644
--- a/tools/editor/io_plugins/editor_sample_import_plugin.cpp
+++ b/tools/editor/io_plugins/editor_sample_import_plugin.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -859,7 +859,7 @@ Vector<uint8_t> EditorSampleExportPlugin::custom_export(String& p_path,const Ref
ERR_FAIL_COND_V(err!=OK,Vector<uint8_t>());
- p_path=p_path.basename()+".smp";
+ p_path=p_path.basename()+".converted.smp";
return FileAccess::get_file_as_array(savepath);
}
diff --git a/tools/editor/io_plugins/editor_sample_import_plugin.h b/tools/editor/io_plugins/editor_sample_import_plugin.h
index 89319affa0..b31562af76 100644
--- a/tools/editor/io_plugins/editor_sample_import_plugin.h
+++ b/tools/editor/io_plugins/editor_sample_import_plugin.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/io_plugins/editor_scene_import_plugin.cpp b/tools/editor/io_plugins/editor_scene_import_plugin.cpp
index ca44df269b..a3b6827cd4 100644
--- a/tools/editor/io_plugins/editor_scene_import_plugin.cpp
+++ b/tools/editor/io_plugins/editor_scene_import_plugin.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/io_plugins/editor_scene_import_plugin.h b/tools/editor/io_plugins/editor_scene_import_plugin.h
index 71efab9503..1f3b73fe7f 100644
--- a/tools/editor/io_plugins/editor_scene_import_plugin.h
+++ b/tools/editor/io_plugins/editor_scene_import_plugin.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/io_plugins/editor_texture_import_plugin.cpp b/tools/editor/io_plugins/editor_texture_import_plugin.cpp
index 8d5a4f1dcf..29273ebd06 100644
--- a/tools/editor/io_plugins/editor_texture_import_plugin.cpp
+++ b/tools/editor/io_plugins/editor_texture_import_plugin.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -1666,7 +1666,7 @@ EditorTextureImportPlugin::EditorTextureImportPlugin(EditorNode *p_editor, Mode
if (pl.is_valid()) {
Vector<uint8_t> ce = pl->custom_export(p_path,p_platform);
if (ce.size()) {
- p_path=p_path.basename()+".tex";
+ p_path=p_path.basename()+".converted.tex";
return ce;
}
}
@@ -1680,7 +1680,7 @@ EditorTextureImportPlugin::EditorTextureImportPlugin(EditorNode *p_editor, Mode
if (pl.is_valid()) {
Vector<uint8_t> ce = pl->custom_export(p_path,p_platform);
if (ce.size()) {
- p_path=p_path.basename()+".tex";
+ p_path=p_path.basename()+".converted.tex";
return ce;
}
}
diff --git a/tools/editor/io_plugins/editor_texture_import_plugin.h b/tools/editor/io_plugins/editor_texture_import_plugin.h
index 38fd671e9d..cb63ba98c8 100644
--- a/tools/editor/io_plugins/editor_texture_import_plugin.h
+++ b/tools/editor/io_plugins/editor_texture_import_plugin.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/io_plugins/editor_translation_import_plugin.cpp b/tools/editor/io_plugins/editor_translation_import_plugin.cpp
index d152d71af4..1edfe697b6 100644
--- a/tools/editor/io_plugins/editor_translation_import_plugin.cpp
+++ b/tools/editor/io_plugins/editor_translation_import_plugin.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/io_plugins/editor_translation_import_plugin.h b/tools/editor/io_plugins/editor_translation_import_plugin.h
index f3c2884534..cadcdc03b3 100644
--- a/tools/editor/io_plugins/editor_translation_import_plugin.h
+++ b/tools/editor/io_plugins/editor_translation_import_plugin.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/optimized_save_dialog.cpp b/tools/editor/optimized_save_dialog.cpp
index 687d3675fc..4814b3b021 100644
--- a/tools/editor/optimized_save_dialog.cpp
+++ b/tools/editor/optimized_save_dialog.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/optimized_save_dialog.h b/tools/editor/optimized_save_dialog.h
index 739d0e1506..bdc36eddc1 100644
--- a/tools/editor/optimized_save_dialog.h
+++ b/tools/editor/optimized_save_dialog.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/output_strings.cpp b/tools/editor/output_strings.cpp
index 30569d11b0..a19352f4ec 100644
--- a/tools/editor/output_strings.cpp
+++ b/tools/editor/output_strings.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/output_strings.h b/tools/editor/output_strings.h
index ad893534fa..3d5deb1646 100644
--- a/tools/editor/output_strings.h
+++ b/tools/editor/output_strings.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/pane_drag.cpp b/tools/editor/pane_drag.cpp
index fb137de5ce..8e8c2941ec 100644
--- a/tools/editor/pane_drag.cpp
+++ b/tools/editor/pane_drag.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/pane_drag.h b/tools/editor/pane_drag.h
index a6cd9b6662..24f2ef7ed8 100644
--- a/tools/editor/pane_drag.h
+++ b/tools/editor/pane_drag.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/plugins/animation_data_editor_plugin.cpp b/tools/editor/plugins/animation_data_editor_plugin.cpp
index d8d65b875a..a73c75056b 100644
--- a/tools/editor/plugins/animation_data_editor_plugin.cpp
+++ b/tools/editor/plugins/animation_data_editor_plugin.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/plugins/animation_data_editor_plugin.h b/tools/editor/plugins/animation_data_editor_plugin.h
index 0daa67d0a5..0a12638474 100644
--- a/tools/editor/plugins/animation_data_editor_plugin.h
+++ b/tools/editor/plugins/animation_data_editor_plugin.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/plugins/animation_player_editor_plugin.cpp b/tools/editor/plugins/animation_player_editor_plugin.cpp
index 6542fc8b4a..43b4276d45 100644
--- a/tools/editor/plugins/animation_player_editor_plugin.cpp
+++ b/tools/editor/plugins/animation_player_editor_plugin.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -32,20 +32,20 @@
#include "io/resource_saver.h"
#include "os/keyboard.h"
#include "tools/editor/editor_settings.h"
+#include "tools/editor/animation_editor.h"
void AnimationPlayerEditor::_node_removed(Node *p_node) {
if (player && player == p_node) {
player=NULL;
- hide();
+
set_process(false);
- if (edit_anim->is_pressed()) {
- editor->get_animation_editor()->set_animation(Ref<Animation>());
- editor->get_animation_editor()->set_root(NULL);
- editor->animation_editor_make_visible(false);
- edit_anim->set_pressed(false);
- }
+ key_editor->set_animation(Ref<Animation>());
+ key_editor->set_root(NULL);
+ _update_player();
+ //editor->animation_editor_make_visible(false);
+
}
}
@@ -72,19 +72,18 @@ void AnimationPlayerEditor::_notification(int p_what) {
Ref<Animation> anim = player->get_animation(animname);
if (!anim.is_null()) {
- seek->set_max(anim->get_length());
+ frame->set_max(anim->get_length());
}
}
}
- seek->set_val(player->get_current_animation_pos());
- if (edit_anim->is_pressed())
- editor->get_animation_editor()->set_anim_pos(player->get_current_animation_pos());
+ frame->set_val(player->get_current_animation_pos());
+ key_editor->set_anim_pos(player->get_current_animation_pos());
EditorNode::get_singleton()->get_property_editor()->refresh();
} else if (last_active) {
//need the last frame after it stopped
- seek->set_val(player->get_current_animation_pos());
+ frame->set_val(player->get_current_animation_pos());
}
last_active=player->is_playing();
@@ -94,7 +93,7 @@ void AnimationPlayerEditor::_notification(int p_what) {
if (p_what==NOTIFICATION_ENTER_TREE) {
- editor->connect("hide_animation_player_editors",this,"_hide_anim_editors");
+// editor->connect("hide_animation_player_editors",this,"_hide_anim_editors");
add_anim->set_icon( get_icon("New","EditorIcons") );
rename_anim->set_icon( get_icon("Rename","EditorIcons") );
duplicate_anim->set_icon( get_icon("Duplicate","EditorIcons") );
@@ -103,7 +102,7 @@ void AnimationPlayerEditor::_notification(int p_what) {
save_anim->set_icon(get_icon("Save", "EditorIcons"));
save_anim->get_popup()->connect("item_pressed", this, "_animation_save_menu");
remove_anim->set_icon( get_icon("Remove","EditorIcons") );
- edit_anim->set_icon( get_icon("Edit","EditorIcons") );
+
blend_anim->set_icon( get_icon("Blend","EditorIcons") );
play->set_icon( get_icon("PlayStart","EditorIcons") );
play_from->set_icon( get_icon("Play","EditorIcons") );
@@ -113,13 +112,14 @@ void AnimationPlayerEditor::_notification(int p_what) {
autoplay_icon=get_icon("AutoPlay","EditorIcons");
stop->set_icon( get_icon("Stop","EditorIcons") );
resource_edit_anim->set_icon( get_icon("EditResource","EditorIcons") );
- pin->set_normal_texture(get_icon("Pin","EditorIcons") );
- pin->set_pressed_texture( get_icon("PinPressed","EditorIcons") );
+ pin->set_icon(get_icon("Pin","EditorIcons") );
tool_anim->set_icon(get_icon("Tools","EditorIcons"));
tool_anim->get_popup()->connect("item_pressed",this,"_animation_tool_menu");
blend_editor.next->connect("text_changed",this,"_blend_editor_next_changed");
+ nodename->set_icon(get_icon("AnimationPlayer","EditorIcons"));
+
/*
anim_editor_load->set_normal_texture( get_icon("AnimGet","EditorIcons"));
anim_editor_store->set_normal_texture( get_icon("AnimSet","EditorIcons"));
@@ -295,22 +295,25 @@ void AnimationPlayerEditor::_animation_selected(int p_which) {
player->set_current_animation( current );
Ref<Animation> anim = player->get_animation(current);
- if (edit_anim->is_pressed()) {
- Ref<Animation> anim = player->get_animation(current);
- editor->get_animation_editor()->set_animation(anim);
+ {
+
+ key_editor->set_animation(anim);
Node *root = player->get_node(player->get_root());
if (root) {
- editor->get_animation_editor()->set_root(root);
+ key_editor->set_root(root);
}
}
- seek->set_max(anim->get_length());
+ frame->set_max(anim->get_length());
+ if (anim->get_step())
+ frame->set_step(anim->get_step());
+ else
+ frame->set_step(0.00001);
+
} else {
- if (edit_anim->is_pressed()) {
- editor->get_animation_editor()->set_animation(Ref<Animation>());
- editor->get_animation_editor()->set_root(NULL);
- }
+ key_editor->set_animation(Ref<Animation>());
+ key_editor->set_root(NULL);
}
@@ -631,7 +634,7 @@ Dictionary AnimationPlayerEditor::get_state() const {
if (is_visible() && player) {
d["player"]=EditorNode::get_singleton()->get_edited_scene()->get_path_to(player);
d["animation"]=player->get_current_animation();
- d["editing"]=edit_anim->is_pressed();
+
}
return d;
@@ -648,16 +651,12 @@ void AnimationPlayerEditor::set_state(const Dictionary& p_state) {
show();
set_process(true);
ensure_visibility();
- EditorNode::get_singleton()->animation_panel_make_visible(true);
+// EditorNode::get_singleton()->animation_panel_make_visible(true);
if (p_state.has("animation")) {
String anim = p_state["animation"];
_select_anim_by_name(anim);
- if (p_state.has("editing") && p_state["editing"]) {
-
- edit_anim->set_pressed(true);
- _animation_edit();
- }
+ _animation_edit();
}
}
@@ -678,36 +677,22 @@ void AnimationPlayerEditor::_animation_resource_edit() {
void AnimationPlayerEditor::_animation_edit() {
-// if (animation->get_item_count()==0)
-// return;
-
- if (edit_anim->is_pressed()) {
- editor->animation_editor_make_visible(true);
-
- //editor->get_animation_editor()->set_root(player->get_roo); - get root pending
- if (animation->get_item_count()) {
- String current = animation->get_item_text(animation->get_selected());
- Ref<Animation> anim = player->get_animation(current);
- editor->get_animation_editor()->set_animation(anim);
- Node *root = player->get_node(player->get_root());
- if (root) {
- editor->get_animation_editor()->set_root(root);
- }
+ if (animation->get_item_count()) {
+ String current = animation->get_item_text(animation->get_selected());
+ Ref<Animation> anim = player->get_animation(current);
+ key_editor->set_animation(anim);
+ Node *root = player->get_node(player->get_root());
+ if (root) {
+ key_editor->set_root(root);
+ }
- } else {
+ } else {
- editor->get_animation_editor()->set_animation(Ref<Animation>());
- editor->get_animation_editor()->set_root(NULL);
+ key_editor->set_animation(Ref<Animation>());
+ key_editor->set_root(NULL);
- }
- } else {
- editor->animation_editor_make_visible(false);
- editor->get_animation_editor()->set_animation(Ref<Animation>());
- editor->get_animation_editor()->set_root(NULL);
}
- //get_scene()->get_root_node()->call("_resource_selected",anim,"");
-
}
void AnimationPlayerEditor::_dialog_action(String p_file) {
@@ -800,16 +785,21 @@ void AnimationPlayerEditor::_update_animation() {
void AnimationPlayerEditor::_update_player() {
- if (!player)
- return;
updating=true;
List<StringName> animlist;
- player->get_animation_list(&animlist);
+ if (player)
+ player->get_animation_list(&animlist);
animation->clear();
- nodename->set_text(player->get_name());
+ if (player)
+ nodename->set_text(player->get_name());
+ else
+ nodename->set_text("<empty>");
+
+ add_anim->set_disabled(player==NULL);
+ load_anim->set_disabled(player==NULL);
stop->set_disabled(animlist.size()==0);
play->set_disabled(animlist.size()==0);
play_bw->set_disabled(animlist.size()==0);
@@ -837,6 +827,9 @@ void AnimationPlayerEditor::_update_player() {
}
+ if (!player)
+ return;
+
updating=false;
if (active_idx!=-1) {
animation->select(active_idx);
@@ -852,17 +845,14 @@ void AnimationPlayerEditor::_update_player() {
//pause->set_pressed(player->is_paused());
- if (edit_anim->is_pressed()) {
-
- if (animation->get_item_count()) {
- String current = animation->get_item_text(animation->get_selected());
- Ref<Animation> anim = player->get_animation(current);
- editor->get_animation_editor()->set_animation(anim);
- Node *root = player->get_node(player->get_root());
- if (root) {
- editor->get_animation_editor()->set_root(root);
- }
+ if (animation->get_item_count()) {
+ String current = animation->get_item_text(animation->get_selected());
+ Ref<Animation> anim = player->get_animation(current);
+ key_editor->set_animation(anim);
+ Node *root = player->get_node(player->get_root());
+ if (root) {
+ key_editor->set_root(root);
}
}
@@ -958,7 +948,7 @@ void AnimationPlayerEditor::_seek_value_changed(float p_value) {
Ref<Animation> anim;
anim=player->get_animation(current);
- float pos = anim->get_length() * (p_value / seek->get_max());
+ float pos = anim->get_length() * (p_value / frame->get_max());
if (player->is_valid()) {
float cpos = player->get_current_animation_pos();
@@ -968,8 +958,7 @@ void AnimationPlayerEditor::_seek_value_changed(float p_value) {
player->seek(pos,true);
}
- if (edit_anim->is_pressed())
- editor->get_animation_editor()->set_anim_pos(pos);
+ key_editor->set_anim_pos(pos);
updating=true;
};
@@ -999,19 +988,19 @@ void AnimationPlayerEditor::_editor_store() {
String current = animation->get_item_text(animation->get_selected());
Ref<Animation> anim = player->get_animation(current);
- if (editor->get_animation_editor()->get_current_animation()==anim)
+ if (key_editor->get_current_animation()==anim)
return; //already there
undo_redo->create_action("Store anim in editor");
- undo_redo->add_do_method(editor->get_animation_editor(),"set_animation",anim);
- undo_redo->add_undo_method(editor->get_animation_editor(),"remove_animation",anim);
+ undo_redo->add_do_method(key_editor,"set_animation",anim);
+ undo_redo->add_undo_method(key_editor,"remove_animation",anim);
undo_redo->commit_action();
}
void AnimationPlayerEditor::_editor_load(){
- Ref<Animation> anim = editor->get_animation_editor()->get_current_animation();
+ Ref<Animation> anim = key_editor->get_current_animation();
if (anim.is_null())
return;
@@ -1059,7 +1048,16 @@ void AnimationPlayerEditor::_editor_load(){
void AnimationPlayerEditor::_animation_key_editor_anim_len_changed(float p_len) {
- seek->set_max(p_len);
+ frame->set_max(p_len);
+
+}
+
+void AnimationPlayerEditor::_animation_key_editor_anim_step_changed(float p_len) {
+
+ if (p_len)
+ frame->set_step(p_len);
+ else
+ frame->set_step(0.00001);
}
@@ -1074,7 +1072,7 @@ void AnimationPlayerEditor::_animation_key_editor_seek(float p_pos) {
if (player->is_playing() )
return;
- seek->set_val(p_pos);
+ frame->set_val(p_pos);
EditorNode::get_singleton()->get_property_editor()->refresh();
@@ -1087,13 +1085,11 @@ void AnimationPlayerEditor::_hide_anim_editors() {
player=NULL;
hide();
set_process(false);
- if (edit_anim->is_pressed()) {
- editor->get_animation_editor()->set_animation(Ref<Animation>());
- editor->get_animation_editor()->set_root(NULL);
- editor->animation_editor_make_visible(false);
- edit_anim->set_pressed(false);
- }
+ key_editor->set_animation(Ref<Animation>());
+ key_editor->set_root(NULL);
+// editor->animation_editor_make_visible(false);
+
}
@@ -1238,6 +1234,7 @@ void AnimationPlayerEditor::_bind_methods() {
ObjectTypeDB::bind_method(_MD("_list_changed"),&AnimationPlayerEditor::_list_changed);
ObjectTypeDB::bind_method(_MD("_animation_key_editor_seek"),&AnimationPlayerEditor::_animation_key_editor_seek);
ObjectTypeDB::bind_method(_MD("_animation_key_editor_anim_len_changed"),&AnimationPlayerEditor::_animation_key_editor_anim_len_changed);
+ ObjectTypeDB::bind_method(_MD("_animation_key_editor_anim_step_changed"),&AnimationPlayerEditor::_animation_key_editor_anim_step_changed);
ObjectTypeDB::bind_method(_MD("_hide_anim_editors"),&AnimationPlayerEditor::_hide_anim_editors);
ObjectTypeDB::bind_method(_MD("_animation_duplicate"),&AnimationPlayerEditor::_animation_duplicate);
ObjectTypeDB::bind_method(_MD("_blend_editor_next_changed"),&AnimationPlayerEditor::_blend_editor_next_changed);
@@ -1250,8 +1247,15 @@ void AnimationPlayerEditor::_bind_methods() {
}
+AnimationPlayerEditor *AnimationPlayerEditor::singleton=NULL;
+
+AnimationPlayer *AnimationPlayerEditor::get_player() const {
+
+ return player;
+}
AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor) {
editor=p_editor;
+ singleton=this;
updating=false;
@@ -1271,6 +1275,50 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor) {
add_child(hb);
+ play_bw_from = memnew( ToolButton );
+ play_bw_from->set_tooltip("Play backwards selected animation from current pos. (A)");
+ hb->add_child(play_bw_from);
+
+ play_bw = memnew( ToolButton );
+ play_bw->set_tooltip("Play backwards selected animation from end. (Shift+A)");
+ hb->add_child(play_bw);
+
+ stop = memnew( ToolButton );
+ stop->set_toggle_mode(true);
+ hb->add_child(stop);
+ stop->set_tooltip("Stop animation playback. (S)");
+
+ play = memnew( ToolButton );
+ play->set_tooltip("Play selected animation from start. (Shift+D)");
+ hb->add_child(play);
+
+
+ play_from = memnew( ToolButton );
+ play_from->set_tooltip("Play selected animation from current pos. (D)");
+ hb->add_child(play_from);
+
+
+
+ //pause = memnew( Button );
+ //pause->set_toggle_mode(true);
+ //hb->add_child(pause);
+
+ frame = memnew( SpinBox );
+ hb->add_child(frame);
+ frame->set_custom_minimum_size(Size2(80,0));
+ frame->set_stretch_ratio(2);
+ frame->set_tooltip("Animation position (in seconds).");
+
+ hb->add_child( memnew( VSeparator));
+
+ scale = memnew( LineEdit );
+ hb->add_child(scale);
+ scale->set_h_size_flags(SIZE_EXPAND_FILL);
+ scale->set_stretch_ratio(1);
+ scale->set_tooltip("Scale animation playback globally for the node.");
+ scale->hide();
+
+
add_anim = memnew( ToolButton );
add_anim->set_tooltip("Create new animation in player.");
@@ -1330,67 +1378,13 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor) {
//tool_anim->get_popup()->add_item("Edit Anim Resource",TOOL_PASTE_ANIM);
hb->add_child(tool_anim);
-
- edit_anim = memnew( ToolButton );
- edit_anim->set_toggle_mode(true);
- hb->add_child(edit_anim);
- edit_anim->set_tooltip("Open animation editor.\nProperty editor will displays all editable keys too.");
-
-
- hb = memnew (HBoxContainer);
- add_child(hb);
-
- play_bw_from = memnew( ToolButton );
- play_bw_from->set_tooltip("Play backwards selected animation from current pos. (A)");
- hb->add_child(play_bw_from);
-
- play_bw = memnew( ToolButton );
- play_bw->set_tooltip("Play backwards selected animation from end. (Shift+A)");
- hb->add_child(play_bw);
-
- stop = memnew( ToolButton );
- stop->set_toggle_mode(true);
- hb->add_child(stop);
- stop->set_tooltip("Stop animation playback. (S)");
-
- play = memnew( ToolButton );
- play->set_tooltip("Play selected animation from start. (Shift+D)");
- hb->add_child(play);
+ nodename = memnew( Button );
+ hb->add_child(nodename);
+ pin = memnew( ToolButton );
+ pin->set_toggle_mode(true);
+ hb->add_child(pin);
- play_from = memnew( ToolButton );
- play_from->set_tooltip("Play selected animation from current pos. (D)");
- hb->add_child(play_from);
-
-
-
- //pause = memnew( Button );
- //pause->set_toggle_mode(true);
- //hb->add_child(pause);
-
- seek = memnew( HSlider );
- seek->set_val(0);
- seek->set_step(0.01);
- hb->add_child(seek);
- seek->set_h_size_flags(SIZE_EXPAND_FILL);
- seek->set_stretch_ratio(8);
- seek->set_tooltip("Seek animation (when stopped).");
-
- frame = memnew( SpinBox );
- hb->add_child(frame);
- frame->set_h_size_flags(SIZE_EXPAND_FILL);
- frame->set_stretch_ratio(2);
- frame->set_tooltip("Animation position (in seconds).");
- seek->share(frame);
-
-
-
- scale = memnew( LineEdit );
- hb->add_child(scale);
- scale->set_h_size_flags(SIZE_EXPAND_FILL);
- scale->set_stretch_ratio(1);
- scale->set_tooltip("Scale animation playback globally for the node.");
- scale->hide();
resource_edit_anim= memnew( Button );
hb->add_child(resource_edit_anim);
@@ -1457,30 +1451,31 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor) {
load_anim->connect("pressed", this,"_animation_load");
duplicate_anim->connect("pressed", this,"_animation_duplicate");
//frame->connect("text_entered", this,"_seek_frame_changed");
- edit_anim->connect("pressed", this,"_animation_edit");
+
blend_anim->connect("pressed", this,"_animation_blend");
remove_anim->connect("pressed", this,"_animation_remove");
animation->connect("item_selected", this,"_animation_selected",Vector<Variant>(),true);
resource_edit_anim->connect("pressed", this,"_animation_resource_edit");
file->connect("file_selected", this,"_dialog_action");
- seek->connect("value_changed", this, "_seek_value_changed",Vector<Variant>(),true);
+ frame->connect("value_changed", this, "_seek_value_changed",Vector<Variant>(),true);
scale->connect("text_entered", this, "_scale_changed",Vector<Variant>(),true);
- editor->get_animation_editor()->connect("timeline_changed",this,"_animation_key_editor_seek");
- editor->get_animation_editor()->connect("animation_len_changed",this,"_animation_key_editor_anim_len_changed");
-
- HBoxContainer *ahb = editor->get_animation_panel_hb();
- nodename = memnew( Label );
- ahb->add_child(nodename);
- nodename->set_h_size_flags(SIZE_EXPAND_FILL);
- nodename->set_opacity(0.5);
- pin = memnew( TextureButton );
- pin->set_toggle_mode(true);
- ahb->add_child(pin);
+
+
renaming=false;
last_active=false;
set_process_unhandled_key_input(true);
+
+ key_editor = memnew( AnimationKeyEditor);
+ add_child(key_editor);
+ add_constant_override("separation",get_constant("separation","VBoxContainer"));
+ key_editor->set_v_size_flags(SIZE_EXPAND_FILL);
+ key_editor->connect("timeline_changed",this,"_animation_key_editor_seek");
+ key_editor->connect("animation_len_changed",this,"_animation_key_editor_anim_len_changed");
+ key_editor->connect("animation_step_changed",this,"_animation_key_editor_anim_step_changed");
+
+ _update_player();
}
@@ -1503,7 +1498,7 @@ void AnimationPlayerEditorPlugin::make_visible(bool p_visible) {
anim_editor->show();
anim_editor->set_process(true);
anim_editor->ensure_visibility();
- editor->animation_panel_make_visible(true);
+// editor->animation_panel_make_visible(true);
} else {
// anim_editor->hide();
@@ -1517,7 +1512,8 @@ AnimationPlayerEditorPlugin::AnimationPlayerEditorPlugin(EditorNode *p_node) {
editor=p_node;
anim_editor = memnew( AnimationPlayerEditor(editor) );
anim_editor->set_undo_redo(editor->get_undo_redo());
- editor->get_animation_panel()->add_child(anim_editor);
+
+ editor->add_bottom_panel_item("Animation",anim_editor);
/*
editor->get_viewport()->add_child(anim_editor);
anim_editor->set_area_as_parent_rect();
diff --git a/tools/editor/plugins/animation_player_editor_plugin.h b/tools/editor/plugins/animation_player_editor_plugin.h
index ac4d1ab6ba..0ad849c2f9 100644
--- a/tools/editor/plugins/animation_player_editor_plugin.h
+++ b/tools/editor/plugins/animation_player_editor_plugin.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -41,7 +41,7 @@
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
-
+class AnimationKeyEditor;
class AnimationPlayerEditor : public VBoxContainer {
OBJ_TYPE(AnimationPlayerEditor, VBoxContainer );
@@ -78,17 +78,16 @@ class AnimationPlayerEditor : public VBoxContainer {
Button *autoplay;
Button *rename_anim;
Button *duplicate_anim;
- Button *edit_anim;
+
Button *resource_edit_anim;
Button *load_anim;
MenuButton *save_anim;
Button *blend_anim;
Button *remove_anim;
MenuButton *tool_anim;
- TextureButton *pin;
- Label *nodename;
+ ToolButton *pin;
+ Button *nodename;
SpinBox *frame;
- HSlider *seek;
LineEdit *scale;
LineEdit *name;
Label *name_title;
@@ -117,6 +116,9 @@ class AnimationPlayerEditor : public VBoxContainer {
bool updating;
bool updating_blends;
+ AnimationKeyEditor *key_editor;
+
+
void _select_anim_by_name(const String& p_anim);
void _play_pressed();
void _play_from_pressed();
@@ -158,10 +160,13 @@ class AnimationPlayerEditor : public VBoxContainer {
void _animation_key_editor_seek(float p_pos);
void _animation_key_editor_anim_len_changed(float p_new);
+ void _animation_key_editor_anim_step_changed(float p_len);
+
void _unhandled_key_input(const InputEvent& p_ev);
void _animation_tool_menu(int p_option);
void _animation_save_menu(int p_option);
+
AnimationPlayerEditor();
protected:
@@ -171,6 +176,10 @@ protected:
static void _bind_methods();
public:
+ AnimationPlayer *get_player() const;
+ static AnimationPlayerEditor *singleton;
+
+ AnimationKeyEditor* get_key_editor() { return key_editor; }
Dictionary get_state() const;
void set_state(const Dictionary& p_state);
diff --git a/tools/editor/plugins/animation_tree_editor_plugin.cpp b/tools/editor/plugins/animation_tree_editor_plugin.cpp
index 382bc44726..d85553b4db 100644
--- a/tools/editor/plugins/animation_tree_editor_plugin.cpp
+++ b/tools/editor/plugins/animation_tree_editor_plugin.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -1498,18 +1498,17 @@ bool AnimationTreeEditorPlugin::handles(Object *p_object) const {
void AnimationTreeEditorPlugin::make_visible(bool p_visible) {
if (p_visible) {
- editor->hide_animation_player_editors();
- editor->animation_panel_make_visible(true);
- anim_tree_editor->show();
+// editor->hide_animation_player_editors();
+// editor->animation_panel_make_visible(true);
+ button->show();
+ editor->make_bottom_panel_item_visible(anim_tree_editor);
anim_tree_editor->set_fixed_process(true);
- EditorNode::get_top_split()->set_collapsed(false);
-
} else {
- anim_tree_editor->hide();
+ if (anim_tree_editor->is_visible())
+ editor->hide_bottom_panel();
+ button->hide();
anim_tree_editor->set_fixed_process(false);
- editor->animation_panel_make_visible(false);
- EditorNode::get_top_split()->set_collapsed(true);
}
}
@@ -1517,12 +1516,10 @@ AnimationTreeEditorPlugin::AnimationTreeEditorPlugin(EditorNode *p_node) {
editor=p_node;
anim_tree_editor = memnew( AnimationTreeEditor );
- //editor->get_viewport()->add_child(anim_tree_editor);
- //anim_tree_editor->set_area_as_parent_rect();
- editor->get_animation_panel()->add_child(anim_tree_editor);
- anim_tree_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL);
- anim_tree_editor->hide();
+ anim_tree_editor->set_custom_minimum_size(Size2(0,300));
+ button=editor->add_bottom_panel_item("AnimationTree",anim_tree_editor);
+ button->hide();
diff --git a/tools/editor/plugins/animation_tree_editor_plugin.h b/tools/editor/plugins/animation_tree_editor_plugin.h
index bd29530c7a..4884a22d90 100644
--- a/tools/editor/plugins/animation_tree_editor_plugin.h
+++ b/tools/editor/plugins/animation_tree_editor_plugin.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -176,6 +176,7 @@ class AnimationTreeEditorPlugin : public EditorPlugin {
AnimationTreeEditor *anim_tree_editor;
EditorNode *editor;
+ Button *button;
public:
diff --git a/tools/editor/plugins/camera_editor_plugin.cpp b/tools/editor/plugins/camera_editor_plugin.cpp
index 08ed2c745d..7433264b16 100644
--- a/tools/editor/plugins/camera_editor_plugin.cpp
+++ b/tools/editor/plugins/camera_editor_plugin.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/plugins/camera_editor_plugin.h b/tools/editor/plugins/camera_editor_plugin.h
index afb8f9415d..ea016ecb4d 100644
--- a/tools/editor/plugins/camera_editor_plugin.h
+++ b/tools/editor/plugins/camera_editor_plugin.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/plugins/canvas_item_editor_plugin.cpp b/tools/editor/plugins/canvas_item_editor_plugin.cpp
index a3164fc524..a259fa0fcc 100644
--- a/tools/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/tools/editor/plugins/canvas_item_editor_plugin.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -37,6 +37,8 @@
#include "os/input.h"
#include "tools/editor/editor_settings.h"
#include "scene/gui/grid_container.h"
+#include "tools/editor/animation_editor.h"
+#include "tools/editor/plugins/animation_player_editor_plugin.h"
class SnapDialog : public ConfirmationDialog {
@@ -152,9 +154,49 @@ public:
}
};
+void CanvasItemEditor::_edit_set_pivot(const Vector2& mouse_pos) {
+ List<Node*> &selection = editor_selection->get_selected_node_list();
+
+ undo_redo->create_action("Move Pivot");
+
+ for(List<Node*>::Element *E=selection.front();E;E=E->next()) {
+
+ Node2D *n2d = E->get()->cast_to<Node2D>();
+
+ if (n2d && n2d->edit_has_pivot()) {
+
+ Vector2 offset = n2d->edit_get_pivot();
+ Vector2 gpos = n2d->get_global_pos();
+
+ Vector2 local_mouse_pos = n2d->get_canvas_transform().affine_inverse().xform(mouse_pos);
+
+ Vector2 motion_ofs = gpos-local_mouse_pos;
+
+ undo_redo->add_do_method(n2d,"set_global_pos",local_mouse_pos);
+ undo_redo->add_do_method(n2d,"edit_set_pivot",offset+n2d->get_global_transform().affine_inverse().basis_xform(motion_ofs));
+ undo_redo->add_undo_method(n2d,"set_global_pos",gpos);
+ undo_redo->add_undo_method(n2d,"edit_set_pivot",offset);
+ for(int i=0;i<n2d->get_child_count();i++) {
+ Node2D *n2dc = n2d->get_child(i)->cast_to<Node2D>();
+ if (!n2dc)
+ continue;
+
+ undo_redo->add_do_method(n2dc,"set_global_pos",n2dc->get_global_pos());
+ undo_redo->add_undo_method(n2dc,"set_global_pos",n2dc->get_global_pos());
+
+ }
+
+ }
+
+ }
+
+ undo_redo->commit_action();
+
+}
+
void CanvasItemEditor::_unhandled_key_input(const InputEvent& p_ev) {
- if (!is_visible())
+ if (!is_visible() || get_viewport()->gui_has_modal_stack())
return;
if (p_ev.key.mod.control)
// prevent to change tool mode when control key is pressed
@@ -179,38 +221,7 @@ void CanvasItemEditor::_unhandled_key_input(const InputEvent& p_ev) {
mouse_pos=transform.affine_inverse().xform(mouse_pos);
mouse_pos=snap_point(mouse_pos);
- undo_redo->create_action("Move Pivot");
-
- for(List<Node*>::Element *E=selection.front();E;E=E->next()) {
-
- Node2D *n2d = E->get()->cast_to<Node2D>();
-
- if (n2d && n2d->edit_has_pivot()) {
-
- Vector2 offset = n2d->edit_get_pivot();
- Vector2 gpos = n2d->get_global_pos();
-
- Vector2 motion_ofs = gpos-mouse_pos;
-
- undo_redo->add_do_method(n2d,"set_global_pos",mouse_pos);
- undo_redo->add_do_method(n2d,"edit_set_pivot",offset+n2d->get_global_transform().affine_inverse().basis_xform(motion_ofs));
- undo_redo->add_undo_method(n2d,"set_global_pos",gpos);
- undo_redo->add_undo_method(n2d,"edit_set_pivot",offset);
- for(int i=0;i<n2d->get_child_count();i++) {
- Node2D *n2dc = n2d->get_child(i)->cast_to<Node2D>();
- if (!n2dc)
- continue;
-
- undo_redo->add_do_method(n2dc,"set_global_pos",n2dc->get_global_pos());
- undo_redo->add_undo_method(n2dc,"set_global_pos",n2dc->get_global_pos());
-
- }
-
- }
-
- }
-
- undo_redo->commit_action();
+ _edit_set_pivot(mouse_pos);
}
}
@@ -221,7 +232,7 @@ void CanvasItemEditor::_unhandled_key_input(const InputEvent& p_ev) {
void CanvasItemEditor::_tool_select(int p_index) {
- ToolButton *tb[TOOL_MAX]={select_button,move_button,rotate_button,pan_button};
+ ToolButton *tb[TOOL_MAX]={select_button,list_select_button,move_button,rotate_button,pivot_button,pan_button};
for(int i=0;i<TOOL_MAX;i++) {
tb[i]->set_pressed(i==p_index);
@@ -396,9 +407,9 @@ void CanvasItemEditor::_node_removed(Node *p_node) {
#endif
}
-void CanvasItemEditor::_keying_changed(bool p_changed) {
+void CanvasItemEditor::_keying_changed() {
- if (p_changed)
+ if (AnimationPlayerEditor::singleton->get_key_editor()->has_keying())
animation_hb->show();
else
animation_hb->hide();
@@ -938,6 +949,75 @@ bool CanvasItemEditor::get_remove_list(List<Node*> *p_list) {
}
+void CanvasItemEditor::_list_select(const InputEventMouseButton& b) {
+
+ Point2 click=Point2(b.x,b.y);
+
+ Node* scene = editor->get_edited_scene();
+ if (!scene)
+ return;
+
+ _find_canvas_items_at_pos(click, scene,transform,Matrix32(), selection_results);
+
+ for(int i=0;i<selection_results.size();i++) {
+ CanvasItem *item=selection_results[i].item;
+ if (item!=scene && item->get_owner()!=scene && !scene->is_editable_instance(item->get_owner())) {
+ //invalid result
+ selection_results.remove(i);
+ i--;
+ }
+
+ }
+
+ if (selection_results.size() == 1) {
+
+ CanvasItem *item = selection_results[0].item;
+ selection_results.clear();
+
+ additive_selection=b.mod.shift;
+ if (!_select(item, click, additive_selection, false))
+ return;
+
+ } else if (!selection_results.empty()) {
+
+ selection_results.sort();
+
+ NodePath root_path = get_tree()->get_edited_scene_root()->get_path();
+ StringName root_name = root_path.get_name(root_path.get_name_count()-1);
+
+ for (int i = 0; i < selection_results.size(); i++) {
+
+ CanvasItem *item=selection_results[i].item;
+
+
+ Ref<Texture> icon;
+ if (item->has_meta("_editor_icon"))
+ icon=item->get_meta("_editor_icon");
+ else
+ icon=get_icon( has_icon(item->get_type(),"EditorIcons")?item->get_type():String("Object"),"EditorIcons");
+
+ String node_path="/"+root_name+"/"+root_path.rel_path_to(item->get_path());
+
+ selection_menu->add_item(item->get_name());
+ selection_menu->set_item_icon(i, icon );
+ selection_menu->set_item_metadata(i, node_path);
+ selection_menu->set_item_tooltip(i,String(item->get_name())+
+ "\nType: "+item->get_type()+"\nPath: "+node_path);
+ }
+
+ additive_selection=b.mod.shift;
+
+ selection_menu->set_global_pos(Vector2( b.global_x, b.global_y ));
+ selection_menu->popup();
+ selection_menu->call_deferred("grab_click_focus");
+ selection_menu->set_invalidate_click_until_motion();
+
+
+ return;
+ }
+
+}
+
void CanvasItemEditor::_viewport_input_event(const InputEvent& p_event) {
{
@@ -993,59 +1073,11 @@ void CanvasItemEditor::_viewport_input_event(const InputEvent& p_event) {
if (b.button_index==BUTTON_RIGHT) {
- if (b.pressed && tool==TOOL_SELECT && b.mod.alt) {
-
- Point2 click=Point2(b.x,b.y);
-
- Node* scene = editor->get_edited_scene();
- if (!scene)
- return;
-
- _find_canvas_items_at_pos(click, scene,transform,Matrix32(), selection_results);
-
- if (selection_results.size() == 1) {
-
- CanvasItem *item = selection_results[0].item;
- selection_results.clear();
-
- additive_selection=b.mod.shift;
- if (!_select(item, click, additive_selection, false))
- return;
-
- } else if (!selection_results.empty()) {
-
- selection_results.sort();
-
- NodePath root_path = get_tree()->get_edited_scene_root()->get_path();
- StringName root_name = root_path.get_name(root_path.get_name_count()-1);
- for (int i = 0; i < selection_results.size(); i++) {
+ if (b.pressed && (tool==TOOL_SELECT && b.mod.alt)) {
- CanvasItem *item=selection_results[i].item;
-
- Ref<Texture> icon;
- if (item->has_meta("_editor_icon"))
- icon=item->get_meta("_editor_icon");
- else
- icon=get_icon( has_icon(item->get_type(),"EditorIcons")?item->get_type():String("Object"),"EditorIcons");
-
- String node_path="/"+root_name+"/"+root_path.rel_path_to(item->get_path());
-
- selection_menu->add_item(item->get_name());
- selection_menu->set_item_icon(i, icon );
- selection_menu->set_item_metadata(i, node_path);
- selection_menu->set_item_tooltip(i,String(item->get_name())+
- "\nType: "+item->get_type()+"\nPath: "+node_path);
- }
-
- additive_selection=b.mod.shift;
-
- selection_menu->set_global_pos(Vector2( b.global_x, b.global_y ));
- selection_menu->popup();
- selection_menu->call_deferred("grab_click_focus");
-
- return;
- }
+ _list_select(b);
+ return;
}
if (get_item_count() > 0 && drag!=DRAG_NONE) {
@@ -1103,6 +1135,26 @@ void CanvasItemEditor::_viewport_input_event(const InputEvent& p_event) {
//if (!canvas_items.size())
// return;
+ if (b.button_index==BUTTON_LEFT && tool==TOOL_LIST_SELECT) {
+ if (b.pressed)
+ _list_select(b);
+ return;
+ }
+
+
+ if (b.button_index==BUTTON_LEFT && tool==TOOL_EDIT_PIVOT) {
+ if (b.pressed) {
+
+ Point2 mouse_pos(b.x,b.y);
+ mouse_pos=transform.affine_inverse().xform(mouse_pos);
+ mouse_pos=snap_point(mouse_pos);
+ _edit_set_pivot(mouse_pos);
+ }
+ return;
+ }
+
+
+
if (tool==TOOL_PAN || b.button_index!=BUTTON_LEFT || Input::get_singleton()->is_key_pressed(KEY_SPACE))
return;
@@ -1491,6 +1543,7 @@ void CanvasItemEditor::_viewport_input_event(const InputEvent& p_event) {
continue;
}
+
dfrom = drag_point_from;
dto = snap_point(dto - (drag == DRAG_ALL ? drag_from - drag_point_from : Vector2(0, 0)), drag_point_from);
@@ -1498,30 +1551,35 @@ void CanvasItemEditor::_viewport_input_event(const InputEvent& p_event) {
canvas_item->get_global_transform_with_canvas().affine_inverse().xform(dto) -
canvas_item->get_global_transform_with_canvas().affine_inverse().xform(dfrom);
-
Rect2 local_rect = canvas_item->get_item_rect();
-
- if (false && drag!=DRAG_ALL && m.mod.alt) {
- float aspect = local_rect.size.get_aspect();
- if (aspect!=0) {
- if (ABS(drag_vector.x) > ABS(drag_vector.y)) {
-
- drag_vector.y = ABS(drag_vector.x)/aspect * SGN(drag_vector.y);
- } else {
-
- drag_vector.x = ABS(drag_vector.y)*aspect * SGN(drag_vector.x);
- }
- }
- }
-
-
-
Vector2 begin=local_rect.pos;
Vector2 end=local_rect.pos+local_rect.size;
Vector2 minsize = canvas_item->edit_get_minimum_size();
bool uniform = m.mod.shift;
bool symmetric=m.mod.alt;
+ if (uniform) {
+ float aspect = local_rect.size.get_aspect();
+ switch(drag) {
+ case DRAG_BOTTOM_LEFT:
+ case DRAG_TOP_RIGHT: {
+ if (aspect > 1.0) { // width > height, take x as reference
+ drag_vector.y = -drag_vector.x/aspect;
+ } else { // height > width, take y as reference
+ drag_vector.x = -drag_vector.y*aspect;
+ }
+ } break;
+ case DRAG_BOTTOM_RIGHT:
+ case DRAG_TOP_LEFT: {
+ if (aspect > 1.0) { // width > height, take x as reference
+ drag_vector.y = drag_vector.x/aspect;
+ } else { // height > width, take y as reference
+ drag_vector.x = drag_vector.y*aspect;
+ }
+ } break;
+ default: {}
+ }
+ }
switch(drag) {
case DRAG_ALL: {
@@ -1540,19 +1598,11 @@ void CanvasItemEditor::_viewport_input_event(const InputEvent& p_event) {
} break;
case DRAG_BOTTOM_RIGHT: {
- if (uniform) {
- drag_vector.y=drag_vector.x;
- minsize.y=minsize.x;
- }
incend(begin.x,end.x,drag_vector.x,minsize.x,symmetric);
incend(begin.y,end.y,drag_vector.y,minsize.y,symmetric);
- } break;
+ } break;
case DRAG_TOP_LEFT: {
- if (uniform) {
- drag_vector.y=drag_vector.x;
- minsize.y=minsize.x;
- }
incbeg(begin.x,end.x,drag_vector.x,minsize.x,symmetric);
incbeg(begin.y,end.y,drag_vector.y,minsize.y,symmetric);
} break;
@@ -1568,20 +1618,12 @@ void CanvasItemEditor::_viewport_input_event(const InputEvent& p_event) {
} break;
case DRAG_TOP_RIGHT: {
- if (uniform) {
- drag_vector.x=-drag_vector.y;
- minsize.x=minsize.y;
- }
incbeg(begin.y,end.y,drag_vector.y,minsize.y,symmetric);
incend(begin.x,end.x,drag_vector.x,minsize.x,symmetric);
} break;
case DRAG_BOTTOM_LEFT: {
- if (uniform) {
- drag_vector.x=-drag_vector.y;
- minsize.x=minsize.y;
- }
incbeg(begin.x,end.x,drag_vector.x,minsize.x,symmetric);
incend(begin.y,end.y,drag_vector.y,minsize.y,symmetric);
} break;
@@ -1831,6 +1873,8 @@ void CanvasItemEditor::_viewport_draw() {
CanvasItem *single_item=NULL;
+ bool pivot_found=false;
+
for(Map<Node*,Object*>::Element *E=selection.front();E;E=E->next()) {
@@ -1872,7 +1916,7 @@ void CanvasItemEditor::_viewport_draw() {
viewport->draw_line(endpoints[i],endpoints[(i+1)%4],c,2);
}
- if (single && (tool==TOOL_SELECT || tool == TOOL_MOVE || tool == TOOL_ROTATE)) { //kind of sucks
+ if (single && (tool==TOOL_SELECT || tool == TOOL_MOVE || tool == TOOL_ROTATE || tool==TOOL_EDIT_PIVOT)) { //kind of sucks
if (canvas_item->cast_to<Node2D>()) {
@@ -1880,6 +1924,7 @@ void CanvasItemEditor::_viewport_draw() {
if (canvas_item->cast_to<Node2D>()->edit_has_pivot()) {
viewport->draw_texture(pivot,xform.get_origin()+(-pivot->get_size()/2).floor());
can_move_pivot=true;
+ pivot_found=true;
}
}
@@ -1914,6 +1959,7 @@ void CanvasItemEditor::_viewport_draw() {
//E->get().last_rect = rect;
}
+ pivot_button->set_disabled(!pivot_found);
VisualServer::get_singleton()->canvas_item_add_set_transform(ci,Matrix32());
@@ -2118,9 +2164,11 @@ void CanvasItemEditor::_notification(int p_what) {
}
select_button->set_icon( get_icon("ToolSelect","EditorIcons"));
+ list_select_button->set_icon( get_icon("ListSelect","EditorIcons"));
move_button->set_icon( get_icon("ToolMove","EditorIcons"));
rotate_button->set_icon( get_icon("ToolRotate","EditorIcons"));
pan_button->set_icon( get_icon("ToolPan", "EditorIcons"));
+ pivot_button->set_icon( get_icon("EditPivot", "EditorIcons"));
select_handle=get_icon("EditorHandle","EditorIcons");
lock_button->set_icon(get_icon("Lock","EditorIcons"));
unlock_button->set_icon(get_icon("Unlock","EditorIcons"));
@@ -2649,11 +2697,11 @@ void CanvasItemEditor::_popup_callback(int p_op) {
Node2D *n2d = canvas_item->cast_to<Node2D>();
if (key_pos)
- editor->get_animation_editor()->insert_node_value_key(n2d,"transform/pos",n2d->get_pos(),existing);
+ AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(n2d,"transform/pos",n2d->get_pos(),existing);
if (key_rot)
- editor->get_animation_editor()->insert_node_value_key(n2d,"transform/rot",Math::rad2deg(n2d->get_rot()),existing);
+ AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(n2d,"transform/rot",Math::rad2deg(n2d->get_rot()),existing);
if (key_scale)
- editor->get_animation_editor()->insert_node_value_key(n2d,"transform/scale",n2d->get_scale(),existing);
+ AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(n2d,"transform/scale",n2d->get_scale(),existing);
if (n2d->has_meta("_edit_bone_") && n2d->get_parent_item()) {
@@ -2681,11 +2729,11 @@ void CanvasItemEditor::_popup_callback(int p_op) {
for(List<Node2D*>::Element *F=ik_chain.front();F;F=F->next()) {
if (key_pos)
- editor->get_animation_editor()->insert_node_value_key(F->get(),"transform/pos",F->get()->get_pos(),existing);
+ AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(F->get(),"transform/pos",F->get()->get_pos(),existing);
if (key_rot)
- editor->get_animation_editor()->insert_node_value_key(F->get(),"transform/rot",Math::rad2deg(F->get()->get_rot()),existing);
+ AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(F->get(),"transform/rot",Math::rad2deg(F->get()->get_rot()),existing);
if (key_scale)
- editor->get_animation_editor()->insert_node_value_key(F->get(),"transform/scale",F->get()->get_scale(),existing);
+ AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(F->get(),"transform/scale",F->get()->get_scale(),existing);
}
@@ -2697,9 +2745,9 @@ void CanvasItemEditor::_popup_callback(int p_op) {
Control *ctrl = canvas_item->cast_to<Control>();
if (key_pos)
- editor->get_animation_editor()->insert_node_value_key(ctrl,"rect/pos",ctrl->get_pos(),existing);
+ AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(ctrl,"rect/pos",ctrl->get_pos(),existing);
if (key_scale)
- editor->get_animation_editor()->insert_node_value_key(ctrl,"rect/size",ctrl->get_size(),existing);
+ AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(ctrl,"rect/size",ctrl->get_size(),existing);
}
}
@@ -2821,7 +2869,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
if (key_pos)
ctrl->set_pos(Point2());
//if (key_scale)
- // editor->get_animation_editor()->insert_node_value_key(ctrl,"rect/size",ctrl->get_size());
+ // AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(ctrl,"rect/size",ctrl->get_size());
}
}
@@ -3155,7 +3203,8 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
hb->add_child(select_button);
select_button->connect("pressed",this,"_tool_select",make_binds(TOOL_SELECT));
select_button->set_pressed(true);
- select_button->set_tooltip("Select Mode (Q)\n"+keycode_get_string(KEY_MASK_CMD)+"Drag: Rotate\nAlt+Drag: Move\nPress 'v' to Change Pivot, 'Shift+v' to Drag Pivot (while moving).");
+ select_button->set_tooltip("Select Mode (Q)\n"+keycode_get_string(KEY_MASK_CMD)+"Drag: Rotate\nAlt+Drag: Move\nPress 'v' to Change Pivot, 'Shift+v' to Drag Pivot (while moving).\nAlt+RMB: Depth list selection");
+
move_button = memnew( ToolButton );
move_button->set_toggle_mode(true);
@@ -3171,6 +3220,18 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
hb->add_child(memnew(VSeparator));
+ list_select_button = memnew( ToolButton );
+ list_select_button->set_toggle_mode(true);
+ hb->add_child(list_select_button);
+ list_select_button->connect("pressed",this,"_tool_select",make_binds(TOOL_LIST_SELECT));
+ list_select_button->set_tooltip("Show a list of all objects at the position clicked\n(same as Alt+RMB in selet mode).");
+
+ pivot_button = memnew( ToolButton );
+ pivot_button->set_toggle_mode(true);
+ hb->add_child(pivot_button);
+ pivot_button->connect("pressed",this,"_tool_select",make_binds(TOOL_EDIT_PIVOT));
+ pivot_button->set_tooltip("Click to change object's rotation pivot");
+
pan_button = memnew( ToolButton );
pan_button->set_toggle_mode(true);
hb->add_child(pan_button);
@@ -3357,7 +3418,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
box_selecting=false;
//zoom=0.5;
singleton=this;
- editor->get_animation_editor()->connect("keying_changed",this,"_keying_changed");
+ AnimationPlayerEditor::singleton->get_key_editor()->connect("keying_changed",this,"_keying_changed");
set_process_unhandled_key_input(true);
can_move_pivot=false;
drag=DRAG_NONE;
diff --git a/tools/editor/plugins/canvas_item_editor_plugin.h b/tools/editor/plugins/canvas_item_editor_plugin.h
index b96d36f7dc..df24734fd7 100644
--- a/tools/editor/plugins/canvas_item_editor_plugin.h
+++ b/tools/editor/plugins/canvas_item_editor_plugin.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -67,8 +67,10 @@ class CanvasItemEditor : public VBoxContainer {
enum Tool {
TOOL_SELECT,
+ TOOL_LIST_SELECT,
TOOL_MOVE,
TOOL_ROTATE,
+ TOOL_EDIT_PIVOT,
TOOL_PAN,
TOOL_MAX
};
@@ -240,9 +242,11 @@ class CanvasItemEditor : public VBoxContainer {
List<PoseClipboard> pose_clipboard;
ToolButton *select_button;
+ ToolButton *list_select_button;
ToolButton *move_button;
ToolButton *rotate_button;
+ ToolButton *pivot_button;
ToolButton *pan_button;
ToolButton *lock_button;
@@ -264,6 +268,7 @@ class CanvasItemEditor : public VBoxContainer {
PopupMenu *selection_menu;
+
//PopupMenu *popup;
DragType drag;
Point2 drag_from;
@@ -304,11 +309,13 @@ class CanvasItemEditor : public VBoxContainer {
CanvasItem *ref_item;
+ void _edit_set_pivot(const Vector2& mouse_pos);
void _add_canvas_item(CanvasItem *p_canvas_item);
void _remove_canvas_item(CanvasItem *p_canvas_item);
void _clear_canvas_items();
void _visibility_changed(ObjectID p_canvas_item);
void _key_move(const Vector2& p_dir, bool p_snap, KeyMoveMODE p_move_mode);
+ void _list_select(const InputEventMouseButton& b);
DragType _find_drag_type(const Matrix32& p_xform, const Rect2& p_local_rect, const Point2& p_click, Vector2& r_point);
@@ -337,7 +344,7 @@ class CanvasItemEditor : public VBoxContainer {
CanvasItem *get_single_item();
int get_item_count();
- void _keying_changed(bool p_changed);
+ void _keying_changed();
void _unhandled_key_input(const InputEvent& p_ev);
diff --git a/tools/editor/plugins/collision_polygon_editor_plugin.cpp b/tools/editor/plugins/collision_polygon_editor_plugin.cpp
index 60683f4eda..d4198f3166 100644
--- a/tools/editor/plugins/collision_polygon_editor_plugin.cpp
+++ b/tools/editor/plugins/collision_polygon_editor_plugin.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/plugins/collision_polygon_editor_plugin.h b/tools/editor/plugins/collision_polygon_editor_plugin.h
index 20a0b3c3f6..45e287ef00 100644
--- a/tools/editor/plugins/collision_polygon_editor_plugin.h
+++ b/tools/editor/plugins/collision_polygon_editor_plugin.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/plugins/color_ramp_editor_plugin.cpp b/tools/editor/plugins/color_ramp_editor_plugin.cpp
index df50535402..42ff1b1de9 100644
--- a/tools/editor/plugins/color_ramp_editor_plugin.cpp
+++ b/tools/editor/plugins/color_ramp_editor_plugin.cpp
@@ -3,14 +3,20 @@
*/
#include "color_ramp_editor_plugin.h"
+#include "spatial_editor_plugin.h"
+#include "canvas_item_editor_plugin.h"
-ColorRampEditorPlugin::ColorRampEditorPlugin(EditorNode *p_node) {
+ColorRampEditorPlugin::ColorRampEditorPlugin(EditorNode *p_node, bool p_2d) {
editor=p_node;
ramp_editor = memnew( ColorRampEdit );
- add_custom_control(CONTAINER_CANVAS_EDITOR_BOTTOM,ramp_editor);
- //add_custom_control(CONTAINER_SPATIAL_EDITOR_BOTTOM,ramp_editor);
+ _2d=p_2d;
+ if (p_2d)
+ add_custom_control(CONTAINER_CANVAS_EDITOR_BOTTOM,ramp_editor);
+ else
+ add_custom_control(CONTAINER_SPATIAL_EDITOR_BOTTOM,ramp_editor);
+
ramp_editor->set_custom_minimum_size(Size2(100, 48));
ramp_editor->hide();
ramp_editor->connect("ramp_changed", this, "ramp_changed");
@@ -27,7 +33,10 @@ void ColorRampEditorPlugin::edit(Object *p_object) {
bool ColorRampEditorPlugin::handles(Object *p_object) const {
- return p_object->is_type("ColorRamp");
+ if (_2d)
+ return p_object->is_type("ColorRamp") && CanvasItemEditor::get_singleton()->is_visible() == true;
+ else
+ return p_object->is_type("ColorRamp") && SpatialEditor::get_singleton()->is_visible() == true;
}
void ColorRampEditorPlugin::make_visible(bool p_visible) {
diff --git a/tools/editor/plugins/color_ramp_editor_plugin.h b/tools/editor/plugins/color_ramp_editor_plugin.h
index e39a5d65fe..f07dbabeb3 100644
--- a/tools/editor/plugins/color_ramp_editor_plugin.h
+++ b/tools/editor/plugins/color_ramp_editor_plugin.h
@@ -13,6 +13,7 @@ class ColorRampEditorPlugin : public EditorPlugin {
OBJ_TYPE( ColorRampEditorPlugin, EditorPlugin );
+ bool _2d;
Ref<ColorRamp> color_ramp_ref;
ColorRampEdit *ramp_editor;
EditorNode *editor;
@@ -29,7 +30,7 @@ public:
virtual bool handles(Object *p_node) const;
virtual void make_visible(bool p_visible);
- ColorRampEditorPlugin(EditorNode *p_node);
+ ColorRampEditorPlugin(EditorNode *p_node, bool p_2d);
~ColorRampEditorPlugin();
};
diff --git a/tools/editor/plugins/control_editor_plugin.cpp b/tools/editor/plugins/control_editor_plugin.cpp
index 7348a69665..375622a89c 100644
--- a/tools/editor/plugins/control_editor_plugin.cpp
+++ b/tools/editor/plugins/control_editor_plugin.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/plugins/control_editor_plugin.h b/tools/editor/plugins/control_editor_plugin.h
index 074298d0df..94cffc8d8d 100644
--- a/tools/editor/plugins/control_editor_plugin.h
+++ b/tools/editor/plugins/control_editor_plugin.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/plugins/cube_grid_theme_editor_plugin.cpp b/tools/editor/plugins/cube_grid_theme_editor_plugin.cpp
index c118485083..c861a5841a 100644
--- a/tools/editor/plugins/cube_grid_theme_editor_plugin.cpp
+++ b/tools/editor/plugins/cube_grid_theme_editor_plugin.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/plugins/cube_grid_theme_editor_plugin.h b/tools/editor/plugins/cube_grid_theme_editor_plugin.h
index 583ddf6e14..72ee171e19 100644
--- a/tools/editor/plugins/cube_grid_theme_editor_plugin.h
+++ b/tools/editor/plugins/cube_grid_theme_editor_plugin.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/plugins/editor_preview_plugins.cpp b/tools/editor/plugins/editor_preview_plugins.cpp
index 5f52d4c3e7..f3b5272571 100644
--- a/tools/editor/plugins/editor_preview_plugins.cpp
+++ b/tools/editor/plugins/editor_preview_plugins.cpp
@@ -6,16 +6,30 @@
#include "scene/resources/material.h"
#include "scene/resources/sample.h"
#include "scene/resources/mesh.h"
+#include "scene/resources/bit_mask.h"
bool EditorTexturePreviewPlugin::handles(const String& p_type) const {
- return ObjectTypeDB::is_type(p_type,"ImageTexture");
+ return (ObjectTypeDB::is_type(p_type,"ImageTexture") || ObjectTypeDB::is_type(p_type, "AtlasTexture"));
}
Ref<Texture> EditorTexturePreviewPlugin::generate(const RES& p_from) {
- Ref<ImageTexture> tex =p_from;
- Image img = tex->get_data();
+ Image img;
+ Ref<AtlasTexture> atex = p_from;
+ if (atex.is_valid()) {
+ Ref<ImageTexture> tex = atex->get_atlas();
+ if (!tex.is_valid()) {
+ return Ref<Texture>();
+ }
+ Image atlas = tex->get_data();
+ img = atlas.get_rect(atex->get_region());
+ }
+ else {
+ Ref<ImageTexture> tex = p_from;
+ img = tex->get_data();
+ }
+
if (img.empty())
return Ref<Texture>();
@@ -58,6 +72,81 @@ EditorTexturePreviewPlugin::EditorTexturePreviewPlugin() {
}
+////////////////////////////////////////////////////////////////////////////
+
+bool EditorBitmapPreviewPlugin::handles(const String& p_type) const {
+
+ return ObjectTypeDB::is_type(p_type,"BitMap");
+}
+
+Ref<Texture> EditorBitmapPreviewPlugin::generate(const RES& p_from) {
+
+ Ref<BitMap> bm =p_from;
+
+ if (bm->get_size()==Size2()) {
+ return Ref<Texture>();
+ }
+
+ DVector<uint8_t> data;
+
+ data.resize(bm->get_size().width*bm->get_size().height);
+
+ {
+ DVector<uint8_t>::Write w=data.write();
+
+ for(int i=0;i<bm->get_size().width;i++) {
+ for(int j=0;j<bm->get_size().height;j++) {
+ if (bm->get_bit(Point2i(i,j))) {
+ w[j*bm->get_size().width+i]=255;
+ } else {
+ w[j*bm->get_size().width+i]=0;
+
+ }
+ }
+
+ }
+ }
+
+
+ Image img(bm->get_size().width,bm->get_size().height,0,Image::FORMAT_GRAYSCALE,data);
+
+ int thumbnail_size = EditorSettings::get_singleton()->get("file_dialog/thumbnail_size");
+ if (img.is_compressed()) {
+ if (img.decompress()!=OK)
+ return Ref<Texture>();
+ } else if (img.get_format()!=Image::FORMAT_RGB && img.get_format()!=Image::FORMAT_RGBA) {
+ img.convert(Image::FORMAT_RGBA);
+ }
+
+ int width,height;
+ if (img.get_width() > thumbnail_size && img.get_width() >= img.get_height()) {
+
+ width=thumbnail_size;
+ height = img.get_height() * thumbnail_size / img.get_width();
+ } else if (img.get_height() > thumbnail_size && img.get_height() >= img.get_width()) {
+
+ height=thumbnail_size;
+ width = img.get_width() * thumbnail_size / img.get_height();
+ } else {
+
+ width=img.get_width();
+ height=img.get_height();
+ }
+
+ img.resize(width,height);
+
+ Ref<ImageTexture> ptex = Ref<ImageTexture>( memnew( ImageTexture ));
+
+ ptex->create_from_image(img,0);
+ return ptex;
+
+}
+
+EditorBitmapPreviewPlugin::EditorBitmapPreviewPlugin() {
+
+
+}
+
///////////////////////////////////////////////////////////////////////////
diff --git a/tools/editor/plugins/editor_preview_plugins.h b/tools/editor/plugins/editor_preview_plugins.h
index 98071e2a0e..b3bfda8045 100644
--- a/tools/editor/plugins/editor_preview_plugins.h
+++ b/tools/editor/plugins/editor_preview_plugins.h
@@ -13,6 +13,17 @@ public:
};
+class EditorBitmapPreviewPlugin : public EditorResourcePreviewGenerator {
+public:
+
+ virtual bool handles(const String& p_type) const;
+ virtual Ref<Texture> generate(const RES& p_from);
+
+ EditorBitmapPreviewPlugin();
+};
+
+
+
class EditorPackedScenePreviewPlugin : public EditorResourcePreviewGenerator {
Ref<Texture> _gen_from_imd(Ref<ResourceImportMetadata> p_imd);
diff --git a/tools/editor/plugins/item_list_editor_plugin.cpp b/tools/editor/plugins/item_list_editor_plugin.cpp
index fa261edea3..6f0db959ba 100644
--- a/tools/editor/plugins/item_list_editor_plugin.cpp
+++ b/tools/editor/plugins/item_list_editor_plugin.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -30,7 +30,6 @@
#include "io/resource_loader.h"
-
bool ItemListPlugin::_set(const StringName& p_name, const Variant& p_value) {
String name = p_name;
@@ -45,12 +44,10 @@ bool ItemListPlugin::_set(const StringName& p_name, const Variant& p_value) {
set_item_checkable(idx,p_value);
else if (what=="checked")
set_item_checked(idx,p_value);
- else if (what=="enabled")
- set_item_enabled(idx,p_value);
- else if (what=="accel")
- set_item_accel(idx,p_value);
else if (what=="id")
set_item_id(idx,p_value);
+ else if (what=="enabled")
+ set_item_enabled(idx,p_value);
else if (what=="separator")
set_item_separator(idx,p_value);
else
@@ -60,6 +57,7 @@ bool ItemListPlugin::_set(const StringName& p_name, const Variant& p_value) {
}
bool ItemListPlugin::_get(const StringName& p_name,Variant &r_ret) const {
+
String name = p_name;
int idx = name.get_slice("/",0).to_int();
String what=name.get_slice("/",1);
@@ -72,12 +70,10 @@ bool ItemListPlugin::_get(const StringName& p_name,Variant &r_ret) const {
r_ret=is_item_checkable(idx);
else if (what=="checked")
r_ret=is_item_checked(idx);
- else if (what=="enabled")
- r_ret=is_item_enabled(idx);
- else if (what=="accel")
- r_ret=get_item_accel(idx);
else if (what=="id")
r_ret=get_item_id(idx);
+ else if (what=="enabled")
+ r_ret=is_item_enabled(idx);
else if (what=="separator")
r_ret=is_item_separator(idx);
else
@@ -93,66 +89,119 @@ void ItemListPlugin::_get_property_list( List<PropertyInfo> *p_list) const {
p_list->push_back( PropertyInfo(Variant::STRING,base+"text") );
p_list->push_back( PropertyInfo(Variant::OBJECT,base+"icon",PROPERTY_HINT_RESOURCE_TYPE,"Texture") );
- if (get_flags()&FLAG_CHECKABLE) {
+ int flags = get_flags();
+
+ if (flags&FLAG_CHECKABLE) {
p_list->push_back( PropertyInfo(Variant::BOOL,base+"checkable") );
p_list->push_back( PropertyInfo(Variant::BOOL,base+"checked") );
-
}
- if (get_flags()&FLAG_ENABLE) {
+ if (flags&FLAG_ID)
+ p_list->push_back( PropertyInfo(Variant::INT,base+"id",PROPERTY_HINT_RANGE,"-1,4096") );
+
+ if (flags&FLAG_ENABLE)
p_list->push_back( PropertyInfo(Variant::BOOL,base+"enabled") );
- }
- if (get_flags()&FLAG_ACCEL) {
+ if (flags&FLAG_SEPARATOR)
+ p_list->push_back( PropertyInfo(Variant::BOOL,base+"separator") );
+ }
+}
- p_list->push_back( PropertyInfo(Variant::INT,base+"accel",PROPERTY_HINT_KEY_ACCEL) );
+///////////////////////////////////////////////////////////////
+///////////////////////// PLUGINS /////////////////////////////
+///////////////////////////////////////////////////////////////
- }
- if (get_flags()&FLAG_ID) {
+void ItemListOptionButtonPlugin::set_object(Object *p_object) {
- p_list->push_back( PropertyInfo(Variant::INT,base+"id",PROPERTY_HINT_RANGE,"-1,4096") );
+ ob = p_object->cast_to<OptionButton>();
+}
- }
- if (get_flags()&FLAG_SEPARATOR) {
+bool ItemListOptionButtonPlugin::handles(Object *p_object) const {
- p_list->push_back( PropertyInfo(Variant::BOOL,base+"separator") );
+ return p_object->is_type("OptionButton");
+}
- }
- }
+int ItemListOptionButtonPlugin::get_flags() const {
+
+ return FLAG_ICON|FLAG_ID|FLAG_ENABLE;
}
-void ItemListEditor::_node_removed(Node *p_node) {
+void ItemListOptionButtonPlugin::add_item() {
- if(p_node==item_list) {
- item_list=NULL;
- hide();
- dialog->hide();
- }
+ ob->add_item( "Item "+itos(ob->get_item_count()));
+ _change_notify();
+}
+int ItemListOptionButtonPlugin::get_item_count() const {
+ return ob->get_item_count();
}
-void ItemListEditor::_delete_pressed() {
+void ItemListOptionButtonPlugin::erase(int p_idx) {
- String p = prop_editor->get_selected_path();
+ ob->remove_item(p_idx);
+ _change_notify();
+}
- if (p.find("/")!=-1) {
+ItemListOptionButtonPlugin::ItemListOptionButtonPlugin() {
- if (selected_idx<0 || selected_idx>=item_plugins.size())
- return;
+ ob=NULL;
+}
- item_plugins[selected_idx]->erase(p.get_slice("/",0).to_int());;
- }
+///////////////////////////////////////////////////////////////
+
+void ItemListPopupMenuPlugin::set_object(Object *p_object) {
+ if (p_object->is_type("MenuButton"))
+ pp = p_object->cast_to<MenuButton>()->get_popup();
+ else
+ pp = p_object->cast_to<PopupMenu>();
}
-void ItemListEditor::_add_pressed() {
+bool ItemListPopupMenuPlugin::handles(Object *p_object) const {
- if (selected_idx<0 || selected_idx>=item_plugins.size())
- return;
+ return p_object->is_type("PopupMenu") || p_object->is_type("MenuButton");
+}
- item_plugins[selected_idx]->add_item();
+int ItemListPopupMenuPlugin::get_flags() const {
+
+ return FLAG_ICON|FLAG_CHECKABLE|FLAG_ID|FLAG_ENABLE|FLAG_SEPARATOR;
+}
+
+void ItemListPopupMenuPlugin::add_item() {
+
+ pp->add_item( "Item "+itos(pp->get_item_count()));
+ _change_notify();
+}
+
+int ItemListPopupMenuPlugin::get_item_count() const {
+
+ return pp->get_item_count();
+}
+
+void ItemListPopupMenuPlugin::erase(int p_idx) {
+
+ pp->remove_item(p_idx);
+ _change_notify();
+}
+
+ItemListPopupMenuPlugin::ItemListPopupMenuPlugin() {
+
+ pp=NULL;
+}
+
+///////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////
+
+void ItemListEditor::_node_removed(Node *p_node) {
+
+ if(p_node==item_list) {
+ item_list=NULL;
+ hide();
+ dialog->hide();
+ }
}
void ItemListEditor::_notification(int p_notification) {
@@ -160,57 +209,73 @@ void ItemListEditor::_notification(int p_notification) {
if (p_notification==NOTIFICATION_ENTER_TREE) {
add_button->set_icon(get_icon("Add","EditorIcons"));
- del_button->set_icon(get_icon("Del","EditorIcons"));
+ del_button->set_icon(get_icon("Remove","EditorIcons"));
}
}
+void ItemListEditor::_add_pressed() {
-void ItemListEditor::_menu_option(int p_option) {
+ if (selected_idx==-1)
+ return;
+ item_plugins[selected_idx]->add_item();
+}
- switch(p_option) {
+void ItemListEditor::_delete_pressed() {
- case MENU_EDIT_ITEMS: {
+ TreeItem *ti = tree->get_selected();
- dialog->popup_centered_ratio();
- } break;
- }
+ if (!ti)
+ return;
+
+ if (ti->get_parent()!=tree->get_root())
+ return;
+
+ int idx = ti->get_text(0).to_int();
+
+ if (selected_idx==-1)
+ return;
+
+ item_plugins[selected_idx]->erase(idx);
}
+void ItemListEditor::_edit_items() {
+
+ dialog->popup_centered(Vector2(300, 400));
+}
void ItemListEditor::edit(Node *p_item_list) {
item_list=p_item_list;
+ if (!item_list) {
+ selected_idx=-1;
+ property_editor->edit(NULL);
+ return;
+ }
+
for(int i=0;i<item_plugins.size();i++) {
if (item_plugins[i]->handles(p_item_list)) {
item_plugins[i]->set_object(p_item_list);
- prop_editor->edit(item_plugins[i]);
+ property_editor->edit(item_plugins[i]);
+
+ if (has_icon(item_list->get_type(), "EditorIcons"))
+ toolbar_button->set_icon(get_icon(item_list->get_type(), "EditorIcons"));
+ else
+ toolbar_button->set_icon(Ref<Texture>());
+
selected_idx=i;
return;
}
}
selected_idx=-1;
-
- prop_editor->edit(NULL);
-
-}
-
-
-void ItemListEditor::_bind_methods() {
-
- ObjectTypeDB::bind_method("_menu_option",&ItemListEditor::_menu_option);
- ObjectTypeDB::bind_method("_add_button",&ItemListEditor::_add_pressed);
- ObjectTypeDB::bind_method("_delete_button",&ItemListEditor::_delete_pressed);
-
- //ObjectTypeDB::bind_method("_populate",&ItemListEditor::_populate);
-
+ property_editor->edit(NULL);
}
bool ItemListEditor::handles(Object *p_object) const {
- return false;
+
for(int i=0;i<item_plugins.size();i++) {
if (item_plugins[i]->handles(p_object)) {
return true;
@@ -218,57 +283,65 @@ bool ItemListEditor::handles(Object *p_object) const {
}
return false;
+}
+void ItemListEditor::_bind_methods() {
+
+ ObjectTypeDB::bind_method("_edit_items",&ItemListEditor::_edit_items);
+ ObjectTypeDB::bind_method("_add_button",&ItemListEditor::_add_pressed);
+ ObjectTypeDB::bind_method("_delete_button",&ItemListEditor::_delete_pressed);
}
+
ItemListEditor::ItemListEditor() {
selected_idx=-1;
- options = memnew( MenuButton );
- add_child(options);
- options->set_area_as_parent_rect();
- options->set_text("Items");
- options->get_popup()->add_item("Edit Items",MENU_EDIT_ITEMS);
- //options->get_popup()->add_item("Clear",MENU_CLEAR);
+ add_child( memnew( VSeparator ) );
- options->get_popup()->connect("item_pressed", this,"_menu_option");
+ toolbar_button = memnew( ToolButton );
+ toolbar_button->set_text("Items");
+ add_child(toolbar_button);
+ toolbar_button->connect("pressed",this,"_edit_items");
dialog = memnew( AcceptDialog );
+ dialog->set_title("Item List Editor");
add_child( dialog );
-
+ VBoxContainer *vbc = memnew( VBoxContainer );
+ dialog->add_child(vbc);
+ dialog->set_child_rect(vbc);
HBoxContainer *hbc = memnew( HBoxContainer );
-
- dialog->add_child(hbc);
- dialog->set_child_rect(hbc);
-
- prop_editor = memnew( PropertyEditor );
-
- hbc->add_child(prop_editor);
- prop_editor->set_h_size_flags(SIZE_EXPAND_FILL);
-
- VBoxContainer *vbc = memnew( VBoxContainer );
- hbc->add_child(vbc);
+ hbc->set_h_size_flags(SIZE_EXPAND_FILL);
+ vbc->add_child(hbc);
add_button = memnew( Button );
- //add_button->set_text("Add");
+ add_button->set_text("Add");
+ hbc->add_child(add_button);
add_button->connect("pressed",this,"_add_button");
- vbc->add_child(add_button);
+
+ hbc->add_spacer();
del_button = memnew( Button );
- //del_button->set_text("Del");
+ del_button->set_text("Delete");
+ hbc->add_child(del_button);
del_button->connect("pressed",this,"_delete_button");
- vbc->add_child(del_button);
- dialog->set_title("Item List");
- prop_editor->hide_top_label();
+ property_editor = memnew( PropertyEditor );
+ property_editor->hide_top_label();
+ property_editor->set_subsection_selectable(true);
+ vbc->add_child(property_editor);
+ property_editor->set_v_size_flags(SIZE_EXPAND_FILL);
+ tree = property_editor->get_scene_tree();
+}
+ItemListEditor::~ItemListEditor() {
+ for(int i=0;i<item_plugins.size();i++)
+ memdelete( item_plugins[i] );
}
-
void ItemListEditorPlugin::edit(Object *p_object) {
item_list_editor->edit(p_object->cast_to<Node>());
@@ -288,127 +361,19 @@ void ItemListEditorPlugin::make_visible(bool p_visible) {
item_list_editor->hide();
item_list_editor->edit(NULL);
}
-
-}
-
-
-ItemListEditor::~ItemListEditor() {
-
- for(int i=0;i<item_plugins.size();i++)
- memdelete( item_plugins[i] );
}
-///////////////////////// PLUGINS /////////////////////////////
-///////////////////////// PLUGINS /////////////////////////////
-///////////////////////// PLUGINS /////////////////////////////
-///////////////////////// PLUGINS /////////////////////////////
-///////////////////////// PLUGINS /////////////////////////////
-
-
-class ItemListOptionButtonPlugin : public ItemListPlugin {
-
- OBJ_TYPE(ItemListOptionButtonPlugin,ItemListPlugin);
-
- OptionButton *ob;
-public:
-
- virtual void set_object(Object *p_object) { ob = p_object->cast_to<OptionButton>(); }
-
- virtual bool handles(Object *p_object) const { return p_object->cast_to<OptionButton>()!=NULL; }
-
- virtual int get_flags() const { return FLAG_ICON|FLAG_ID|FLAG_ENABLE; }
-
- virtual void set_item_text(int p_idx,const String& p_text){ ob->set_item_text(p_idx,p_text);}
- virtual void set_item_icon(int p_idx,const Ref<Texture>& p_tex){ ob->set_item_icon(p_idx,p_tex);}
- virtual void set_item_enabled(int p_idx,int p_enabled){ ob->set_item_disabled(p_idx,!p_enabled);}
- virtual void set_item_id(int p_idx,int p_id){ ob->set_item_ID(p_idx,p_id);}
-
-
- virtual String get_item_text(int p_idx) const{ return ob->get_item_text(p_idx); };
- virtual Ref<Texture> get_item_icon(int p_idx) const{ return ob->get_item_icon(p_idx); };
- virtual bool is_item_enabled(int p_idx) const{ return !ob->is_item_disabled(p_idx); };
- virtual int get_item_id(int p_idx) const{ return ob->get_item_ID(p_idx); };
-
- virtual void add_item() { ob->add_item( "New Item "+itos(ob->get_item_count())); _change_notify();}
- virtual int get_item_count() const { return ob->get_item_count(); }
- virtual void erase(int p_idx) { ob->remove_item(p_idx); _change_notify();}
-
-
- ItemListOptionButtonPlugin() { ob=NULL; }
-};
-
-class ItemListPopupMenuPlugin : public ItemListPlugin {
-
- OBJ_TYPE(ItemListPopupMenuPlugin,ItemListPlugin);
-
- PopupMenu *pp;
-public:
-
- virtual void set_object(Object *p_object) {
- if (p_object->cast_to<MenuButton>())
- pp = p_object->cast_to<MenuButton>()->get_popup();
- else
- pp = p_object->cast_to<PopupMenu>();
- }
-
- virtual bool handles(Object *p_object) const { return p_object->cast_to<PopupMenu>()!=NULL || p_object->cast_to<MenuButton>()!=NULL; }
-
- virtual int get_flags() const { return FLAG_ICON|FLAG_ID|FLAG_ENABLE|FLAG_CHECKABLE|FLAG_SEPARATOR|FLAG_ACCEL; }
-
- virtual void set_item_text(int p_idx,const String& p_text){ pp->set_item_text(p_idx,p_text); }
- virtual void set_item_icon(int p_idx,const Ref<Texture>& p_tex){ pp->set_item_icon(p_idx,p_tex);}
- virtual void set_item_checkable(int p_idx,bool p_check){ pp->set_item_as_checkable(p_idx,p_check);}
- virtual void set_item_checked(int p_idx,bool p_checked){ pp->set_item_checked(p_idx,p_checked);}
- virtual void set_item_accel(int p_idx,int p_accel){ pp->set_item_accelerator(p_idx,p_accel);}
- virtual void set_item_enabled(int p_idx,int p_enabled){ pp->set_item_disabled(p_idx,!p_enabled);}
- virtual void set_item_id(int p_idx,int p_id){ pp->set_item_ID(p_idx,p_idx);}
- virtual void set_item_separator(int p_idx,bool p_separator){ pp->set_item_as_separator(p_idx,p_separator);}
-
-
- virtual String get_item_text(int p_idx) const{ return pp->get_item_text(p_idx); };
- virtual Ref<Texture> get_item_icon(int p_idx) const{ return pp->get_item_icon(p_idx); };
- virtual bool is_item_checkable(int p_idx) const{ return pp->is_item_checkable(p_idx); };
- virtual bool is_item_checked(int p_idx) const{ return pp->is_item_checked(p_idx); };
- virtual int get_item_accel(int p_idx) const{ return pp->get_item_accelerator(p_idx); };
- virtual bool is_item_enabled(int p_idx) const{ return !pp->is_item_disabled(p_idx); };
- virtual int get_item_id(int p_idx) const{ return pp->get_item_ID(p_idx); };
- virtual bool is_item_separator(int p_idx) const{ return pp->is_item_separator(p_idx); };
-
-
-
- virtual void add_item() { pp->add_item( "New Item "+itos(pp->get_item_count())); _change_notify();}
- virtual int get_item_count() const { return pp->get_item_count(); }
- virtual void erase(int p_idx) { pp->remove_item(p_idx); _change_notify();}
-
-
- ItemListPopupMenuPlugin() { pp=NULL; }
-};
-
-
-
-
-
-
ItemListEditorPlugin::ItemListEditorPlugin(EditorNode *p_node) {
editor=p_node;
item_list_editor = memnew( ItemListEditor );
- editor->get_viewport()->add_child(item_list_editor);
-
-// item_list_editor->set_anchor(MARGIN_LEFT,Control::ANCHOR_END);
-// item_list_editor->set_anchor(MARGIN_RIGHT,Control::ANCHOR_END);
- item_list_editor->set_margin(MARGIN_LEFT,180);
- item_list_editor->set_margin(MARGIN_RIGHT,230);
- item_list_editor->set_margin(MARGIN_TOP,0);
- item_list_editor->set_margin(MARGIN_BOTTOM,10);
-
+ CanvasItemEditor::get_singleton()->add_control_to_menu_panel(item_list_editor);
item_list_editor->hide();
- item_list_editor->add_plugin( memnew( ItemListOptionButtonPlugin) );
- item_list_editor->add_plugin( memnew( ItemListPopupMenuPlugin) );
+ item_list_editor->add_plugin( memnew( ItemListOptionButtonPlugin ) );
+ item_list_editor->add_plugin( memnew( ItemListPopupMenuPlugin ) );
}
-
ItemListEditorPlugin::~ItemListEditorPlugin()
{
}
diff --git a/tools/editor/plugins/item_list_editor_plugin.h b/tools/editor/plugins/item_list_editor_plugin.h
index 351dbb800d..95d316b199 100644
--- a/tools/editor/plugins/item_list_editor_plugin.h
+++ b/tools/editor/plugins/item_list_editor_plugin.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -31,10 +31,11 @@
#include "tools/editor/editor_plugin.h"
#include "tools/editor/editor_node.h"
+#include "canvas_item_editor_plugin.h"
+
#include "scene/gui/option_button.h"
#include "scene/gui/menu_button.h"
#include "scene/gui/popup_menu.h"
-#include "scene/gui/spin_box.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
@@ -51,43 +52,42 @@ protected:
bool _get(const StringName& p_name,Variant &r_ret) const;
void _get_property_list( List<PropertyInfo> *p_list) const;
-
public:
enum Flags {
FLAG_ICON=1,
FLAG_CHECKABLE=2,
- FLAG_ACCEL=4,
- FLAG_ID=8,
- FLAG_ENABLE=16,
- FLAG_SEPARATOR=32
+ FLAG_ID=4,
+ FLAG_ENABLE=8,
+ FLAG_SEPARATOR=16
};
virtual void set_object(Object *p_object)=0;
-
virtual bool handles(Object *p_object) const=0;
virtual int get_flags() const=0;
- virtual void set_item_text(int p_idx,const String& p_text){}
- virtual void set_item_icon(int p_idx,const Ref<Texture>& p_tex){}
- virtual void set_item_checkable(int p_idx,bool p_check){}
- virtual void set_item_checked(int p_idx,bool p_checked){}
- virtual void set_item_accel(int p_idx,int p_accel){}
- virtual void set_item_enabled(int p_idx,int p_enabled){}
- virtual void set_item_id(int p_idx,int p_id){}
- virtual void set_item_separator(int p_idx,bool p_separator){}
-
-
+ virtual void set_item_text(int p_idx, const String& p_text) {}
virtual String get_item_text(int p_idx) const{ return ""; };
+
+ virtual void set_item_icon(int p_idx, const Ref<Texture>& p_tex) {}
virtual Ref<Texture> get_item_icon(int p_idx) const{ return Ref<Texture>(); };
+
+ virtual void set_item_checkable(int p_idx, bool p_check) {}
virtual bool is_item_checkable(int p_idx) const{ return false; };
+
+ virtual void set_item_checked(int p_idx, bool p_checked) {}
virtual bool is_item_checked(int p_idx) const{ return false; };
- virtual int get_item_accel(int p_idx) const{ return 0; };
+
+ virtual void set_item_enabled(int p_idx, int p_enabled) {}
virtual bool is_item_enabled(int p_idx) const{ return false; };
+
+ virtual void set_item_id(int p_idx, int p_id) {}
virtual int get_item_id(int p_idx) const{ return -1; };
- virtual bool is_item_separator(int p_idx) const{ return false; };
+
+ virtual void set_item_separator(int p_idx, bool p_separator) {}
+ virtual bool is_item_separator(int p_idx) const { return false; };
virtual void add_item()=0;
virtual int get_item_count() const=0;
@@ -96,41 +96,107 @@ public:
ItemListPlugin() {}
};
-class ItemListEditor : public Control {
+///////////////////////////////////////////////////////////////
- OBJ_TYPE(ItemListEditor, Control );
+class ItemListOptionButtonPlugin : public ItemListPlugin {
- Node *item_list;
+ OBJ_TYPE(ItemListOptionButtonPlugin,ItemListPlugin);
- enum {
+ OptionButton *ob;
+public:
- MENU_EDIT_ITEMS,
- MENU_CLEAR
- };
+ virtual void set_object(Object *p_object);
+ virtual bool handles(Object *p_object) const;
+ virtual int get_flags() const;
- AcceptDialog *dialog;
+ virtual void set_item_text(int p_idx, const String& p_text) { ob->set_item_text(p_idx,p_text); }
+ virtual String get_item_text(int p_idx) const { return ob->get_item_text(p_idx); }
- PropertyEditor *prop_editor;
+ virtual void set_item_icon(int p_idx, const Ref<Texture>& p_tex) { ob->set_item_icon(p_idx, p_tex); }
+ virtual Ref<Texture> get_item_icon(int p_idx) const { return ob->get_item_icon(p_idx); }
- MenuButton * options;
- int selected_idx;
+ virtual void set_item_enabled(int p_idx, int p_enabled) { ob->set_item_disabled(p_idx, !p_enabled); }
+ virtual bool is_item_enabled(int p_idx) const { return !ob->is_item_disabled(p_idx); }
+
+ virtual void set_item_id(int p_idx, int p_id) { ob->set_item_ID(p_idx,p_id); }
+ virtual int get_item_id(int p_idx) const { return ob->get_item_ID(p_idx); }
+
+ virtual void add_item();
+ virtual int get_item_count() const;
+ virtual void erase(int p_idx);
+
+ ItemListOptionButtonPlugin();
+};
+
+class ItemListPopupMenuPlugin : public ItemListPlugin {
+
+ OBJ_TYPE(ItemListPopupMenuPlugin,ItemListPlugin);
+
+ PopupMenu *pp;
+public:
+
+ virtual void set_object(Object *p_object);
+ virtual bool handles(Object *p_object) const;
+ virtual int get_flags() const;
+ virtual void set_item_text(int p_idx, const String& p_text) { pp->set_item_text(p_idx,p_text); }
+ virtual String get_item_text(int p_idx) const { return pp->get_item_text(p_idx); }
+
+ virtual void set_item_icon(int p_idx, const Ref<Texture>& p_tex) { pp->set_item_icon(p_idx,p_tex); }
+ virtual Ref<Texture> get_item_icon(int p_idx) const { return pp->get_item_icon(p_idx); }
+
+ virtual void set_item_checkable(int p_idx, bool p_check) { pp->set_item_as_checkable(p_idx,p_check); }
+ virtual bool is_item_checkable(int p_idx) const { return pp->is_item_checkable(p_idx); }
+
+ virtual void set_item_checked(int p_idx, bool p_checked) { pp->set_item_checked(p_idx,p_checked); }
+ virtual bool is_item_checked(int p_idx) const { return pp->is_item_checked(p_idx); }
+
+ virtual void set_item_enabled(int p_idx, int p_enabled) { pp->set_item_disabled(p_idx,!p_enabled); }
+ virtual bool is_item_enabled(int p_idx) const { return !pp->is_item_disabled(p_idx); }
+
+ virtual void set_item_id(int p_idx, int p_id) { pp->set_item_ID(p_idx,p_idx); }
+ virtual int get_item_id(int p_idx) const { return pp->get_item_ID(p_idx); }
+
+ virtual void set_item_separator(int p_idx, bool p_separator) { pp->set_item_as_separator(p_idx,p_separator); }
+ virtual bool is_item_separator(int p_idx) const { return pp->is_item_separator(p_idx); }
+
+ virtual void add_item();
+ virtual int get_item_count() const;
+ virtual void erase(int p_idx);
+
+ ItemListPopupMenuPlugin();
+};
+
+///////////////////////////////////////////////////////////////
+
+class ItemListEditor : public HBoxContainer {
+
+ OBJ_TYPE(ItemListEditor,HBoxContainer);
+
+ Node *item_list;
+
+ ToolButton *toolbar_button;
+
+ AcceptDialog *dialog;
+ PropertyEditor *property_editor;
+ Tree *tree;
Button *add_button;
Button *del_button;
-
-// FileDialog *emission_file_dialog;
- void _menu_option(int);
+ int selected_idx;
Vector<ItemListPlugin*> item_plugins;
- void _node_removed(Node *p_node);
+ void _edit_items();
+
void _add_pressed();
void _delete_pressed();
+
+ void _node_removed(Node *p_node);
+
protected:
void _notification(int p_notification);
-
static void _bind_methods();
public:
@@ -143,7 +209,7 @@ public:
class ItemListEditorPlugin : public EditorPlugin {
- OBJ_TYPE( ItemListEditorPlugin, EditorPlugin );
+ OBJ_TYPE(ItemListEditorPlugin,EditorPlugin);
ItemListEditor *item_list_editor;
EditorNode *editor;
diff --git a/tools/editor/plugins/mesh_editor_plugin.cpp b/tools/editor/plugins/mesh_editor_plugin.cpp
index cea774f94b..5314529a23 100644
--- a/tools/editor/plugins/mesh_editor_plugin.cpp
+++ b/tools/editor/plugins/mesh_editor_plugin.cpp
@@ -1,13 +1,8 @@
#include "mesh_editor_plugin.h"
-#include "tools/editor/editor_plugin.h"
-#include "tools/editor/editor_node.h"
-#include "scene/3d/mesh_instance.h"
#include "scene/3d/physics_body.h"
#include "scene/3d/body_shape.h"
-#include "scene/gui/spin_box.h"
#include "scene/gui/box_container.h"
-#include "scene/3d/mesh_instance.h"
#include "scene/3d/navigation_mesh.h"
#include "spatial_editor_plugin.h"
@@ -38,92 +33,106 @@ void MeshInstanceEditor::_menu_option(int p_option) {
}
switch(p_option) {
- case MENU_OPTION_CREATE_STATIC_TRIMESH_BODY: {
+ case MENU_OPTION_CREATE_STATIC_TRIMESH_BODY:
+ case MENU_OPTION_CREATE_STATIC_CONVEX_BODY: {
- Ref<Shape> shape = mesh->create_trimesh_shape();
- if (shape.is_null())
- return;
- StaticBody *body = memnew( StaticBody );
- CollisionShape *cshape = memnew( CollisionShape );
- cshape->set_shape(shape);
- body->add_child(cshape);
- Node *owner = node==get_tree()->get_edited_scene_root() ? node : node->get_owner();
+ bool trimesh_shape = (p_option==MENU_OPTION_CREATE_STATIC_TRIMESH_BODY);
+ EditorSelection *editor_selection = EditorNode::get_singleton()->get_editor_selection();
UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
- ur->create_action("Create Static Trimesh");
- ur->add_do_method(node,"add_child",body);
- ur->add_do_method(body,"set_owner",owner);
- ur->add_do_method(cshape,"set_owner",owner);
- ur->add_do_reference(body);
- ur->add_undo_method(node,"remove_child",body);
- ur->commit_action();
- } break;
- case MENU_OPTION_CREATE_STATIC_CONVEX_BODY: {
+ List<Node*> selection = editor_selection->get_selected_node_list();
- Ref<Shape> shape = mesh->create_convex_shape();
- if (shape.is_null())
- return;
- StaticBody *body = memnew( StaticBody );
- CollisionShape *cshape = memnew( CollisionShape );
- cshape->set_shape(shape);
- body->add_child(cshape);
- Node *owner = node==get_tree()->get_edited_scene_root() ? node : node->get_owner();
+ if (selection.empty()) {
+ Ref<Shape> shape = trimesh_shape ? mesh->create_trimesh_shape() : mesh->create_convex_shape();
+ if (shape.is_null())
+ return;
- UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
- ur->create_action("Create Static Trimesh");
- ur->add_do_method(node,"add_child",body);
- ur->add_do_method(body,"set_owner",owner);
- ur->add_do_method(cshape,"set_owner",owner);
- ur->add_do_reference(body);
- ur->add_undo_method(node,"remove_child",body);
- ur->commit_action();
+ CollisionShape *cshape = memnew( CollisionShape );
+ cshape->set_shape(shape);
+ StaticBody *body = memnew( StaticBody );
+ body->add_child(cshape);
- } break;
- case MENU_OPTION_CREATE_TRIMESH_COLLISION_SHAPE: {
+ Node *owner = node==get_tree()->get_edited_scene_root() ? node : node->get_owner();
+ if (trimesh_shape)
+ ur->create_action("Create Static Trimesh Body");
+ else
+ ur->create_action("Create Static Convex Body");
- if (node==get_tree()->get_edited_scene_root()) {
- err_dialog->set_text("This doesn't work on scene root!");
- err_dialog->popup_centered_minsize();
+ ur->add_do_method(node,"add_child",body);
+ ur->add_do_method(body,"set_owner",owner);
+ ur->add_do_method(cshape,"set_owner",owner);
+ ur->add_do_reference(body);
+ ur->add_undo_method(node,"remove_child",body);
+ ur->commit_action();
return;
}
- Ref<Shape> shape = mesh->create_trimesh_shape();
- if (shape.is_null())
- return;
- CollisionShape *cshape = memnew( CollisionShape );
- cshape->set_shape(shape);
- Node *owner = node->get_owner();
+ if (trimesh_shape)
+ ur->create_action("Create Static Trimesh Body");
+ else
+ ur->create_action("Create Static Convex Body");
+
+ for (List<Node*>::Element *E=selection.front();E;E=E->next()) {
+
+ MeshInstance *instance = E->get()->cast_to<MeshInstance>();
+ if (!instance)
+ continue;
+
+ Ref<Mesh> m = instance->get_mesh();
+ if (m.is_null())
+ continue;
+
+ Ref<Shape> shape = trimesh_shape ? m->create_trimesh_shape() : m->create_convex_shape();
+ if (shape.is_null())
+ continue;
+
+ CollisionShape *cshape = memnew( CollisionShape );
+ cshape->set_shape(shape);
+ StaticBody *body = memnew( StaticBody );
+ body->add_child(cshape);
+
+ Node *owner = instance==get_tree()->get_edited_scene_root() ? instance : instance->get_owner();
+
+ ur->add_do_method(instance,"add_child",body);
+ ur->add_do_method(body,"set_owner",owner);
+ ur->add_do_method(cshape,"set_owner",owner);
+ ur->add_do_reference(body);
+ ur->add_undo_method(instance,"remove_child",body);
+ }
- UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
- ur->create_action("Create Static Trimesh");
- ur->add_do_method(node->get_parent(),"add_child",cshape);
- ur->add_do_method(node->get_parent(),"move_child",cshape,node->get_index()+1);
- ur->add_do_method(cshape,"set_owner",owner);
- ur->add_do_reference(cshape);
- ur->add_undo_method(node->get_parent(),"remove_child",cshape);
ur->commit_action();
} break;
- case MENU_OPTION_CREATE_CONVEX_COLLISION_SHAPE: {
+ case MENU_OPTION_CREATE_TRIMESH_COLLISION_SHAPE:
+ case MENU_OPTION_CREATE_CONVEX_COLLISION_SHAPE: {
if (node==get_tree()->get_edited_scene_root()) {
err_dialog->set_text("This doesn't work on scene root!");
err_dialog->popup_centered_minsize();
return;
}
- Ref<Shape> shape = mesh->create_convex_shape();
+
+ bool trimesh_shape = (p_option==MENU_OPTION_CREATE_TRIMESH_COLLISION_SHAPE);
+
+ Ref<Shape> shape = trimesh_shape ? mesh->create_trimesh_shape() : mesh->create_convex_shape();
if (shape.is_null())
return;
+
CollisionShape *cshape = memnew( CollisionShape );
cshape->set_shape(shape);
Node *owner = node->get_owner();
UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
- ur->create_action("Create Static Trimesh");
+
+ if (trimesh_shape)
+ ur->create_action("Create Trimesh Shape");
+ else
+ ur->create_action("Create Convex Shape");
+
ur->add_do_method(node->get_parent(),"add_child",cshape);
ur->add_do_method(node->get_parent(),"move_child",cshape,node->get_index()+1);
ur->add_do_method(cshape,"set_owner",owner);
@@ -132,10 +141,8 @@ void MeshInstanceEditor::_menu_option(int p_option) {
ur->commit_action();
} break;
- case MENU_OPTION_CREATE_NAVMESH: {
-
-
+ case MENU_OPTION_CREATE_NAVMESH: {
Ref<NavigationMesh> nmesh = memnew( NavigationMesh );
@@ -158,6 +165,7 @@ void MeshInstanceEditor::_menu_option(int p_option) {
ur->add_undo_method(node,"remove_child",nmi);
ur->commit_action();
} break;
+
case MENU_OPTION_CREATE_OUTLINE_MESH: {
outline_dialog->popup_centered(Vector2(200, 90));
diff --git a/tools/editor/plugins/mesh_editor_plugin.h b/tools/editor/plugins/mesh_editor_plugin.h
index e502b5dc2b..6b3e23f31f 100644
--- a/tools/editor/plugins/mesh_editor_plugin.h
+++ b/tools/editor/plugins/mesh_editor_plugin.h
@@ -23,24 +23,19 @@ class MeshInstanceEditor : public Node {
MENU_OPTION_CREATE_OUTLINE_MESH,
};
+ MeshInstance *node;
+
+ MenuButton *options;
+
ConfirmationDialog *outline_dialog;
SpinBox *outline_size;
AcceptDialog *err_dialog;
-
- Panel *panel;
- MeshInstance *node;
-
- LineEdit *surface_source;
- LineEdit *mesh_source;
-
-
void _menu_option(int p_option);
void _create_outline_mesh();
friend class MeshInstanceEditorPlugin;
- MenuButton * options;
protected:
void _node_removed(Node *p_node);
diff --git a/tools/editor/plugins/multimesh_editor_plugin.cpp b/tools/editor/plugins/multimesh_editor_plugin.cpp
index a5c823f8bd..3f63ef706b 100644
--- a/tools/editor/plugins/multimesh_editor_plugin.cpp
+++ b/tools/editor/plugins/multimesh_editor_plugin.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/plugins/multimesh_editor_plugin.h b/tools/editor/plugins/multimesh_editor_plugin.h
index edc3dfd55f..245da1eeb7 100644
--- a/tools/editor/plugins/multimesh_editor_plugin.h
+++ b/tools/editor/plugins/multimesh_editor_plugin.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/plugins/particles_2d_editor_plugin.cpp b/tools/editor/plugins/particles_2d_editor_plugin.cpp
index dadfa8bfdc..2488c4cdd9 100644
--- a/tools/editor/plugins/particles_2d_editor_plugin.cpp
+++ b/tools/editor/plugins/particles_2d_editor_plugin.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/plugins/particles_2d_editor_plugin.h b/tools/editor/plugins/particles_2d_editor_plugin.h
index dba0bb4dae..f70a0e7b76 100644
--- a/tools/editor/plugins/particles_2d_editor_plugin.h
+++ b/tools/editor/plugins/particles_2d_editor_plugin.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/plugins/particles_editor_plugin.cpp b/tools/editor/plugins/particles_editor_plugin.cpp
index 5c84d9a86a..2df6d3ea90 100644
--- a/tools/editor/plugins/particles_editor_plugin.cpp
+++ b/tools/editor/plugins/particles_editor_plugin.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/plugins/particles_editor_plugin.h b/tools/editor/plugins/particles_editor_plugin.h
index 92756af1f6..ff80bffc29 100644
--- a/tools/editor/plugins/particles_editor_plugin.h
+++ b/tools/editor/plugins/particles_editor_plugin.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/plugins/path_2d_editor_plugin.cpp b/tools/editor/plugins/path_2d_editor_plugin.cpp
index d037adc555..509edbe5f8 100644
--- a/tools/editor/plugins/path_2d_editor_plugin.cpp
+++ b/tools/editor/plugins/path_2d_editor_plugin.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -534,6 +534,7 @@ void Path2DEditor::edit(Node *p_path2d) {
if (!node->is_connected("visibility_changed", this, "_node_visibility_changed"))
node->connect("visibility_changed", this, "_node_visibility_changed");
+
} else {
if (canvas_item_editor->get_viewport_control()->is_connected("draw",this,"_canvas_draw"))
@@ -614,6 +615,7 @@ Path2DEditor::Path2DEditor(EditorNode *p_editor) {
editor=p_editor;
undo_redo = editor->get_undo_redo();
+ mode=MODE_EDIT;
action=ACTION_NONE;
#if 0
diff --git a/tools/editor/plugins/path_2d_editor_plugin.h b/tools/editor/plugins/path_2d_editor_plugin.h
index 9f15c0669f..973c17464e 100644
--- a/tools/editor/plugins/path_2d_editor_plugin.h
+++ b/tools/editor/plugins/path_2d_editor_plugin.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/plugins/path_editor_plugin.cpp b/tools/editor/plugins/path_editor_plugin.cpp
index f4bdf50fe9..b99e632604 100644
--- a/tools/editor/plugins/path_editor_plugin.cpp
+++ b/tools/editor/plugins/path_editor_plugin.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/plugins/path_editor_plugin.h b/tools/editor/plugins/path_editor_plugin.h
index fcd4241e59..18bad23bd1 100644
--- a/tools/editor/plugins/path_editor_plugin.h
+++ b/tools/editor/plugins/path_editor_plugin.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/plugins/polygon_2d_editor_plugin.cpp b/tools/editor/plugins/polygon_2d_editor_plugin.cpp
index cd82297365..3e9c58d604 100644
--- a/tools/editor/plugins/polygon_2d_editor_plugin.cpp
+++ b/tools/editor/plugins/polygon_2d_editor_plugin.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -755,7 +755,6 @@ void Polygon2DEditor::edit(Node *p_collision_polygon) {
canvas_item_editor=CanvasItemEditor::get_singleton();
}
-
if (p_collision_polygon) {
node=p_collision_polygon->cast_to<Polygon2D>();
diff --git a/tools/editor/plugins/resource_preloader_editor_plugin.cpp b/tools/editor/plugins/resource_preloader_editor_plugin.cpp
index 9cd20ac53a..8490f63ff0 100644
--- a/tools/editor/plugins/resource_preloader_editor_plugin.cpp
+++ b/tools/editor/plugins/resource_preloader_editor_plugin.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -356,11 +356,16 @@ bool ResourcePreloaderEditorPlugin::handles(Object *p_object) const {
void ResourcePreloaderEditorPlugin::make_visible(bool p_visible) {
if (p_visible) {
- preloader_editor->show();
+ //preloader_editor->show();
+ button->show();
+ editor->make_bottom_panel_item_visible(preloader_editor);
// preloader_editor->set_process(true);
} else {
- preloader_editor->hide();
+ if (preloader_editor->is_visible())
+ editor->hide_bottom_panel();
+ button->hide();
+ //preloader_editor->hide();
// preloader_editor->set_process(false);
}
@@ -370,11 +375,14 @@ ResourcePreloaderEditorPlugin::ResourcePreloaderEditorPlugin(EditorNode *p_node)
editor=p_node;
preloader_editor = memnew( ResourcePreloaderEditor );
- editor->get_viewport()->add_child(preloader_editor);
- preloader_editor->set_area_as_parent_rect();
+ preloader_editor->set_custom_minimum_size(Size2(0,250));
+
+ button=editor->add_bottom_panel_item("ResourcePreloader",preloader_editor);
+ button->hide();
+
// preloader_editor->set_anchor( MARGIN_TOP, Control::ANCHOR_END);
// preloader_editor->set_margin( MARGIN_TOP, 120 );
- preloader_editor->hide();
+
diff --git a/tools/editor/plugins/resource_preloader_editor_plugin.h b/tools/editor/plugins/resource_preloader_editor_plugin.h
index 88272bc603..53436797a9 100644
--- a/tools/editor/plugins/resource_preloader_editor_plugin.h
+++ b/tools/editor/plugins/resource_preloader_editor_plugin.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -85,6 +85,7 @@ class ResourcePreloaderEditorPlugin : public EditorPlugin {
ResourcePreloaderEditor *preloader_editor;
EditorNode *editor;
+ Button *button;
public:
diff --git a/tools/editor/plugins/rich_text_editor_plugin.cpp b/tools/editor/plugins/rich_text_editor_plugin.cpp
index a0daad854f..08374d6624 100644
--- a/tools/editor/plugins/rich_text_editor_plugin.cpp
+++ b/tools/editor/plugins/rich_text_editor_plugin.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/plugins/rich_text_editor_plugin.h b/tools/editor/plugins/rich_text_editor_plugin.h
index 478dc0d308..ae1d04be01 100644
--- a/tools/editor/plugins/rich_text_editor_plugin.h
+++ b/tools/editor/plugins/rich_text_editor_plugin.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/plugins/sample_editor_plugin.cpp b/tools/editor/plugins/sample_editor_plugin.cpp
index d88f2adc73..ffa39bd010 100644
--- a/tools/editor/plugins/sample_editor_plugin.cpp
+++ b/tools/editor/plugins/sample_editor_plugin.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/plugins/sample_editor_plugin.h b/tools/editor/plugins/sample_editor_plugin.h
index e615667914..22dc75b53b 100644
--- a/tools/editor/plugins/sample_editor_plugin.h
+++ b/tools/editor/plugins/sample_editor_plugin.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/plugins/sample_library_editor_plugin.cpp b/tools/editor/plugins/sample_library_editor_plugin.cpp
index b497458a2a..a28fbb2ec8 100644
--- a/tools/editor/plugins/sample_library_editor_plugin.cpp
+++ b/tools/editor/plugins/sample_library_editor_plugin.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -423,11 +423,16 @@ bool SampleLibraryEditorPlugin::handles(Object *p_object) const {
void SampleLibraryEditorPlugin::make_visible(bool p_visible) {
if (p_visible) {
- sample_library_editor->show();
+ //sample_library_editor->show();
+ button->show();
+ editor->make_bottom_panel_item_visible(sample_library_editor);
// sample_library_editor->set_process(true);
} else {
- sample_library_editor->hide();
+ if (sample_library_editor->is_visible())
+ editor->hide_bottom_panel();
+ button->hide();
+
// sample_library_editor->set_process(false);
}
@@ -437,11 +442,16 @@ SampleLibraryEditorPlugin::SampleLibraryEditorPlugin(EditorNode *p_node) {
editor=p_node;
sample_library_editor = memnew( SampleLibraryEditor );
- editor->get_viewport()->add_child(sample_library_editor);
- sample_library_editor->set_area_as_parent_rect();
+
+ //editor->get_viewport()->add_child(sample_library_editor);
+ sample_library_editor->set_custom_minimum_size(Size2(0,250));
+ button=p_node->add_bottom_panel_item("SampleLibrary",sample_library_editor);
+ button->hide();
+
+ //sample_library_editor->set_area_as_parent_rect();
// sample_library_editor->set_anchor( MARGIN_TOP, Control::ANCHOR_END);
// sample_library_editor->set_margin( MARGIN_TOP, 120 );
- sample_library_editor->hide();
+ //sample_library_editor->hide();
diff --git a/tools/editor/plugins/sample_library_editor_plugin.h b/tools/editor/plugins/sample_library_editor_plugin.h
index 2770ca2d9a..cbdcf5fc3f 100644
--- a/tools/editor/plugins/sample_library_editor_plugin.h
+++ b/tools/editor/plugins/sample_library_editor_plugin.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -90,6 +90,7 @@ class SampleLibraryEditorPlugin : public EditorPlugin {
SampleLibraryEditor *sample_library_editor;
EditorNode *editor;
+ Button *button;
public:
diff --git a/tools/editor/plugins/sample_player_editor_plugin.cpp b/tools/editor/plugins/sample_player_editor_plugin.cpp
index f1c7ca8c98..3085ad87d8 100644
--- a/tools/editor/plugins/sample_player_editor_plugin.cpp
+++ b/tools/editor/plugins/sample_player_editor_plugin.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/plugins/sample_player_editor_plugin.h b/tools/editor/plugins/sample_player_editor_plugin.h
index cdd1a99c17..013b042487 100644
--- a/tools/editor/plugins/sample_player_editor_plugin.h
+++ b/tools/editor/plugins/sample_player_editor_plugin.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/plugins/script_editor_plugin.cpp b/tools/editor/plugins/script_editor_plugin.cpp
index e01cf72149..34d7e89760 100644
--- a/tools/editor/plugins/script_editor_plugin.cpp
+++ b/tools/editor/plugins/script_editor_plugin.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -316,6 +316,8 @@ void ScriptTextEditor::_load_theme_settings() {
get_text_edit()->add_keyword_color("Color",basetype_color);
get_text_edit()->add_keyword_color("Image",basetype_color);
get_text_edit()->add_keyword_color("InputEvent",basetype_color);
+ get_text_edit()->add_keyword_color("Rect2",basetype_color);
+ get_text_edit()->add_keyword_color("NodePath",basetype_color);
//colorize engine types
Color type_color= EDITOR_DEF("text_editor/engine_type_color",Color(0.0,0.2,0.4));
@@ -325,7 +327,11 @@ void ScriptTextEditor::_load_theme_settings() {
for(List<StringName>::Element *E=types.front();E;E=E->next()) {
- get_text_edit()->add_keyword_color(E->get(),type_color);
+ String n = E->get();
+ if (n.begins_with("_"))
+ n = n.substr(1, n.length());
+
+ get_text_edit()->add_keyword_color(n,type_color);
}
//colorize comments
@@ -379,6 +385,8 @@ void ScriptTextEditor::reload_text() {
te->set_h_scroll(h);
te->set_v_scroll(v);
+ te->tag_saved_version();
+
_line_col_changed();
}
@@ -391,6 +399,12 @@ void ScriptTextEditor::_notification(int p_what) {
}
}
+
+bool ScriptTextEditor::is_unsaved() {
+
+ return get_text_edit()->get_version()!=get_text_edit()->get_saved_version();
+}
+
String ScriptTextEditor::get_name() {
String name;
@@ -492,6 +506,59 @@ static Node* _find_node_for_script(Node* p_base, Node*p_current, const Ref<Scrip
return NULL;
}
+static void _find_changed_scripts_for_external_editor(Node* p_base, Node*p_current, Set<Ref<Script> > &r_scripts) {
+
+ if (p_current->get_owner()!=p_base && p_base!=p_current)
+ return;
+ Ref<Script> c = p_current->get_script();
+
+ if (c.is_valid())
+ r_scripts.insert(c);
+
+ for(int i=0;i<p_current->get_child_count();i++) {
+ _find_changed_scripts_for_external_editor(p_base,p_current->get_child(i),r_scripts);
+ }
+
+}
+
+void ScriptEditor::_update_modified_scripts_for_external_editor() {
+
+ if (!bool(EditorSettings::get_singleton()->get("external_editor/use_external_editor")))
+ return;
+
+ Set<Ref<Script> > scripts;
+
+ Node *base = get_tree()->get_edited_scene_root();
+ if (base) {
+ _find_changed_scripts_for_external_editor(base,base,scripts);
+ }
+
+ for (Set<Ref<Script> >::Element *E=scripts.front();E;E=E->next()) {
+
+ Ref<Script> script = E->get();
+
+ if (script->get_path()=="" || script->get_path().find("local://")!=-1 || script->get_path().find("::")!=-1) {
+
+ continue; //internal script, who cares, though weird
+ }
+
+ uint64_t last_date = script->get_last_modified_time();
+ uint64_t date = FileAccess::get_modified_time(script->get_path());
+
+ if (last_date!=date) {
+
+ Ref<Script> rel_script = ResourceLoader::load(script->get_path(),script->get_type(),true);
+ ERR_CONTINUE(!rel_script.is_valid());
+ script->set_source_code( rel_script->get_source_code() );
+ script->set_last_modified_time( rel_script->get_last_modified_time() );
+ script->update_exports();
+ }
+
+ }
+}
+
+
+
void ScriptTextEditor::_code_complete_script(const String& p_code, List<String>* r_options) {
Node *base = get_tree()->get_edited_scene_root();
@@ -543,7 +610,6 @@ void ScriptEditor::_breaked(bool p_breaked,bool p_can_debug) {
void ScriptEditor::_show_debugger(bool p_show) {
debug_menu->get_popup()->set_item_checked( debug_menu->get_popup()->get_item_index(DEBUG_SHOW), p_show);
-
}
void ScriptEditor::_script_created(Ref<Script> p_script) {
@@ -749,6 +815,7 @@ void ScriptEditor::_reload_scripts(){
}
disk_changed->hide();
+ _update_script_names();
}
@@ -791,46 +858,53 @@ bool ScriptEditor::_test_script_times_on_disk() {
TreeItem *r = disk_changed_list->create_item();
disk_changed_list->set_hide_root(true);
- bool all_ok=true;
+ bool need_ask=false;
+ bool need_reload=false;
+ bool use_autoreload=bool(EDITOR_DEF("text_editor/auto_reload_scripts_on_external_change",false));
+
for(int i=0;i<tab_container->get_child_count();i++) {
ScriptTextEditor *ste = tab_container->get_child(i)->cast_to<ScriptTextEditor>();
- if (!ste)
- continue;
+ if (ste) {
+ Ref<Script> script = ste->get_edited_script();
- Ref<Script> script = ste->get_edited_script();
+ if (script->get_path()=="" || script->get_path().find("local://")!=-1 || script->get_path().find("::")!=-1)
+ continue; //internal script, who cares
- if (script->get_path()=="" || script->get_path().find("local://")!=-1 || script->get_path().find("::")!=-1)
- continue; //internal script, who cares
+ uint64_t last_date = script->get_last_modified_time();
+ uint64_t date = FileAccess::get_modified_time(script->get_path());
- uint64_t last_date = script->get_last_modified_time();
- uint64_t date = FileAccess::get_modified_time(script->get_path());
+ //printf("last date: %lli vs date: %lli\n",last_date,date);
+ if (last_date!=date) {
- //printf("last date: %lli vs date: %lli\n",last_date,date);
- if (last_date!=date) {
+ TreeItem *ti = disk_changed_list->create_item(r);
+ ti->set_text(0,script->get_path().get_file());
- TreeItem *ti = disk_changed_list->create_item(r);
- ti->set_text(0,script->get_path().get_file());
- all_ok=false;
- //r->set_metadata(0,);
+ if (!use_autoreload || ste->is_unsaved()) {
+ need_ask=true;
+ }
+ need_reload=true;
+ //r->set_metadata(0,);
+ }
}
}
- if (!all_ok) {
- if (bool(EDITOR_DEF("text_editor/auto_reload_changed_scripts",false))) {
+ if (need_reload) {
+ if (!need_ask) {
script_editor->_reload_scripts();
+ need_reload=false;
} else {
disk_changed->call_deferred("popup_centered_ratio",0.5);
}
}
- return all_ok;
+ return need_reload;
}
void ScriptEditor::swap_lines(TextEdit *tx, int line1, int line2)
@@ -912,7 +986,22 @@ void ScriptEditor::_menu_option(int p_option) {
case WINDOW_PREV: {
_history_back();
} break;
-
+ case DEBUG_SHOW: {
+ if (debugger) {
+ bool visible = debug_menu->get_popup()->is_item_checked( debug_menu->get_popup()->get_item_index(DEBUG_SHOW) );
+ debug_menu->get_popup()->set_item_checked( debug_menu->get_popup()->get_item_index(DEBUG_SHOW), !visible);
+ if (visible)
+ debugger->hide();
+ else
+ debugger->show();
+ }
+ } break;
+ case DEBUG_SHOW_KEEP_OPEN: {
+ bool visible = debug_menu->get_popup()->is_item_checked( debug_menu->get_popup()->get_item_index(DEBUG_SHOW_KEEP_OPEN) );
+ if (debugger)
+ debugger->set_hide_on_stop(visible);
+ debug_menu->get_popup()->set_item_checked( debug_menu->get_popup()->get_item_index(DEBUG_SHOW_KEEP_OPEN), !visible);
+ } break;
}
@@ -929,8 +1018,10 @@ void ScriptEditor::_menu_option(int p_option) {
script_create_dialog->popup_centered(Size2(300, 300));
} break;
case FILE_SAVE: {
- if (!_test_script_times_on_disk())
+
+ if (_test_script_times_on_disk())
return;
+
editor->save_resource( current->get_edited_script() );
} break;
@@ -1137,12 +1228,14 @@ void ScriptEditor::_menu_option(int p_option) {
return;
int line = tx->cursor_get_line();
int next_line = line + 1;
+ int column = tx->cursor_get_column();
- if (line == tx->get_line_count() || next_line > tx->get_line_count())
- return;
+ if (line >= tx->get_line_count() - 1)
+ tx->set_line(line, tx->get_line(line) + "\n");
String line_clone = tx->get_line(line);
tx->insert_at(line_clone, next_line);
+ tx->cursor_set_column(column);
tx->update();
} break;
@@ -1264,16 +1357,6 @@ void ScriptEditor::_menu_option(int p_option) {
debugger->debug_continue();
} break;
- case DEBUG_SHOW: {
- if (debugger) {
- bool visible = debug_menu->get_popup()->is_item_checked( debug_menu->get_popup()->get_item_index(DEBUG_SHOW) );
- debug_menu->get_popup()->set_item_checked( debug_menu->get_popup()->get_item_index(DEBUG_SHOW), !visible);
- if (visible)
- debugger->hide();
- else
- debugger->show();
- }
- } break;
case HELP_CONTEXTUAL: {
String text = current->get_text_edit()->get_selection_text();
if (text == "")
@@ -1401,6 +1484,7 @@ void ScriptEditor::_notification(int p_what) {
if (p_what==MainLoop::NOTIFICATION_WM_FOCUS_IN) {
_test_script_times_on_disk();
+ _update_modified_scripts_for_external_editor();
}
if (p_what==NOTIFICATION_PROCESS) {
@@ -1409,6 +1493,11 @@ void ScriptEditor::_notification(int p_what) {
}
+void ScriptEditor::edited_scene_changed() {
+
+ _update_modified_scripts_for_external_editor();
+
+}
static const Node * _find_node_with_script(const Node* p_node, const RefPtr & p_script) {
@@ -1692,7 +1781,7 @@ void ScriptEditor::_update_script_colors() {
if (h>hist_size) {
continue;
}
- float v = Math::ease((edit_pass-pass)/float_t(hist_size),0.4);
+ float v = Math::ease((edit_pass-pass)/float(hist_size),0.4);
script_list->set_item_custom_bg_color(i,hot_color.linear_interpolate(cold_color,v));
@@ -1835,6 +1924,7 @@ void ScriptEditor::edit(const Ref<Script>& p_script) {
ScriptTextEditor *ste = memnew( ScriptTextEditor );
ste->set_edited_script(p_script);
ste->get_text_edit()->set_tooltip_request_func(this,"_get_debug_tooltip",ste);
+ ste->get_text_edit()->set_auto_brace_completion(EditorSettings::get_singleton()->get("text_editor/auto_brace_complete"));
tab_container->add_child(ste);
_go_to_tab(tab_container->get_tab_count()-1);
@@ -1959,6 +2049,15 @@ void ScriptEditor::_editor_settings_changed() {
autosave_timer->stop();
}
+ for(int i=0;i<tab_container->get_child_count();i++) {
+
+ ScriptTextEditor *ste = tab_container->get_child(i)->cast_to<ScriptTextEditor>();
+ if (!ste)
+ continue;
+
+ ste->get_text_edit()->set_auto_brace_completion(EditorSettings::get_singleton()->get("text_editor/auto_brace_complete"));
+ }
+
}
void ScriptEditor::_autosave_scripts() {
@@ -2174,6 +2273,10 @@ void ScriptEditor::_history_back(){
void ScriptEditor::set_scene_root_script( Ref<Script> p_script ) {
bool open_dominant = EditorSettings::get_singleton()->get("text_editor/open_dominant_script_on_scene_change");
+
+ if (bool(EditorSettings::get_singleton()->get("external_editor/use_external_editor")))
+ return;
+
if (open_dominant && p_script.is_valid()) {
edit(p_script);
}
@@ -2220,18 +2323,15 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
menu_hb = memnew( HBoxContainer );
add_child(menu_hb);
- v_split = memnew( VSplitContainer );
- add_child(v_split);
- v_split->set_v_size_flags(SIZE_EXPAND_FILL);
script_split = memnew( HSplitContainer );
- v_split->add_child(script_split);
+ add_child(script_split);
script_split->set_v_size_flags(SIZE_EXPAND_FILL);
script_list = memnew( ItemList );
script_split->add_child(script_list);
- script_list->set_custom_minimum_size(Size2(70,0));
- script_split->set_split_offset(70);
+ script_list->set_custom_minimum_size(Size2(0,0));
+ script_split->set_split_offset(140);
tab_container = memnew( TabContainer );
tab_container->set_tabs_visible(false);
@@ -2315,7 +2415,8 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
debug_menu->get_popup()->add_item("Break",DEBUG_BREAK);
debug_menu->get_popup()->add_item("Continue",DEBUG_CONTINUE);
debug_menu->get_popup()->add_separator();
- debug_menu->get_popup()->add_check_item("Show Debugger",DEBUG_SHOW);
+ //debug_menu->get_popup()->add_check_item("Show Debugger",DEBUG_SHOW);
+ debug_menu->get_popup()->add_check_item("Keep Debugger Open",DEBUG_SHOW_KEEP_OPEN);
debug_menu->get_popup()->connect("item_pressed", this,"_menu_option");
debug_menu->get_popup()->set_item_disabled( debug_menu->get_popup()->get_item_index(DEBUG_NEXT), true);
@@ -2443,7 +2544,11 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
quick_open->connect("goto_line",this,"_goto_script_line2");
- v_split->add_child(debugger);
+
+ Button *db = EditorNode::get_singleton()->add_bottom_panel_item("Debugger",debugger);
+ debugger->set_tool_button(db);
+
+
debugger->connect("breaked",this,"_breaked");
autosave_timer = memnew( Timer );
@@ -2557,6 +2662,11 @@ void ScriptEditorPlugin::get_breakpoints(List<String> *p_breakpoints) {
return script_editor->get_breakpoints(p_breakpoints);
}
+void ScriptEditorPlugin::edited_scene_changed() {
+
+ script_editor->edited_scene_changed();
+}
+
ScriptEditorPlugin::ScriptEditorPlugin(EditorNode *p_node) {
editor=p_node;
@@ -2566,7 +2676,7 @@ ScriptEditorPlugin::ScriptEditorPlugin(EditorNode *p_node) {
script_editor->hide();
- EDITOR_DEF("text_editor/auto_reload_changed_scripts",false);
+ EDITOR_DEF("text_editor/auto_reload_scripts_on_external_change",true);
EDITOR_DEF("text_editor/open_dominant_script_on_scene_change",true);
EDITOR_DEF("external_editor/use_external_editor",false);
EDITOR_DEF("external_editor/exec_path","");
diff --git a/tools/editor/plugins/script_editor_plugin.h b/tools/editor/plugins/script_editor_plugin.h
index e755f570ef..c52da41a43 100644
--- a/tools/editor/plugins/script_editor_plugin.h
+++ b/tools/editor/plugins/script_editor_plugin.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -103,7 +103,7 @@ public:
void reload_text();
String get_name() ;
Ref<Texture> get_icon() ;
-
+ bool is_unsaved();
ScriptTextEditor();
};
@@ -151,7 +151,8 @@ class ScriptEditor : public VBoxContainer {
DEBUG_BREAK,
DEBUG_CONTINUE,
DEBUG_SHOW,
- HELP_CONTEXTUAL,
+ DEBUG_SHOW_KEEP_OPEN,
+ HELP_CONTEXTUAL,
WINDOW_MOVE_LEFT,
WINDOW_MOVE_RIGHT,
WINDOW_NEXT,
@@ -211,8 +212,6 @@ class ScriptEditor : public VBoxContainer {
Tree *disk_changed_list;
ConfirmationDialog *disk_changed;
- VSplitContainer *v_split;
-
bool restoring_layout;
String _get_debug_tooltip(const String&p_text,Node *_ste);
@@ -271,6 +270,7 @@ class ScriptEditor : public VBoxContainer {
void _go_to_tab(int p_idx);
void _update_history_pos(int p_new_pos);
void _update_script_colors();
+ void _update_modified_scripts_for_external_editor();
static ScriptEditor *script_editor;
@@ -302,6 +302,8 @@ public:
void set_scene_root_script( Ref<Script> p_script );
+ virtual void edited_scene_changed();
+
ScriptEditorDebugger *get_debugger() { return debugger; }
ScriptEditor(EditorNode *p_editor);
@@ -338,6 +340,7 @@ public:
virtual void get_breakpoints(List<String> *p_breakpoints);
+ virtual void edited_scene_changed();
ScriptEditorPlugin(EditorNode *p_node);
~ScriptEditorPlugin();
diff --git a/tools/editor/plugins/shader_editor_plugin.cpp b/tools/editor/plugins/shader_editor_plugin.cpp
index a182d57742..18d8f5efc0 100644
--- a/tools/editor/plugins/shader_editor_plugin.cpp
+++ b/tools/editor/plugins/shader_editor_plugin.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -172,11 +172,8 @@ ShaderTextEditor::ShaderTextEditor() {
void ShaderEditor::_menu_option(int p_option) {
- int selected = tab_container->get_current_tab();
- if (selected<0 || selected>=tab_container->get_child_count())
- return;
- ShaderTextEditor *current = tab_container->get_child(selected)->cast_to<ShaderTextEditor>();
+ ShaderTextEditor *current = tab_container->get_current_tab_control()->cast_to<ShaderTextEditor>();
if (!current)
return;
@@ -235,6 +232,11 @@ void ShaderEditor::_menu_option(int p_option) {
void ShaderEditor::_tab_changed(int p_which) {
+ ShaderTextEditor *shader_editor = tab_container->get_tab_control(p_which)->cast_to<ShaderTextEditor>();
+
+ if (shader_editor && is_inside_tree())
+ shader_editor->get_text_edit()->grab_focus();
+
ensure_select_current();
}
diff --git a/tools/editor/plugins/shader_editor_plugin.h b/tools/editor/plugins/shader_editor_plugin.h
index 4ead2ba94e..26d20b80b4 100644
--- a/tools/editor/plugins/shader_editor_plugin.h
+++ b/tools/editor/plugins/shader_editor_plugin.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/plugins/shader_graph_editor_plugin.cpp b/tools/editor/plugins/shader_graph_editor_plugin.cpp
index 3a7dc26466..36a8c79b84 100644
--- a/tools/editor/plugins/shader_graph_editor_plugin.cpp
+++ b/tools/editor/plugins/shader_graph_editor_plugin.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -2658,13 +2658,13 @@ void ShaderGraphEditor::edit(Ref<ShaderGraph> p_shader) {
void ShaderGraphEditor::_add_node(int p_type) {
ShaderGraph::ShaderType shader_type=ShaderGraph::ShaderType(tabs->get_current_tab());
-
graph_edits[shader_type]->add_node(p_type, next_location);
}
void ShaderGraphEditor::_popup_requested(const Vector2 &p_position)
{
- next_location = get_local_mouse_pos();
+ Vector2 scroll_ofs=graph_edits[tabs->get_current_tab()]->get_graph_edit()->get_scroll_ofs();
+ next_location = get_local_mouse_pos() + scroll_ofs;
popup->set_global_pos(p_position);
popup->set_size( Size2( 200, 0) );
popup->popup();
diff --git a/tools/editor/plugins/shader_graph_editor_plugin.h b/tools/editor/plugins/shader_graph_editor_plugin.h
index 39e9b29d45..0336696911 100644
--- a/tools/editor/plugins/shader_graph_editor_plugin.h
+++ b/tools/editor/plugins/shader_graph_editor_plugin.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -149,7 +149,7 @@ class ShaderGraphView : public Node {
void _end_node_move();
void _move_node(int p_id,const Vector2& p_to);
void _duplicate_nodes_request();
- void _duplicate_nodes(const Array &p_nodes);
+ void _duplicate_nodes(const Array &p_nodes);
void _delete_nodes_request();
diff --git a/tools/editor/plugins/spatial_editor_plugin.cpp b/tools/editor/plugins/spatial_editor_plugin.cpp
index 7816efe89f..236d69dfb3 100644
--- a/tools/editor/plugins/spatial_editor_plugin.cpp
+++ b/tools/editor/plugins/spatial_editor_plugin.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -39,6 +39,9 @@
#include "scene/resources/surface_tool.h"
#include "tools/editor/spatial_editor_gizmos.h"
#include "globals.h"
+#include "tools/editor/plugins/animation_player_editor_plugin.h"
+#include "tools/editor/animation_editor.h"
+
#define DISTANCE_DEFAULT 4
@@ -736,6 +739,68 @@ void SpatialEditorViewport::_smouseenter() {
surface->grab_focus();
}
+void SpatialEditorViewport::_list_select(InputEventMouseButton b) {
+
+ _find_items_at_pos(Vector2( b.x, b.y ),clicked_includes_current,selection_results,b.mod.shift);
+
+ Node *scene=editor->get_edited_scene();
+
+ for(int i=0;i<selection_results.size();i++) {
+ Spatial *item=selection_results[i].item;
+ if (item!=scene && item->get_owner()!=scene && !scene->is_editable_instance(item->get_owner())) {
+ //invalid result
+ selection_results.remove(i);
+ i--;
+ }
+
+ }
+
+
+ clicked_wants_append=b.mod.shift;
+
+ if (selection_results.size() == 1) {
+
+ clicked=selection_results[0].item->get_instance_ID();
+ selection_results.clear();
+
+ if (clicked) {
+ _select_clicked(clicked_wants_append,true);
+ clicked=0;
+ }
+
+ } else if (!selection_results.empty()) {
+
+ NodePath root_path = get_tree()->get_edited_scene_root()->get_path();
+ StringName root_name = root_path.get_name(root_path.get_name_count()-1);
+
+ for (int i = 0; i < selection_results.size(); i++) {
+
+ Spatial *spat=selection_results[i].item;
+
+ Ref<Texture> icon;
+ if (spat->has_meta("_editor_icon"))
+ icon=spat->get_meta("_editor_icon");
+ else
+ icon=get_icon( has_icon(spat->get_type(),"EditorIcons")?spat->get_type():String("Object"),"EditorIcons");
+
+ String node_path="/"+root_name+"/"+root_path.rel_path_to(spat->get_path());
+
+ selection_menu->add_item(spat->get_name());
+ selection_menu->set_item_icon(i, icon );
+ selection_menu->set_item_metadata(i, node_path);
+ selection_menu->set_item_tooltip(i,String(spat->get_name())+
+ "\nType: "+spat->get_type()+"\nPath: "+node_path);
+ }
+
+ selection_menu->set_global_pos(Vector2( b.global_x, b.global_y ));
+ selection_menu->popup();
+ selection_menu->call_deferred("grab_click_focus");
+ selection_menu->set_invalidate_click_until_motion();
+
+
+
+ }
+}
void SpatialEditorViewport::_sinput(const InputEvent &p_event) {
if (previewing)
@@ -868,50 +933,9 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) {
if (nav_scheme == NAVIGATION_MAYA)
break;
- _find_items_at_pos(Vector2( b.x, b.y ),clicked_includes_current,selection_results,b.mod.shift);
-
- clicked_wants_append=b.mod.shift;
-
- if (selection_results.size() == 1) {
-
- clicked=selection_results[0].item->get_instance_ID();
- selection_results.clear();
-
- if (clicked) {
- _select_clicked(clicked_wants_append,true);
- clicked=0;
- }
-
- } else if (!selection_results.empty()) {
-
- NodePath root_path = get_tree()->get_edited_scene_root()->get_path();
- StringName root_name = root_path.get_name(root_path.get_name_count()-1);
-
- for (int i = 0; i < selection_results.size(); i++) {
-
- Spatial *spat=selection_results[i].item;
-
- Ref<Texture> icon;
- if (spat->has_meta("_editor_icon"))
- icon=spat->get_meta("_editor_icon");
- else
- icon=get_icon( has_icon(spat->get_type(),"EditorIcons")?spat->get_type():String("Object"),"EditorIcons");
-
- String node_path="/"+root_name+"/"+root_path.rel_path_to(spat->get_path());
+ _list_select(b);
+ return;
- selection_menu->add_item(spat->get_name());
- selection_menu->set_item_icon(i, icon );
- selection_menu->set_item_metadata(i, node_path);
- selection_menu->set_item_tooltip(i,String(spat->get_name())+
- "\nType: "+spat->get_type()+"\nPath: "+node_path);
- }
-
- selection_menu->set_global_pos(Vector2( b.global_x, b.global_y ));
- selection_menu->popup();
- selection_menu->call_deferred("grab_click_focus");
-
- break;
- }
}
}
@@ -984,6 +1008,11 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) {
break;
}
+ if (spatial_editor->get_tool_mode()==SpatialEditor::TOOL_MODE_LIST_SELECT) {
+ _list_select(b);
+ break;
+ }
+
_edit.mouse_pos=Point2(b.x,b.y);
_edit.snap=false;
_edit.mode=TRANSFORM_NONE;
@@ -1591,6 +1620,8 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) {
case InputEvent::KEY: {
const InputEventKey &k = p_event.key;
+ if (!k.pressed)
+ break;
switch(k.scancode) {
case KEY_S: {
@@ -1651,7 +1682,8 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) {
} break;
case KEY_KP_5: {
- orthogonal = !orthogonal;
+
+ //orthogonal = !orthogonal;
_menu_option(orthogonal?VIEW_PERSPECTIVE:VIEW_ORTHOGONAL);
_update_name();
@@ -1662,7 +1694,7 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) {
if (!get_selected_count() || _edit.mode!=TRANSFORM_NONE)
break;
- if (!editor->get_animation_editor()->has_keying()) {
+ if (!AnimationPlayerEditor::singleton->get_key_editor()->has_keying()) {
set_message("Keying is disabled (no key inserted).");
break;
}
@@ -2383,6 +2415,7 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed
add_child(c);
c->set_area_as_parent_rect();
viewport = memnew( Viewport );
+ viewport->set_disable_input(true);
c->add_child(viewport);
surface = memnew( Control );
add_child(surface);
@@ -2600,6 +2633,13 @@ Dictionary SpatialEditor::get_state() const {
Dictionary d;
+ d["snap_enabled"]=snap_enabled;
+ d["translate_snap"]=get_translate_snap();
+ d["rotate_snap"]=get_rotate_snap();
+ d["scale_snap"]=get_scale_snap();
+
+ int local_coords_index=transform_menu->get_popup()->get_item_index(MENU_TRANSFORM_LOCAL_COORDS);
+ d["local_coords"]=transform_menu->get_popup()->is_item_checked( local_coords_index );
int vc=0;
if (view_menu->get_popup()->is_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT) ))
@@ -2641,37 +2681,52 @@ void SpatialEditor::set_state(const Dictionary& p_state) {
Dictionary d = p_state;
- ERR_FAIL_COND(!d.has("viewport_mode"));
- ERR_FAIL_COND(!d.has("viewports"));
- ERR_FAIL_COND(!d.has("default_light"));
- ERR_FAIL_COND(!d.has("show_grid"));
- ERR_FAIL_COND(!d.has("show_origin"));
- ERR_FAIL_COND(!d.has("fov"));
- ERR_FAIL_COND(!d.has("znear"));
- ERR_FAIL_COND(!d.has("zfar"));
+ if (d.has("snap_enabled")) {
+ snap_enabled=d["snap_enabled"];
+ int snap_enabled_idx=transform_menu->get_popup()->get_item_index(MENU_TRANSFORM_USE_SNAP);
+ transform_menu->get_popup()->set_item_checked( snap_enabled_idx, snap_enabled );
+ }
- int vc = d["viewport_mode"];
+ if (d.has("translate_snap"))
+ snap_translate->set_text(d["translate_snap"]);
- if (vc==1)
- _menu_item_pressed(MENU_VIEW_USE_1_VIEWPORT);
- else if (vc==2)
- _menu_item_pressed(MENU_VIEW_USE_2_VIEWPORTS);
- else if (vc==3)
- _menu_item_pressed(MENU_VIEW_USE_3_VIEWPORTS);
- else if (vc==4)
- _menu_item_pressed(MENU_VIEW_USE_4_VIEWPORTS);
- else if (vc==5)
- _menu_item_pressed(MENU_VIEW_USE_2_VIEWPORTS_ALT);
- else if (vc==6)
- _menu_item_pressed(MENU_VIEW_USE_3_VIEWPORTS_ALT);
-
- Array vp = d["viewports"];
- ERR_FAIL_COND(vp.size()>4);
+ if (d.has("rotate_snap"))
+ snap_rotate->set_text(d["rotate_snap"]);
- for(int i=0;i<4;i++) {
- viewports[i]->set_state(vp[i]);
+ if (d.has("scale_snap"))
+ snap_scale->set_text(d["scale_snap"]);
+
+ if (d.has("local_coords")) {
+ int local_coords_idx=transform_menu->get_popup()->get_item_index(MENU_TRANSFORM_LOCAL_COORDS);
+ transform_menu->get_popup()->set_item_checked( local_coords_idx, d["local_coords"] );
+ update_transform_gizmo();
}
+ if (d.has("viewport_mode")) {
+ int vc = d["viewport_mode"];
+
+ if (vc==1)
+ _menu_item_pressed(MENU_VIEW_USE_1_VIEWPORT);
+ else if (vc==2)
+ _menu_item_pressed(MENU_VIEW_USE_2_VIEWPORTS);
+ else if (vc==3)
+ _menu_item_pressed(MENU_VIEW_USE_3_VIEWPORTS);
+ else if (vc==4)
+ _menu_item_pressed(MENU_VIEW_USE_4_VIEWPORTS);
+ else if (vc==5)
+ _menu_item_pressed(MENU_VIEW_USE_2_VIEWPORTS_ALT);
+ else if (vc==6)
+ _menu_item_pressed(MENU_VIEW_USE_3_VIEWPORTS_ALT);
+ }
+
+ if (d.has("viewports")) {
+ Array vp = d["viewports"];
+ ERR_FAIL_COND(vp.size()>4);
+
+ for(int i=0;i<4;i++) {
+ viewports[i]->set_state(vp[i]);
+ }
+ }
if (d.has("zfar"))
settings_zfar->set_val(float(d["zfar"]));
@@ -2841,13 +2896,14 @@ void SpatialEditor::_menu_item_pressed(int p_option) {
case MENU_TOOL_SELECT:
case MENU_TOOL_MOVE:
case MENU_TOOL_ROTATE:
- case MENU_TOOL_SCALE: {
+ case MENU_TOOL_SCALE:
+ case MENU_TOOL_LIST_SELECT: {
- for(int i=0;i<4;i++)
+ for(int i=0;i<TOOL_MAX;i++)
tool_button[i]->set_pressed(i==p_option);
tool_mode=(ToolMode)p_option;
- static const char *_mode[]={"Selection Mode.","Translation Mode.","Rotation Mode.","Scale Mode."};
+ static const char *_mode[]={"Selection Mode.","Translation Mode.","Rotation Mode.","Scale Mode.","List Selection Mode."};
// set_message(_mode[p_option],3);
update_transform_gizmo();
@@ -3474,19 +3530,13 @@ void SpatialEditor::_instance_scene() {
undo_redo->commit_action();
#endif
}
-/*
-void SpatialEditor::_update_selection() {
-
-
-}
-*/
void SpatialEditor::_unhandled_key_input(InputEvent p_event) {
- if (!is_visible())
+ if (!is_visible() || get_viewport()->gui_has_modal_stack())
return;
- {
+ {
EditorNode *en = editor;
EditorPlugin *over_plugin = en->get_editor_plugin_over();
@@ -3530,6 +3580,7 @@ void SpatialEditor::_notification(int p_what) {
tool_button[SpatialEditor::TOOL_MODE_MOVE]->set_icon( get_icon("ToolMove","EditorIcons") );
tool_button[SpatialEditor::TOOL_MODE_ROTATE]->set_icon( get_icon("ToolRotate","EditorIcons") );
tool_button[SpatialEditor::TOOL_MODE_SCALE]->set_icon( get_icon("ToolScale","EditorIcons") );
+ tool_button[SpatialEditor::TOOL_MODE_LIST_SELECT]->set_icon( get_icon("ListSelect","EditorIcons") );
instance_button->set_icon( get_icon("SpatialAdd","EditorIcons") );
instance_button->hide();
@@ -3684,7 +3735,6 @@ void SpatialEditor::_bind_methods() {
ObjectTypeDB::bind_method("_menu_item_pressed",&SpatialEditor::_menu_item_pressed);
ObjectTypeDB::bind_method("_xform_dialog_action",&SpatialEditor::_xform_dialog_action);
ObjectTypeDB::bind_method("_instance_scene",&SpatialEditor::_instance_scene);
-// ObjectTypeDB::bind_method("_update_selection",&SpatialEditor::_update_selection);
ObjectTypeDB::bind_method("_get_editor_data",&SpatialEditor::_get_editor_data);
ObjectTypeDB::bind_method("_request_gizmo",&SpatialEditor::_request_gizmo);
ObjectTypeDB::bind_method("_default_light_angle_input",&SpatialEditor::_default_light_angle_input);
@@ -3786,7 +3836,6 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
editor=p_editor;
editor_selection=editor->get_editor_selection();
editor_selection->add_editor_plugin(this);
- editor_selection->connect("selection_changed",this,"_update_selection");
snap_enabled=false;
tool_mode = TOOL_MODE_SELECT;
@@ -3807,7 +3856,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
tool_button[TOOL_MODE_SELECT]->set_pressed(true);
button_binds[0]=MENU_TOOL_SELECT;
tool_button[TOOL_MODE_SELECT]->connect("pressed", this,"_menu_item_pressed",button_binds);
- tool_button[TOOL_MODE_SELECT]->set_tooltip("Select Mode (Q)");
+ tool_button[TOOL_MODE_SELECT]->set_tooltip("Select Mode (Q)\n"+keycode_get_string(KEY_MASK_CMD)+"Drag: Rotate\nAlt+Drag: Move\nAlt+RMB: Depth list selection");
tool_button[TOOL_MODE_MOVE] = memnew( ToolButton );
@@ -3839,10 +3888,22 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
hbc_menu->add_child( instance_button );
instance_button->set_flat(true);
instance_button->connect("pressed",this,"_instance_scene");
+ instance_button->hide();
VSeparator *vs = memnew( VSeparator );
hbc_menu->add_child(vs);
+ tool_button[TOOL_MODE_LIST_SELECT] = memnew( ToolButton );
+ hbc_menu->add_child( tool_button[TOOL_MODE_LIST_SELECT] );
+ tool_button[TOOL_MODE_LIST_SELECT]->set_toggle_mode(true);
+ tool_button[TOOL_MODE_LIST_SELECT]->set_flat(true);
+ button_binds[0]=MENU_TOOL_LIST_SELECT;
+ tool_button[TOOL_MODE_LIST_SELECT]->connect("pressed", this,"_menu_item_pressed",button_binds);
+ tool_button[TOOL_MODE_LIST_SELECT]->set_tooltip("Show a list of all objects at the position clicked\n(same as Alt+RMB in selet mode).");
+
+ vs = memnew( VSeparator );
+ hbc_menu->add_child(vs);
+
PopupMenu *p;
@@ -3962,6 +4023,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
settings_light_base->connect("input_event",this,"_default_light_angle_input");
settings_vbc->add_margin_child("Default Light Normal:",settings_light_base);
settings_light_vp = memnew( Viewport );
+ settings_light_vp->set_disable_input(true);
settings_light_vp->set_use_own_world(true);
settings_light_base->add_child(settings_light_vp);
diff --git a/tools/editor/plugins/spatial_editor_plugin.h b/tools/editor/plugins/spatial_editor_plugin.h
index ebd3f77fe7..b0e366b140 100644
--- a/tools/editor/plugins/spatial_editor_plugin.h
+++ b/tools/editor/plugins/spatial_editor_plugin.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -137,7 +137,6 @@ private:
Vector3 _get_screen_to_space(const Vector3& p_vector3);
void _select_region();
- void _update_selection();
bool _gizmo_select(const Vector2& p_screenpos,bool p_hilite_only=false);
float get_znear() const;
@@ -239,6 +238,7 @@ private:
void _finish_gizmo_instances();
void _selection_result_pressed(int);
void _selection_menu_hide();
+ void _list_select(InputEventMouseButton b);
protected:
@@ -287,7 +287,9 @@ public:
TOOL_MODE_SELECT,
TOOL_MODE_MOVE,
TOOL_MODE_ROTATE,
- TOOL_MODE_SCALE
+ TOOL_MODE_SCALE,
+ TOOL_MODE_LIST_SELECT,
+ TOOL_MAX
};
@@ -369,6 +371,7 @@ private:
MENU_TOOL_MOVE,
MENU_TOOL_ROTATE,
MENU_TOOL_SCALE,
+ MENU_TOOL_LIST_SELECT,
MENU_TRANSFORM_USE_SNAP,
MENU_TRANSFORM_CONFIGURE_SNAP,
MENU_TRANSFORM_LOCAL_COORDS,
@@ -392,7 +395,7 @@ private:
};
- Button *tool_button[4];
+ Button *tool_button[TOOL_MAX];
Button *instance_button;
diff --git a/tools/editor/plugins/sprite_frames_editor_plugin.cpp b/tools/editor/plugins/sprite_frames_editor_plugin.cpp
index e90087efda..af73828b61 100644
--- a/tools/editor/plugins/sprite_frames_editor_plugin.cpp
+++ b/tools/editor/plugins/sprite_frames_editor_plugin.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -338,7 +338,6 @@ void SpriteFramesEditor::_update_library() {
TreeItem *ti = tree->create_item(root);
ti->set_cell_mode(0,TreeItem::CELL_MODE_STRING);
- ti->set_editable(0,true);
ti->set_selectable(0,true);
if (frames->get_frame(i).is_null()) {
@@ -346,7 +345,7 @@ void SpriteFramesEditor::_update_library() {
ti->set_text(0,"Frame "+itos(i)+" (empty)");
} else {
- ti->set_text(0,"Frame "+itos(i));
+ ti->set_text(0,"Frame "+itos(i)+" ("+frames->get_frame(i)->get_name()+")");
ti->set_icon(0,frames->get_frame(i));
}
if (frames->get_frame(i).is_valid())
@@ -486,11 +485,15 @@ bool SpriteFramesEditorPlugin::handles(Object *p_object) const {
void SpriteFramesEditorPlugin::make_visible(bool p_visible) {
if (p_visible) {
- frames_editor->show();
+ button->show();
+ editor->make_bottom_panel_item_visible(frames_editor);
// frames_editor->set_process(true);
} else {
- frames_editor->hide();
+ button->hide();
+ if (frames_editor->is_visible())
+ editor->hide_bottom_panel();
+
// frames_editor->set_process(false);
}
@@ -500,11 +503,9 @@ SpriteFramesEditorPlugin::SpriteFramesEditorPlugin(EditorNode *p_node) {
editor=p_node;
frames_editor = memnew( SpriteFramesEditor );
- editor->get_viewport()->add_child(frames_editor);
- frames_editor->set_area_as_parent_rect();
-// frames_editor->set_anchor( MARGIN_TOP, Control::ANCHOR_END);
-// frames_editor->set_margin( MARGIN_TOP, 120 );
- frames_editor->hide();
+ frames_editor->set_custom_minimum_size(Size2(0,300));
+ button=editor->add_bottom_panel_item("SpriteFrames",frames_editor);
+ button->hide();
diff --git a/tools/editor/plugins/sprite_frames_editor_plugin.h b/tools/editor/plugins/sprite_frames_editor_plugin.h
index 969d7b1ce3..5d0a6cb035 100644
--- a/tools/editor/plugins/sprite_frames_editor_plugin.h
+++ b/tools/editor/plugins/sprite_frames_editor_plugin.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -94,6 +94,7 @@ class SpriteFramesEditorPlugin : public EditorPlugin {
SpriteFramesEditor *frames_editor;
EditorNode *editor;
+ Button *button;
public:
diff --git a/tools/editor/plugins/sprite_region_editor_plugin.cpp b/tools/editor/plugins/sprite_region_editor_plugin.cpp
index 35c53cf562..8dfa8a60a6 100644
--- a/tools/editor/plugins/sprite_region_editor_plugin.cpp
+++ b/tools/editor/plugins/sprite_region_editor_plugin.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Author: Mariano Suligoy */
/* */
@@ -367,7 +367,7 @@ void SpriteRegionEditor::edit(Node *p_sprite)
{
if (p_sprite) {
node=p_sprite->cast_to<Sprite>();
- node->connect("exit_tree",this,"_node_removed",varray(),CONNECT_ONESHOT);
+ node->connect("exit_tree",this,"_node_removed",varray(p_sprite),CONNECT_ONESHOT);
} else {
if (node)
node->disconnect("exit_tree",this,"_node_removed");
@@ -411,6 +411,7 @@ SpriteRegionEditor::SpriteRegionEditor(EditorNode* p_editor)
snap_step=Vector2(10,10);
use_snap=false;
snap_show_grid=false;
+ drag=false;
add_child( memnew( VSeparator ));
edit_node = memnew( ToolButton );
@@ -449,7 +450,7 @@ SpriteRegionEditor::SpriteRegionEditor(EditorNode* p_editor)
hb_tools->add_child( memnew( VSeparator ));
hb_tools->add_child( memnew( Label("Grid Offset:") ) );
- SpinBox *sb_off_x = memnew( SpinBox );
+ sb_off_x = memnew( SpinBox );
sb_off_x->set_min(-256);
sb_off_x->set_max(256);
sb_off_x->set_step(1);
@@ -458,7 +459,7 @@ SpriteRegionEditor::SpriteRegionEditor(EditorNode* p_editor)
sb_off_x->connect("value_changed", this, "_set_snap_off_x");
hb_tools->add_child(sb_off_x);
- SpinBox *sb_off_y = memnew( SpinBox );
+ sb_off_y = memnew( SpinBox );
sb_off_y->set_min(-256);
sb_off_y->set_max(256);
sb_off_y->set_step(1);
@@ -470,7 +471,7 @@ SpriteRegionEditor::SpriteRegionEditor(EditorNode* p_editor)
hb_tools->add_child( memnew( VSeparator ));
hb_tools->add_child( memnew( Label("Grid Step:") ) );
- SpinBox *sb_step_x = memnew( SpinBox );
+ sb_step_x = memnew( SpinBox );
sb_step_x->set_min(-256);
sb_step_x->set_max(256);
sb_step_x->set_step(1);
@@ -479,7 +480,7 @@ SpriteRegionEditor::SpriteRegionEditor(EditorNode* p_editor)
sb_step_x->connect("value_changed", this, "_set_snap_step_x");
hb_tools->add_child(sb_step_x);
- SpinBox *sb_step_y = memnew( SpinBox );
+ sb_step_y = memnew( SpinBox );
sb_step_y->set_min(-256);
sb_step_y->set_max(256);
sb_step_y->set_step(1);
@@ -488,8 +489,6 @@ SpriteRegionEditor::SpriteRegionEditor(EditorNode* p_editor)
sb_step_y->connect("value_changed", this, "_set_snap_step_y");
hb_tools->add_child(sb_step_y);
-// MARIANOGNU::TODO: Add more tools?
-
HBoxContainer *main_hb = memnew( HBoxContainer );
main_vb->add_child(main_hb);
edit_draw = memnew( Control );
@@ -554,6 +553,50 @@ void SpriteRegionEditorPlugin::make_visible(bool p_visible)
}
}
+
+Dictionary SpriteRegionEditorPlugin::get_state() const {
+
+ Dictionary state;
+ state["zoom"]=region_editor->zoom->get_val();
+ state["snap_offset"]=region_editor->snap_offset;
+ state["snap_step"]=region_editor->snap_step;
+ state["use_snap"]=region_editor->use_snap;
+ state["snap_show_grid"]=region_editor->snap_show_grid;
+ return state;
+}
+
+void SpriteRegionEditorPlugin::set_state(const Dictionary& p_state){
+
+ Dictionary state=p_state;
+ if (state.has("zoom")) {
+ region_editor->zoom->set_val(p_state["zoom"]);
+ }
+
+ if (state.has("snap_step")) {
+ Vector2 s = state["snap_step"];
+ region_editor->sb_step_x->set_val(s.x);
+ region_editor->sb_step_y->set_val(s.y);
+ region_editor->snap_step = s;
+ }
+
+ if (state.has("snap_offset")) {
+ Vector2 ofs = state["snap_offset"];
+ region_editor->sb_off_x->set_val(ofs.x);
+ region_editor->sb_off_y->set_val(ofs.y);
+ region_editor->snap_offset = ofs;
+ }
+
+ if (state.has("use_snap")) {
+ region_editor->use_snap=state["use_snap"];
+ region_editor->b_snap_enable->set_pressed(state["use_snap"]);
+ }
+
+ if (state.has("snap_show_grid")) {
+ region_editor->snap_show_grid=state["snap_show_grid"];
+ region_editor->b_snap_grid->set_pressed(state["snap_show_grid"]);
+ }
+}
+
SpriteRegionEditorPlugin::SpriteRegionEditorPlugin(EditorNode *p_node)
{
editor = p_node;
diff --git a/tools/editor/plugins/sprite_region_editor_plugin.h b/tools/editor/plugins/sprite_region_editor_plugin.h
index cf69395f40..47cb210863 100644
--- a/tools/editor/plugins/sprite_region_editor_plugin.h
+++ b/tools/editor/plugins/sprite_region_editor_plugin.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Author: Mariano Suligoy */
/* */
@@ -41,6 +41,8 @@ class SpriteRegionEditor : public HBoxContainer {
OBJ_TYPE(SpriteRegionEditor, HBoxContainer );
+ friend class SpriteRegionEditorPlugin;
+
ToolButton *edit_node;
// Button *use_region;
ToolButton *b_snap_enable;
@@ -48,6 +50,10 @@ class SpriteRegionEditor : public HBoxContainer {
TextureFrame *icon_zoom;
HSlider *zoom;
SpinBox *zoom_value;
+ SpinBox *sb_step_y;
+ SpinBox *sb_step_x;
+ SpinBox *sb_off_y;
+ SpinBox *sb_off_x;
Control *edit_draw;
VScrollBar *vscroll;
@@ -113,11 +119,13 @@ class SpriteRegionEditorPlugin : public EditorPlugin
EditorNode *editor;
public:
- virtual String get_name() const { return "Sprite"; }
+ virtual String get_name() const { return "SpriteRegion"; }
bool has_main_screen() const { return false; }
virtual void edit(Object *p_node);
virtual bool handles(Object *p_node) const;
virtual void make_visible(bool p_visible);
+ void set_state(const Dictionary &p_state);
+ Dictionary get_state() const;
SpriteRegionEditorPlugin(EditorNode *p_node);
};
diff --git a/tools/editor/plugins/stream_editor_plugin.cpp b/tools/editor/plugins/stream_editor_plugin.cpp
index 81db7f2846..d896784074 100644
--- a/tools/editor/plugins/stream_editor_plugin.cpp
+++ b/tools/editor/plugins/stream_editor_plugin.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/plugins/stream_editor_plugin.h b/tools/editor/plugins/stream_editor_plugin.h
index 7378bfad0c..5730612d61 100644
--- a/tools/editor/plugins/stream_editor_plugin.h
+++ b/tools/editor/plugins/stream_editor_plugin.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/plugins/style_box_editor_plugin.cpp b/tools/editor/plugins/style_box_editor_plugin.cpp
index 898c69e1e0..3d7cf4135d 100644
--- a/tools/editor/plugins/style_box_editor_plugin.cpp
+++ b/tools/editor/plugins/style_box_editor_plugin.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -90,19 +90,24 @@ bool StyleBoxEditorPlugin::handles(Object *p_node) const{
void StyleBoxEditorPlugin::make_visible(bool p_visible){
- if (p_visible)
- stylebox_editor->show();
- else
- stylebox_editor->hide();
+ if (p_visible) {
+ button->show();
+
+ } else {
+ if (stylebox_editor->is_visible())
+ EditorNode::get_singleton()->hide_bottom_panel();
+ button->hide();
+ }
}
StyleBoxEditorPlugin::StyleBoxEditorPlugin(EditorNode *p_node) {
stylebox_editor = memnew( StyleBoxEditor );
+ stylebox_editor->set_custom_minimum_size(Size2(0,250));
- p_node->get_viewport()->add_child(stylebox_editor);
- stylebox_editor->set_area_as_parent_rect();
- stylebox_editor->hide();
+ //p_node->get_viewport()->add_child(stylebox_editor);
+ button = p_node->add_bottom_panel_item("StyleBox",stylebox_editor);
+ button->hide();
}
diff --git a/tools/editor/plugins/style_box_editor_plugin.h b/tools/editor/plugins/style_box_editor_plugin.h
index 00b0871572..737f830bbb 100644
--- a/tools/editor/plugins/style_box_editor_plugin.h
+++ b/tools/editor/plugins/style_box_editor_plugin.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -65,6 +65,7 @@ class StyleBoxEditorPlugin : public EditorPlugin {
StyleBoxEditor *stylebox_editor;
EditorNode *editor;
+ Button *button;
public:
diff --git a/tools/editor/plugins/theme_editor_plugin.cpp b/tools/editor/plugins/theme_editor_plugin.cpp
index 63ba57bfc0..ef7b3b17c3 100644
--- a/tools/editor/plugins/theme_editor_plugin.cpp
+++ b/tools/editor/plugins/theme_editor_plugin.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -831,21 +831,26 @@ bool ThemeEditorPlugin::handles(Object *p_node) const{
void ThemeEditorPlugin::make_visible(bool p_visible){
if (p_visible) {
- theme_editor->show();
theme_editor->set_process(true);
+ button->show();
} else {
- theme_editor->hide();
theme_editor->set_process(false);
+ if (theme_editor->is_visible())
+ EditorNode::get_singleton()->hide_bottom_panel();
+ button->hide();
}
}
ThemeEditorPlugin::ThemeEditorPlugin(EditorNode *p_node) {
+ editor=p_node;
theme_editor = memnew( ThemeEditor );
+ theme_editor->set_custom_minimum_size(Size2(0,500));
+
+// p_node->get_viewport()->add_child(theme_editor);
+ button=EditorNode::get_singleton()->add_bottom_panel_item("Theme",theme_editor);
+ button->hide();
- p_node->get_viewport()->add_child(theme_editor);
- theme_editor->set_area_as_parent_rect();
- theme_editor->hide();
}
diff --git a/tools/editor/plugins/theme_editor_plugin.h b/tools/editor/plugins/theme_editor_plugin.h
index 40c7ad8186..52c4aed839 100644
--- a/tools/editor/plugins/theme_editor_plugin.h
+++ b/tools/editor/plugins/theme_editor_plugin.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -102,6 +102,7 @@ class ThemeEditorPlugin : public EditorPlugin {
ThemeEditor *theme_editor;
EditorNode *editor;
+ Button *button;
public:
diff --git a/tools/editor/plugins/tile_map_editor_plugin.cpp b/tools/editor/plugins/tile_map_editor_plugin.cpp
index 66c7a39096..29326a2222 100644
--- a/tools/editor/plugins/tile_map_editor_plugin.cpp
+++ b/tools/editor/plugins/tile_map_editor_plugin.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -218,7 +218,8 @@ struct _TileMapEditorCopyData {
bool TileMapEditor::forward_input_event(const InputEvent& p_event) {
- if (!node || !node->get_tileset().is_valid())
+
+ if (!node || !node->get_tileset().is_valid() || !node->is_visible())
return false;
Matrix32 xform = CanvasItemEditor::get_singleton()->get_canvas_transform() * node->get_global_transform();
@@ -675,12 +676,9 @@ void TileMapEditor::_canvas_draw() {
Ref<Texture> t = ts->tile_get_texture(st);
if (t.is_valid()) {
Vector2 from = node->map_to_world(over_tile)+node->get_cell_draw_offset();
+ Vector2 tile_ofs = ts->tile_get_texture_offset(st);
Rect2 r = ts->tile_get_region(st);
Size2 sc = xform.get_scale();
- if (mirror_x->is_pressed())
- sc.x*=-1.0;
- if (mirror_y->is_pressed())
- sc.y*=-1.0;
Rect2 rect;
if (r==Rect2()) {
@@ -690,23 +688,47 @@ void TileMapEditor::_canvas_draw() {
rect=Rect2(from,r.get_size());
}
+ bool transp = transpose->is_pressed();
+ bool flip_h = mirror_x->is_pressed();
+ bool flip_v = mirror_y->is_pressed();
+
+ if (rect.size.y > rect.size.x) {
+ if ((flip_h && (flip_v || transp)) || (flip_v && !transp))
+ tile_ofs.y += rect.size.y - rect.size.x;
+ } else if (rect.size.y < rect.size.x) {
+ if ((flip_v && (flip_h || transp)) || (flip_h && !transp))
+ tile_ofs.x += rect.size.x - rect.size.y;
+ }
+
+ if (transp) {
+ SWAP(tile_ofs.x, tile_ofs.y);
+ }
+
+ if (flip_h) {
+ sc.x*=-1.0;
+ tile_ofs.x*=-1.0;
+ }
+ if (flip_v) {
+ sc.y*=-1.0;
+ tile_ofs.y*=-1.0;
+ }
if (node->get_tile_origin()==TileMap::TILE_ORIGIN_TOP_LEFT) {
- rect.pos+=ts->tile_get_texture_offset(st);
+ rect.pos+=tile_ofs;
} else if (node->get_tile_origin()==TileMap::TILE_ORIGIN_CENTER) {
rect.pos+=node->get_cell_size()/2;
Vector2 s = r.size;
- Vector2 center = (s/2) - ts->tile_get_texture_offset(st);
+ Vector2 center = (s/2) - tile_ofs;
- if (mirror_x->is_pressed())
+ if (flip_h)
rect.pos.x-=s.x-center.x;
else
rect.pos.x-=center.x;
- if (mirror_y->is_pressed())
+ if (flip_v)
rect.pos.y-=s.y-center.y;
else
rect.pos.y-=center.y;
@@ -717,10 +739,10 @@ void TileMapEditor::_canvas_draw() {
if (r==Rect2()) {
- canvas_item_editor->draw_texture_rect(t,rect,false,Color(1,1,1,0.5),transpose->is_pressed());
+ canvas_item_editor->draw_texture_rect(t,rect,false,Color(1,1,1,0.5),transp);
} else {
- canvas_item_editor->draw_texture_rect_region(t,rect,r,Color(1,1,1,0.5),transpose->is_pressed());
+ canvas_item_editor->draw_texture_rect_region(t,rect,r,Color(1,1,1,0.5),transp);
}
}
}
diff --git a/tools/editor/plugins/tile_map_editor_plugin.h b/tools/editor/plugins/tile_map_editor_plugin.h
index 74d1573d0f..3cbf5ff68d 100644
--- a/tools/editor/plugins/tile_map_editor_plugin.h
+++ b/tools/editor/plugins/tile_map_editor_plugin.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/plugins/tile_set_editor_plugin.cpp b/tools/editor/plugins/tile_set_editor_plugin.cpp
index 09115472a8..06046b226a 100644
--- a/tools/editor/plugins/tile_set_editor_plugin.cpp
+++ b/tools/editor/plugins/tile_set_editor_plugin.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -145,10 +145,6 @@ void TileSetEditor::_menu_confirm() {
switch(option) {
- case MENU_OPTION_REMOVE_ITEM: {
-
- tileset->remove_tile(to_erase);
- } break;
case MENU_OPTION_MERGE_FROM_SCENE:
case MENU_OPTION_CREATE_FROM_SCENE: {
@@ -165,6 +161,27 @@ void TileSetEditor::_menu_confirm() {
}
}
+void TileSetEditor::_name_dialog_confirm(const String& name) {
+
+ switch (option) {
+
+ case MENU_OPTION_REMOVE_ITEM: {
+
+ int id=tileset->find_tile_by_name(name);
+
+ if (id<0 && name.is_valid_integer())
+ id=name.to_int();
+
+ if (tileset->has_tile(id)) {
+ tileset->remove_tile(id);
+ } else {
+ err_dialog->set_text("Could not find tile: " + name);
+ err_dialog->popup_centered(Size2(300, 60));
+ }
+ } break;
+ }
+}
+
void TileSetEditor::_menu_cbk(int p_option) {
option=p_option;
@@ -176,13 +193,9 @@ void TileSetEditor::_menu_cbk(int p_option) {
} break;
case MENU_OPTION_REMOVE_ITEM: {
- String p = editor->get_property_editor()->get_selected_path();
- if (p.begins_with("/TileSet") && p.get_slice_count("/")>=2) {
-
- to_erase = p.get_slice("/",2).to_int();
- cd->set_text("Remove Item "+itos(to_erase)+"?");
- cd->popup_centered(Size2(300,60));
- }
+ nd->set_title("Remove Item");
+ nd->set_text("Item name or ID:");
+ nd->popup_centered(Size2(300, 95));
} break;
case MENU_OPTION_CREATE_FROM_SCENE: {
@@ -210,6 +223,7 @@ void TileSetEditor::_bind_methods() {
ObjectTypeDB::bind_method("_menu_cbk",&TileSetEditor::_menu_cbk);
ObjectTypeDB::bind_method("_menu_confirm",&TileSetEditor::_menu_confirm);
+ ObjectTypeDB::bind_method("_name_dialog_confirm",&TileSetEditor::_name_dialog_confirm);
}
TileSetEditor::TileSetEditor(EditorNode *p_editor) {
@@ -222,7 +236,7 @@ TileSetEditor::TileSetEditor(EditorNode *p_editor) {
options->set_pos(Point2(1,1));
options->set_text("Theme");
options->get_popup()->add_item("Add Item",MENU_OPTION_ADD_ITEM);
- options->get_popup()->add_item("Remove Selected Item",MENU_OPTION_REMOVE_ITEM);
+ options->get_popup()->add_item("Remove Item",MENU_OPTION_REMOVE_ITEM);
options->get_popup()->add_separator();
options->get_popup()->add_item("Create from Scene",MENU_OPTION_CREATE_FROM_SCENE);
options->get_popup()->add_item("Merge from Scene",MENU_OPTION_MERGE_FROM_SCENE);
@@ -232,6 +246,15 @@ TileSetEditor::TileSetEditor(EditorNode *p_editor) {
add_child(cd);
cd->get_ok()->connect("pressed", this,"_menu_confirm");
+ nd = memnew(EditorNameDialog);
+ add_child(nd);
+ nd->set_hide_on_ok(true);
+ nd->get_line_edit()->set_margin(MARGIN_TOP,28);
+ nd->connect("name_confirmed", this,"_name_dialog_confirm");
+
+ err_dialog = memnew(AcceptDialog);
+ add_child(err_dialog);
+ err_dialog->set_title("Error");
}
void TileSetEditorPlugin::edit(Object *p_node) {
diff --git a/tools/editor/plugins/tile_set_editor_plugin.h b/tools/editor/plugins/tile_set_editor_plugin.h
index df82df6993..3f47520e2a 100644
--- a/tools/editor/plugins/tile_set_editor_plugin.h
+++ b/tools/editor/plugins/tile_set_editor_plugin.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -33,6 +33,7 @@
#include "scene/resources/tile_set.h"
#include "tools/editor/editor_node.h"
+#include "tools/editor/editor_name_dialog.h"
class TileSetEditor : public Control {
@@ -44,7 +45,8 @@ class TileSetEditor : public Control {
EditorNode *editor;
MenuButton *menu;
ConfirmationDialog *cd;
- int to_erase;
+ EditorNameDialog *nd;
+ AcceptDialog *err_dialog;
enum {
@@ -56,7 +58,8 @@ class TileSetEditor : public Control {
int option;
void _menu_cbk(int p_option);
- void _menu_confirm();
+ void _menu_confirm();
+ void _name_dialog_confirm(const String& name);
static void _import_scene(Node *p_scene, Ref<TileSet> p_library, bool p_merge);
diff --git a/tools/editor/progress_dialog.cpp b/tools/editor/progress_dialog.cpp
index c8b87486c0..d072ce7f83 100644
--- a/tools/editor/progress_dialog.cpp
+++ b/tools/editor/progress_dialog.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -29,7 +29,7 @@
#include "progress_dialog.h"
#include "main/main.h"
#include "message_queue.h"
-
+#include "os/os.h"
void BackgroundProgress::_add_task(const String& p_task,const String& p_label, int p_steps) {
@@ -191,10 +191,16 @@ void ProgressDialog::add_task(const String& p_task,const String& p_label,int p_s
}
-void ProgressDialog::task_step(const String& p_task, const String& p_state, int p_step){
+void ProgressDialog::task_step(const String& p_task, const String& p_state, int p_step,bool p_force_redraw){
ERR_FAIL_COND(!tasks.has(p_task));
+ if (!p_force_redraw) {
+ uint64_t tus = OS::get_singleton()->get_ticks_usec();
+ if (tus-last_progress_tick < 50000) //50ms
+ return;
+ }
+
Task &t=tasks[p_task];
if (p_step<0)
t.progress->set_val(t.progress->get_val()+1);
@@ -202,6 +208,7 @@ void ProgressDialog::task_step(const String& p_task, const String& p_state, int
t.progress->set_val(p_step);
t.state->set_text(p_state);
+ last_progress_tick=OS::get_singleton()->get_ticks_usec();
Main::iteration(); // this will not work on a lot of platforms, so it's only meant for the editor
}
@@ -229,4 +236,5 @@ ProgressDialog::ProgressDialog() {
add_child(main);
main->set_area_as_parent_rect();
set_exclusive(true);
+ last_progress_tick=0;
}
diff --git a/tools/editor/progress_dialog.h b/tools/editor/progress_dialog.h
index 7f1cc4cb2d..539eaa8737 100644
--- a/tools/editor/progress_dialog.h
+++ b/tools/editor/progress_dialog.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -84,6 +84,7 @@ class ProgressDialog : public Popup {
Map<String,Task> tasks;
VBoxContainer *main;
+ uint64_t last_progress_tick;
void _popup();
protected:
@@ -92,7 +93,7 @@ protected:
public:
void add_task(const String& p_task,const String& p_label, int p_steps);
- void task_step(const String& p_task,const String& p_state, int p_step=-1);
+ void task_step(const String& p_task, const String& p_state, int p_step=-1, bool p_force_redraw=true);
void end_task(const String& p_task);
diff --git a/tools/editor/project_export.cpp b/tools/editor/project_export.cpp
index 3464b3c9bb..7690d31e7b 100644
--- a/tools/editor/project_export.cpp
+++ b/tools/editor/project_export.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -258,6 +258,7 @@ void ProjectExportDialog::_sample_convert_edited(int what) {
EditorImportExport::get_singleton()->sample_set_action( EditorImportExport::SampleAction(sample_mode->get_selected()));
EditorImportExport::get_singleton()->sample_set_max_hz( sample_max_hz->get_val() );
EditorImportExport::get_singleton()->sample_set_trim( sample_trim->is_pressed() );
+ _save_export_cfg();
}
@@ -297,6 +298,7 @@ void ProjectExportDialog::_notification(int p_what) {
// _rescan();
_update_platform();
export_mode->select( EditorImportExport::get_singleton()->get_export_filter() );
+ convert_text_scenes->set_pressed( EditorImportExport::get_singleton()->get_convert_text_scenes() );
filters->set_text( EditorImportExport::get_singleton()->get_export_custom_filter() );
if (EditorImportExport::get_singleton()->get_export_filter()!=EditorImportExport::EXPORT_SELECTED)
tree_vb->hide();
@@ -420,6 +422,8 @@ void ProjectExportDialog::_export_mode_changed(int p_idx) {
else
tree_vb->show();
+ EditorImportExport::get_singleton()->set_convert_text_scenes( convert_text_scenes->is_pressed() );
+
_save_export_cfg();
}
@@ -468,20 +472,32 @@ void ProjectExportDialog::_export_action_pck(const String& p_file) {
ERR_PRINT("Invalid platform for export of PCK");
return;
}
- FileAccess *f = FileAccess::open(p_file,FileAccess::WRITE);
- if (!f) {
- error->set_text("Error exporting project PCK! Can't write");
- error->popup_centered_minsize();
- }
- ERR_FAIL_COND(!f);
- Error err = exporter->save_pack(f,false);
- memdelete(f);
+ if (p_file.ends_with(".pck")) {
+ FileAccess *f = FileAccess::open(p_file,FileAccess::WRITE);
+ if (!f) {
+ error->set_text("Error exporting project PCK! Can't write");
+ error->popup_centered_minsize();
+ }
+ ERR_FAIL_COND(!f);
- if (err!=OK) {
- error->set_text("Error exporting project!");
- error->popup_centered_minsize();
- return;
+ Error err = exporter->save_pack(f,false);
+ memdelete(f);
+
+ if (err!=OK) {
+ error->set_text("Error exporting project!");
+ error->popup_centered_minsize();
+ return;
+ }
+ } else if (p_file.ends_with(".zip")) {
+
+ Error err = exporter->save_zip(p_file,false);
+
+ if (err!=OK) {
+ error->set_text("Error exporting project!");
+ error->popup_centered_minsize();
+ return;
+ }
}
}
@@ -1137,6 +1153,7 @@ ProjectExportDialog::ProjectExportDialog(EditorNode *p_editor) {
vb = memnew( VBoxContainer );
vb->set_name("Resources");
sections->add_child(vb);
+
export_mode = memnew( OptionButton );
export_mode->add_item("Export selected resources (including dependencies).");
export_mode->add_item("Export all resources in the project.");
@@ -1145,6 +1162,8 @@ ProjectExportDialog::ProjectExportDialog(EditorNode *p_editor) {
vb->add_margin_child("Export Mode:",export_mode);
+
+
tree_vb = memnew( VBoxContainer );
vb->add_child(tree_vb);
tree_vb->set_v_size_flags(SIZE_EXPAND_FILL);
@@ -1165,6 +1184,10 @@ ProjectExportDialog::ProjectExportDialog(EditorNode *p_editor) {
vb->add_margin_child("Filters to export non-resource files (Comma Separated, ie: *.json, *.txt):",filters);
filters->connect("text_changed",this,"_filters_edited");
+ convert_text_scenes = memnew( CheckButton );
+ convert_text_scenes->set_text("Convert text scenes to binary on export");
+ vb->add_child(convert_text_scenes);
+ convert_text_scenes->connect("toggled",this,"_export_mode_changed");
image_vb = memnew( VBoxContainer );
image_vb->set_name("Images");
@@ -1385,7 +1408,7 @@ ProjectExportDialog::ProjectExportDialog(EditorNode *p_editor) {
add_child(confirm);
confirm->connect("confirmed",this,"_confirmed");
- get_ok()->set_text("Export PCK");
+ get_ok()->set_text("Export PCK/Zip");
expopt="--,Export,Bundle";
@@ -1415,6 +1438,7 @@ ProjectExportDialog::ProjectExportDialog(EditorNode *p_editor) {
pck_export->set_title("Export Project PCK");
pck_export->connect("file_selected", this,"_export_action_pck");
pck_export->add_filter("*.pck ; Data Pack");
+ pck_export->add_filter("*.zip ; Zip");
add_child(pck_export);
button_export = add_button("Export..",!OS::get_singleton()->get_swap_ok_cancel(),"export_pck");
diff --git a/tools/editor/project_export.h b/tools/editor/project_export.h
index 2f824e5ff7..5a42a58e58 100644
--- a/tools/editor/project_export.h
+++ b/tools/editor/project_export.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -108,6 +108,7 @@ private:
PropertyEditor *platform_options;
OptionButton *export_mode;
+ CheckButton *convert_text_scenes;
VBoxContainer *tree_vb;
VBoxContainer *image_vb;
diff --git a/tools/editor/project_manager.cpp b/tools/editor/project_manager.cpp
index 04705017d2..589d9d3d99 100644
--- a/tools/editor/project_manager.cpp
+++ b/tools/editor/project_manager.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -348,6 +348,13 @@ struct ProjectItem {
_FORCE_INLINE_ bool operator ==(const ProjectItem& l) const { return project==l.project; }
};
+void ProjectManager::_notification(int p_what) {
+
+ if (p_what==NOTIFICATION_ENTER_TREE) {
+
+ get_tree()->set_editor_hint(true);
+ }
+}
void ProjectManager::_panel_draw(Node *p_hb) {
@@ -825,6 +832,19 @@ ProjectManager::ProjectManager() {
FileDialog::set_default_show_hidden_files(EditorSettings::get_singleton()->get("file_dialog/show_hidden_files"));
set_area_as_parent_rect();
+
+ Ref<Theme> theme = Ref<Theme>( memnew( Theme ) );
+ set_theme(theme);
+ editor_register_icons(theme);
+
+ String global_font = EditorSettings::get_singleton()->get("global/font");
+ if (global_font!="") {
+ Ref<Font> fnt = ResourceLoader::load(global_font);
+ if (fnt.is_valid()) {
+ theme->set_default_theme_font(fnt);
+ }
+ }
+
Panel *panel = memnew( Panel );
add_child(panel);
panel->set_area_as_parent_rect();
@@ -944,7 +964,7 @@ ProjectManager::ProjectManager() {
String cp;
cp.push_back(0xA9);
cp.push_back(0);
- l->set_text(cp+" 2008-2015 Juan Linietsky, Ariel Manzur.");
+ l->set_text(cp+" 2008-2016 Juan Linietsky, Ariel Manzur.");
l->set_align(Label::ALIGN_CENTER);
vb->add_child(l);
@@ -972,10 +992,6 @@ ProjectManager::ProjectManager() {
npdialog = memnew( NewProjectDialog );
add_child(npdialog);
- Ref<Theme> theme = memnew( Theme );
- editor_register_icons(theme);
- set_theme(theme);
-
npdialog->connect("project_created", this,"_load_recent_projects");
_load_recent_projects();
diff --git a/tools/editor/project_manager.h b/tools/editor/project_manager.h
index 1e6ea9c1c9..80c34690f8 100644
--- a/tools/editor/project_manager.h
+++ b/tools/editor/project_manager.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -85,6 +85,7 @@ class ProjectManager : public Control {
protected:
+ void _notification(int p_what);
static void _bind_methods();
public:
ProjectManager();
diff --git a/tools/editor/project_settings.cpp b/tools/editor/project_settings.cpp
index 2fd8b37753..6c5e18ec9a 100644
--- a/tools/editor/project_settings.cpp
+++ b/tools/editor/project_settings.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -33,6 +33,7 @@
#include "editor_node.h"
#include "scene/gui/margin_container.h"
#include "translation.h"
+#include "global_constants.h"
ProjectSettings *ProjectSettings::singleton=NULL;
@@ -106,6 +107,8 @@ void ProjectSettings::_action_persist_toggle() {
String name="input/"+ti->get_text(0);
bool prev = Globals::get_singleton()->is_persisting(name);
+ print_line("prev persist: "+itos(prev));
+ print_line("new persist: "+itos(ti->is_checked(0)));
if (prev==ti->is_checked(0))
return;
@@ -155,12 +158,14 @@ void ProjectSettings::_device_input_add() {
} break;
case InputEvent::JOYSTICK_MOTION: {
- ie.joy_motion.axis = device_index->get_selected();
+ ie.joy_motion.axis = device_index->get_selected()>>1;
+ ie.joy_motion.axis_value = device_index->get_selected()&1?1:-1;
+
for(int i=0;i<arr.size();i++) {
InputEvent aie=arr[i];
- if (aie.device == ie.device && aie.type==InputEvent::JOYSTICK_MOTION && aie.joy_motion.axis==ie.joy_motion.axis) {
+ if (aie.device == ie.device && aie.type==InputEvent::JOYSTICK_MOTION && aie.joy_motion.axis==ie.joy_motion.axis && aie.joy_motion.axis_value==ie.joy_motion.axis_value) {
return;
}
}
@@ -294,9 +299,10 @@ void ProjectSettings::_add_item(int p_item){
device_id->set_val(0);
device_index_label->set_text("Joy Button Axis:");
device_index->clear();
- for(int i=0;i<8;i++) {
+ for(int i=0;i<24;i++) {
+
- device_index->add_item("Axis "+itos(i));
+ device_index->add_item("Axis "+itos(i/2)+" "+(i&1?"+":"-"));
}
device_input->popup_centered(Size2(350,95));
@@ -338,6 +344,15 @@ void ProjectSettings::_action_button_pressed(Object* p_obj, int p_column,int p_i
add_at="input/"+ti->get_text(0);
} else if (p_id==2) {
+ //rename
+
+ add_at="input/"+ti->get_text(0);
+ rename_action->popup_centered();
+ rename_action->get_line_edit()->set_text(ti->get_text(0));
+ rename_action->get_line_edit()->set_cursor_pos(ti->get_text(0).length());
+ rename_action->get_line_edit()->select_all();
+
+ } else if (p_id==3) {
//remove
if (ti->get_parent()==input_editor->get_root()) {
@@ -415,13 +430,16 @@ void ProjectSettings::_update_actions() {
continue;
TreeItem *item=input_editor->create_item(root);
- item->set_cell_mode(0,TreeItem::CELL_MODE_CHECK);
+ //item->set_cell_mode(0,TreeItem::CELL_MODE_CHECK);
item->set_text(0,name);
item->add_button(0,get_icon("Add","EditorIcons"),1);
- item->add_button(0,get_icon("Remove","EditorIcons"),2);
+ if (!Globals::get_singleton()->get_input_presets().find(pi.name)) {
+ item->add_button(0,get_icon("Rename","EditorIcons"),2);
+ item->add_button(0,get_icon("Remove","EditorIcons"),3);
+ }
item->set_custom_bg_color(0,get_color("prop_subsection","Editor"));
item->set_editable(0,true);
- item->set_checked(0,pi.usage&PROPERTY_USAGE_CHECKED);
+ //item->set_checked(0,pi.usage&PROPERTY_USAGE_CHECKED);
@@ -481,12 +499,12 @@ void ProjectSettings::_update_actions() {
} break;
case InputEvent::JOYSTICK_MOTION: {
- String str = "Device "+itos(ie.device)+", Axis "+itos(ie.joy_motion.axis)+".";
+ String str = "Device "+itos(ie.device)+", Axis "+itos(ie.joy_motion.axis)+" "+(ie.joy_motion.axis_value<0?"-.":"+.");
action->set_text(0,str);
action->set_icon(0,get_icon("JoyAxis","EditorIcons"));
} break;
}
- action->add_button(0,get_icon("Remove","EditorIcons"),2);
+ action->add_button(0,get_icon("Remove","EditorIcons"),3);
action->set_metadata(0,i);
}
}
@@ -507,12 +525,12 @@ void ProjectSettings::popup_project_settings() {
void ProjectSettings::_item_selected() {
- TreeItem *ti = globals_editor->get_scene_tree()->get_selected();
+ TreeItem *ti = globals_editor->get_property_editor()->get_scene_tree()->get_selected();
if (!ti)
return;
if (!ti->get_parent())
return;
- category->set_text(ti->get_parent()->get_text(0));
+ category->set_text(globals_editor->get_current_section());
property->set_text(ti->get_text(0));
popup_platform->set_disabled(false);
@@ -551,7 +569,8 @@ void ProjectSettings::_item_add() {
String name = catname+"/"+propname;
Globals::get_singleton()->set(name,value);
- globals_editor->update_tree();
+ globals_editor->edit(NULL);
+ globals_editor->edit(Globals::get_singleton());
}
void ProjectSettings::_item_del() {
@@ -563,7 +582,7 @@ void ProjectSettings::_item_del() {
String name = catname+"/"+propname;
Globals::get_singleton()->set(name,Variant());
- globals_editor->update_tree();
+ globals_editor->get_property_editor()->update_tree();
}
@@ -616,14 +635,57 @@ void ProjectSettings::_action_add() {
}
+void ProjectSettings::_action_rename(const String &p_name) {
+
+
+ if (p_name.find("/")!=-1 || p_name.find(":")!=-1 || p_name=="") {
+ message->set_text("Invalid Action (Anything goes but / or :).");
+ message->popup_centered(Size2(300,100));
+ return;
+ }
+
+ String new_name = "input/"+p_name;
+
+ if (Globals::get_singleton()->has(new_name)) {
+ message->set_text("Action '"+p_name+"' already exists!.");
+ message->popup_centered(Size2(300,100));
+ return;
+ }
+
+ int order = Globals::get_singleton()->get_order(add_at);
+ Array va = Globals::get_singleton()->get(add_at);
+ bool persisting = Globals::get_singleton()->is_persisting(add_at);
+
+ undo_redo->create_action("Rename Input Action Event");
+ undo_redo->add_do_method(Globals::get_singleton(),"clear",add_at);
+ undo_redo->add_do_method(Globals::get_singleton(),"set",new_name,va);
+ undo_redo->add_do_method(Globals::get_singleton(),"set_persisting",new_name,persisting);
+ undo_redo->add_do_method(Globals::get_singleton(),"set_order",new_name,order);
+ undo_redo->add_undo_method(Globals::get_singleton(),"clear",new_name);
+ undo_redo->add_undo_method(Globals::get_singleton(),"set",add_at,va);
+ undo_redo->add_undo_method(Globals::get_singleton(),"set_persisting",add_at,persisting);
+ undo_redo->add_undo_method(Globals::get_singleton(),"set_order",add_at,order);
+ undo_redo->add_do_method(this,"_update_actions");
+ undo_redo->add_undo_method(this,"_update_actions");
+ undo_redo->add_do_method(this,"_settings_changed");
+ undo_redo->add_undo_method(this,"_settings_changed");
+ undo_redo->commit_action();
+
+ rename_action->hide();
+}
+
void ProjectSettings::_item_checked(const String& p_item, bool p_check) {
undo_redo->create_action("Toggle Persisting");
- undo_redo->add_do_method(Globals::get_singleton(),"set_persisting",p_item,p_check);
- undo_redo->add_undo_method(Globals::get_singleton(),"set_persisting",p_item,!p_check);
+ String full_item = globals_editor->get_full_item_path(p_item);
+
+ undo_redo->add_do_method(Globals::get_singleton(),"set_persisting",full_item,p_check);
+ undo_redo->add_undo_method(Globals::get_singleton(),"set_persisting",full_item,!p_check);
undo_redo->add_do_method(this,"_settings_changed");
undo_redo->add_undo_method(this,"_settings_changed");
+ undo_redo->add_do_method(globals_editor->get_property_editor(),"update_tree");
+ undo_redo->add_undo_method(globals_editor->get_property_editor(),"update_tree");
undo_redo->commit_action();
}
@@ -640,11 +702,22 @@ void ProjectSettings::_save() {
void ProjectSettings::_settings_prop_edited(const String& p_name) {
- if (!Globals::get_singleton()->is_persisting(p_name)) {
+ String full_item = globals_editor->get_full_item_path(p_name);
+
+ if (!Globals::get_singleton()->is_persisting(full_item)) {
+ Globals::get_singleton()->set_persisting(full_item,true);
+
+ {
+ //small usability workaround, if anything related to resolution scaling or size is modified, change all of them together
+ if (full_item=="display/width" || full_item=="display/height" || full_item=="display/stretch_mode") {
+ Globals::get_singleton()->set_persisting("display/height",true);
+ Globals::get_singleton()->set_persisting("display/width",true);
+ }
+ }
+
- Globals::get_singleton()->set_persisting(p_name,true);
// globals_editor->update_property(p_name);
- globals_editor->update_tree();
+ globals_editor->get_property_editor()->update_tree();
}
_settings_changed();
}
@@ -679,7 +752,7 @@ void ProjectSettings::_copy_to_platform(int p_which) {
name = catname+"/"+propname;
Globals::get_singleton()->set(name,value);
- globals_editor->update_tree();
+ globals_editor->get_property_editor()->update_tree();
}
@@ -722,6 +795,11 @@ void ProjectSettings::_translation_file_open() {
void ProjectSettings::_autoload_file_callback(const String& p_path) {
autoload_add_path->set_text(p_path);
+ //if (autoload_add_name->get_text().strip_edges()==String()) {
+
+ autoload_add_name->set_text( p_path.get_file().basename() );
+ //}
+
//_translation_add(p_translation);
}
@@ -730,6 +808,40 @@ void ProjectSettings::_autoload_file_open() {
autoload_file_open->popup_centered_ratio();
}
+void ProjectSettings::_autoload_edited() {
+
+ if (updating_autoload)
+ return;
+
+ TreeItem *ti = autoload_list->get_edited();
+ if (!ti || autoload_list->get_edited_column()!=2)
+ return;
+
+ updating_autoload=true;
+ bool checked=ti->is_checked(2);
+
+ String base="autoload/"+ti->get_text(0);
+
+ String path = Globals::get_singleton()->get(base);
+
+ if (path.begins_with("*"))
+ path=path.substr(1,path.length());
+
+ if (checked)
+ path="*"+path;
+
+ undo_redo->create_action("Toggle Autoload GlobalVar");
+ undo_redo->add_do_property(Globals::get_singleton(),base,path);
+ undo_redo->add_undo_property(Globals::get_singleton(),base,Globals::get_singleton()->get(base));
+ undo_redo->add_do_method(this,"_update_autoload");
+ undo_redo->add_undo_method(this,"_update_autoload");
+ undo_redo->add_do_method(this,"_settings_changed");
+ undo_redo->add_undo_method(this,"_settings_changed");
+ undo_redo->commit_action();
+ updating_autoload=false;
+
+}
+
void ProjectSettings::_autoload_add() {
String name = autoload_add_name->get_text();
@@ -740,6 +852,35 @@ void ProjectSettings::_autoload_add() {
}
+ if (ObjectTypeDB::type_exists(name)) {
+
+ message->set_text("Invalid Name.Must not collide with an existing engine class name.");
+ message->popup_centered(Size2(300,100));
+ return;
+
+ }
+
+ for(int i=0;i<Variant::VARIANT_MAX;i++) {
+ if (Variant::get_type_name(Variant::Type(i))==name) {
+
+ message->set_text("Invalid Name.Must not collide with an existing buit-in type name.");
+ message->popup_centered(Size2(300,100));
+ return;
+
+ }
+ }
+
+ for(int i=0;i<GlobalConstants::get_global_constant_count();i++) {
+
+ if (GlobalConstants::get_global_constant_name(i)==name) {
+
+ message->set_text("Invalid Name.Must not collide with an existing global constant name.");
+ message->popup_centered(Size2(300,100));
+ return;
+ }
+
+ }
+
String path = autoload_add_path->get_text();
if (!FileAccess::exists(path)) {
message->set_text("Invalid Path.\nFile does not exist.");
@@ -756,7 +897,7 @@ void ProjectSettings::_autoload_add() {
undo_redo->create_action("Add Autoload");
name = "autoload/"+name;
- undo_redo->add_do_property(Globals::get_singleton(),name,path);
+ undo_redo->add_do_property(Globals::get_singleton(),name,"*"+path);
if (Globals::get_singleton()->has(name))
undo_redo->add_undo_property(Globals::get_singleton(),name,Globals::get_singleton()->get(name));
else
@@ -769,6 +910,9 @@ void ProjectSettings::_autoload_add() {
undo_redo->add_undo_method(this,"_settings_changed");
undo_redo->commit_action();
+ autoload_add_path->set_text("");
+ autoload_add_name->set_text("");
+
//autoload_file_open->popup_centered_ratio();
}
@@ -803,11 +947,14 @@ void ProjectSettings::_autoload_delete(Object *p_item,int p_column, int p_button
String swap_name= "autoload/"+swap->get_text(0);
+ int order = Globals::get_singleton()->get_order(name);
+ int swap_order = Globals::get_singleton()->get_order(swap_name);
+
undo_redo->create_action("Move Autoload");
- undo_redo->add_do_method(Globals::get_singleton(),"set_order",swap_name,Globals::get_singleton()->get_order(name));
- undo_redo->add_do_method(Globals::get_singleton(),"set_order",name,Globals::get_singleton()->get_order(swap_name));
- undo_redo->add_undo_method(Globals::get_singleton(),"set_order",swap_name,Globals::get_singleton()->get_order(swap_name));
- undo_redo->add_undo_method(Globals::get_singleton(),"set_order",name,Globals::get_singleton()->get_order(name));
+ undo_redo->add_do_method(Globals::get_singleton(),"set_order",swap_name,order);
+ undo_redo->add_do_method(Globals::get_singleton(),"set_order",name,swap_order);
+ undo_redo->add_undo_method(Globals::get_singleton(),"set_order",swap_name,swap_order);
+ undo_redo->add_undo_method(Globals::get_singleton(),"set_order",name,order);
undo_redo->add_do_method(this,"_update_autoload");
undo_redo->add_undo_method(this,"_update_autoload");
undo_redo->add_do_method(this,"_settings_changed");
@@ -1146,6 +1293,11 @@ void ProjectSettings::_update_translations() {
void ProjectSettings::_update_autoload() {
+ if (updating_autoload)
+ return;
+
+ updating_autoload=true;
+
autoload_list->clear();
TreeItem *root = autoload_list->create_item();
autoload_list->set_hide_root(true);
@@ -1160,23 +1312,36 @@ void ProjectSettings::_update_autoload() {
continue;
String name = pi.name.get_slice("/",1);
+ String path = Globals::get_singleton()->get(pi.name);
+
if (name=="")
continue;
-
+ bool global=false;
+ if (path.begins_with("*")) {
+ path=path.substr(1,path.length());
+ global=true;
+ }
TreeItem *t = autoload_list->create_item(root);
t->set_text(0,name);
- t->set_text(1,Globals::get_singleton()->get(pi.name));
- t->add_button(1,get_icon("MoveUp","EditorIcons"),1);
- t->add_button(1,get_icon("MoveDown","EditorIcons"),2);
- t->add_button(1,get_icon("Del","EditorIcons"),0);
+ t->set_text(1,path);
+ t->set_cell_mode(2,TreeItem::CELL_MODE_CHECK);
+ t->set_editable(2,true);
+ t->set_text(2,"Enable");
+ t->set_checked(2,global);
+ t->add_button(3,get_icon("MoveUp","EditorIcons"),1);
+ t->add_button(3,get_icon("MoveDown","EditorIcons"),2);
+ t->add_button(3,get_icon("Del","EditorIcons"),0);
+
}
+ updating_autoload=false;
+
}
void ProjectSettings::_toggle_search_bar(bool p_pressed) {
- globals_editor->set_use_filter(p_pressed);
+ globals_editor->get_property_editor()->set_use_filter(p_pressed);
if (p_pressed) {
@@ -1197,7 +1362,7 @@ void ProjectSettings::_clear_search_box() {
return;
search_box->clear();
- globals_editor->update_tree();
+ globals_editor->get_property_editor()->update_tree();
}
void ProjectSettings::_bind_methods() {
@@ -1212,6 +1377,7 @@ void ProjectSettings::_bind_methods() {
ObjectTypeDB::bind_method(_MD("_action_adds"),&ProjectSettings::_action_adds);
ObjectTypeDB::bind_method(_MD("_action_persist_toggle"),&ProjectSettings::_action_persist_toggle);
ObjectTypeDB::bind_method(_MD("_action_button_pressed"),&ProjectSettings::_action_button_pressed);
+ ObjectTypeDB::bind_method(_MD("_action_rename"),&ProjectSettings::_action_rename);
ObjectTypeDB::bind_method(_MD("_update_actions"),&ProjectSettings::_update_actions);
ObjectTypeDB::bind_method(_MD("_wait_for_key"),&ProjectSettings::_wait_for_key);
ObjectTypeDB::bind_method(_MD("_add_item"),&ProjectSettings::_add_item);
@@ -1239,6 +1405,7 @@ void ProjectSettings::_bind_methods() {
ObjectTypeDB::bind_method(_MD("_autoload_file_callback"),&ProjectSettings::_autoload_file_callback);
ObjectTypeDB::bind_method(_MD("_update_autoload"),&ProjectSettings::_update_autoload);
ObjectTypeDB::bind_method(_MD("_autoload_delete"),&ProjectSettings::_autoload_delete);
+ ObjectTypeDB::bind_method(_MD("_autoload_edited"),&ProjectSettings::_autoload_edited);
ObjectTypeDB::bind_method(_MD("_clear_search_box"),&ProjectSettings::_clear_search_box);
ObjectTypeDB::bind_method(_MD("_toggle_search_bar"),&ProjectSettings::_toggle_search_bar);
@@ -1339,15 +1506,15 @@ ProjectSettings::ProjectSettings(EditorData *p_data) {
search_bar->add_child(clear_button);
clear_button->connect("pressed",this,"_clear_search_box");
- globals_editor = memnew( PropertyEditor );
+ globals_editor = memnew( SectionedPropertyEditor );
props_base->add_child(globals_editor);
- globals_editor->hide_top_label();
+ //globals_editor->hide_top_label();
globals_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL);
- globals_editor->register_text_enter(search_box);
- globals_editor->set_capitalize_paths(false);
- globals_editor->get_scene_tree()->connect("cell_selected",this,"_item_selected");
- globals_editor->connect("property_toggled",this,"_item_checked");
- globals_editor->connect("property_edited",this,"_settings_prop_edited");
+ globals_editor->get_property_editor()->register_text_enter(search_box);
+ globals_editor->get_property_editor()->set_capitalize_paths(false);
+ globals_editor->get_property_editor()->get_scene_tree()->connect("cell_selected",this,"_item_selected");
+ globals_editor->get_property_editor()->connect("property_toggled",this,"_item_checked",varray(),CONNECT_DEFERRED);
+ globals_editor->get_property_editor()->connect("property_edited",this,"_settings_prop_edited");
/*
Button *save = memnew( Button );
@@ -1431,12 +1598,17 @@ ProjectSettings::ProjectSettings(EditorData *p_data) {
add_child(popup_add);
popup_add->connect("item_pressed",this,"_add_item");
+ rename_action = memnew( EditorNameDialog );
+ add_child(rename_action);
+ rename_action->set_hide_on_ok(false);
+ rename_action->set_size(Size2(200, 70));
+ rename_action->set_title("Rename Input Action");
+ rename_action->connect("name_confirmed", this,"_action_rename");
+
press_a_key = memnew( ConfirmationDialog );
press_a_key->set_focus_mode(FOCUS_ALL);
add_child(press_a_key);
-
-
l = memnew( Label );
l->set_text("Press a Key..");
l->set_area_as_parent_rect();
@@ -1589,11 +1761,6 @@ ProjectSettings::ProjectSettings(EditorData *p_data) {
HBoxContainer *ahb = memnew( HBoxContainer);
avb->add_child(ahb);
- VBoxContainer *avb_name = memnew( VBoxContainer );
- avb_name->set_h_size_flags(SIZE_EXPAND_FILL);
- autoload_add_name = memnew(LineEdit);
- avb_name->add_margin_child("Node Name:",autoload_add_name);
- ahb->add_child(avb_name);
VBoxContainer *avb_path = memnew( VBoxContainer );
avb_path->set_h_size_flags(SIZE_EXPAND_FILL);
@@ -1604,13 +1771,24 @@ ProjectSettings::ProjectSettings(EditorData *p_data) {
Button *browseaa = memnew( Button("..") );
ahb_path->add_child(browseaa);
browseaa->connect("pressed",this,"_autoload_file_open");
- Button *addaa = memnew( Button("Add") );
- ahb_path->add_child(addaa);
- addaa->connect("pressed",this,"_autoload_add");
avb_path->add_margin_child("Path:",ahb_path);
ahb->add_child(avb_path);
+ VBoxContainer *avb_name = memnew( VBoxContainer );
+ avb_name->set_h_size_flags(SIZE_EXPAND_FILL);
+
+ HBoxContainer *ahb_name = memnew( HBoxContainer );
+ autoload_add_name = memnew(LineEdit);
+ autoload_add_name->set_h_size_flags(SIZE_EXPAND_FILL);
+ ahb_name->add_child(autoload_add_name);
+ avb_name->add_margin_child("Node Name:",ahb_name);
+ Button *addaa = memnew( Button("Add") );
+ ahb_name->add_child(addaa);
+ addaa->connect("pressed",this,"_autoload_add");
+
+ ahb->add_child(avb_name);
+
autoload_list = memnew( Tree );
autoload_list->set_v_size_flags(SIZE_EXPAND_FILL);
avb->add_margin_child("List:",autoload_list,true);
@@ -1620,11 +1798,24 @@ ProjectSettings::ProjectSettings(EditorData *p_data) {
autoload_file_open->set_mode(EditorFileDialog::MODE_OPEN_FILE);
autoload_file_open->connect("file_selected",this,"_autoload_file_callback");
- autoload_list->set_columns(2);
+ autoload_list->set_columns(4);
autoload_list->set_column_titles_visible(true);
- autoload_list->set_column_title(0,"name");
- autoload_list->set_column_title(1,"path");
+ autoload_list->set_column_title(0,"Name");
+ autoload_list->set_column_expand(0,true);
+ autoload_list->set_column_min_width(0,100);
+ autoload_list->set_column_title(1,"Path");
+ autoload_list->set_column_expand(1,true);
+ autoload_list->set_column_min_width(1,100);
+ autoload_list->set_column_title(2,"Singleton");
+ autoload_list->set_column_expand(2,false);
+ autoload_list->set_column_min_width(2,80);
+ autoload_list->set_column_expand(3,false);
+ autoload_list->set_column_min_width(3,80);
+
autoload_list->connect("button_pressed",this,"_autoload_delete");
+ autoload_list->connect("item_edited",this,"_autoload_edited");
+
+ updating_autoload=false;
}
diff --git a/tools/editor/project_settings.h b/tools/editor/project_settings.h
index b122609e52..b689340fdf 100644
--- a/tools/editor/project_settings.h
+++ b/tools/editor/project_settings.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -34,6 +34,7 @@
#include "optimized_save_dialog.h"
#include "undo_redo.h"
#include "editor_data.h"
+#include "editor_name_dialog.h"
//#include "project_export_settings.h"
class ProjectSettings : public AcceptDialog {
@@ -45,7 +46,7 @@ class ProjectSettings : public AcceptDialog {
EditorData *data;
UndoRedo *undo_redo;
- PropertyEditor *globals_editor;
+ SectionedPropertyEditor *globals_editor;
HBoxContainer *search_bar;
ToolButton *search_button;
@@ -66,6 +67,8 @@ class ProjectSettings : public AcceptDialog {
Label *device_index_label;
MenuButton *popup_platform;
+ EditorNameDialog *rename_action;
+
LineEdit *action_name;
Tree *input_editor;
bool setting;
@@ -92,8 +95,10 @@ class ProjectSettings : public AcceptDialog {
void _update_autoload();
void _autoload_file_callback(const String& p_path);
void _autoload_add();
+ void _autoload_edited();
void _autoload_file_open();
void _autoload_delete(Object *p_item,int p_column, int p_button);
+ bool updating_autoload;
void _item_selected();
@@ -106,6 +111,7 @@ class ProjectSettings : public AcceptDialog {
void _action_adds(String);
void _action_add();
+ void _action_rename(const String& p_name);
void _device_input_add();
void _item_checked(const String& p_item, bool p_check);
diff --git a/tools/editor/property_editor.cpp b/tools/editor/property_editor.cpp
index 0fe3dee2ea..4b1b93ea6e 100644
--- a/tools/editor/property_editor.cpp
+++ b/tools/editor/property_editor.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -89,13 +89,23 @@ void CustomPropertyEditor::_menu_option(int p_which) {
case OBJ_MENU_LOAD: {
file->set_mode(EditorFileDialog::MODE_OPEN_FILE);
- List<String> extensions;
String type=(hint==PROPERTY_HINT_RESOURCE_TYPE)?hint_text:String();
- ResourceLoader::get_recognized_extensions_for_type(type,&extensions);
- file->clear_filters();
+ List<String> extensions;
+ for (int i=0;i<type.get_slice_count(",");i++) {
+
+ ResourceLoader::get_recognized_extensions_for_type(type.get_slice(",",i),&extensions);
+ }
+
+ Set<String> valid_extensions;
for (List<String>::Element *E=extensions.front();E;E=E->next()) {
+ valid_extensions.insert(E->get());
+ }
+
+ file->clear_filters();
+ for (Set<String>::Element *E=valid_extensions.front();E;E=E->next()) {
+
file->add_filter("*."+E->get()+" ; "+E->get().to_upper() );
}
@@ -585,7 +595,7 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty
color_picker->show();
color_picker->set_edit_alpha(hint!=PROPERTY_HINT_COLOR_NO_ALPHA);
color_picker->set_color(v);
- set_size( Size2(350, color_picker->get_combined_minimum_size().height+10));
+ set_size( Size2(300, color_picker->get_combined_minimum_size().height+10));
/*
int ofs=80;
int m=10;
@@ -717,7 +727,17 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty
RES cb=EditorSettings::get_singleton()->get_resource_clipboard();
- bool paste_valid=cb.is_valid() && (hint_text=="" || ObjectTypeDB::is_type(cb->get_type(),hint_text));
+ bool paste_valid=false;
+ if (cb.is_valid()) {
+ if (hint_text=="")
+ paste_valid=true;
+ else
+ for (int i = 0; i < hint_text.get_slice_count(",");i++)
+ if (ObjectTypeDB::is_type(cb->get_type(),hint_text.get_slice(",",i))) {
+ paste_valid=true;
+ break;
+ }
+ }
if (!RES(v).is_null() || paste_valid) {
menu->add_separator();
@@ -905,19 +925,31 @@ void CustomPropertyEditor::_color_changed(const Color& p_color) {
void CustomPropertyEditor::_node_path_selected(NodePath p_path) {
- if (owner && owner->is_type("Node")) {
+ if (owner) {
+
+ Node *node=NULL;
+
+ if (owner->is_type("Node"))
+ node = owner->cast_to<Node>();
+ else if (owner->is_type("ArrayPropertyEdit"))
+ node = owner->cast_to<ArrayPropertyEdit>()->get_node();
+
+ if (!node) {
+ v=p_path;
+ emit_signal("variant_changed");
+ call_deferred("hide"); //to not mess with dialogs
+ return;
+ }
- Node *node = owner->cast_to<Node>();
Node *tonode=node->get_node(p_path);
if (tonode) {
-
p_path=node->get_path_to(tonode);
}
-
}
v=p_path;
emit_signal("variant_changed");
+ call_deferred("hide"); //to not mess with dialogs
}
@@ -1020,6 +1052,7 @@ void CustomPropertyEditor::_action_pressed(int p_which) {
v=NodePath();
emit_signal("variant_changed");
+ hide();
}
} break;
case Variant::OBJECT: {
@@ -2012,7 +2045,7 @@ void PropertyEditor::set_item_text(TreeItem *p_item, int p_type, const String& p
if (img.empty())
p_item->set_text(1,"[Image (empty)]");
else
- p_item->set_text(1,"[Image "+itos(img.get_width())+"x"+itos(img.get_height())+"]");
+ p_item->set_text(1,"[Image "+itos(img.get_width())+"x"+itos(img.get_height())+"-"+String(Image::get_format_name(img.get_format()))+"]");
} break;
case Variant::NODE_PATH: {
@@ -2090,6 +2123,65 @@ void PropertyEditor::set_item_text(TreeItem *p_item, int p_type, const String& p
}
+void PropertyEditor::_check_reload_status(const String&p_name, TreeItem* item) {
+
+ bool has_reload=false;
+ int found=-1;
+
+ for(int i=0;i<item->get_button_count(1);i++) {
+
+ if (item->get_button_id(1,i)==3) {
+ found=i;
+ break;
+ }
+ }
+
+ if (_might_be_in_instance()) {
+
+
+ Variant vorig;
+ Dictionary d=item->get_metadata(0);
+ int usage = d.has("usage")?int(int(d["usage"])&(PROPERTY_USAGE_STORE_IF_NONONE|PROPERTY_USAGE_STORE_IF_NONZERO)):0;
+
+
+ if (_get_instanced_node_original_property(p_name,vorig) || usage) {
+ Variant v = obj->get(p_name);
+
+ bool changed = _is_property_different(v,vorig,usage);
+
+ if ((found!=-1)!=changed) {
+
+ if (changed) {
+
+ has_reload=true;
+ } else {
+
+ }
+
+ }
+
+ }
+
+
+
+ }
+
+ if (!has_reload && !obj->get_script().is_null()) {
+ Ref<Script> scr = obj->get_script();
+ Variant orig_value;
+ if (scr->get_property_default_value(p_name,orig_value)) {
+ if (orig_value!=obj->get(p_name)) {
+ has_reload=true;
+ }
+ }
+ }
+
+ if (found!=-1 && !has_reload) {
+ item->erase_button(1,found);
+ } else if (found==-1 && has_reload) {
+ item->add_button(1,get_icon("Reload","EditorIcons"),3);
+ }
+}
void PropertyEditor::_notification(int p_what) {
@@ -2131,43 +2223,8 @@ void PropertyEditor::_notification(int p_what) {
if (!item)
continue;
- if (_might_be_in_instance()) {
-
-
- Variant vorig;
- Dictionary d=item->get_metadata(0);
- int usage = d.has("usage")?int(int(d["usage"])&(PROPERTY_USAGE_STORE_IF_NONONE|PROPERTY_USAGE_STORE_IF_NONZERO)):0;
-
-
- if (_get_instanced_node_original_property(*k,vorig) || usage) {
- Variant v = obj->get(*k);
-
- int found=-1;
- for(int i=0;i<item->get_button_count(1);i++) {
-
- if (item->get_button_id(1,i)==3) {
- found=i;
- break;
- }
- }
-
- bool changed = _is_property_different(v,vorig,usage);
-
- if ((found!=-1)!=changed) {
-
- if (changed) {
+ _check_reload_status(*k,item);
- item->add_button(1,get_icon("Reload","EditorIcons"),3);
- } else {
-
- item->erase_button(1,found);
- }
-
- }
-
- }
-
- }
Dictionary d=item->get_metadata(0);
set_item_text(item,d["type"],d["name"],d["hint"],d["hint_text"]);
}
@@ -2207,9 +2264,9 @@ TreeItem *PropertyEditor::get_parent_node(String p_path,HashMap<String,TreeItem*
}
item->set_editable(0,false);
- item->set_selectable(0,false);
+ item->set_selectable(0,subsection_selectable);
item->set_editable(1,false);
- item->set_selectable(1,false);
+ item->set_selectable(1,subsection_selectable);
if (item->get_parent()==root) {
@@ -2234,23 +2291,30 @@ void PropertyEditor::_refresh_item(TreeItem *p_item) {
if (name!=String()) {
+
+ _check_reload_status(name,p_item);
+#if 0
+ bool has_reload=false;
+
+ int found=-1;
+ for(int i=0;i<p_item->get_button_count(1);i++) {
+
+ if (p_item->get_button_id(1,i)==3) {
+ found=i;
+ break;
+ }
+ }
+
if (_might_be_in_instance()) {
Variant vorig;
Dictionary d=p_item->get_metadata(0);
int usage = d.has("usage")?int(int(d["usage"])&(PROPERTY_USAGE_STORE_IF_NONONE|PROPERTY_USAGE_STORE_IF_NONZERO)):0;
+
if (_get_instanced_node_original_property(name,vorig) || usage) {
Variant v = obj->get(name);
- int found=-1;
- for(int i=0;i<p_item->get_button_count(1);i++) {
-
- if (p_item->get_button_id(1,i)==3) {
- found=i;
- break;
- }
- }
bool changed = _is_property_different(v,vorig,usage);
@@ -2258,10 +2322,11 @@ void PropertyEditor::_refresh_item(TreeItem *p_item) {
if (changed) {
- p_item->add_button(1,get_icon("Reload","EditorIcons"),3);
+ has_reload=true;
+
} else {
- p_item->erase_button(1,found);
+ //p_item->erase_button(1,found);
}
}
@@ -2270,6 +2335,22 @@ void PropertyEditor::_refresh_item(TreeItem *p_item) {
}
+ if (!has_reload && !obj->get_script().is_null()) {
+ Ref<Script> scr = obj->get_script();
+ Variant orig_value;
+ if (scr->get_property_default_value(name,orig_value)) {
+ if (orig_value!=obj->get(name)) {
+ has_reload=true;
+ }
+ }
+ }
+
+ if (!has_reload && found!=-1) {
+ p_item->erase_button(1,found);
+ } else if (has_reload && found==-1) {
+ p_item->add_button(1,get_icon("Reload","EditorIcons"),3);
+ }
+#endif
Dictionary d=p_item->get_metadata(0);
set_item_text(p_item,d["type"],d["name"],d["hint"],d["hint_text"]);
}
@@ -2549,7 +2630,8 @@ void PropertyEditor::update_tree() {
item->set_cell_mode( 1, TreeItem::CELL_MODE_CHECK );
item->set_text(1,"On");
item->set_checked( 1, obj->get( p.name ) );
- item->set_icon( 0, get_icon("Bool","EditorIcons") );
+ if (show_type_icons)
+ item->set_icon( 0, get_icon("Bool","EditorIcons") );
item->set_editable(1,!read_only);
} break;
@@ -2561,7 +2643,8 @@ void PropertyEditor::update_tree() {
item->set_cell_mode( 1, TreeItem::CELL_MODE_CUSTOM );
item->set_text(1, String::num(obj->get( p.name ),2) );
item->set_editable(1,!read_only);
- item->set_icon( 0, get_icon("Curve","EditorIcons"));
+ if (show_type_icons)
+ item->set_icon( 0, get_icon("Curve","EditorIcons"));
break;
@@ -2631,7 +2714,8 @@ void PropertyEditor::update_tree() {
// int c = p.hint_string.get_slice_count(",");
item->set_text(1,p.hint_string);
- item->set_icon( 0,get_icon("Enum","EditorIcons") );
+ if (show_type_icons)
+ item->set_icon( 0,get_icon("Enum","EditorIcons") );
item->set_range(1, obj->get( p.name ) );
item->set_editable(1,!read_only);
break;
@@ -2647,11 +2731,13 @@ void PropertyEditor::update_tree() {
};
if (p.type==Variant::REAL) {
- item->set_icon( 0, get_icon("Real","EditorIcons"));
+ if (show_type_icons)
+ item->set_icon( 0, get_icon("Real","EditorIcons"));
item->set_range(1, obj->get( p.name ) );
} else {
- item->set_icon( 0,get_icon("Integer","EditorIcons") );
+ if (show_type_icons)
+ item->set_icon( 0,get_icon("Integer","EditorIcons") );
item->set_range(1, obj->get( p.name ) );
}
@@ -2671,7 +2757,8 @@ void PropertyEditor::update_tree() {
item->set_cell_mode( 1, TreeItem::CELL_MODE_STRING );
item->set_editable(1,!read_only);
- item->set_icon( 0, get_icon("File","EditorIcons") );
+ if (show_type_icons)
+ item->set_icon( 0, get_icon("File","EditorIcons") );
item->set_text(1,obj->get(p.name));
item->add_button(1,get_icon("Folder","EditorIcons"));
@@ -2691,7 +2778,8 @@ void PropertyEditor::update_tree() {
item->set_text(1, p.hint_string);
item->set_range(1,idx);
item->set_editable( 1, !read_only );
- item->set_icon( 0,get_icon("Enum","EditorIcons") );
+ if (show_type_icons)
+ item->set_icon( 0,get_icon("Enum","EditorIcons") );
} break;
@@ -2699,7 +2787,8 @@ void PropertyEditor::update_tree() {
item->set_cell_mode( 1, TreeItem::CELL_MODE_STRING );
item->set_editable(1,!read_only);
- item->set_icon( 0, get_icon("String","EditorIcons") );
+ if (show_type_icons)
+ item->set_icon( 0, get_icon("String","EditorIcons") );
item->set_text(1,obj->get(p.name));
if (p.hint==PROPERTY_HINT_MULTILINE_TEXT)
item->add_button(1,get_icon("MultiLine","EditorIcons") );
@@ -2719,7 +2808,8 @@ void PropertyEditor::update_tree() {
item->set_text(1,"Array["+itos(v.call("size"))+"]");
else
item->set_text(1,"Array[]");
- item->set_icon( 0, get_icon("ArrayData","EditorIcons") );
+ if (show_type_icons)
+ item->set_icon( 0, get_icon("ArrayData","EditorIcons") );
} break;
@@ -2734,7 +2824,8 @@ void PropertyEditor::update_tree() {
item->set_text(1,"IntArray["+itos(v.call("size"))+"]");
else
item->set_text(1,"IntArray[]");
- item->set_icon( 0, get_icon("ArrayInt","EditorIcons") );
+ if (show_type_icons)
+ item->set_icon( 0, get_icon("ArrayInt","EditorIcons") );
} break;
@@ -2748,7 +2839,8 @@ void PropertyEditor::update_tree() {
item->set_text(1,"FloatArray["+itos(v.call("size"))+"]");
else
item->set_text(1,"FloatArray[]");
- item->set_icon( 0, get_icon("ArrayReal","EditorIcons") );
+ if (show_type_icons)
+ item->set_icon( 0, get_icon("ArrayReal","EditorIcons") );
} break;
@@ -2762,7 +2854,8 @@ void PropertyEditor::update_tree() {
item->set_text(1,"String["+itos(v.call("size"))+"]");
else
item->set_text(1,"String[]");
- item->set_icon( 0, get_icon("ArrayString","EditorIcons") );
+ if (show_type_icons)
+ item->set_icon( 0, get_icon("ArrayString","EditorIcons") );
} break;
@@ -2776,7 +2869,8 @@ void PropertyEditor::update_tree() {
item->set_text(1,"Byte["+itos(v.call("size"))+"]");
else
item->set_text(1,"Byte[]");
- item->set_icon( 0, get_icon("ArrayData","EditorIcons") );
+ if (show_type_icons)
+ item->set_icon( 0, get_icon("ArrayData","EditorIcons") );
} break;
@@ -2790,7 +2884,8 @@ void PropertyEditor::update_tree() {
item->set_text(1,"Vector2["+itos(v.call("size"))+"]");
else
item->set_text(1,"Vector2[]");
- item->set_icon( 0, get_icon("Vector2","EditorIcons") );
+ if (show_type_icons)
+ item->set_icon( 0, get_icon("Vector2","EditorIcons") );
} break;
@@ -2804,7 +2899,8 @@ void PropertyEditor::update_tree() {
item->set_text(1,"Vector3["+itos(v.call("size"))+"]");
else
item->set_text(1,"Vector3[]");
- item->set_icon( 0, get_icon("Vector","EditorIcons") );
+ if (show_type_icons)
+ item->set_icon( 0, get_icon("Vector","EditorIcons") );
} break;
@@ -2818,7 +2914,8 @@ void PropertyEditor::update_tree() {
item->set_text(1,"Color["+itos(v.call("size"))+"]");
else
item->set_text(1,"Color[]");
- item->set_icon( 0, get_icon("Color","EditorIcons") );
+ if (show_type_icons)
+ item->set_icon( 0, get_icon("Color","EditorIcons") );
} break;
@@ -2827,7 +2924,8 @@ void PropertyEditor::update_tree() {
item->set_cell_mode( 1, TreeItem::CELL_MODE_CUSTOM );
item->set_editable( 1, true );
item->set_text(1,obj->get(p.name));
- item->set_icon( 0,get_icon("Vector2","EditorIcons") );
+ if (show_type_icons)
+ item->set_icon( 0,get_icon("Vector2","EditorIcons") );
} break;
case Variant::RECT2: {
@@ -2835,7 +2933,8 @@ void PropertyEditor::update_tree() {
item->set_cell_mode( 1, TreeItem::CELL_MODE_CUSTOM );
item->set_editable( 1, true );
item->set_text(1,obj->get(p.name));
- item->set_icon( 0,get_icon("Rect2","EditorIcons") );
+ if (show_type_icons)
+ item->set_icon( 0,get_icon("Rect2","EditorIcons") );
} break;
case Variant::VECTOR3: {
@@ -2843,7 +2942,8 @@ void PropertyEditor::update_tree() {
item->set_cell_mode( 1, TreeItem::CELL_MODE_CUSTOM );
item->set_editable( 1, true );
item->set_text(1,obj->get(p.name));
- item->set_icon( 0,get_icon("Vector","EditorIcons") );
+ if (show_type_icons)
+ item->set_icon( 0,get_icon("Vector","EditorIcons") );
} break;
case Variant::MATRIX32:
@@ -2858,7 +2958,8 @@ void PropertyEditor::update_tree() {
item->set_cell_mode( 1, TreeItem::CELL_MODE_CUSTOM );
item->set_editable( 1, true );
item->set_text(1,obj->get(p.name));
- item->set_icon( 0,get_icon("Matrix","EditorIcons") );
+ if (show_type_icons)
+ item->set_icon( 0,get_icon("Matrix","EditorIcons") );
} break;
case Variant::PLANE: {
@@ -2866,7 +2967,8 @@ void PropertyEditor::update_tree() {
item->set_cell_mode( 1, TreeItem::CELL_MODE_CUSTOM );
item->set_editable( 1, true );
item->set_text(1,obj->get(p.name));
- item->set_icon( 0,get_icon("Plane","EditorIcons") );
+ if (show_type_icons)
+ item->set_icon( 0,get_icon("Plane","EditorIcons") );
} break;
case Variant::_AABB: {
@@ -2874,7 +2976,8 @@ void PropertyEditor::update_tree() {
item->set_cell_mode( 1, TreeItem::CELL_MODE_CUSTOM );
item->set_editable( 1, true );
item->set_text(1,"AABB");
- item->set_icon( 0,get_icon("Rect3","EditorIcons") );
+ if (show_type_icons)
+ item->set_icon( 0,get_icon("Rect3","EditorIcons") );
} break;
case Variant::QUAT: {
@@ -2882,7 +2985,8 @@ void PropertyEditor::update_tree() {
item->set_cell_mode( 1, TreeItem::CELL_MODE_CUSTOM );
item->set_editable( 1, true );
item->set_text(1,obj->get(p.name));
- item->set_icon( 0,get_icon("Quat","EditorIcons") );
+ if (show_type_icons)
+ item->set_icon( 0,get_icon("Quat","EditorIcons") );
} break;
case Variant::COLOR: {
@@ -2891,7 +2995,8 @@ void PropertyEditor::update_tree() {
item->set_editable( 1, !read_only );
// item->set_text(1,obj->get(p.name));
item->set_custom_bg_color(1,obj->get(p.name));
- item->set_icon( 0,get_icon("Color","EditorIcons") );
+ if (show_type_icons)
+ item->set_icon( 0,get_icon("Color","EditorIcons") );
} break;
case Variant::IMAGE: {
@@ -2902,8 +3007,9 @@ void PropertyEditor::update_tree() {
if (img.empty())
item->set_text(1,"[Image (empty)]");
else
- item->set_text(1,"[Image "+itos(img.get_width())+"x"+itos(img.get_height())+"]");
- item->set_icon( 0,get_icon("Image","EditorIcons") );
+ item->set_text(1,"[Image "+itos(img.get_width())+"x"+itos(img.get_height())+"-"+String(Image::get_format_name(img.get_format()))+"]");
+ if (show_type_icons)
+ item->set_icon( 0,get_icon("Image","EditorIcons") );
} break;
case Variant::NODE_PATH: {
@@ -2985,6 +3091,7 @@ void PropertyEditor::update_tree() {
}
}
+ bool has_reload=false;
if (_might_be_in_instance()) {
Variant vorig;
@@ -2992,16 +3099,29 @@ void PropertyEditor::update_tree() {
int usage = d.has("usage")?int(int(d["usage"])&(PROPERTY_USAGE_STORE_IF_NONONE|PROPERTY_USAGE_STORE_IF_NONZERO)):0;
if (_get_instanced_node_original_property(p.name,vorig) || usage) {
Variant v = obj->get(p.name);
-
+
if (_is_property_different(v,vorig,usage)) {
//print_line("FOR "+String(p.name)+" RELOAD WITH: "+String(v)+"("+Variant::get_type_name(v.get_type())+")=="+String(vorig)+"("+Variant::get_type_name(vorig.get_type())+")");
item->add_button(1,get_icon("Reload","EditorIcons"),3);
+ has_reload=true;
}
}
}
+ if (!has_reload && !obj->get_script().is_null()) {
+ Ref<Script> scr = obj->get_script();
+ Variant orig_value;
+ if (scr->get_property_default_value(p.name,orig_value)) {
+ if (orig_value!=obj->get(p.name)) {
+ item->add_button(1,get_icon("Reload","EditorIcons"),3);
+ }
+ }
+ }
+
+
+
}
}
@@ -3292,8 +3412,6 @@ void PropertyEditor::_edit_button(Object *p_item, int p_column, int p_button) {
call_deferred("_set_range_def",ti,prop,ti->get_range(p_column)+1.0);
} else if (p_button==3) {
- if (!_might_be_in_instance())
- return;
if (!d.has("name"))
return;
@@ -3301,11 +3419,21 @@ void PropertyEditor::_edit_button(Object *p_item, int p_column, int p_button) {
Variant vorig;
- if (_get_instanced_node_original_property(prop,vorig)) {
+ if (_might_be_in_instance() && _get_instanced_node_original_property(prop,vorig)) {
_edit_set(prop,vorig);
+ return;
}
+ if (!obj->get_script().is_null()) {
+ Ref<Script> scr = obj->get_script();
+ Variant orig_value;
+ if (scr->get_property_default_value(prop,orig_value)) {
+ _edit_set(prop,orig_value);
+ }
+ }
+
+
} else {
Dictionary d = ti->get_metadata(0);
@@ -3441,6 +3569,7 @@ void PropertyEditor::_bind_methods() {
ObjectTypeDB::bind_method( "_draw_flags",&PropertyEditor::_draw_flags);
ObjectTypeDB::bind_method( "_set_range_def",&PropertyEditor::_set_range_def);
ObjectTypeDB::bind_method( "_filter_changed",&PropertyEditor::_filter_changed);
+ ObjectTypeDB::bind_method( "update_tree",&PropertyEditor::update_tree);
ADD_SIGNAL( MethodInfo("property_toggled",PropertyInfo( Variant::STRING, "property"),PropertyInfo( Variant::BOOL, "value")));
ADD_SIGNAL( MethodInfo("resource_selected", PropertyInfo( Variant::OBJECT, "res"),PropertyInfo( Variant::STRING, "prop") ) );
@@ -3511,7 +3640,15 @@ void PropertyEditor::register_text_enter(Node* p_line_edit) {
if (search_box)
search_box->connect("text_changed",this,"_filter_changed");
+}
+
+void PropertyEditor::set_subsection_selectable(bool p_selectable) {
+
+ if (p_selectable==subsection_selectable)
+ return;
+ subsection_selectable=p_selectable;
+ update_tree();
}
PropertyEditor::PropertyEditor() {
@@ -3573,8 +3710,9 @@ PropertyEditor::PropertyEditor() {
show_categories=false;
refresh_countdown=0;
use_doc_hints=false;
-
use_filter=false;
+ subsection_selectable=false;
+ show_type_icons=EDITOR_DEF("inspector/show_type_icons",false);
}
@@ -3584,3 +3722,201 @@ PropertyEditor::~PropertyEditor()
}
+/////////////////////////////
+
+
+
+
+
+class SectionedPropertyEditorFilter : public Object {
+
+ OBJ_TYPE( SectionedPropertyEditorFilter, Object );
+
+ Object *edited;
+ String section;
+
+ bool _set(const StringName& p_name, const Variant& p_value) {
+
+ if (!edited)
+ return false;
+
+ String name=p_name;
+ if (section!="") {
+ name=section+"/"+name;
+ }
+
+ bool valid;
+ edited->set(name,p_value,&valid);
+ return valid;
+ }
+
+ bool _get(const StringName& p_name,Variant &r_ret) const{
+
+ if (!edited)
+ return false;
+
+ String name=p_name;
+ if (section!="") {
+ name=section+"/"+name;
+ }
+
+ bool valid=false;
+
+ r_ret=edited->get(name,&valid);
+ return valid;
+
+
+ }
+ void _get_property_list(List<PropertyInfo> *p_list) const{
+
+ if (!edited)
+ return;
+
+ List<PropertyInfo> pinfo;
+ edited->get_property_list(&pinfo);
+ for (List<PropertyInfo>::Element *E=pinfo.front();E;E=E->next()) {
+
+ PropertyInfo pi=E->get();
+ int sp = pi.name.find("/");
+ if (sp!=-1) {
+ String ss = pi.name.substr(0,sp);
+
+ if (ss==section) {
+ pi.name=pi.name.substr(sp+1,pi.name.length());
+ p_list->push_back(pi);
+ }
+ } else {
+ if (section=="")
+ p_list->push_back(pi);
+ }
+ }
+
+ }
+public:
+
+ void set_section(const String& p_section) {
+
+ section=p_section;
+ _change_notify();
+ }
+
+ void set_edited(Object* p_edited) {
+ edited=p_edited;
+ _change_notify();
+ }
+
+ SectionedPropertyEditorFilter() {
+ edited=NULL;
+ }
+
+};
+
+
+void SectionedPropertyEditor::_bind_methods() {
+
+ ObjectTypeDB::bind_method("_section_selected",&SectionedPropertyEditor::_section_selected);
+}
+
+void SectionedPropertyEditor::_section_selected(int p_which) {
+
+ filter->set_section( sections->get_item_metadata(p_which) );
+}
+
+String SectionedPropertyEditor::get_current_section() const {
+
+ return sections->get_item_metadata( sections->get_current() );
+}
+
+String SectionedPropertyEditor::get_full_item_path(const String& p_item) {
+
+ String base = sections->get_item_metadata( sections->get_current() );
+ if (base!="")
+ return base+"/"+p_item;
+ else
+ return p_item;
+}
+
+void SectionedPropertyEditor::edit(Object* p_object) {
+
+ List<PropertyInfo> pinfo;
+ if (p_object)
+ p_object->get_property_list(&pinfo);
+ sections->clear();
+
+ Set<String> existing_sections;
+ for (List<PropertyInfo>::Element *E=pinfo.front();E;E=E->next()) {
+
+ PropertyInfo pi=E->get();
+ if (pi.usage&PROPERTY_USAGE_CATEGORY)
+ continue;
+ if (pi.name.find(":")!=-1 || pi.name=="script/script")
+ continue;
+ int sp = pi.name.find("/");
+ if (sp!=-1) {
+ String sname=pi.name.substr(0,sp);
+ if (!existing_sections.has(sname)) {
+ existing_sections.insert(sname);
+ sections->add_item(sname.capitalize());
+ sections->set_item_metadata(sections->get_item_count()-1,sname);
+ }
+
+ } else {
+ if (!existing_sections.has("")) {
+ existing_sections.insert("");
+ sections->add_item("Global");
+ sections->set_item_metadata(sections->get_item_count()-1,"");
+ }
+ }
+
+
+ }
+
+ //sections->sort_items_by_text();
+
+
+ filter->set_edited(p_object);
+ editor->edit(filter);
+
+ sections->select(0);
+ _section_selected(0);
+
+}
+
+PropertyEditor *SectionedPropertyEditor::get_property_editor() {
+
+ return editor;
+}
+
+SectionedPropertyEditor::SectionedPropertyEditor() {
+
+ VBoxContainer *left_vb = memnew( VBoxContainer);
+ left_vb->set_custom_minimum_size(Size2(160,0));
+ add_child(left_vb);
+
+ sections = memnew( ItemList );
+ sections->set_v_size_flags(SIZE_EXPAND_FILL);
+
+ left_vb->add_margin_child("Sections:",sections,true);
+
+ VBoxContainer *right_vb = memnew( VBoxContainer);
+ right_vb->set_h_size_flags(SIZE_EXPAND_FILL);
+ add_child(right_vb);
+
+ filter = memnew( SectionedPropertyEditorFilter );
+ editor = memnew( PropertyEditor );
+ editor->set_v_size_flags(SIZE_EXPAND_FILL);
+ right_vb->add_margin_child("Properties:",editor,true);
+
+ editor->get_scene_tree()->set_column_titles_visible(false);
+
+
+ editor->hide_top_label();
+
+ sections->connect("item_selected",this,"_section_selected");
+
+}
+
+SectionedPropertyEditor::~SectionedPropertyEditor() {
+
+ memdelete(filter);
+}
diff --git a/tools/editor/property_editor.h b/tools/editor/property_editor.h
index 5fb8386b1b..63ad090901 100644
--- a/tools/editor/property_editor.h
+++ b/tools/editor/property_editor.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -39,6 +39,7 @@
#include "scene/gui/texture_frame.h"
#include "scene/gui/text_edit.h"
#include "scene/gui/check_button.h"
+#include "scene/gui/split_container.h"
#include "scene_tree_editor.h"
/**
@@ -113,6 +114,7 @@ class CustomPropertyEditor : public Popup {
void _action_pressed(int p_which);
void _type_create_selected(int p_idx);
+
void _color_changed(const Color& p_color);
void _draw_easing();
void _menu_option(int p_which);
@@ -161,10 +163,11 @@ class PropertyEditor : public Control {
bool keying;
bool read_only;
bool show_categories;
+ bool show_type_icons;
float refresh_countdown;
bool use_doc_hints;
-
bool use_filter;
+ bool subsection_selectable;
HashMap<String,String> pending;
String selected_property;
@@ -190,6 +193,7 @@ class PropertyEditor : public Control {
virtual void _changed_callback(Object *p_changed,const char * p_what);
virtual void _changed_callbacks(Object *p_changed,const String& p_callback);
+ void _check_reload_status(const String&p_name,TreeItem* item);
void _edit_button(Object *p_item, int p_column, int p_button);
@@ -239,9 +243,37 @@ public:
void set_use_filter(bool p_use);
void register_text_enter(Node *p_line_edit);
+ void set_subsection_selectable(bool p_selectable);
+
PropertyEditor();
~PropertyEditor();
};
+
+class SectionedPropertyEditorFilter;
+
+class SectionedPropertyEditor : public HBoxContainer {
+
+
+ OBJ_TYPE(SectionedPropertyEditor,HBoxContainer);
+ ItemList *sections;
+ SectionedPropertyEditorFilter *filter;
+ PropertyEditor *editor;
+
+
+ static void _bind_methods();
+ void _section_selected(int p_which);
+
+public:
+
+ PropertyEditor *get_property_editor();
+ void edit(Object* p_object);
+ String get_full_item_path(const String& p_item);
+ String get_current_section() const;
+
+ SectionedPropertyEditor();
+ ~SectionedPropertyEditor();
+};
+
#endif
diff --git a/tools/editor/pvrtc_compress.cpp b/tools/editor/pvrtc_compress.cpp
index a2f98adbe0..c30aedc1dc 100644
--- a/tools/editor/pvrtc_compress.cpp
+++ b/tools/editor/pvrtc_compress.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/pvrtc_compress.h b/tools/editor/pvrtc_compress.h
index c4fb0bacb5..129faee080 100644
--- a/tools/editor/pvrtc_compress.h
+++ b/tools/editor/pvrtc_compress.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/quick_open.cpp b/tools/editor/quick_open.cpp
index 6135a4ab64..828275340b 100644
--- a/tools/editor/quick_open.cpp
+++ b/tools/editor/quick_open.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -30,7 +30,7 @@
#include "os/keyboard.h"
-void EditorQuickOpen::popup(const StringName &p_base, bool p_dontclear, bool p_add_dirs) {
+void EditorQuickOpen::popup(const StringName &p_base, bool p_enable_multi, bool p_add_dirs, bool p_dontclear) {
add_directories=p_add_dirs;
popup_centered_ratio(0.6);
@@ -38,13 +38,38 @@ void EditorQuickOpen::popup(const StringName &p_base, bool p_dontclear, bool p_a
search_box->select_all();
else
search_box->clear();
+ if (p_enable_multi)
+ search_options->set_select_mode(Tree::SELECT_MULTI);
+ else
+ search_options->set_select_mode(Tree::SELECT_SINGLE);
search_box->grab_focus();
base_type=p_base;
_update_search();
+}
+
+String EditorQuickOpen::get_selected() const {
+ TreeItem *ti = search_options->get_selected();
+ if (!ti)
+ return String();
+ return "res://" + ti->get_text(0);
}
+Vector<String> EditorQuickOpen::get_selected_files() const {
+
+ Vector<String> files;
+
+ TreeItem* item = search_options->get_next_selected(search_options->get_root());
+ while (item) {
+
+ files.push_back("res://"+item->get_text(0));
+
+ item = search_options->get_next_selected(item);
+ }
+
+ return files;
+}
void EditorQuickOpen::_text_changed(const String& p_newtext) {
@@ -53,14 +78,33 @@ void EditorQuickOpen::_text_changed(const String& p_newtext) {
void EditorQuickOpen::_sbox_input(const InputEvent& p_ie) {
- if (p_ie.type==InputEvent::KEY && (
- p_ie.key.scancode == KEY_UP ||
- p_ie.key.scancode == KEY_DOWN ||
- p_ie.key.scancode == KEY_PAGEUP ||
- p_ie.key.scancode == KEY_PAGEDOWN ) ) {
+ if (p_ie.type==InputEvent::KEY) {
- search_options->call("_input_event",p_ie);
- search_box->accept_event();
+ switch(p_ie.key.scancode) {
+ case KEY_UP:
+ case KEY_DOWN:
+ case KEY_PAGEUP:
+ case KEY_PAGEDOWN: {
+
+ search_options->call("_input_event", p_ie);
+ search_box->accept_event();
+
+ TreeItem *root = search_options->get_root();
+ if (!root->get_children())
+ break;
+
+ TreeItem *current = search_options->get_selected();
+
+ TreeItem *item = search_options->get_next_selected(root);
+ while (item) {
+ item->deselect(0);
+ item = search_options->get_next_selected(item);
+ }
+
+ current->select(0);
+
+ } break;
+ }
}
}
@@ -100,9 +144,6 @@ void EditorQuickOpen::_parse_fs(EditorFileSystemDirectory *efsd) {
ti->set_text(0,file);
Ref<Texture> icon = get_icon( (has_icon(efsd->get_file_type(i),ei)?efsd->get_file_type(i):ot),ei);
ti->set_icon(0,icon);
- if (root->get_children()==ti)
- ti->select(0);
-
}
}
@@ -123,6 +164,13 @@ void EditorQuickOpen::_update_search() {
TreeItem *root = search_options->create_item();
_parse_fs(EditorFileSystem::get_singleton()->get_filesystem());
+ if (root->get_children()) {
+ TreeItem *ti = root->get_children();
+
+ ti->select(0);
+ ti->set_as_cursor(0);
+ }
+
get_ok()->set_disabled(root->get_children()==NULL);
}
@@ -132,7 +180,7 @@ void EditorQuickOpen::_confirmed() {
TreeItem *ti = search_options->get_selected();
if (!ti)
return;
- emit_signal("quick_open","res://"+ti->get_text(0));
+ emit_signal("quick_open");
hide();
}
@@ -156,7 +204,7 @@ void EditorQuickOpen::_bind_methods() {
ObjectTypeDB::bind_method(_MD("_confirmed"),&EditorQuickOpen::_confirmed);
ObjectTypeDB::bind_method(_MD("_sbox_input"),&EditorQuickOpen::_sbox_input);
- ADD_SIGNAL(MethodInfo("quick_open",PropertyInfo(Variant::STRING,"respath")));
+ ADD_SIGNAL(MethodInfo("quick_open"));
}
diff --git a/tools/editor/quick_open.h b/tools/editor/quick_open.h
index 8b38256d39..520f7e569d 100644
--- a/tools/editor/quick_open.h
+++ b/tools/editor/quick_open.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -61,7 +61,10 @@ public:
StringName get_base_type() const;
- void popup(const StringName& p_base,bool p_dontclear=false,bool p_add_dirs=false);
+ String get_selected() const;
+ Vector<String> get_selected_files() const;
+
+ void popup(const StringName& p_base,bool p_enable_multi=false,bool p_add_dirs=false,bool p_dontclear=false);
EditorQuickOpen();
};
diff --git a/tools/editor/register_exporters.h b/tools/editor/register_exporters.h
index 0e1ad2ca46..364ad5efc9 100644
--- a/tools/editor/register_exporters.h
+++ b/tools/editor/register_exporters.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/reparent_dialog.cpp b/tools/editor/reparent_dialog.cpp
index 78ba47d54b..97b27603b2 100644
--- a/tools/editor/reparent_dialog.cpp
+++ b/tools/editor/reparent_dialog.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -36,12 +36,12 @@
void ReparentDialog::_notification(int p_what) {
- if (p_what==NOTIFICATION_ENTER_TREE) {
+ if (p_what==NOTIFICATION_ENTER_TREE) {
connect("confirmed", this,"_reparent");
}
- if (p_what==NOTIFICATION_EXIT_TREE) {
+ if (p_what==NOTIFICATION_EXIT_TREE) {
disconnect("confirmed", this,"_reparent");
}
@@ -62,7 +62,7 @@ void ReparentDialog::_reparent() {
if (tree->get_selected()) {
- emit_signal("reparent",tree->get_selected()->get_path(),node_only->is_pressed());
+ emit_signal("reparent",tree->get_selected()->get_path(),keep_transform->is_pressed());
hide();
}
}
@@ -78,38 +78,41 @@ void ReparentDialog::_bind_methods() {
ObjectTypeDB::bind_method("_reparent",&ReparentDialog::_reparent);
ObjectTypeDB::bind_method("_cancel",&ReparentDialog::_cancel);
- ADD_SIGNAL( MethodInfo("reparent",PropertyInfo(Variant::NODE_PATH,"path"),PropertyInfo(Variant::BOOL,"only_node")));
+ ADD_SIGNAL( MethodInfo("reparent",PropertyInfo(Variant::NODE_PATH,"path"),PropertyInfo(Variant::BOOL,"keep_global_xform")));
}
ReparentDialog::ReparentDialog() {
-
set_title("Reparent Node");
+
VBoxContainer *vbc = memnew( VBoxContainer );
add_child(vbc);
set_child_rect(vbc);
tree = memnew( SceneTreeEditor(false) );
-
+ tree->set_show_enabled_subscene(true);
vbc->add_margin_child("Reparent Location (Select new Parent):",tree,true);
-
+
+ tree->get_scene_tree()->connect("item_activated",this,"_reparent");
+
//Label *label = memnew( Label );
//label->set_pos( Point2( 15,8) );
//label->set_text("Reparent Location (Select new Parent):");
-
- node_only = memnew( CheckButton );
- add_child(node_only);
- node_only->hide();
- tree->set_show_enabled_subscene(true);
+ keep_transform = memnew( CheckBox );
+ keep_transform->set_text("Keep Global Transform");
+ keep_transform->set_pressed(true);
+ vbc->add_child(keep_transform);
+
+
//vbc->add_margin_child("Options:",node_only);;
-
//cancel->connect("pressed", this,"_cancel");
get_ok()->set_text("Reparent");
+
}
diff --git a/tools/editor/reparent_dialog.h b/tools/editor/reparent_dialog.h
index 78c0df9285..296102e4b9 100644
--- a/tools/editor/reparent_dialog.h
+++ b/tools/editor/reparent_dialog.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -32,6 +32,7 @@
#include "scene/gui/dialogs.h"
#include "scene/gui/button.h"
#include "scene/gui/check_button.h"
+#include "scene/gui/check_box.h"
#include "tools/editor/scene_tree_editor.h"
#include "scene/gui/line_edit.h"
/**
@@ -42,12 +43,14 @@ class ReparentDialog : public ConfirmationDialog {
OBJ_TYPE( ReparentDialog, ConfirmationDialog );
SceneTreeEditor *tree;
- CheckButton *node_only;
+ CheckBox *keep_transform;
+
void update_tree();
void _reparent();
void _cancel();
-
+
+
protected:
void _notification(int p_what);
diff --git a/tools/editor/resources_dock.cpp b/tools/editor/resources_dock.cpp
index b69eec4a51..5e44162c93 100644
--- a/tools/editor/resources_dock.cpp
+++ b/tools/editor/resources_dock.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/resources_dock.h b/tools/editor/resources_dock.h
index 933b457b29..978291fc3f 100644
--- a/tools/editor/resources_dock.h
+++ b/tools/editor/resources_dock.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/run_settings_dialog.cpp b/tools/editor/run_settings_dialog.cpp
index e883c69939..e8c509d79d 100644
--- a/tools/editor/run_settings_dialog.cpp
+++ b/tools/editor/run_settings_dialog.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/run_settings_dialog.h b/tools/editor/run_settings_dialog.h
index fdb8857f6b..09319702f3 100644
--- a/tools/editor/run_settings_dialog.h
+++ b/tools/editor/run_settings_dialog.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/scene_tree_dock.cpp b/tools/editor/scene_tree_dock.cpp
index 8b5bf8c1e1..5877ce1a43 100644
--- a/tools/editor/scene_tree_dock.cpp
+++ b/tools/editor/scene_tree_dock.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -35,7 +35,10 @@
#include "tools/editor/plugins/canvas_item_editor_plugin.h"
#include "script_editor_debugger.h"
#include "tools/editor/plugins/script_editor_plugin.h"
+#include "core/io/resource_saver.h"
#include "multi_node_edit.h"
+#include "tools/editor/plugins/animation_player_editor_plugin.h"
+#include "animation_editor.h"
void SceneTreeDock::_unhandled_key_input(InputEvent p_event) {
@@ -291,7 +294,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
for (int i = 0; i < selection.size(); i++) {
Node *top_node = selection[i];
Node *bottom_node = selection[selection.size() - 1 - i];
-
+
ERR_FAIL_COND(!top_node->get_parent());
ERR_FAIL_COND(!bottom_node->get_parent());
@@ -397,7 +400,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
editor_data->get_undo_redo().add_do_method(d,"set_owner",node->get_owner());
}
editor_data->get_undo_redo().add_do_method(editor_selection,"add_node",dup);
- editor_data->get_undo_redo().add_undo_method(parent,"remove_child",dup);
+ editor_data->get_undo_redo().add_undo_method(parent,"remove_child",dup);
editor_data->get_undo_redo().add_do_reference(dup);
ScriptEditorDebugger *sed = ScriptEditor::get_singleton()->get_debugger();
@@ -485,7 +488,54 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
delete_dialog->popup_centered_minsize();
}
+ } break;
+ case TOOL_NEW_SCENE_FROM: {
+
+ Node *scene = editor_data->get_edited_scene_root();
+
+ if (!scene) {
+ accept->get_ok()->set_text("I see..");
+ accept->set_text("This operation can't be done without a scene.");
+ accept->popup_centered_minsize();
+ break;
+ }
+
+ List<Node*> selection = editor_selection->get_selected_node_list();
+
+ if (selection.size()!=1) {
+ accept->get_ok()->set_text("I see..");
+ accept->set_text("This operation requires a single selected node.");
+ accept->popup_centered_minsize();
+ break;
+ }
+
+ Node *tocopy = selection.front()->get();
+
+ if (tocopy!=editor_data->get_edited_scene_root() && tocopy->get_filename()!="") {
+ accept->get_ok()->set_text("I see..");
+ accept->set_text("This operation can't be done on instanced scenes.");
+ accept->popup_centered_minsize();
+ break;
+ }
+
+ new_scene_from_dialog->set_mode(EditorFileDialog::MODE_SAVE_FILE);
+
+ List<String> extensions;
+ Ref<PackedScene> sd = memnew( PackedScene );
+ ResourceSaver::get_recognized_extensions(sd,&extensions);
+ new_scene_from_dialog->clear_filters();
+ for(int i=0;i<extensions.size();i++) {
+ new_scene_from_dialog->add_filter("*."+extensions[i]+" ; "+extensions[i].to_upper());
+ }
+
+ String existing;
+ if (extensions.size()) {
+ existing="new_scene."+extensions.front()->get().to_lower();
+ }
+ new_scene_from_dialog->set_current_path(existing);
+ new_scene_from_dialog->popup_centered_ratio();
+ new_scene_from_dialog->set_title("Save New Scene As..");
} break;
@@ -520,6 +570,7 @@ void SceneTreeDock::_notification(int p_what) {
"MoveDown",
"Duplicate",
"Reparent",
+ "CreateNewSceneFrom",
"MultiNodeEdit",
"Remove",
};
@@ -875,7 +926,7 @@ bool SceneTreeDock::_validate_no_foreign() {
}
- if (edited_scene->get_scene_inherited_state().is_valid() && edited_scene->get_scene_inherited_state()->find_node_by_path(edited_scene->get_path_to(E->get()))>=0) {
+ if (edited_scene->get_scene_inherited_state().is_valid() && edited_scene->get_scene_inherited_state()->find_node_by_path(edited_scene->get_path_to(E->get()))>=0) {
accept->get_ok()->set_text("Makes Sense!");
accept->set_text("Can't operate on nodes the current scene inherits from!");
@@ -889,7 +940,7 @@ bool SceneTreeDock::_validate_no_foreign() {
return true;
}
-void SceneTreeDock::_node_reparent(NodePath p_path,bool p_node_only) {
+void SceneTreeDock::_node_reparent(NodePath p_path,bool p_keep_global_xform) {
Node *node = scene_tree->get_selected();
@@ -948,11 +999,28 @@ void SceneTreeDock::_node_reparent(NodePath p_path,bool p_node_only) {
editor_data->get_undo_redo().add_do_method(sed,"live_debug_reparent_node",edited_scene->get_path_to(node),edited_scene->get_path_to(new_parent),new_name,-1);
editor_data->get_undo_redo().add_undo_method(sed,"live_debug_reparent_node",NodePath(String(edited_scene->get_path_to(new_parent))+"/"+new_name),edited_scene->get_path_to(node->get_parent()),node->get_name(),node->get_index());
+ if (p_keep_global_xform) {
+ if (node->cast_to<Node2D>())
+ editor_data->get_undo_redo().add_do_method(node,"set_global_transform",node->cast_to<Node2D>()->get_global_transform());
+ if (node->cast_to<Spatial>())
+ editor_data->get_undo_redo().add_do_method(node,"set_global_transform",node->cast_to<Spatial>()->get_global_transform());
+ if (node->cast_to<Control>()) {
+ bool can_do_it=false;
+ Control *c=node->cast_to<Control>();
+ if (c->get_parent()->cast_to<Container>())
+ can_do_it=false;
+ for(int i=0;i<4;i++) {
+ if (c->get_anchor(Margin(i))!=ANCHOR_BEGIN)
+ can_do_it=false;
+ }
+ editor_data->get_undo_redo().add_do_method(node,"set_global_pos",node->cast_to<Control>()->get_global_pos());
+ }
+ }
editor_data->get_undo_redo().add_do_method(this,"_set_owners",edited_scene,owners);
- if (editor->get_animation_editor()->get_root()==node)
- editor_data->get_undo_redo().add_do_method(editor->get_animation_editor(),"set_root",node);
+ if (AnimationPlayerEditor::singleton->get_key_editor()->get_root()==node)
+ editor_data->get_undo_redo().add_do_method(AnimationPlayerEditor::singleton->get_key_editor(),"set_root",node);
editor_data->get_undo_redo().add_undo_method(new_parent,"remove_child",node);
@@ -979,8 +1047,28 @@ void SceneTreeDock::_node_reparent(NodePath p_path,bool p_node_only) {
editor_data->get_undo_redo().add_undo_method(node->get_parent(),"add_child",node);
editor_data->get_undo_redo().add_undo_method(node->get_parent(),"move_child",node,child_pos);
editor_data->get_undo_redo().add_undo_method(this,"_set_owners",edited_scene,owners);
- if (editor->get_animation_editor()->get_root()==node)
- editor_data->get_undo_redo().add_undo_method(editor->get_animation_editor(),"set_root",node);
+ if (AnimationPlayerEditor::singleton->get_key_editor()->get_root()==node)
+ editor_data->get_undo_redo().add_undo_method(AnimationPlayerEditor::singleton->get_key_editor(),"set_root",node);
+
+ if (p_keep_global_xform) {
+ if (node->cast_to<Node2D>())
+ editor_data->get_undo_redo().add_undo_method(node,"set_transform",node->cast_to<Node2D>()->get_transform());
+ if (node->cast_to<Spatial>())
+ editor_data->get_undo_redo().add_undo_method(node,"set_transform",node->cast_to<Spatial>()->get_transform());
+ if (node->cast_to<Control>()) {
+ bool can_do_it=false;
+ Control *c=node->cast_to<Control>();
+ if (c->get_parent()->cast_to<Container>())
+ can_do_it=false;
+ for(int i=0;i<4;i++) {
+ if (c->get_anchor(Margin(i))!=ANCHOR_BEGIN)
+ can_do_it=false;
+ }
+ editor_data->get_undo_redo().add_undo_method(node,"set_pos",node->cast_to<Control>()->get_pos());
+ }
+ }
+
+
}
@@ -1066,8 +1154,8 @@ void SceneTreeDock::_delete_confirm() {
editor_data->get_undo_redo().add_do_method(n->get_parent(),"remove_child",n);
editor_data->get_undo_redo().add_undo_method(n->get_parent(),"add_child",n);
editor_data->get_undo_redo().add_undo_method(n->get_parent(),"move_child",n,n->get_index());
- if (editor->get_animation_editor()->get_root()==n)
- editor_data->get_undo_redo().add_undo_method(editor->get_animation_editor(),"set_root",n);
+ if (AnimationPlayerEditor::singleton->get_key_editor()->get_root()==n)
+ editor_data->get_undo_redo().add_undo_method(AnimationPlayerEditor::singleton->get_key_editor(),"set_root",n);
editor_data->get_undo_redo().add_undo_method(this,"_set_owners",edited_scene,owners);
//editor_data->get_undo_redo().add_undo_method(n,"set_owner",n->get_owner());
editor_data->get_undo_redo().add_undo_reference(n);
@@ -1103,6 +1191,7 @@ void SceneTreeDock::_update_tool_buttons() {
tool_buttons[TOOL_DUPLICATE]->set_disabled(disable_root);
tool_buttons[TOOL_REPARENT]->set_disabled(disable_root);
tool_buttons[TOOL_ERASE]->set_disabled(disable);
+ tool_buttons[TOOL_NEW_SCENE_FROM]->set_disabled(disable_root);
tool_buttons[TOOL_MULTI_EDIT]->set_disabled(EditorNode::get_singleton()->get_editor_selection()->get_selection().size()<2);
@@ -1231,13 +1320,18 @@ void SceneTreeDock::_create() {
editor->set_edited_scene(newnode);
}
+ //small hack to make collisionshapes and other kind of nodes to work
+ for(int i=0;i<newnode->get_child_count();i++) {
+ Node *c=newnode->get_child(i);
+ c->call("set_transform", c->call("get_transform") );
+ }
editor_data->get_undo_redo().clear_history();
newnode->set_name(newname);
editor->push_item(newnode);
memdelete(n);
-
+
_update_tool_buttons();
}
@@ -1284,6 +1378,59 @@ void SceneTreeDock::_import_subscene() {
*/
}
+void SceneTreeDock::_new_scene_from(String p_file) {
+
+ List<Node*> selection = editor_selection->get_selected_node_list();
+
+ if (selection.size()!=1) {
+ accept->get_ok()->set_text("I see..");
+ accept->set_text("This operation requires a single selected node.");
+ accept->popup_centered_minsize();
+ return;
+ }
+
+ Node *base = selection.front()->get();
+
+ Map<Node*,Node*> reown;
+ reown[editor_data->get_edited_scene_root()]=base;
+ Node *copy = base->duplicate_and_reown(reown);
+ if (copy) {
+
+ Ref<PackedScene> sdata = memnew( PackedScene );
+ Error err = sdata->pack(copy);
+ memdelete(copy);
+
+ if (err!=OK) {
+ accept->get_ok()->set_text("I see..");
+ accept->set_text("Couldn't save new scene. Likely dependencies (instances) couldn't be satisfied.");
+ accept->popup_centered_minsize();
+ return;
+ }
+
+ int flg=0;
+ if (EditorSettings::get_singleton()->get("on_save/compress_binary_resources"))
+ flg|=ResourceSaver::FLAG_COMPRESS;
+ if (EditorSettings::get_singleton()->get("on_save/save_paths_as_relative"))
+ flg|=ResourceSaver::FLAG_RELATIVE_PATHS;
+
+
+ err = ResourceSaver::save(p_file,sdata,flg);
+ if (err!=OK) {
+ accept->get_ok()->set_text("I see..");
+ accept->set_text("Error saving scene.");
+ accept->popup_centered_minsize();
+ return;
+ }
+
+ } else {
+ accept->get_ok()->set_text("I see..");
+ accept->set_text("Error duplicating scene to save it.");
+ accept->popup_centered_minsize();
+ return;
+ }
+
+}
+
void SceneTreeDock::_bind_methods() {
ObjectTypeDB::bind_method(_MD("_tool_selected"),&SceneTreeDock::_tool_selected);
@@ -1301,6 +1448,7 @@ void SceneTreeDock::_bind_methods() {
ObjectTypeDB::bind_method(_MD("_node_prerenamed"),&SceneTreeDock::_node_prerenamed);
ObjectTypeDB::bind_method(_MD("_import_subscene"),&SceneTreeDock::_import_subscene);
ObjectTypeDB::bind_method(_MD("_selection_changed"),&SceneTreeDock::_selection_changed);
+ ObjectTypeDB::bind_method(_MD("_new_scene_from"),&SceneTreeDock::_new_scene_from);
ObjectTypeDB::bind_method(_MD("instance"),&SceneTreeDock::instance);
}
@@ -1373,9 +1521,10 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor,Node *p_scene_root,EditorSelec
scene_tree->set_undo_redo(&editor_data->get_undo_redo());
scene_tree->set_editor_selection(editor_selection);
+
HBoxContainer *hbc_bottom = memnew( HBoxContainer );
vbc->add_child(hbc_bottom);
-
+ hbc_bottom->add_constant_override("separation", 0);
tb = memnew( ToolButton );
tb->connect("pressed",this,"_tool_selected",make_binds(TOOL_MOVE_UP, false));
@@ -1404,6 +1553,12 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor,Node *p_scene_root,EditorSelec
hbc_bottom->add_spacer();
tb = memnew( ToolButton );
+ tb->connect("pressed",this,"_tool_selected",make_binds(TOOL_NEW_SCENE_FROM, false));
+ tb->set_tooltip("Create New Scene From Node(s)");
+ hbc_bottom->add_child(tb);
+ tool_buttons[TOOL_NEW_SCENE_FROM]=tb;
+
+ tb = memnew( ToolButton );
tb->connect("pressed",this,"_tool_selected",make_binds(TOOL_MULTI_EDIT, false));
tb->set_tooltip("Multi-Edit Selected Nodes");
hbc_bottom->add_child(tb);
@@ -1423,12 +1578,15 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor,Node *p_scene_root,EditorSelec
groups_editor = memnew( GroupsEditor );
add_child(groups_editor);
groups_editor->set_undo_redo(&editor_data->get_undo_redo());
+
connect_dialog = memnew( ConnectionsDialog(p_editor) );
add_child(connect_dialog);
connect_dialog->set_undoredo(&editor_data->get_undo_redo());
+
script_create_dialog = memnew( ScriptCreateDialog );
add_child(script_create_dialog);
script_create_dialog->connect("script_created",this,"_script_created");
+
reparent_dialog = memnew( ReparentDialog );
add_child(reparent_dialog);
reparent_dialog->connect("reparent",this,"_node_reparent");
@@ -1444,10 +1602,16 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor,Node *p_scene_root,EditorSelec
delete_dialog = memnew( ConfirmationDialog );
add_child(delete_dialog);
delete_dialog->connect("confirmed",this,"_delete_confirm");
+
import_subscene_dialog = memnew( EditorSubScene );
add_child(import_subscene_dialog);
import_subscene_dialog->connect("subscene_selected",this,"_import_subscene");
+ new_scene_from_dialog = memnew( EditorFileDialog );
+ new_scene_from_dialog->set_mode(EditorFileDialog::MODE_SAVE_FILE);
+ add_child(new_scene_from_dialog);
+ new_scene_from_dialog->connect("file_selected",this,"_new_scene_from");
+
first_enter=true;
diff --git a/tools/editor/scene_tree_dock.h b/tools/editor/scene_tree_dock.h
index b1c53d2ff9..114e2c5c97 100644
--- a/tools/editor/scene_tree_dock.h
+++ b/tools/editor/scene_tree_dock.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -62,6 +62,7 @@ class SceneTreeDock : public VBoxContainer {
TOOL_MOVE_DOWN,
TOOL_DUPLICATE,
TOOL_REPARENT,
+ TOOL_NEW_SCENE_FROM,
TOOL_MULTI_EDIT,
TOOL_ERASE,
TOOL_BUTTON_MAX
@@ -90,6 +91,7 @@ class SceneTreeDock : public VBoxContainer {
ReparentDialog *reparent_dialog;
EditorFileDialog *file;
EditorSubScene *import_subscene_dialog;
+ EditorFileDialog *new_scene_from_dialog;
bool first_enter;
@@ -99,7 +101,7 @@ class SceneTreeDock : public VBoxContainer {
EditorNode *editor;
Node *_duplicate(Node *p_node, Map<Node*,Node*> &duplimap);
- void _node_reparent(NodePath p_path,bool p_node_only);
+ void _node_reparent(NodePath p_path, bool p_keep_global_xform);
void _set_owners(Node *p_owner, const Array& p_nodes);
void _load_request(const String& p_path);
void _script_open_request(const Ref<Script>& p_script);
@@ -119,6 +121,8 @@ class SceneTreeDock : public VBoxContainer {
void _import_subscene();
+ void _new_scene_from(String p_file);
+
bool _validate_no_foreign();
void _selection_changed();
diff --git a/tools/editor/scene_tree_editor.cpp b/tools/editor/scene_tree_editor.cpp
index 6575603073..0260457c81 100644
--- a/tools/editor/scene_tree_editor.cpp
+++ b/tools/editor/scene_tree_editor.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -39,12 +39,8 @@
Node *SceneTreeEditor::get_scene_node() {
ERR_FAIL_COND_V(!is_inside_tree(),NULL);
- if (get_tree()->get_root()->get_child_count() && get_tree()->get_root()->get_child(0)->cast_to<EditorNode>())
- return get_tree()->get_root()->get_child(0)->cast_to<EditorNode>()->get_edited_scene();
- else
- return get_tree()->get_root();
- return NULL;
+ return get_tree()->get_edited_scene_root();
}
@@ -725,6 +721,9 @@ void SceneTreeEditor::_update_selection(TreeItem *item) {
NodePath np = item->get_metadata(0);
+ if (!has_node(np))
+ return;
+
Node *n=get_node(np);
if (!n)
@@ -928,7 +927,7 @@ void SceneTreeDialog::_cancel() {
void SceneTreeDialog::_select() {
if (tree->get_selected()) {
- emit_signal("selected",tree->get_selected()->get_path());
+ emit_signal("selected",tree->get_selected()->get_path());
hide();
}
}
@@ -939,7 +938,6 @@ void SceneTreeDialog::_bind_methods() {
ObjectTypeDB::bind_method("_cancel",&SceneTreeDialog::_cancel);
ADD_SIGNAL( MethodInfo("selected",PropertyInfo(Variant::NODE_PATH,"path")));
-
}
@@ -951,7 +949,7 @@ SceneTreeDialog::SceneTreeDialog() {
add_child(tree);
set_child_rect(tree);
-
+ tree->get_scene_tree()->connect("item_activated",this,"_select");
}
diff --git a/tools/editor/scene_tree_editor.h b/tools/editor/scene_tree_editor.h
index 50cca4e24b..334debc148 100644
--- a/tools/editor/scene_tree_editor.h
+++ b/tools/editor/scene_tree_editor.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/scenes.cpp b/tools/editor/scenes.cpp
index ada5751b5a..e6569c98a9 100644
--- a/tools/editor/scenes.cpp
+++ b/tools/editor/scenes.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/scenes.h b/tools/editor/scenes.h
index 463c3b5e18..bae9ef65f0 100644
--- a/tools/editor/scenes.h
+++ b/tools/editor/scenes.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/scenes_dock.cpp b/tools/editor/scenes_dock.cpp
index c9b376ebec..5abc4992df 100644
--- a/tools/editor/scenes_dock.cpp
+++ b/tools/editor/scenes_dock.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -195,7 +195,12 @@ void ScenesDock::_notification(int p_what) {
case NOTIFICATION_EXIT_TREE: {
} break;
+ case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
+ display_mode->set_pressed(int(EditorSettings::get_singleton()->get("file_dialog/display_mode"))==EditorFileDialog::DISPLAY_LIST);
+
+ _change_file_display();
+ } break;
}
}
@@ -1063,6 +1068,11 @@ void ScenesDock::open(const String& p_path) {
}
+void ScenesDock::set_use_thumbnails(bool p_use) {
+
+ display_mode->set_pressed(!p_use);
+}
+
void ScenesDock::_bind_methods() {
ObjectTypeDB::bind_method(_MD("_update_tree"),&ScenesDock::_update_tree);
@@ -1244,6 +1254,8 @@ ScenesDock::ScenesDock(EditorNode *p_editor) {
history_pos=0;
tree_mode=true;
+ path="res://";
+
}
diff --git a/tools/editor/scenes_dock.h b/tools/editor/scenes_dock.h
index d045124bf7..a1978a3ca4 100644
--- a/tools/editor/scenes_dock.h
+++ b/tools/editor/scenes_dock.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -153,6 +153,7 @@ public:
void fix_dependencies(const String& p_for_file);
+ void set_use_thumbnails(bool p_use);
ScenesDock(EditorNode *p_editor);
~ScenesDock();
diff --git a/tools/editor/script_create_dialog.cpp b/tools/editor/script_create_dialog.cpp
index 622150ab68..409e8be870 100644
--- a/tools/editor/script_create_dialog.cpp
+++ b/tools/editor/script_create_dialog.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/script_create_dialog.h b/tools/editor/script_create_dialog.h
index 59fde8fbd5..181989402e 100644
--- a/tools/editor/script_create_dialog.h
+++ b/tools/editor/script_create_dialog.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/tools/editor/script_editor_debugger.cpp b/tools/editor/script_editor_debugger.cpp
index 60f2afa2c2..e727668c49 100644
--- a/tools/editor/script_editor_debugger.cpp
+++ b/tools/editor/script_editor_debugger.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -210,6 +210,8 @@ void ScriptEditorDebugger::_parse_message(const String& p_msg,const Array& p_dat
OS::get_singleton()->move_window_to_foreground();
tabs->set_current_tab(0);
+ EditorNode::get_singleton()->make_bottom_panel_item_visible(this);
+
} else if (p_msg=="debug_exit") {
breaked=false;
@@ -358,7 +360,7 @@ void ScriptEditorDebugger::_parse_message(const String& p_msg,const Array& p_dat
if (EditorNode::get_log()->is_hidden()) {
log_forced_visible=true;
- EditorNode::get_log()->show();
+ EditorNode::get_singleton()->make_bottom_panel_item_visible(EditorNode::get_log());
}
EditorNode::get_log()->add_message(t);
@@ -528,6 +530,8 @@ void ScriptEditorDebugger::_notification(int p_what) {
case NOTIFICATION_ENTER_TREE: {
+ inspector->edit(variables);
+
step->set_icon( get_icon("DebugStep","EditorIcons"));
next->set_icon( get_icon("DebugNext","EditorIcons"));
back->set_icon( get_icon("Back","EditorIcons"));
@@ -551,8 +555,14 @@ void ScriptEditorDebugger::_notification(int p_what) {
if (error_count==0) {
error_split->set_name("Errors");
+ debugger_button->set_text("Debugger");
+ debugger_button->set_icon(Ref<Texture>());
+ tabs->set_tab_icon(error_split->get_index(),Ref<Texture>());
} else {
error_split->set_name("Errors ("+itos(error_count)+")");
+ debugger_button->set_text("Debugger ("+itos(error_count)+")");
+ debugger_button->set_icon(get_icon("Error","EditorIcons"));
+ tabs->set_tab_icon(error_split->get_index(),get_icon("Error","EditorIcons"));
}
last_error_count=error_count;
}
@@ -569,12 +579,12 @@ void ScriptEditorDebugger::_notification(int p_what) {
ppeer->set_stream_peer(connection);
+ //EditorNode::get_singleton()->make_bottom_panel_item_visible(this);
+ //emit_signal("show_debugger",true);
- show();
dobreak->set_disabled(false);
tabs->set_current_tab(0);
- emit_signal("show_debugger",true);
reason->set_text("Child Process Connected");
reason->set_tooltip("Child Process Connected");
scene_tree->clear();
@@ -727,7 +737,9 @@ void ScriptEditorDebugger::stop(){
message.clear();
if (log_forced_visible) {
- EditorNode::get_log()->hide();
+ //EditorNode::get_singleton()->make_bottom_panel_item_visible(this);
+ if (EditorNode::get_log()->is_visible())
+ EditorNode::get_singleton()->hide_bottom_panel();
log_forced_visible=false;
}
@@ -737,8 +749,11 @@ void ScriptEditorDebugger::stop(){
le_set->set_disabled(true);
- hide();
- emit_signal("show_debugger",false);
+ if (hide_on_stop) {
+ if (is_visible())
+ EditorNode::get_singleton()->hide_bottom_panel();
+ emit_signal("show_debugger",false);
+ }
}
@@ -768,9 +783,9 @@ void ScriptEditorDebugger::_stack_dump_frame_selected() {
void ScriptEditorDebugger::_hide_request() {
- hide();
+ if (EditorNode::get_log()->is_visible())
+ EditorNode::get_singleton()->hide_bottom_panel();
emit_signal("show_debugger",false);
-
}
void ScriptEditorDebugger::_output_clear() {
@@ -1160,6 +1175,10 @@ void ScriptEditorDebugger:: _error_stack_selected(int p_idx){
}
+void ScriptEditorDebugger::set_hide_on_stop(bool p_hide) {
+
+ hide_on_stop=p_hide;
+}
void ScriptEditorDebugger::_bind_methods() {
@@ -1222,12 +1241,13 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor){
vbc->add_child(hbc);
- reason = memnew( Label );
+ reason = memnew( LineEdit );
reason->set_text("");
+ reason->set_editable(false);
hbc->add_child(reason);
reason->add_color_override("font_color",Color(1,0.4,0.0,0.8));
reason->set_h_size_flags(SIZE_EXPAND_FILL);
- reason->set_clip_text(true);
+ //reason->set_clip_text(true);
hbc->add_child( memnew( VSeparator) );
@@ -1290,7 +1310,7 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor){
pending_in_queue=0;
variables = memnew( ScriptEditorDebuggerVariables );
- inspector->edit(variables);
+
breaked=false;
tabs->add_child(dbg);
@@ -1454,7 +1474,6 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor){
msgdialog = memnew( AcceptDialog );
add_child(msgdialog);
- hide();
log_forced_visible=false;
p_editor->get_undo_redo()->set_method_notify_callback(_method_changeds,this);
@@ -1462,6 +1481,7 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor){
live_debug=false;
last_path_id=false;
error_count=0;
+ hide_on_stop=true;
last_error_count=0;
diff --git a/tools/editor/script_editor_debugger.h b/tools/editor/script_editor_debugger.h
index 6b66a62dd5..0be311a990 100644
--- a/tools/editor/script_editor_debugger.h
+++ b/tools/editor/script_editor_debugger.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -54,6 +54,7 @@ class ScriptEditorDebugger : public Control {
AcceptDialog *msgdialog;
+ Button *debugger_button;
LineEdit *clicked_ctrl;
LineEdit *clicked_ctrl_type;
@@ -71,6 +72,8 @@ class ScriptEditorDebugger : public Control {
int error_count;
int last_error_count;
+ bool hide_on_stop;
+
TextureButton *tb;
@@ -78,7 +81,7 @@ class ScriptEditorDebugger : public Control {
TabContainer *tabs;
- Label *reason;
+ LineEdit *reason;
bool log_forced_visible;
ScriptEditorDebuggerVariables *variables;
@@ -182,6 +185,9 @@ public:
void update_live_edit_root();
+ void set_hide_on_stop(bool p_hide);
+
+ void set_tool_button(Button *p_tb) { debugger_button=p_tb; }
virtual Size2 get_minimum_size() const;
ScriptEditorDebugger(EditorNode *p_editor=NULL);
diff --git a/tools/editor/settings_config_dialog.cpp b/tools/editor/settings_config_dialog.cpp
index 6d8f849427..ebbc488ff2 100644
--- a/tools/editor/settings_config_dialog.cpp
+++ b/tools/editor/settings_config_dialog.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -71,7 +71,7 @@ void EditorSettingsDialog::popup_edit_settings() {
return;
property_editor->edit(EditorSettings::get_singleton());
- property_editor->update_tree();
+ property_editor->get_property_editor()->update_tree();
search_box->select_all();
search_box->grab_focus();
@@ -254,7 +254,7 @@ void EditorSettingsDialog::_clear_search_box() {
return;
search_box->clear();
- property_editor->update_tree();
+ property_editor->get_property_editor()->update_tree();
}
void EditorSettingsDialog::_notification(int p_what) {
@@ -306,10 +306,10 @@ EditorSettingsDialog::EditorSettingsDialog() {
hbc->add_child(clear_button);
clear_button->connect("pressed",this,"_clear_search_box");
- property_editor = memnew( PropertyEditor );
- property_editor->hide_top_label();
- property_editor->set_use_filter(true);
- property_editor->register_text_enter(search_box);
+ property_editor = memnew( SectionedPropertyEditor );
+ //property_editor->hide_top_label();
+ property_editor->get_property_editor()->set_use_filter(true);
+ property_editor->get_property_editor()->register_text_enter(search_box);
property_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL);
vbc->add_child(property_editor);
diff --git a/tools/editor/settings_config_dialog.h b/tools/editor/settings_config_dialog.h
index 50159cf488..e1c3238a64 100644
--- a/tools/editor/settings_config_dialog.h
+++ b/tools/editor/settings_config_dialog.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -53,7 +53,7 @@ class EditorSettingsDialog : public AcceptDialog {
Tree *plugins;
LineEdit *search_box;
ToolButton *clear_button;
- PropertyEditor *property_editor;
+ SectionedPropertyEditor *property_editor;
Timer *timer;
diff --git a/tools/editor/spatial_editor_gizmos.cpp b/tools/editor/spatial_editor_gizmos.cpp
index 5efca44c7d..320b0c3a70 100644
--- a/tools/editor/spatial_editor_gizmos.cpp
+++ b/tools/editor/spatial_editor_gizmos.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -2283,6 +2283,8 @@ void NavigationMeshSpatialGizmo::redraw() {
}
}
+ if (faces.empty())
+ return;
Map<_EdgeKey,bool> edge_map;
DVector<Vector3> tmeshfaces;
@@ -2330,7 +2332,7 @@ void NavigationMeshSpatialGizmo::redraw() {
}
}
- Ref<TriangleMesh> tmesh = memnew( TriangleMesh);
+ Ref<TriangleMesh> tmesh = memnew( TriangleMesh );
tmesh->create(tmeshfaces);
if (lines.size())
diff --git a/tools/editor/spatial_editor_gizmos.h b/tools/editor/spatial_editor_gizmos.h
index bc7e8ad21d..669d3e2380 100644
--- a/tools/editor/spatial_editor_gizmos.h
+++ b/tools/editor/spatial_editor_gizmos.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */