feat: modules moved and engine moved to submodule
This commit is contained in:
parent
dfb5e645cd
commit
c33d2130cc
5136 changed files with 225275 additions and 64485 deletions
|
|
@ -68,10 +68,18 @@ void FileDialog::_native_popup() {
|
|||
} else if (access == ACCESS_USERDATA) {
|
||||
root = OS::get_singleton()->get_user_data_dir();
|
||||
}
|
||||
|
||||
// Attach native file dialog to first persistent parent window.
|
||||
Window *w = (is_transient() || is_transient_to_focused()) ? get_parent_visible_window() : nullptr;
|
||||
while (w && w->get_flag(FLAG_POPUP) && w->get_parent_visible_window()) {
|
||||
w = w->get_parent_visible_window();
|
||||
}
|
||||
DisplayServer::WindowID wid = w ? w->get_window_id() : DisplayServer::INVALID_WINDOW_ID;
|
||||
|
||||
if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_NATIVE_DIALOG_FILE_EXTRA)) {
|
||||
DisplayServer::get_singleton()->file_dialog_with_options_show(get_translated_title(), ProjectSettings::get_singleton()->globalize_path(full_dir), root, file->get_text().get_file(), show_hidden_files, DisplayServer::FileDialogMode(mode), processed_filters, _get_options(), callable_mp(this, &FileDialog::_native_dialog_cb_with_options));
|
||||
DisplayServer::get_singleton()->file_dialog_with_options_show(get_translated_title(), ProjectSettings::get_singleton()->globalize_path(full_dir), root, file->get_text().get_file(), show_hidden_files, DisplayServer::FileDialogMode(mode), processed_filters, _get_options(), callable_mp(this, &FileDialog::_native_dialog_cb_with_options), wid);
|
||||
} else {
|
||||
DisplayServer::get_singleton()->file_dialog_show(get_translated_title(), ProjectSettings::get_singleton()->globalize_path(full_dir), file->get_text().get_file(), show_hidden_files, DisplayServer::FileDialogMode(mode), processed_filters, callable_mp(this, &FileDialog::_native_dialog_cb));
|
||||
DisplayServer::get_singleton()->file_dialog_show(get_translated_title(), ProjectSettings::get_singleton()->globalize_path(full_dir), file->get_text().get_file(), show_hidden_files, DisplayServer::FileDialogMode(mode), processed_filters, callable_mp(this, &FileDialog::_native_dialog_cb), wid);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -160,9 +168,9 @@ void FileDialog::_native_dialog_cb_with_options(bool p_ok, const Vector<String>
|
|||
} else if (filters.size() > 1 && p_filter == 0) {
|
||||
// Match all filters.
|
||||
for (int i = 0; i < filters.size(); i++) {
|
||||
String flt = filters[i].get_slice(";", 0);
|
||||
String flt = filters[i].get_slicec(';', 0);
|
||||
for (int j = 0; j < flt.get_slice_count(","); j++) {
|
||||
String str = flt.get_slice(",", j).strip_edges();
|
||||
String str = flt.get_slicec(',', j).strip_edges();
|
||||
if (f.matchn(str)) {
|
||||
valid = true;
|
||||
break;
|
||||
|
|
@ -178,10 +186,10 @@ void FileDialog::_native_dialog_cb_with_options(bool p_ok, const Vector<String>
|
|||
idx--;
|
||||
}
|
||||
if (idx >= 0 && idx < filters.size()) {
|
||||
String flt = filters[idx].get_slice(";", 0);
|
||||
String flt = filters[idx].get_slicec(';', 0);
|
||||
int filter_slice_count = flt.get_slice_count(",");
|
||||
for (int j = 0; j < filter_slice_count; j++) {
|
||||
String str = (flt.get_slice(",", j).strip_edges());
|
||||
String str = flt.get_slicec(',', j).strip_edges();
|
||||
if (f.matchn(str)) {
|
||||
valid = true;
|
||||
break;
|
||||
|
|
@ -189,8 +197,8 @@ void FileDialog::_native_dialog_cb_with_options(bool p_ok, const Vector<String>
|
|||
}
|
||||
|
||||
if (!valid && filter_slice_count > 0) {
|
||||
String str = (flt.get_slice(",", 0).strip_edges());
|
||||
f += str.substr(1, str.length() - 1);
|
||||
String str = flt.get_slicec(',', 0).strip_edges();
|
||||
f += str.substr(1);
|
||||
file->set_text(f.get_file());
|
||||
valid = true;
|
||||
}
|
||||
|
|
@ -202,8 +210,8 @@ void FileDialog::_native_dialog_cb_with_options(bool p_ok, const Vector<String>
|
|||
// Add first extension of filter if no valid extension is found.
|
||||
if (!valid) {
|
||||
int idx = p_filter;
|
||||
String flt = filters[idx].get_slice(";", 0);
|
||||
String ext = flt.get_slice(",", 0).strip_edges().get_extension();
|
||||
String flt = filters[idx].get_slicec(';', 0);
|
||||
String ext = flt.get_slicec(',', 0).strip_edges().get_extension();
|
||||
f += "." + ext;
|
||||
}
|
||||
emit_signal(SNAME("file_selected"), f);
|
||||
|
|
@ -478,7 +486,7 @@ void FileDialog::_post_popup() {
|
|||
void FileDialog::_push_history() {
|
||||
local_history.resize(local_history_pos + 1);
|
||||
String new_path = dir_access->get_current_dir();
|
||||
if (local_history.size() == 0 || new_path != local_history[local_history_pos]) {
|
||||
if (local_history.is_empty() || new_path != local_history[local_history_pos]) {
|
||||
local_history.push_back(new_path);
|
||||
local_history_pos++;
|
||||
dir_prev->set_disabled(local_history_pos == 0);
|
||||
|
|
@ -514,7 +522,7 @@ void FileDialog::_action_pressed() {
|
|||
} else if (mode == FILE_MODE_OPEN_ANY || mode == FILE_MODE_OPEN_DIR) {
|
||||
String path = dir_access->get_current_dir();
|
||||
|
||||
path = path.replace("\\", "/");
|
||||
path = path.replace_char('\\', '/');
|
||||
TreeItem *item = tree->get_selected();
|
||||
if (item) {
|
||||
Dictionary d = item->get_metadata(0);
|
||||
|
|
@ -535,9 +543,9 @@ void FileDialog::_action_pressed() {
|
|||
} else if (filters.size() > 1 && filter->get_selected() == 0) {
|
||||
// Match all filters.
|
||||
for (int i = 0; i < filters.size(); i++) {
|
||||
String flt = filters[i].get_slice(";", 0);
|
||||
String flt = filters[i].get_slicec(';', 0);
|
||||
for (int j = 0; j < flt.get_slice_count(","); j++) {
|
||||
String str = flt.get_slice(",", j).strip_edges();
|
||||
String str = flt.get_slicec(',', j).strip_edges();
|
||||
if (f.matchn(str)) {
|
||||
valid = true;
|
||||
break;
|
||||
|
|
@ -553,10 +561,10 @@ void FileDialog::_action_pressed() {
|
|||
idx--;
|
||||
}
|
||||
if (idx >= 0 && idx < filters.size()) {
|
||||
String flt = filters[idx].get_slice(";", 0);
|
||||
String flt = filters[idx].get_slicec(';', 0);
|
||||
int filter_slice_count = flt.get_slice_count(",");
|
||||
for (int j = 0; j < filter_slice_count; j++) {
|
||||
String str = (flt.get_slice(",", j).strip_edges());
|
||||
String str = (flt.get_slicec(',', j).strip_edges());
|
||||
if (f.matchn(str)) {
|
||||
valid = true;
|
||||
break;
|
||||
|
|
@ -564,8 +572,8 @@ void FileDialog::_action_pressed() {
|
|||
}
|
||||
|
||||
if (!valid && filter_slice_count > 0) {
|
||||
String str = (flt.get_slice(",", 0).strip_edges());
|
||||
f += str.substr(1, str.length() - 1);
|
||||
String str = flt.get_slicec(',', 0).strip_edges();
|
||||
f += str.substr(1);
|
||||
file->set_text(f.get_file());
|
||||
valid = true;
|
||||
}
|
||||
|
|
@ -661,10 +669,10 @@ void FileDialog::deselect_all() {
|
|||
switch (mode) {
|
||||
case FILE_MODE_OPEN_FILE:
|
||||
case FILE_MODE_OPEN_FILES:
|
||||
set_ok_button_text(ETR("Open"));
|
||||
set_internal_ok_text(ETR("Open"));
|
||||
break;
|
||||
case FILE_MODE_OPEN_DIR:
|
||||
set_ok_button_text(ETR("Select Current Folder"));
|
||||
set_internal_ok_text(ETR("Select Current Folder"));
|
||||
break;
|
||||
case FILE_MODE_OPEN_ANY:
|
||||
set_ok_button_text(ETR("Open"));
|
||||
|
|
@ -690,14 +698,14 @@ void FileDialog::_tree_selected() {
|
|||
if (!d["dir"]) {
|
||||
file->set_text(d["name"]);
|
||||
if (mode == FILE_MODE_SAVE_FILE) {
|
||||
set_ok_button_text(ETR("Save"));
|
||||
set_internal_ok_text(ETR("Save"));
|
||||
} else {
|
||||
set_ok_button_text(ETR("Open"));
|
||||
set_internal_ok_text(ETR("Open"));
|
||||
}
|
||||
} else if (mode == FILE_MODE_OPEN_DIR || mode == FILE_MODE_OPEN_ANY || !dir_access->file_exists(file->get_text())) {
|
||||
file->set_text("");
|
||||
if (mode == FILE_MODE_OPEN_DIR || mode == FILE_MODE_OPEN_ANY) {
|
||||
set_ok_button_text(ETR("Select This Folder"));
|
||||
set_internal_ok_text(ETR("Select This Folder"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -862,9 +870,9 @@ void FileDialog::update_file_list() {
|
|||
} else if (filters.size() > 1 && filter->get_selected() == 0) {
|
||||
// match all filters
|
||||
for (int i = 0; i < filters.size(); i++) {
|
||||
String f = filters[i].get_slice(";", 0);
|
||||
String f = filters[i].get_slicec(';', 0);
|
||||
for (int j = 0; j < f.get_slice_count(","); j++) {
|
||||
patterns.push_back(f.get_slice(",", j).strip_edges());
|
||||
patterns.push_back(f.get_slicec(',', j).strip_edges());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
@ -874,9 +882,9 @@ void FileDialog::update_file_list() {
|
|||
}
|
||||
|
||||
if (idx >= 0 && idx < filters.size()) {
|
||||
String f = filters[idx].get_slice(";", 0);
|
||||
String f = filters[idx].get_slicec(';', 0);
|
||||
for (int j = 0; j < f.get_slice_count(","); j++) {
|
||||
patterns.push_back(f.get_slice(",", j).strip_edges());
|
||||
patterns.push_back(f.get_slicec(',', j).strip_edges());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1184,7 +1192,7 @@ void FileDialog::set_current_path(const String &p_path) {
|
|||
set_current_file(p_path);
|
||||
} else {
|
||||
String path_dir = p_path.substr(0, pos);
|
||||
String path_file = p_path.substr(pos + 1, p_path.length());
|
||||
String path_file = p_path.substr(pos + 1);
|
||||
set_current_dir(path_dir);
|
||||
set_current_file(path_file);
|
||||
}
|
||||
|
|
@ -1227,35 +1235,35 @@ void FileDialog::set_file_mode(FileMode p_mode) {
|
|||
mode = p_mode;
|
||||
switch (mode) {
|
||||
case FILE_MODE_OPEN_FILE:
|
||||
set_ok_button_text(ETR("Open"));
|
||||
set_internal_ok_text(ETR("Open"));
|
||||
if (mode_overrides_title) {
|
||||
set_title(ETR("Open a File"));
|
||||
}
|
||||
makedir->hide();
|
||||
break;
|
||||
case FILE_MODE_OPEN_FILES:
|
||||
set_ok_button_text(ETR("Open"));
|
||||
set_internal_ok_text(ETR("Open"));
|
||||
if (mode_overrides_title) {
|
||||
set_title(ETR("Open File(s)"));
|
||||
}
|
||||
makedir->hide();
|
||||
break;
|
||||
case FILE_MODE_OPEN_DIR:
|
||||
set_ok_button_text(ETR("Select Current Folder"));
|
||||
set_internal_ok_text(ETR("Select Current Folder"));
|
||||
if (mode_overrides_title) {
|
||||
set_title(ETR("Open a Directory"));
|
||||
}
|
||||
makedir->show();
|
||||
break;
|
||||
case FILE_MODE_OPEN_ANY:
|
||||
set_ok_button_text(ETR("Open"));
|
||||
set_internal_ok_text(ETR("Open"));
|
||||
if (mode_overrides_title) {
|
||||
set_title(ETR("Open a File or Directory"));
|
||||
}
|
||||
makedir->show();
|
||||
break;
|
||||
case FILE_MODE_SAVE_FILE:
|
||||
set_ok_button_text(ETR("Save"));
|
||||
set_internal_ok_text(ETR("Save"));
|
||||
if (mode_overrides_title) {
|
||||
set_title(ETR("Save a File"));
|
||||
}
|
||||
|
|
@ -1434,9 +1442,11 @@ void FileDialog::_update_option_controls() {
|
|||
for (const FileDialog::Option &opt : options) {
|
||||
Label *lbl = memnew(Label);
|
||||
lbl->set_text(opt.name);
|
||||
lbl->set_focus_mode(Control::FOCUS_NONE);
|
||||
grid_options->add_child(lbl);
|
||||
if (opt.values.is_empty()) {
|
||||
CheckBox *cb = memnew(CheckBox);
|
||||
cb->set_accessibility_name(opt.name);
|
||||
cb->set_pressed(opt.default_idx);
|
||||
grid_options->add_child(cb);
|
||||
cb->connect(SceneStringName(toggled), callable_mp(this, &FileDialog::_option_changed_checkbox_toggled).bind(opt.name));
|
||||
|
|
@ -1446,6 +1456,7 @@ void FileDialog::_update_option_controls() {
|
|||
for (const String &val : opt.values) {
|
||||
ob->add_item(val);
|
||||
}
|
||||
ob->set_accessibility_name(opt.name);
|
||||
ob->select(opt.default_idx);
|
||||
grid_options->add_child(ob);
|
||||
ob->connect(SceneStringName(item_selected), callable_mp(this, &FileDialog::_option_changed_item_selected).bind(opt.name));
|
||||
|
|
@ -1724,11 +1735,14 @@ FileDialog::FileDialog() {
|
|||
|
||||
dir_prev = memnew(Button);
|
||||
dir_prev->set_theme_type_variation(SceneStringName(FlatButton));
|
||||
dir_prev->set_accessibility_name(ETR("Previous"));
|
||||
dir_prev->set_tooltip_text(ETR("Go to previous folder."));
|
||||
dir_next = memnew(Button);
|
||||
dir_next->set_accessibility_name(ETR("Next"));
|
||||
dir_next->set_theme_type_variation(SceneStringName(FlatButton));
|
||||
dir_next->set_tooltip_text(ETR("Go to next folder."));
|
||||
dir_up = memnew(Button);
|
||||
dir_up->set_accessibility_name(ETR("Parent Folder"));
|
||||
dir_up->set_theme_type_variation(SceneStringName(FlatButton));
|
||||
dir_up->set_tooltip_text(ETR("Go to parent folder."));
|
||||
hbc->add_child(dir_prev);
|
||||
|
|
@ -1738,22 +1752,27 @@ FileDialog::FileDialog() {
|
|||
dir_next->connect(SceneStringName(pressed), callable_mp(this, &FileDialog::_go_forward));
|
||||
dir_up->connect(SceneStringName(pressed), callable_mp(this, &FileDialog::_go_up));
|
||||
|
||||
hbc->add_child(memnew(Label(ETR("Path:"))));
|
||||
Label *lbl_path = memnew(Label(ETR("Path:")));
|
||||
lbl_path->set_focus_mode(Control::FOCUS_NONE);
|
||||
hbc->add_child(lbl_path);
|
||||
|
||||
drives_container = memnew(HBoxContainer);
|
||||
hbc->add_child(drives_container);
|
||||
|
||||
drives = memnew(OptionButton);
|
||||
drives->connect(SceneStringName(item_selected), callable_mp(this, &FileDialog::_select_drive));
|
||||
drives->set_accessibility_name(ETR("Drive"));
|
||||
hbc->add_child(drives);
|
||||
|
||||
dir = memnew(LineEdit);
|
||||
dir->set_accessibility_name(ETR("Directory Path"));
|
||||
dir->set_structured_text_bidi_override(TextServer::STRUCTURED_TEXT_FILE);
|
||||
hbc->add_child(dir);
|
||||
dir->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
|
||||
refresh = memnew(Button);
|
||||
refresh->set_theme_type_variation(SceneStringName(FlatButton));
|
||||
refresh->set_accessibility_name(ETR("Refresh"));
|
||||
refresh->set_tooltip_text(ETR("Refresh files."));
|
||||
refresh->connect(SceneStringName(pressed), callable_mp(this, &FileDialog::update_file_list));
|
||||
hbc->add_child(refresh);
|
||||
|
|
@ -1762,6 +1781,7 @@ FileDialog::FileDialog() {
|
|||
show_hidden->set_theme_type_variation(SceneStringName(FlatButton));
|
||||
show_hidden->set_toggle_mode(true);
|
||||
show_hidden->set_pressed(is_showing_hidden_files());
|
||||
show_hidden->set_accessibility_name(ETR("Show Hidden Files"));
|
||||
show_hidden->set_tooltip_text(ETR("Toggle the visibility of hidden files."));
|
||||
show_hidden->connect(SceneStringName(toggled), callable_mp(this, &FileDialog::set_show_hidden_files));
|
||||
hbc->add_child(show_hidden);
|
||||
|
|
@ -1770,7 +1790,8 @@ FileDialog::FileDialog() {
|
|||
show_filename_filter_button->set_theme_type_variation(SceneStringName(FlatButton));
|
||||
show_filename_filter_button->set_toggle_mode(true);
|
||||
show_filename_filter_button->set_pressed(false);
|
||||
show_filename_filter_button->set_tooltip_text(RTR("Toggle the visibility of the filter for file names."));
|
||||
show_filename_filter_button->set_accessibility_name(ETR("Filter File Names"));
|
||||
show_filename_filter_button->set_tooltip_text(ETR("Toggle the visibility of the filter for file names."));
|
||||
show_filename_filter_button->connect(SceneStringName(toggled), callable_mp(this, &FileDialog::set_show_filename_filter));
|
||||
hbc->add_child(show_filename_filter_button);
|
||||
|
||||
|
|
@ -1779,6 +1800,7 @@ FileDialog::FileDialog() {
|
|||
|
||||
makedir = memnew(Button);
|
||||
makedir->set_theme_type_variation(SceneStringName(FlatButton));
|
||||
makedir->set_accessibility_name(ETR("Create New Folder"));
|
||||
makedir->set_tooltip_text(ETR("Create a new folder."));
|
||||
makedir->connect(SceneStringName(pressed), callable_mp(this, &FileDialog::_make_dir));
|
||||
hbc->add_child(makedir);
|
||||
|
|
@ -1786,6 +1808,7 @@ FileDialog::FileDialog() {
|
|||
|
||||
tree = memnew(Tree);
|
||||
tree->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED);
|
||||
tree->set_accessibility_name(ETR("Directories and Files"));
|
||||
tree->set_hide_root(true);
|
||||
vbox->add_margin_child(ETR("Directories & Files:"), tree, true);
|
||||
|
||||
|
|
@ -1797,19 +1820,24 @@ FileDialog::FileDialog() {
|
|||
tree->add_child(message);
|
||||
|
||||
filename_filter_box = memnew(HBoxContainer);
|
||||
filename_filter_box->add_child(memnew(Label(RTR("Filter:"))));
|
||||
filename_filter_box->add_child(memnew(Label(ETR("Filter:"))));
|
||||
filename_filter = memnew(LineEdit);
|
||||
filename_filter->set_structured_text_bidi_override(TextServer::STRUCTURED_TEXT_FILE);
|
||||
filename_filter->set_stretch_ratio(4);
|
||||
filename_filter->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
filename_filter->set_clear_button_enabled(true);
|
||||
filename_filter->set_accessibility_name(ETR("Filename Filter"));
|
||||
filename_filter_box->add_child(filename_filter);
|
||||
filename_filter_box->set_visible(false);
|
||||
vbox->add_child(filename_filter_box);
|
||||
|
||||
file_box = memnew(HBoxContainer);
|
||||
file_box->add_child(memnew(Label(ETR("File:"))));
|
||||
Label *lbl_file = memnew(Label(ETR("File:")));
|
||||
lbl_file->set_focus_mode(Control::FOCUS_NONE);
|
||||
file_box->add_child(lbl_file);
|
||||
|
||||
file = memnew(LineEdit);
|
||||
file->set_accessibility_name(ETR("File Name"));
|
||||
file->set_structured_text_bidi_override(TextServer::STRUCTURED_TEXT_FILE);
|
||||
file->set_stretch_ratio(4);
|
||||
file->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
|
|
@ -1878,6 +1906,7 @@ FileDialog::FileDialog() {
|
|||
|
||||
set_hide_on_ok(false);
|
||||
set_size(Size2(640, 360));
|
||||
set_internal_ok_text(ETR("Save")); // Default mode text.
|
||||
|
||||
if (register_func) {
|
||||
register_func(this);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue