summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
Diffstat (limited to 'editor')
-rw-r--r--editor/editor_file_system.cpp48
-rw-r--r--editor/editor_node.cpp23
-rw-r--r--editor/editor_node.h3
-rw-r--r--editor/editor_settings.cpp2
-rw-r--r--editor/plugins/script_editor_plugin.cpp39
-rw-r--r--editor/project_manager.cpp42
-rw-r--r--editor/project_settings.cpp3
-rw-r--r--editor/property_editor.cpp9
8 files changed, 96 insertions, 73 deletions
diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp
index 2612a2af16..3fb2923696 100644
--- a/editor/editor_file_system.cpp
+++ b/editor/editor_file_system.cpp
@@ -487,6 +487,22 @@ bool EditorFileSystem::_check_missing_imported_files(const String &p_path) {
return true;
}
+static bool _find_project(const String &p_path) {
+ DirAccess *dir_access = DirAccess::create_for_path(p_path);
+ bool ret = false;
+ while (true) {
+ bool is_dir;
+ String file = dir_access->get_next(&is_dir);
+ if (file == "")
+ break;
+ if (file.ends_with(".godot")) {
+ ret = true;
+ }
+ }
+ memdelete(dir_access);
+ return ret;
+}
+
void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess *da, const ScanProgress &p_progress) {
List<String> dirs;
@@ -509,8 +525,9 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess
if (f.begins_with(".")) //ignore hidden and . / ..
continue;
- if (FileAccess::exists(cd.plus_file(f).plus_file("godot.cfg"))) // skip if another project inside this
+ if (_find_project(cd.plus_file(f))) {
continue;
+ }
dirs.push_back(f);
@@ -676,34 +693,35 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir, const
while (true) {
bool isdir;
- String f = da->get_next(&isdir);
- if (f == "")
+ String file = da->get_next(&isdir);
+ if (file == "")
break;
if (isdir) {
- if (f.begins_with(".")) //ignore hidden and . / ..
+ if (file.begins_with(".")) //ignore hidden and . / ..
continue;
- int idx = p_dir->find_dir_index(f);
+ int idx = p_dir->find_dir_index(file);
if (idx == -1) {
- if (FileAccess::exists(cd.plus_file(f).plus_file("godot.cfg"))) // skip if another project inside this
+ if (_find_project(cd.plus_file(file))) {
continue;
+ }
EditorFileSystemDirectory *efd = memnew(EditorFileSystemDirectory);
efd->parent = p_dir;
- efd->name = f;
+ efd->name = file;
DirAccess *d = DirAccess::create(DirAccess::ACCESS_RESOURCES);
- d->change_dir(cd.plus_file(f));
+ d->change_dir(cd.plus_file(file));
_scan_new_dir(efd, d, p_progress.get_sub(1, 1));
memdelete(d);
ItemAction ia;
ia.action = ItemAction::ACTION_DIR_ADD;
ia.dir = p_dir;
- ia.file = f;
+ ia.file = file;
ia.new_dir = efd;
scan_actions.push_back(ia);
} else {
@@ -711,16 +729,16 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir, const
}
} else {
- String ext = f.get_extension().to_lower();
+ String ext = file.get_extension().to_lower();
if (!valid_extensions.has(ext))
continue; //invalid
- int idx = p_dir->find_file_index(f);
+ int idx = p_dir->find_file_index(file);
if (idx == -1) {
//never seen this file, add actition to add it
EditorFileSystemDirectory::FileInfo *fi = memnew(EditorFileSystemDirectory::FileInfo);
- fi->file = f;
+ fi->file = file;
String path = cd.plus_file(fi->file);
fi->modified_time = FileAccess::get_modified_time(path);
@@ -731,7 +749,7 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir, const
ItemAction ia;
ia.action = ItemAction::ACTION_FILE_ADD;
ia.dir = p_dir;
- ia.file = f;
+ ia.file = file;
ia.new_file = fi;
scan_actions.push_back(ia);
}
@@ -739,14 +757,14 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir, const
if (import_extensions.has(ext)) {
//if it can be imported, and it was added, it needs to be reimported
print_line("REIMPORT: file was not found before, reimport");
- print_line("at dir: " + p_dir->get_path() + " file: " + f);
+ print_line("at dir: " + p_dir->get_path() + " file: " + file);
for (int i = 0; i < p_dir->files.size(); i++) {
print_line(itos(i) + ": " + p_dir->files[i]->file);
}
ItemAction ia;
ia.action = ItemAction::ACTION_FILE_REIMPORT;
ia.dir = p_dir;
- ia.file = f;
+ ia.file = file;
scan_actions.push_back(ia);
}
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 1223abd76c..cc7ee44902 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -447,18 +447,6 @@ void EditorNode::_sources_changed(bool p_exist) {
void EditorNode::_vp_resized() {
}
-void EditorNode::_rebuild_import_menu() {
- PopupMenu *p = import_menu->get_popup();
- p->clear();
-//p->add_item(TTR("Node From Scene"), FILE_IMPORT_SUBSCENE);
-//p->add_separator();
-#if 0
- 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);
- }
-#endif
-}
-
void EditorNode::_node_renamed() {
if (property_editor)
@@ -5257,15 +5245,6 @@ EditorNode::EditorNode() {
menu_panel->add_child( resource_menu );
#endif
- import_menu = memnew(MenuButton);
- import_menu->set_tooltip(TTR("Import assets to the project."));
- import_menu->set_text(TTR("Import"));
- //import_menu->set_icon(gui_base->get_icon("Save","EditorIcons"));
- left_menu_hb->add_child(import_menu);
-
- p = import_menu->get_popup();
- p->connect("id_pressed", this, "_menu_option");
-
tool_menu = memnew(MenuButton);
tool_menu->set_tooltip(TTR("Miscellaneous project or scene-wide tools."));
tool_menu->set_text(TTR("Tools"));
@@ -5960,8 +5939,6 @@ EditorNode::EditorNode() {
circle_step_frame = Engine::get_singleton()->get_frames_drawn();
circle_step = 0;
- _rebuild_import_menu();
-
editor_plugin_screen = NULL;
editor_plugins_over = memnew(EditorPluginList);
diff --git a/editor/editor_node.h b/editor/editor_node.h
index e7f4085fc5..7de713eae9 100644
--- a/editor/editor_node.h
+++ b/editor/editor_node.h
@@ -242,7 +242,6 @@ private:
HBoxContainer *menu_hb;
Control *viewport;
MenuButton *file_menu;
- MenuButton *import_menu;
MenuButton *tool_menu;
ToolButton *export_button;
ToolButton *prev_scene;
@@ -447,8 +446,6 @@ private:
void _show_messages();
void _vp_resized();
- void _rebuild_import_menu();
-
void _save_scene(String p_file, int idx = -1);
void _instance_request(const Vector<String> &p_files);
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index 8ea5d16bbf..f1daf05432 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -506,7 +506,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
set("interface/dim_editor_on_dialog_popup", true);
set("interface/dim_amount", 0.6f);
hints["interface/dim_amount"] = PropertyInfo(Variant::REAL, "interface/dim_amount", PROPERTY_HINT_RANGE, "0,1,0.01", PROPERTY_USAGE_DEFAULT);
- set("interface/dim_transition_time", 0.11f);
+ set("interface/dim_transition_time", 0.08f);
hints["interface/dim_transition_time"] = PropertyInfo(Variant::REAL, "interface/dim_transition_time", PROPERTY_HINT_RANGE, "0,1,0.001", PROPERTY_USAGE_DEFAULT);
set("filesystem/directories/autoscan_project_path", "");
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index 8ce0f51211..c94ab706bc 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -878,28 +878,29 @@ void ScriptEditor::_menu_option(int p_option) {
}
}
}
- }
+ } else {
- EditorHelp *help = tab_container->get_current_tab_control()->cast_to<EditorHelp>();
- if (help) {
+ EditorHelp *help = tab_container->get_current_tab_control()->cast_to<EditorHelp>();
+ if (help) {
- switch (p_option) {
+ switch (p_option) {
- case HELP_SEARCH_FIND: {
- help->popup_search();
- } break;
- case HELP_SEARCH_FIND_NEXT: {
- help->search_again();
- } break;
- case FILE_CLOSE: {
- _close_current_tab();
- } break;
- case CLOSE_DOCS: {
- _close_docs_tab();
- } break;
- case CLOSE_ALL: {
- _close_all_tabs();
- } break;
+ case HELP_SEARCH_FIND: {
+ help->popup_search();
+ } break;
+ case HELP_SEARCH_FIND_NEXT: {
+ help->search_again();
+ } break;
+ case FILE_CLOSE: {
+ _close_current_tab();
+ } break;
+ case CLOSE_DOCS: {
+ _close_docs_tab();
+ } break;
+ case CLOSE_ALL: {
+ _close_all_tabs();
+ } break;
+ }
}
}
}
diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp
index 7e9dc5f4f1..35b8973818 100644
--- a/editor/project_manager.cpp
+++ b/editor/project_manager.cpp
@@ -50,6 +50,19 @@
#include "scene/gui/tool_button.h"
#include "version.h"
+static String _find_project_file(DirAccess *p_da) {
+ p_da->list_dir_begin();
+ while (true) {
+ String f = p_da->get_next();
+ if (f == "")
+ break;
+ if (f.get_extension() == "godot")
+ return p_da->get_current_dir() + "/" + f;
+ }
+ p_da->list_dir_end();
+ return "";
+}
+
class NewProjectDialog : public ConfirmationDialog {
GDCLASS(NewProjectDialog, ConfirmationDialog);
@@ -92,18 +105,18 @@ private:
if (mode != MODE_IMPORT) {
- if (d->file_exists("godot.cfg")) {
+ if (_find_project_file(d) != "") {
- error->set_text(TTR("Invalid project path, godot.cfg must not exist."));
+ error->set_text(TTR("Invalid project path, *.godot must not exist."));
memdelete(d);
return "";
}
} else {
- if (valid_path != "" && !d->file_exists("godot.cfg")) {
+ if (valid_path != "" && _find_project_file(d) == "") {
- error->set_text(TTR("Invalid project path, godot.cfg must exist."));
+ error->set_text(TTR("Invalid project path, *.godot must exist."));
memdelete(d);
return "";
}
@@ -136,7 +149,7 @@ private:
String p = p_path;
if (mode == MODE_IMPORT) {
- if (p.ends_with("godot.cfg")) {
+ if (p.get_extension() == "godot") {
p = p.get_base_dir();
}
@@ -162,7 +175,7 @@ private:
fdialog->set_mode(FileDialog::MODE_OPEN_FILE);
fdialog->clear_filters();
- fdialog->add_filter("godot.cfg ; " _MKSTR(VERSION_NAME) " Project");
+ fdialog->add_filter("*.godot ; " _MKSTR(VERSION_NAME) " Project");
} else {
fdialog->set_mode(FileDialog::MODE_OPEN_DIR);
}
@@ -186,9 +199,9 @@ private:
} else {
if (mode == MODE_NEW) {
- FileAccess *f = FileAccess::open(dir.plus_file("/godot.cfg"), FileAccess::WRITE);
+ FileAccess *f = FileAccess::open(dir.plus_file("/" + project_name->get_text().replace(" ", "_") + ".godot"), FileAccess::WRITE);
if (!f) {
- error->set_text(TTR("Couldn't create godot.cfg in project path."));
+ error->set_text(TTR("Couldn't create *.godot project file in project path."));
} else {
f->store_line("; Engine configuration file.");
@@ -741,10 +754,17 @@ void ProjectManager::_load_recent_projects() {
continue;
String project = _name.get_slice("/", 1);
- String conf = path.plus_file("godot.cfg");
+ DirAccess *dir_access = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
+ if (dir_access->change_dir(path) != OK) {
+ EditorSettings::get_singleton()->erase(_name);
+ continue;
+ }
+ String conf = _find_project_file(dir_access);
+ memdelete(dir_access);
bool favorite = (_name.begins_with("favorite_projects/")) ? true : false;
uint64_t last_modified = 0;
+
if (FileAccess::exists(conf)) {
last_modified = FileAccess::get_modified_time(conf);
@@ -1006,7 +1026,7 @@ void ProjectManager::_scan_dir(DirAccess *da, float pos, float total, List<Strin
while (n != String()) {
if (da->current_is_dir() && !n.begins_with(".")) {
subdirs.push_front(n);
- } else if (n == "godot.cfg") {
+ } else if (n.get_extension() == "godot") {
r_projects->push_back(da->get_current_dir());
}
n = da->get_next();
@@ -1117,7 +1137,7 @@ void ProjectManager::_files_dropped(PoolStringArray p_files, int p_screen) {
dir->list_dir_begin();
String file = dir->get_next();
while (confirm && file != String()) {
- if (!dir->current_is_dir() && file.ends_with("godot.cfg")) {
+ if (!dir->current_is_dir() && file.get_extension() == "godot") {
confirm = false;
}
file = dir->get_next();
diff --git a/editor/project_settings.cpp b/editor/project_settings.cpp
index a45ea26086..bc1bdcf8af 100644
--- a/editor/project_settings.cpp
+++ b/editor/project_settings.cpp
@@ -1168,7 +1168,8 @@ void ProjectSettings::_bind_methods() {
ProjectSettings::ProjectSettings(EditorData *p_data) {
singleton = this;
- set_title(TTR("Project Settings (godot.cfg)"));
+ String project_file = "(" + GlobalConfig::get_singleton()->get_project_file_name() + ")";
+ set_title(TTR("Project Settings " + project_file));
set_resizable(true);
undo_redo = &p_data->get_undo_redo();
data = p_data;
diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp
index 86136fa78b..1cc58f6dcf 100644
--- a/editor/property_editor.cpp
+++ b/editor/property_editor.cpp
@@ -2388,6 +2388,10 @@ void PropertyEditor::set_item_text(TreeItem *p_item, int p_type, const String &p
RES res = obj->get(p_name).operator RefPtr();
if (res->is_class("Texture")) {
int tw = EditorSettings::get_singleton()->get("docks/property_editor/texture_preview_width");
+ Vector2 size(res->call("get_width"), res->call("get_height"));
+ if (size.width < size.height) {
+ tw = MAX((size.width / size.height) * tw, 1);
+ }
p_item->set_icon_max_width(1, tw);
p_item->set_icon(1, res);
p_item->set_text(1, "");
@@ -3618,6 +3622,10 @@ void PropertyEditor::update_tree() {
if (res->is_class("Texture")) {
int tw = EditorSettings::get_singleton()->get("docks/property_editor/texture_preview_width");
+ Vector2 size(res->call("get_width"), res->call("get_height"));
+ if (size.width < size.height) {
+ tw = MAX((size.width / size.height) * tw, 1);
+ }
item->set_icon_max_width(1, tw);
item->set_icon(1, res);
item->set_text(1, "");
@@ -4389,6 +4397,7 @@ PropertyEditor::PropertyEditor() {
capitalize_paths = true;
autoclear = false;
tree->set_column_titles_visible(false);
+ tree->add_constant_override("button_margin", 0);
keying = false;
read_only = false;