/**************************************************************************/ /* file_dialog.h */ /**************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ /* https://godotengine.org */ /**************************************************************************/ /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ /* "Software"), to deal in the Software without restriction, including */ /* without limitation the rights to use, copy, modify, merge, publish, */ /* distribute, sublicense, and/or sell copies of the Software, and to */ /* permit persons to whom the Software is furnished to do so, subject to */ /* the following conditions: */ /* */ /* The above copyright notice and this permission notice shall be */ /* included in all copies or substantial portions of the Software. */ /* */ /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /**************************************************************************/ #pragma once #include "scene/gui/dialogs.h" #include "scene/property_list_helper.h" class DirAccess; class FlowContainer; class GridContainer; class HBoxContainer; class ItemList; class LineEdit; class MenuButton; class OptionButton; class PopupMenu; class VBoxContainer; class FileDialog : public ConfirmationDialog { GDCLASS(FileDialog, ConfirmationDialog); struct Option { String name; Vector values; int default_idx = 0; }; struct DirInfo { String name; uint64_t modified_time = 0; bool bundle = false; struct NameComparator { bool operator()(const DirInfo &p_a, const DirInfo &p_b) const { return FileNoCaseComparator()(p_a.name, p_b.name); } }; struct TimeComparator { bool operator()(const DirInfo &p_a, const DirInfo &p_b) const { return p_a.modified_time > p_b.modified_time; } }; }; struct FileInfo { String name; String match_string; String type_sort; uint64_t modified_time = 0; struct NameComparator { bool operator()(const FileInfo &p_a, const FileInfo &p_b) const { return FileNoCaseComparator()(p_a.name, p_b.name); } }; struct TypeComparator { bool operator()(const FileInfo &p_a, const FileInfo &p_b) const { return FileNoCaseComparator()(p_a.type_sort, p_b.type_sort); } }; struct TimeComparator { bool operator()(const FileInfo &p_a, const FileInfo &p_b) const { return p_a.modified_time > p_b.modified_time; } }; }; enum class FileSortOption { NAME, NAME_REVERSE, TYPE, TYPE_REVERSE, MODIFIED_TIME, MODIFIED_TIME_REVERSE, MAX }; public: enum Access { ACCESS_RESOURCES, ACCESS_USERDATA, ACCESS_FILESYSTEM, }; enum FileMode { FILE_MODE_OPEN_FILE, FILE_MODE_OPEN_FILES, FILE_MODE_OPEN_DIR, FILE_MODE_OPEN_ANY, FILE_MODE_SAVE_FILE, }; enum ItemMenu { ITEM_MENU_COPY_PATH, ITEM_MENU_SHOW_IN_EXPLORER, ITEM_MENU_SHOW_BUNDLE_CONTENT, }; typedef Ref (*GetIconFunc)(const String &); typedef void (*RegisterFunc)(FileDialog *); inline static GetIconFunc get_icon_func = nullptr; inline static RegisterFunc register_func = nullptr; inline static RegisterFunc unregister_func = nullptr; private: static inline PropertyListHelper base_property_helper; PropertyListHelper property_helper; inline static bool default_show_hidden_files = false; bool show_hidden_files = false; bool use_native_dialog = false; Access access = ACCESS_RESOURCES; FileMode mode = FILE_MODE_SAVE_FILE; FileSortOption file_sort = FileSortOption::NAME; Ref dir_access; Vector filters; Vector processed_filters; Vector