Prevented Aegisub from saving .txt files directly. (Fix for #653)

Originally committed to SVN as r1935.
This commit is contained in:
Rodrigo Braz Monteiro 2008-03-06 23:36:43 +00:00
parent b19737c628
commit cf3a233970
1 changed files with 13 additions and 1 deletions

View File

@ -237,12 +237,20 @@ void AssFile::Export(wxString _filename) {
// Can save file?
bool AssFile::CanSave() {
// ASS format?
if (filename.Lower().Right(4) == _T(".ass")) return true;
wxString ext = filename.Lower().Right(4);
if (ext == _T(".ass")) return true;
// Never save texts
if (ext == _T(".txt")) return false;
// Check if it's a known extension
SubtitleFormat *writer = SubtitleFormat::GetWriter(filename);
if (!writer) return false;
// Check if format supports timing
bool canTime = true;
//if (filename.Lower().Right(4) == _T(".txt")) canTime = false;
// Scan through the lines
AssStyle defstyle;
AssStyle *curstyle;
@ -262,6 +270,10 @@ bool AssFile::CanSave() {
// Check dialog
curdiag = AssEntry::GetAsDialogue(*cur);
if (curdiag) {
// Timed?
if (!canTime && (curdiag->Start.GetMS() != 0 || curdiag->End.GetMS() != 0)) return false;
// Overrides?
curdiag->ParseASSTags();
for (size_t i=0;i<curdiag->Blocks.size();i++) {
if (curdiag->Blocks[i]->GetType() != BLOCK_PLAIN) return false;