diff options
Diffstat (limited to 'scene/gui')
-rw-r--r-- | scene/gui/control.cpp | 4 | ||||
-rw-r--r-- | scene/gui/file_dialog.cpp | 54 | ||||
-rw-r--r-- | scene/gui/file_dialog.h | 1 | ||||
-rw-r--r-- | scene/gui/menu_button.cpp | 2 |
4 files changed, 58 insertions, 3 deletions
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index 83c0397554..9e0faac716 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -346,7 +346,7 @@ void Control::_notification(int p_notification) { if (data.window==this) { window = memnew( Window ); - add_to_group("_gui_input"); + add_to_group("_vp_gui_input"+itos(get_viewport()->get_instance_ID())); add_to_group("windows"); window->tooltip_timer = memnew( Timer ); @@ -401,7 +401,7 @@ void Control::_notification(int p_notification) { if (window) { - remove_from_group("_gui_input"); + remove_from_group("_vp_gui_input"+itos(get_viewport()->get_instance_ID())); remove_from_group("windows"); if (window->tooltip_timer) memdelete(window->tooltip_timer); diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp index c4226e0f23..a7ff1431bd 100644 --- a/scene/gui/file_dialog.cpp +++ b/scene/gui/file_dialog.cpp @@ -156,11 +156,61 @@ void FileDialog::_action_pressed() { if (mode==MODE_SAVE_FILE) { + String ext = f.extension(); + bool valid=false; + + if (filter->get_selected()==filter->get_item_count()-1) { + valid=true; //match none + } 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); + for (int j=0;j<flt.get_slice_count(",");j++) { + + String str = flt.get_slice(",",j).strip_edges(); + if (f.match(str)) { + valid=true; + break; + } + } + if (valid) + break; + } + } else { + int idx=filter->get_selected(); + if (filters.size()>1) + idx--; + if (idx>=0 && idx<filters.size()) { + + String flt=filters[idx].get_slice(";",0); + for (int j=0;j<flt.get_slice_count(",");j++) { + + String str = (flt.get_slice(",",j).strip_edges()); + if (f.match(str)) { + valid=true; + break; + } + } + } else { + valid=true; + } + } + + + if (!valid) { + + exterr->popup_centered_minsize(Size2(250,80)); + return; + + } + if (dir_access->file_exists(f)) { confirm_save->set_text("File Exists, Overwrite?"); confirm_save->popup_centered(Size2(200,80)); } else { + emit_signal("file_selected",f); hide(); } @@ -682,6 +732,10 @@ FileDialog::FileDialog() { mkdirerr->set_text("Could not create folder."); add_child(mkdirerr); + exterr = memnew( AcceptDialog ); + exterr->set_text("Must use a valid extension."); + add_child(exterr); + //update_file_list(); update_filters(); diff --git a/scene/gui/file_dialog.h b/scene/gui/file_dialog.h index 6f274de52a..bda1797696 100644 --- a/scene/gui/file_dialog.h +++ b/scene/gui/file_dialog.h @@ -82,6 +82,7 @@ private: Tree *tree; LineEdit *file; AcceptDialog *mkdirerr; + AcceptDialog *exterr; OptionButton *filter; DirAccess *dir_access; ConfirmationDialog *confirm_save; diff --git a/scene/gui/menu_button.cpp b/scene/gui/menu_button.cpp index 4d1609bef9..7353744d07 100644 --- a/scene/gui/menu_button.cpp +++ b/scene/gui/menu_button.cpp @@ -141,7 +141,7 @@ MenuButton::MenuButton() { popup->hide(); add_child(popup); popup->set_as_toplevel(true); - add_to_group("unhandled_key_input"); + set_process_unhandled_key_input(true); set_click_on_press(true); } |