fix font import path on windows, closes #1675
This commit is contained in:
parent
fbbe7dcdfb
commit
2a02d3f96f
|
@ -3297,8 +3297,11 @@ String String::path_to_file(const String& p_path) const {
|
||||||
|
|
||||||
String src=this->replace("\\","/").get_base_dir();
|
String src=this->replace("\\","/").get_base_dir();
|
||||||
String dst=p_path.replace("\\","/").get_base_dir();
|
String dst=p_path.replace("\\","/").get_base_dir();
|
||||||
|
String rel = src.path_to(dst);
|
||||||
return src.path_to(dst)+p_path.get_file();
|
if (rel==dst) // failed
|
||||||
|
return p_path;
|
||||||
|
else
|
||||||
|
return rel+p_path.get_file();
|
||||||
}
|
}
|
||||||
|
|
||||||
String String::path_to(const String& p_path) const {
|
String String::path_to(const String& p_path) const {
|
||||||
|
@ -3333,7 +3336,9 @@ String String::path_to(const String& p_path) const {
|
||||||
String src_begin=src.get_slice("/",0);
|
String src_begin=src.get_slice("/",0);
|
||||||
String dst_begin=dst.get_slice("/",0);
|
String dst_begin=dst.get_slice("/",0);
|
||||||
|
|
||||||
ERR_FAIL_COND_V(src_begin!=dst_begin,p_path); //return dst absolute path
|
if (src_begin!=dst_begin)
|
||||||
|
return p_path; //impossible to do this
|
||||||
|
|
||||||
base=src_begin;
|
base=src_begin;
|
||||||
src=src.substr(src_begin.length(),src.length());
|
src=src.substr(src_begin.length(),src.length());
|
||||||
dst=dst.substr(dst_begin.length(),dst.length());
|
dst=dst.substr(dst_begin.length(),dst.length());
|
||||||
|
|
|
@ -92,7 +92,6 @@ void FileDialog::_file_entered(const String& p_file) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileDialog::_save_confirm_pressed() {
|
void FileDialog::_save_confirm_pressed() {
|
||||||
|
|
||||||
String f=dir_access->get_current_dir().plus_file(file->get_text());
|
String f=dir_access->get_current_dir().plus_file(file->get_text());
|
||||||
emit_signal("file_selected",f);
|
emit_signal("file_selected",f);
|
||||||
hide();
|
hide();
|
||||||
|
|
|
@ -47,6 +47,7 @@ String EditorImportPlugin::validate_source_path(const String& p_path) {
|
||||||
String rp = Globals::get_singleton()->get_resource_path();
|
String rp = Globals::get_singleton()->get_resource_path();
|
||||||
if (!rp.ends_with("/"))
|
if (!rp.ends_with("/"))
|
||||||
rp+="/";
|
rp+="/";
|
||||||
|
|
||||||
return rp.path_to_file(gp);
|
return rp.path_to_file(gp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -406,7 +406,10 @@ class EditorFontImportDialog : public ConfirmationDialog {
|
||||||
imd->set_option(opt,v);
|
imd->set_option(opt,v);
|
||||||
}
|
}
|
||||||
|
|
||||||
imd->add_source(EditorImportPlugin::validate_source_path(source->get_line_edit()->get_text()));
|
String src_path = EditorImportPlugin::validate_source_path(source->get_line_edit()->get_text());
|
||||||
|
//print_line("pre src path "+source->get_line_edit()->get_text());
|
||||||
|
//print_line("src path "+src_path);
|
||||||
|
imd->add_source(src_path);
|
||||||
imd->set_option("font/size",font_size->get_val());
|
imd->set_option("font/size",font_size->get_val());
|
||||||
|
|
||||||
return imd;
|
return imd;
|
||||||
|
@ -1018,7 +1021,7 @@ Ref<Font> EditorFontImportPlugin::generate_font(const Ref<ResourceImportMetadata
|
||||||
int h = slot->bitmap.rows;
|
int h = slot->bitmap.rows;
|
||||||
int p = slot->bitmap.pitch;
|
int p = slot->bitmap.pitch;
|
||||||
|
|
||||||
print_line("W: "+itos(w)+" P: "+itos(slot->bitmap.pitch));
|
//print_line("W: "+itos(w)+" P: "+itos(slot->bitmap.pitch));
|
||||||
|
|
||||||
if (font_mode==_EditorFontImportOptions::FONT_DISTANCE_FIELD) {
|
if (font_mode==_EditorFontImportOptions::FONT_DISTANCE_FIELD) {
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue