Fixed loading of SRT and TXT files, which were causing an empty line to appear at the start of the file. Also changed default WarpStyle to 0, instead of 1.

Originally committed to SVN as r723.
This commit is contained in:
Rodrigo Braz Monteiro 2007-01-06 05:04:57 +00:00
parent 1d647a9b09
commit d58fba3839
7 changed files with 36 additions and 9 deletions

View file

@ -417,7 +417,7 @@ void AssFile::LoadDefault (bool defline) {
AddLine(_T("[Script Info]"),_T("[Script Info]"),-1,IsSSA); AddLine(_T("[Script Info]"),_T("[Script Info]"),-1,IsSSA);
AddLine(_T("Title: Default Aegisub file"),_T("[Script Info]"),-1,IsSSA); AddLine(_T("Title: Default Aegisub file"),_T("[Script Info]"),-1,IsSSA);
AddLine(_T("ScriptType: v4.00+"),_T("[Script Info]"),-1,IsSSA); AddLine(_T("ScriptType: v4.00+"),_T("[Script Info]"),-1,IsSSA);
AddLine(_T("WrapStyle: 1"), _T("[Script Info]"),-1,IsSSA); AddLine(_T("WrapStyle: 0"), _T("[Script Info]"),-1,IsSSA);
AddLine(_T("PlayResX: 640"),_T("[Script Info]"),-1,IsSSA); AddLine(_T("PlayResX: 640"),_T("[Script Info]"),-1,IsSSA);
AddLine(_T("PlayResY: 480"),_T("[Script Info]"),-1,IsSSA); AddLine(_T("PlayResY: 480"),_T("[Script Info]"),-1,IsSSA);
AddLine(_T(""),_T("[Script Info]"),-1,IsSSA); AddLine(_T(""),_T("[Script Info]"),-1,IsSSA);

View file

@ -1526,7 +1526,7 @@ void AudioDisplay::OnMouseEvent(wxMouseEvent& event) {
if (hold == 1 && buttonIsDown) { if (hold == 1 && buttonIsDown) {
// Set new value // Set new value
if (x != selStart) { if (x != selStart) {
selStart = GetBoundarySnap(x,10); selStart = GetBoundarySnap(x,event.ShiftDown()?0:10);
if (selStart > selEnd) { if (selStart > selEnd) {
int temp = selStart; int temp = selStart;
selStart = selEnd; selStart = selEnd;
@ -1544,7 +1544,7 @@ void AudioDisplay::OnMouseEvent(wxMouseEvent& event) {
if (hold == 2 && buttonIsDown) { if (hold == 2 && buttonIsDown) {
// Set new value // Set new value
if (x != selEnd) { if (x != selEnd) {
selEnd = GetBoundarySnap(x,10); selEnd = GetBoundarySnap(x,event.ShiftDown()?0:10);
if (selStart > selEnd) { if (selStart > selEnd) {
int temp = selStart; int temp = selStart;
selStart = selEnd; selStart = selEnd;

View file

@ -70,9 +70,10 @@ Please visit http://aegisub.net to download latest version
o Normal and SSA mode have been merged into one, all functionality available to both is now used at once. This is the same behavior as Sabbu has. (AMZ) o Normal and SSA mode have been merged into one, all functionality available to both is now used at once. This is the same behavior as Sabbu has. (AMZ)
o Next line on commit is now on by default. o Next line on commit is now on by default.
o Auto-commit will never change to the next line. o Auto-commit will never change to the next line.
o When dragging line start/end markers, they will snap to keyframes or nearby subtitle start/end markers. o When dragging line start/end markers, they will snap to keyframes or nearby subtitle start/end markers, hold down "Shift" to override this behaviour.
o The "Play" shortcut will always play, regardless of whether it was already playing or not. There is a new shortcut for "Stop". o The "Play" shortcut will always play, regardless of whether it was already playing or not. There is a new shortcut for "Stop".
o Styles for line start/end markers have changed. o Styles for line start/end markers have changed.
- Fixed loading of SRT and TXT files, which were causing an empty line to appear at the start of the file. (AMZ)
= 1.10 beta - 2006.08.07 =========================== = 1.10 beta - 2006.08.07 ===========================

View file

@ -108,8 +108,8 @@ void SubtitleFormat::Clear() {
//////////////// ////////////////
// Load default // Load default
void SubtitleFormat::LoadDefault() { void SubtitleFormat::LoadDefault(bool defline) {
assFile->LoadDefault(); assFile->LoadDefault(defline);
} }

View file

@ -68,7 +68,7 @@ protected:
void ClearCopy(); void ClearCopy();
void Clear(); void Clear();
void LoadDefault(); void LoadDefault(bool defline=true);
AssFile *GetAssFile() { return assFile; } AssFile *GetAssFile() { return assFile; }
int AddLine(wxString data,wxString group,int lasttime,bool &IsSSA,wxString *outgroup=NULL); int AddLine(wxString data,wxString group,int lasttime,bool &IsSSA,wxString *outgroup=NULL);

View file

@ -89,12 +89,13 @@ void SRTSubtitleFormat::ReadFile(wxString filename,wxString encoding) {
TextFileReader file(filename,encoding); TextFileReader file(filename,encoding);
// Default // Default
LoadDefault(); LoadDefault(false);
// Parse file // Parse file
int linen = 1; int linen = 1;
int fileLine = 0; int fileLine = 0;
int mode = 0; int mode = 0;
int lines = 0;
long templ; long templ;
AssDialogue *line = NULL; AssDialogue *line = NULL;
while (file.HasMoreLines()) { while (file.HasMoreLines()) {
@ -145,6 +146,7 @@ void SRTSubtitleFormat::ReadFile(wxString filename,wxString encoding) {
line->ParseSRTTags(); line->ParseSRTTags();
line->StartMS = line->Start.GetMS(); line->StartMS = line->Start.GetMS();
Line->push_back(line); Line->push_back(line);
lines++;
break; break;
} }
// Append text // Append text
@ -153,6 +155,17 @@ void SRTSubtitleFormat::ReadFile(wxString filename,wxString encoding) {
break; break;
} }
} }
// No lines?
if (lines == 0) {
AssDialogue *line = new AssDialogue();
line->group = _T("[Events]");
line->Style = _T("Default");
line->StartMS = 0;
line->Start.SetMS(0);
line->End.SetMS(5000);
Line->push_back(line);
}
} }

View file

@ -89,13 +89,14 @@ void TXTSubtitleFormat::ReadFile(wxString filename,wxString encoding) { using na
TextFileReader file(filename,encoding,false); TextFileReader file(filename,encoding,false);
// Default // Default
LoadDefault(); LoadDefault(false);
// Data // Data
wxString actor; wxString actor;
wxString separator = Options.AsText(_T("Text actor separator")); wxString separator = Options.AsText(_T("Text actor separator"));
wxString comment = Options.AsText(_T("Text comment starter")); wxString comment = Options.AsText(_T("Text comment starter"));
bool isComment = false; bool isComment = false;
int lines = 0;
// Parse file // Parse file
AssDialogue *line = NULL; AssDialogue *line = NULL;
@ -152,6 +153,18 @@ void TXTSubtitleFormat::ReadFile(wxString filename,wxString encoding) { using na
// Adds line // Adds line
Line->push_back(line); Line->push_back(line);
lines++;
}
// No lines?
if (lines == 0) {
AssDialogue *line = new AssDialogue();
line->group = _T("[Events]");
line->Style = _T("Default");
line->StartMS = 0;
line->Start.SetMS(0);
line->End.SetMS(5000);
Line->push_back(line);
} }
} }