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.
Originally committed to SVN as r434.
This commit is contained in:
parent
34257c39e8
commit
5f41c378f1
|
@ -89,7 +89,6 @@ void AssFile::Load (const wxString _filename,const wxString charset) {
|
||||||
|
|
||||||
// Generic preparation
|
// Generic preparation
|
||||||
Clear();
|
Clear();
|
||||||
IsASS = false;
|
|
||||||
|
|
||||||
// Get proper format reader
|
// Get proper format reader
|
||||||
SubtitleFormat *reader = SubtitleFormat::GetReader(_filename);
|
SubtitleFormat *reader = SubtitleFormat::GetReader(_filename);
|
||||||
|
@ -167,7 +166,6 @@ void AssFile::Save(wxString _filename,bool setfilename,bool addToRecent,const wx
|
||||||
if (setfilename) {
|
if (setfilename) {
|
||||||
Modified = false;
|
Modified = false;
|
||||||
filename = _filename;
|
filename = _filename;
|
||||||
IsASS = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,6 +179,43 @@ void AssFile::Export(wxString _filename) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////
|
||||||
|
// Can save file?
|
||||||
|
bool AssFile::CanSave() {
|
||||||
|
// ASS format?
|
||||||
|
if (filename.Lower().Right(4) == _T(".ass")) return true;
|
||||||
|
|
||||||
|
// Check if it's a known extension
|
||||||
|
SubtitleFormat *writer = SubtitleFormat::GetWriter(filename);
|
||||||
|
if (!writer) return false;
|
||||||
|
|
||||||
|
// Scan through the lines
|
||||||
|
AssStyle defstyle;
|
||||||
|
AssStyle *curstyle;
|
||||||
|
AssDialogue *curdiag;
|
||||||
|
for (entryIter cur=Line.begin();cur!=Line.end();cur++) {
|
||||||
|
// Check style, if anything non-default is found, return false
|
||||||
|
curstyle = AssEntry::GetAsStyle(*cur);
|
||||||
|
if (curstyle) {
|
||||||
|
if (curstyle->GetEntryData() != defstyle.GetEntryData()) return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check dialog
|
||||||
|
curdiag = AssEntry::GetAsDialogue(*cur);
|
||||||
|
if (curdiag) {
|
||||||
|
curdiag->ParseASSTags();
|
||||||
|
for (size_t i=0;i<curdiag->Blocks.size();i++) {
|
||||||
|
if (curdiag->Blocks[i]->type != BLOCK_PLAIN) return false;
|
||||||
|
}
|
||||||
|
curdiag->ClearBlocks();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Success
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////
|
////////////////////////////////////
|
||||||
// Returns script as a single string
|
// Returns script as a single string
|
||||||
wxString AssFile::GetString() {
|
wxString AssFile::GetString() {
|
||||||
|
@ -280,7 +315,6 @@ void AssFile::Clear () {
|
||||||
}
|
}
|
||||||
Line.clear();
|
Line.clear();
|
||||||
|
|
||||||
IsASS = false;
|
|
||||||
loaded = false;
|
loaded = false;
|
||||||
filename = _T("");
|
filename = _T("");
|
||||||
Modified = false;
|
Modified = false;
|
||||||
|
@ -315,7 +349,6 @@ void AssFile::LoadDefault (bool defline) {
|
||||||
}
|
}
|
||||||
|
|
||||||
loaded = true;
|
loaded = true;
|
||||||
IsASS = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -326,7 +359,6 @@ AssFile::AssFile (AssFile &from) {
|
||||||
|
|
||||||
// Copy standard variables
|
// Copy standard variables
|
||||||
filename = from.filename;
|
filename = from.filename;
|
||||||
IsASS = from.IsASS;
|
|
||||||
loaded = from.loaded;
|
loaded = from.loaded;
|
||||||
Modified = from.Modified;
|
Modified = from.Modified;
|
||||||
bool IsSSA = false;
|
bool IsSSA = false;
|
||||||
|
|
|
@ -72,7 +72,6 @@ public:
|
||||||
|
|
||||||
wxString filename;
|
wxString filename;
|
||||||
bool loaded;
|
bool loaded;
|
||||||
bool IsASS;
|
|
||||||
|
|
||||||
AssFile();
|
AssFile();
|
||||||
AssFile(AssFile &from);
|
AssFile(AssFile &from);
|
||||||
|
@ -92,6 +91,7 @@ public:
|
||||||
void Save(wxString file,bool setfilename=false,bool addToRecent=true,const wxString encoding=_T("")); // Save to a file. Pass true to second argument if this isn't a copy
|
void Save(wxString file,bool setfilename=false,bool addToRecent=true,const wxString encoding=_T("")); // Save to a file. Pass true to second argument if this isn't a copy
|
||||||
void Export(wxString file); // Saves exported copy, with effects applied
|
void Export(wxString file); // Saves exported copy, with effects applied
|
||||||
void AddToRecent(wxString file); // Adds file name to list of recently opened files
|
void AddToRecent(wxString file); // Adds file name to list of recently opened files
|
||||||
|
bool CanSave(); // Return true if the file can be saved in its current format
|
||||||
|
|
||||||
int GetScriptInfoAsInt(const wxString key);
|
int GetScriptInfoAsInt(const wxString key);
|
||||||
wxString GetScriptInfo(const wxString key); // Returns the value in a [Script Info] key.
|
wxString GetScriptInfo(const wxString key); // Returns the value in a [Script Info] key.
|
||||||
|
|
|
@ -85,6 +85,7 @@ Please visit http://aegisub.net to download latest version
|
||||||
- Text edit boxes in the subtitle editing area will now revert to unmodified if you restore the original text. (AMZ)
|
- Text edit boxes in the subtitle editing area will now revert to unmodified if you restore the original text. (AMZ)
|
||||||
- Re-arranged the controls in the subtitle editing area. (AMZ)
|
- Re-arranged the controls in the subtitle editing area. (AMZ)
|
||||||
- Right-clicking on the header of the subtitles grid will now bring up a popup menu that allows you to disable columns. (AMZ)
|
- Right-clicking on the header of the subtitles grid will now bring up a popup menu that allows you to disable columns. (AMZ)
|
||||||
|
- 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)
|
||||||
|
|
||||||
|
|
||||||
= 1.09 beta - 2006.01.16 ===========================
|
= 1.09 beta - 2006.01.16 ===========================
|
||||||
|
|
|
@ -561,7 +561,7 @@ void FrameMain::LoadSubtitles (wxString filename,wxString charset) {
|
||||||
bool FrameMain::SaveSubtitles(bool saveas,bool withCharset) {
|
bool FrameMain::SaveSubtitles(bool saveas,bool withCharset) {
|
||||||
// Try to get filename from file
|
// Try to get filename from file
|
||||||
wxString filename;
|
wxString filename;
|
||||||
if (saveas == false && AssFile::top->IsASS) filename = AssFile::top->filename;
|
if (saveas == false && AssFile::top->CanSave()) filename = AssFile::top->filename;
|
||||||
|
|
||||||
// Failed, ask user
|
// Failed, ask user
|
||||||
if (filename.IsEmpty()) {
|
if (filename.IsEmpty()) {
|
||||||
|
|
|
@ -1133,7 +1133,7 @@ void FrameMain::OnOpenStylingAssistant (wxCommandEvent &event) {
|
||||||
void FrameMain::OnAutoSave(wxTimerEvent &event) {
|
void FrameMain::OnAutoSave(wxTimerEvent &event) {
|
||||||
// Auto Save
|
// Auto Save
|
||||||
try {
|
try {
|
||||||
if (AssFile::top->loaded && AssFile::top->IsASS) {
|
if (AssFile::top->loaded && AssFile::top->CanSave()) {
|
||||||
// Set path
|
// Set path
|
||||||
wxFileName origfile(AssFile::top->filename);
|
wxFileName origfile(AssFile::top->filename);
|
||||||
wxString path = Options.AsText(_T("Auto save path"));
|
wxString path = Options.AsText(_T("Auto save path"));
|
||||||
|
|
|
@ -109,13 +109,6 @@ void SubtitleFormat::LoadDefault() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///////////////////
|
|
||||||
// Set if it's ASS
|
|
||||||
void SubtitleFormat::SetIsASS(bool isASS) {
|
|
||||||
assFile->IsASS = isASS;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
////////////
|
////////////
|
||||||
// Add line
|
// Add line
|
||||||
int SubtitleFormat::AddLine(wxString data,wxString group,int lasttime,bool &IsSSA) {
|
int SubtitleFormat::AddLine(wxString data,wxString group,int lasttime,bool &IsSSA) {
|
||||||
|
|
|
@ -69,7 +69,6 @@ protected:
|
||||||
|
|
||||||
void Clear();
|
void Clear();
|
||||||
void LoadDefault();
|
void LoadDefault();
|
||||||
void SetIsASS(bool isASS);
|
|
||||||
AssFile *GetAssFile() { return assFile; }
|
AssFile *GetAssFile() { return assFile; }
|
||||||
int AddLine(wxString data,wxString group,int lasttime,bool &IsSSA);
|
int AddLine(wxString data,wxString group,int lasttime,bool &IsSSA);
|
||||||
|
|
||||||
|
|
|
@ -88,9 +88,6 @@ void ASSSubtitleFormat::ReadFile(wxString filename,wxString encoding) {
|
||||||
throw wxString(_T("Error processing line: ")) + wxbuffer;
|
throw wxString(_T("Error processing line: ")) + wxbuffer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set ASS
|
|
||||||
SetIsASS(!IsSSA);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,6 @@ void TXTSubtitleFormat::ReadFile(wxString filename,wxString encoding) { using na
|
||||||
|
|
||||||
// Default
|
// Default
|
||||||
LoadDefault();
|
LoadDefault();
|
||||||
SetIsASS(false);
|
|
||||||
|
|
||||||
// Data
|
// Data
|
||||||
wxString actor;
|
wxString actor;
|
||||||
|
|
Loading…
Reference in a new issue