summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2017-02-07 14:14:54 +0100
committerGitHub <noreply@github.com>2017-02-07 14:14:54 +0100
commitbd8df0f21dfa0d9c68d14107bcb4f4b2cc4e099d (patch)
treed2c505c99a61d77047df338546f4d8882dffbe0d /tools
parent6bfaa0f12c65947ab0f124ec4c75345bd1332b77 (diff)
parent6f3fc1f05a015e0b4f2e5e5db430217298c1e970 (diff)
Merge pull request #7709 from bojidar-bg/sort-scripts-by-path
Sort settings for scripts in the editor
Diffstat (limited to 'tools')
-rw-r--r--tools/editor/plugins/script_editor_plugin.cpp43
-rw-r--r--tools/editor/plugins/script_editor_plugin.h11
2 files changed, 50 insertions, 4 deletions
diff --git a/tools/editor/plugins/script_editor_plugin.cpp b/tools/editor/plugins/script_editor_plugin.cpp
index 4738b348f4..5f97fce4e7 100644
--- a/tools/editor/plugins/script_editor_plugin.cpp
+++ b/tools/editor/plugins/script_editor_plugin.cpp
@@ -1334,6 +1334,7 @@ void ScriptEditor::_find_scripts(Node* p_base, Node* p_current, Set<Ref<Script>
struct _ScriptEditorItemData {
String name;
+ String sort_key;
Ref<Texture> icon;
int index;
String tooltip;
@@ -1343,7 +1344,7 @@ struct _ScriptEditorItemData {
bool operator<(const _ScriptEditorItemData& id) const {
- return category==id.category?name.nocasecmp_to(id.name)<0:category<id.category;
+ return category==id.category?sort_key<id.sort_key:category<id.category;
}
};
@@ -1404,6 +1405,8 @@ void ScriptEditor::_update_script_names() {
script_list->clear();
bool split_script_help = EditorSettings::get_singleton()->get("text_editor/open_scripts/group_help_pages");
+ ScriptSortBy sort_by = (ScriptSortBy) (int) EditorSettings::get_singleton()->get("text_editor/open_scripts/sort_scripts_by");
+ ScriptListName display_as = (ScriptListName) (int) EditorSettings::get_singleton()->get("text_editor/open_scripts/list_script_names_as");
Vector<_ScriptEditorItemData> sedata;
@@ -1415,15 +1418,41 @@ void ScriptEditor::_update_script_names() {
String name = se->get_name();
Ref<Texture> icon = se->get_icon();
- String tooltip = se->get_edited_script()->get_path();
+ String path = se->get_edited_script()->get_path();
_ScriptEditorItemData sd;
sd.icon=icon;
sd.name=name;
- sd.tooltip=tooltip;
+ sd.tooltip=path;
sd.index=i;
sd.used=used.has(se->get_edited_script());
sd.category=0;
+
+ switch (sort_by) {
+ case SORT_BY_NAME: {
+ sd.sort_key=name.to_lower();
+ } break;
+ case SORT_BY_PATH: {
+ sd.sort_key=path;
+ } break;
+ }
+
+ switch (display_as) {
+ case DISPLAY_NAME: {
+ sd.name=name;
+ } break;
+ case DISPLAY_DIR_AND_NAME: {
+ if (!path.get_base_dir().get_file().empty()) {
+ sd.name=path.get_base_dir().get_file() + "/" + name;
+ } else {
+ sd.name=name;
+ }
+ } break;
+ case DISPLAY_FULL_PATH: {
+ sd.name=path;
+ } break;
+ }
+
sedata.push_back(sd);
}
@@ -1438,6 +1467,7 @@ void ScriptEditor::_update_script_names() {
_ScriptEditorItemData sd;
sd.icon=icon;
sd.name=name;
+ sd.sort_key=name;
sd.tooltip=tooltip;
sd.index=i;
sd.used=false;
@@ -1727,6 +1757,7 @@ void ScriptEditor::_editor_settings_changed() {
se->update_settings();
}
_update_script_colors();
+ _update_script_names();
ScriptServer::set_reload_scripts_on_save(EDITOR_DEF("text_editor/files/auto_reload_and_parse_scripts_on_save",true));
@@ -2440,9 +2471,13 @@ ScriptEditorPlugin::ScriptEditorPlugin(EditorNode *p_node) {
EDITOR_DEF("text_editor/open_scripts/script_temperature_cold_color",Color(0,0,1,0.3));
EDITOR_DEF("text_editor/open_scripts/current_script_background_color",Color(0.81,0.81,0.14,0.63));
EDITOR_DEF("text_editor/open_scripts/group_help_pages",true);
+ EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::INT,"text_editor/open_scripts/sort_scripts_by",PROPERTY_HINT_ENUM,"Name,Path"));
+ EDITOR_DEF("text_editor/open_scripts/sort_scripts_by",0);
+ EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::INT,"text_editor/open_scripts/list_script_names_as",PROPERTY_HINT_ENUM,"Name,Parent Directory And Name,Full Path"));
+ EDITOR_DEF("text_editor/open_scripts/list_script_names_as",0);
EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING,"text_editor/external/exec_path",PROPERTY_HINT_GLOBAL_FILE));
EDITOR_DEF("text_editor/external/exec_flags","");
-
+
}
diff --git a/tools/editor/plugins/script_editor_plugin.h b/tools/editor/plugins/script_editor_plugin.h
index 887c2f7d68..75099fc5ec 100644
--- a/tools/editor/plugins/script_editor_plugin.h
+++ b/tools/editor/plugins/script_editor_plugin.h
@@ -154,6 +154,17 @@ class ScriptEditor : public VBoxContainer {
WINDOW_PREV,
WINDOW_SELECT_BASE=100
};
+
+ enum ScriptSortBy {
+ SORT_BY_NAME,
+ SORT_BY_PATH,
+ };
+
+ enum ScriptListName {
+ DISPLAY_NAME,
+ DISPLAY_DIR_AND_NAME,
+ DISPLAY_FULL_PATH,
+ };
HBoxContainer *menu_hb;
MenuButton *file_menu;