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

View file

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