mirror of
https://github.com/godotengine/godot.git
synced 2025-12-08 06:09:55 +00:00
Bring that Whole New World to the Old Continent too
Applies the clang-format style to the 2.1 branch as done for master in
5dbf1809c6.
This commit is contained in:
parent
1d418afe86
commit
f8db8a3faa
1308 changed files with 147754 additions and 174357 deletions
|
|
@ -29,10 +29,9 @@
|
|||
#include "quick_open.h"
|
||||
#include "os/keyboard.h"
|
||||
|
||||
|
||||
void EditorQuickOpen::popup(const StringName &p_base, bool p_enable_multi, bool p_add_dirs, bool p_dontclear) {
|
||||
|
||||
add_directories=p_add_dirs;
|
||||
add_directories = p_add_dirs;
|
||||
popup_centered_ratio(0.6);
|
||||
if (p_dontclear)
|
||||
search_box->select_all();
|
||||
|
|
@ -43,7 +42,7 @@ void EditorQuickOpen::popup(const StringName &p_base, bool p_enable_multi, bool
|
|||
else
|
||||
search_options->set_select_mode(Tree::SELECT_SINGLE);
|
||||
search_box->grab_focus();
|
||||
base_type=p_base;
|
||||
base_type = p_base;
|
||||
_update_search();
|
||||
}
|
||||
|
||||
|
|
@ -60,10 +59,10 @@ Vector<String> EditorQuickOpen::get_selected_files() const {
|
|||
|
||||
Vector<String> files;
|
||||
|
||||
TreeItem* item = search_options->get_next_selected(search_options->get_root());
|
||||
TreeItem *item = search_options->get_next_selected(search_options->get_root());
|
||||
while (item) {
|
||||
|
||||
files.push_back("res://"+item->get_text(0));
|
||||
files.push_back("res://" + item->get_text(0));
|
||||
|
||||
item = search_options->get_next_selected(item);
|
||||
}
|
||||
|
|
@ -71,16 +70,16 @@ Vector<String> EditorQuickOpen::get_selected_files() const {
|
|||
return files;
|
||||
}
|
||||
|
||||
void EditorQuickOpen::_text_changed(const String& p_newtext) {
|
||||
void EditorQuickOpen::_text_changed(const String &p_newtext) {
|
||||
|
||||
_update_search();
|
||||
}
|
||||
|
||||
void EditorQuickOpen::_sbox_input(const InputEvent& p_ie) {
|
||||
void EditorQuickOpen::_sbox_input(const InputEvent &p_ie) {
|
||||
|
||||
if (p_ie.type==InputEvent::KEY) {
|
||||
if (p_ie.type == InputEvent::KEY) {
|
||||
|
||||
switch(p_ie.key.scancode) {
|
||||
switch (p_ie.key.scancode) {
|
||||
case KEY_UP:
|
||||
case KEY_DOWN:
|
||||
case KEY_PAGEUP:
|
||||
|
|
@ -106,7 +105,6 @@ void EditorQuickOpen::_sbox_input(const InputEvent& p_ie) {
|
|||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
float EditorQuickOpen::_path_cmp(String search, String path) const {
|
||||
|
|
@ -120,10 +118,10 @@ float EditorQuickOpen::_path_cmp(String search, String path) const {
|
|||
return path.to_lower().similarity(search.to_lower());
|
||||
}
|
||||
|
||||
void EditorQuickOpen::_parse_fs(EditorFileSystemDirectory *efsd, Vector< Pair< String, Ref<Texture> > > &list) {
|
||||
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++) {
|
||||
for (int i = 0; i < efsd->get_subdir_count(); i++) {
|
||||
|
||||
_parse_fs(efsd->get_subdir(i), list);
|
||||
}
|
||||
|
|
@ -134,11 +132,11 @@ void EditorQuickOpen::_parse_fs(EditorFileSystemDirectory *efsd, Vector< Pair< S
|
|||
if (add_directories) {
|
||||
String path = efsd->get_path();
|
||||
if (!path.ends_with("/"))
|
||||
path+="/";
|
||||
if (path!="res://") {
|
||||
path=path.substr(6,path.length());
|
||||
path += "/";
|
||||
if (path != "res://") {
|
||||
path = path.substr(6, path.length());
|
||||
if (search_text.is_subsequence_ofi(path)) {
|
||||
Pair< String, Ref<Texture> > pair;
|
||||
Pair<String, Ref<Texture> > pair;
|
||||
pair.first = path;
|
||||
pair.second = get_icon("folder", "FileDialog");
|
||||
|
||||
|
|
@ -161,13 +159,13 @@ void EditorQuickOpen::_parse_fs(EditorFileSystemDirectory *efsd, Vector< Pair< S
|
|||
}
|
||||
}
|
||||
}
|
||||
for(int i=0;i<efsd->get_file_count();i++) {
|
||||
for (int i = 0; i < efsd->get_file_count(); i++) {
|
||||
|
||||
String file = efsd->get_file_path(i);
|
||||
file=file.substr(6,file.length());
|
||||
file = file.substr(6, file.length());
|
||||
|
||||
if (ObjectTypeDB::is_type(efsd->get_file_type(i),base_type) && (search_text.is_subsequence_ofi(file))) {
|
||||
Pair< String, Ref<Texture> > pair;
|
||||
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);
|
||||
|
||||
|
|
@ -191,14 +189,12 @@ void EditorQuickOpen::_parse_fs(EditorFileSystemDirectory *efsd, Vector< Pair< S
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
if (add_directories) {
|
||||
for(int i=0;i<efsd->get_subdir_count();i++) {
|
||||
for (int i = 0; i < efsd->get_subdir_count(); i++) {
|
||||
|
||||
_parse_fs(efsd->get_subdir(i), list);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void EditorQuickOpen::_update_search() {
|
||||
|
|
@ -206,7 +202,7 @@ void EditorQuickOpen::_update_search() {
|
|||
search_options->clear();
|
||||
TreeItem *root = search_options->create_item();
|
||||
EditorFileSystemDirectory *efsd = EditorFileSystem::get_singleton()->get_filesystem();
|
||||
Vector< Pair< String, Ref<Texture> > > list;
|
||||
Vector<Pair<String, Ref<Texture> > > list;
|
||||
|
||||
_parse_fs(efsd, list);
|
||||
|
||||
|
|
@ -223,8 +219,7 @@ void EditorQuickOpen::_update_search() {
|
|||
ti->set_as_cursor(0);
|
||||
}
|
||||
|
||||
get_ok()->set_disabled(root->get_children()==NULL);
|
||||
|
||||
get_ok()->set_disabled(root->get_children() == NULL);
|
||||
}
|
||||
|
||||
void EditorQuickOpen::_confirmed() {
|
||||
|
|
@ -238,13 +233,12 @@ void EditorQuickOpen::_confirmed() {
|
|||
|
||||
void EditorQuickOpen::_notification(int p_what) {
|
||||
|
||||
if (p_what==NOTIFICATION_ENTER_TREE) {
|
||||
if (p_what == NOTIFICATION_ENTER_TREE) {
|
||||
|
||||
connect("confirmed",this,"_confirmed");
|
||||
connect("confirmed", this, "_confirmed");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
StringName EditorQuickOpen::get_base_type() const {
|
||||
|
||||
return base_type;
|
||||
|
|
@ -252,34 +246,31 @@ StringName EditorQuickOpen::get_base_type() const {
|
|||
|
||||
void EditorQuickOpen::_bind_methods() {
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("_text_changed"),&EditorQuickOpen::_text_changed);
|
||||
ObjectTypeDB::bind_method(_MD("_confirmed"),&EditorQuickOpen::_confirmed);
|
||||
ObjectTypeDB::bind_method(_MD("_sbox_input"),&EditorQuickOpen::_sbox_input);
|
||||
ObjectTypeDB::bind_method(_MD("_text_changed"), &EditorQuickOpen::_text_changed);
|
||||
ObjectTypeDB::bind_method(_MD("_confirmed"), &EditorQuickOpen::_confirmed);
|
||||
ObjectTypeDB::bind_method(_MD("_sbox_input"), &EditorQuickOpen::_sbox_input);
|
||||
|
||||
ADD_SIGNAL(MethodInfo("quick_open"));
|
||||
|
||||
}
|
||||
|
||||
|
||||
EditorQuickOpen::EditorQuickOpen() {
|
||||
|
||||
|
||||
VBoxContainer *vbc = memnew( VBoxContainer );
|
||||
VBoxContainer *vbc = memnew(VBoxContainer);
|
||||
add_child(vbc);
|
||||
set_child_rect(vbc);
|
||||
search_box = memnew( LineEdit );
|
||||
vbc->add_margin_child(TTR("Search:"),search_box);
|
||||
search_box->connect("text_changed",this,"_text_changed");
|
||||
search_box->connect("input_event",this,"_sbox_input");
|
||||
search_options = memnew( Tree );
|
||||
vbc->add_margin_child(TTR("Matches:"),search_options,true);
|
||||
search_box = memnew(LineEdit);
|
||||
vbc->add_margin_child(TTR("Search:"), search_box);
|
||||
search_box->connect("text_changed", this, "_text_changed");
|
||||
search_box->connect("input_event", this, "_sbox_input");
|
||||
search_options = memnew(Tree);
|
||||
vbc->add_margin_child(TTR("Matches:"), search_options, true);
|
||||
get_ok()->set_text(TTR("Open"));
|
||||
get_ok()->set_disabled(true);
|
||||
register_text_enter(search_box);
|
||||
set_hide_on_ok(false);
|
||||
search_options->connect("item_activated",this,"_confirmed");
|
||||
search_options->connect("item_activated", this, "_confirmed");
|
||||
search_options->set_hide_root(true);
|
||||
ei="EditorIcons";
|
||||
ot="Object";
|
||||
add_directories=false;
|
||||
ei = "EditorIcons";
|
||||
ot = "Object";
|
||||
add_directories = false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue