summaryrefslogtreecommitdiff
path: root/editor/editor_node.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/editor_node.cpp')
-rw-r--r--editor/editor_node.cpp66
1 files changed, 47 insertions, 19 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index b3a8490fe9..a9423019dd 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -906,23 +906,29 @@ void EditorNode::_save_scene_with_preview(String p_file, int p_idx) {
int preview_size = EditorSettings::get_singleton()->get("filesystem/file_dialog/thumbnail_size");
preview_size *= EDSCALE;
- int width, height;
- if (img->get_width() > preview_size && img->get_width() >= img->get_height()) {
- width = preview_size;
- height = img->get_height() * preview_size / img->get_width();
- } else if (img->get_height() > preview_size && img->get_height() >= img->get_width()) {
+ // consider a square region
+ int vp_size = MIN(img->get_width(), img->get_height());
+ int x = (img->get_width() - vp_size) / 2;
+ int y = (img->get_height() - vp_size) / 2;
- height = preview_size;
- width = img->get_width() * preview_size / img->get_height();
+ img->convert(Image::FORMAT_RGB8);
+
+ if (vp_size < preview_size) {
+ // just square it.
+ img->crop_from_point(x, y, vp_size, vp_size);
} else {
+ int ratio = vp_size / preview_size;
+ int size = preview_size * (ratio / 2);
- width = img->get_width();
- height = img->get_height();
+ x = (img->get_width() - size) / 2;
+ y = (img->get_height() - size) / 2;
+
+ img->crop_from_point(x, y, size, size);
+ // We could get better pictures with better filters
+ img->resize(preview_size, preview_size, Image::INTERPOLATE_CUBIC);
}
- img->convert(Image::FORMAT_RGB8);
- img->resize(width, height);
img->flip_y();
//save thumbnail directly, as thumbnailer may not update due to actual scene not changing md5
@@ -1109,7 +1115,7 @@ void EditorNode::_dialog_action(String p_file) {
_save_default_environment();
_save_scene_with_preview(p_file);
- _run(false);
+ _run(false, p_file);
}
} break;
@@ -3273,7 +3279,7 @@ void EditorNode::register_editor_types() {
ClassDB::register_class<EditorResourceConversionPlugin>();
// FIXME: Is this stuff obsolete, or should it be ported to new APIs?
- //ClassDB::register_class<EditorScenePostImport>();
+ ClassDB::register_class<EditorScenePostImport>();
//ClassDB::register_type<EditorImportExport>();
}
@@ -4276,12 +4282,19 @@ Variant EditorNode::drag_files_and_dirs(const Vector<String> &p_paths, Control *
void EditorNode::_dropped_files(const Vector<String> &p_files, int p_screen) {
- /*
- String cur_path = filesystem_dock->get_current_path();
- for(int i=0;i<EditorImportExport::get_singleton()->get_import_plugin_count();i++) {
- EditorImportExport::get_singleton()->get_import_plugin(i)->import_from_drop(p_files,cur_path);
+ String to_path = ProjectSettings::get_singleton()->globalize_path(get_filesystem_dock()->get_current_path());
+ DirAccessRef dir = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
+
+ for (int i = 0; i < p_files.size(); i++) {
+
+ String from = p_files[i];
+ if (!ResourceFormatImporter::get_singleton()->can_be_imported(from)) {
+ continue;
+ }
+ String to = to_path.plus_file(from.get_file());
+ dir->copy(from, to);
}
- */
+ EditorFileSystem::get_singleton()->scan_changes();
}
void EditorNode::_file_access_close_error_notify(const String &p_str) {
@@ -4552,6 +4565,11 @@ static Node *_resource_get_edited_scene() {
return EditorNode::get_singleton()->get_edited_scene();
}
+void EditorNode::_print_handler(void *p_this, const String &p_string, bool p_error) {
+ EditorNode *en = (EditorNode *)p_this;
+ en->log->add_message(p_string, p_error);
+}
+
EditorNode::EditorNode() {
Resource::_get_local_scene_func = _resource_get_edited_scene;
@@ -4788,7 +4806,12 @@ EditorNode::EditorNode() {
dock_tab_move_left->set_focus_mode(Control::FOCUS_NONE);
dock_tab_move_left->connect("pressed", this, "_dock_move_left");
dock_hb->add_child(dock_tab_move_left);
- dock_hb->add_spacer();
+
+ Label *dock_label = memnew(Label);
+ dock_label->set_text(TTR("Dock Position"));
+ dock_label->set_h_size_flags(Control::SIZE_EXPAND_FILL);
+ dock_hb->add_child(dock_label);
+
dock_tab_move_right = memnew(ToolButton);
dock_tab_move_right->set_icon(theme->get_icon("Forward", "EditorIcons"));
dock_tab_move_right->set_focus_mode(Control::FOCUS_NONE);
@@ -5652,6 +5675,10 @@ EditorNode::EditorNode() {
_dim_timer->connect("timeout", this, "_dim_timeout");
add_child(_dim_timer);
+ print_handler.printfunc = _print_handler;
+ print_handler.userdata = this;
+ add_print_handler(&print_handler);
+
ED_SHORTCUT("editor/editor_2d", TTR("Open 2D Editor"), KEY_F1);
ED_SHORTCUT("editor/editor_3d", TTR("Open 3D Editor"), KEY_F2);
ED_SHORTCUT("editor/editor_script", TTR("Open Script Editor"), KEY_F3); //hack neded for script editor F3 search to work :) Assign like this or don't use F3
@@ -5663,6 +5690,7 @@ EditorNode::EditorNode() {
EditorNode::~EditorNode() {
+ remove_print_handler(&print_handler);
memdelete(EditorHelp::get_doc_data());
memdelete(editor_selection);
memdelete(editor_plugins_over);