diff --git a/core/ass_file.cpp b/core/ass_file.cpp index cc20aab8e..716f04a59 100644 --- a/core/ass_file.cpp +++ b/core/ass_file.cpp @@ -559,7 +559,8 @@ void AssFile::InsertAttachment (wxString filename) { } // Insert - newAttach->group = _T("[Fonts]"); + if (filename.Right(4).Lower() == _T(".ttf")) newAttach->group = _T("[Fonts]"); + else newAttach->group = _T("[Graphics]"); InsertAttachment(newAttach); } diff --git a/core/changelog.txt b/core/changelog.txt index 61fde27c9..40eb5ae13 100644 --- a/core/changelog.txt +++ b/core/changelog.txt @@ -87,7 +87,7 @@ Please visit http://aegisub.net to download latest version - Right-clicking on the header of the subtitles grid will now bring up a popup menu that allows you to disable columns. (AMZ) - Saving back to SRT directly (that is, via "save", not "export" or "save as") is now allowed, as long as no data will be lost. (AMZ) - Aegisub now supports file attachments, which are stored decoded (to save memory) and are not part of the undo stack (for the same reason). Previously, they were simply left ignored in the file as unknown lines. (AMZ) -- Implemented an Attached files list, where you can attach new fonts, extract them, or remove them from the script file. (AMZ) +- Implemented an Attached files list, where you can attach new fonts and graphics, extract them, or remove them from the script file. (AMZ) - The Font Collector can now collect fonts as script attachments. (AMZ) diff --git a/core/dialog_attachments.cpp b/core/dialog_attachments.cpp index de62e2a9e..aff0ea872 100644 --- a/core/dialog_attachments.cpp +++ b/core/dialog_attachments.cpp @@ -58,10 +58,11 @@ DialogAttachments::DialogAttachments(wxWindow *parent) // Buttons sizer wxSizer *buttonSizer = new wxBoxSizer(wxHORIZONTAL); - buttonSizer->Add(new wxButton(this,BUTTON_ATTACH_FONT,_("&Attach Font")),3,0,0); - buttonSizer->Add(new wxButton(this,BUTTON_EXTRACT,_("E&xtract")),2,0,0); - buttonSizer->Add(new wxButton(this,BUTTON_DELETE,_("&Delete")),2,0,0); - buttonSizer->Add(new wxButton(this,BUTTON_CLOSE,_("&Close")),2,wxLEFT,5); + buttonSizer->Add(new wxButton(this,BUTTON_ATTACH_FONT,_("Attach &Font")),1,0,0); + buttonSizer->Add(new wxButton(this,BUTTON_ATTACH_GRAPHICS,_("Attach &Graphics")),1,0,0); + buttonSizer->Add(new wxButton(this,BUTTON_EXTRACT,_("E&xtract")),1,0,0); + buttonSizer->Add(new wxButton(this,BUTTON_DELETE,_("&Delete")),1,0,0); + buttonSizer->Add(new wxButton(this,BUTTON_CLOSE,_("&Close")),1,wxLEFT,5); // Main sizer wxSizer *mainSizer = new wxBoxSizer(wxVERTICAL); @@ -109,6 +110,7 @@ DialogAttachments::~DialogAttachments() { // Event table BEGIN_EVENT_TABLE(DialogAttachments,wxDialog) EVT_BUTTON(BUTTON_ATTACH_FONT,DialogAttachments::OnAttachFont) + EVT_BUTTON(BUTTON_ATTACH_GRAPHICS,DialogAttachments::OnAttachGraphics) EVT_BUTTON(BUTTON_EXTRACT,DialogAttachments::OnExtract) EVT_BUTTON(BUTTON_DELETE,DialogAttachments::OnDelete) EVT_BUTTON(BUTTON_CLOSE,DialogAttachments::OnClose) @@ -118,12 +120,12 @@ END_EVENT_TABLE() /////////////// // Attach font void DialogAttachments::OnAttachFont(wxCommandEvent &event) { - // Pick file + // Pick files wxArrayString filenames; wxArrayString paths; { wxFileDialog diag (this,_("Choose file to be attached"), Options.AsText(_T("Fonts Collector Destination")), _T(""), _T("Font Files (*.ttf)|*.ttf"), wxOPEN | wxFILE_MUST_EXIST | wxMULTIPLE); - diag.ShowModal(); + if (diag.ShowModal() == wxID_CANCEL) return; diag.GetFilenames(filenames); diag.GetPaths(paths); } @@ -148,6 +150,39 @@ void DialogAttachments::OnAttachFont(wxCommandEvent &event) { } +/////////////////// +// Attach graphics +void DialogAttachments::OnAttachGraphics(wxCommandEvent &event) { + // Pick files + wxArrayString filenames; + wxArrayString paths; + { + wxFileDialog diag (this,_("Choose file to be attached"), _T(""), _T(""), _T("Graphic Files (*.bmp,*.gif,*.jpg,*.ico,*.wmf)|*.bmp;*.gif;*.jpg;*.ico;*.wmf"), wxOPEN | wxFILE_MUST_EXIST | wxMULTIPLE); + if (diag.ShowModal() == wxID_CANCEL) return; + diag.GetFilenames(filenames); + diag.GetPaths(paths); + } + + // Create attachments + for (size_t i=0;iImport(paths[i]); + } + catch (...) { + delete newAttach; + return; + } + newAttach->group = _T("[Graphics]"); + AssFile::top->InsertAttachment(newAttach); + } + + // Update + UpdateList(); +} + + /////////// // Extract void DialogAttachments::OnExtract(wxCommandEvent &event) { diff --git a/core/dialog_attachments.h b/core/dialog_attachments.h index 2c00f2561..9c8198aed 100644 --- a/core/dialog_attachments.h +++ b/core/dialog_attachments.h @@ -54,6 +54,7 @@ private: wxListView *listView; void OnAttachFont(wxCommandEvent &event); + void OnAttachGraphics(wxCommandEvent &event); void OnExtract(wxCommandEvent &event); void OnDelete(wxCommandEvent &event); void OnClose(wxCommandEvent &event); @@ -72,6 +73,7 @@ public: // IDs enum { BUTTON_ATTACH_FONT = 1300, + BUTTON_ATTACH_GRAPHICS, BUTTON_EXTRACT, BUTTON_DELETE, BUTTON_CLOSE