summaryrefslogtreecommitdiff
path: root/tools/editor
diff options
context:
space:
mode:
Diffstat (limited to 'tools/editor')
-rw-r--r--tools/editor/animation_editor.cpp362
-rw-r--r--tools/editor/animation_editor.h9
-rw-r--r--tools/editor/asset_library_editor_plugin.cpp31
-rw-r--r--tools/editor/asset_library_editor_plugin.h5
-rw-r--r--tools/editor/code_editor.cpp62
-rw-r--r--tools/editor/code_editor.h3
-rw-r--r--tools/editor/connections_dialog.cpp1
-rw-r--r--tools/editor/create_dialog.cpp14
-rw-r--r--tools/editor/dependency_editor.cpp4
-rw-r--r--tools/editor/editor_asset_installer.cpp6
-rw-r--r--tools/editor/editor_autoload_settings.cpp616
-rw-r--r--tools/editor/editor_autoload_settings.h (renamed from tools/editor/import_settings.h)88
-rw-r--r--tools/editor/editor_data.cpp42
-rw-r--r--tools/editor/editor_data.h7
-rw-r--r--tools/editor/editor_dir_dialog.cpp18
-rw-r--r--tools/editor/editor_file_system.cpp7
-rw-r--r--tools/editor/editor_file_system.h1
-rw-r--r--tools/editor/editor_help.cpp3
-rw-r--r--tools/editor/editor_node.cpp182
-rw-r--r--tools/editor/editor_node.h14
-rw-r--r--tools/editor/editor_path.cpp1
-rw-r--r--tools/editor/editor_plugin.cpp1
-rw-r--r--tools/editor/editor_resource_preview.cpp168
-rw-r--r--tools/editor/editor_resource_preview.h4
-rw-r--r--tools/editor/editor_run_native.cpp4
-rw-r--r--tools/editor/editor_settings.cpp26
-rw-r--r--tools/editor/editor_settings.h3
-rw-r--r--tools/editor/groups_editor.cpp30
-rw-r--r--tools/editor/import_settings.cpp301
-rw-r--r--tools/editor/io_plugins/editor_atlas.cpp6
-rw-r--r--tools/editor/io_plugins/editor_import_collada.cpp7
-rw-r--r--tools/editor/io_plugins/editor_mesh_import_plugin.cpp2
-rw-r--r--tools/editor/io_plugins/editor_scene_import_plugin.cpp95
-rw-r--r--tools/editor/io_plugins/editor_texture_import_plugin.cpp4
-rw-r--r--tools/editor/io_plugins/editor_translation_import_plugin.cpp2
-rw-r--r--tools/editor/output_strings.cpp1
-rw-r--r--tools/editor/plugins/animation_player_editor_plugin.cpp2
-rw-r--r--tools/editor/plugins/animation_tree_editor_plugin.cpp2
-rw-r--r--tools/editor/plugins/baked_light_baker.cpp11
-rw-r--r--tools/editor/plugins/canvas_item_editor_plugin.cpp58
-rw-r--r--tools/editor/plugins/collision_polygon_2d_editor_plugin.cpp2
-rw-r--r--tools/editor/plugins/collision_polygon_editor_plugin.cpp4
-rw-r--r--tools/editor/plugins/editor_preview_plugins.cpp12
-rw-r--r--tools/editor/plugins/light_occluder_2d_editor_plugin.cpp2
-rw-r--r--tools/editor/plugins/navigation_polygon_editor_plugin.cpp2
-rw-r--r--tools/editor/plugins/particles_editor_plugin.cpp1
-rw-r--r--tools/editor/plugins/polygon_2d_editor_plugin.cpp2
-rw-r--r--tools/editor/plugins/sample_editor_plugin.cpp15
-rw-r--r--tools/editor/plugins/script_editor_plugin.cpp112
-rw-r--r--tools/editor/plugins/script_editor_plugin.h6
-rw-r--r--tools/editor/plugins/shader_editor_plugin.cpp11
-rw-r--r--tools/editor/plugins/shader_graph_editor_plugin.cpp7
-rw-r--r--tools/editor/plugins/spatial_editor_plugin.cpp349
-rw-r--r--tools/editor/plugins/sprite_frames_editor_plugin.cpp63
-rw-r--r--tools/editor/plugins/texture_region_editor_plugin.cpp4
-rw-r--r--tools/editor/plugins/tile_map_editor_plugin.cpp20
-rw-r--r--tools/editor/plugins/tile_set_editor_plugin.cpp22
-rw-r--r--tools/editor/project_export.cpp1
-rw-r--r--tools/editor/project_manager.cpp233
-rw-r--r--tools/editor/project_manager.h2
-rw-r--r--tools/editor/project_settings.cpp429
-rw-r--r--tools/editor/project_settings.h19
-rw-r--r--tools/editor/property_editor.cpp13
-rw-r--r--tools/editor/quick_open.cpp84
-rw-r--r--tools/editor/quick_open.h4
-rw-r--r--tools/editor/scene_tree_dock.cpp53
-rw-r--r--tools/editor/scene_tree_dock.h2
-rw-r--r--tools/editor/scenes_dock.cpp86
-rw-r--r--tools/editor/scenes_dock.h2
-rw-r--r--tools/editor/script_editor_debugger.cpp1
-rw-r--r--tools/editor/settings_config_dialog.cpp66
-rw-r--r--tools/editor/settings_config_dialog.h6
-rw-r--r--tools/editor/spatial_editor_gizmos.cpp83
73 files changed, 2248 insertions, 1673 deletions
diff --git a/tools/editor/animation_editor.cpp b/tools/editor/animation_editor.cpp
index 7582162b72..9eb6b4013f 100644
--- a/tools/editor/animation_editor.cpp
+++ b/tools/editor/animation_editor.cpp
@@ -85,7 +85,6 @@ private:
int points = 48;
if (mode==MODE_MULTIPLE) {
- int max_draw = 16;
Color mcolor=color;
mcolor.a*=0.3;
@@ -694,11 +693,103 @@ void AnimationKeyEditor::_menu_add_track(int p_type) {
}
}
+void AnimationKeyEditor::_anim_duplicate_keys(bool transpose) {
+ //duplicait!
+ if (selection.size() && animation.is_valid() && selected_track>=0 && selected_track<animation->get_track_count()) {
+
+ int top_track=0x7FFFFFFF;
+ float top_time = 1e10;
+ for(Map<SelectedKey,KeyInfo>::Element *E=selection.back();E;E=E->prev()) {
+
+ const SelectedKey &sk = E->key();
+
+ float t = animation->track_get_key_time(sk.track,sk.key);
+ if (t<top_time)
+ top_time=t;
+ if (sk.track<top_track)
+ top_track=sk.track;
+
+ }
+ ERR_FAIL_COND( top_track == 0x7FFFFFFF || top_time==1e10 );
+
+ //
+
+ int start_track = transpose ? selected_track : top_track;
+
+ undo_redo->create_action(TTR("Anim Duplicate Keys"));
+
+ List<Pair<int,float> > new_selection_values;
+
+ for(Map<SelectedKey,KeyInfo>::Element *E=selection.back();E;E=E->prev()) {
+
+ const SelectedKey &sk = E->key();
+
+ float t = animation->track_get_key_time(sk.track,sk.key);
+
+ float dst_time = t+(timeline_pos - top_time);
+ int dst_track = sk.track + (start_track - top_track);
+
+ if (dst_track < 0 || dst_track>= animation->get_track_count())
+ continue;
+
+ if (animation->track_get_type(dst_track) != animation->track_get_type(sk.track))
+ continue;
+
+ int existing_idx = animation->track_find_key(dst_track,dst_time,true);
+
+ undo_redo->add_do_method(animation.ptr(),"track_insert_key",dst_track,dst_time,animation->track_get_key_value(E->key().track,E->key().key),animation->track_get_key_transition(E->key().track,E->key().key));
+ undo_redo->add_undo_method(animation.ptr(),"track_remove_key_at_pos",dst_track,dst_time);
+
+ Pair<int,float> p;
+ p.first=dst_track;
+ p.second=dst_time;
+ new_selection_values.push_back( p );
+
+ if (existing_idx!=-1) {
+
+ undo_redo->add_undo_method(animation.ptr(),"track_insert_key",dst_track,dst_time,animation->track_get_key_value(dst_track,existing_idx),animation->track_get_key_transition(dst_track,existing_idx));
+
+ }
+
+ }
+
+ undo_redo->commit_action();
+
+ //reselect duplicated
+
+ Map<SelectedKey,KeyInfo> new_selection;
+ for (List<Pair<int,float> >::Element *E=new_selection_values.front();E;E=E->next()) {
+
+ int track=E->get().first;
+ float time = E->get().second;
+
+ int existing_idx = animation->track_find_key(track,time,true);
+
+ if (existing_idx==-1)
+ continue;
+ SelectedKey sk2;
+ sk2.track=track;
+ sk2.key=existing_idx;
+
+ KeyInfo ki;
+ ki.pos=time;
+
+ new_selection[sk2]=ki;
+
+ }
+
+
+ selection=new_selection;
+ track_editor->update();
+ _edit_if_single_selection();
+
+ }
+}
+
void AnimationKeyEditor::_menu_track(int p_type) {
ERR_FAIL_COND(!animation.is_valid());
-
last_menu_track_opt=p_type;
switch(p_type) {
@@ -766,108 +857,7 @@ void AnimationKeyEditor::_menu_track(int p_type) {
case TRACK_MENU_DUPLICATE:
case TRACK_MENU_DUPLICATE_TRANSPOSE: {
-
- //duplicait!
- if (selection.size() && animation.is_valid() && selected_track>=0 && selected_track<animation->get_track_count()) {
-
-
- int top_track=0x7FFFFFFF;
- float top_time = 1e10;
- for(Map<SelectedKey,KeyInfo>::Element *E=selection.back();E;E=E->prev()) {
-
- const SelectedKey &sk = E->key();
-
- float t = animation->track_get_key_time(sk.track,sk.key);
- if (t<top_time)
- top_time=t;
- if (sk.track<top_track)
- top_track=sk.track;
-
-
- }
- ERR_FAIL_COND( top_track == 0x7FFFFFFF || top_time==1e10 );
-
- //
-
- int start_track = p_type==TRACK_MENU_DUPLICATE_TRANSPOSE ? selected_track : top_track;
-
-
- undo_redo->create_action(TTR("Anim Duplicate Keys"));
-
- List<Pair<int,float> > new_selection_values;
-
- for(Map<SelectedKey,KeyInfo>::Element *E=selection.back();E;E=E->prev()) {
-
- const SelectedKey &sk = E->key();
-
- float t = animation->track_get_key_time(sk.track,sk.key);
-
- float dst_time = t+(timeline_pos - top_time);
- int dst_track = sk.track + (start_track - top_track);
-
- if (dst_track < 0 || dst_track>= animation->get_track_count())
- continue;
-
- if (animation->track_get_type(dst_track) != animation->track_get_type(sk.track))
- continue;
-
- int existing_idx = animation->track_find_key(dst_track,dst_time,true);
-
- undo_redo->add_do_method(animation.ptr(),"track_insert_key",dst_track,dst_time,animation->track_get_key_value(E->key().track,E->key().key),animation->track_get_key_transition(E->key().track,E->key().key));
- undo_redo->add_undo_method(animation.ptr(),"track_remove_key_at_pos",dst_track,dst_time);
-
- Pair<int,float> p;
- p.first=dst_track;
- p.second=dst_time;
- new_selection_values.push_back( p );
-
- if (existing_idx!=-1) {
-
- undo_redo->add_undo_method(animation.ptr(),"track_insert_key",dst_track,dst_time,animation->track_get_key_value(dst_track,existing_idx),animation->track_get_key_transition(dst_track,existing_idx));
-
- }
-
-
-
- }
-
- undo_redo->commit_action();
-
- //reselect duplicated
-
- Map<SelectedKey,KeyInfo> new_selection;
- for (List<Pair<int,float> >::Element *E=new_selection_values.front();E;E=E->next()) {
-
-
- int track=E->get().first;
- float time = E->get().second;
-
- int existing_idx = animation->track_find_key(track,time,true);
-
- if (existing_idx==-1)
- continue;
- SelectedKey sk2;
- sk2.track=track;
- sk2.key=existing_idx;
-
- KeyInfo ki;
- ki.pos=time;
-
-
- new_selection[sk2]=ki;
-
-
- }
-
-
- selection=new_selection;
- track_editor->update();
- _edit_if_single_selection();
-
-
- }
-
-
+ _anim_duplicate_keys(p_type==TRACK_MENU_DUPLICATE_TRANSPOSE);
} break;
case TRACK_MENU_SET_ALL_TRANS_LINEAR:
case TRACK_MENU_SET_ALL_TRANS_CONSTANT:
@@ -1356,7 +1346,6 @@ void AnimationKeyEditor::_track_editor_draw() {
}
}
- Color sep_color=color;
color.a*=0.5;
for(int i=0;i<fit;i++) {
@@ -1620,9 +1609,7 @@ void AnimationKeyEditor::_track_menu_selected(int p_idx) {
undo_redo->add_do_method(animation.ptr(),"track_set_interpolation_type",interp_editing,p_idx);
undo_redo->add_undo_method(animation.ptr(),"track_set_interpolation_type",interp_editing,animation->track_get_interpolation_type(interp_editing));
undo_redo->commit_action();
- }
-
- if (cont_editing!=-1) {
+ } else if (cont_editing!=-1) {
ERR_FAIL_INDEX(cont_editing,animation->get_track_count());
@@ -1630,6 +1617,16 @@ void AnimationKeyEditor::_track_menu_selected(int p_idx) {
undo_redo->add_do_method(animation.ptr(),"value_track_set_update_mode",cont_editing,p_idx);
undo_redo->add_undo_method(animation.ptr(),"value_track_set_update_mode",cont_editing,animation->value_track_get_update_mode(cont_editing));
undo_redo->commit_action();
+ } else {
+ switch (p_idx) {
+
+ case RIGHT_MENU_DUPLICATE:
+ _anim_duplicate_keys(); break;
+ case RIGHT_MENU_DUPLICATE_TRANSPOSE:
+ _anim_duplicate_keys(true); break;
+ case RIGHT_MENU_REMOVE:
+ _anim_delete_keys(); break;
+ }
}
}
@@ -1791,6 +1788,25 @@ bool AnimationKeyEditor::_edit_if_single_selection() {
}
+void AnimationKeyEditor::_anim_delete_keys() {
+ if (selection.size()) {
+ undo_redo->create_action(TTR("Anim Delete Keys"));
+
+ for(Map<SelectedKey,KeyInfo>::Element *E=selection.back();E;E=E->prev()) {
+
+ undo_redo->add_do_method(animation.ptr(),"track_remove_key",E->key().track,E->key().key);
+ undo_redo->add_undo_method(animation.ptr(),"track_insert_key",E->key().track,E->get().pos,animation->track_get_key_value(E->key().track,E->key().key),animation->track_get_key_transition(E->key().track,E->key().key));
+
+ }
+ undo_redo->add_do_method(this,"_clear_selection_for_anim",animation);
+ undo_redo->add_undo_method(this,"_clear_selection_for_anim",animation);
+ undo_redo->commit_action();
+ //selection.clear();
+ accept_event();
+ _edit_if_single_selection();
+ }
+}
+
void AnimationKeyEditor::_track_editor_input_event(const InputEvent& p_input) {
Control *te=track_editor;
@@ -1806,8 +1822,6 @@ void AnimationKeyEditor::_track_editor_input_event(const InputEvent& p_input) {
Ref<Font> font = te->get_font("font","Tree");
int sep = get_constant("vseparation","Tree");
int hsep = get_constant("hseparation","Tree");
- Color color = get_color("font_color","Tree");
- Color sepcolor = get_color("guide_color","Tree");
Ref<Texture> remove_icon = get_icon("Remove","EditorIcons");
Ref<Texture> move_up_icon = get_icon("MoveUp","EditorIcons");
Ref<Texture> move_down_icon = get_icon("MoveDown","EditorIcons");
@@ -1863,22 +1877,7 @@ void AnimationKeyEditor::_track_editor_input_event(const InputEvent& p_input) {
} else if (p_input.key.scancode==KEY_DELETE && p_input.key.pressed && click.click==ClickOver::CLICK_NONE) {
- if (selection.size()) {
- undo_redo->create_action(TTR("Anim Delete Keys"));
-
- for(Map<SelectedKey,KeyInfo>::Element *E=selection.back();E;E=E->prev()) {
-
- undo_redo->add_do_method(animation.ptr(),"track_remove_key",E->key().track,E->key().key);
- undo_redo->add_undo_method(animation.ptr(),"track_insert_key",E->key().track,E->get().pos,animation->track_get_key_value(E->key().track,E->key().key),animation->track_get_key_transition(E->key().track,E->key().key));
-
- }
- undo_redo->add_do_method(this,"_clear_selection_for_anim",animation);
- undo_redo->add_undo_method(this,"_clear_selection_for_anim",animation);
- undo_redo->commit_action();
- //selection.clear();
- accept_event();
- _edit_if_single_selection();
- }
+ _anim_delete_keys();
} else if (animation.is_valid() && animation->get_track_count()>0) {
if (p_input.is_pressed() && (p_input.is_action("ui_up") || p_input.is_action("ui_page_up"))) {
@@ -1938,6 +1937,116 @@ void AnimationKeyEditor::_track_editor_input_event(const InputEvent& p_input) {
v_scroll->set_val( v_scroll->get_val() + v_scroll->get_page() / 8 );
}
+ if (mb.button_index==BUTTON_RIGHT && mb.pressed) {
+
+ Point2 mpos = Point2(mb.x,mb.y)-ofs;
+
+ if (selection.size() == 0) {
+ // Auto-select on right-click if nothing is selected
+ // Note: This code is pretty much duplicated from the left click code,
+ // both codes could be moved into a function to avoid the duplicated code.
+ Point2 mpos = Point2(mb.x,mb.y)-ofs;
+
+ if (mpos.y < h ) {
+ return;
+ }
+
+ mpos.y -= h;
+
+ int idx = mpos.y / h;
+ idx+=v_scroll->get_val();
+ if (idx <0 || idx>=animation->get_track_count())
+ break;
+
+ if (mpos.x < name_limit) {
+ } else if (mpos.x < settings_limit) {
+ float pos = mpos.x - name_limit;
+ pos/=_get_zoom_scale();
+ pos+=h_scroll->get_val();
+ float w_time = (type_icon[0]->get_width() / _get_zoom_scale())/2.0;
+
+ int kidx = animation->track_find_key(idx,pos);
+ int kidx_n = kidx+1;
+ int key=-1;
+
+ if (kidx>=0 && kidx<animation->track_get_key_count(idx)) {
+
+ float kpos = animation->track_get_key_time(idx,kidx);
+ if (ABS(pos-kpos)<=w_time) {
+
+ key=kidx;
+ }
+ }
+
+ if (key==-1 && kidx_n>=0 && kidx_n<animation->track_get_key_count(idx)) {
+
+ float kpos = animation->track_get_key_time(idx,kidx_n);
+ if (ABS(pos-kpos)<=w_time) {
+
+ key=kidx_n;
+ }
+ }
+
+ if (key==-1) {
+
+ click.click=ClickOver::CLICK_SELECT_KEYS;
+ click.at=Point2(mb.x,mb.y);
+ click.to=click.at;
+ click.shift=mb.mod.shift;
+ selected_track=idx;
+ track_editor->update();
+ //drag select region
+ return;
+
+ }
+
+
+
+ SelectedKey sk;
+ sk.track=idx;
+ sk.key=key;
+ KeyInfo ki;
+ ki.pos= animation->track_get_key_time(idx,key);
+ click.shift=mb.mod.shift;
+ click.selk=sk;
+
+
+ if (!mb.mod.shift && !selection.has(sk))
+ _clear_selection();
+
+ selection.insert(sk,ki);
+
+ click.click=ClickOver::CLICK_MOVE_KEYS;
+ click.at=Point2(mb.x,mb.y);
+ click.to=click.at;
+ update();
+ selected_track=idx;
+ track_editor->update();
+
+ if (_edit_if_single_selection() && mb.mod.command) {
+ edit_button->set_pressed(true);
+ key_editor_tab->show();
+ }
+ }
+ }
+
+ if (selection.size()) {
+ // User has right clicked and we have a selection, show a popup menu with options
+ track_menu->clear();
+ track_menu->set_size(Point2(1,1));
+ track_menu->add_item(TTR("Duplicate Selection"), RIGHT_MENU_DUPLICATE);
+ track_menu->add_item(TTR("Duplicate Transposed"), RIGHT_MENU_DUPLICATE_TRANSPOSE);
+ track_menu->add_item(TTR("Remove Selection"), RIGHT_MENU_REMOVE);
+
+ track_menu->set_pos(te->get_global_pos()+mpos);
+
+ interp_editing=-1;
+ cont_editing=-1;
+
+ track_menu->popup();
+ }
+ }
+
if (mb.button_index==BUTTON_LEFT && !(mb.button_mask&~BUTTON_MASK_LEFT)) {
@@ -3007,7 +3116,6 @@ void AnimationKeyEditor::_update_menu() {
updating=true;
- bool empty= !animation.is_valid();
if (animation.is_valid()) {
length->set_val(animation->get_length());
diff --git a/tools/editor/animation_editor.h b/tools/editor/animation_editor.h
index 413c73b4b9..131100a205 100644
--- a/tools/editor/animation_editor.h
+++ b/tools/editor/animation_editor.h
@@ -99,6 +99,12 @@ class AnimationKeyEditor : public VBoxContainer {
CURVE_SET_CONSTANT
};
+ enum {
+ RIGHT_MENU_DUPLICATE,
+ RIGHT_MENU_DUPLICATE_TRANSPOSE,
+ RIGHT_MENU_REMOVE
+ };
+
struct MouseOver {
enum Over {
@@ -313,6 +319,9 @@ class AnimationKeyEditor : public VBoxContainer {
void _add_call_track(const NodePath& p_base);
+ void _anim_duplicate_keys(bool transpose = false);
+ void _anim_delete_keys();
+
void _root_removed();
protected:
diff --git a/tools/editor/asset_library_editor_plugin.cpp b/tools/editor/asset_library_editor_plugin.cpp
index a2448921d7..4f685badfb 100644
--- a/tools/editor/asset_library_editor_plugin.cpp
+++ b/tools/editor/asset_library_editor_plugin.cpp
@@ -444,6 +444,13 @@ void EditorAssetLibraryItemDownload::_close() {
void EditorAssetLibraryItemDownload::_install() {
String file = download->get_download_file();
+
+ if (external_install) {
+ emit_signal("install_asset",file,title->get_text());
+ return;
+ }
+
+
asset_installer->open(file,1);
}
@@ -465,6 +472,8 @@ void EditorAssetLibraryItemDownload::_bind_methods() {
ObjectTypeDB::bind_method("_close",&EditorAssetLibraryItemDownload::_close);
ObjectTypeDB::bind_method("_make_request",&EditorAssetLibraryItemDownload::_make_request);
+ ADD_SIGNAL(MethodInfo("install_asset",PropertyInfo(Variant::STRING,"zip_path"),PropertyInfo(Variant::STRING,"name")));
+
}
EditorAssetLibraryItemDownload::EditorAssetLibraryItemDownload() {
@@ -530,6 +539,8 @@ EditorAssetLibraryItemDownload::EditorAssetLibraryItemDownload() {
prev_status=-1;
+ external_install=false;
+
}
@@ -600,7 +611,8 @@ void EditorAssetLibrary::_install_asset() {
EditorAssetLibraryItemDownload *d = downloads_hb->get_child(i)->cast_to<EditorAssetLibraryItemDownload>();
if (d && d->get_asset_id() == description->get_asset_id()) {
- EditorNode::get_singleton()->show_warning("Download for this asset is already in progress!");
+ if (EditorNode::get_singleton() != NULL)
+ EditorNode::get_singleton()->show_warning("Download for this asset is already in progress!");
return;
}
}
@@ -610,6 +622,11 @@ void EditorAssetLibrary::_install_asset() {
downloads_hb->add_child(download);
download->configure(description->get_title(),description->get_asset_id(),description->get_preview_icon(),description->get_download_url(),description->get_sha256());
+ if (templates_only) {
+ download->set_external_install(true);
+ download->connect("install_asset",this,"_install_external_asset");
+ }
+
}
const char* EditorAssetLibrary::sort_key[SORT_MAX]={
@@ -1258,6 +1275,11 @@ void EditorAssetLibrary::_manage_plugins() {
+void EditorAssetLibrary::_install_external_asset(String p_zip_path,String p_title) {
+
+ emit_signal("install_asset",p_zip_path,p_title);
+}
+
void EditorAssetLibrary::_bind_methods() {
ObjectTypeDB::bind_method("_http_request_completed",&EditorAssetLibrary::_http_request_completed);
@@ -1273,6 +1295,11 @@ void EditorAssetLibrary::_bind_methods() {
ObjectTypeDB::bind_method("_repository_changed",&EditorAssetLibrary::_repository_changed);
ObjectTypeDB::bind_method("_support_toggled",&EditorAssetLibrary::_support_toggled);
ObjectTypeDB::bind_method("_rerun_search",&EditorAssetLibrary::_rerun_search);
+ ObjectTypeDB::bind_method("_install_external_asset",&EditorAssetLibrary::_install_external_asset);
+
+
+
+ ADD_SIGNAL(MethodInfo("install_asset",PropertyInfo(Variant::STRING,"zip_path"),PropertyInfo(Variant::STRING,"name")));
}
@@ -1366,7 +1393,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
repository = memnew( OptionButton );
repository->add_item("Godot");
- repository->set_item_metadata(0, "http://godotengine.org/asset-library/api");
+ repository->set_item_metadata(0, "https://godotengine.org/asset-library/api");
repository->add_item("Localhost"); // TODO: Maybe remove?
repository->set_item_metadata(1, "http://127.0.0.1/asset-library/api");
repository->connect("item_selected",this,"_repository_changed");
diff --git a/tools/editor/asset_library_editor_plugin.h b/tools/editor/asset_library_editor_plugin.h
index 89663aa00b..fe40255af9 100644
--- a/tools/editor/asset_library_editor_plugin.h
+++ b/tools/editor/asset_library_editor_plugin.h
@@ -155,6 +155,8 @@ class EditorAssetLibraryItemDownload : public PanelContainer {
int asset_id;
+ bool external_install;
+
EditorAssetInstaller *asset_installer;
void _close();
@@ -168,6 +170,7 @@ protected:
static void _bind_methods();
public:
+ void set_external_install(bool p_enable) { external_install=p_enable; }
int get_asset_id() { return asset_id; }
void configure(const String& p_title,int p_asset_id,const Ref<Texture>& p_preview, const String& p_download_url, const String& p_sha256_hash);
EditorAssetLibraryItemDownload();
@@ -301,6 +304,8 @@ class EditorAssetLibrary : public PanelContainer {
void _repository_changed(int p_repository_id);
void _support_toggled(int p_support);
+ void _install_external_asset(String p_zip_path,String p_title);
+
friend class EditorAssetLibraryItemDescription;
friend class EditorAssetLibraryItem;
protected:
diff --git a/tools/editor/code_editor.cpp b/tools/editor/code_editor.cpp
index 644478923c..71ae171dfe 100644
--- a/tools/editor/code_editor.cpp
+++ b/tools/editor/code_editor.cpp
@@ -32,6 +32,7 @@
#include "scene/gui/separator.h"
#include "scene/resources/dynamic_font.h"
#include "os/keyboard.h"
+#include "tools/editor/editor_scale.h"
void GotoLineDialog::popup_find_line(TextEdit *p_edit) {
@@ -984,36 +985,47 @@ void CodeTextEditor::_text_editor_input_event(const InputEvent& p_event) {
if (mb.pressed && mb.mod.command) {
if (mb.button_index==BUTTON_WHEEL_UP) {
-
- font_resize_val+=1;
-
- if (font_resize_timer->get_time_left()==0)
- font_resize_timer->start();
-
+ _zoom_in();
} else if (mb.button_index==BUTTON_WHEEL_DOWN) {
-
- font_resize_val-=1;
-
- if (font_resize_timer->get_time_left()==0)
- font_resize_timer->start();
+ _zoom_out();
}
}
} else if (p_event.type==InputEvent::KEY) {
- const InputEventKey& k=p_event.key;
+ if (p_event.key.pressed) {
+ if (ED_IS_SHORTCUT("script_editor/zoom_in", p_event)) {
+ _zoom_in();
+ }
+ if (ED_IS_SHORTCUT("script_editor/zoom_out", p_event)) {
+ _zoom_out();
+ }
+ if (ED_IS_SHORTCUT("script_editor/reset_zoom", p_event)) {
+ _reset_zoom();
+ }
+ }
+ }
+}
- if (k.pressed && k.mod.command) {
+void CodeTextEditor::_zoom_in() {
+ font_resize_val+=1;
- if (k.scancode==KEY_0) { // reset source font size to default
+ if (font_resize_timer->get_time_left()==0)
+ font_resize_timer->start();
+}
- Ref<DynamicFont> font = text_editor->get_font("font");
+void CodeTextEditor::_zoom_out() {
+ font_resize_val-=1;
- if (font.is_valid()) {
- EditorSettings::get_singleton()->set("global/source_font_size",14);
- font->set_size(14);
- }
- }
- }
+ if (font_resize_timer->get_time_left()==0)
+ font_resize_timer->start();
+}
+
+void CodeTextEditor::_reset_zoom() {
+ Ref<DynamicFont> font = text_editor->get_font("font"); // reset source font size to default
+
+ if (font.is_valid()) {
+ EditorSettings::get_singleton()->set("global/source_font_size",14);
+ font->set_size(14);
}
}
@@ -1149,6 +1161,10 @@ void CodeTextEditor::_bind_methods() {
CodeTextEditor::CodeTextEditor() {
+ ED_SHORTCUT("script_editor/zoom_in", TTR("Zoom In"), KEY_MASK_CMD|KEY_EQUAL);
+ ED_SHORTCUT("script_editor/zoom_out", TTR("Zoom Out"), KEY_MASK_CMD|KEY_MINUS);
+ ED_SHORTCUT("script_editor/reset_zoom", TTR("Reset Zoom"), KEY_MASK_CMD|KEY_0);
+
find_replace_bar = memnew( FindReplaceBar );
add_child(find_replace_bar);
find_replace_bar->set_h_size_flags(SIZE_EXPAND_FILL);
@@ -1198,6 +1214,10 @@ CodeTextEditor::CodeTextEditor() {
line_col = memnew( Label );
status_bar->add_child(line_col);
line_col->set_valign(Label::VALIGN_CENTER);
+ line_col->set_autowrap(true);
+ line_col->set_v_size_flags(SIZE_FILL);
+ line_col->set_custom_minimum_size(Size2(100,1)*EDSCALE);
+ status_bar->add_child( memnew( Label ) ); //to keep the height if the other labels are not visible
text_editor->connect("input_event", this,"_text_editor_input_event");
diff --git a/tools/editor/code_editor.h b/tools/editor/code_editor.h
index bdfd295ded..7983c46f7a 100644
--- a/tools/editor/code_editor.h
+++ b/tools/editor/code_editor.h
@@ -214,6 +214,9 @@ class CodeTextEditor : public VBoxContainer {
void _font_resize_timeout();
void _text_editor_input_event(const InputEvent& p_event);
+ void _zoom_in();
+ void _zoom_out();
+ void _reset_zoom();
protected:
diff --git a/tools/editor/connections_dialog.cpp b/tools/editor/connections_dialog.cpp
index faaae4360b..bdc420c70f 100644
--- a/tools/editor/connections_dialog.cpp
+++ b/tools/editor/connections_dialog.cpp
@@ -309,6 +309,7 @@ ConnectDialog::ConnectDialog() {
tree = memnew(SceneTreeEditor(false));
+ tree->get_scene_tree()->connect("item_activated",this,"_ok");
vbc_left->add_margin_child(TTR("Connect To Node:"),tree,true);
diff --git a/tools/editor/create_dialog.cpp b/tools/editor/create_dialog.cpp
index 5275e1beeb..210b799f3d 100644
--- a/tools/editor/create_dialog.cpp
+++ b/tools/editor/create_dialog.cpp
@@ -42,12 +42,13 @@
void CreateDialog::popup(bool p_dontclear) {
- popup_centered_ratio(0.6);
+ popup_centered_ratio();
if (p_dontclear)
search_box->select_all();
else
search_box->clear();
search_box->grab_focus();
+
_update_search();
@@ -165,9 +166,10 @@ void CreateDialog::_update_search() {
if (!ObjectTypeDB::can_instance(type))
continue; // cant create what can't be instanced
- if (search_box->get_text()=="")
+
+ if (search_box->get_text()=="") {
add_type(type,types,root,&to_select);
- else {
+ } else {
bool found=false;
String type=I->get();
@@ -186,7 +188,7 @@ void CreateDialog::_update_search() {
add_type(I->get(),types,root,&to_select);
}
- if (EditorNode::get_editor_data().get_custom_types().has(type)) {
+ if (EditorNode::get_editor_data().get_custom_types().has(type) && ObjectTypeDB::is_type(type, base_type)) {
//there are custom types based on this... cool.
//print_line("there are custom types");
@@ -198,6 +200,7 @@ void CreateDialog::_update_search() {
if (!show)
continue;
+
if (!types.has(type))
add_type(type,types,root,&to_select);
@@ -216,7 +219,7 @@ void CreateDialog::_update_search() {
}
- if (!to_select && (search_box->get_text()=="" || ct[i].name.findn(search_box->get_text())!=-1)) {
+ if (!to_select) {
to_select=item;
}
@@ -246,7 +249,6 @@ void CreateDialog::_notification(int p_what) {
if (p_what==NOTIFICATION_ENTER_TREE) {
connect("confirmed",this,"_confirmed");
- _update_search();
}
if (p_what==NOTIFICATION_EXIT_TREE) {
diff --git a/tools/editor/dependency_editor.cpp b/tools/editor/dependency_editor.cpp
index ad2eb57f00..049bcefc75 100644
--- a/tools/editor/dependency_editor.cpp
+++ b/tools/editor/dependency_editor.cpp
@@ -80,8 +80,6 @@ void DependencyEditor::_fix_and_find(EditorFileSystemDirectory *efsd, Map<String
continue;
String path = efsd->get_file_path(i);
- Map<String,String> &ss = candidates[file];
-
for(Map<String,String>::Element *E=candidates[file].front();E;E=E->next()) {
@@ -420,7 +418,7 @@ void DependencyRemoveDialog::show(const Vector<String> &to_erase) {
exist=false;
owners->clear();
files.clear();
- TreeItem *root=owners->create_item();
+ owners->create_item(); // root
for(int i=0;i<to_erase.size();i++) {
files[to_erase[i]]=NULL;
}
diff --git a/tools/editor/editor_asset_installer.cpp b/tools/editor/editor_asset_installer.cpp
index ec36773d8d..b6051886c0 100644
--- a/tools/editor/editor_asset_installer.cpp
+++ b/tools/editor/editor_asset_installer.cpp
@@ -317,9 +317,11 @@ void EditorAssetInstaller::ok_pressed() {
}
msg+=failed_files[i];
}
- EditorNode::get_singleton()->show_warning(msg);
+ if (EditorNode::get_singleton() != NULL)
+ EditorNode::get_singleton()->show_warning(msg);
} else {
- EditorNode::get_singleton()->show_warning("Package Installed Successfully!","Success!");
+ if (EditorNode::get_singleton() != NULL)
+ EditorNode::get_singleton()->show_warning("Package Installed Successfully!","Success!");
}
diff --git a/tools/editor/editor_autoload_settings.cpp b/tools/editor/editor_autoload_settings.cpp
new file mode 100644
index 0000000000..97062b1480
--- /dev/null
+++ b/tools/editor/editor_autoload_settings.cpp
@@ -0,0 +1,616 @@
+/*************************************************************************/
+/* editor_autoload_settings.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_autoload_settings.h"
+
+#include "globals.h"
+#include "global_constants.h"
+
+#include "editor_node.h"
+
+#define PREVIEW_LIST_MAX_SIZE 10
+
+void EditorAutoloadSettings::_notification(int p_what) {
+
+ if (p_what == NOTIFICATION_ENTER_TREE) {
+
+ List<String> afn;
+ ResourceLoader::get_recognized_extensions_for_type("Script", &afn);
+ ResourceLoader::get_recognized_extensions_for_type("PackedScene", &afn);
+
+ EditorFileDialog *file_dialog = autoload_add_path->get_file_dialog();
+
+ for (List<String>::Element *E = afn.front(); E; E = E->next()) {
+
+ file_dialog->add_filter("*." + E->get());
+ }
+ }
+}
+
+bool EditorAutoloadSettings::_autoload_name_is_valid(const String& p_name, String* r_error) {
+
+ if (!p_name.is_valid_identifier()) {
+ if (r_error)
+ *r_error = TTR("Invalid name.") + "\n" + TTR("Valid characters:")+" a-z, A-Z, 0-9 or _";
+
+ return false;
+ }
+
+ if (ObjectTypeDB::type_exists(p_name)) {
+ if (r_error)
+ *r_error = TTR("Invalid name. Must not collide with an existing engine class name.");
+
+ return false;
+ }
+
+ for (int i = 0; i < Variant::VARIANT_MAX; i++) {
+ if (Variant::get_type_name( Variant::Type(i) ) == p_name) {
+ if (r_error)
+ *r_error = TTR("Invalid name. Must not collide with an existing buit-in type name.");
+
+ return false;
+ }
+ }
+
+ for (int i = 0; i < GlobalConstants::get_global_constant_count(); i++) {
+ if (GlobalConstants::get_global_constant_name(i) == p_name) {
+ if (r_error)
+ *r_error = TTR("Invalid name. Must not collide with an existing global constant name.");
+
+ return false;
+ }
+ }
+
+ return true;
+}
+
+void EditorAutoloadSettings::_autoload_add() {
+
+ String name = autoload_add_name->get_text();
+
+ String error;
+ if (!_autoload_name_is_valid(name, &error)) {
+ EditorNode::get_singleton()->show_warning(error);
+ return;
+ }
+
+ String path = autoload_add_path->get_line_edit()->get_text();
+ if (!FileAccess::exists(path)) {
+ EditorNode::get_singleton()->show_warning(TTR("Invalid Path.") + "\n" + TTR("File does not exist."));
+ return;
+ }
+
+ if (!path.begins_with("res://")) {
+ EditorNode::get_singleton()->show_warning(TTR("Invalid Path.") + "\n"+ TTR("Not in resource path."));
+ return;
+ }
+
+ name = "autoload/" + name;
+
+ UndoRedo* undo_redo = EditorNode::get_singleton()->get_undo_redo();
+
+ undo_redo->create_action(TTR("Add AutoLoad"));
+ undo_redo->add_do_property(Globals::get_singleton(), name, "*" + path);
+ undo_redo->add_do_method(Globals::get_singleton(), "set_persisting", name, true);
+
+ if (Globals::get_singleton()->has(name)) {
+ undo_redo->add_undo_property(Globals::get_singleton(), name, Globals::get_singleton()->get(name));
+ } else {
+ undo_redo->add_undo_property(Globals::get_singleton(), name, Variant());
+ }
+
+ undo_redo->add_do_method(this, "update_autoload");
+ undo_redo->add_undo_method(this, "update_autoload");
+
+ undo_redo->add_do_method(this, "emit_signal", autoload_changed);
+ undo_redo->add_undo_method(this, "emit_signal", autoload_changed);
+
+ undo_redo->commit_action();
+
+ autoload_add_path->get_line_edit()->set_text("");
+ autoload_add_name->set_text("");
+}
+
+void EditorAutoloadSettings::_autoload_selected() {
+
+ TreeItem *ti = tree->get_selected();
+
+ if (!ti)
+ return;
+
+ selected_autoload = "autoload/" + ti->get_text(0);
+}
+
+void EditorAutoloadSettings::_autoload_edited() {
+
+ if (updating_autoload)
+ return;
+
+ TreeItem *ti = tree->get_edited();
+ int column = tree->get_edited_column();
+
+ UndoRedo *undo_redo = EditorNode::get_undo_redo();
+
+ if (column == 0) {
+ String name = ti->get_text(0);
+ String old_name = selected_autoload.get_slice("/", 1);
+
+ if (name == old_name)
+ return;
+
+ String error;
+ if (!_autoload_name_is_valid(name, &error)) {
+ ti->set_text(0, old_name);
+ EditorNode::get_singleton()->show_warning(error);
+ return;
+ }
+
+ if (Globals::get_singleton()->has("autoload/" + name)) {
+ ti->set_text(0, old_name);
+ EditorNode::get_singleton()->show_warning(vformat(TTR("Autoload '%s' already exists!"), name));
+ return;
+ }
+
+ updating_autoload = true;
+
+ name = "autoload/" + name;
+
+ bool persisting = Globals::get_singleton()->get(selected_autoload);
+ int order = Globals::get_singleton()->get(selected_autoload);
+ String path = Globals::get_singleton()->get(selected_autoload);
+
+ undo_redo->create_action(TTR("Rename Autoload"));
+
+ undo_redo->add_do_property(Globals::get_singleton(), name, path);
+ undo_redo->add_do_method(Globals::get_singleton(), "set_persisting", name, persisting);
+ undo_redo->add_do_method(Globals::get_singleton(), "set_order", name, order);
+ undo_redo->add_do_method(Globals::get_singleton(), "clear", selected_autoload);
+
+ undo_redo->add_undo_property(Globals::get_singleton(), selected_autoload, path);
+ undo_redo->add_undo_method(Globals::get_singleton(), "set_persisting", selected_autoload, persisting);
+ undo_redo->add_undo_method(Globals::get_singleton(), "set_order", selected_autoload, order);
+ undo_redo->add_undo_method(Globals::get_singleton(), "clear", name);
+
+ undo_redo->add_do_method(this, "update_autoload");
+ undo_redo->add_undo_method(this, "update_autoload");
+
+ undo_redo->add_do_method(this, "emit_signal", autoload_changed);
+ undo_redo->add_undo_method(this, "emit_signal", autoload_changed);
+
+ undo_redo->commit_action();
+
+ selected_autoload = name;
+ } else if (column == 2) {
+ updating_autoload = true;
+
+ bool checked = ti->is_checked(2);
+ String base = "autoload/" + ti->get_text(0);
+
+ int order = Globals::get_singleton()->get_order(base);
+ 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(TTR("Toggle AutoLoad Globals"));
+
+ 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(Globals::get_singleton(),"set_order", base, order);
+ undo_redo->add_undo_method(Globals::get_singleton(),"set_order", base, order);
+
+ undo_redo->add_do_method(this, "update_autoload");
+ undo_redo->add_undo_method(this, "update_autoload");
+
+ undo_redo->add_do_method(this, "emit_signal", autoload_changed);
+ undo_redo->add_undo_method(this, "emit_signal", autoload_changed);
+
+ undo_redo->commit_action();
+ }
+
+ updating_autoload = false;
+}
+
+void EditorAutoloadSettings::_autoload_button_pressed(Object *p_item, int p_column, int p_button) {
+
+ TreeItem *ti = p_item->cast_to<TreeItem>();
+
+ String name = "autoload/" + ti->get_text(0);
+
+ UndoRedo *undo_redo = EditorNode::get_undo_redo();
+
+ switch (p_button) {
+
+ case BUTTON_MOVE_UP:
+ case BUTTON_MOVE_DOWN: {
+
+ TreeItem *swap = NULL;
+
+ if (p_button == BUTTON_MOVE_UP) {
+ swap = ti->get_prev();
+ } else {
+ swap = ti->get_next();
+ }
+
+ if (!swap)
+ return;
+
+ 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(TTR("Move Autoload"));
+
+ undo_redo->add_do_method(Globals::get_singleton(), "set_order", name, swap_order);
+ undo_redo->add_undo_method(Globals::get_singleton(), "set_order", name, order);
+
+ undo_redo->add_do_method(Globals::get_singleton(), "set_order", swap_name, order);
+ undo_redo->add_undo_method(Globals::get_singleton(), "set_order", swap_name, swap_order);
+
+ undo_redo->add_do_method(this, "update_autoload");
+ undo_redo->add_undo_method(this, "update_autoload");
+
+ undo_redo->add_do_method(this, "emit_signal", autoload_changed);
+ undo_redo->add_undo_method(this, "emit_signal", autoload_changed);
+
+ undo_redo->commit_action();
+ } break;
+ case BUTTON_DELETE: {
+
+ int order = Globals::get_singleton()->get_order(name);
+
+ undo_redo->create_action(TTR("Remove Autoload"));
+
+ undo_redo->add_do_property(Globals::get_singleton(), name, Variant());
+
+ undo_redo->add_undo_property(Globals::get_singleton(), name, Globals::get_singleton()->get(name));
+ undo_redo->add_undo_method(Globals::get_singleton(), "set_persisting", name, true);
+ undo_redo->add_undo_method(Globals::get_singleton(), "set_order", order);
+
+ undo_redo->add_do_method(this, "update_autoload");
+ undo_redo->add_undo_method(this, "update_autoload");
+
+ undo_redo->add_do_method(this, "emit_signal", autoload_changed);
+ undo_redo->add_undo_method(this, "emit_signal", autoload_changed);
+
+ undo_redo->commit_action();
+ } break;
+ }
+}
+
+void EditorAutoloadSettings::_autoload_file_callback(const String& p_path) {
+
+ autoload_add_name->set_text(p_path.get_file().basename());
+}
+
+void EditorAutoloadSettings::update_autoload() {
+
+ if (updating_autoload)
+ return;
+
+ updating_autoload = true;
+
+ autoload_cache.clear();
+
+ tree->clear();
+ TreeItem *root = tree->create_item();
+
+ List<PropertyInfo> props;
+ Globals::get_singleton()->get_property_list(&props);
+
+ for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) {
+
+ const PropertyInfo &pi = E->get();
+
+ if (!pi.name.begins_with("autoload/"))
+ continue;
+
+ String name = pi.name.get_slice("/", 1);
+ String path = Globals::get_singleton()->get(pi.name);
+
+ if (name.empty())
+ continue;
+
+ AutoLoadInfo info;
+ info.name = pi.name;
+ info.order = Globals::get_singleton()->get_order(pi.name);
+
+ autoload_cache.push_back(info);
+
+ bool global = false;
+
+ if (path.begins_with("*")) {
+ global = true;
+ path = path.substr(1, path.length());
+ }
+
+ TreeItem *item = tree->create_item(root);
+ item->set_text(0, name);
+ item->set_editable(0, true);
+
+ item->set_text(1, path);
+ item->set_selectable(1, false);
+
+ item->set_cell_mode(2, TreeItem::CELL_MODE_CHECK);
+ item->set_editable(2, true);
+ item->set_text(2, TTR("Enable"));
+ item->set_checked(2, global);
+
+ item->add_button(3, get_icon("MoveUp","EditorIcons"), BUTTON_MOVE_UP);
+ item->add_button(3, get_icon("MoveDown","EditorIcons"), BUTTON_MOVE_DOWN);
+ item->add_button(3, get_icon("Del","EditorIcons"), BUTTON_DELETE);
+ item->set_selectable(3, false);
+ }
+
+ updating_autoload = false;
+}
+
+Variant EditorAutoloadSettings::get_drag_data_fw(const Point2& p_point, Control *p_control) {
+
+ if (autoload_cache.size() <= 1)
+ return false;
+
+ StringArray autoloads;
+
+ TreeItem *next = tree->get_next_selected(NULL);
+
+ while (next) {
+ autoloads.push_back(next->get_text(0));
+ next = tree->get_next_selected(next);
+ }
+
+ if (autoloads.size() == 0 || autoloads.size() == autoload_cache.size())
+ return Variant();
+
+ VBoxContainer *preview = memnew( VBoxContainer );
+
+ int max_size = MIN(PREVIEW_LIST_MAX_SIZE, autoloads.size());
+
+ for (int i = 0; i < max_size; i++) {
+ Label *label = memnew( Label(autoloads[i]) );
+ label->set_self_opacity(Math::lerp(1, 0, float(i)/PREVIEW_LIST_MAX_SIZE));
+
+ preview->add_child(label);
+ }
+
+ tree->set_drop_mode_flags(Tree::DROP_MODE_INBETWEEN);
+ tree->set_drag_preview(preview);
+
+ Dictionary drop_data;
+ drop_data["type"] = "autoload";
+ drop_data["autoloads"] = autoloads;
+
+ return drop_data;
+}
+
+bool EditorAutoloadSettings::can_drop_data_fw(const Point2& p_point, const Variant& p_data, Control *p_control) const {
+ if (updating_autoload)
+ return false;
+
+ Dictionary drop_data = p_data;
+
+ if (!drop_data.has("type"))
+ return false;
+
+ if (drop_data.has("type")) {
+ TreeItem *ti = tree->get_item_at_pos(p_point);
+
+ if (!ti)
+ return false;
+
+ int section = tree->get_drop_section_at_pos(p_point);
+
+ if (section < -1)
+ return false;
+
+ return true;
+ }
+
+ return false;
+}
+
+void EditorAutoloadSettings::drop_data_fw(const Point2& p_point, const Variant& p_data, Control *p_control) {
+
+ TreeItem *ti = tree->get_item_at_pos(p_point);
+
+ if (!ti)
+ return;
+
+ int section = tree->get_drop_section_at_pos(p_point);
+
+ if (section < -1)
+ return;
+
+ String name;
+ bool move_to_back = false;
+
+ if (section < 0) {
+ name = ti->get_text(0);
+ } else if (ti->get_next()) {
+ name = ti->get_next()->get_text(0);
+ } else {
+ name = ti->get_text(0);
+ move_to_back = true;
+ }
+
+ int order = Globals::get_singleton()->get_order("autoload/" + name);
+
+ AutoLoadInfo aux;
+ List<AutoLoadInfo>::Element *E = NULL;
+
+ if (!move_to_back) {
+ aux.order = order;
+ E = autoload_cache.find(aux);
+ }
+
+ Dictionary drop_data = p_data;
+ StringArray autoloads = drop_data["autoloads"];
+
+ Vector<int> orders;
+ orders.resize(autoload_cache.size());
+
+ for (int i = 0; i < autoloads.size(); i++) {
+ aux.order = Globals::get_singleton()->get_order("autoload/" + autoloads[i]);
+
+ List<AutoLoadInfo>::Element *I = autoload_cache.find(aux);
+
+ if (move_to_back) {
+ autoload_cache.move_to_back(I);
+ } else if (E != I) {
+ autoload_cache.move_before(I, E);
+ } else if (E->next()) {
+ E = E->next();
+ } else {
+ break;
+ }
+ }
+
+ int i = 0;
+
+ for (List<AutoLoadInfo>::Element *E = autoload_cache.front(); E; E = E->next()) {
+ orders[i++] = E->get().order;
+ }
+
+ orders.sort();
+
+ UndoRedo *undo_redo = EditorNode::get_undo_redo();
+
+ undo_redo->create_action(TTR("Rearrange Autoloads"));
+
+ i = 0;
+
+ for (List<AutoLoadInfo>::Element *E = autoload_cache.front(); E; E = E->next()) {
+ undo_redo->add_do_method(Globals::get_singleton(), "set_order", E->get().name, orders[i++]);
+ undo_redo->add_undo_method(Globals::get_singleton(), "set_order", E->get().name, E->get().order);
+ }
+
+ orders.clear();
+
+ undo_redo->add_do_method(this, "update_autoload");
+ undo_redo->add_undo_method(this, "update_autoload");
+
+ undo_redo->add_do_method(this, "emit_signal", autoload_changed);
+ undo_redo->add_undo_method(this, "emit_signal", autoload_changed);
+
+ undo_redo->commit_action();
+}
+
+void EditorAutoloadSettings::_bind_methods() {
+
+ ObjectTypeDB::bind_method("_autoload_add", &EditorAutoloadSettings::_autoload_add);
+ ObjectTypeDB::bind_method("_autoload_selected", &EditorAutoloadSettings::_autoload_selected);
+ ObjectTypeDB::bind_method("_autoload_edited", &EditorAutoloadSettings::_autoload_edited);
+ ObjectTypeDB::bind_method("_autoload_button_pressed", &EditorAutoloadSettings::_autoload_button_pressed);
+ ObjectTypeDB::bind_method("_autoload_file_callback", &EditorAutoloadSettings::_autoload_file_callback);
+
+ ObjectTypeDB::bind_method("get_drag_data_fw", &EditorAutoloadSettings::get_drag_data_fw);
+ ObjectTypeDB::bind_method("can_drop_data_fw", &EditorAutoloadSettings::can_drop_data_fw);
+ ObjectTypeDB::bind_method("drop_data_fw", &EditorAutoloadSettings::drop_data_fw);
+
+ ObjectTypeDB::bind_method("update_autoload", &EditorAutoloadSettings::update_autoload);
+
+ ADD_SIGNAL(MethodInfo("autoload_changed"));
+}
+
+EditorAutoloadSettings::EditorAutoloadSettings() {
+
+ autoload_changed = "autoload_changed";
+
+ updating_autoload = false;
+ selected_autoload = "";
+
+ HBoxContainer *hbc = memnew( HBoxContainer );
+ add_child(hbc);
+
+ VBoxContainer *vbc_path = memnew( VBoxContainer );
+ vbc_path->set_h_size_flags(SIZE_EXPAND_FILL);
+
+ autoload_add_path = memnew( EditorLineEditFileChooser );
+ autoload_add_path->set_h_size_flags(SIZE_EXPAND_FILL);
+
+ autoload_add_path->get_file_dialog()->set_mode(EditorFileDialog::MODE_OPEN_FILE);
+ autoload_add_path->get_file_dialog()->connect("file_selected", this, "_autoload_file_callback");
+
+ vbc_path->add_margin_child(TTR("Path:"), autoload_add_path);
+ hbc->add_child(vbc_path);
+
+ VBoxContainer *vbc_name = memnew( VBoxContainer );
+ vbc_name->set_h_size_flags(SIZE_EXPAND_FILL);
+
+ HBoxContainer *hbc_name = memnew( HBoxContainer );
+
+ autoload_add_name = memnew( LineEdit );
+ autoload_add_name->set_h_size_flags(SIZE_EXPAND_FILL);
+ hbc_name->add_child(autoload_add_name);
+
+ Button *add_autoload = memnew( Button );
+ add_autoload->set_text(TTR("Add"));
+ hbc_name->add_child(add_autoload);
+ add_autoload->connect("pressed", this, "_autoload_add");
+
+ vbc_name->add_margin_child(TTR("Node Name:"), hbc_name);
+ hbc->add_child(vbc_name);
+
+ tree = memnew( Tree );
+ tree->set_hide_root(true);
+ tree->set_select_mode(Tree::SELECT_MULTI);
+ tree->set_single_select_cell_editing_only_when_already_selected(true);
+
+ tree->set_drag_forwarding(this);
+
+ tree->set_columns(4);
+ tree->set_column_titles_visible(true);
+
+ tree->set_column_title(0,TTR("Name"));
+ tree->set_column_expand(0,true);
+ tree->set_column_min_width(0,100);
+
+ tree->set_column_title(1,TTR("Path"));
+ tree->set_column_expand(1,true);
+ tree->set_column_min_width(1,100);
+
+ tree->set_column_title(2,TTR("Singleton"));
+ tree->set_column_expand(2,false);
+ tree->set_column_min_width(2,80);
+
+ tree->set_column_expand(3,false);
+ tree->set_column_min_width(3,80);
+
+ tree->connect("cell_selected", this, "_autoload_selected");
+ tree->connect("item_edited", this, "_autoload_edited");
+ tree->connect("button_pressed", this, "_autoload_button_pressed");
+
+ add_margin_child(TTR("List:"), tree, true);
+}
+
diff --git a/tools/editor/import_settings.h b/tools/editor/editor_autoload_settings.h
index 5a383a1a1a..b61c44b9c2 100644
--- a/tools/editor/import_settings.h
+++ b/tools/editor/editor_autoload_settings.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* import_settings.h */
+/* editor_autoload_settings.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -26,57 +26,69 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef IMPORT_SETTINGS_H
-#define IMPORT_SETTINGS_H
-#include "object.h"
-#include "scene/gui/dialogs.h"
+#ifndef EDITOR_AUTOLOAD_SETTINGS_H
+#define EDITOR_AUTOLOAD_SETTINGS_H
+
#include "scene/gui/tree.h"
-#include "scene/gui/label.h"
-#include "scene/gui/option_button.h"
-#include "scene/gui/line_edit.h"
-#include "scene/gui/file_dialog.h"
-#include "scene/gui/progress_bar.h"
-#include "scene/gui/slider.h"
-#include "scene/gui/spin_box.h"
-#include "scene/resources/mesh.h"
-#include "editor_import_export.h"
-#include "editor_file_system.h"
-#include "editor_dir_dialog.h"
-class EditorNode;
-
-
-class ImportSettingsDialog : public ConfirmationDialog {
-
- OBJ_TYPE(ImportSettingsDialog,ConfirmationDialog);
-
- TreeItem *edited;
- EditorNode *editor;
+
+#include "editor_file_dialog.h"
+
+class EditorAutoloadSettings : public VBoxContainer {
+
+ OBJ_TYPE( EditorAutoloadSettings, VBoxContainer );
+
+ enum {
+ BUTTON_MOVE_UP,
+ BUTTON_MOVE_DOWN,
+ BUTTON_DELETE
+ };
+
+ String autoload_changed;
+
+ struct AutoLoadInfo {
+ String name;
+ int order;
+
+ bool operator==(const AutoLoadInfo& p_info) {
+ return order == p_info.order;
+ }
+ };
+
+ List<AutoLoadInfo> autoload_cache;
+
+ bool updating_autoload;
+ int number_of_autoloads;
+ String selected_autoload;
+
Tree *tree;
- bool updating;
+ EditorLineEditFileChooser *autoload_add_path;
+ LineEdit *autoload_add_name;
- void _button_pressed(Object *p_button, int p_col, int p_id);
- void _item_pressed(int p_idx);
- bool _generate_fs(TreeItem *p_parent,EditorFileSystemDirectory *p_dir);
+ bool _autoload_name_is_valid(const String& p_string, String *r_error = NULL);
- String texformat;
+ void _autoload_add();
+ void _autoload_selected();
+ void _autoload_edited();
+ void _autoload_button_pressed(Object *p_item, int p_column, int p_button);
+ void _autoload_file_callback(const String& p_path);
- void _item_edited();
- virtual void ok_pressed();
+ Variant get_drag_data_fw(const Point2& p_point, Control *p_from);
+ bool can_drop_data_fw(const Point2& p_point, const Variant& p_data, Control *p_from) const;
+ void drop_data_fw(const Point2& p_point, const Variant& p_data, Control *p_from);
protected:
-
void _notification(int p_what);
static void _bind_methods();
-public:
- void update_tree();
+public:
+ void update_autoload();
- void popup_import_settings();
- ImportSettingsDialog(EditorNode *p_editor);
+ EditorAutoloadSettings();
};
-#endif // IMPORT_SETTINGS_H
+#endif
+
diff --git a/tools/editor/editor_data.cpp b/tools/editor/editor_data.cpp
index 4c4fecdd83..8d3fd6c9c2 100644
--- a/tools/editor/editor_data.cpp
+++ b/tools/editor/editor_data.cpp
@@ -326,6 +326,13 @@ Dictionary EditorData::get_editor_states() const {
}
+Dictionary EditorData::get_scene_editor_states(int p_idx) const
+{
+ ERR_FAIL_INDEX_V(p_idx,edited_scene.size(),Dictionary());
+ EditedScene es = edited_scene[p_idx];
+ return es.editor_states;
+}
+
void EditorData::set_editor_states(const Dictionary& p_states) {
List<Variant> keys;
@@ -565,6 +572,8 @@ bool EditorData::check_and_update_scene(int p_idx) {
bool must_reload = _find_updated_instances(edited_scene[p_idx].root,edited_scene[p_idx].root,checked_scenes);
+ print_line("MUST RELOAD? "+itos(must_reload));
+
if (must_reload) {
Ref<PackedScene> pscene;
pscene.instance();
@@ -611,11 +620,14 @@ void EditorData::set_edited_scene(int p_idx){
current_edited_scene=p_idx;
//swap
}
-Node* EditorData::get_edited_scene_root(){
-
- ERR_FAIL_INDEX_V(current_edited_scene,edited_scene.size(),NULL);
-
- return edited_scene[current_edited_scene].root;
+Node* EditorData::get_edited_scene_root(int p_idx){
+ if (p_idx < 0) {
+ ERR_FAIL_INDEX_V(current_edited_scene,edited_scene.size(),NULL);
+ return edited_scene[current_edited_scene].root;
+ } else {
+ ERR_FAIL_INDEX_V(p_idx,edited_scene.size(),NULL);
+ return edited_scene[p_idx].root;
+ }
}
void EditorData::set_edited_scene_root(Node* p_root) {
@@ -628,9 +640,14 @@ int EditorData::get_edited_scene_count() const {
return edited_scene.size();
}
-void EditorData::set_edited_scene_version(uint64_t version) {
+void EditorData::set_edited_scene_version(uint64_t version, int scene_idx) {
ERR_FAIL_INDEX(current_edited_scene,edited_scene.size());
- edited_scene[current_edited_scene].version=version;
+ if (scene_idx < 0) {
+ edited_scene[current_edited_scene].version=version;
+ } else {
+ ERR_FAIL_INDEX(scene_idx,edited_scene.size());
+ edited_scene[scene_idx].version=version;
+ }
}
@@ -756,12 +773,19 @@ void EditorData::set_edited_scene_import_metadata(Ref<ResourceImportMetadata> p_
}
-Ref<ResourceImportMetadata> EditorData::get_edited_scene_import_metadata() const{
+Ref<ResourceImportMetadata> EditorData::get_edited_scene_import_metadata(int idx) const{
ERR_FAIL_INDEX_V(current_edited_scene,edited_scene.size(),Ref<ResourceImportMetadata>());
- return edited_scene[current_edited_scene].medatata;
+ if(idx<0) {
+ return edited_scene[current_edited_scene].medatata;
+ } else {
+ ERR_FAIL_INDEX_V(idx,edited_scene.size(),Ref<ResourceImportMetadata>());
+ return edited_scene[idx].medatata;
+ }
}
+
+
void EditorData::clear_edited_scenes() {
for(int i=0;i<edited_scene.size();i++) {
diff --git a/tools/editor/editor_data.h b/tools/editor/editor_data.h
index 319155655d..a0b716f560 100644
--- a/tools/editor/editor_data.h
+++ b/tools/editor/editor_data.h
@@ -156,6 +156,7 @@ public:
void paste_object_params(Object *p_object);
Dictionary get_editor_states() const;
+ Dictionary get_scene_editor_states(int p_idx) const;
void set_editor_states(const Dictionary& p_states);
void get_editor_breakpoints(List<String> *p_breakpoints);
void clear_editor_states();
@@ -184,15 +185,15 @@ public:
void set_edited_scene(int p_idx);
void set_edited_scene_root(Node* p_root);
void set_edited_scene_import_metadata(Ref<ResourceImportMetadata> p_mdata);
- Ref<ResourceImportMetadata> get_edited_scene_import_metadata() const;
+ Ref<ResourceImportMetadata> get_edited_scene_import_metadata(int p_idx = -1) const;
int get_edited_scene() const;
- Node* get_edited_scene_root();
+ Node* get_edited_scene_root(int p_idx = -1);
int get_edited_scene_count() const;
String get_scene_title(int p_idx) const;
String get_scene_path(int p_idx) const;
String get_scene_type(int p_idx) const;
Ref<Script> get_scene_root_script(int p_idx) const;
- void set_edited_scene_version(uint64_t version);
+ void set_edited_scene_version(uint64_t version, int p_scene_idx = -1);
uint64_t get_edited_scene_version() const;
uint64_t get_scene_version(int p_idx) const;
void clear_edited_scenes();
diff --git a/tools/editor/editor_dir_dialog.cpp b/tools/editor/editor_dir_dialog.cpp
index a6e231cf18..f6ce7bf3f8 100644
--- a/tools/editor/editor_dir_dialog.cpp
+++ b/tools/editor/editor_dir_dialog.cpp
@@ -99,8 +99,14 @@ void EditorDirDialog::_notification(int p_what) {
if (p_what==NOTIFICATION_ENTER_TREE) {
reload();
- tree->connect("item_collapsed",this,"_item_collapsed",varray(),CONNECT_DEFERRED);
- EditorFileSystem::get_singleton()->connect("filesystem_changed",this,"reload");
+
+ if (!tree->is_connected("item_collapsed",this,"_item_collapsed")) {
+ tree->connect("item_collapsed",this,"_item_collapsed",varray(),CONNECT_DEFERRED);
+ }
+
+ if (!EditorFileSystem::get_singleton()->is_connected("filesystem_changed",this,"reload")) {
+ EditorFileSystem::get_singleton()->connect("filesystem_changed",this,"reload");
+ }
}
@@ -185,10 +191,14 @@ void EditorDirDialog::ok_pressed() {
void EditorDirDialog::_make_dir() {
TreeItem *ti=tree->get_selected();
- if (!ti)
+ if (!ti) {
+ mkdirerr->set_text("Please select a base directory first");
+ mkdirerr->popup_centered_minsize();
return;
+ }
makedialog->popup_centered_minsize(Size2(250,80));
+ makedirname->grab_focus();
}
void EditorDirDialog::_make_dir_confirm() {
@@ -198,9 +208,11 @@ void EditorDirDialog::_make_dir_confirm() {
return;
String dir = ti->get_metadata(0);
+
DirAccess *d = DirAccess::open(dir);
ERR_FAIL_COND(!d);
Error err = d->make_dir(makedirname->get_text());
+
if (err!=OK) {
mkdirerr->popup_centered_minsize(Size2(250,80));
} else {
diff --git a/tools/editor/editor_file_system.cpp b/tools/editor/editor_file_system.cpp
index 1f414f80a0..cb7cefea26 100644
--- a/tools/editor/editor_file_system.cpp
+++ b/tools/editor/editor_file_system.cpp
@@ -34,6 +34,7 @@
#include "editor_node.h"
#include "io/resource_saver.h"
#include "editor_settings.h"
+#include "editor_resource_preview.h"
EditorFileSystem *EditorFileSystem::singleton=NULL;
@@ -848,6 +849,7 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir,const S
continue;
}
+
if (_check_meta_sources(p_dir->files[i]->meta)) {
ItemAction ia;
ia.action=ItemAction::ACTION_FILE_SOURCES_CHANGED;
@@ -858,6 +860,8 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir,const S
} else {
p_dir->files[i]->meta.sources_changed=false;
}
+
+ EditorResourcePreview::get_singleton()->check_for_invalidation(p_dir->get_file_path(i));
}
for(int i=0;i<p_dir->subdirs.size();i++) {
@@ -1328,6 +1332,7 @@ void EditorFileSystem::update_file(const String& p_file) {
fs->files[cpos]->modified_time=FileAccess::get_modified_time(p_file);
fs->files[cpos]->meta=_get_meta(p_file);
+ EditorResourcePreview::get_singleton()->call_deferred("check_for_invalidation",p_file);
call_deferred("emit_signal","filesystem_changed"); //update later
}
@@ -1341,6 +1346,8 @@ void EditorFileSystem::_bind_methods() {
}
+
+
EditorFileSystem::EditorFileSystem() {
diff --git a/tools/editor/editor_file_system.h b/tools/editor/editor_file_system.h
index b96e947569..fb768fb358 100644
--- a/tools/editor/editor_file_system.h
+++ b/tools/editor/editor_file_system.h
@@ -236,6 +236,7 @@ public:
EditorFileSystemDirectory *get_path(const String& p_path);
String get_file_type(const String& p_file) const;
EditorFileSystemDirectory* find_file(const String& p_file,int* r_index) const;
+
EditorFileSystem();
~EditorFileSystem();
};
diff --git a/tools/editor/editor_help.cpp b/tools/editor/editor_help.cpp
index 0b60db5ee3..1fc157098c 100644
--- a/tools/editor/editor_help.cpp
+++ b/tools/editor/editor_help.cpp
@@ -332,7 +332,7 @@ EditorHelpSearch::EditorHelpSearch() {
register_text_enter(search_box);
set_hide_on_ok(false);
search_options->connect("item_activated",this,"_confirmed");
- set_title(TTR("Search Classes"));
+ set_title(TTR("Search Help"));
// search_options->set_hide_root(true);
@@ -526,6 +526,7 @@ EditorHelpIndex::EditorHelpIndex() {
class_list->connect("item_activated",this,"_tree_item_selected");
get_ok()->set_text(TTR("Open"));
+ set_title(TTR("Search Classes"));
}
diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp
index 84321af337..92b22eb5d1 100644
--- a/tools/editor/editor_node.cpp
+++ b/tools/editor/editor_node.cpp
@@ -508,8 +508,6 @@ void EditorNode::_rebuild_import_menu()
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);
}
- //p->add_separator();
- //p->add_item(TTR("Re-Import.."), SETTINGS_IMPORT);
}
void EditorNode::_node_renamed() {
@@ -597,7 +595,6 @@ void EditorNode::save_resource(const Ref<Resource>& p_resource) {
void EditorNode::save_resource_as(const Ref<Resource>& p_resource,const String& p_at_path) {
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;
@@ -728,9 +725,9 @@ void EditorNode::_get_scene_metadata(const String& p_file) {
}
-void EditorNode::_set_scene_metadata(const String& p_file) {
+void EditorNode::_set_scene_metadata(const String& p_file, int p_idx) {
- Node *scene = editor_data.get_edited_scene_root();
+ Node *scene = editor_data.get_edited_scene_root(p_idx);
if (!scene)
return;
@@ -743,7 +740,7 @@ void EditorNode::_set_scene_metadata(const String& p_file) {
Ref<ConfigFile> cf;
cf.instance();
- Dictionary md = editor_data.get_editor_states();
+ Dictionary md = editor_data.get_edited_scene()==p_idx?editor_data.get_editor_states():editor_data.get_scene_editor_states(p_idx);
List<Variant> keys;
md.get_key_list(&keys);
@@ -957,9 +954,9 @@ void EditorNode::_save_scene_with_preview(String p_file) {
}
-void EditorNode::_save_scene(String p_file) {
+void EditorNode::_save_scene(String p_file, int idx) {
- Node *scene = editor_data.get_edited_scene_root();
+ Node *scene = editor_data.get_edited_scene_root(idx);
if (!scene) {
@@ -973,7 +970,7 @@ void EditorNode::_save_scene(String p_file) {
editor_data.apply_changes_in_editors();
- _set_scene_metadata(p_file);
+ _set_scene_metadata(p_file,idx);
Ref<PackedScene> sdata;
@@ -1004,7 +1001,7 @@ void EditorNode::_save_scene(String p_file) {
return;
}
- sdata->set_import_metadata(editor_data.get_edited_scene_import_metadata());
+ sdata->set_import_metadata(editor_data.get_edited_scene_import_metadata(idx));
int flg=0;
if (EditorSettings::get_singleton()->get("on_save/compress_binary_resources"))
flg|=ResourceSaver::FLAG_COMPRESS;
@@ -1020,7 +1017,10 @@ void EditorNode::_save_scene(String p_file) {
if (err==OK) {
scene->set_filename( Globals::get_singleton()->localize_path(p_file) );
//EditorFileSystem::get_singleton()->update_file(p_file,sdata->get_type());
- set_current_version(editor_data.get_undo_redo().get_version());
+ if (idx < 0 || idx == editor_data.get_edited_scene())
+ set_current_version(editor_data.get_undo_redo().get_version());
+ else
+ editor_data.set_edited_scene_version(0,idx);
_update_title();
_update_scene_tabs();
} else {
@@ -1551,9 +1551,10 @@ void EditorNode::_property_editor_back() {
void EditorNode::_imported(Node *p_node) {
- Node *scene = editor_data.get_edited_scene_root();
-// add_edited_scene(p_node);
/*
+ Node *scene = editor_data.get_edited_scene_root();
+ add_edited_scene(p_node);
+
if (scene) {
String path = scene->get_filename();
p_node->set_filename(path);
@@ -1613,6 +1614,7 @@ void EditorNode::_edit_current() {
object_menu->set_disabled(true);
bool is_resource = current_obj->is_type("Resource");
+ bool is_node = current_obj->is_type("Node");
resource_save_button->set_disabled(!is_resource);
if (is_resource) {
@@ -1629,7 +1631,7 @@ void EditorNode::_edit_current() {
//top_pallete->set_current_tab(1);
- } else if (current_obj->is_type("Node")) {
+ } else if (is_node) {
Node * current_node = current_obj->cast_to<Node>();
ERR_FAIL_COND(!current_node);
@@ -1725,10 +1727,14 @@ void EditorNode::_edit_current() {
p->add_shortcut(ED_SHORTCUT("property_editor/copy_resource",TTR("Copy Resource")),RESOURCE_COPY);
p->add_shortcut(ED_SHORTCUT("property_editor/unref_resource",TTR("Make Built-In")),RESOURCE_UNREF);
}
- p->add_separator();
- p->add_shortcut(ED_SHORTCUT("property_editor/make_subresources_unique",TTR("Make Sub-Resources Unique")),OBJECT_UNIQUE_RESOURCES);
- p->add_separator();
- p->add_icon_shortcut(gui_base->get_icon("Help","EditorIcons"),ED_SHORTCUT("property_editor/open_help",TTR("Open in Help")),OBJECT_REQUEST_HELP);
+
+ if (is_resource || is_node) {
+ p->add_separator();
+ p->add_shortcut(ED_SHORTCUT("property_editor/make_subresources_unique",TTR("Make Sub-Resources Unique")),OBJECT_UNIQUE_RESOURCES);
+ p->add_separator();
+ p->add_icon_shortcut(gui_base->get_icon("Help","EditorIcons"),ED_SHORTCUT("property_editor/open_help",TTR("Open in Help")),OBJECT_REQUEST_HELP);
+ }
+
List<MethodInfo> methods;
current_obj->get_method_list(&methods);
@@ -1807,7 +1813,6 @@ void EditorNode::_run(bool p_current,const String& p_custom) {
String args;
-
if (p_current || (editor_data.get_edited_scene_root() && p_custom==editor_data.get_edited_scene_root()->get_filename())) {
Node *scene = editor_data.get_edited_scene_root();
@@ -1830,12 +1835,7 @@ void EditorNode::_run(bool p_current,const String& p_custom) {
}
- bool autosave = EDITOR_DEF("run/auto_save_before_running",true);
- if (autosave) {
-
- _menu_option(FILE_SAVE_SCENE);
- }
if (run_settings_dialog->get_run_mode()==RunSettingsDialog::RUN_LOCAL_SCENE) {
@@ -1908,7 +1908,7 @@ void EditorNode::_run(bool p_current,const String& p_custom) {
_save_scene_with_preview(scene->get_filename());
}
}
-
+ _menu_option(FILE_SAVE_ALL_SCENES);
editor_data.save_editor_external_data();
}
@@ -2129,7 +2129,6 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
}
file->set_mode(EditorFileDialog::MODE_SAVE_FILE);
- bool relpaths = (scene->has_meta("__editor_relpaths__") && scene->get_meta("__editor_relpaths__").operator bool());
List<String> extensions;
@@ -2165,6 +2164,19 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
} break;
+ case FILE_SAVE_ALL_SCENES: {
+ for (int i = 0; i < editor_data.get_edited_scene_count(); i++) {
+ Node *scene = editor_data.get_edited_scene_root(i);
+ if (scene && scene->get_filename()!="") {
+ // save in background if in the script editor
+ if (i != editor_data.get_edited_scene() || _get_current_main_editor() == EDITOR_SCRIPT) {
+ _save_scene(scene->get_filename(), i);
+ } else {
+ _save_scene_with_preview(scene->get_filename());
+ }
+ }// else: ignore new scenes
+ }
+ } break;
case FILE_SAVE_BEFORE_RUN: {
if (!p_confirmed) {
accept->get_ok()->set_text(TTR("Yes"));
@@ -2210,8 +2222,6 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
}
- bool relpaths = (scene->has_meta("__editor_relpaths__") && scene->get_meta("__editor_relpaths__").operator bool());
-
file->set_mode(EditorFileDialog::MODE_SAVE_FILE);
file->set_current_path(cpath);
@@ -2220,8 +2230,8 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
} break;
case FILE_SAVE_OPTIMIZED: {
- Node *scene = editor_data.get_edited_scene_root();
#if 0
+ Node *scene = editor_data.get_edited_scene_root();
if (!scene) {
current_option=-1;
@@ -2494,7 +2504,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
#endif
case RESOURCE_NEW: {
- create_dialog->popup_centered_ratio();
+ create_dialog->popup(true);
} break;
case RESOURCE_LOAD: {
@@ -2665,11 +2675,16 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
} break;
case RUN_PLAY_NATIVE: {
- _menu_option_confirm(RUN_STOP,true);
- emit_signal("play_pressed");
- editor_run.run_native_notify();
-
-
+
+ bool autosave = EDITOR_DEF("run/auto_save_before_running",true);
+ if (autosave) {
+ _menu_option_confirm(FILE_SAVE_ALL_SCENES, false);
+ }
+ if (run_native->is_deploy_debug_remote_enabled()){
+ _menu_option_confirm(RUN_STOP,true);
+ emit_signal("play_pressed");
+ editor_run.run_native_notify();
+ }
} break;
case RUN_SCENE_SETTINGS: {
@@ -2782,10 +2797,6 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
settings_config_dialog->popup_edit_settings();
} break;
- case SETTINGS_IMPORT: {
-
- import_settings->popup_import_settings();
- } break;
case SETTINGS_OPTIMIZED_PRESETS: {
//optimized_presets->popup_centered_ratio();
@@ -2846,6 +2857,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
if (mt!=E->get()->get_last_modified_time()) {
E->get()->reload_from_file();
}
+
}
@@ -3132,6 +3144,11 @@ void EditorNode::_remove_edited_scene() {
new_index=1;
}
+
+
+ if (editor_data.get_scene_path(old_index)!=String()) {
+ ScriptEditor::get_singleton()->close_builtin_scripts_from_scene(editor_data.get_scene_path(old_index));
+ }
_scene_tab_changed(new_index);
editor_data.remove_scene(old_index);
editor_data.get_undo_redo().clear_history();
@@ -3429,7 +3446,10 @@ Dictionary EditorNode::_get_main_scene_state() {
return state;
}
-void EditorNode::_set_main_scene_state(Dictionary p_state) {
+void EditorNode::_set_main_scene_state(Dictionary p_state,Node* p_for_scene) {
+
+ if (get_edited_scene()!=p_for_scene && p_for_scene!=NULL)
+ return; //not for this scene
//print_line("set current 7 ");
changing_scene=false;
@@ -3573,7 +3593,7 @@ void EditorNode::set_current_scene(int p_idx) {
}*/
//_set_main_scene_state(state);
- call_deferred("_set_main_scene_state",state); //do after everything else is done setting up
+ call_deferred("_set_main_scene_state",state,get_edited_scene()); //do after everything else is done setting up
//print_line("set current 6 ");
@@ -5115,6 +5135,78 @@ void EditorNode::_file_access_close_error_notify(const String& p_str) {
add_io_error("Unable to write to file '"+p_str+"', file in use, locked or lacking permissions.");
}
+
+void EditorNode::reload_scene(const String& p_path) {
+
+
+ //first of all, reload textures as they might have changed on disk
+
+ List<Ref<Resource> > cached;
+ ResourceCache::get_cached_resources(&cached);
+ List<Ref<Resource> > to_clear; //clear internal resources from previous scene from being used
+ for(List<Ref<Resource> >::Element *E=cached.front();E;E=E->next()) {
+
+ if (E->get()->get_path().begins_with(p_path+"::")) //subresources of existing scene
+ to_clear.push_back(E->get());
+
+ if (!E->get()->cast_to<Texture>())
+ continue;
+ if (!E->get()->get_path().is_resource_file() && !E->get()->get_path().is_abs_path())
+ continue;
+ if (!FileAccess::exists(E->get()->get_path()))
+ continue;
+ uint64_t mt = FileAccess::get_modified_time(E->get()->get_path());
+ if (mt!=E->get()->get_last_modified_time()) {
+ E->get()->reload_from_file();
+ }
+ }
+
+ //so reload reloads everything, clear subresources of previous scene
+ while(to_clear.front()) {
+ to_clear.front()->get()->set_path("");
+ to_clear.pop_front();
+ }
+
+ int scene_idx=-1;
+ for(int i=0;i<editor_data.get_edited_scene_count();i++) {
+
+ if (editor_data.get_scene_path(i)==p_path) {
+ scene_idx=i;
+ break;
+ }
+ }
+
+ int current_tab = editor_data.get_edited_scene();
+
+
+ if (scene_idx==-1) {
+ if (get_edited_scene()) {
+ //scene is not open, so at it might be instanced, just refresh, set tab to itself and it will reload
+ set_current_scene(current_tab);
+ editor_data.get_undo_redo().clear_history();
+ }
+ return;
+ }
+
+
+ if (current_tab==scene_idx) {
+ editor_data.apply_changes_in_editors();
+ _set_scene_metadata(p_path);
+
+ }
+ //remove scene
+ _remove_scene(scene_idx);
+ //reload scene
+ load_scene(p_path);
+ //adjust index so tab is back a the previous position
+ editor_data.move_edited_scene_to_index(scene_idx);
+ get_undo_redo()->clear_history();
+ //recover the tab
+ scene_tabs->set_current_tab(current_tab);
+ _scene_tab_changed(current_tab);
+}
+
+
void EditorNode::_bind_methods() {
@@ -5563,8 +5655,6 @@ EditorNode::EditorNode() {
ED_SHORTCUT("editor/prev_tab", TTR("Previous tab"), KEY_MASK_CMD+KEY_MASK_SHIFT+KEY_TAB);
- Separator *vs=NULL;
-
file_menu->set_tooltip(TTR("Operations with scene files."));
p=file_menu->get_popup();
p->add_shortcut(ED_SHORTCUT("editor/new_scene",TTR("New Scene")),FILE_NEW_SCENE);
@@ -5573,6 +5663,7 @@ EditorNode::EditorNode() {
p->add_separator();
p->add_shortcut(ED_SHORTCUT("editor/save_scene",TTR("Save Scene"),KEY_MASK_CMD+KEY_S),FILE_SAVE_SCENE);
p->add_shortcut(ED_SHORTCUT("editor/save_scene_as",TTR("Save Scene As.."),KEY_MASK_SHIFT+KEY_MASK_CMD+KEY_S),FILE_SAVE_AS_SCENE);
+ p->add_shortcut(ED_SHORTCUT("editor/save_all_scenes",TTR("Save all Scenes"),KEY_MASK_ALT+KEY_MASK_SHIFT+KEY_MASK_CMD+KEY_S),FILE_SAVE_ALL_SCENES);
p->add_separator();
p->add_shortcut(ED_SHORTCUT("editor/close_scene",TTR("Close Scene"),KEY_MASK_SHIFT+KEY_MASK_CTRL+KEY_W),FILE_CLOSE);
p->add_separator();
@@ -5765,7 +5856,8 @@ EditorNode::EditorNode() {
play_custom_scene_button->set_focus_mode(Control::FOCUS_NONE);
play_custom_scene_button->set_icon(gui_base->get_icon("PlayCustom","EditorIcons"));
play_custom_scene_button->connect("pressed", this,"_menu_option",make_binds(RUN_PLAY_CUSTOM_SCENE));
- play_custom_scene_button->set_tooltip(TTR("Play custom scene")+" ("+keycode_get_string(KEY_MASK_CMD|KEY_MASK_SHIFT|KEY_F5)+").");
+ play_custom_scene_button->set_tooltip(TTR("Play custom scene"));
+ play_custom_scene_button->set_shortcut(ED_SHORTCUT("editor/play_custom_scene",TTR("Play Custom Scene"),KEY_MASK_CMD|KEY_MASK_SHIFT|KEY_F5));
debug_button = memnew( MenuButton );
debug_button->set_flat(true);
@@ -6213,8 +6305,6 @@ EditorNode::EditorNode() {
open_recent_confirmation->connect("confirmed",this,"_open_recent_scene_confirm");
- import_settings= memnew(ImportSettingsDialog(this));
- gui_base->add_child(import_settings);
run_settings_dialog = memnew( RunSettingsDialog );
gui_base->add_child( run_settings_dialog );
diff --git a/tools/editor/editor_node.h b/tools/editor/editor_node.h
index a0a03341fc..d18de1c531 100644
--- a/tools/editor/editor_node.h
+++ b/tools/editor/editor_node.h
@@ -74,7 +74,6 @@
#include "tools/editor/editor_sub_scene.h"
#include "editor_import_export.h"
#include "editor_reimport_dialog.h"
-#include "import_settings.h"
#include "tools/editor/editor_plugin.h"
#include "tools/editor/editor_name_dialog.h"
@@ -125,6 +124,7 @@ private:
FILE_OPEN_SCENE,
FILE_SAVE_SCENE,
FILE_SAVE_AS_SCENE,
+ FILE_SAVE_ALL_SCENES,
FILE_SAVE_BEFORE_RUN,
FILE_SAVE_AND_RUN,
FILE_IMPORT_SUBSCENE,
@@ -177,7 +177,6 @@ private:
RUN_RELOAD_SCRIPTS,
SETTINGS_UPDATE_ALWAYS,
SETTINGS_UPDATE_CHANGES,
- SETTINGS_IMPORT,
SETTINGS_EXPORT_PREFERENCES,
SETTINGS_PREFERENCES,
SETTINGS_OPTIMIZED_PRESETS,
@@ -338,7 +337,6 @@ private:
Vector<EditorPlugin*> editor_table;
EditorReImportDialog *reimport_dialog;
- ImportSettingsDialog *import_settings;
ProgressDialog *progress_dialog;
BackgroundProgress *progress_hb;
@@ -441,7 +439,7 @@ private:
void _node_renamed();
void _editor_select(int p_which);
- void _set_scene_metadata(const String &p_file);
+ void _set_scene_metadata(const String &p_file, int p_idx=-1);
void _get_scene_metadata(const String& p_file);
void _update_title();
void _update_scene_tabs();
@@ -451,7 +449,7 @@ private:
void _rebuild_import_menu();
- void _save_scene(String p_file);
+ void _save_scene(String p_file, int idx = -1);
void _instance_request(const String& p_path);
@@ -555,7 +553,7 @@ private:
void _scene_tab_script_edited(int p_tab);
Dictionary _get_main_scene_state();
- void _set_main_scene_state(Dictionary p_state);
+ void _set_main_scene_state(Dictionary p_state,Node* p_for_scene);
int _get_current_main_editor();
@@ -716,6 +714,8 @@ public:
void update_keying();
+ void reload_scene(const String& p_path);
+
bool is_exiting() const { return exiting; }
ToolButton *get_pause_button() { return pause_button; }
@@ -760,7 +760,7 @@ public:
plugins_list = p_plugins_list;
}
- Vector<EditorPlugin*> get_plugins_list() {
+ Vector<EditorPlugin*>& get_plugins_list() {
return plugins_list;
}
diff --git a/tools/editor/editor_path.cpp b/tools/editor/editor_path.cpp
index 4cf98e832c..6b804b6a24 100644
--- a/tools/editor/editor_path.cpp
+++ b/tools/editor/editor_path.cpp
@@ -38,7 +38,6 @@ void EditorPath::_notification(int p_what) {
RID ci=get_canvas_item();
Ref<Font> label_font = get_font("font","Label");
- Color label_color = get_color("font_color","Label");
Size2i size = get_size();
Ref<Texture> sn = get_icon("SmallNext","EditorIcons");
diff --git a/tools/editor/editor_plugin.cpp b/tools/editor/editor_plugin.cpp
index 138e532ce8..01e6b613c0 100644
--- a/tools/editor/editor_plugin.cpp
+++ b/tools/editor/editor_plugin.cpp
@@ -27,6 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "editor_plugin.h"
+#include "scene/3d/camera.h"
#include "plugins/canvas_item_editor_plugin.h"
#include "plugins/spatial_editor_plugin.h"
#include "tools/editor/editor_node.h"
diff --git a/tools/editor/editor_resource_preview.cpp b/tools/editor/editor_resource_preview.cpp
index 8975c0ec35..a02fe2a531 100644
--- a/tools/editor/editor_resource_preview.cpp
+++ b/tools/editor/editor_resource_preview.cpp
@@ -33,6 +33,7 @@
#include "io/resource_saver.h"
#include "globals.h"
#include "editor_scale.h"
+#include "message_queue.h"
Ref<Texture> EditorResourcePreviewGenerator::generate_from_path(const String& p_path) {
@@ -66,25 +67,27 @@ void EditorResourcePreview::_preview_ready(const String& p_str,const Ref<Texture
String path = p_str;
uint32_t hash=0;
+ uint64_t modified_time=0;
if (p_str.begins_with("ID:")) {
hash=p_str.get_slicec(':',2).to_int();
path="ID:"+p_str.get_slicec(':',1);
+ } else {
+ modified_time = FileAccess::get_modified_time(path);
}
Item item;
item.order=order++;
item.preview=p_texture;
item.last_hash=hash;
+ item.modified_time=modified_time;
cache[path]=item;
- Object *recv = ObjectDB::get_instance(id);
- if (recv) {
- recv->call_deferred(p_func,path,p_texture,p_ud);
- }
-
preview_mutex->unlock();
+
+ MessageQueue::get_singleton()->push_call(id,p_func,path,p_texture,p_ud);
+
}
Ref<Texture> EditorResourcePreview::_generate_preview(const QueueItem& p_item,const String& cache_base) {
@@ -103,6 +106,7 @@ Ref<Texture> EditorResourcePreview::_generate_preview(const QueueItem& p_item,co
Ref<Texture> generated;
for(int i=0;i<preview_generators.size();i++) {
+
if (!preview_generators[i]->handles(type))
continue;
if (p_item.resource.is_valid()) {
@@ -153,99 +157,107 @@ void EditorResourcePreview::_thread() {
QueueItem item = queue.front()->get();
queue.pop_front();
- preview_mutex->unlock();
-
- Ref<Texture> texture;
-
- //print_line("pop from queue "+item.path);
-
- int thumbnail_size = EditorSettings::get_singleton()->get("file_dialog/thumbnail_size");
- thumbnail_size*=EDSCALE;
if (cache.has(item.path)) {
//already has it because someone loaded it, just let it know it's ready
if (item.resource.is_valid()) {
item.path+=":"+itos(cache[item.path].last_hash); //keep last hash (see description of what this is in condition below)
}
- call_deferred("_preview_ready",item.path,cache[item.path].preview,item.id,item.function,item.userdata);
-
- } else if (item.resource.is_valid()){
- texture=_generate_preview(item,String());
- //adding hash to the end of path (should be ID:<objid>:<hash>) because of 5 argument limit to call_deferred
- call_deferred("_preview_ready",item.path+":"+itos(item.resource->hash_edited_version()),texture,item.id,item.function,item.userdata);
+ _preview_ready(item.path,cache[item.path].preview,item.id,item.function,item.userdata);
+ preview_mutex->unlock();
} else {
+ preview_mutex->unlock();
- String temp_path=EditorSettings::get_singleton()->get_settings_path().plus_file("tmp");
- String cache_base = Globals::get_singleton()->globalize_path(item.path).md5_text();
- cache_base = temp_path.plus_file("resthumb-"+cache_base);
+ Ref<Texture> texture;
- //does not have it, try to load a cached thumbnail
+ //print_line("pop from queue "+item.path);
- String file = cache_base+".txt";
- //print_line("cachetxt at "+file);
- FileAccess *f=FileAccess::open(file,FileAccess::READ);
- if (!f) {
+ int thumbnail_size = EditorSettings::get_singleton()->get("file_dialog/thumbnail_size");
+ thumbnail_size*=EDSCALE;
- //print_line("generate because not cached");
- //generate
- texture=_generate_preview(item,cache_base);
+ if (item.resource.is_valid()){
+
+ texture=_generate_preview(item,String());
+ //adding hash to the end of path (should be ID:<objid>:<hash>) because of 5 argument limit to call_deferred
+ _preview_ready(item.path+":"+itos(item.resource->hash_edited_version()),texture,item.id,item.function,item.userdata);
+
} else {
- uint64_t modtime = FileAccess::get_modified_time(item.path);
- int tsize = f->get_line().to_int64();
- uint64_t last_modtime = f->get_line().to_int64();
- bool cache_valid = true;
+ String temp_path=EditorSettings::get_singleton()->get_settings_path().plus_file("tmp");
+ String cache_base = Globals::get_singleton()->globalize_path(item.path).md5_text();
+ cache_base = temp_path.plus_file("resthumb-"+cache_base);
- if (tsize!=thumbnail_size) {
- cache_valid=false;
- memdelete(f);
- } else if (last_modtime!=modtime) {
+ //does not have it, try to load a cached thumbnail
- String last_md5 = f->get_line();
- String md5 = FileAccess::get_md5(item.path);
- memdelete(f);
+ String file = cache_base+".txt";
+ //print_line("cachetxt at "+file);
+ FileAccess *f=FileAccess::open(file,FileAccess::READ);
+ if (!f) {
- if (last_md5!=md5) {
+ //print_line("generate because not cached");
+ //generate
+ texture=_generate_preview(item,cache_base);
+ } else {
+
+ uint64_t modtime = FileAccess::get_modified_time(item.path);
+ int tsize = f->get_line().to_int64();
+ uint64_t last_modtime = f->get_line().to_int64();
+
+ bool cache_valid = true;
+
+ if (tsize!=thumbnail_size) {
cache_valid=false;
- } else {
- //update modified time
+ memdelete(f);
+ } else if (last_modtime!=modtime) {
+
+ String last_md5 = f->get_line();
+ String md5 = FileAccess::get_md5(item.path);
+ memdelete(f);
+
+ if (last_md5!=md5) {
- f=FileAccess::open(file,FileAccess::WRITE);
- f->store_line(itos(modtime));
- f->store_line(md5);
+ cache_valid=false;
+ } else {
+ //update modified time
+
+ f=FileAccess::open(file,FileAccess::WRITE);
+ f->store_line(itos(modtime));
+ f->store_line(md5);
+ memdelete(f);
+ }
+ } else {
memdelete(f);
}
- } else {
- memdelete(f);
- }
- if (cache_valid) {
+ if (cache_valid) {
- texture = ResourceLoader::load(cache_base+".png","ImageTexture",true);
- if (!texture.is_valid()) {
- //well fuck
- cache_valid=false;
+ texture = ResourceLoader::load(cache_base+".png","ImageTexture",true);
+ if (!texture.is_valid()) {
+ //well fuck
+ cache_valid=false;
+ }
}
- }
- if (!cache_valid) {
+ if (!cache_valid) {
- texture=_generate_preview(item,cache_base);
- }
+ texture=_generate_preview(item,cache_base);
+ }
- }
+ }
- //print_line("notify of preview ready");
- call_deferred("_preview_ready",item.path,texture,item.id,item.function,item.userdata);
+ //print_line("notify of preview ready");
+ _preview_ready(item.path,texture,item.id,item.function,item.userdata);
+ }
}
+
} else {
preview_mutex->unlock();
}
@@ -263,6 +275,8 @@ void EditorResourcePreview::queue_edited_resource_preview(const Ref<Resource>& p
preview_mutex->lock();
String path_id = "ID:"+itos(p_res->get_instance_ID());
+
+
if (cache.has(path_id) && cache[path_id].last_hash==p_res->hash_edited_version()) {
cache[path_id].order=order++;
@@ -272,6 +286,8 @@ void EditorResourcePreview::queue_edited_resource_preview(const Ref<Resource>& p
}
+ cache.erase(path_id); //erase if exists, since it will be regen
+
//print_line("send to thread "+p_path);
QueueItem item;
item.function=p_receiver_func;
@@ -322,6 +338,34 @@ EditorResourcePreview* EditorResourcePreview::get_singleton() {
void EditorResourcePreview::_bind_methods() {
ObjectTypeDB::bind_method("_preview_ready",&EditorResourcePreview::_preview_ready);
+ ObjectTypeDB::bind_method(_MD("check_for_invalidation","path"),&EditorResourcePreview::check_for_invalidation);
+
+
+ ADD_SIGNAL(MethodInfo("preview_invalidated",PropertyInfo(Variant::STRING,"path")));
+}
+
+void EditorResourcePreview::check_for_invalidation(const String& p_path) {
+
+ preview_mutex->lock();
+
+ bool call_invalidated=false;
+ if (cache.has(p_path)) {
+
+ uint64_t modified_time = FileAccess::get_modified_time(p_path);
+ if (modified_time!=cache[p_path].modified_time) {
+ cache.erase(p_path);
+ call_invalidated=true;
+ }
+ }
+
+ preview_mutex->unlock();
+
+ if (call_invalidated) {//do outside mutex
+ call_deferred("emit_signal","preview_invalidated",p_path);
+ }
+
+
+
}
EditorResourcePreview::EditorResourcePreview() {
diff --git a/tools/editor/editor_resource_preview.h b/tools/editor/editor_resource_preview.h
index 63dc5c3dd3..51a00965eb 100644
--- a/tools/editor/editor_resource_preview.h
+++ b/tools/editor/editor_resource_preview.h
@@ -93,6 +93,7 @@ class EditorResourcePreview : public Node {
Ref<Texture> preview;
int order;
uint32_t last_hash;
+ uint64_t modified_time;
};
int order;
@@ -106,6 +107,8 @@ class EditorResourcePreview : public Node {
void _thread();
Vector<Ref<EditorResourcePreviewGenerator> > preview_generators;
+
+
protected:
static void _bind_methods();
@@ -118,6 +121,7 @@ public:
void queue_edited_resource_preview(const Ref<Resource>& p_path, Object* p_receiver, const StringName& p_receiver_func, const Variant& p_userdata);
void add_preview_generator(const Ref<EditorResourcePreviewGenerator>& p_generator);
+ void check_for_invalidation(const String& p_path);
EditorResourcePreview();
~EditorResourcePreview();
diff --git a/tools/editor/editor_run_native.cpp b/tools/editor/editor_run_native.cpp
index 234dd03087..edbcc71284 100644
--- a/tools/editor/editor_run_native.cpp
+++ b/tools/editor/editor_run_native.cpp
@@ -101,10 +101,8 @@ void EditorRunNative::_run_native(int p_idx,const String& p_platform) {
Ref<EditorExportPlatform> eep = EditorImportExport::get_singleton()->get_export_platform(p_platform);
ERR_FAIL_COND(eep.is_null());
- if (deploy_debug_remote) {
- emit_signal("native_run");
+ emit_signal("native_run");
- }
int flags=0;
if (deploy_debug_remote)
flags|=EditorExportPlatform::EXPORT_REMOTE_DEBUG;
diff --git a/tools/editor/editor_settings.cpp b/tools/editor/editor_settings.cpp
index b89863289a..7f496d0e22 100644
--- a/tools/editor/editor_settings.cpp
+++ b/tools/editor/editor_settings.cpp
@@ -104,12 +104,17 @@ bool EditorSettings::_get(const StringName& p_name,Variant &r_ret) const {
for (const Map<String,Ref<ShortCut> >::Element *E=shortcuts.front();E;E=E->next()) {
Ref<ShortCut> sc=E->get();
- if (!sc->has_meta("original"))
- continue; //this came from settings but is not any longer used
- InputEvent original = sc->get_meta("original");
- if (sc->is_shortcut(original) || (original.type==InputEvent::NONE && sc->get_shortcut().type==InputEvent::NONE))
- continue; //not changed from default, don't save
+ if (optimize_save) {
+ if (!sc->has_meta("original")) {
+ continue; //this came from settings but is not any longer used
+ }
+
+ InputEvent original = sc->get_meta("original");
+ if (sc->is_shortcut(original) || (original.type==InputEvent::NONE && sc->get_shortcut().type==InputEvent::NONE))
+ continue; //not changed from default, don't save
+ }
+
arr.push_back(E->key());
arr.push_back(sc->get_shortcut());
}
@@ -161,7 +166,7 @@ void EditorSettings::_get_property_list(List<PropertyInfo> *p_list) const {
for(Set<_EVCSort>::Element *E=vclist.front();E;E=E->next()) {
int pinfo = 0;
- if (E->get().save) {
+ if (E->get().save || !optimize_save) {
pinfo|=PROPERTY_USAGE_STORAGE;
}
@@ -677,6 +682,8 @@ void EditorSettings::_load_default_text_editor_theme() {
set("text_editor/completion_background_color", Color::html("2C2A32"));
set("text_editor/completion_selected_color", Color::html("434244"));
set("text_editor/completion_existing_color", Color::html("21dfdfdf"));
+ set("text_editor/completion_scroll_color", Color::html("ffffff"));
+ set("text_editor/completion_font_color", Color::html("aaaaaa"));
set("text_editor/caret_color",Color::html("aaaaaa"));
set("text_editor/line_number_color",Color::html("66aaaaaa"));
set("text_editor/text_color",Color::html("aaaaaa"));
@@ -912,6 +919,8 @@ bool EditorSettings::_save_text_editor_theme(String p_file) {
cf->set_value(theme_section, "completion_background_color", ((Color)get("text_editor/completion_background_color")).to_html());
cf->set_value(theme_section, "completion_selected_color", ((Color)get("text_editor/completion_selected_color")).to_html());
cf->set_value(theme_section, "completion_existing_color", ((Color)get("text_editor/completion_existing_color")).to_html());
+ cf->set_value(theme_section, "completion_scroll_color", ((Color)get("text_editor/completion_scroll_color")).to_html());
+ cf->set_value(theme_section, "completion_font_color", ((Color)get("text_editor/completion_font_color")).to_html());
cf->set_value(theme_section, "caret_color", ((Color)get("text_editor/caret_color")).to_html());
cf->set_value(theme_section, "line_number_color", ((Color)get("text_editor/line_number_color")).to_html());
cf->set_value(theme_section, "text_color", ((Color)get("text_editor/text_color")).to_html());
@@ -976,6 +985,10 @@ void EditorSettings::get_shortcut_list(List<String> *r_shortcuts) {
}
}
+void EditorSettings::set_optimize_save(bool p_optimize) {
+
+ optimize_save=p_optimize;
+}
void EditorSettings::_bind_methods() {
@@ -998,6 +1011,7 @@ EditorSettings::EditorSettings() {
//singleton=this;
last_order=0;
+ optimize_save=true;
save_changed_setting=true;
EditorTranslationList *etl=_editor_translations;
diff --git a/tools/editor/editor_settings.h b/tools/editor/editor_settings.h
index d975a7ef86..937956a366 100644
--- a/tools/editor/editor_settings.h
+++ b/tools/editor/editor_settings.h
@@ -88,6 +88,7 @@ private:
bool save_changed_setting;
+ bool optimize_save; //do not save stuff that came from config but was not set from engine
void _load_defaults(Ref<ConfigFile> p_extra_config = NULL);
void _load_default_text_editor_theme();
@@ -155,6 +156,8 @@ public:
Ref<ShortCut> get_shortcut(const String&p_name) const;
void get_shortcut_list(List<String> *r_shortcuts);
+ void set_optimize_save(bool p_optimize);
+
EditorSettings();
~EditorSettings();
diff --git a/tools/editor/groups_editor.cpp b/tools/editor/groups_editor.cpp
index 898e1e115e..5b7bc1da78 100644
--- a/tools/editor/groups_editor.cpp
+++ b/tools/editor/groups_editor.cpp
@@ -31,7 +31,7 @@
#include "scene/gui/box_container.h"
#include "scene/gui/label.h"
#include "editor_node.h"
-
+#include "scene/resources/packed_scene.h"
void GroupsEditor::_add_group(const String& p_group) {
if (!node)
@@ -107,9 +107,35 @@ void GroupsEditor::update_tree() {
if (!gi.persistent)
continue;
+ Node *n = node;
+ bool can_be_deleted=true;
+
+ while(n) {
+
+ Ref<SceneState> ss = (n==EditorNode::get_singleton()->get_edited_scene()) ? n->get_scene_inherited_state() : n->get_scene_instance_state();
+
+ if (ss.is_valid()) {
+
+ int path = ss->find_node_by_path(n->get_path_to(node));
+ if (path!=-1) {
+ if (ss->is_node_in_group(path,gi.name)) {
+ can_be_deleted=false;
+ }
+ }
+ }
+
+ n=n->get_owner();
+ }
+
+
TreeItem *item=tree->create_item(root);
item->set_text(0, gi.name);
- item->add_button(0, get_icon("Remove", "EditorIcons"), 0);
+ if (can_be_deleted) {
+ item->add_button(0, get_icon("Remove", "EditorIcons"), 0);
+ } else {
+ item->set_selectable(0,false);
+ }
+
}
}
diff --git a/tools/editor/import_settings.cpp b/tools/editor/import_settings.cpp
deleted file mode 100644
index dfaeca03db..0000000000
--- a/tools/editor/import_settings.cpp
+++ /dev/null
@@ -1,301 +0,0 @@
-/*************************************************************************/
-/* import_settings.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 "import_settings.h"
-#include "os/os.h"
-#include "editor_node.h"
-
-void ImportSettingsDialog::_item_pressed(int p_idx) {
-
- if (!edited)
- return;
-
- String p=edited->get_metadata(0);
-#if 0
- if (EditorImportDB::get_singleton()->is_image(p)) {
-
- uint32_t flags = EditorImportDB::get_singleton()->get_image_flags(p);
- bool pressed = !popup->is_item_checked(p_idx);
- if (pressed)
- flags|=(1<<p_idx);
- else
- flags&=~(1<<p_idx);
-
-
- EditorImportDB::get_singleton()->set_image_flags(p,flags);
- edited->set_text(2,_str_from_flags(flags));
- }
-#endif
-}
-
-void ImportSettingsDialog::_item_edited() {
-
- if (updating)
- return;
- TreeItem *it=tree->get_selected();
- int ec=tree->get_edited_column();
-
- String p=it->get_metadata(0);
-#if 0
- if (EditorImportDB::get_singleton()->is_image(p)) {
-
- if (ec==1) {
-
-
- EditorImportDB::get_singleton()->set_image_format(p,EditorImport::ImageFormat(int(it->get_range(1))));
-
- } else if (ec==2) {
-
-
- int flags = EditorImportDB::get_singleton()->get_image_flags(p);
- for(int i=0;i<popup->get_item_count();i++) {
-
- popup->set_item_checked(i,flags&(1<<i));
- }
-
- Rect2 r = tree->get_custom_popup_rect();
- popup->set_size(Size2(r.size.width,1));
- popup->set_pos(/*tree->get_global_pos()+*/r.pos+Point2(0,r.size.height));
- popup->popup();
- }
-
- edited=it;
-
- }
-#endif
-
-
-}
-
-
-void ImportSettingsDialog::_button_pressed(Object *p_button, int p_col, int p_id) {
-
- TreeItem *ti=p_button->cast_to<TreeItem>();
- if (!ti)
- return;
- String path = ti->get_metadata(0);
- print_line("PATH: "+path);
- Ref<ResourceImportMetadata> rimd = ResourceLoader::load_import_metadata(path);
- ERR_FAIL_COND(rimd.is_null());
- Ref<EditorImportPlugin> rimp = EditorImportExport::get_singleton()->get_import_plugin_by_name(rimd->get_editor());
- ERR_FAIL_COND(!rimp.is_valid());
- rimp->import_dialog(path);
- hide();
-}
-
-bool ImportSettingsDialog::_generate_fs(TreeItem *p_parent,EditorFileSystemDirectory *p_dir) {
-
- bool valid=false;
-
-
- for(int i=0;i<p_dir->get_subdir_count();i++) {
-
- EditorFileSystemDirectory *sd=p_dir->get_subdir(i);
- TreeItem *ti = tree->create_item(p_parent);
- ti->set_text(0,sd->get_name()+"/");
- ti->set_icon(0,get_icon("Folder","EditorIcons"));
-
- if (!_generate_fs(ti,sd)) {
- memdelete(ti);
- } else {
- valid=true;
- }
- }
-
-
- for(int i=0;i<p_dir->get_file_count();i++) {
-
- String path=p_dir->get_file_path(i);
- if (!p_dir->get_file_meta(i))
- continue;
-
- valid=true;
-
- String f = p_dir->get_file(i);
- TreeItem *ti = tree->create_item(p_parent);
- String type = p_dir->get_file_type(i);
- Ref<Texture> t;
- if (has_icon(type,"EditorIcons"))
- t = get_icon(type,"EditorIcons");
- else
- t = get_icon("Object","EditorIcons");
-
-
- ti->set_icon(0,t);
- ti->set_text(0,f);
-// ti->add_button(0,get_icon("Reload","EditorIcons"));
- ti->set_metadata(0,p_dir->get_file_path(i));
- String tt = p_dir->get_file_path(i);
-
- if (p_dir->is_missing_sources(i)) {
- ti->set_icon(1,get_icon("ImportFail","EditorIcons"));
- Vector<String> missing = p_dir->get_missing_sources(i);
- for(int j=0;j<missing.size();j++) {
- tt+="\nmissing: "+missing[j];
- }
-
- } else
- ti->set_icon(1,get_icon("ImportCheck","EditorIcons"));
-
- ti->set_tooltip(0,tt);
- ti->set_tooltip(1,tt);
-
- }
-
-#if 0
- if (!EditorImportDB::get_singleton()->is_image(path) && !EditorImportDB::get_singleton()->is_scene(path))
- continue;
-
- String f = p_dir->get_file(i);
- TreeItem *ti = tree->create_item(p_parent);
- ti->set_text(0,f);
- String type = p_dir->get_file_type(i);
- Ref<Texture> icon = get_icon( (has_icon(type,"EditorIcons")?type:String("Object")),"EditorIcons");
-
-
- if (EditorImportDB::get_singleton()->is_image(path)) {
-
-
- ti->set_tooltip(0,"Type: Image\nSource: "+EditorImportDB::get_singleton()->get_file_source(path)+"\nSource MD5: "+EditorImportDB::get_singleton()->get_file_md5(path));
- ti->set_cell_mode(1,TreeItem::CELL_MODE_RANGE);
- ti->set_editable(1,true);
- ti->set_range_config(1,0,3,1);
- ti->set_range(1,EditorImportDB::get_singleton()->get_image_format(path));
- ti->set_text(1,texformat);
- ti->set_cell_mode(2,TreeItem::CELL_MODE_CUSTOM);
- ti->set_editable(2,true);
- ti->set_metadata(0,path);
-
- String txt;
- uint32_t flags=EditorImportDB::get_singleton()->get_image_flags(path);
- txt=_str_from_flags(flags);
-
- ti->set_text(2,txt);
- }
-
- ti->set_icon(0, icon);
- valid=true;
-#endif
-
-
- return valid;
-}
-
-void ImportSettingsDialog::update_tree() {
-
- updating=true;
- tree->clear();
- edited=NULL;
-
-
- TreeItem *root = tree->create_item();
- EditorFileSystemDirectory *fs = EditorFileSystem::get_singleton()->get_filesystem();
-
- _generate_fs(root,fs);
- updating=false;
-
-
-}
-
-void ImportSettingsDialog::_notification(int p_what) {
-
- if (p_what==NOTIFICATION_ENTER_TREE) {
-
- EditorFileSystem::get_singleton()->connect("filesystem_changed",this,"update_tree");
- }
-}
-
-
-void ImportSettingsDialog::_bind_methods() {
-
- ObjectTypeDB::bind_method("update_tree",&ImportSettingsDialog::update_tree);
- ObjectTypeDB::bind_method("_item_edited",&ImportSettingsDialog::_item_edited);
- ObjectTypeDB::bind_method("_item_pressed",&ImportSettingsDialog::_item_pressed);
- ObjectTypeDB::bind_method("_button_pressed",&ImportSettingsDialog::_button_pressed);
-
-
-}
-
-
-void ImportSettingsDialog::popup_import_settings() {
-
- update_tree();
- popup_centered_ratio();
-}
-
-void ImportSettingsDialog::ok_pressed() {
-
-
- TreeItem *ti = tree->get_selected();
- if (!ti)
- return;
-
- String path = ti->get_metadata(0);
- print_line("PATH: "+path);
- Ref<ResourceImportMetadata> rimd = ResourceLoader::load_import_metadata(path);
- ERR_FAIL_COND(rimd.is_null());
- Ref<EditorImportPlugin> rimp = EditorImportExport::get_singleton()->get_import_plugin_by_name(rimd->get_editor());
- ERR_FAIL_COND(!rimp.is_valid());
- rimp->import_dialog(path);
- hide();
-
-
-}
-
-ImportSettingsDialog::ImportSettingsDialog(EditorNode *p_editor) {
-
- editor=p_editor;
-
- get_ok()->set_text(TTR("Close"));
-
- tree = memnew( Tree );
- add_child(tree);
- set_child_rect(tree);
- set_title(TTR("Imported Resources"));
-
-// texformat="Keep,None,Disk,VRAM";
-
- tree->set_hide_root(true);
- tree->set_columns(2);
- tree->set_column_expand(1,false);
- tree->set_column_min_width(1,20);
-
- tree->connect("item_edited",this,"_item_edited");
- tree->connect("button_pressed",this,"_button_pressed");
-
-// add_button("Re-Import","reimport");
- get_ok()->set_text(TTR("Re-Import"));
- get_cancel()->set_text(TTR("Close"));
-
- updating=false;
- edited=NULL;
- set_hide_on_ok(false);
-
-
-}
-
diff --git a/tools/editor/io_plugins/editor_atlas.cpp b/tools/editor/io_plugins/editor_atlas.cpp
index f894e7e8b2..f69e383fb0 100644
--- a/tools/editor/io_plugins/editor_atlas.cpp
+++ b/tools/editor/io_plugins/editor_atlas.cpp
@@ -82,7 +82,6 @@ void EditorAtlas::fit(const Vector<Size2i>& p_rects,Vector<Point2i>& r_result, S
//place them
int ofs=0;
- int limit_h=0;
for(int j=0;j<wrects.size();j++) {
@@ -106,8 +105,6 @@ void EditorAtlas::fit(const Vector<Size2i>& p_rects,Vector<Point2i>& r_result, S
int end_h = from_y+wrects[j].s.height;
int end_w = ofs+wrects[j].s.width;
- if (ofs==0)
- limit_h=end_h;
for(int k=0;k<wrects[j].s.width;k++) {
@@ -120,8 +117,7 @@ void EditorAtlas::fit(const Vector<Size2i>& p_rects,Vector<Point2i>& r_result, S
if (end_w > max_w)
max_w=end_w;
- //if (ofs==0 || end_h>limit_h ) //while h limit not reched, keep stacking
- ofs+=wrects[j].s.width;
+ ofs+=wrects[j].s.width;
}
diff --git a/tools/editor/io_plugins/editor_import_collada.cpp b/tools/editor/io_plugins/editor_import_collada.cpp
index 363cba3678..1130e2be30 100644
--- a/tools/editor/io_plugins/editor_import_collada.cpp
+++ b/tools/editor/io_plugins/editor_import_collada.cpp
@@ -2278,12 +2278,6 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones
NodeMap &nm = node_map[at.target];
String path = scene->get_path_to(nm.node);
- Collada::Node *cn = collada.state.scene_map[at.target];
- //if (cn->ignore_anim) {
- // print_line("warning, ignoring property animation on node: "+nm.path);
- //continue;
- //}
-
animation->add_track(Animation::TYPE_VALUE);
int track = animation->get_track_count() -1;
@@ -2381,7 +2375,6 @@ Node* EditorSceneImporterCollada::import_scene(const String& p_path, uint32_t p_
state.create_animations(p_flags&IMPORT_ANIMATION_FORCE_ALL_TRACKS_IN_ALL_CLIPS);
AnimationPlayer *ap = memnew( AnimationPlayer );
- ap->set_name("animations");
for(int i=0;i<state.animations.size();i++) {
String name;
if (state.animations[i]->get_name()=="")
diff --git a/tools/editor/io_plugins/editor_mesh_import_plugin.cpp b/tools/editor/io_plugins/editor_mesh_import_plugin.cpp
index 095c56a373..2c3ed2afd6 100644
--- a/tools/editor/io_plugins/editor_mesh_import_plugin.cpp
+++ b/tools/editor/io_plugins/editor_mesh_import_plugin.cpp
@@ -520,7 +520,7 @@ Error EditorMeshImportPlugin::import(const String& p_path, const Ref<ResourceImp
//new object/surface
if (generate_normals || force_smooth)
surf_tool->generate_normals();
- if (uvs.size() && (normals.size() || generate_normals))
+ if (uvs.size() && (normals.size() || generate_normals) && generate_tangents)
surf_tool->generate_tangents();
surf_tool->index();
diff --git a/tools/editor/io_plugins/editor_scene_import_plugin.cpp b/tools/editor/io_plugins/editor_scene_import_plugin.cpp
index d5d0fac2b6..e24412d4ef 100644
--- a/tools/editor/io_plugins/editor_scene_import_plugin.cpp
+++ b/tools/editor/io_plugins/editor_scene_import_plugin.cpp
@@ -2459,7 +2459,7 @@ void EditorSceneImportPlugin::_optimize_animations(Node *scene, float p_max_lin_
void EditorSceneImportPlugin::_find_resources_to_merge(Node *scene, Node *node, bool p_merge_material, Map<String, Ref<Material> > &materials, bool p_merge_anims, Map<String,Ref<Animation> >& merged_anims,Set<Ref<Mesh> > &tested_meshes) {
- if (node->get_owner()!=scene)
+ if (node!=scene && node->get_owner()!=scene)
return;
String path = scene->get_path_to(node);
@@ -2507,11 +2507,43 @@ void EditorSceneImportPlugin::_find_resources_to_merge(Node *scene, Node *node,
for(int i=0;i<mesh->get_surface_count();i++) {
Ref<Material> material = mesh->surface_get_material(i);
- materials[mesh->get_name()+":surf:"+mesh->surface_get_name(i)]=material;
+
+ if (material.is_valid()) {
+
+ String sname = mesh->surface_get_name(i);
+ if (sname=="")
+ sname="surf_"+itos(i);
+
+ sname=mesh->get_name()+":surf:"+sname;
+ materials[sname]=material;
+ }
}
tested_meshes.insert(mesh);
}
+
+ if (mesh.is_valid()) {
+
+ for(int i=0;i<mesh->get_surface_count();i++) {
+ Ref<Material> material = mi->get_surface_material(i);
+ if (material.is_valid()) {
+ String sname = mesh->surface_get_name(i);
+ if (sname=="")
+ sname="surf_"+itos(i);
+
+ sname=path+":inst_surf:"+sname;
+ materials[sname]=material;
+ }
+ }
+
+ }
+
+ Ref<Material> override = mi->get_material_override();
+
+ if (override.is_valid()) {
+
+ materials[path+":override"]=override;
+ }
}
@@ -2525,11 +2557,13 @@ void EditorSceneImportPlugin::_find_resources_to_merge(Node *scene, Node *node,
void EditorSceneImportPlugin::_merge_found_resources(Node *scene, Node *node, bool p_merge_material, const Map<String, Ref<Material> > &materials, bool p_merge_anims, const Map<String,Ref<Animation> >& merged_anims, Set<Ref<Mesh> > &tested_meshes) {
- if (node->get_owner()!=scene)
+ if (node!=scene && node->get_owner()!=scene)
return;
String path = scene->get_path_to(node);
+ print_line("at path: "+path);
+
if (node->cast_to<AnimationPlayer>()) {
AnimationPlayer *ap = node->cast_to<AnimationPlayer>();
@@ -2570,15 +2604,48 @@ void EditorSceneImportPlugin::_merge_found_resources(Node *scene, Node *node, bo
if (mesh.is_valid() && mesh->get_name()!=String() && !tested_meshes.has(mesh)) {
for(int i=0;i<mesh->get_surface_count();i++) {
- String sname = mesh->get_name()+":surf:"+mesh->surface_get_name(i);
+
+ String sname = mesh->surface_get_name(i);
+ if (sname=="")
+ sname="surf_"+itos(i);
+
+ sname=mesh->get_name()+":surf:"+sname;
+
if (materials.has(sname)) {
+
mesh->surface_set_material(i,materials[sname]);
}
}
tested_meshes.insert(mesh);
}
+
+ if (mesh.is_valid()) {
+
+ for(int i=0;i<mesh->get_surface_count();i++) {
+
+ String sname = mesh->surface_get_name(i);
+ if (sname=="")
+ sname="surf_"+itos(i);
+
+ sname=path+":inst_surf:"+sname;
+
+
+ if (materials.has(sname)) {
+
+ mi->set_surface_material(i,materials[sname]);
+ }
+ }
+
+ }
+
+
+ String opath = path+":override";
+ if (materials.has(opath)) {
+ mi->set_material_override(materials[opath]);
+ }
+
}
@@ -2613,12 +2680,6 @@ Error EditorSceneImportPlugin::import2(Node *scene, const String& p_dest_path, c
progress.step(TTR("Importing Scene.."),2);
- bool reimport = bool(from->get_option("reimport"));
- int this_time_action = from->get_option("import_this_time");
- int next_time_action = from->get_option("import_next_time");
-
- int import_action = reimport?this_time_action:next_time_action;
-
from->set_source_md5(0,FileAccess::get_md5(src_path));
from->set_editor(get_name());
@@ -2627,8 +2688,6 @@ Error EditorSceneImportPlugin::import2(Node *scene, const String& p_dest_path, c
Map<Ref<Mesh>,Ref<Shape> > collision_map;
- Ref<ResourceImportMetadata> imd = memnew(ResourceImportMetadata);
-
Map< Ref<ImageTexture>,TextureRole > imagemap;
scene=_fix_node(scene,scene,collision_map,scene_flags,imagemap);
@@ -2643,6 +2702,7 @@ Error EditorSceneImportPlugin::import2(Node *scene, const String& p_dest_path, c
if (scene_flags&(SCENE_FLAG_MERGE_KEEP_MATERIALS|SCENE_FLAG_MERGE_KEEP_EXTRA_ANIM_TRACKS) && FileAccess::exists(p_dest_path)) {
//must merge!
+ print_line("MUST MERGE");
Ref<PackedScene> pscene = ResourceLoader::load(p_dest_path,"PackedScene",true);
if (pscene.is_valid()) {
@@ -2653,8 +2713,9 @@ Error EditorSceneImportPlugin::import2(Node *scene, const String& p_dest_path, c
Set<Ref<Mesh> > tested_meshes;
_find_resources_to_merge(instance,instance,scene_flags&SCENE_FLAG_MERGE_KEEP_MATERIALS,merged_materials,scene_flags&SCENE_FLAG_MERGE_KEEP_EXTRA_ANIM_TRACKS,merged_anims,tested_meshes);
+
tested_meshes.clear();
- _merge_found_resources(instance,instance,scene_flags&SCENE_FLAG_MERGE_KEEP_MATERIALS,merged_materials,scene_flags&SCENE_FLAG_MERGE_KEEP_EXTRA_ANIM_TRACKS,merged_anims,tested_meshes);
+ _merge_found_resources(scene,scene,scene_flags&SCENE_FLAG_MERGE_KEEP_MATERIALS,merged_materials,scene_flags&SCENE_FLAG_MERGE_KEEP_EXTRA_ANIM_TRACKS,merged_anims,tested_meshes);
memdelete(instance);
}
@@ -2742,7 +2803,7 @@ Error EditorSceneImportPlugin::import2(Node *scene, const String& p_dest_path, c
target_path=target_path.basename()+".tex";
Ref<ResourceImportMetadata> imd = memnew( ResourceImportMetadata );
- print_line("flags: "+itos(image_flags));
+
uint32_t flags = image_flags;
if (E->get()==TEXTURE_ROLE_DIFFUSE && scene_flags&SCENE_FLAG_LINEARIZE_DIFFUSE_TEXTURES)
flags|=EditorTextureImportPlugin::IMAGE_FLAG_CONVERT_TO_LINEAR;
@@ -2790,15 +2851,16 @@ Error EditorSceneImportPlugin::import2(Node *scene, const String& p_dest_path, c
Ref<PackedScene> packer = memnew( PackedScene );
packer->pack(scene);
- packer->set_path(p_dest_path);
+ //packer->set_path(p_dest_path); do not take over, let the changed files reload themselves
packer->set_import_metadata(from);
print_line("SAVING TO: "+p_dest_path);
- err = ResourceSaver::save(p_dest_path,packer,ResourceSaver::FLAG_REPLACE_SUBRESOURCE_PATHS);
+ err = ResourceSaver::save(p_dest_path,packer); //do not take over, let the changed files reload themselves
//EditorFileSystem::get_singleton()->update_resource(packer);
memdelete(scene);
+
/*
scene->set_filename(p_dest_path);
if (r_scene) {
@@ -2818,6 +2880,7 @@ Error EditorSceneImportPlugin::import2(Node *scene, const String& p_dest_path, c
*/
+ EditorNode::get_singleton()->reload_scene(p_dest_path);
return err;
diff --git a/tools/editor/io_plugins/editor_texture_import_plugin.cpp b/tools/editor/io_plugins/editor_texture_import_plugin.cpp
index 16ea803da4..1d8319d460 100644
--- a/tools/editor/io_plugins/editor_texture_import_plugin.cpp
+++ b/tools/editor/io_plugins/editor_texture_import_plugin.cpp
@@ -1192,8 +1192,6 @@ Error EditorTextureImportPlugin::import2(const String& p_path, const Ref<Resourc
}
ep.step(TTR("Converting Images"),sources.size());
- int base_index=0;
-
Map<uint64_t,int> source_md5;
Map<int,List<int> > source_map;
@@ -1760,7 +1758,6 @@ void EditorTextureImportPlugin::reimport_multiple_files(const Vector<String>& p_
Vector<String> valid;
- bool warning=false;
for(int i=0;i<p_list.size();i++) {
Ref<ResourceImportMetadata> rimd = ResourceLoader::load_import_metadata(p_list[i]);
@@ -1768,7 +1765,6 @@ void EditorTextureImportPlugin::reimport_multiple_files(const Vector<String>& p_
if (type=="texture" || type.begins_with("texture_")) {
if ((rimd->has_option("atlas") && rimd->get_option("atlas")) || (rimd->has_option("large") && rimd->get_option("large"))) {
- warning=true;
continue;
}
diff --git a/tools/editor/io_plugins/editor_translation_import_plugin.cpp b/tools/editor/io_plugins/editor_translation_import_plugin.cpp
index aa36fefdb7..9ee3e98486 100644
--- a/tools/editor/io_plugins/editor_translation_import_plugin.cpp
+++ b/tools/editor/io_plugins/editor_translation_import_plugin.cpp
@@ -425,7 +425,6 @@ Error EditorTranslationImportPlugin::import(const String& p_path, const Ref<Reso
ERR_FAIL_COND_V( !f, ERR_INVALID_PARAMETER );
- bool first=false;
bool skip_first = from->get_option("skip_first");
int index = from->get_option("index");
index+=1;
@@ -439,7 +438,6 @@ Error EditorTranslationImportPlugin::import(const String& p_path, const Ref<Reso
while(line.size()>1) {
-
if (!skip_first) {
ERR_FAIL_INDEX_V(index,line.size(),ERR_INVALID_DATA );
translation->add_message(line[0].strip_edges(),line[index]);
diff --git a/tools/editor/output_strings.cpp b/tools/editor/output_strings.cpp
index f1b49d2326..a6126466c4 100644
--- a/tools/editor/output_strings.cpp
+++ b/tools/editor/output_strings.cpp
@@ -32,7 +32,6 @@
void OutputStrings::update_scrollbars() {
- Size2 size = get_size();
Size2 hmin = h_scroll->get_combined_minimum_size();
Size2 vmin = v_scroll->get_combined_minimum_size();
diff --git a/tools/editor/plugins/animation_player_editor_plugin.cpp b/tools/editor/plugins/animation_player_editor_plugin.cpp
index 10c7bf79a3..98ba25b482 100644
--- a/tools/editor/plugins/animation_player_editor_plugin.cpp
+++ b/tools/editor/plugins/animation_player_editor_plugin.cpp
@@ -407,7 +407,6 @@ void AnimationPlayerEditor::_animation_save(const Ref<Resource>& p_resource) {
void AnimationPlayerEditor::_animation_save_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());
List<String> extensions;
ResourceSaver::get_recognized_extensions(p_resource, &extensions);
@@ -1404,6 +1403,7 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor) {
hb->add_child(animation);
animation->set_h_size_flags(SIZE_EXPAND_FILL);
animation->set_tooltip(TTR("Display list of animations in player."));
+ animation->set_clip_text(true);
autoplay = memnew( ToolButton );
hb->add_child(autoplay);
diff --git a/tools/editor/plugins/animation_tree_editor_plugin.cpp b/tools/editor/plugins/animation_tree_editor_plugin.cpp
index a381ec4678..24914e4bc5 100644
--- a/tools/editor/plugins/animation_tree_editor_plugin.cpp
+++ b/tools/editor/plugins/animation_tree_editor_plugin.cpp
@@ -90,7 +90,6 @@ Size2 AnimationTreeEditor::get_node_size(const StringName& p_node) const {
Ref<StyleBox> style = get_stylebox("panel","PopupMenu");
Ref<Font> font = get_font("font","PopupMenu");
- Color font_color = get_color("font_color","PopupMenu");
Size2 size = style->get_minimum_size();
@@ -633,7 +632,6 @@ AnimationTreeEditor::ClickType AnimationTreeEditor::_locate_click(const Point2&
Ref<StyleBox> style = get_stylebox("panel","PopupMenu");
Ref<Font> font = get_font("font","PopupMenu");
- Color font_color = get_color("font_color","PopupMenu");
float h = (font->get_height()+get_constant("vseparation","PopupMenu"));
diff --git a/tools/editor/plugins/baked_light_baker.cpp b/tools/editor/plugins/baked_light_baker.cpp
index 1962f81e87..6a88ba4cbe 100644
--- a/tools/editor/plugins/baked_light_baker.cpp
+++ b/tools/editor/plugins/baked_light_baker.cpp
@@ -645,7 +645,6 @@ void BakedLightBaker::_octree_insert(int p_octant,Triangle* p_triangle, int p_de
leaf_list=child_idx;
cell_count++;
- int lz = lights.size();
for(int ci=0;ci<8;ci++) {
child->light_accum[ci][0]=0;
child->light_accum[ci][1]=0;
@@ -1016,8 +1015,6 @@ float BakedLightBaker::_throw_ray(ThreadStack& thread_stack,bool p_bake_direct,c
//ray_aabb.expand_to(p_end);
- const BVH *bvhptr = bvh;
-
bstack[0]=bvh;
stack[0]=TEST_AABB_BIT;
@@ -1693,7 +1690,7 @@ void BakedLightBaker::throw_rays(ThreadStack& thread_stack,int p_amount) {
Vector3 from = dl.pos;
double r1 = double(rand())/RAND_MAX;
- double r2 = double(rand())/RAND_MAX;
+ //double r2 = double(rand())/RAND_MAX;
double r3 = double(rand())/RAND_MAX;
float d=Math::tan(Math::deg2rad(dl.spot_angle));
@@ -1994,7 +1991,6 @@ void BakedLightBaker::update_octree_images(DVector<uint8_t> &p_octree,DVector<ui
const double *normptr=norm_arr.ptr();
*/
double norm = 1.0/double(total_rays);
- int lz=lights.size();
mult/=multiplier;
double saturation = baked_light->get_saturation();
@@ -2261,8 +2257,6 @@ void BakedLightBaker::_plot_pixel_to_lightmap(int x, int y, int width, int heigh
continue;
n/=len;
- const BVH *bvhptr = bvh;
-
bstack[0]=bvh;
stack[0]=TEST_RAY_BIT;
@@ -2404,8 +2398,6 @@ Error BakedLightBaker::transfer_to_lightmaps() {
float gamma = baked_light->get_gamma_adjust();
float mult = baked_light->get_energy_multiplier();
-
- const double *normptr=norm_arr.ptr();
for(int i=0;i<triangles.size();i++) {
if (i%200==0) {
@@ -2538,7 +2530,6 @@ Error BakedLightBaker::transfer_to_lightmaps() {
Vector<uint8_t> copy_data=bt.data;
uint8_t *data=bt.data.ptr();
- uint8_t *src_data=copy_data.ptr();
const int max_radius=8;
const int shadow_radius=2;
const int max_dist=0x7FFFFFFF;
diff --git a/tools/editor/plugins/canvas_item_editor_plugin.cpp b/tools/editor/plugins/canvas_item_editor_plugin.cpp
index 81601a81a7..f9499904db 100644
--- a/tools/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/tools/editor/plugins/canvas_item_editor_plugin.cpp
@@ -1940,8 +1940,6 @@ void CanvasItemEditor::_viewport_draw() {
Map<Node*,Object*> &selection = editor_selection->get_selection();
- CanvasItem *single_item=NULL;
-
bool pivot_found=false;
for(Map<Node*,Object*>::Element *E=selection.front();E;E=E->next()) {
@@ -1961,15 +1959,6 @@ void CanvasItemEditor::_viewport_draw() {
Matrix32 xform=transform * canvas_item->get_global_transform_with_canvas();
VisualServer::get_singleton()->canvas_item_add_set_transform(ci,xform);
- Point2 ofs=Point2();//get_global_pos();
- Rect2 draw_rect=rect;
- Color light_edit_color=Color(1.0,0.8,0.8);
- Color dark_edit_color=Color(0.4,0.1,0.1);
- Size2 handle_size=Size2(handle_len,handle_len);
-
- //select_sb->draw(ci,draw_rect.grow(2));
- //DRAW_EMPTY_RECT( draw_rect.grow(2), light_edit_color );
- //DRAW_EMPTY_RECT( draw_rect.grow(1), dark_edit_color );
Vector2 endpoints[4]={
@@ -3374,25 +3363,25 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
PopupMenu *p;
p = edit_menu->get_popup();
- p->add_check_item(TTR("Use Snap"),SNAP_USE);
- p->add_check_item(TTR("Show Grid"),SNAP_SHOW_GRID);
- p->add_check_item(TTR("Use Rotation Snap"),SNAP_USE_ROTATION);
- p->add_check_item(TTR("Snap Relative"),SNAP_RELATIVE);
- p->add_item(TTR("Configure Snap.."),SNAP_CONFIGURE);
+ p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/use_snap", TTR("Use Snap")), SNAP_USE);
+ p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/show_grid", TTR("Show Grid")), SNAP_SHOW_GRID);
+ p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/use_rotation_snap", TTR("Use Rotation Snap")), SNAP_USE_ROTATION);
+ p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/snap_relative", TTR("Snap Relative")), SNAP_RELATIVE);
+ p->add_shortcut(ED_SHORTCUT("canvas_item_editor/configure_snap", TTR("Configure Snap..")), SNAP_CONFIGURE);
p->add_separator();
- p->add_check_item(TTR("Use Pixel Snap"),SNAP_USE_PIXEL);
+ p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/use_pixel_snap", TTR("Use Pixel Snap")), SNAP_USE_PIXEL);
p->add_separator();
- p->add_item(TTR("Expand to Parent"),EXPAND_TO_PARENT,KEY_MASK_CMD|KEY_P);
+ p->add_shortcut(ED_SHORTCUT("canvas_item_editor/expand_to_parent", TTR("Expand to Parent"), KEY_MASK_CMD | KEY_P), EXPAND_TO_PARENT);
p->add_separator();
p->add_submenu_item(TTR("Skeleton.."),"skeleton");
PopupMenu *p2 = memnew(PopupMenu);
p->add_child(p2);
p2->set_name("skeleton");
- p2->add_item(TTR("Make Bones"),SKELETON_MAKE_BONES,KEY_MASK_CMD|KEY_MASK_SHIFT|KEY_B);
- p2->add_item(TTR("Clear Bones"),SKELETON_CLEAR_BONES);
+ p2->add_shortcut(ED_SHORTCUT("canvas_item_editor/skeleton_make_bones", TTR("Make Bones"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_B ),SKELETON_MAKE_BONES);
+ p2->add_shortcut(ED_SHORTCUT("canvas_item_editor/skeleton_clear_bones", TTR("Clear Bones")), SKELETON_CLEAR_BONES);
p2->add_separator();
- p2->add_item(TTR("Make IK Chain"),SKELETON_SET_IK_CHAIN);
- p2->add_item(TTR("Clear IK Chain"),SKELETON_CLEAR_IK_CHAIN);
+ p2->add_shortcut(ED_SHORTCUT("canvas_item_editor/skeleton_set_ik_chain", TTR("Make IK Chain")), SKELETON_SET_IK_CHAIN);
+ p2->add_shortcut(ED_SHORTCUT("canvas_item_editor/skeleton_clear_ik_chain", TTR("Clear IK Chain")), SKELETON_CLEAR_IK_CHAIN);
p2->connect("item_pressed", this,"_popup_callback");
@@ -3409,13 +3398,13 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
p = view_menu->get_popup();
- p->add_item(TTR("Zoom In"),ZOOM_IN);
- p->add_item(TTR("Zoom Out"),ZOOM_OUT);
- p->add_item(TTR("Zoom Reset"),ZOOM_RESET);
- p->add_item(TTR("Zoom Set.."),ZOOM_SET);
+ p->add_shortcut(ED_SHORTCUT("canvas_item_editor/zoom_in", TTR("Zoom In")), ZOOM_IN);
+ p->add_shortcut(ED_SHORTCUT("canvas_item_editor/zoom_out", TTR("Zoom Out")), ZOOM_OUT);
+ p->add_shortcut(ED_SHORTCUT("canvas_item_editor/zoom_reset", TTR("Zoom Reset")), ZOOM_RESET);
+ p->add_shortcut(ED_SHORTCUT("canvas_item_editor/zoom_set", TTR("Zoom Set..")), ZOOM_SET);
p->add_separator();
- p->add_item(TTR("Center Selection"), VIEW_CENTER_TO_SELECTION, KEY_F);
- p->add_item(TTR("Frame Selection"), VIEW_FRAME_TO_SELECTION, KEY_MASK_CMD|KEY_F);
+ p->add_shortcut(ED_SHORTCUT("canvas_item_editor/center_selection", TTR("Center Selection"), KEY_F), VIEW_CENTER_TO_SELECTION);
+ p->add_shortcut(ED_SHORTCUT("canvas_item_editor/frame_selection", TTR("Frame Selection"), KEY_MASK_SHIFT | KEY_F), VIEW_FRAME_TO_SELECTION);
anchor_menu = memnew( MenuButton );
anchor_menu->set_text(TTR("Anchor"));
@@ -3458,7 +3447,8 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
key_insert_button = memnew( Button );
key_insert_button->set_focus_mode(FOCUS_NONE);
key_insert_button->connect("pressed",this,"_popup_callback",varray(ANIM_INSERT_KEY));
- key_insert_button->set_tooltip(TTR("Insert Keys (Ins)"));
+ key_insert_button->set_tooltip(TTR("Insert Keys"));
+ key_insert_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/anim_insert_key", TTR("Insert Key"), KEY_INSERT));
animation_hb->add_child(key_insert_button);
@@ -3469,12 +3459,12 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
p = animation_menu->get_popup();
- p->add_item(TTR("Insert Key"),ANIM_INSERT_KEY,KEY_INSERT);
- p->add_item(TTR("Insert Key (Existing Tracks)"),ANIM_INSERT_KEY_EXISTING,KEY_MASK_CMD+KEY_INSERT);
+ p->add_shortcut(ED_GET_SHORTCUT("canvas_item_editor/anim_insert_key"), ANIM_INSERT_KEY);
+ p->add_shortcut(ED_SHORTCUT("canvas_item_editor/anim_insert_key_existing_tracks", TTR("Insert Key (Existing Tracks)"), KEY_MASK_CMD+KEY_INSERT), ANIM_INSERT_KEY_EXISTING);
p->add_separator();
- p->add_item(TTR("Copy Pose"),ANIM_COPY_POSE);
- p->add_item(TTR("Paste Pose"),ANIM_PASTE_POSE);
- p->add_item(TTR("Clear Pose"),ANIM_CLEAR_POSE,KEY_MASK_SHIFT|KEY_K);
+ p->add_shortcut(ED_SHORTCUT("canvas_item_editor/anim_copy_pose", TTR("Copy Pose")), ANIM_COPY_POSE);
+ p->add_shortcut(ED_SHORTCUT("canvas_item_editor/anim_paste_pose", TTR("Paste Pose")), ANIM_PASTE_POSE);
+ p->add_shortcut(ED_SHORTCUT("canvas_item_editor/anim_clear_pose", TTR("Clear Pose"), KEY_MASK_SHIFT | KEY_K), ANIM_CLEAR_POSE);
snap_dialog = memnew( SnapDialog );
snap_dialog->connect("confirmed",this,"_snap_changed");
diff --git a/tools/editor/plugins/collision_polygon_2d_editor_plugin.cpp b/tools/editor/plugins/collision_polygon_2d_editor_plugin.cpp
index 5ed9f8ab5f..95364e8921 100644
--- a/tools/editor/plugins/collision_polygon_2d_editor_plugin.cpp
+++ b/tools/editor/plugins/collision_polygon_2d_editor_plugin.cpp
@@ -349,8 +349,6 @@ void CollisionPolygon2DEditor::_canvas_draw() {
Matrix32 xform = canvas_item_editor->get_canvas_transform() * node->get_global_transform();
Ref<Texture> handle= get_icon("EditorHandle","EditorIcons");
- int len = poly.size();
-
for(int i=0;i<poly.size();i++) {
diff --git a/tools/editor/plugins/collision_polygon_editor_plugin.cpp b/tools/editor/plugins/collision_polygon_editor_plugin.cpp
index b18afe7838..0b06b3ba21 100644
--- a/tools/editor/plugins/collision_polygon_editor_plugin.cpp
+++ b/tools/editor/plugins/collision_polygon_editor_plugin.cpp
@@ -381,8 +381,6 @@ void CollisionPolygonEditor::_polygon_draw() {
poly=node->get_polygon();
-
- int len = poly.size();
float depth = node->get_depth()*0.5;
imgeom->clear();
@@ -586,7 +584,7 @@ CollisionPolygonEditor::CollisionPolygonEditor(EditorNode *p_editor) {
handle_material->set_parameter(FixedMaterial::PARAM_DIFFUSE,Color(1,1,1));
handle_material->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA, true);
handle_material->set_fixed_flag(FixedMaterial::FLAG_USE_COLOR_ARRAY, false);
- Ref<Texture> handle= SpatialEditor::get_singleton()->get_icon("Editor3DHandle","EditorIcons");
+ Ref<Texture> handle=editor->get_gui_base()->get_icon("Editor3DHandle","EditorIcons");
handle_material->set_point_size(handle->get_width());
handle_material->set_texture(FixedMaterial::PARAM_DIFFUSE,handle);
diff --git a/tools/editor/plugins/editor_preview_plugins.cpp b/tools/editor/plugins/editor_preview_plugins.cpp
index a057e6c2a1..b1bce60484 100644
--- a/tools/editor/plugins/editor_preview_plugins.cpp
+++ b/tools/editor/plugins/editor_preview_plugins.cpp
@@ -36,6 +36,7 @@
#include "scene/resources/mesh.h"
#include "scene/resources/bit_mask.h"
#include "tools/editor/editor_scale.h"
+
bool EditorTexturePreviewPlugin::handles(const String& p_type) const {
return (ObjectTypeDB::is_type(p_type,"ImageTexture") || ObjectTypeDB::is_type(p_type, "AtlasTexture"));
@@ -442,7 +443,6 @@ Ref<Texture> EditorScriptPreviewPlugin::generate(const RES& p_from) {
Color keyword_color = EditorSettings::get_singleton()->get("text_editor/keyword_color");
Color text_color = EditorSettings::get_singleton()->get("text_editor/text_color");
Color symbol_color = EditorSettings::get_singleton()->get("text_editor/symbol_color");
- Color comment_color = EditorSettings::get_singleton()->get("text_editor/comment_color");
for(int i=0;i<thumbnail_size;i++) {
@@ -607,7 +607,7 @@ Ref<Texture> EditorSamplePreviewPlugin::generate(const RES& p_from) {
-1, -1, -1, -1, 2, 4, 6, 8
};
- int16_t nibble,signed_nibble,diff,step;
+ int16_t nibble,diff,step;
ima_adpcm.last_nibble++;
const uint8_t *src_ptr=sdata;
@@ -628,10 +628,6 @@ Ref<Texture> EditorSamplePreviewPlugin::generate(const RES& p_from) {
if (ima_adpcm.step_index>88)
ima_adpcm.step_index=88;
- /*
- signed_nibble = (nibble&7) * ((nibble&8)?-1:1);
- diff = (2 * signed_nibble + 1) * step / 4; */
-
diff = step >> 3 ;
if (nibble & 1)
diff += step >> 2 ;
@@ -748,15 +744,13 @@ Ref<Texture> EditorSamplePreviewPlugin::generate(const RES& p_from) {
for(int j=0;j<h;j++) {
- int half,ofs;
+ int half;
float v;
if (j<(h/2)) {
half=0;
- ofs=0;
v = (j/(float)(h/2)) * 2.0 - 1.0;
} else {
half=1;
- ofs=h/2;
if( (float)(h/2) != 0 ) {
v = ((j-(h/2))/(float)(h/2)) * 2.0 - 1.0;
} else {
diff --git a/tools/editor/plugins/light_occluder_2d_editor_plugin.cpp b/tools/editor/plugins/light_occluder_2d_editor_plugin.cpp
index 14e7b14fc3..56e58bc983 100644
--- a/tools/editor/plugins/light_occluder_2d_editor_plugin.cpp
+++ b/tools/editor/plugins/light_occluder_2d_editor_plugin.cpp
@@ -364,8 +364,6 @@ void LightOccluder2DEditor::_canvas_draw() {
Matrix32 xform = canvas_item_editor->get_canvas_transform() * node->get_global_transform();
Ref<Texture> handle= get_icon("EditorHandle","EditorIcons");
- int len = poly.size();
-
for(int i=0;i<poly.size();i++) {
diff --git a/tools/editor/plugins/navigation_polygon_editor_plugin.cpp b/tools/editor/plugins/navigation_polygon_editor_plugin.cpp
index 5a8cd8791e..22546c72f3 100644
--- a/tools/editor/plugins/navigation_polygon_editor_plugin.cpp
+++ b/tools/editor/plugins/navigation_polygon_editor_plugin.cpp
@@ -427,8 +427,6 @@ void NavigationPolygonEditor::_canvas_draw() {
poly = Variant(node->get_navigation_polygon()->get_outline(j));
}
- int len = poly.size();
-
for(int i=0;i<poly.size();i++) {
diff --git a/tools/editor/plugins/particles_editor_plugin.cpp b/tools/editor/plugins/particles_editor_plugin.cpp
index 93e2fb2f38..7e20cc3f54 100644
--- a/tools/editor/plugins/particles_editor_plugin.cpp
+++ b/tools/editor/plugins/particles_editor_plugin.cpp
@@ -283,7 +283,6 @@ void ParticlesEditor::_generate_emission_points() {
ofs=(Vector3(1,1,1)-dir)*Vector3(Math::randf(),Math::randf(),Math::randf())*aabb.size;
ofs+=aabb.pos;
- Vector3 dirv = -dir;
Vector3 ofsv = ofs + aabb.size * dir;
//space it a little
diff --git a/tools/editor/plugins/polygon_2d_editor_plugin.cpp b/tools/editor/plugins/polygon_2d_editor_plugin.cpp
index d78508c429..19d1ccc06f 100644
--- a/tools/editor/plugins/polygon_2d_editor_plugin.cpp
+++ b/tools/editor/plugins/polygon_2d_editor_plugin.cpp
@@ -466,8 +466,6 @@ void Polygon2DEditor::_canvas_draw() {
Matrix32 xform = canvas_item_editor->get_canvas_transform() * node->get_global_transform();
Ref<Texture> handle= get_icon("EditorHandle","EditorIcons");
- int len = poly.size();
-
for(int i=0;i<poly.size();i++) {
diff --git a/tools/editor/plugins/sample_editor_plugin.cpp b/tools/editor/plugins/sample_editor_plugin.cpp
index b094184a29..7965fa54ae 100644
--- a/tools/editor/plugins/sample_editor_plugin.cpp
+++ b/tools/editor/plugins/sample_editor_plugin.cpp
@@ -151,7 +151,7 @@ void SampleEditor::generate_preview_texture(const Ref<Sample>& p_sample,Ref<Imag
-1, -1, -1, -1, 2, 4, 6, 8
};
- int16_t nibble,signed_nibble,diff,step;
+ int16_t nibble,diff,step;
ima_adpcm.last_nibble++;
const uint8_t *src_ptr=sdata;
@@ -172,10 +172,6 @@ void SampleEditor::generate_preview_texture(const Ref<Sample>& p_sample,Ref<Imag
if (ima_adpcm.step_index>88)
ima_adpcm.step_index=88;
- /*
- signed_nibble = (nibble&7) * ((nibble&8)?-1:1);
- diff = (2 * signed_nibble + 1) * step / 4; */
-
diff = step >> 3 ;
if (nibble & 1)
diff += step >> 2 ;
@@ -285,15 +281,13 @@ void SampleEditor::generate_preview_texture(const Ref<Sample>& p_sample,Ref<Imag
for(int j=0;j<h;j++) {
- int half,ofs;
+ int half;
float v;
if (j<(h/2)) {
half=0;
- ofs=0;
v = (j/(float)(h/2)) * 2.0 - 1.0;
} else {
half=1;
- ofs=h/2;
v = ((j-(h/2))/(float)(h/2)) * 2.0 - 1.0;
}
@@ -324,12 +318,13 @@ void SampleEditor::generate_preview_texture(const Ref<Sample>& p_sample,Ref<Imag
void SampleEditor::_update_sample() {
player->stop_all();
- if (sample->get_format()==Sample::FORMAT_IMA_ADPCM)
- return; //bye or unsupported
generate_preview_texture(sample,peakdisplay);
info_label->set_text(TTR("Length:")+" "+String::num(sample->get_length()/(float)sample->get_mix_rate(),2)+"s");
+ if (library->has_sample("default"))
+ library->remove_sample("default");
+
library->add_sample("default",sample);
}
diff --git a/tools/editor/plugins/script_editor_plugin.cpp b/tools/editor/plugins/script_editor_plugin.cpp
index 10e4fc8475..fc5f552723 100644
--- a/tools/editor/plugins/script_editor_plugin.cpp
+++ b/tools/editor/plugins/script_editor_plugin.cpp
@@ -43,6 +43,28 @@
/*** SCRIPT EDITOR ****/
+static bool _can_open_in_editor(Script* p_script) {
+
+ String path = p_script->get_path();
+
+ if (path.find("::")!=-1) {
+ //refuse handling this if it can't be edited
+
+ bool valid=false;
+ for(int i=0;i<EditorNode::get_singleton()->get_editor_data().get_edited_scene_count();i++) {
+ if (path.begins_with(EditorNode::get_singleton()->get_editor_data().get_scene_path(i))) {
+ valid=true;
+ break;
+ }
+ }
+
+ return valid;
+ }
+
+ return true;
+}
+
+
class EditorScriptCodeCompletionCache : public ScriptCodeCompletionCache {
@@ -290,6 +312,8 @@ void ScriptTextEditor::_load_theme_settings() {
get_text_edit()->add_color_override("completion_background_color", EDITOR_DEF("text_editor/completion_background_color", Color(0,0,0,0)));
get_text_edit()->add_color_override("completion_selected_color", EDITOR_DEF("text_editor/completion_selected_color", Color::html("434244")));
get_text_edit()->add_color_override("completion_existing_color", EDITOR_DEF("text_editor/completion_existing_color", Color::html("21dfdfdf")));
+ get_text_edit()->add_color_override("completion_scroll_color", EDITOR_DEF("text_editor/completion_scroll_color", Color::html("ffffff")));
+ get_text_edit()->add_color_override("completion_font_color", EDITOR_DEF("text_editor/completion_font_color", Color::html("aaaaaa")));
get_text_edit()->add_color_override("font_color",EDITOR_DEF("text_editor/text_color",Color(0,0,0)));
get_text_edit()->add_color_override("line_number_color",EDITOR_DEF("text_editor/line_number_color",Color(0,0,0)));
get_text_edit()->add_color_override("caret_color",EDITOR_DEF("text_editor/caret_color",Color(0,0,0)));
@@ -585,7 +609,6 @@ void ScriptTextEditor::_code_complete_script(const String& p_code, List<String>*
Error err = script->get_language()->complete_code(p_code,script->get_path().get_base_dir(),base,r_options,hint);
if (hint!="") {
get_text_edit()->set_code_hint(hint);
- print_line("hint: "+hint.replace(String::chr(0xFFFF),"|"));
}
}
@@ -748,9 +771,9 @@ void ScriptEditor::_go_to_tab(int p_idx) {
_update_script_colors();
}
-void ScriptEditor::_close_current_tab() {
+void ScriptEditor::_close_tab(int p_idx) {
- int selected = tab_container->get_current_tab();
+ int selected = p_idx;
if (selected<0 || selected>=tab_container->get_child_count())
return;
@@ -796,6 +819,11 @@ void ScriptEditor::_close_current_tab() {
_update_script_names();
EditorNode::get_singleton()->save_layout();
+}
+
+void ScriptEditor::_close_current_tab() {
+
+ _close_tab(tab_container->get_current_tab());
}
@@ -848,6 +876,15 @@ void ScriptEditor::_reload_scripts(){
}
+ 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) {
+ continue;
+ }
+
+
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() );
@@ -1682,6 +1719,33 @@ void ScriptEditor::_notification(int p_what) {
}
+
+void ScriptEditor::close_builtin_scripts_from_scene(const String& p_scene) {
+
+
+
+ for(int i=0;i<tab_container->get_child_count();i++) {
+
+ ScriptTextEditor *ste = tab_container->get_child(i)->cast_to<ScriptTextEditor>();
+
+ if (ste) {
+
+ Ref<Script> script = ste->get_edited_script();
+ if (!script.is_valid())
+ continue;
+
+ if (script->get_path().find("::")!=-1 && script->get_path().begins_with(p_scene)) { //is an internal script and belongs to scene being closed
+ _close_tab(i);
+ i--;
+
+ }
+ }
+
+ }
+
+
+}
+
void ScriptEditor::edited_scene_changed() {
_update_modified_scripts_for_external_editor();
@@ -2060,11 +2124,18 @@ void ScriptEditor::_update_script_names() {
}
+
+
void ScriptEditor::edit(const Ref<Script>& p_script) {
if (p_script.is_null())
return;
+ // refuse to open built-in if scene is not loaded
+
+
+
+
// see if already has it
bool open_dominant = EditorSettings::get_singleton()->get("text_editor/open_dominant_script_on_scene_change");
@@ -2316,6 +2387,22 @@ void ScriptEditor::_script_split_dragged(float) {
EditorNode::get_singleton()->save_layout();
}
+void ScriptEditor::_unhandled_input(const InputEvent& p_event) {
+ if (p_event.key.pressed || !is_visible()) return;
+ if (ED_IS_SHORTCUT("script_editor/next_script", p_event)) {
+ int next_tab = script_list->get_current() + 1;
+ next_tab %= script_list->get_item_count();
+ _go_to_tab(script_list->get_item_metadata(next_tab));
+ _update_script_names();
+ }
+ if (ED_IS_SHORTCUT("script_editor/prev_script", p_event)) {
+ int next_tab = script_list->get_current() - 1;
+ next_tab = next_tab >= 0 ? next_tab : script_list->get_item_count() - 1;
+ _go_to_tab(script_list->get_item_metadata(next_tab));
+ _update_script_names();
+ }
+}
+
void ScriptEditor::set_window_layout(Ref<ConfigFile> p_layout) {
if (!bool(EDITOR_DEF("text_editor/restore_scripts_on_load",true))) {
@@ -2335,6 +2422,8 @@ void ScriptEditor::set_window_layout(Ref<ConfigFile> p_layout) {
for(int i=0;i<scripts.size();i++) {
String path = scripts[i];
+ if (!FileAccess::exists(path))
+ continue;
Ref<Script> scr = ResourceLoader::load(path);
if (scr.is_valid()) {
edit(scr);
@@ -2512,7 +2601,7 @@ void ScriptEditor::set_scene_root_script( Ref<Script> p_script ) {
if (bool(EditorSettings::get_singleton()->get("external_editor/use_external_editor")))
return;
- if (open_dominant && p_script.is_valid()) {
+ if (open_dominant && p_script.is_valid() && _can_open_in_editor(p_script.ptr())) {
edit(p_script);
}
}
@@ -2598,6 +2687,7 @@ void ScriptEditor::_bind_methods() {
ObjectTypeDB::bind_method("_history_forward",&ScriptEditor::_history_forward);
ObjectTypeDB::bind_method("_history_back",&ScriptEditor::_history_back);
ObjectTypeDB::bind_method("_live_auto_reload_running_scripts",&ScriptEditor::_live_auto_reload_running_scripts);
+ ObjectTypeDB::bind_method("_unhandled_input",&ScriptEditor::_unhandled_input);
}
@@ -2631,6 +2721,10 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
tab_container->set_h_size_flags(SIZE_EXPAND_FILL);
+ ED_SHORTCUT("script_editor/next_script", TTR("Next script"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_GREATER);
+ ED_SHORTCUT("script_editor/prev_script", TTR("Previous script"), KEY_MASK_CMD | KEY_LESS);
+ set_process_unhandled_input(true);
+
file_menu = memnew( MenuButton );
menu_hb->add_child(file_menu);
file_menu->set_text(TTR("File"));
@@ -2895,6 +2989,16 @@ void ScriptEditorPlugin::edit(Object *p_object) {
bool ScriptEditorPlugin::handles(Object *p_object) const {
+ if (p_object->cast_to<Script>()) {
+
+ bool valid = _can_open_in_editor(p_object->cast_to<Script>());
+
+ if (!valid) { //user tried to open it by clicking
+ EditorNode::get_singleton()->show_warning(TTR("Built-in scripts can only be edited when the scene they belong to is loaded"));
+ }
+ return valid;
+ }
+
return p_object->is_type("Script");
}
diff --git a/tools/editor/plugins/script_editor_plugin.h b/tools/editor/plugins/script_editor_plugin.h
index 0636190a41..2e6e2c035c 100644
--- a/tools/editor/plugins/script_editor_plugin.h
+++ b/tools/editor/plugins/script_editor_plugin.h
@@ -234,6 +234,8 @@ class ScriptEditor : public VBoxContainer {
bool _test_script_times_on_disk(Ref<Script> p_for_script=Ref<Script>());
+ void _close_tab(int p_idx);
+
void _close_current_tab();
bool grab_focus_block;
@@ -279,6 +281,8 @@ class ScriptEditor : public VBoxContainer {
void _script_split_dragged(float);
+ void _unhandled_input(const InputEvent& p_event);
+
void _history_forward();
void _history_back();
@@ -329,6 +333,8 @@ public:
virtual void edited_scene_changed();
+ void close_builtin_scripts_from_scene(const String& p_scene);
+
ScriptEditorDebugger *get_debugger() { return debugger; }
void set_live_auto_reload_running_scripts(bool p_enabled);
diff --git a/tools/editor/plugins/shader_editor_plugin.cpp b/tools/editor/plugins/shader_editor_plugin.cpp
index 76042c3028..9ef84af260 100644
--- a/tools/editor/plugins/shader_editor_plugin.cpp
+++ b/tools/editor/plugins/shader_editor_plugin.cpp
@@ -81,6 +81,8 @@ void ShaderTextEditor::_load_theme_settings() {
get_text_edit()->add_color_override("completion_background_color", EDITOR_DEF("text_editor/completion_background_color", Color(0,0,0,0)));
get_text_edit()->add_color_override("completion_selected_color", EDITOR_DEF("text_editor/completion_selected_color", Color::html("434244")));
get_text_edit()->add_color_override("completion_existing_color", EDITOR_DEF("text_editor/completion_existing_color", Color::html("21dfdfdf")));
+ get_text_edit()->add_color_override("completion_scroll_color", EDITOR_DEF("text_editor/completion_scroll_color", Color::html("ffffff")));
+ get_text_edit()->add_color_override("completion_font_color", EDITOR_DEF("text_editor/completion_font_color", Color::html("aaaaaa")));
get_text_edit()->add_color_override("font_color",EDITOR_DEF("text_editor/text_color",Color(0,0,0)));
get_text_edit()->add_color_override("line_number_color",EDITOR_DEF("text_editor/line_number_color",Color(0,0,0)));
get_text_edit()->add_color_override("caret_color",EDITOR_DEF("text_editor/caret_color",Color(0,0,0)));
@@ -118,9 +120,10 @@ void ShaderTextEditor::_load_theme_settings() {
get_text_edit()->add_color_region("/*","*/",comment_color,false);
get_text_edit()->add_color_region("//","",comment_color,false);
- //colorize strings
+
+ /*//colorize strings
Color string_color = EDITOR_DEF("text_editor/string_color",Color::hex(0x6b6f00ff));
- /*
+
List<String> strings;
shader->get_shader_mode()->get_string_delimiters(&strings);
@@ -499,7 +502,7 @@ ShaderEditor::ShaderEditor() {
edit_menu->set_pos(Point2(5,-1));
edit_menu->set_text(TTR("Edit"));
edit_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/undo", TTR("Undo"), KEY_MASK_CMD|KEY_Z), EDIT_UNDO);
- edit_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/redo", TTR("Redo"), KEY_MASK_CMD|KEY_MASK_SHIFT|KEY_Z), EDIT_REDO);
+ edit_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/redo", TTR("Redo"), KEY_MASK_CMD|KEY_Y), EDIT_REDO);
edit_menu->get_popup()->add_separator();
edit_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/cut", TTR("Cut"), KEY_MASK_CMD|KEY_X), EDIT_CUT);
edit_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/copy", TTR("Copy"), KEY_MASK_CMD|KEY_C), EDIT_COPY);
@@ -519,7 +522,7 @@ ShaderEditor::ShaderEditor() {
search_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/replace", TTR("Replace.."), KEY_MASK_CMD|KEY_R), SEARCH_REPLACE);
search_menu->get_popup()->add_separator();
// search_menu->get_popup()->add_item("Locate Symbol..",SEARCH_LOCATE_SYMBOL,KEY_MASK_CMD|KEY_K);
- search_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/goto_line", TTR("Goto Line.."), KEY_MASK_CMD|KEY_G), SEARCH_GOTO_LINE);
+ search_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/goto_line", TTR("Goto Line.."), KEY_MASK_CMD|KEY_L), SEARCH_GOTO_LINE);
search_menu->get_popup()->connect("item_pressed", this,"_menu_option");
diff --git a/tools/editor/plugins/shader_graph_editor_plugin.cpp b/tools/editor/plugins/shader_graph_editor_plugin.cpp
index d567c8e9b3..375220051c 100644
--- a/tools/editor/plugins/shader_graph_editor_plugin.cpp
+++ b/tools/editor/plugins/shader_graph_editor_plugin.cpp
@@ -176,7 +176,9 @@ void GraphColorRampEdit::_input_event(const InputEvent& p_event) {
void GraphColorRampEdit::_notification(int p_what){
if (p_what==NOTIFICATION_ENTER_TREE) {
- picker->connect("color_changed",this,"_color_changed");
+ if (!picker->is_connected("color_changed",this,"_color_changed")) {
+ picker->connect("color_changed",this,"_color_changed");
+ }
}
if (p_what==NOTIFICATION_DRAW) {
@@ -184,9 +186,8 @@ void GraphColorRampEdit::_notification(int p_what){
Point prev;
prev.offset=0;
prev.color=Color(0,0,0);
- int w = get_size().x;
- int h = get_size().y;
+ int h = get_size().y;
int total_w = get_size().width-get_size().height-3;
for(int i=-1;i<points.size();i++) {
diff --git a/tools/editor/plugins/spatial_editor_plugin.cpp b/tools/editor/plugins/spatial_editor_plugin.cpp
index 8d72178f23..a70df78697 100644
--- a/tools/editor/plugins/spatial_editor_plugin.cpp
+++ b/tools/editor/plugins/spatial_editor_plugin.cpp
@@ -53,8 +53,6 @@
void SpatialEditorViewport::_update_camera() {
if (orthogonal) {
- Size2 size = get_size();
- Size2 vpsize = Point2(cursor.distance*size.get_aspect(), cursor.distance / size.get_aspect());
//camera->set_orthogonal(size.width*cursor.distance,get_znear(),get_zfar());
camera->set_orthogonal(2 * cursor.distance, 0.1, 8192);
}
@@ -79,21 +77,30 @@ void SpatialEditorViewport::_update_camera() {
String SpatialEditorGizmo::get_handle_name(int p_idx) const {
+ if (get_script_instance() && get_script_instance()->has_method("get_handle_name"))
+ return get_script_instance()->call("get_handle_name", p_idx);
+
return "";
}
Variant SpatialEditorGizmo::get_handle_value(int p_idx) const{
+ if (get_script_instance() && get_script_instance()->has_method("get_handle_value"))
+ return get_script_instance()->call("get_handle_value", p_idx);
+
return Variant();
}
void SpatialEditorGizmo::set_handle(int p_idx,Camera *p_camera, const Point2& p_point) {
+ if (get_script_instance() && get_script_instance()->has_method("set_handle"))
+ get_script_instance()->call("set_handle", p_idx, p_camera, p_point);
}
void SpatialEditorGizmo::commit_handle(int p_idx,const Variant& p_restore,bool p_cancel){
-
+ if (get_script_instance() && get_script_instance()->has_method("commit_handle"))
+ get_script_instance()->call("commit_handle", p_idx, p_restore, p_cancel);
}
bool SpatialEditorGizmo::intersect_frustum(const Camera *p_camera,const Vector<Plane> &p_frustum) {
@@ -276,10 +283,6 @@ ObjectID SpatialEditorViewport::_select_ray(const Point2& p_pos, bool p_append,b
r_includes_current=false;
List<_RayResult> results;
- Vector3 cn=_get_camera_normal();
- Plane cplane(pos,cn.normalized());
-
- float min_d=1e20;
for (int i=0;i<instances.size();i++) {
@@ -649,21 +652,8 @@ bool SpatialEditorViewport::_gizmo_select(const Vector2& p_screenpos,bool p_hili
Vector3 ray_pos=_get_ray_pos( Vector2( p_screenpos.x, p_screenpos.y ) );
Vector3 ray=_get_ray( Vector2( p_screenpos.x, p_screenpos.y ) );
- Vector3 cn=_get_camera_normal();
- Plane cplane(ray_pos,cn.normalized());
-
Transform gt = spatial_editor->get_gizmo_transform();
float gs=gizmo_scale;
- /*
- if (orthogonal) {
- gs= cursor.distance/surface->get_size().get_aspect();
-
- } else {
- gs = cplane.distance_to(gt.origin);
- }
-
- gs*=GIZMO_SCALE_DEFAULT;
-*/
if (spatial_editor->get_tool_mode()==SpatialEditor::TOOL_MODE_SELECT || spatial_editor->get_tool_mode()==SpatialEditor::TOOL_MODE_MOVE) {
@@ -1268,16 +1258,6 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) {
if (_edit.gizmo.is_valid()) {
- Plane plane=Plane(_edit.gizmo_initial_pos,_get_camera_normal());
-
-
- Vector3 ray_pos=_get_ray_pos( Vector2( m.x, m.y ) );
- Vector3 ray=_get_ray( Vector2( m.x, m.y ) );
-
- //Vector3 intersection;
- //if (!plane.intersects_ray(ray_pos,ray,&intersection))
- // break;
-
_edit.gizmo->set_handle(_edit.gizmo_handle,camera,Vector2(m.x,m.y));
Variant v = _edit.gizmo->get_handle_value(_edit.gizmo_handle);
String n = _edit.gizmo->get_handle_name(_edit.gizmo_handle);
@@ -1658,136 +1638,89 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) {
default: {}
}
} break;
-
case InputEvent::KEY: {
-
const InputEventKey &k = p_event.key;
if (!k.pressed)
break;
- switch(k.scancode) {
-
- case KEY_S: {
-
- if (_edit.mode!=TRANSFORM_NONE) {
-
- _edit.snap=true;
- }
- } break;
- case KEY_7:
- case KEY_KP_7: {
- bool emulate_numpad = EditorSettings::get_singleton()->get("3d_editor/emulate_numpad");
- if (!emulate_numpad && k.scancode==KEY_7)
- return;
- cursor.y_rot=0;
- if (k.mod.shift) {
- cursor.x_rot=-Math_PI/2.0;
- set_message(TTR("Bottom View."),2);
- name=TTR("Bottom");
- _update_name();
-
- } else {
- cursor.x_rot=Math_PI/2.0;
- set_message(TTR("Top View."),2);
- name=TTR("Top");
- _update_name();
- }
- } break;
- case KEY_1:
- case KEY_KP_1: {
- bool emulate_numpad = EditorSettings::get_singleton()->get("3d_editor/emulate_numpad");
- if (!emulate_numpad && k.scancode==KEY_1)
- return;
- cursor.x_rot=0;
- if (k.mod.shift) {
- cursor.y_rot=Math_PI;
- set_message(TTR("Rear View."),2);
- name=TTR("Rear");
- _update_name();
-
- } else {
- cursor.y_rot=0;
- set_message(TTR("Front View."),2);
- name=TTR("Front");
- _update_name();
- }
-
- } break;
- case KEY_3:
- case KEY_KP_3: {
- bool emulate_numpad = EditorSettings::get_singleton()->get("3d_editor/emulate_numpad");
- if (!emulate_numpad && k.scancode==KEY_3)
- return;
- cursor.x_rot=0;
- if (k.mod.shift) {
- cursor.y_rot=Math_PI/2.0;
- set_message(TTR("Left View."),2);
- name=TTR("Left");
- _update_name();
- } else {
- cursor.y_rot=-Math_PI/2.0;
- set_message(TTR("Right View."),2);
- name=TTR("Right");
- _update_name();
- }
-
- } break;
- case KEY_5:
- case KEY_KP_5: {
- bool emulate_numpad = EditorSettings::get_singleton()->get("3d_editor/emulate_numpad");
- if (!emulate_numpad && k.scancode==KEY_5)
- return;
-
- //orthogonal = !orthogonal;
- _menu_option(orthogonal?VIEW_PERSPECTIVE:VIEW_ORTHOGONAL);
- _update_name();
-
-
- } break;
- case KEY_K: {
-
- if (!get_selected_count() || _edit.mode!=TRANSFORM_NONE)
- break;
-
- if (!AnimationPlayerEditor::singleton->get_key_editor()->has_keying()) {
- set_message(TTR("Keying is disabled (no key inserted)."));
- break;
- }
-
- List<Node*> &selection = editor_selection->get_selected_node_list();
-
- for(List<Node*>::Element *E=selection.front();E;E=E->next()) {
-
- Spatial *sp = E->get()->cast_to<Spatial>();
- if (!sp)
- continue;
-
- emit_signal("transform_key_request",sp,"",sp->get_transform());
- }
-
-
- set_message(TTR("Animation Key Inserted."));
+ if (ED_IS_SHORTCUT("spatial_editor/snap", p_event)) {
+ if (_edit.mode != TRANSFORM_NONE) {
+ _edit.snap=true;
+ }
+ }
+ if (ED_IS_SHORTCUT("spatial_editor/bottom_view", p_event)) {
+ cursor.y_rot = 0;
+ cursor.x_rot = -Math_PI/2.0;
+ set_message(TTR("Bottom View."),2);
+ name = TTR("Bottom");
+ _update_name();
+ }
+ if (ED_IS_SHORTCUT("spatial_editor/top_view", p_event)) {
+ cursor.y_rot = 0;
+ cursor.x_rot = Math_PI/2.0;
+ set_message(TTR("Top View."),2);
+ name = TTR("Top");
+ _update_name();
+ }
+ if (ED_IS_SHORTCUT("spatial_editor/rear_view", p_event)) {
+ cursor.x_rot = 0;
+ cursor.y_rot = Math_PI;
+ set_message(TTR("Rear View."),2);
+ name = TTR("Rear");
+ _update_name();
+ }
+ if (ED_IS_SHORTCUT("spatial_editor/front_view", p_event)) {
+ cursor.x_rot = 0;
+ cursor.y_rot=0;
+ set_message(TTR("Front View."),2);
+ name=TTR("Front");
+ _update_name();
+ }
+ if (ED_IS_SHORTCUT("spatial_editor/left_view", p_event)) {
+ cursor.x_rot=0;
+ cursor.y_rot = Math_PI/2.0;
+ set_message(TTR("Left View."),2);
+ name = TTR("Left");
+ _update_name();
+ }
+ if (ED_IS_SHORTCUT("spatial_editor/right_view", p_event)) {
+ cursor.x_rot=0;
+ cursor.y_rot = -Math_PI/2.0;
+ set_message(TTR("Right View."),2);
+ name = TTR("Right");
+ _update_name();
+ }
+ if (ED_IS_SHORTCUT("spatial_editor/switch_perspective_orthogonal", p_event)) {
+ _menu_option(orthogonal?VIEW_PERSPECTIVE:VIEW_ORTHOGONAL);
+ _update_name();
+ }
+ if (ED_IS_SHORTCUT("spatial_editor/insert_anim_key", p_event)) {
+ if (!get_selected_count() || _edit.mode!=TRANSFORM_NONE)
+ break;
+ if (!AnimationPlayerEditor::singleton->get_key_editor()->has_keying()) {
+ set_message(TTR("Keying is disabled (no key inserted)."));
+ break;
+ }
- } break;
+ List<Node*> &selection = editor_selection->get_selected_node_list();
- case KEY_F: {
+ for(List<Node*>::Element *E=selection.front();E;E=E->next()) {
- if (k.pressed && k.mod.shift && k.mod.control) {
- _menu_option(VIEW_ALIGN_SELECTION_WITH_VIEW);
- } else if (k.pressed) {
- _menu_option(VIEW_CENTER_TO_SELECTION);
- }
+ Spatial *sp = E->get()->cast_to<Spatial>();
+ if (!sp)
+ continue;
- } break;
+ emit_signal("transform_key_request",sp,"",sp->get_transform());
+ }
- case KEY_SPACE: {
- if (!k.pressed)
- emit_signal("toggle_maximize_view", this);
- } break;
+ set_message(TTR("Animation Key Inserted."));
}
+ if (k.scancode == KEY_SPACE) {
+ if (!k.pressed) emit_signal("toggle_maximize_view", this);
+ }
} break;
@@ -1855,16 +1788,6 @@ void SpatialEditorViewport::_notification(int p_what) {
continue;
- /*
- ??
- if (!se->poly_instance.is_valid())
- continue;
- if (!ObjectDB::get_instance( E->key() )) {
- VisualServer::get_singleton()->free( se->poly_instance );
- se->poly_instance=RID();
- continue;
- }
- */
VisualInstance *vi=sp->cast_to<VisualInstance>();
@@ -1902,35 +1825,6 @@ void SpatialEditorViewport::_notification(int p_what) {
surface->update();
}
- //grid
- Vector3 grid_cam_axis=_get_camera_normal();
- /*
- for(int i=0;i<3;i++) {
-
-
- Vector3 axis;
- axis[i]=1;
-
- bool should_be_visible= grid_enabled && (grid_enable[i] || (Math::abs(grid_cam_axis.dot(axis))>0.99 && orthogonal));
-
- if (should_be_visible!=grid_visible[i]) {
-
- VisualServer::get_singleton()->instance_geometry_set_flag(grid_instance[i],VS::INSTANCE_FLAG_VISIBLE,should_be_visible);
- grid_visible[i]=should_be_visible;
- }
- }
-
- if (last_grid_snap!=spatial_editor->get_translate_snap()) {
-
-
- last_grid_snap=spatial_editor->get_translate_snap()
- Transform gridt;
- gridt.basis.scale(Vector3(last_grid_snap,last_grid_snap,last_grid_snap));
- for(int i=0;i<3;i++)
- VisualServer::get_singleton()->instance_set_transform(grid_instance[i],gridt);
-
- }*/
-
}
if (p_what==NOTIFICATION_ENTER_TREE) {
@@ -2470,29 +2364,28 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed
surface->add_child(view_menu);
view_menu->set_pos( Point2(4,4));
view_menu->set_self_opacity(0.5);
-
- view_menu->get_popup()->add_item(TTR("Top (Num7)"),VIEW_TOP);
- view_menu->get_popup()->add_item(TTR("Bottom (Shift+Num7)"),VIEW_BOTTOM);
- view_menu->get_popup()->add_item(TTR("Left (Num3)"),VIEW_LEFT);
- view_menu->get_popup()->add_item(TTR("Right (Shift+Num3)"),VIEW_RIGHT);
- view_menu->get_popup()->add_item(TTR("Front (Num1)"),VIEW_FRONT);
- view_menu->get_popup()->add_item(TTR("Rear (Shift+Num1)"),VIEW_REAR);
+ view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/top_view"), VIEW_TOP);
+ view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/bottom_view"), VIEW_BOTTOM);
+ view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/left_view"), VIEW_LEFT);
+ view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/right_view"), VIEW_RIGHT);
+ view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/front_view"), VIEW_FRONT);
+ view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/rear_view"), VIEW_REAR);
view_menu->get_popup()->add_separator();
- view_menu->get_popup()->add_check_item(TTR("Perspective (Num5)"),VIEW_PERSPECTIVE);
- view_menu->get_popup()->add_check_item(TTR("Orthogonal (Num5)"),VIEW_ORTHOGONAL);
+ view_menu->get_popup()->add_check_item(TTR("Perspective") + " (" + ED_GET_SHORTCUT("spatial_editor/switch_perspective_orthogonal")->get_as_text() + ")", VIEW_PERSPECTIVE);
+ view_menu->get_popup()->add_check_item(TTR("Orthogonal") + " (" + ED_GET_SHORTCUT("spatial_editor/switch_perspective_orthogonal")->get_as_text() + ")", VIEW_ORTHOGONAL);
view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_PERSPECTIVE),true);
view_menu->get_popup()->add_separator();
- view_menu->get_popup()->add_check_item(TTR("Environment"),VIEW_ENVIRONMENT);
+ view_menu->get_popup()->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_environment", TTR("Environment")), VIEW_ENVIRONMENT);
view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(VIEW_ENVIRONMENT),true);
view_menu->get_popup()->add_separator();
- view_menu->get_popup()->add_check_item(TTR("Audio Listener"),VIEW_AUDIO_LISTENER);
+ view_menu->get_popup()->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_audio_listener", TTR("Audio Listener")), VIEW_AUDIO_LISTENER);
view_menu->get_popup()->add_separator();
- view_menu->get_popup()->add_check_item(TTR("Gizmos"),VIEW_GIZMOS);
+ view_menu->get_popup()->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_gizmos", TTR("Gizmos")),VIEW_GIZMOS);
view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(VIEW_GIZMOS),true);
view_menu->get_popup()->add_separator();
- view_menu->get_popup()->add_item(TTR("Selection (F)"),VIEW_CENTER_TO_SELECTION);
- view_menu->get_popup()->add_item(TTR("Align with view (Ctrl+Shift+F)"),VIEW_ALIGN_SELECTION_WITH_VIEW);
+ view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/focus_selection"), VIEW_CENTER_TO_SELECTION);
+ view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/align_selection_with_view"), VIEW_ALIGN_SELECTION_WITH_VIEW);
view_menu->get_popup()->connect("item_pressed",this,"_menu_option");
preview_camera = memnew( Button );
@@ -2613,16 +2506,9 @@ Object *SpatialEditor::_get_editor_data(Object *p_what) {
si->sbox_instance=VisualServer::get_singleton()->instance_create2(selection_box->get_rid(),sp->get_world()->get_scenario());
VS::get_singleton()->instance_geometry_set_cast_shadows_setting(si->sbox_instance, VS::SHADOW_CASTING_SETTING_OFF);
- RID inst = sp->call("_get_visual_instance_rid");
-
-// if (inst.is_valid())
-// si->aabb = VisualServer::get_singleton()->instance_get_base_aabb(inst);
-
-
if (get_tree()->is_editor_hint())
editor->call("edit_node",sp);
-
return si;
}
@@ -3951,6 +3837,19 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
hbc_menu->add_child(vs);
+ ED_SHORTCUT("spatial_editor/bottom_view", TTR("Bottom View"), KEY_MASK_ALT+KEY_KP_7);
+ ED_SHORTCUT("spatial_editor/top_view", TTR("Top View"), KEY_KP_7);
+ ED_SHORTCUT("spatial_editor/rear_view", TTR("Rear View"), KEY_MASK_ALT+KEY_KP_1);
+ ED_SHORTCUT("spatial_editor/front_view", TTR("Front View"), KEY_KP_1);
+ ED_SHORTCUT("spatial_editor/left_view", TTR("Left View"), KEY_MASK_ALT+KEY_KP_3);
+ ED_SHORTCUT("spatial_editor/right_view", TTR("Right View"), KEY_KP_3);
+ ED_SHORTCUT("spatial_editor/switch_perspective_orthogonal", TTR("Switch Perspective/Orthogonal view"), KEY_KP_5);
+ ED_SHORTCUT("spatial_editor/snap", TTR("Snap"), KEY_S);
+ ED_SHORTCUT("spatial_editor/insert_anim_key", TTR("Insert Animation Key"), KEY_K);
+ ED_SHORTCUT("spatial_editor/focus_selection", TTR("Focus Selection"), KEY_F);
+ ED_SHORTCUT("spatial_editor/align_selection_with_view", TTR("Align Selection With View"), KEY_MASK_ALT+KEY_MASK_CMD+KEY_F);
+
+
PopupMenu *p;
transform_menu = memnew( MenuButton );
@@ -3958,13 +3857,13 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
hbc_menu->add_child( transform_menu );
p = transform_menu->get_popup();
- p->add_check_item(TTR("Use Snap"),MENU_TRANSFORM_USE_SNAP);
- p->add_item(TTR("Configure Snap.."),MENU_TRANSFORM_CONFIGURE_SNAP);
+ p->add_check_shortcut(ED_SHORTCUT("spatial_editor/use_snap", TTR("Use Snap")), MENU_TRANSFORM_USE_SNAP);
+ p->add_shortcut(ED_SHORTCUT("spatial_editor/configure_snap", TTR("Configure Snap..")), MENU_TRANSFORM_CONFIGURE_SNAP);
p->add_separator();
- p->add_check_item(TTR("Local Coords"),MENU_TRANSFORM_LOCAL_COORDS);
+ p->add_check_shortcut(ED_SHORTCUT("spatial_editor/local_coords", TTR("Local Coords")), MENU_TRANSFORM_LOCAL_COORDS);
//p->set_item_checked(p->get_item_count()-1,true);
p->add_separator();
- p->add_item(TTR("Transform Dialog.."),MENU_TRANSFORM_DIALOG);
+ p->add_shortcut(ED_SHORTCUT("spatial_editor/transform_dialog", TTR("Transform Dialog..")), MENU_TRANSFORM_DIALOG);
p->connect("item_pressed", this,"_menu_item_pressed");
@@ -3975,27 +3874,27 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
p = view_menu->get_popup();
- p->add_check_item(TTR("Use Default Light"),MENU_VIEW_USE_DEFAULT_LIGHT);
- p->add_check_item(TTR("Use Default sRGB"),MENU_VIEW_USE_DEFAULT_SRGB);
+ p->add_check_shortcut(ED_SHORTCUT("spatial_editor/use_default_light", TTR("Use Default Light")), MENU_VIEW_USE_DEFAULT_LIGHT);
+ p->add_check_shortcut(ED_SHORTCUT("spatial_editor/use_default_srgb", TTR("Use Default sRGB")), MENU_VIEW_USE_DEFAULT_SRGB);
p->add_separator();
- p->add_check_item(TTR("1 Viewport"),MENU_VIEW_USE_1_VIEWPORT,KEY_MASK_CMD+KEY_1);
- p->add_check_item(TTR("2 Viewports"),MENU_VIEW_USE_2_VIEWPORTS,KEY_MASK_CMD+KEY_2);
- p->add_check_item(TTR("2 Viewports (Alt)"),MENU_VIEW_USE_2_VIEWPORTS_ALT,KEY_MASK_SHIFT+KEY_MASK_CMD+KEY_2);
- p->add_check_item(TTR("3 Viewports"),MENU_VIEW_USE_3_VIEWPORTS,KEY_MASK_CMD+KEY_3);
- p->add_check_item(TTR("3 Viewports (Alt)"),MENU_VIEW_USE_3_VIEWPORTS_ALT,KEY_MASK_SHIFT+KEY_MASK_CMD+KEY_3);
- p->add_check_item(TTR("4 Viewports"),MENU_VIEW_USE_4_VIEWPORTS,KEY_MASK_CMD+KEY_4);
+ p->add_check_shortcut(ED_SHORTCUT("spatial_editor/1_viewport", TTR("1 Viewport"), KEY_MASK_CMD+KEY_1), MENU_VIEW_USE_1_VIEWPORT);
+ p->add_check_shortcut(ED_SHORTCUT("spatial_editor/2_viewports", TTR("2 Viewports"), KEY_MASK_CMD+KEY_2), MENU_VIEW_USE_2_VIEWPORTS);
+ p->add_check_shortcut(ED_SHORTCUT("spatial_editor/2_viewports_alt", TTR("2 Viewports (Alt)"), KEY_MASK_ALT+KEY_MASK_CMD+KEY_2), MENU_VIEW_USE_2_VIEWPORTS_ALT);
+ p->add_check_shortcut(ED_SHORTCUT("spatial_editor/3_viewports", TTR("3 Viewports"),KEY_MASK_CMD+KEY_3), MENU_VIEW_USE_3_VIEWPORTS);
+ p->add_check_shortcut(ED_SHORTCUT("spatial_editor/3_viewports_alt", TTR("3 Viewports (Alt)"), KEY_MASK_ALT+KEY_MASK_CMD+KEY_3), MENU_VIEW_USE_3_VIEWPORTS_ALT);
+ p->add_check_shortcut(ED_SHORTCUT("spatial_editor/4_viewports", TTR("4 Viewports"), KEY_MASK_CMD+KEY_4), MENU_VIEW_USE_4_VIEWPORTS);
p->add_separator();
- p->add_check_item(TTR("Display Normal"),MENU_VIEW_DISPLAY_NORMAL);
- p->add_check_item(TTR("Display Wireframe"),MENU_VIEW_DISPLAY_WIREFRAME);
- p->add_check_item(TTR("Display Overdraw"),MENU_VIEW_DISPLAY_OVERDRAW);
- p->add_check_item(TTR("Display Shadeless"),MENU_VIEW_DISPLAY_SHADELESS);
+ p->add_check_shortcut(ED_SHORTCUT("spatial_editor/display_normal", TTR("Display Normal")), MENU_VIEW_DISPLAY_NORMAL);
+ p->add_check_shortcut(ED_SHORTCUT("spatial_editor/display_wireframe", TTR("Display Wireframe")), MENU_VIEW_DISPLAY_WIREFRAME);
+ p->add_check_shortcut(ED_SHORTCUT("spatial_editor/display_overdraw", TTR("Display Overdraw")), MENU_VIEW_DISPLAY_OVERDRAW);
+ p->add_check_shortcut(ED_SHORTCUT("spatial_editor/display_shadeless", TTR("Display Shadeless")), MENU_VIEW_DISPLAY_SHADELESS);
p->add_separator();
- p->add_check_item(TTR("View Origin"),MENU_VIEW_ORIGIN);
- p->add_check_item(TTR("View Grid"),MENU_VIEW_GRID);
+ p->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_origin", TTR("View Origin")), MENU_VIEW_ORIGIN);
+ p->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_grid", TTR("View Grid")), MENU_VIEW_GRID);
p->add_separator();
- p->add_item(TTR("Settings"),MENU_VIEW_CAMERA_SETTINGS);
+ p->add_shortcut(ED_SHORTCUT("spatial_editor/settings", TTR("Settings")), MENU_VIEW_CAMERA_SETTINGS);
p->set_item_checked( p->get_item_index(MENU_VIEW_USE_DEFAULT_LIGHT), true );
diff --git a/tools/editor/plugins/sprite_frames_editor_plugin.cpp b/tools/editor/plugins/sprite_frames_editor_plugin.cpp
index 4f59287994..e29a0c8d52 100644
--- a/tools/editor/plugins/sprite_frames_editor_plugin.cpp
+++ b/tools/editor/plugins/sprite_frames_editor_plugin.cpp
@@ -31,7 +31,7 @@
#include "io/resource_loader.h"
#include "globals.h"
#include "tools/editor/editor_settings.h"
-
+#include "scene/3d/sprite_3d.h"
@@ -355,6 +355,35 @@ void SpriteFramesEditor::_animation_select() {
}
+
+static void _find_anim_sprites(Node* p_node,List<Node*> *r_nodes,Ref<SpriteFrames> p_sfames) {
+
+ Node *edited = EditorNode::get_singleton()->get_edited_scene();
+ if (!edited)
+ return;
+ if (p_node!=edited && p_node->get_owner()!=edited)
+ return;
+
+ {
+ AnimatedSprite *as = p_node->cast_to<AnimatedSprite>();
+ if (as && as->get_sprite_frames()==p_sfames) {
+ r_nodes->push_back(p_node);
+ }
+ }
+
+ {
+ AnimatedSprite3D *as = p_node->cast_to<AnimatedSprite3D>();
+ if (as && as->get_sprite_frames()==p_sfames) {
+ r_nodes->push_back(p_node);
+ }
+ }
+
+ for(int i=0;i<p_node->get_child_count();i++) {
+ _find_anim_sprites(p_node->get_child(i),r_nodes,p_sfames);
+ }
+
+}
+
void SpriteFramesEditor::_animation_name_edited(){
if (updating)
@@ -381,9 +410,24 @@ void SpriteFramesEditor::_animation_name_edited(){
name=new_name+" "+itos(counter);
}
+ List<Node*> nodes;
+ _find_anim_sprites(EditorNode::get_singleton()->get_edited_scene(),&nodes,Ref<SpriteFrames>(frames));
+
undo_redo->create_action(TTR("Rename Animation"));
undo_redo->add_do_method(frames,"rename_animation",edited_anim,name);
undo_redo->add_undo_method(frames,"rename_animation",name,edited_anim);
+
+ for(List<Node*>::Element *E=nodes.front();E;E=E->next()) {
+
+ String current = E->get()->call("get_animation");
+ if (current!=edited_anim)
+ continue;
+
+ undo_redo->add_do_method(E->get(),"set_animation",name);
+ undo_redo->add_undo_method(E->get(),"set_animation",edited_anim);
+
+ }
+
undo_redo->add_do_method(this,"_update_library");
undo_redo->add_undo_method(this,"_update_library");
@@ -406,12 +450,28 @@ void SpriteFramesEditor::_animation_add(){
name=new_name+" "+itos(counter);
}
+ List<Node*> nodes;
+ _find_anim_sprites(EditorNode::get_singleton()->get_edited_scene(),&nodes,Ref<SpriteFrames>(frames));
+
+
undo_redo->create_action(TTR("Add Animation"));
undo_redo->add_do_method(frames,"add_animation",name);
undo_redo->add_undo_method(frames,"remove_animation",name);
undo_redo->add_do_method(this,"_update_library");
undo_redo->add_undo_method(this,"_update_library");
+
+ for(List<Node*>::Element *E=nodes.front();E;E=E->next()) {
+
+ String current = E->get()->call("get_animation");
+ if (frames->has_animation(current))
+ continue;
+
+ undo_redo->add_do_method(E->get(),"set_animation",name);
+ undo_redo->add_undo_method(E->get(),"set_animation",current);
+
+ }
+
edited_anim=new_name;
undo_redo->commit_action();
@@ -426,6 +486,7 @@ void SpriteFramesEditor::_animation_remove(){
if (!frames->has_animation(edited_anim))
return;
+
undo_redo->create_action(TTR("Remove Animation"));
undo_redo->add_do_method(frames,"remove_animation",edited_anim);
undo_redo->add_undo_method(frames,"add_animation",edited_anim);
diff --git a/tools/editor/plugins/texture_region_editor_plugin.cpp b/tools/editor/plugins/texture_region_editor_plugin.cpp
index 8515008982..63d8e2e1cf 100644
--- a/tools/editor/plugins/texture_region_editor_plugin.cpp
+++ b/tools/editor/plugins/texture_region_editor_plugin.cpp
@@ -302,7 +302,6 @@ void TextureRegionEditor::_region_input(const InputEvent& p_input)
}
}
} else if (edited_margin < 0) {
- print_line("EDIT RECTANGLE!!!");
drag_from=mtx.affine_inverse().xform(Vector2(mb.x,mb.y));
if (snap_mode == SNAP_PIXEL)
drag_from = drag_from.snapped(Vector2(1,1));
@@ -332,7 +331,6 @@ void TextureRegionEditor::_region_input(const InputEvent& p_input)
}
} else if (drag) {
- print_line("DRAGING!!!");
if (edited_margin >= 0) {
undo_redo->create_action("Set Margin");
static Margin m[4] = {MARGIN_TOP,MARGIN_BOTTOM,MARGIN_LEFT,MARGIN_RIGHT};
@@ -776,6 +774,8 @@ TextureRegionEditor::TextureRegionEditor(EditorNode* p_editor)
snap_step=Vector2(10,10);
snap_separation = Vector2(0,0);
+ edited_margin = -1;
+ drag_index = -1;
drag=false;
VBoxContainer *main_vb = memnew( VBoxContainer );
diff --git a/tools/editor/plugins/tile_map_editor_plugin.cpp b/tools/editor/plugins/tile_map_editor_plugin.cpp
index d5f85d3333..d686c37d1a 100644
--- a/tools/editor/plugins/tile_map_editor_plugin.cpp
+++ b/tools/editor/plugins/tile_map_editor_plugin.cpp
@@ -223,7 +223,7 @@ void TileMapEditor::_update_palette() {
String name;
if (tileset->tile_get_name(E->get())!="") {
- name = tileset->tile_get_name(E->get());
+ name = itos(E->get())+" - "+tileset->tile_get_name(E->get());
} else {
name = "#"+itos(E->get());
}
@@ -412,6 +412,24 @@ void TileMapEditor::_draw_cell(int p_cell, const Point2i& p_point, bool p_flip_h
if (node->get_tile_origin()==TileMap::TILE_ORIGIN_TOP_LEFT) {
rect.pos+=tile_ofs;
+ } else if (node->get_tile_origin()==TileMap::TILE_ORIGIN_BOTTOM_LEFT) {
+ Size2 cell_size = node->get_cell_size();
+
+ rect.pos+=tile_ofs;
+
+ if(p_transpose)
+ {
+ if(p_flip_h)
+ rect.pos.x-=cell_size.x;
+ else
+ rect.pos.x+=cell_size.x;
+ } else {
+ if(p_flip_v)
+ rect.pos.y-=cell_size.y;
+ else
+ rect.pos.y+=cell_size.y;
+ }
+
} else if (node->get_tile_origin()==TileMap::TILE_ORIGIN_CENTER) {
rect.pos+=node->get_cell_size()/2;
Vector2 s = r.size;
diff --git a/tools/editor/plugins/tile_set_editor_plugin.cpp b/tools/editor/plugins/tile_set_editor_plugin.cpp
index a2c7147bf3..39a15189e7 100644
--- a/tools/editor/plugins/tile_set_editor_plugin.cpp
+++ b/tools/editor/plugins/tile_set_editor_plugin.cpp
@@ -73,24 +73,24 @@ void TileSetEditor::_import_scene(Node *scene, Ref<TileSet> p_library, bool p_me
p_library->tile_set_name(id,mi->get_name());
}
-
-
p_library->tile_set_texture(id,texture);
p_library->tile_set_material(id,material);
Vector2 phys_offset;
+ Size2 s;
- if (mi->is_centered()) {
- Size2 s;
- if (mi->is_region()) {
- s=mi->get_region_rect().size;
- } else {
- s=texture->get_size();
- }
- phys_offset+=-s/2;
- }
if (mi->is_region()) {
+ s=mi->get_region_rect().size;
p_library->tile_set_region(id,mi->get_region_rect());
+ } else {
+ const int frame = mi->get_frame();
+ const int hframes = mi->get_hframes();
+ s=texture->get_size()/Size2(hframes,mi->get_vframes());
+ p_library->tile_set_region(id,Rect2(Vector2(frame%hframes,frame/hframes)*s,s));
+ }
+
+ if (mi->is_centered()) {
+ phys_offset+=-s/2;
}
Vector<Ref<Shape2D> >collisions;
diff --git a/tools/editor/project_export.cpp b/tools/editor/project_export.cpp
index 3f82199fc3..103962716b 100644
--- a/tools/editor/project_export.cpp
+++ b/tools/editor/project_export.cpp
@@ -431,7 +431,6 @@ void ProjectExportDialog::_validate_platform() {
void ProjectExportDialog::_export_mode_changed(int p_idx) {
- bool do_all = p_idx==0;
if (EditorImportExport::get_singleton()->get_export_filter()==p_idx)
return;
EditorImportExport::get_singleton()->set_export_filter(EditorImportExport::ExportFilter(p_idx));
diff --git a/tools/editor/project_manager.cpp b/tools/editor/project_manager.cpp
index d8814fd50e..52c8ca4d6c 100644
--- a/tools/editor/project_manager.cpp
+++ b/tools/editor/project_manager.cpp
@@ -46,20 +46,33 @@
#include "io/resource_saver.h"
#include "editor_themes.h"
-
+#include "editor_initialize_ssl.h"
#include "editor_scale.h"
+#include "io/zip_io.h"
+
class NewProjectDialog : public ConfirmationDialog {
OBJ_TYPE(NewProjectDialog,ConfirmationDialog);
+public:
- bool import_mode;
+ enum Mode {
+ MODE_NEW,
+ MODE_IMPORT,
+ MODE_INSTALL
+ };
+private:
+
+ Mode mode;
Label *pp,*pn;
Label *error;
LineEdit *project_path;
LineEdit *project_name;
FileDialog *fdialog;
+ String zip_path;
+ String zip_title;
+ AcceptDialog *dialog_error;
bool _test_path() {
@@ -72,7 +85,7 @@ class NewProjectDialog : public ConfirmationDialog {
return false;
}
- if (!import_mode) {
+ if (mode!=MODE_IMPORT) {
if (d->file_exists("engine.cfg")) {
@@ -109,7 +122,7 @@ class NewProjectDialog : public ConfirmationDialog {
if (lidx!=-1) {
sp=sp.substr(lidx+1,sp.length());
}
- if (sp=="" && import_mode )
+ if (sp=="" && mode==MODE_IMPORT )
sp=TTR("Imported Project");
project_name->set_text(sp);
@@ -119,7 +132,7 @@ class NewProjectDialog : public ConfirmationDialog {
void _file_selected(const String& p_path) {
String p = p_path;
- if (import_mode) {
+ if (mode==MODE_IMPORT) {
if (p.ends_with("engine.cfg")) {
p=p.get_base_dir();
@@ -141,7 +154,7 @@ class NewProjectDialog : public ConfirmationDialog {
void _browse_path() {
- if (import_mode) {
+ if (mode==MODE_IMPORT) {
fdialog->set_mode(FileDialog::MODE_OPEN_FILE);
fdialog->clear_filters();
@@ -163,7 +176,7 @@ class NewProjectDialog : public ConfirmationDialog {
String dir;
- if (import_mode) {
+ if (mode==MODE_IMPORT) {
dir=project_path->get_text();
@@ -179,26 +192,130 @@ class NewProjectDialog : public ConfirmationDialog {
dir=d->get_current_dir();
memdelete(d);
- FileAccess *f = FileAccess::open(dir.plus_file("/engine.cfg"),FileAccess::WRITE);
- if (!f) {
- error->set_text(TTR("Couldn't create engine.cfg in project path."));
- } else {
+ if (mode==MODE_NEW) {
+
+
+
+
+ FileAccess *f = FileAccess::open(dir.plus_file("/engine.cfg"),FileAccess::WRITE);
+ if (!f) {
+ error->set_text(TTR("Couldn't create engine.cfg in project path."));
+ } else {
+
+ f->store_line("; Engine configuration file.");
+ f->store_line("; It's best to edit using the editor UI, not directly,");
+ f->store_line("; becausethe parameters that go here are not obvious.");
+ f->store_line("; ");
+ f->store_line("; Format: ");
+ f->store_line("; [section] ; section goes between []");
+ f->store_line("; param=value ; assign values to parameters");
+ f->store_line("\n");
+ f->store_line("[application]");
+ f->store_line("name=\""+project_name->get_text()+"\"");
+ f->store_line("icon=\"res://icon.png\"");
+
+ memdelete(f);
+
+ ResourceSaver::save(dir.plus_file("/icon.png"),get_icon("DefaultProjectIcon","EditorIcons"));
+ }
+
+ } else if (mode==MODE_INSTALL) {
+
+
+ FileAccess *src_f=NULL;
+ zlib_filefunc_def io = zipio_create_io_from_file(&src_f);
+
+ unzFile pkg = unzOpen2(zip_path.utf8().get_data(), &io);
+ if (!pkg) {
+
+ dialog_error->set_text("Error opening package file, not in zip format.");
+ return;
+ }
+
+ int ret = unzGoToFirstFile(pkg);
+
+ Vector<String> failed_files;
+
+ int idx=0;
+ while(ret==UNZ_OK) {
+
+ //get filename
+ unz_file_info info;
+ char fname[16384];
+ ret = unzGetCurrentFileInfo(pkg,&info,fname,16384,NULL,0,NULL,0);
+
+ String path=fname;
+
+ int depth=1; //stuff from github comes with tag
+ bool skip=false;
+ while(depth>0) {
+ int pp = path.find("/");
+ if (pp==-1) {
+ skip=true;
+ break;
+ }
+ path=path.substr(pp+1,path.length());
+ depth--;
+ }
+
+
+ if (skip || path==String()) {
+ //
+ } else if (path.ends_with("/")) { // a dir
+
+ path=path.substr(0,path.length()-1);
+
+ DirAccess *da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
+ da->make_dir(dir.plus_file(path));
+ memdelete(da);
+
+ } else {
+
+ Vector<uint8_t> data;
+ data.resize(info.uncompressed_size);
+
+ //read
+ unzOpenCurrentFile(pkg);
+ unzReadCurrentFile(pkg,data.ptr(),data.size());
+ unzCloseCurrentFile(pkg);
+
+ FileAccess *f=FileAccess::open(dir.plus_file(path),FileAccess::WRITE);
+
+ if (f) {
+ f->store_buffer(data.ptr(),data.size());
+ memdelete(f);
+ } else {
+ failed_files.push_back(path);
+ }
+
+
+ }
+
+ idx++;
+ ret = unzGoToNextFile(pkg);
+ }
+
+ unzClose(pkg);
+
+ if (failed_files.size()) {
+ String msg=TTR("The following files failed extraction from package:")+"\n\n";
+ for(int i=0;i<failed_files.size();i++) {
+
+ if (i>15) {
+ msg+="\nAnd "+itos(failed_files.size()-i)+" more files.";
+ break;
+ }
+ msg+=failed_files[i]+"\n";
+ }
+
+ dialog_error->set_text(msg);
+ dialog_error->popup_centered_minsize();
+
+ } else {
+ dialog_error->set_text(TTR("Package Installed Successfully!"));
+ dialog_error->popup_centered_minsize();
+ }
- f->store_line("; Engine configuration file.");
- f->store_line("; It's best to edit using the editor UI, not directly,");
- f->store_line("; becausethe parameters that go here are not obvious.");
- f->store_line("; ");
- f->store_line("; Format: ");
- f->store_line("; [section] ; section goes between []");
- f->store_line("; param=value ; assign values to parameters");
- f->store_line("\n");
- f->store_line("[application]");
- f->store_line("name=\""+project_name->get_text()+"\"");
- f->store_line("icon=\"res://icon.png\"");
-
- memdelete(f);
-
- ResourceSaver::save(dir.plus_file("/icon.png"),get_icon("DefaultProjectIcon","EditorIcons"));
}
@@ -233,10 +350,16 @@ protected:
public:
+ void set_zip_path(const String& p_path) {
+ zip_path=p_path;
+ }
+ void set_zip_title(const String& p_title) {
+ zip_title=p_title;
+ }
- void set_import_mode(bool p_import ) {
+ void set_mode(Mode p_mode) {
- import_mode=p_import;
+ mode=p_mode;
}
void show_dialog() {
@@ -245,7 +368,7 @@ public:
project_path->clear();
project_name->clear();
- if (import_mode) {
+ if (mode==MODE_IMPORT) {
set_title(TTR("Import Existing Project"));
get_ok()->set_text(TTR("Import"));
pp->set_text(TTR("Project Path (Must Exist):"));
@@ -253,9 +376,10 @@ public:
pn->hide();
project_name->hide();
- popup_centered(Size2(500,125));
+ popup_centered(Size2(500,125)*EDSCALE);
+
+ } else if (mode==MODE_NEW){
- } else {
set_title(TTR("Create New Project"));
get_ok()->set_text(TTR("Create"));
pp->set_text(TTR("Project Path:"));
@@ -263,7 +387,16 @@ public:
pn->show();
project_name->show();
- popup_centered(Size2(500,145));
+ popup_centered(Size2(500,145)*EDSCALE);
+ } else if (mode==MODE_INSTALL){
+
+ set_title(TTR("Install Project:")+" "+zip_title);
+ get_ok()->set_text(TTR("Install"));
+ pp->set_text(TTR("Project Path:"));
+ pn->hide();
+ project_name->hide();
+
+ popup_centered(Size2(500,125)*EDSCALE);
}
@@ -329,7 +462,10 @@ public:
fdialog->connect("dir_selected", this,"_path_selected");
fdialog->connect("file_selected", this,"_file_selected");
set_hide_on_ok(false);
- import_mode=false;
+ mode=MODE_NEW;
+
+ dialog_error = memnew( AcceptDialog );
+ add_child(dialog_error);
}
@@ -616,6 +752,8 @@ void ProjectManager::_load_recent_projects() {
run_btn->set_disabled(selected_list.size()<1 || (selected_list.size()==1 && single_selected_main==""));
EditorSettings::get_singleton()->save();
+
+ tabs->set_current_tab(0);
}
void ProjectManager::_open_project_confirm() {
@@ -755,14 +893,14 @@ void ProjectManager::_scan_projects() {
void ProjectManager::_new_project() {
- npdialog->set_import_mode(false);
+ npdialog->set_mode(NewProjectDialog::MODE_NEW);
npdialog->show_dialog();
}
void ProjectManager::_import_project() {
- npdialog->set_import_mode(true);
+ npdialog->set_mode(NewProjectDialog::MODE_IMPORT);
npdialog->show_dialog();
}
@@ -800,6 +938,15 @@ void ProjectManager::_exit_dialog() {
get_tree()->quit();
}
+
+void ProjectManager::_install_project(const String& p_zip_path,const String& p_title) {
+
+ npdialog->set_mode(NewProjectDialog::MODE_INSTALL);
+ npdialog->set_zip_path(p_zip_path);
+ npdialog->set_zip_title(p_title);
+ npdialog->show_dialog();
+}
+
void ProjectManager::_bind_methods() {
ObjectTypeDB::bind_method("_open_project",&ProjectManager::_open_project);
@@ -817,19 +964,20 @@ void ProjectManager::_bind_methods() {
ObjectTypeDB::bind_method("_panel_draw",&ProjectManager::_panel_draw);
ObjectTypeDB::bind_method("_panel_input",&ProjectManager::_panel_input);
ObjectTypeDB::bind_method("_favorite_pressed",&ProjectManager::_favorite_pressed);
+ ObjectTypeDB::bind_method("_install_project",&ProjectManager::_install_project);
}
ProjectManager::ProjectManager() {
- int margin = get_constant("margin","Dialogs");
- int button_margin = get_constant("button_margin","Dialogs");
-
// load settings
if (!EditorSettings::get_singleton())
EditorSettings::create();
+
+ EditorSettings::get_singleton()->set_optimize_save(false); //just write settings as they came
+
{
int dpi_mode = EditorSettings::get_singleton()->get("global/hidpi_mode");
if (dpi_mode==0) {
@@ -871,9 +1019,6 @@ ProjectManager::ProjectManager() {
HBoxContainer *top_hb = memnew( HBoxContainer);
vb->add_child(top_hb);
- TextureFrame *logo = memnew( TextureFrame );
- logo->set_texture(theme->get_icon("LogoSmall","EditorIcons"));
- //top_hb->add_child( logo );
CenterContainer *ccl = memnew( CenterContainer );
Label *l = memnew( Label );
l->set_text(_MKSTR(VERSION_NAME)+String(" - ")+TTR("Project Manager"));
@@ -981,10 +1126,10 @@ ProjectManager::ProjectManager() {
if (StreamPeerSSL::is_available()) {
-
asset_library = memnew( EditorAssetLibrary(true) );
asset_library->set_name("Templates");
tabs->add_child(asset_library);
+ asset_library->connect("install_asset",this,"_install_project");
} else {
WARN_PRINT("Asset Library not available, as it requires SSL to work.");
}
@@ -1018,8 +1163,6 @@ ProjectManager::ProjectManager() {
gui_base->add_child(multi_run_ask);
-
-
OS::get_singleton()->set_low_processor_usage_mode(true);
npdialog = memnew( NewProjectDialog );
@@ -1103,6 +1246,8 @@ void ProjectListFilter::_bind_methods() {
ProjectListFilter::ProjectListFilter() {
+ editor_initialize_certificates(); //for asset sharing
+
_current_filter = FILTER_NAME;
filter_option = memnew(OptionButton);
diff --git a/tools/editor/project_manager.h b/tools/editor/project_manager.h
index 2db1bb839e..69467f50e7 100644
--- a/tools/editor/project_manager.h
+++ b/tools/editor/project_manager.h
@@ -88,6 +88,8 @@ class ProjectManager : public Control {
void _load_recent_projects();
void _scan_dir(DirAccess *da,float pos, float total,List<String> *r_projects);
+ void _install_project(const String& p_zip_path,const String& p_title);
+
void _panel_draw(Node *p_hb);
void _panel_input(const InputEvent& p_ev,Node *p_hb);
void _favorite_pressed(Node *p_hb);
diff --git a/tools/editor/project_settings.cpp b/tools/editor/project_settings.cpp
index 6822e50b73..6be1abf52f 100644
--- a/tools/editor/project_settings.cpp
+++ b/tools/editor/project_settings.cpp
@@ -100,16 +100,6 @@ void ProjectSettings::_notification(int p_what) {
translation_res_file_open->add_filter("*."+E->get());
translation_res_option_file_open->add_filter("*."+E->get());
}
-
- List<String> afn;
- ResourceLoader::get_recognized_extensions_for_type("Script",&afn);
- ResourceLoader::get_recognized_extensions_for_type("PackedScene",&afn);
-
- for (List<String>::Element *E=afn.front();E;E=E->next()) {
-
- autoload_file_open->add_filter("*."+E->get());
- }
-
}
}
@@ -564,7 +554,7 @@ void ProjectSettings::popup_project_settings() {
popup_centered_ratio();
globals_editor->update_category_list();
_update_translations();
- _update_autoload();
+ autoload_settings->update_autoload();
plugin_settings->update_plugins();
}
@@ -616,10 +606,26 @@ void ProjectSettings::_item_add() {
String name = catname!="" ? catname+"/"+propname : propname;
- Globals::get_singleton()->set(name,value);
+ undo_redo->create_action("Add Global Property");
+
+ undo_redo->add_do_property(Globals::get_singleton(), name, value);
+ undo_redo->add_do_method(Globals::get_singleton(), "set_persisting", name, true);
+
+ if (Globals::get_singleton()->has(name)) {
+ undo_redo->add_undo_property(Globals::get_singleton(), name, Globals::get_singleton()->get(name));
+ } else {
+ undo_redo->add_undo_property(Globals::get_singleton(), name, Variant());
+ }
+
+ undo_redo->add_do_method(globals_editor, "update_category_list");
+ undo_redo->add_undo_method(globals_editor, "update_category_list");
+
+ undo_redo->add_do_method(this, "_settings_changed");
+ undo_redo->add_undo_method(this, "_settings_changed");
+
+ undo_redo->commit_action();
globals_editor->set_current_section(catname);
- globals_editor->update_category_list();
_settings_changed();
}
@@ -633,10 +639,20 @@ void ProjectSettings::_item_del() {
String name = catname!="" ? catname+"/"+propname : propname;
- Globals::get_singleton()->set(name,Variant());
+ undo_redo->create_action("Delete Global Property");
- globals_editor->set_current_section(catname);
- globals_editor->update_category_list();
+ undo_redo->add_do_property(Globals::get_singleton(), name, Variant());
+
+ undo_redo->add_undo_property(Globals::get_singleton(), name, Globals::get_singleton()->get(name));
+ undo_redo->add_undo_method(Globals::get_singleton(), "set_persisting", name, Globals::get_singleton()->is_persisting(name));
+
+ undo_redo->add_do_method(globals_editor, "update_category_list");
+ undo_redo->add_undo_method(globals_editor, "update_category_list");
+
+ undo_redo->add_do_method(this, "_settings_changed");
+ undo_redo->add_undo_method(this, "_settings_changed");
+
+ undo_redo->commit_action();
_settings_changed();
}
@@ -811,263 +827,6 @@ void ProjectSettings::_translation_file_open() {
translation_file_open->popup_centered_ratio();
}
-
-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);
-}
-
-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();
- int column = autoload_list->get_edited_column();
-
- if (!ti || (column != 0 && column != 2))
- return;
-
- if (column == 0) {
- String name = ti->get_text(0);
- String old_name = selected_autoload.substr(selected_autoload.find("/")+1,selected_autoload.length());
-
- if (!name.is_valid_identifier()) {
- ti->set_text(0,old_name);
- message->set_text(TTR("Invalid name.")+"\n"+TTR("Valid characters:")+" a-z, A-Z, 0-9 or _");
- message->popup_centered(Size2(300,100));
- return;
- }
-
- if (ObjectTypeDB::type_exists(name)) {
- ti->set_text(0,old_name);
- message->set_text(TTR("Invalid name. Must not collide with an existing engine class name."));
- message->popup_centered(Size2(400,100));
- return;
- }
-
- for(int i=0;i<Variant::VARIANT_MAX;i++) {
- if (Variant::get_type_name(Variant::Type(i))==name) {
- ti->set_text(0,old_name);
- message->set_text(TTR("Invalid name. Must not collide with an existing buit-in type name."));
- message->popup_centered(Size2(400,100));
- return;
- }
- }
-
- for(int i=0;i<GlobalConstants::get_global_constant_count();i++) {
- if (GlobalConstants::get_global_constant_name(i)==name) {
- ti->set_text(0,old_name);
- message->set_text(TTR("Invalid name. Must not collide with an existing global constant name."));
- message->popup_centered(Size2(400,100));
- return;
- }
- }
-
- if (Globals::get_singleton()->has("autoload/"+name)) {
- ti->set_text(0,old_name);
- message->set_text(vformat(TTR("Autoload '%s' already exists!"),name));
- message->popup_centered(Size2(300,100));
- return;
- }
-
- updating_autoload = true;
-
- name = "autoload/"+name;
- String path = Globals::get_singleton()->get(selected_autoload);
- bool is_persisting = Globals::get_singleton()->is_persisting(selected_autoload);
- int order = Globals::get_singleton()->get_order(selected_autoload);
-
- undo_redo->create_action(TTR("Rename Autoload"));
- undo_redo->add_do_property(Globals::get_singleton(),name,path);
- undo_redo->add_do_method(Globals::get_singleton(),"set_persisting",name,is_persisting);
- undo_redo->add_do_method(Globals::get_singleton(),"set_order",name,order);
- undo_redo->add_do_method(Globals::get_singleton(),"clear",selected_autoload);
- undo_redo->add_undo_property(Globals::get_singleton(),selected_autoload,path);
- undo_redo->add_undo_method(Globals::get_singleton(),"set_persisting",selected_autoload,is_persisting);
- undo_redo->add_undo_method(Globals::get_singleton(),"set_order",selected_autoload,order);
- undo_redo->add_undo_method(Globals::get_singleton(),"clear",name);
- 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();
-
- selected_autoload = name;
- } else if (column == 2) {
- updating_autoload = true;
-
- bool checked = ti->is_checked(2);
- String base = "autoload/"+ti->get_text(0);
- String path = Globals::get_singleton()->get(base);
- int order = Globals::get_singleton()->get_order(base);
-
- if (path.begins_with("*"))
- path = path.substr(1,path.length());
-
- if (checked)
- path = "*" + path;
-
- undo_redo->create_action(TTR("Toggle AutoLoad Globals"));
- 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(Globals::get_singleton(),"set_order",base,order); // keep order, as config order matters for these
- undo_redo->add_undo_method(Globals::get_singleton(),"set_order",base,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");
- 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();
- if (!name.is_valid_identifier()) {
- message->set_text(TTR("Invalid name.")+"\n"+TTR("Valid characters:")+" a-z, A-Z, 0-9 or _");
- message->popup_centered(Size2(300,100));
- return;
-
- }
-
- if (ObjectTypeDB::type_exists(name)) {
-
- message->set_text(TTR("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(TTR("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(TTR("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.");
- message->popup_centered(Size2(300,100));
- return;
-
- }
- if (!path.begins_with("res://")) {
- message->set_text("Invalid Path.\nNot in resource path.");
- message->popup_centered(Size2(300,100));
- return;
-
- }
-
- undo_redo->create_action(TTR("Add Autoload"));
- name = "autoload/"+name;
- 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
- undo_redo->add_undo_property(Globals::get_singleton(),name,Variant());
-
- undo_redo->add_do_method(Globals::get_singleton(),"set_persisting",name,true);
- 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();
-
- autoload_add_path->set_text("");
- autoload_add_name->set_text("");
-
- //autoload_file_open->popup_centered_ratio();
-}
-
-void ProjectSettings::_autoload_delete(Object *p_item,int p_column, int p_button) {
-
-
- TreeItem *ti=p_item->cast_to<TreeItem>();
- String name = "autoload/"+ti->get_text(0);
-
- if (p_button==0) {
- //delete
- int order = Globals::get_singleton()->get_order(name);
- undo_redo->create_action(TTR("Remove Autoload"));
- undo_redo->add_do_property(Globals::get_singleton(),name,Variant());
- undo_redo->add_undo_property(Globals::get_singleton(),name,Globals::get_singleton()->get(name));
- undo_redo->add_undo_method(Globals::get_singleton(),"set_persisting",name,true);
- 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");
- undo_redo->add_undo_method(this,"_settings_changed");
- undo_redo->commit_action();
- } else {
-
- TreeItem *swap = NULL;
-
- if (p_button==1) {
- swap=ti->get_prev();
- } else if (p_button==2) {
- swap=ti->get_next();
- }
- if (!swap)
- return;
-
- 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(TTR("Move Autoload"));
- 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");
- undo_redo->add_undo_method(this,"_settings_changed");
- undo_redo->commit_action();
-
- }
-
-}
-
-void ProjectSettings::_autoload_selected() {
- TreeItem *ti = autoload_list->get_selected();
-
- if (!ti)
- return;
-
- selected_autoload = "autoload/"+ti->get_text(0);
-}
-
void ProjectSettings::_translation_delete(Object *p_item,int p_column, int p_button) {
TreeItem *ti = p_item->cast_to<TreeItem>();
@@ -1393,55 +1152,6 @@ 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);
-
- List<PropertyInfo> props;
- Globals::get_singleton()->get_property_list(&props);
-
- for(List<PropertyInfo>::Element *E=props.front();E;E=E->next()) {
-
- const PropertyInfo &pi=E->get();
- if (!pi.name.begins_with("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_editable(0,true);
- t->set_text(1,path);
- t->set_cell_mode(2,TreeItem::CELL_MODE_CHECK);
- t->set_editable(2,true);
- t->set_text(2,TTR("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->get_property_editor()->set_use_filter(p_pressed);
@@ -1508,14 +1218,6 @@ void ProjectSettings::_bind_methods() {
ObjectTypeDB::bind_method(_MD("_translation_res_delete"),&ProjectSettings::_translation_res_delete);
ObjectTypeDB::bind_method(_MD("_translation_res_option_delete"),&ProjectSettings::_translation_res_option_delete);
- ObjectTypeDB::bind_method(_MD("_autoload_add"),&ProjectSettings::_autoload_add);
- ObjectTypeDB::bind_method(_MD("_autoload_file_open"),&ProjectSettings::_autoload_file_open);
- 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("_autoload_selected"),&ProjectSettings::_autoload_selected);
-
ObjectTypeDB::bind_method(_MD("_clear_search_box"),&ProjectSettings::_clear_search_box);
ObjectTypeDB::bind_method(_MD("_toggle_search_bar"),&ProjectSettings::_toggle_search_bar);
@@ -1858,69 +1560,10 @@ ProjectSettings::ProjectSettings(EditorData *p_data) {
{
- VBoxContainer *avb = memnew( VBoxContainer );
- tab_container->add_child(avb);
- avb->set_name(TTR("AutoLoad"));
- HBoxContainer *ahb = memnew( HBoxContainer);
- avb->add_child(ahb);
-
-
- VBoxContainer *avb_path = memnew( VBoxContainer );
- avb_path->set_h_size_flags(SIZE_EXPAND_FILL);
- HBoxContainer *ahb_path = memnew( HBoxContainer );
- autoload_add_path = memnew(LineEdit);
- autoload_add_path->set_h_size_flags(SIZE_EXPAND_FILL);
- ahb_path->add_child(autoload_add_path);
- Button *browseaa = memnew( Button("..") );
- ahb_path->add_child(browseaa);
- browseaa->connect("pressed",this,"_autoload_file_open");
-
- avb_path->add_margin_child(TTR("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(TTR("Node Name:"),ahb_name);
- Button *addaa = memnew( Button(TTR("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(TTR("List:"),autoload_list,true);
-
- autoload_file_open=memnew( EditorFileDialog );
- add_child(autoload_file_open);
- autoload_file_open->set_mode(EditorFileDialog::MODE_OPEN_FILE);
- autoload_file_open->connect("file_selected",this,"_autoload_file_callback");
-
- autoload_list->set_columns(4);
- autoload_list->set_column_titles_visible(true);
- autoload_list->set_column_title(0,TTR("Name"));
- autoload_list->set_column_expand(0,true);
- autoload_list->set_column_min_width(0,100);
- autoload_list->set_column_title(1,TTR("Path"));
- autoload_list->set_column_expand(1,true);
- autoload_list->set_column_min_width(1,100);
- autoload_list->set_column_title(2,TTR("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");
- autoload_list->connect("cell_selected", this, "_autoload_selected");
-
- updating_autoload=false;
-
+ autoload_settings = memnew( EditorAutoloadSettings );
+ autoload_settings->set_name(TTR("AutoLoad"));
+ tab_container->add_child(autoload_settings);
+ autoload_settings->connect("autoload_changed", this, "_settings_changed");
}
{
diff --git a/tools/editor/project_settings.h b/tools/editor/project_settings.h
index 79e1acf75e..46e98f69ad 100644
--- a/tools/editor/project_settings.h
+++ b/tools/editor/project_settings.h
@@ -34,6 +34,7 @@
#include "undo_redo.h"
#include "editor_data.h"
#include "scene/gui/tab_container.h"
+#include "editor_autoload_settings.h"
#include "editor_plugin_settings.h"
//#include "project_export_settings.h"
@@ -88,26 +89,10 @@ class ProjectSettings : public AcceptDialog {
Tree *translation_remap;
Tree *translation_remap_options;
-
- Tree *autoload_list;
- String selected_autoload;
- EditorFileDialog *autoload_file_open;
- LineEdit *autoload_add_name;
- LineEdit *autoload_add_path;
-
+ EditorAutoloadSettings *autoload_settings;
EditorPluginSettings *plugin_settings;
- 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);
- void _autoload_selected();
- bool updating_autoload;
-
-
void _item_selected();
void _item_adds(String);
void _item_add();
diff --git a/tools/editor/property_editor.cpp b/tools/editor/property_editor.cpp
index 246785932d..ceb62d5ff0 100644
--- a/tools/editor/property_editor.cpp
+++ b/tools/editor/property_editor.cpp
@@ -389,7 +389,6 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty
List<String> names;
names.push_back("value:");
config_value_editors(1,1,50,names);
- Vector3 vec=v;
value_editor[0]->set_text( String::num(v) );
}
@@ -436,7 +435,6 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty
List<String> names;
names.push_back("string:");
config_value_editors(1,1,50,names);
- Vector3 vec=v;
value_editor[0]->set_text( v );
}
@@ -612,6 +610,7 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty
color_picker->set_edit_alpha(hint!=PROPERTY_HINT_COLOR_NO_ALPHA);
color_picker->set_color(v);
set_size( Size2(300*EDSCALE, color_picker->get_combined_minimum_size().height+10*EDSCALE));
+ color_picker->set_focus_on_line_edit();
/*
int ofs=80;
int m=10;
@@ -2980,10 +2979,8 @@ void PropertyEditor::update_tree() {
else
item->set_cell_mode( 1, TreeItem::CELL_MODE_RANGE_EXPRESSION );
- if (p.hint==PROPERTY_HINT_SPRITE_FRAME) {
- item->set_range_config(1,0,99999,1);
- } else if (p.hint==PROPERTY_HINT_RANGE || p.hint==PROPERTY_HINT_EXP_RANGE) {
+ if (p.hint==PROPERTY_HINT_SPRITE_FRAME || p.hint==PROPERTY_HINT_RANGE || p.hint==PROPERTY_HINT_EXP_RANGE) {
int c = p.hint_string.get_slice_count(",");
float min=0,max=100,step=1;
@@ -3346,7 +3343,6 @@ void PropertyEditor::update_tree() {
String type;
if (p.hint==PROPERTY_HINT_RESOURCE_TYPE)
type=p.hint_string;
- bool notnil=false;
if (obj->get( p.name ).get_type() == Variant::NIL || obj->get( p.name ).operator RefPtr().is_null()) {
item->set_text(1,"<null>");
@@ -3369,8 +3365,7 @@ void PropertyEditor::update_tree() {
} else {
item->set_text(1,"<"+res->get_type()+">");
- };
- notnil=true;
+ }
if (has_icon(res->get_type(),"EditorIcons")) {
type=res->get_type();
@@ -4192,6 +4187,8 @@ public:
void SectionedPropertyEditor::_bind_methods() {
ObjectTypeDB::bind_method("_section_selected",&SectionedPropertyEditor::_section_selected);
+
+ ObjectTypeDB::bind_method("update_category_list", &SectionedPropertyEditor::update_category_list);
}
void SectionedPropertyEditor::_section_selected(int p_which) {
diff --git a/tools/editor/quick_open.cpp b/tools/editor/quick_open.cpp
index fc2a2241ab..e18dc584d5 100644
--- a/tools/editor/quick_open.cpp
+++ b/tools/editor/quick_open.cpp
@@ -109,16 +109,27 @@ void EditorQuickOpen::_sbox_input(const InputEvent& p_ie) {
}
-void EditorQuickOpen::_parse_fs(EditorFileSystemDirectory *efsd) {
+float EditorQuickOpen::_path_cmp(String search, String path) const {
+
+ if (search == path) {
+ return 1.2f;
+ }
+ if (path.findn(search) != -1) {
+ return 1.1f;
+ }
+ return path.to_lower().similarity(search.to_lower());
+}
+
+void EditorQuickOpen::_parse_fs(EditorFileSystemDirectory *efsd, Vector< Pair< String, Ref<Texture> > > &list) {
if (!add_directories) {
for(int i=0;i<efsd->get_subdir_count();i++) {
- _parse_fs(efsd->get_subdir(i));
+ _parse_fs(efsd->get_subdir(i), list);
}
}
- TreeItem *root = search_options->get_root();
+ String search_text = search_box->get_text();
if (add_directories) {
String path = efsd->get_path();
@@ -126,11 +137,27 @@ void EditorQuickOpen::_parse_fs(EditorFileSystemDirectory *efsd) {
path+="/";
if (path!="res://") {
path=path.substr(6,path.length());
- if (search_box->get_text().is_subsequence_ofi(path)) {
- TreeItem *ti = search_options->create_item(root);
- ti->set_text(0,path);
- Ref<Texture> icon = get_icon("folder","FileDialog");
- ti->set_icon(0,icon);
+ if (search_text.is_subsequence_ofi(path)) {
+ Pair< String, Ref<Texture> > pair;
+ pair.first = path;
+ pair.second = get_icon("folder", "FileDialog");
+
+ if (search_text != String() && list.size() > 0) {
+
+ float this_sim = _path_cmp(search_text, path);
+ float other_sim = _path_cmp(list[0].first, path);
+ int pos = 1;
+
+ while (pos < list.size() && this_sim <= other_sim) {
+ other_sim = _path_cmp(list[pos++].first, path);
+ }
+
+ pos = this_sim >= other_sim ? pos - 1 : pos;
+ list.insert(pos, pair);
+
+ } else {
+ list.push_back(pair);
+ }
}
}
}
@@ -138,12 +165,29 @@ void EditorQuickOpen::_parse_fs(EditorFileSystemDirectory *efsd) {
String file = efsd->get_file_path(i);
file=file.substr(6,file.length());
- if (ObjectTypeDB::is_type(efsd->get_file_type(i),base_type) && (search_box->get_text().is_subsequence_ofi(file))) {
- TreeItem *ti = search_options->create_item(root);
- 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 (ObjectTypeDB::is_type(efsd->get_file_type(i),base_type) && (search_text.is_subsequence_ofi(file))) {
+ Pair< String, Ref<Texture> > pair;
+ pair.first = file;
+ pair.second = get_icon((has_icon(efsd->get_file_type(i), ei) ? efsd->get_file_type(i) : ot), ei);
+
+ if (search_text != String() && list.size() > 0) {
+
+ float this_sim = _path_cmp(search_text, file);
+ float other_sim = _path_cmp(list[0].first, file);
+ int pos = 1;
+
+ while (pos < list.size() && this_sim <= other_sim) {
+ other_sim = _path_cmp(list[pos++].first, file);
+ }
+
+ pos = this_sim >= other_sim ? pos - 1 : pos;
+ list.insert(pos, pair);
+
+ } else {
+
+ list.push_back(pair);
+ }
}
}
@@ -151,7 +195,7 @@ void EditorQuickOpen::_parse_fs(EditorFileSystemDirectory *efsd) {
if (add_directories) {
for(int i=0;i<efsd->get_subdir_count();i++) {
- _parse_fs(efsd->get_subdir(i));
+ _parse_fs(efsd->get_subdir(i), list);
}
}
@@ -159,10 +203,18 @@ void EditorQuickOpen::_parse_fs(EditorFileSystemDirectory *efsd) {
void EditorQuickOpen::_update_search() {
-
search_options->clear();
TreeItem *root = search_options->create_item();
- _parse_fs(EditorFileSystem::get_singleton()->get_filesystem());
+ EditorFileSystemDirectory *efsd = EditorFileSystem::get_singleton()->get_filesystem();
+ Vector< Pair< String, Ref<Texture> > > list;
+
+ _parse_fs(efsd, list);
+
+ for (int i = 0; i < list.size(); i++) {
+ TreeItem *ti = search_options->create_item(root);
+ ti->set_text(0, list[i].first);
+ ti->set_icon(0, list[i].second);
+ }
if (root->get_children()) {
TreeItem *ti = root->get_children();
diff --git a/tools/editor/quick_open.h b/tools/editor/quick_open.h
index 520f7e569d..c253f7606e 100644
--- a/tools/editor/quick_open.h
+++ b/tools/editor/quick_open.h
@@ -32,6 +32,7 @@
#include "scene/gui/dialogs.h"
#include "scene/gui/tree.h"
#include "editor_file_system.h"
+#include "pair.h"
class EditorQuickOpen : public ConfirmationDialog {
OBJ_TYPE(EditorQuickOpen,ConfirmationDialog )
@@ -47,7 +48,8 @@ class EditorQuickOpen : public ConfirmationDialog {
void _update_search();
void _sbox_input(const InputEvent& p_ie);
- void _parse_fs(EditorFileSystemDirectory *efsd);
+ void _parse_fs(EditorFileSystemDirectory *efsd, Vector< Pair< String,Ref <Texture> > > &list);
+ float _path_cmp(String search, String path) const;
void _confirmed();
diff --git a/tools/editor/scene_tree_dock.cpp b/tools/editor/scene_tree_dock.cpp
index ab5c6e5044..2e7d65eadc 100644
--- a/tools/editor/scene_tree_dock.cpp
+++ b/tools/editor/scene_tree_dock.cpp
@@ -243,7 +243,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
//if (!_validate_no_foreign())
// break;
- create_dialog->popup_centered_ratio();
+ create_dialog->popup(true);
} break;
case TOOL_INSTANCE: {
@@ -281,7 +281,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
} break;
case TOOL_REPLACE: {
- create_dialog->popup_centered_ratio();
+ create_dialog->popup(false);
} break;
case TOOL_CONNECT: {
@@ -382,11 +382,8 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
ERR_FAIL_COND(!top_node->get_parent());
ERR_FAIL_COND(!bottom_node->get_parent());
- int top_node_pos = top_node->get_index();
int bottom_node_pos = bottom_node->get_index();
-
- int top_node_pos_next = top_node_pos + (MOVING_DOWN ? 1 : -1);
- int bottom_node_pos_next = bottom_node_pos + (MOVING_DOWN ? 1 : -1);
+ int top_node_pos_next = top_node->get_index() + (MOVING_DOWN ? 1 : -1);
editor_data->get_undo_redo().add_do_method(top_node->get_parent(), "move_child", top_node, top_node_pos_next);
editor_data->get_undo_redo().add_undo_method(bottom_node->get_parent(), "move_child", bottom_node, bottom_node_pos);
@@ -1069,6 +1066,8 @@ void SceneTreeDock::_do_reparent(Node* p_new_parent,int p_position_in_parent,Vec
List<Pair<NodePath,NodePath> > path_renames;
+ int inc=0;
+
for(int ni=0;ni<p_nodes.size();ni++) {
//no undo for now, sorry
@@ -1085,12 +1084,16 @@ void SceneTreeDock::_do_reparent(Node* p_new_parent,int p_position_in_parent,Vec
}
+ if (new_parent==node->get_parent() && node->get_index() < p_position_in_parent+ni) {
+ //if child will generate a gap when moved, adjust
+ inc--;
+ }
editor_data->get_undo_redo().add_do_method(node->get_parent(),"remove_child",node);
editor_data->get_undo_redo().add_do_method(new_parent,"add_child",node);
if (p_position_in_parent>=0)
- editor_data->get_undo_redo().add_do_method(new_parent,"move_child",node,p_position_in_parent+ni);
+ editor_data->get_undo_redo().add_do_method(new_parent,"move_child",node,p_position_in_parent+inc);
ScriptEditorDebugger *sed = ScriptEditor::get_singleton()->get_debugger();
String new_name = new_parent->validate_child_name(node->get_name());
@@ -1102,17 +1105,8 @@ void SceneTreeDock::_do_reparent(Node* p_new_parent,int p_position_in_parent,Vec
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;
- }
+ if (node->cast_to<Control>())
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);
@@ -1122,6 +1116,8 @@ void SceneTreeDock::_do_reparent(Node* p_new_parent,int p_position_in_parent,Vec
editor_data->get_undo_redo().add_undo_method(new_parent,"remove_child",node);
+ inc++;
+
}
//add and move in a second step.. (so old order is preserved)
@@ -1153,17 +1149,8 @@ void SceneTreeDock::_do_reparent(Node* p_new_parent,int p_position_in_parent,Vec
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;
- }
+ if (node->cast_to<Control>())
editor_data->get_undo_redo().add_undo_method(node,"set_pos",node->cast_to<Control>()->get_pos());
- }
}
@@ -1543,7 +1530,7 @@ static bool _has_visible_children(Node* p_node) {
for(int i=0;i<p_node->get_child_count();i++) {
Node* child = p_node->get_child(i);
- if (!_is_node_visible(p_node))
+ if (!_is_node_visible(child))
continue;
return true;
@@ -1555,9 +1542,9 @@ static bool _has_visible_children(Node* p_node) {
-static Node* _find_last_visible(Node*p_node) {
+static Node* _find_last_visible(Node* p_node) {
- Node*last=NULL;
+ Node* last=NULL;
bool collapsed = p_node->has_meta("_editor_collapsed") ? (bool)p_node->get_meta("_editor_collapsed") : false;
@@ -1583,7 +1570,7 @@ static Node* _find_last_visible(Node*p_node) {
}
-void SceneTreeDock::_normalize_drop(Node*& to_node, int &to_pos,int p_type) {
+void SceneTreeDock::_normalize_drop(Node*& to_node, int &to_pos, int p_type) {
to_pos=-1;
@@ -1624,6 +1611,7 @@ void SceneTreeDock::_normalize_drop(Node*& to_node, int &to_pos,int p_type) {
//just insert over this node because nothing is above at the same level
to_pos=to_node->get_index();
to_node=to_node->get_parent();
+
}
} else if (p_type==1) {
@@ -1650,12 +1638,13 @@ void SceneTreeDock::_normalize_drop(Node*& to_node, int &to_pos,int p_type) {
break;
}
}
-
if (lower_sibling) {
to_pos=lower_sibling->get_index();
}
to_node=to_node->get_parent();
+
+
}
#if 0
//quite complicated, look for next visible in tree
diff --git a/tools/editor/scene_tree_dock.h b/tools/editor/scene_tree_dock.h
index 60bec9b4f4..51041a235b 100644
--- a/tools/editor/scene_tree_dock.h
+++ b/tools/editor/scene_tree_dock.h
@@ -139,7 +139,7 @@ class SceneTreeDock : public VBoxContainer {
void _fill_path_renames(Vector<StringName> base_path,Vector<StringName> new_base_path,Node * p_node, List<Pair<NodePath,NodePath> > *p_renames);
- void _normalize_drop(Node*& to_node, int &to_pos,int p_type);
+ void _normalize_drop(Node*& to_node, int &to_pos, int p_type);
void _nodes_dragged(Array p_nodes,NodePath p_to,int p_type);
void _files_dropped(Vector<String> p_files,NodePath p_to,int p_type);
diff --git a/tools/editor/scenes_dock.cpp b/tools/editor/scenes_dock.cpp
index cbd7df9d18..75c983994e 100644
--- a/tools/editor/scenes_dock.cpp
+++ b/tools/editor/scenes_dock.cpp
@@ -37,6 +37,8 @@
#include "editor_settings.h"
#include "scene/main/viewport.h"
+
+
bool ScenesDock::_create_tree(TreeItem *p_parent,EditorFileSystemDirectory *p_dir) {
@@ -57,60 +59,8 @@ bool ScenesDock::_create_tree(TreeItem *p_parent,EditorFileSystemDirectory *p_di
item->select(0);
}
-
- //item->set_custom_bg_color(0,get_color("prop_subsection","Editor"));
-
- bool has_items=false;
-
- for(int i=0;i<p_dir->get_subdir_count();i++) {
-
- if (_create_tree(item,p_dir->get_subdir(i)))
- has_items=true;
- }
-#if 0
- for (int i=0;i<p_dir->get_file_count();i++) {
-
- String file_name = p_dir->get_file(i);
- String file_path = p_dir->get_file_path(i);
-
- // ScenesDockFilter::FILTER_PATH
- String search_from = file_path.right(6); // trim "res://"
- if (file_filter == ScenesDockFilter::FILTER_NAME)
- search_from = file_name;
- else if (file_filter == ScenesDockFilter::FILTER_FOLDER)
- search_from = file_path.right(6).get_base_dir();
-
- if (search_term!="" && search_from.findn(search_term)==-1)
- continue;
-
- bool isfave = favorites.has(file_path);
- if (button_favorite->is_pressed() && !isfave)
- continue;
-
- TreeItem *fitem = tree->create_item(item);
- fitem->set_cell_mode(0,TreeItem::CELL_MODE_CHECK);
- fitem->set_editable(0,true);
- fitem->set_checked(0,isfave);
- fitem->set_text(0,file_name);
-
- Ref<Texture> icon = get_icon( (has_icon(p_dir->get_file_type(i),"EditorIcons")?p_dir->get_file_type(i):String("Object")),"EditorIcons");
- fitem->set_icon(0, icon );
-
-
- fitem->set_metadata(0,file_path);
- //if (p_dir->files[i]->icon.is_valid()) {
-// fitem->set_icon(0,p_dir->files[i]->icon);
-// }
- has_items=true;
-
- }
-#endif
- /*if (!has_items) {
-
- memdelete(item);
- return false;
-
- }*/
+ for(int i=0;i<p_dir->get_subdir_count();i++)
+ _create_tree(item,p_dir->get_subdir(i));
return true;
}
@@ -164,12 +114,14 @@ void ScenesDock::_notification(int p_what) {
if (split_mode) {
file_list_vb->hide();
+ tree->set_custom_minimum_size(Size2(0,0));
tree->set_v_size_flags(SIZE_EXPAND_FILL);
button_back->show();
} else {
tree->show();
file_list_vb->show();
+ tree->set_custom_minimum_size(Size2(0,200)*EDSCALE);
tree->set_v_size_flags(SIZE_FILL);
button_back->hide();
if (!EditorFileSystem::get_singleton()->is_scanning()) {
@@ -187,6 +139,7 @@ void ScenesDock::_notification(int p_what) {
initialized=true;
EditorFileSystem::get_singleton()->connect("filesystem_changed",this,"_fs_changed");
+ EditorResourcePreview::get_singleton()->connect("preview_invalidated",this,"_preview_invalidated");
button_reload->set_icon( get_icon("Reload","EditorIcons"));
button_favorite->set_icon( get_icon("Favorites","EditorIcons"));
@@ -661,6 +614,27 @@ void ScenesDock::_go_to_dir(const String& p_dir){
}
+
+void ScenesDock::_preview_invalidated(const String& p_path) {
+
+ if (p_path.get_base_dir()==path && search_box->get_text()==String() && file_list_vb->is_visible()) {
+
+
+ for(int i=0;i<files->get_item_count();i++) {
+
+ if (files->get_item_metadata(i)==p_path) {
+ //re-request preview
+ Array udata;
+ udata.resize(2);
+ udata[0]=i;
+ udata[1]=files->get_item_text(i);
+ EditorResourcePreview::get_singleton()->queue_resource_preview(p_path,this,"_thumbnail_done",udata);
+ break;
+ }
+ }
+ }
+}
+
void ScenesDock::_fs_changed() {
button_hist_prev->set_disabled(history_pos==0);
@@ -1618,6 +1592,9 @@ void ScenesDock::_bind_methods() {
ObjectTypeDB::bind_method(_MD("drop_data_fw"), &ScenesDock::drop_data_fw);
ObjectTypeDB::bind_method(_MD("_files_list_rmb_select"),&ScenesDock::_files_list_rmb_select);
+ ObjectTypeDB::bind_method(_MD("_preview_invalidated"),&ScenesDock::_preview_invalidated);
+
+
ADD_SIGNAL(MethodInfo("instance"));
ADD_SIGNAL(MethodInfo("open"));
@@ -1702,7 +1679,6 @@ ScenesDock::ScenesDock(EditorNode *p_editor) {
tree->set_hide_root(true);
split_box->add_child(tree);
- tree->set_custom_minimum_size(Size2(0,200)*EDSCALE);
tree->set_drag_forwarding(this);
diff --git a/tools/editor/scenes_dock.h b/tools/editor/scenes_dock.h
index ed24711abb..0973fce250 100644
--- a/tools/editor/scenes_dock.h
+++ b/tools/editor/scenes_dock.h
@@ -168,6 +168,8 @@ class ScenesDock : public VBoxContainer {
bool can_drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from) const;
void drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from);
+ void _preview_invalidated(const String& p_path);
+
protected:
void _notification(int p_what);
static void _bind_methods();
diff --git a/tools/editor/script_editor_debugger.cpp b/tools/editor/script_editor_debugger.cpp
index 6d8f54d88f..fc746bc21d 100644
--- a/tools/editor/script_editor_debugger.cpp
+++ b/tools/editor/script_editor_debugger.cpp
@@ -819,7 +819,6 @@ void ScriptEditorDebugger::_performance_draw() {
if(which.empty())
return;
- Color graph_color=get_color("font_color","TextEdit");
Ref<StyleBox> graph_sb = get_stylebox("normal","TextEdit");
Ref<Font> graph_font = get_font("font","TextEdit");
diff --git a/tools/editor/settings_config_dialog.cpp b/tools/editor/settings_config_dialog.cpp
index e1a2ea162e..f436e369af 100644
--- a/tools/editor/settings_config_dialog.cpp
+++ b/tools/editor/settings_config_dialog.cpp
@@ -97,11 +97,24 @@ void EditorSettingsDialog::_clear_search_box() {
property_editor->get_property_editor()->update_tree();
}
+void EditorSettingsDialog::_clear_shortcut_search_box() {
+ if (shortcut_search_box->get_text()=="")
+ return;
+
+ shortcut_search_box->clear();
+}
+
+void EditorSettingsDialog::_filter_shortcuts(const String& p_filter) {
+ shortcut_filter = p_filter;
+ _update_shortcuts();
+}
+
void EditorSettingsDialog::_notification(int p_what) {
if (p_what==NOTIFICATION_ENTER_TREE) {
clear_button->set_icon(get_icon("Close","EditorIcons"));
+ shortcut_clear_button->set_icon(get_icon("Close","EditorIcons"));
}
}
@@ -137,26 +150,30 @@ void EditorSettingsDialog::_update_shortcuts() {
sections[section_name]=section;
section->set_custom_bg_color(0,get_color("prop_subsection","Editor"));
section->set_custom_bg_color(1,get_color("prop_subsection","Editor"));
-
}
- TreeItem *item = shortcuts->create_item(section);
-
-
- item->set_text(0,sc->get_name());
- item->set_text(1,sc->get_as_text());
- if (!sc->is_shortcut(original) && !(sc->get_shortcut().type==InputEvent::NONE && original.type==InputEvent::NONE)) {
- item->add_button(1,get_icon("Reload","EditorIcons"),2);
+ if (shortcut_filter.is_subsequence_ofi(sc->get_name())) {
+ TreeItem *item = shortcuts->create_item(section);
+
+ item->set_text(0,sc->get_name());
+ item->set_text(1,sc->get_as_text());
+ if (!sc->is_shortcut(original) && !(sc->get_shortcut().type==InputEvent::NONE && original.type==InputEvent::NONE)) {
+ item->add_button(1,get_icon("Reload","EditorIcons"),2);
+ }
+ item->add_button(1,get_icon("Edit","EditorIcons"),0);
+ item->add_button(1,get_icon("Close","EditorIcons"),1);
+ item->set_tooltip(0,E->get());
+ item->set_metadata(0,E->get());
}
- item->add_button(1,get_icon("Edit","EditorIcons"),0);
- item->add_button(1,get_icon("Close","EditorIcons"),1);
- item->set_tooltip(0,E->get());
- item->set_metadata(0,E->get());
}
-
-
-
+ // remove sections with no shortcuts
+ for(Map<String,TreeItem*>::Element *E=sections.front();E;E=E->next()) {
+ TreeItem *section = E->get();
+ if (section->get_children() == NULL) {
+ root->remove_child(section);
+ }
+ }
}
void EditorSettingsDialog::_shortcut_button_pressed(Object* p_item,int p_column,int p_idx) {
@@ -265,7 +282,9 @@ void EditorSettingsDialog::_bind_methods() {
ObjectTypeDB::bind_method(_MD("_settings_save"),&EditorSettingsDialog::_settings_save);
ObjectTypeDB::bind_method(_MD("_settings_changed"),&EditorSettingsDialog::_settings_changed);
ObjectTypeDB::bind_method(_MD("_clear_search_box"),&EditorSettingsDialog::_clear_search_box);
+ ObjectTypeDB::bind_method(_MD("_clear_shortcut_search_box"),&EditorSettingsDialog::_clear_shortcut_search_box);
ObjectTypeDB::bind_method(_MD("_shortcut_button_pressed"),&EditorSettingsDialog::_shortcut_button_pressed);
+ ObjectTypeDB::bind_method(_MD("_filter_shortcuts"),&EditorSettingsDialog::_filter_shortcuts);
ObjectTypeDB::bind_method(_MD("_update_shortcuts"),&EditorSettingsDialog::_update_shortcuts);
ObjectTypeDB::bind_method(_MD("_press_a_key_confirm"),&EditorSettingsDialog::_press_a_key_confirm);
ObjectTypeDB::bind_method(_MD("_wait_for_key"),&EditorSettingsDialog::_wait_for_key);
@@ -311,6 +330,23 @@ EditorSettingsDialog::EditorSettingsDialog() {
tabs->add_child(vbc);
vbc->set_name(TTR("Shortcuts"));
+ hbc = memnew( HBoxContainer );
+ hbc->set_h_size_flags(Control::SIZE_EXPAND_FILL);
+ vbc->add_child(hbc);
+
+ l = memnew( Label );
+ l->set_text(TTR("Search:")+" ");
+ hbc->add_child(l);
+
+ shortcut_search_box = memnew( LineEdit );
+ shortcut_search_box->set_h_size_flags(Control::SIZE_EXPAND_FILL);
+ hbc->add_child(shortcut_search_box);
+ shortcut_search_box->connect("text_changed", this, "_filter_shortcuts");
+
+ shortcut_clear_button = memnew( ToolButton );
+ hbc->add_child(shortcut_clear_button);
+ shortcut_clear_button->connect("pressed",this,"_clear_shortcut_search_box");
+
shortcuts = memnew( Tree );
vbc->add_margin_child("Shortcut List:",shortcuts,true);
shortcuts->set_columns(2);
diff --git a/tools/editor/settings_config_dialog.h b/tools/editor/settings_config_dialog.h
index c930de6a77..68a2b008f0 100644
--- a/tools/editor/settings_config_dialog.h
+++ b/tools/editor/settings_config_dialog.h
@@ -45,7 +45,9 @@ class EditorSettingsDialog : public AcceptDialog {
TabContainer *tabs;
LineEdit *search_box;
+ LineEdit *shortcut_search_box;
ToolButton *clear_button;
+ ToolButton *shortcut_clear_button;
SectionedPropertyEditor *property_editor;
Timer *timer;
@@ -56,6 +58,7 @@ class EditorSettingsDialog : public AcceptDialog {
Label *press_a_key_label;
InputEvent last_wait_for_key;
String shortcut_configured;
+ String shortcut_filter;
virtual void cancel_pressed();
virtual void ok_pressed();
@@ -69,8 +72,11 @@ class EditorSettingsDialog : public AcceptDialog {
void _press_a_key_confirm();
void _wait_for_key(const InputEvent& p_event);
+ void _clear_shortcut_search_box();
void _clear_search_box();
+ void _filter_shortcuts(const String& p_filter);
+
void _update_shortcuts();
void _shortcut_button_pressed(Object* p_item,int p_column,int p_idx);
diff --git a/tools/editor/spatial_editor_gizmos.cpp b/tools/editor/spatial_editor_gizmos.cpp
index 1ca62d3a63..480d33fd0a 100644
--- a/tools/editor/spatial_editor_gizmos.cpp
+++ b/tools/editor/spatial_editor_gizmos.cpp
@@ -424,16 +424,11 @@ bool EditorSpatialGizmo::intersect_ray(const Camera *p_camera,const Point2& p_po
}
Transform ti=t.affine_inverse();
- Vector3 ray_from=ti.xform(p_camera->project_ray_origin(p_point));
- Vector3 ray_dir=t.basis.xform_inv(p_camera->project_ray_normal(p_point)).normalized();
- Vector3 ray_to = ray_from+ray_dir*4096;
float min_d=1e20;
int idx=-1;
for(int i=0;i<secondary_handles.size();i++) {
-#if 1
-
Vector3 hpos = t.xform(secondary_handles[i]);
Vector2 p = p_camera->unproject_position(hpos);
@@ -449,31 +444,7 @@ bool EditorSpatialGizmo::intersect_ray(const Camera *p_camera,const Point2& p_po
idx=i+handles.size();
}
-
}
-
-#else
- AABB aabb;
- aabb.pos=Vector3(-1,-1,-1)*HANDLE_HALF_SIZE;
- aabb.size=aabb.pos*-2;
- aabb.pos+=secondary_handles[i];
-
-
- Vector3 rpos,rnorm;
-
- if (aabb.intersects_segment(ray_from,ray_to,&rpos,&rnorm)) {
-
- real_t dp = ray_dir.dot(rpos);
- if (dp<min_d) {
-
- r_pos=t.xform(rpos);
- r_normal=ti.basis.xform_inv(rnorm).normalized();
- min_d=dp;
- idx=i+handles.size();
-
- }
- }
-#endif
}
if (p_sec_first && idx!=-1) {
@@ -486,9 +457,6 @@ bool EditorSpatialGizmo::intersect_ray(const Camera *p_camera,const Point2& p_po
for(int i=0;i<handles.size();i++) {
-#if 1
-
-
Vector3 hpos = t.xform(handles[i]);
Vector2 p = p_camera->unproject_position(hpos);
if (p.distance_to(p_point)<SpatialEditorGizmos::singleton->handle_t->get_width()*0.6) {
@@ -503,32 +471,7 @@ bool EditorSpatialGizmo::intersect_ray(const Camera *p_camera,const Point2& p_po
idx=i;
}
-
- }
-
-#else
-
- AABB aabb;
- aabb.pos=Vector3(-1,-1,-1)*HANDLE_HALF_SIZE;
- aabb.size=aabb.pos*-2;
- aabb.pos+=handles[i];
-
-
- Vector3 rpos,rnorm;
-
- if (aabb.intersects_segment(ray_from,ray_to,&rpos,&rnorm)) {
-
- real_t dp = ray_dir.dot(rpos);
- if (dp<min_d) {
-
- r_pos=t.xform(rpos);
- r_normal=ti.basis.xform_inv(rnorm).normalized();
- min_d=dp;
- idx=i;
-
- }
}
-#endif
}
if (idx>=0) {
@@ -612,9 +555,6 @@ bool EditorSpatialGizmo::intersect_ray(const Camera *p_camera,const Point2& p_po
Vector3 ray_dir=ai.basis.xform(p_camera->project_ray_normal(p_point)).normalized();
Vector3 rpos,rnorm;
-#if 1
-
-
if (collision_mesh->intersect_ray(ray_from,ray_dir,rpos,rnorm)) {
@@ -622,16 +562,6 @@ bool EditorSpatialGizmo::intersect_ray(const Camera *p_camera,const Point2& p_po
r_normal=gt.basis.xform(rnorm).normalized();
return true;
}
-#else
-
- if (collision_mesh->intersect_segment(ray_from,ray_from+ray_dir*4906.0,rpos,rnorm)) {
-
- r_pos=gt.xform(rpos);
- r_normal=gt.basis.xform(rnorm).normalized();
- return true;
- }
-
-#endif
}
return false;
@@ -693,12 +623,11 @@ void EditorSpatialGizmo::_bind_methods() {
ObjectTypeDB::bind_method(_MD("add_unscaled_billboard","material:Material","default_scale"),&EditorSpatialGizmo::add_unscaled_billboard,DEFVAL(1));
ObjectTypeDB::bind_method(_MD("add_handles","handles","billboard","secondary"),&EditorSpatialGizmo::add_handles,DEFVAL(false),DEFVAL(false));
ObjectTypeDB::bind_method(_MD("set_spatial_node","node:Spatial"),&EditorSpatialGizmo::_set_spatial_node);
+ ObjectTypeDB::bind_method(_MD("clear"),&EditorSpatialGizmo::clear);
BIND_VMETHOD( MethodInfo("redraw"));
BIND_VMETHOD( MethodInfo(Variant::STRING,"get_handle_name",PropertyInfo(Variant::INT,"index")));
- {
- BIND_VMETHOD( MethodInfo("get_handle_value:Variant",PropertyInfo(Variant::INT,"index")));
- }
+ BIND_VMETHOD( MethodInfo("get_handle_value:Variant",PropertyInfo(Variant::INT,"index")));
BIND_VMETHOD( MethodInfo("set_handle",PropertyInfo(Variant::INT,"index"),PropertyInfo(Variant::OBJECT,"camera:Camera"),PropertyInfo(Variant::VECTOR2,"point")));
MethodInfo cm = MethodInfo("commit_handle",PropertyInfo(Variant::INT,"index"),PropertyInfo(Variant::NIL,"restore:Variant"),PropertyInfo(Variant::BOOL,"cancel"));
cm.default_arguments.push_back(false);
@@ -2250,7 +2179,6 @@ void VisibilityNotifierGizmo::set_handle(int p_idx,Camera *p_camera, const Point
if (d<0.001)
d=0.001;
- Vector3 he = aabb.size;
aabb.pos[p_idx]=(aabb.pos[p_idx]+aabb.size[p_idx]*0.5)-d;
aabb.size[p_idx]=d*2;
notifier->set_aabb(aabb);
@@ -2456,8 +2384,6 @@ void HingeJointSpatialGizmo::redraw() {
if (p3d->get_flag(HingeJoint::FLAG_USE_LIMIT) && ll<ul) {
const int points = 32;
- float step = (ul-ll)/points;
-
for(int i=0;i<points;i++) {
@@ -2573,8 +2499,6 @@ void SliderJointSpatialGizmo::redraw() {
if (ll<ul) {
const int points = 32;
- float step = (ul-ll)/points;
-
for(int i=0;i<points;i++) {
@@ -2641,7 +2565,6 @@ SliderJointSpatialGizmo::SliderJointSpatialGizmo(SliderJoint* p_p3d) {
void ConeTwistJointSpatialGizmo::redraw() {
clear();
- float cs = 0.25;
Vector<Vector3> points;
float r = 1.0;
@@ -2837,8 +2760,6 @@ void Generic6DOFJointSpatialGizmo::redraw() {
if (enable_ang && ll<=ul) {
const int points = 32;
- float step = (ul-ll)/points;
-
for(int i=0;i<points;i++) {