From d58fba3839c9f236fcbbf084c17fcb6c8aac20e7 Mon Sep 17 00:00:00 2001 From: Rodrigo Braz Monteiro Date: Sat, 6 Jan 2007 05:04:57 +0000 Subject: [PATCH] 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. --- aegisub/ass_file.cpp | 2 +- aegisub/audio_display.cpp | 4 ++-- aegisub/changelog.txt | 3 ++- aegisub/subtitle_format.cpp | 4 ++-- aegisub/subtitle_format.h | 2 +- aegisub/subtitle_format_srt.cpp | 15 ++++++++++++++- aegisub/subtitle_format_txt.cpp | 15 ++++++++++++++- 7 files changed, 36 insertions(+), 9 deletions(-) diff --git a/aegisub/ass_file.cpp b/aegisub/ass_file.cpp index 9293287df..f0569ebb0 100644 --- a/aegisub/ass_file.cpp +++ b/aegisub/ass_file.cpp @@ -417,7 +417,7 @@ void AssFile::LoadDefault (bool defline) { AddLine(_T("[Script Info]"),_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("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("PlayResY: 480"),_T("[Script Info]"),-1,IsSSA); AddLine(_T(""),_T("[Script Info]"),-1,IsSSA); diff --git a/aegisub/audio_display.cpp b/aegisub/audio_display.cpp index 4b06ca55e..d1c21688f 100644 --- a/aegisub/audio_display.cpp +++ b/aegisub/audio_display.cpp @@ -1526,7 +1526,7 @@ void AudioDisplay::OnMouseEvent(wxMouseEvent& event) { if (hold == 1 && buttonIsDown) { // Set new value if (x != selStart) { - selStart = GetBoundarySnap(x,10); + selStart = GetBoundarySnap(x,event.ShiftDown()?0:10); if (selStart > selEnd) { int temp = selStart; selStart = selEnd; @@ -1544,7 +1544,7 @@ void AudioDisplay::OnMouseEvent(wxMouseEvent& event) { if (hold == 2 && buttonIsDown) { // Set new value if (x != selEnd) { - selEnd = GetBoundarySnap(x,10); + selEnd = GetBoundarySnap(x,event.ShiftDown()?0:10); if (selStart > selEnd) { int temp = selStart; selStart = selEnd; diff --git a/aegisub/changelog.txt b/aegisub/changelog.txt index 6a4b775f9..d5d530e44 100644 --- a/aegisub/changelog.txt +++ b/aegisub/changelog.txt @@ -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 Next line on commit is now on by default. 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 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 =========================== diff --git a/aegisub/subtitle_format.cpp b/aegisub/subtitle_format.cpp index 1557cff0f..b3cc23979 100644 --- a/aegisub/subtitle_format.cpp +++ b/aegisub/subtitle_format.cpp @@ -108,8 +108,8 @@ void SubtitleFormat::Clear() { //////////////// // Load default -void SubtitleFormat::LoadDefault() { - assFile->LoadDefault(); +void SubtitleFormat::LoadDefault(bool defline) { + assFile->LoadDefault(defline); } diff --git a/aegisub/subtitle_format.h b/aegisub/subtitle_format.h index 84f2e2d7d..ef158cc8a 100644 --- a/aegisub/subtitle_format.h +++ b/aegisub/subtitle_format.h @@ -68,7 +68,7 @@ protected: void ClearCopy(); void Clear(); - void LoadDefault(); + void LoadDefault(bool defline=true); AssFile *GetAssFile() { return assFile; } int AddLine(wxString data,wxString group,int lasttime,bool &IsSSA,wxString *outgroup=NULL); diff --git a/aegisub/subtitle_format_srt.cpp b/aegisub/subtitle_format_srt.cpp index 876f34729..153c523ab 100644 --- a/aegisub/subtitle_format_srt.cpp +++ b/aegisub/subtitle_format_srt.cpp @@ -89,12 +89,13 @@ void SRTSubtitleFormat::ReadFile(wxString filename,wxString encoding) { TextFileReader file(filename,encoding); // Default - LoadDefault(); + LoadDefault(false); // Parse file int linen = 1; int fileLine = 0; int mode = 0; + int lines = 0; long templ; AssDialogue *line = NULL; while (file.HasMoreLines()) { @@ -145,6 +146,7 @@ void SRTSubtitleFormat::ReadFile(wxString filename,wxString encoding) { line->ParseSRTTags(); line->StartMS = line->Start.GetMS(); Line->push_back(line); + lines++; break; } // Append text @@ -153,6 +155,17 @@ void SRTSubtitleFormat::ReadFile(wxString filename,wxString encoding) { 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); + } } diff --git a/aegisub/subtitle_format_txt.cpp b/aegisub/subtitle_format_txt.cpp index d005977e3..0828a816d 100644 --- a/aegisub/subtitle_format_txt.cpp +++ b/aegisub/subtitle_format_txt.cpp @@ -89,13 +89,14 @@ void TXTSubtitleFormat::ReadFile(wxString filename,wxString encoding) { using na TextFileReader file(filename,encoding,false); // Default - LoadDefault(); + LoadDefault(false); // Data wxString actor; wxString separator = Options.AsText(_T("Text actor separator")); wxString comment = Options.AsText(_T("Text comment starter")); bool isComment = false; + int lines = 0; // Parse file AssDialogue *line = NULL; @@ -152,6 +153,18 @@ void TXTSubtitleFormat::ReadFile(wxString filename,wxString encoding) { using na // Adds 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); } }