Skip to content

Commit

Permalink
improved save path error messages for scene, textures and audio, fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
reduz committed Apr 12, 2015
1 parent 87c51b6 commit 2dfa127
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 8 deletions.
9 changes: 9 additions & 0 deletions core/os/dir_access.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,15 @@ Error DirAccess::copy(String p_from,String p_to) {
return err;
}

bool DirAccess::exists(String p_dir) {

DirAccess* da = DirAccess::create_for_path(p_dir);
bool valid = da->change_dir(p_dir)==OK;
memdelete(da);
return valid;

}

DirAccess::DirAccess(){

_access_type=ACCESS_FILESYSTEM;
Expand Down
2 changes: 1 addition & 1 deletion core/os/dir_access.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class DirAccess {

virtual bool file_exists(String p_file)=0;
virtual bool dir_exists(String p_dir)=0;

static bool exists(String p_dir);
virtual size_t get_space_left()=0;

virtual Error copy(String p_from,String p_to);
Expand Down
1 change: 1 addition & 0 deletions platform/x11/os_x11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ void OS_X11::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi
continue;
if (AudioDriverManagerSW::get_driver(i)->init()==OK) {
success=true;
print_line("Audio Driver Failed: "+String(AudioDriverManagerSW::get_driver(p_audio_driver)->get_name()));
print_line("Using alternate audio driver: "+String(AudioDriverManagerSW::get_driver(i)->get_name()));
break;
}
Expand Down
18 changes: 18 additions & 0 deletions tools/editor/io_plugins/editor_sample_import_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,24 @@ class EditorSampleImportDialog : public ConfirmationDialog {
error_dialog->popup_centered(Size2(200,100));
}

if (save_path->get_text().strip_edges()=="") {
error_dialog->set_text("Target path is empty.");
error_dialog->popup_centered_minsize();
return;
}

if (!save_path->get_text().begins_with("res://")) {
error_dialog->set_text("Target path must be full resource path.");
error_dialog->popup_centered_minsize();
return;
}

if (!DirAccess::exists(save_path->get_text())) {
error_dialog->set_text("Target path must exist.");
error_dialog->popup_centered_minsize();
return;
}

for(int i=0;i<samples.size();i++) {

Ref<ResourceImportMetadata> imd = memnew( ResourceImportMetadata );
Expand Down
21 changes: 17 additions & 4 deletions tools/editor/io_plugins/editor_scene_import_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -671,15 +671,28 @@ void EditorSceneImportDialog::_import(bool p_and_open) {
wip_open=p_and_open;
//' ImportMonitorBlock imb;

if (import_path->get_text()=="") {

if (import_path->get_text().strip_edges()=="") {
error_dialog->set_text("Source path is empty.");
error_dialog->popup_centered(Size2(200,100));
error_dialog->popup_centered_minsize();
return;
}

if (save_path->get_text()=="") {
if (save_path->get_text().strip_edges()=="") {
error_dialog->set_text("Target path is empty.");
error_dialog->popup_centered(Size2(200,100));
error_dialog->popup_centered_minsize();
return;
}

if (!save_path->get_text().begins_with("res://")) {
error_dialog->set_text("Target path must be full resource path.");
error_dialog->popup_centered_minsize();
return;
}

if (!DirAccess::exists(save_path->get_text())) {
error_dialog->set_text("Target path must exist.");
error_dialog->popup_centered_minsize();
return;
}

Expand Down
17 changes: 14 additions & 3 deletions tools/editor/io_plugins/editor_texture_import_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,12 +321,23 @@ void EditorTextureImportDialog::_import() {

String dst_path=save_path->get_text();

if (dst_path.empty()) {
if (save_path->get_text().strip_edges()=="") {
error_dialog->set_text("Target path is empty.");
error_dialog->popup_centered_minsize();
return;
}

error_dialog->set_text("Please specify a valid target import path!");
error_dialog->popup_centered(Size2(200,100));
if (!save_path->get_text().begins_with("res://")) {
error_dialog->set_text("Target path must be full resource path.");
error_dialog->popup_centered_minsize();
return;
}


if (!atlas && !DirAccess::exists(save_path->get_text())) {
error_dialog->set_text("Target path must exist.");
error_dialog->popup_centered_minsize();
return;
}

if (atlas) { //atlas
Expand Down

0 comments on commit 2dfa127

Please sign in to comment.