The Font Collector can now collect fonts as script attachments.
Originally committed to SVN as r447.
This commit is contained in:
parent
d6c3e6492a
commit
33a6ba558a
5 changed files with 52 additions and 3 deletions
|
@ -38,6 +38,7 @@
|
|||
// Includes
|
||||
#include <list>
|
||||
#include <fstream>
|
||||
#include <wx/filename.h>
|
||||
#include "ass_file.h"
|
||||
#include "ass_dialogue.h"
|
||||
#include "ass_style.h"
|
||||
|
@ -539,6 +540,30 @@ void AssFile::InsertAttachment (AssAttachment *attach) {
|
|||
}
|
||||
|
||||
|
||||
///////////////////////////////
|
||||
// Insert attachment from file
|
||||
void AssFile::InsertAttachment (wxString filename) {
|
||||
// Get name
|
||||
wxFileName fname(filename);
|
||||
|
||||
// Create
|
||||
AssAttachment *newAttach = new AssAttachment(fname.GetFullName());
|
||||
|
||||
// Load
|
||||
try {
|
||||
newAttach->Import(filename);
|
||||
}
|
||||
catch (...) {
|
||||
delete newAttach;
|
||||
throw;
|
||||
}
|
||||
|
||||
// Insert
|
||||
newAttach->group = _T("[Fonts]");
|
||||
InsertAttachment(newAttach);
|
||||
}
|
||||
|
||||
|
||||
////////////////////
|
||||
// Gets script info
|
||||
wxString AssFile::GetScriptInfo(const wxString _key) {
|
||||
|
|
|
@ -85,6 +85,7 @@ public:
|
|||
void LoadDefault(bool noline=true); // Loads default file. Pass true to prevent it from adding a default line too
|
||||
void InsertStyle(AssStyle *style); // Inserts a style to file
|
||||
void InsertAttachment(AssAttachment *attach); // Inserts an attachment
|
||||
void InsertAttachment(wxString filename); // Inserts a file as an attachment
|
||||
wxArrayString GetStyles(); // Gets a list of all styles available
|
||||
AssStyle *GetStyle(wxString name); // Gets style by its name
|
||||
|
||||
|
|
|
@ -88,6 +88,7 @@ Please visit http://aegisub.net to download latest version
|
|||
- 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)
|
||||
- The Font Collector can now collect fonts as script attachments. (AMZ)
|
||||
|
||||
|
||||
= 1.09 beta - 2006.01.16 ===========================
|
||||
|
|
|
@ -61,6 +61,7 @@ DialogFontsCollector::DialogFontsCollector(wxWindow *parent)
|
|||
wxFileName filename(AssFile::top->filename);
|
||||
dest = filename.GetPath();
|
||||
}
|
||||
AttachmentCheck = new wxCheckBox(this,ATTACHMENT_CHECK,_T("As attachments"),wxDefaultPosition);
|
||||
DestBox = new wxTextCtrl(this,-1,dest,wxDefaultPosition,wxSize(250,20),0);
|
||||
BrowseButton = new wxButton(this,BROWSE_BUTTON,_("&Browse..."));
|
||||
wxSizer *DestBottomSizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
|
@ -70,6 +71,7 @@ DialogFontsCollector::DialogFontsCollector(wxWindow *parent)
|
|||
wxSizer *DestSizer = new wxStaticBoxSizer(wxVERTICAL,this,_("Destination"));
|
||||
DestSizer->Add(DestLabel,0,wxEXPAND | wxBOTTOM,5);
|
||||
DestSizer->Add(DestBottomSizer,0,wxEXPAND,0);
|
||||
DestSizer->Add(AttachmentCheck,0,wxTOP,5);
|
||||
|
||||
// Log box
|
||||
LogBox = new wxTextCtrl(this,-1,_T(""),wxDefaultPosition,wxSize(300,210),wxTE_MULTILINE | wxTE_READONLY | wxTE_RICH);
|
||||
|
@ -142,6 +144,7 @@ BEGIN_EVENT_TABLE(DialogFontsCollector, wxDialog)
|
|||
EVT_BUTTON(START_BUTTON,DialogFontsCollector::OnStart)
|
||||
EVT_BUTTON(BROWSE_BUTTON,DialogFontsCollector::OnBrowse)
|
||||
EVT_BUTTON(wxID_CLOSE,DialogFontsCollector::OnClose)
|
||||
EVT_CHECKBOX(ATTACHMENT_CHECK,DialogFontsCollector::OnCheck)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
|
||||
|
@ -176,6 +179,7 @@ void DialogFontsCollector::OnStart(wxCommandEvent &event) {
|
|||
BrowseButton->Enable(false);
|
||||
DestBox->Enable(false);
|
||||
CloseButton->Enable(false);
|
||||
AttachmentCheck->Enable(false);
|
||||
if (!worker->IsDetached()) worker->Wait();
|
||||
}
|
||||
|
||||
|
@ -203,6 +207,14 @@ void DialogFontsCollector::OnBrowse(wxCommandEvent &event) {
|
|||
}
|
||||
|
||||
|
||||
////////////
|
||||
// Checkbox
|
||||
void DialogFontsCollector::OnCheck(wxCommandEvent &event) {
|
||||
BrowseButton->Enable(!AttachmentCheck->IsChecked());
|
||||
DestBox->Enable(!AttachmentCheck->IsChecked());
|
||||
}
|
||||
|
||||
|
||||
//////////////////////
|
||||
// Get font filenames
|
||||
wxArrayString FontsCollectorThread::GetFontFiles (wxString face) {
|
||||
|
@ -352,6 +364,7 @@ void FontsCollectorThread::Collect() {
|
|||
// Get font file names
|
||||
wxArrayString work;
|
||||
wxArrayString copied;
|
||||
bool attaching = collector->AttachmentCheck->IsChecked();
|
||||
for (size_t i=0;i<fonts.GetCount();i++) {
|
||||
try {
|
||||
work = GetFontFiles(fonts[i]);
|
||||
|
@ -372,7 +385,7 @@ void FontsCollectorThread::Collect() {
|
|||
copied.Add(work[j]);
|
||||
|
||||
// Check if it exists
|
||||
if (wxFileName::FileExists(dstFile)) {
|
||||
if (!attaching && wxFileName::FileExists(dstFile)) {
|
||||
wxMutexGuiEnter();
|
||||
LogBox->SetDefaultStyle(wxTextAttr(wxColour(255,128,0)));
|
||||
LogBox->AppendText(wxString(_T("\"")) + work[j] + _("\" already exists on destination.\n"));
|
||||
|
@ -385,7 +398,13 @@ void FontsCollectorThread::Collect() {
|
|||
// Copy
|
||||
else {
|
||||
// Copy font
|
||||
bool success = Copy(srcFile,dstFile);
|
||||
bool success;
|
||||
if (attaching) {
|
||||
success = true;
|
||||
try { subs->InsertAttachment(srcFile); }
|
||||
catch (...) { success = false; }
|
||||
}
|
||||
else success = Copy(srcFile,dstFile);
|
||||
|
||||
// Report
|
||||
wxMutexGuiEnter();
|
||||
|
|
|
@ -93,10 +93,12 @@ private:
|
|||
wxButton *BrowseButton;
|
||||
wxButton *StartButton;
|
||||
wxButton *CloseButton;
|
||||
wxCheckBox *AttachmentCheck;
|
||||
|
||||
void OnStart(wxCommandEvent &event);
|
||||
void OnClose(wxCommandEvent &event);
|
||||
void OnBrowse(wxCommandEvent &event);
|
||||
void OnCheck(wxCommandEvent &event);
|
||||
|
||||
public:
|
||||
DialogFontsCollector(wxWindow *parent);
|
||||
|
@ -110,5 +112,6 @@ public:
|
|||
// IDs
|
||||
enum {
|
||||
BROWSE_BUTTON = 1100,
|
||||
START_BUTTON
|
||||
START_BUTTON,
|
||||
ATTACHMENT_CHECK
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue