mirror of https://github.com/odrling/Aegisub
Wildcards in file open dialogs are now generated from the subtitle formats themselves.
Originally committed to SVN as r626.
This commit is contained in:
parent
95059b79bf
commit
a14ab15c94
|
@ -773,9 +773,14 @@ void AssFile::AddToRecent(wxString file) {
|
|||
///////////////////////////////
|
||||
// List of supported wildcards
|
||||
wxString AssFile::GetWildcardList(int mode) {
|
||||
if (mode == 0) return _T("All Supported Types (*.ass,*.ssa,*.srt,*.txt,*.mkv,*.mks,*.mka)|*.ass;*.ssa;*.srt;*.txt;*.mkv;*.mks;*.mka|Advanced Substation Alpha (*.ass)|*.ass|Substation Alpha (*.ssa)|*.ssa|SubRip (*.srt)|*.srt|Plain-text (*.txt)|*.txt|Matroska (*.mkv,*.mks,*.mka)|*.mkv;*.mks;*.mka");
|
||||
//if (mode == 0) return _T("All Supported Types (*.ass,*.ssa,*.srt,*.txt,*.mkv,*.mks,*.mka)|*.ass;*.ssa;*.srt;*.txt;*.mkv;*.mks;*.mka|Advanced Substation Alpha (*.ass)|*.ass|Substation Alpha (*.ssa)|*.ssa|SubRip (*.srt)|*.srt|Plain-text (*.txt)|*.txt|Matroska (*.mkv,*.mks,*.mka)|*.mkv;*.mks;*.mka");
|
||||
//else if (mode == 1) return _T("Advanced Substation Alpha (*.ass)|*.ass");
|
||||
//else if (mode == 2) return _T("All Supported Types (*.ass,*.ssa,*.srt,*.txt,*.mkv,*.mks,*.mka)|*.ass;*.ssa;*.srt;*.txt|Advanced Substation Alpha (*.ass)|*.ass|Substation Alpha (*.ssa)|*.ssa|SubRip (*.srt)|*.srt|Plain-text (*.txt)|*.txt");
|
||||
//else return _T("");
|
||||
|
||||
if (mode == 0) return SubtitleFormat::GetWildcards(0);
|
||||
else if (mode == 1) return _T("Advanced Substation Alpha (*.ass)|*.ass");
|
||||
else if (mode == 2) return _T("All Supported Types (*.ass,*.ssa,*.srt,*.txt,*.mkv,*.mks,*.mka)|*.ass;*.ssa;*.srt;*.txt|Advanced Substation Alpha (*.ass)|*.ass|Substation Alpha (*.ssa)|*.ssa|SubRip (*.srt)|*.srt|Plain-text (*.txt)|*.txt");
|
||||
else if (mode == 2) return SubtitleFormat::GetWildcards(1);
|
||||
else return _T("");
|
||||
}
|
||||
|
||||
|
|
|
@ -197,3 +197,60 @@ void SubtitleFormat::Remove() {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//////////////////////
|
||||
// Get read wildcards
|
||||
wxArrayString SubtitleFormat::GetReadWildcards() {
|
||||
return wxArrayString();
|
||||
}
|
||||
|
||||
|
||||
///////////////////////
|
||||
// Get write wildcards
|
||||
wxArrayString SubtitleFormat::GetWriteWildcards() {
|
||||
return wxArrayString();
|
||||
}
|
||||
|
||||
|
||||
/////////////////////
|
||||
// Get wildcard list
|
||||
wxString SubtitleFormat::GetWildcards(int mode) {
|
||||
// Ensure it's loaded
|
||||
LoadFormats();
|
||||
|
||||
// Variables
|
||||
wxArrayString all;
|
||||
wxArrayString cur;
|
||||
wxString wild;
|
||||
wxString final;
|
||||
|
||||
// For each format
|
||||
std::list<SubtitleFormat*>::iterator curIter;
|
||||
SubtitleFormat *format;
|
||||
for (curIter=formats.begin();curIter!=formats.end();curIter++) {
|
||||
// Get list
|
||||
format = *curIter;
|
||||
if (mode == 0) cur = format->GetReadWildcards();
|
||||
else if (mode == 1) cur = format->GetWriteWildcards();
|
||||
wxString temp1;
|
||||
wxString temp2;
|
||||
|
||||
// Has wildcards
|
||||
if (cur.Count()) {
|
||||
// Process entries
|
||||
for (unsigned int i=0;i<cur.Count();i++) {
|
||||
wild = _T("*.") + cur[i];
|
||||
all.Add(wild);
|
||||
temp1 += wild + _T(",");
|
||||
temp2 += wild + _T(";");
|
||||
}
|
||||
|
||||
// Assemble final name
|
||||
final += format->GetName() + _T(" (") + temp1.Left(temp1.Length()-1) + _T(")|") + temp2.Left(temp2.Length()-1) + _T("|");
|
||||
}
|
||||
}
|
||||
|
||||
// Return final list
|
||||
return final.Left(final.Length()-1);
|
||||
}
|
||||
|
|
|
@ -72,11 +72,17 @@ protected:
|
|||
AssFile *GetAssFile() { return assFile; }
|
||||
int AddLine(wxString data,wxString group,int lasttime,bool &IsSSA,wxString *outgroup=NULL);
|
||||
|
||||
virtual wxString GetName()=0;
|
||||
virtual wxArrayString GetReadWildcards();
|
||||
virtual wxArrayString GetWriteWildcards();
|
||||
|
||||
public:
|
||||
SubtitleFormat();
|
||||
virtual ~SubtitleFormat();
|
||||
void SetTarget(AssFile *file);
|
||||
|
||||
static wxString GetWildcards(int mode);
|
||||
|
||||
virtual bool CanReadFile(wxString filename) { return false; };
|
||||
virtual bool CanWriteFile(wxString filename) { return false; };
|
||||
virtual void ReadFile(wxString filename,wxString forceEncoding=_T("")) { };
|
||||
|
|
|
@ -49,6 +49,33 @@ bool ASSSubtitleFormat::CanReadFile(wxString filename) {
|
|||
}
|
||||
|
||||
|
||||
////////////
|
||||
// Get name
|
||||
wxString ASSSubtitleFormat::GetName() {
|
||||
return _T("Advanced Substation Alpha");
|
||||
}
|
||||
|
||||
|
||||
//////////////////////
|
||||
// Get read wildcards
|
||||
wxArrayString ASSSubtitleFormat::GetReadWildcards() {
|
||||
wxArrayString formats;
|
||||
formats.Add(_T("ass"));
|
||||
formats.Add(_T("ssa"));
|
||||
return formats;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////
|
||||
// Get write wildcards
|
||||
wxArrayString ASSSubtitleFormat::GetWriteWildcards() {
|
||||
wxArrayString formats;
|
||||
formats.Add(_T("ass"));
|
||||
formats.Add(_T("ssa"));
|
||||
return formats;
|
||||
}
|
||||
|
||||
|
||||
/////////////
|
||||
// Read file
|
||||
void ASSSubtitleFormat::ReadFile(wxString filename,wxString encoding) {
|
||||
|
|
|
@ -51,6 +51,10 @@ class AssDialogue;
|
|||
// ASS reader/writer
|
||||
class ASSSubtitleFormat : public SubtitleFormat {
|
||||
public:
|
||||
wxString GetName();
|
||||
wxArrayString GetReadWildcards();
|
||||
wxArrayString GetWriteWildcards();
|
||||
|
||||
bool CanReadFile(wxString filename);
|
||||
void ReadFile(wxString filename,wxString forceEncoding);
|
||||
|
||||
|
|
|
@ -49,6 +49,24 @@ bool MKVSubtitleFormat::CanReadFile(wxString filename) {
|
|||
}
|
||||
|
||||
|
||||
////////////
|
||||
// Get name
|
||||
wxString MKVSubtitleFormat::GetName() {
|
||||
return _T("Matroska");
|
||||
}
|
||||
|
||||
|
||||
//////////////////////
|
||||
// Get read wildcards
|
||||
wxArrayString MKVSubtitleFormat::GetReadWildcards() {
|
||||
wxArrayString formats;
|
||||
formats.Add(_T("mkv"));
|
||||
formats.Add(_T("mka"));
|
||||
formats.Add(_T("mks"));
|
||||
return formats;
|
||||
}
|
||||
|
||||
|
||||
/////////////
|
||||
// Read file
|
||||
void MKVSubtitleFormat::ReadFile(wxString filename,wxString encoding) {
|
||||
|
|
|
@ -51,6 +51,9 @@ class AssDialogue;
|
|||
// ASS reader/writer
|
||||
class MKVSubtitleFormat : public SubtitleFormat {
|
||||
public:
|
||||
wxString GetName();
|
||||
wxArrayString GetReadWildcards();
|
||||
|
||||
bool CanReadFile(wxString filename);
|
||||
void ReadFile(wxString filename,wxString forceEncoding);
|
||||
|
||||
|
|
|
@ -71,6 +71,22 @@ bool PRSSubtitleFormat::CanWriteFile(wxString filename) {
|
|||
}
|
||||
|
||||
|
||||
////////////
|
||||
// Get name
|
||||
wxString PRSSubtitleFormat::GetName() {
|
||||
return _T("Pre-Rendered Subtitles");
|
||||
}
|
||||
|
||||
|
||||
///////////////////////
|
||||
// Get write wildcards
|
||||
wxArrayString PRSSubtitleFormat::GetWriteWildcards() {
|
||||
wxArrayString formats;
|
||||
formats.Add(_T("prs"));
|
||||
return formats;
|
||||
}
|
||||
|
||||
|
||||
//////////////
|
||||
// Write file
|
||||
void PRSSubtitleFormat::WriteFile(wxString filename,wxString encoding) {
|
||||
|
|
|
@ -68,6 +68,9 @@ private:
|
|||
void OptimizeImage(wxImage &image);
|
||||
|
||||
public:
|
||||
wxString GetName();
|
||||
wxArrayString GetWriteWildcards();
|
||||
|
||||
bool CanWriteFile(wxString filename);
|
||||
void WriteFile(wxString filename,wxString encoding);
|
||||
};
|
||||
|
|
|
@ -50,6 +50,36 @@ bool SRTSubtitleFormat::CanReadFile(wxString filename) {
|
|||
}
|
||||
|
||||
|
||||
//////////////
|
||||
// Can write?
|
||||
bool SRTSubtitleFormat::CanWriteFile(wxString filename) {
|
||||
return (filename.Right(4).Lower() == _T(".srt"));
|
||||
}
|
||||
|
||||
|
||||
////////////
|
||||
// Get name
|
||||
wxString SRTSubtitleFormat::GetName() {
|
||||
return _T("SubRip");
|
||||
}
|
||||
|
||||
|
||||
//////////////////////
|
||||
// Get read wildcards
|
||||
wxArrayString SRTSubtitleFormat::GetReadWildcards() {
|
||||
wxArrayString formats;
|
||||
formats.Add(_T("srt"));
|
||||
return formats;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////
|
||||
// Get write wildcards
|
||||
wxArrayString SRTSubtitleFormat::GetWriteWildcards() {
|
||||
return GetReadWildcards();
|
||||
}
|
||||
|
||||
|
||||
/////////////
|
||||
// Read file
|
||||
void SRTSubtitleFormat::ReadFile(wxString filename,wxString encoding) {
|
||||
|
@ -126,13 +156,6 @@ void SRTSubtitleFormat::ReadFile(wxString filename,wxString encoding) {
|
|||
}
|
||||
|
||||
|
||||
//////////////
|
||||
// Can write?
|
||||
bool SRTSubtitleFormat::CanWriteFile(wxString filename) {
|
||||
return (filename.Right(4).Lower() == _T(".srt"));
|
||||
}
|
||||
|
||||
|
||||
//////////////
|
||||
// Write file
|
||||
void SRTSubtitleFormat::WriteFile(wxString _filename,wxString encoding) {
|
||||
|
|
|
@ -55,6 +55,10 @@ private:
|
|||
void DialogueToSRT(AssDialogue *current,std::list<AssEntry*>::iterator prev);
|
||||
|
||||
public:
|
||||
wxString GetName();
|
||||
wxArrayString GetReadWildcards();
|
||||
wxArrayString GetWriteWildcards();
|
||||
|
||||
bool CanReadFile(wxString filename);
|
||||
void ReadFile(wxString filename,wxString forceEncoding);
|
||||
|
||||
|
|
|
@ -58,6 +58,29 @@ bool TXTSubtitleFormat::CanWriteFile(wxString filename) {
|
|||
}
|
||||
|
||||
|
||||
////////////
|
||||
// Get name
|
||||
wxString TXTSubtitleFormat::GetName() {
|
||||
return _T("Plain-Text");
|
||||
}
|
||||
|
||||
|
||||
//////////////////////
|
||||
// Get read wildcards
|
||||
wxArrayString TXTSubtitleFormat::GetReadWildcards() {
|
||||
wxArrayString formats;
|
||||
formats.Add(_T("txt"));
|
||||
return formats;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////
|
||||
// Get write wildcards
|
||||
wxArrayString TXTSubtitleFormat::GetWriteWildcards() {
|
||||
return GetReadWildcards();
|
||||
}
|
||||
|
||||
|
||||
/////////////
|
||||
// Read file
|
||||
void TXTSubtitleFormat::ReadFile(wxString filename,wxString encoding) { using namespace std;
|
||||
|
|
|
@ -53,6 +53,10 @@ class TXTSubtitleFormat : public SubtitleFormat {
|
|||
private:
|
||||
|
||||
public:
|
||||
wxString GetName();
|
||||
wxArrayString GetReadWildcards();
|
||||
wxArrayString GetWriteWildcards();
|
||||
|
||||
bool CanReadFile(wxString filename);
|
||||
bool CanWriteFile(wxString filename);
|
||||
void ReadFile(wxString filename,wxString forceEncoding);
|
||||
|
|
Loading…
Reference in New Issue