From eb5e8ea8a19d3da4d44f7df732b71715f50e3379 Mon Sep 17 00:00:00 2001 From: Niels Martin Hansen Date: Fri, 18 Jul 2008 21:10:48 +0000 Subject: [PATCH] Corrections for TranStation export support. Format written was incorrect (a space placed on the wrong side of a bracket). Also added full support for alignments, and subtracting one frame from end times to avoid overlaps Originally committed to SVN as r2269. --- aegisub/subtitle_format_transtation.cpp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/aegisub/subtitle_format_transtation.cpp b/aegisub/subtitle_format_transtation.cpp index 76e6836ba..79170b475 100644 --- a/aegisub/subtitle_format_transtation.cpp +++ b/aegisub/subtitle_format_transtation.cpp @@ -41,6 +41,7 @@ #include "ass_style.h" #include "subtitle_format_transtation.h" #include "text_file_writer.h" +#include //////// @@ -90,16 +91,27 @@ void TranStationSubtitleFormat::WriteFile(wxString _filename,wxString encoding) if (current && !current->Comment) { // Get line data AssStyle *style = GetAssFile()->GetStyle(current->Style); - int align = 0; - wxString type = _T("N"); + int valign = 0; + wxChar *halign = _T("C"); + wxChar *type = _T("N"); if (style) { - if (style->alignment >= 4) align = 4; - if (style->alignment >= 7) align = 9; + if (style->alignment >= 4) valign = 4; + if (style->alignment >= 7) valign = 9; + if (style->alignment == 1 || style->alignment == 4 || style->alignment == 7) halign = _T("L"); + if (style->alignment == 3 || style->alignment == 6 || style->alignment == 9) halign = _T("R"); if (style->italic) type = _T("I"); } // Write header - wxString header = wxString::Format(_T("SUB [%i %s "),align,type.c_str()) + current->Start.GetSMPTE(fps) + _T(">") + current->End.GetSMPTE(fps) + _T("]"); + AssTime start = current->Start; + AssTime end = current->End; + // Subtract one frame duration from end time, since it is inclusive + // and we otherwise run the risk of having two lines overlap in a + // frame, when they should run right into each other. + printf("Before adjusting end: %d fps=%f to subtract=%d\n", end.GetMS(), fps, (int)(500.0/fps)); + end.SetMS(end.GetMS() - (int)(500.0/fps)); + printf("After adjusting end: %d\n", end.GetMS()); + wxString header = wxString::Format(_T("SUB[ %i%s%s "),valign,halign,type) + start.GetSMPTE(fps) + _T(">") + end.GetSMPTE(fps) + _T("]"); file.WriteLineToFile(header); // Process text