diff --git a/core/ass_attachment.cpp b/core/ass_attachment.cpp index 558fe54fa..45668260c 100644 --- a/core/ass_attachment.cpp +++ b/core/ass_attachment.cpp @@ -45,7 +45,8 @@ // Constructor AssAttachment::AssAttachment(wxString _name) { // Parse name - wxFileName fname(_name); + filename = _name; + wxFileName fname(GetFileName()); wxString ext = fname.GetExt().Lower(); wxString name; if (ext == _T("ttf")) { @@ -186,6 +187,26 @@ void AssAttachment::Import(wxString filename) { } +//////////////// +// Get filename +wxString AssAttachment::GetFileName(bool raw) { + // Raw + if (raw || filename.Right(4).Lower() != _T(".ttf")) return filename; + + // Remove stuff after last underscore if it's a font + int lastUnder = -1; + for (size_t i=0;i data; + wxString filename; public: - wxString filename; const DataVec &GetData(); void AddData(wxString data); @@ -81,6 +81,7 @@ public: void Extract(wxString filename); void Import(wxString filename); + wxString GetFileName(bool raw=false); const wxString GetEntryData(); ASS_EntryType GetType() { return ENTRY_ATTACHMENT; } diff --git a/core/dialog_attachments.cpp b/core/dialog_attachments.cpp index 1c2cac784..ecdbadd4b 100644 --- a/core/dialog_attachments.cpp +++ b/core/dialog_attachments.cpp @@ -91,7 +91,7 @@ void DialogAttachments::UpdateList() { if (attach) { // Add item int row = listView->GetItemCount(); - listView->InsertItem(row,attach->filename); + listView->InsertItem(row,attach->GetFileName(true)); listView->SetItem(row,1,PrettySize(attach->GetData().size())); listView->SetItem(row,2,attach->group); listView->SetItemData(row,(long)attach); @@ -197,7 +197,9 @@ void DialogAttachments::OnExtract(wxCommandEvent &event) { // Multiple or single? if (listView->GetNextSelected(i) != -1) path = wxDirSelector(_("Select the path to save the files to:"),Options.AsText(_T("Fonts Collector Destination"))) + _T("/"); else { - path = wxFileSelector(_("Select the path to save the file to:"),Options.AsText(_T("Fonts Collector Destination")),((AssAttachment*) listView->GetItemData(i))->filename); + // Default path + wxString defPath = ((AssAttachment*) listView->GetItemData(i))->GetFileName(); + path = wxFileSelector(_("Select the path to save the file to:"),Options.AsText(_T("Fonts Collector Destination")),defPath); fullPath = true; } if (path.IsEmpty()) return; @@ -206,7 +208,7 @@ void DialogAttachments::OnExtract(wxCommandEvent &event) { while (i != -1) { AssAttachment *attach = (AssAttachment*) listView->GetItemData(i); wxString filename = path; - if (!fullPath) filename += attach->filename; + if (!fullPath) filename += attach->GetFileName(); attach->Extract(filename); i = listView->GetNextSelected(i); }