diff --git a/core/ass_file.cpp b/core/ass_file.cpp index 6ef3d6b58..74a8c48de 100644 --- a/core/ass_file.cpp +++ b/core/ass_file.cpp @@ -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(""); } diff --git a/core/subtitle_format.cpp b/core/subtitle_format.cpp index a4f026338..936029c66 100644 --- a/core/subtitle_format.cpp +++ b/core/subtitle_format.cpp @@ -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::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;iGetName() + _T(" (") + temp1.Left(temp1.Length()-1) + _T(")|") + temp2.Left(temp2.Length()-1) + _T("|"); + } + } + + // Return final list + return final.Left(final.Length()-1); +} diff --git a/core/subtitle_format.h b/core/subtitle_format.h index b391f448f..84f2e2d7d 100644 --- a/core/subtitle_format.h +++ b/core/subtitle_format.h @@ -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("")) { }; diff --git a/core/subtitle_format_ass.cpp b/core/subtitle_format_ass.cpp index 495c4fa16..2d972eca5 100644 --- a/core/subtitle_format_ass.cpp +++ b/core/subtitle_format_ass.cpp @@ -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) { diff --git a/core/subtitle_format_ass.h b/core/subtitle_format_ass.h index 279c935c0..1f7b3d70c 100644 --- a/core/subtitle_format_ass.h +++ b/core/subtitle_format_ass.h @@ -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); diff --git a/core/subtitle_format_mkv.cpp b/core/subtitle_format_mkv.cpp index f5acbccd7..b39c5c12b 100644 --- a/core/subtitle_format_mkv.cpp +++ b/core/subtitle_format_mkv.cpp @@ -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) { diff --git a/core/subtitle_format_mkv.h b/core/subtitle_format_mkv.h index 50074f346..dd6038f03 100644 --- a/core/subtitle_format_mkv.h +++ b/core/subtitle_format_mkv.h @@ -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); diff --git a/core/subtitle_format_prs.cpp b/core/subtitle_format_prs.cpp index c0f0bdfe6..05316a440 100644 --- a/core/subtitle_format_prs.cpp +++ b/core/subtitle_format_prs.cpp @@ -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) { diff --git a/core/subtitle_format_prs.h b/core/subtitle_format_prs.h index 6dbd7ebb7..24ead9828 100644 --- a/core/subtitle_format_prs.h +++ b/core/subtitle_format_prs.h @@ -68,6 +68,9 @@ private: void OptimizeImage(wxImage &image); public: + wxString GetName(); + wxArrayString GetWriteWildcards(); + bool CanWriteFile(wxString filename); void WriteFile(wxString filename,wxString encoding); }; diff --git a/core/subtitle_format_srt.cpp b/core/subtitle_format_srt.cpp index 547c879b4..876f34729 100644 --- a/core/subtitle_format_srt.cpp +++ b/core/subtitle_format_srt.cpp @@ -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) { diff --git a/core/subtitle_format_srt.h b/core/subtitle_format_srt.h index a8df343a2..257b16065 100644 --- a/core/subtitle_format_srt.h +++ b/core/subtitle_format_srt.h @@ -55,6 +55,10 @@ private: void DialogueToSRT(AssDialogue *current,std::list::iterator prev); public: + wxString GetName(); + wxArrayString GetReadWildcards(); + wxArrayString GetWriteWildcards(); + bool CanReadFile(wxString filename); void ReadFile(wxString filename,wxString forceEncoding); diff --git a/core/subtitle_format_txt.cpp b/core/subtitle_format_txt.cpp index 4d459d0b8..d005977e3 100644 --- a/core/subtitle_format_txt.cpp +++ b/core/subtitle_format_txt.cpp @@ -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; diff --git a/core/subtitle_format_txt.h b/core/subtitle_format_txt.h index 70267c1fc..2c15ab988 100644 --- a/core/subtitle_format_txt.h +++ b/core/subtitle_format_txt.h @@ -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);