Add a custom icon for the project.godot
file in the EditorFileDialog
This commit is contained in:
parent
0c27edf3d9
commit
236cec0633
9 changed files with 30 additions and 9 deletions
|
@ -50,7 +50,7 @@
|
|||
#include "servers/display_server.h"
|
||||
|
||||
EditorFileDialog::GetIconFunc EditorFileDialog::get_icon_func = nullptr;
|
||||
EditorFileDialog::GetIconFunc EditorFileDialog::get_large_icon_func = nullptr;
|
||||
EditorFileDialog::GetIconFunc EditorFileDialog::get_thumbnail_func = nullptr;
|
||||
|
||||
EditorFileDialog::RegisterFunc EditorFileDialog::register_func = nullptr;
|
||||
EditorFileDialog::RegisterFunc EditorFileDialog::unregister_func = nullptr;
|
||||
|
@ -902,7 +902,15 @@ void EditorFileDialog::update_file_list() {
|
|||
if (get_icon_func) {
|
||||
Ref<Texture2D> icon = get_icon_func(cdir.path_join(files.front()->get()));
|
||||
if (display_mode == DISPLAY_THUMBNAILS) {
|
||||
item_list->set_item_icon(-1, file_thumbnail);
|
||||
Ref<Texture2D> thumbnail;
|
||||
if (get_thumbnail_func) {
|
||||
thumbnail = get_thumbnail_func(cdir.path_join(files.front()->get()));
|
||||
}
|
||||
if (thumbnail.is_null()) {
|
||||
thumbnail = file_thumbnail;
|
||||
}
|
||||
|
||||
item_list->set_item_icon(-1, thumbnail);
|
||||
item_list->set_item_tag_icon(-1, icon);
|
||||
} else {
|
||||
item_list->set_item_icon(-1, icon);
|
||||
|
|
|
@ -68,7 +68,7 @@ public:
|
|||
typedef void (*RegisterFunc)(EditorFileDialog *);
|
||||
|
||||
static GetIconFunc get_icon_func;
|
||||
static GetIconFunc get_large_icon_func;
|
||||
static GetIconFunc get_thumbnail_func;
|
||||
static RegisterFunc register_func;
|
||||
static RegisterFunc unregister_func;
|
||||
|
||||
|
|
1
editor/icons/GodotFile.svg
Normal file
1
editor/icons/GodotFile.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg height="64" viewBox="0 0 64 64" width="64" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><clipPath id="a"><path clip-rule="evenodd" d="m0 0h16v16h-16z"/></clipPath><g fill-rule="nonzero"><g clip-path="url(#a)" transform="matrix(1.68179 0 0 1.68179 18.54568 24.26388)"><path d="m0 0s-.325 1.994-.515 1.976l-36.182-3.491c-2.879-.278-5.115-2.574-5.317-5.459l-.994-14.247-27.992-1.997-1.904 12.912c-.424 2.872-2.932 5.037-5.835 5.037h-38.188c-2.902 0-5.41-2.165-5.834-5.037l-1.905-12.912-27.992 1.997-.994 14.247c-.202 2.886-2.438 5.182-5.317 5.46l-36.2 3.49c-.187.018-.324-1.978-.511-1.978l-.049-7.83 30.658-4.944 1.004-14.374c.203-2.91 2.551-5.263 5.463-5.472l38.551-2.75c.146-.01.29-.016.434-.016 2.897 0 5.401 2.166 5.825 5.038l1.959 13.286h28.005l1.959-13.286c.423-2.871 2.93-5.037 5.831-5.037.142 0 .284.005.423.015l38.556 2.75c2.911.209 5.26 2.562 5.463 5.472l1.003 14.374 30.645 4.966z" fill="#fff" transform="matrix(.0717673866 0 0 -.0717673866 15.02102684 10.60436247)"/><path d="m0 0v-59.041c.108-.001.216-.005.323-.015l36.196-3.49c1.896-.183 3.382-1.709 3.514-3.609l1.116-15.978 31.574-2.253 2.175 14.747c.282 1.912 1.922 3.329 3.856 3.329h38.188c1.933 0 3.573-1.417 3.855-3.329l2.175-14.747 31.575 2.253 1.115 15.978c.133 1.9 1.618 3.425 3.514 3.609l36.182 3.49c.107.01.214.014.322.015v4.711l.015.005v54.325h.134c4.795 6.12 9.232 12.569 13.487 19.449-5.651 9.62-12.575 18.217-19.976 26.182-6.864-3.455-13.531-7.369-19.828-11.534-3.151 3.132-6.7 5.694-10.186 8.372-3.425 2.751-7.285 4.768-10.946 7.118 1.09 8.117 1.629 16.108 1.846 24.448-9.446 4.754-19.519 7.906-29.708 10.17-4.068-6.837-7.788-14.241-11.028-21.479-3.842.642-7.702.88-11.567.926v.006c-.027 0-.052-.006-.075-.006-.024 0-.049.006-.073.006v-.006c-3.872-.046-7.729-.284-11.572-.926-3.238 7.238-6.956 14.642-11.03 21.479-10.184-2.264-20.258-5.416-29.703-10.17.216-8.34.755-16.331 1.848-24.448-3.668-2.35-7.523-4.367-10.949-7.118-3.481-2.678-7.036-5.24-10.188-8.372-6.297 4.165-12.962 8.079-19.828 11.534-7.401-7.965-14.321-16.562-19.974-26.182 4.253-6.88 8.693-13.329 13.487-19.449z" fill="#478cbf" transform="matrix(.0717673866 0 0 -.0717673866 .9775427 6.36721431)"/><path d="m0 0-1.121-16.063c-.135-1.936-1.675-3.477-3.611-3.616l-38.555-2.751c-.094-.007-.188-.01-.281-.01-1.916 0-3.569 1.406-3.852 3.33l-2.211 14.994h-31.459l-2.211-14.994c-.297-2.018-2.101-3.469-4.133-3.32l-38.555 2.751c-1.936.139-3.476 1.68-3.611 3.616l-1.121 16.063-32.547 3.138c.015-3.498.06-7.33.06-8.093 0-34.374 43.605-50.896 97.781-51.086h.133c54.176.19 97.766 16.712 97.766 51.086 0 .777.047 4.593.063 8.093z" fill="#478cbf" transform="matrix(.0717673866 0 0 -.0717673866 12.69056087 11.39003484)"/><path d="m0 0c0-12.052-9.765-21.815-21.813-21.815-12.042 0-21.81 9.763-21.81 21.815 0 12.044 9.768 21.802 21.81 21.802 12.048 0 21.813-9.758 21.813-21.802" fill="#fff" transform="matrix(.0717673866 0 0 -.0717673866 5.88277961 8.08717647)"/><path d="m0 0c0-7.994-6.479-14.473-14.479-14.473-7.996 0-14.479 6.479-14.479 14.473s6.483 14.479 14.479 14.479c8 0 14.479-6.485 14.479-14.479" fill="#414042" transform="matrix(.0717673866 0 0 -.0717673866 5.50623617 8.18010546)"/><path d="m0 0c-3.878 0-7.021 2.858-7.021 6.381v20.081c0 3.52 3.143 6.381 7.021 6.381s7.028-2.861 7.028-6.381v-20.081c0-3.523-3.15-6.381-7.028-6.381" fill="#fff" transform="matrix(.0717673866 0 0 -.0717673866 7.99962959 9.79524234)"/><path d="m0 0c0-12.052 9.765-21.815 21.815-21.815 12.041 0 21.808 9.763 21.808 21.815 0 12.044-9.767 21.802-21.808 21.802-12.05 0-21.815-9.758-21.815-21.802" fill="#fff" transform="matrix(.0717673866 0 0 -.0717673866 10.11682439 8.08717647)"/><path d="m0 0c0-7.994 6.477-14.473 14.471-14.473 8.002 0 14.479 6.479 14.479 14.473s-6.477 14.479-14.479 14.479c-7.994 0-14.471-6.485-14.471-14.479" fill="#414042" transform="matrix(.0717673866 0 0 -.0717673866 10.49354024 8.18010546)"/></g><path d="m14 5c-2.199 0-4 1.801-4 4v46c0 2.199 1.801 4 4 4h36c2.199 0 4-1.801 4-4v-33h-.008c.002-.248-.079-.501-.285-.707l-16-16c-.188-.187-.442-.289-.707-.289v-.004zm0 2h22v12c0 2.199 1.801 4 4 4h12v32c0 1.125-.875 2-2 2h-36c-1.125 0-2-.875-2-2v-46c0-1.125.875-2 2-2z" fill="#fff" fill-opacity=".59" transform="translate(0 -.000017)"/></g></svg>
|
After Width: | Height: | Size: 4.1 KiB |
1
editor/icons/GodotMonochrome.svg
Normal file
1
editor/icons/GodotMonochrome.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><g fill="#fff" fill-rule="nonzero" transform="matrix(.0165985 0 0 .0165985 -.498437 -.50081)"><path d="m417.615 76.875c-42.392 9.424-84.326 22.545-123.642 42.334.899 34.716 3.143 67.98 7.693 101.768-15.268 9.782-31.315 18.177-45.576 29.628-14.49 11.148-29.29 21.813-42.41 34.85-26.212-17.337-53.955-33.63-82.535-48.012-30.808 33.156-59.614 68.94-83.145 108.985 18.493 29.029 38.329 58.205 56.699 80.959v245.765c.45.005.899.021 1.344.063l150.67 14.527c7.892.762 14.077 7.115 14.627 15.024l4.646 66.509 131.43 9.379 9.055-61.386c1.174-7.959 8-13.858 16.05-13.858h158.961c8.047 0 14.873 5.899 16.047 13.858l9.055 61.386 131.434-9.379 4.642-66.509c.554-7.909 6.735-14.258 14.627-15.024l150.611-14.527c.446-.042.891-.058 1.34-.063v-19.611l.063-.02v-226.134c21.216-26.71 41.307-56.172 56.699-80.959-23.523-40.045-52.345-75.829-83.152-108.985-28.573 14.382-56.325 30.675-82.537 48.012-13.117-13.037-27.89-23.702-42.401-34.85-14.257-11.451-30.323-19.846-45.562-29.628 4.537-33.788 6.78-67.052 7.683-101.768-39.32-19.789-81.249-32.91-123.662-42.334-16.933 28.46-32.419 59.279-45.906 89.408-15.993-2.672-32.06-3.662-48.149-3.853v-.026c-.112 0-.216.026-.312.026-.1 0-.205-.026-.305-.026v.026c-16.117.191-32.171 1.181-48.168 3.853-13.478-30.129-28.955-60.948-45.914-89.408zm-119.199 359.523c50.151 0 90.799 40.618 90.799 90.752 0 50.168-40.648 90.809-90.799 90.809-50.126 0-90.787-40.641-90.787-90.809 0-50.134 40.661-90.752 90.787-90.752zm427.178 0c50.122 0 90.779 40.618 90.779 90.752 0 50.168-40.657 90.809-90.779 90.809-50.16 0-90.807-40.641-90.807-90.809 0-50.134 40.647-90.752 90.807-90.752zm-213.6 53.11c16.143 0 29.254 11.908 29.254 26.56v83.59c0 14.665-13.111 26.563-29.254 26.563-16.142 0-29.226-11.898-29.226-26.563v-83.59c0-14.652 13.084-26.56 29.226-26.56z"/><path d="m0 0-1.121-16.063c-.135-1.936-1.675-3.477-3.611-3.616l-38.555-2.751c-.094-.007-.188-.01-.281-.01-1.916 0-3.569 1.406-3.852 3.33l-2.211 14.994h-31.459l-2.211-14.994c-.297-2.018-2.101-3.469-4.133-3.32l-38.555 2.751c-1.936.139-3.476 1.68-3.611 3.616l-1.121 16.063-32.547 3.138c.015-3.498.06-7.33.06-8.093 0-34.374 43.605-50.896 97.781-51.086h.133c54.176.19 97.766 16.712 97.766 51.086 0 .777.047 4.593.063 8.093z" transform="matrix(4.16261 0 0 -4.16261 784.071 718.723)"/><path d="m0 0c0-7.994-6.479-14.473-14.479-14.473-7.996 0-14.479 6.479-14.479 14.473s6.483 14.479 14.479 14.479c8 0 14.479-6.485 14.479-14.479" transform="matrix(4.16261 0 0 -4.16261 367.367 532.537)"/><path d="m0 0c0-7.994 6.477-14.473 14.471-14.473 8.002 0 14.479 6.479 14.479 14.473s-6.477 14.479-14.479 14.479c-7.994 0-14.471-6.485-14.471-14.479" transform="matrix(4.16261 0 0 -4.16261 656.641 532.537)"/></g></svg>
|
After Width: | Height: | Size: 2.7 KiB |
|
@ -58,6 +58,8 @@ def make_editor_icons_action(target, source, env):
|
|||
thumb_medium_indices.append(str(index))
|
||||
if icon_name.endswith("BigThumb"): # don't know a better way to handle this
|
||||
thumb_big_indices.append(str(index))
|
||||
if icon_name.endswith("GodotFile"): # don't know a better way to handle this
|
||||
thumb_big_indices.append(str(index))
|
||||
|
||||
s.write('\t"{0}"'.format(icon_name))
|
||||
|
||||
|
|
|
@ -2013,16 +2013,25 @@ void ProjectManager::_notification(int p_what) {
|
|||
}
|
||||
|
||||
Ref<Texture2D> ProjectManager::_file_dialog_get_icon(const String &p_path) {
|
||||
return singleton->icon_type_cache["ObjectHR"];
|
||||
if (p_path.get_extension().to_lower() == "godot") {
|
||||
return singleton->icon_type_cache["GodotMonochrome"];
|
||||
}
|
||||
|
||||
return singleton->icon_type_cache["Object"];
|
||||
}
|
||||
|
||||
Ref<Texture2D> ProjectManager::_file_dialog_get_thumbnail(const String &p_path) {
|
||||
if (p_path.get_extension().to_lower() == "godot") {
|
||||
return singleton->icon_type_cache["GodotFile"];
|
||||
}
|
||||
|
||||
return Ref<Texture2D>();
|
||||
}
|
||||
|
||||
void ProjectManager::_build_icon_type_cache(Ref<Theme> p_theme) {
|
||||
List<StringName> tl;
|
||||
p_theme->get_icon_list(SNAME("EditorIcons"), &tl);
|
||||
for (List<StringName>::Element *E = tl.front(); E; E = E->next()) {
|
||||
if (!ClassDB::class_exists(E->get())) {
|
||||
continue;
|
||||
}
|
||||
icon_type_cache[E->get()] = p_theme->get_icon(E->get(), SNAME("EditorIcons"));
|
||||
}
|
||||
}
|
||||
|
@ -2651,6 +2660,7 @@ ProjectManager::ProjectManager() {
|
|||
break;
|
||||
}
|
||||
EditorFileDialog::get_icon_func = &ProjectManager::_file_dialog_get_icon;
|
||||
EditorFileDialog::get_thumbnail_func = &ProjectManager::_file_dialog_get_thumbnail;
|
||||
}
|
||||
|
||||
// TRANSLATORS: This refers to the application where users manage their Godot projects.
|
||||
|
|
|
@ -144,6 +144,7 @@ class ProjectManager : public Control {
|
|||
void _on_search_term_changed(const String &p_term);
|
||||
|
||||
static Ref<Texture2D> _file_dialog_get_icon(const String &p_path);
|
||||
static Ref<Texture2D> _file_dialog_get_thumbnail(const String &p_path);
|
||||
|
||||
protected:
|
||||
void _notification(int p_what);
|
||||
|
|
|
@ -35,7 +35,6 @@
|
|||
#include "scene/gui/label.h"
|
||||
|
||||
FileDialog::GetIconFunc FileDialog::get_icon_func = nullptr;
|
||||
FileDialog::GetIconFunc FileDialog::get_large_icon_func = nullptr;
|
||||
|
||||
FileDialog::RegisterFunc FileDialog::register_func = nullptr;
|
||||
FileDialog::RegisterFunc FileDialog::unregister_func = nullptr;
|
||||
|
|
|
@ -60,7 +60,6 @@ public:
|
|||
typedef void (*RegisterFunc)(FileDialog *);
|
||||
|
||||
static GetIconFunc get_icon_func;
|
||||
static GetIconFunc get_large_icon_func;
|
||||
static RegisterFunc register_func;
|
||||
static RegisterFunc unregister_func;
|
||||
|
||||
|
|
Loading…
Reference in a new issue