From b96f4ba5d0f4b45038a96dbfd5a5e4540215874b Mon Sep 17 00:00:00 2001 From: Rodrigo Braz Monteiro Date: Tue, 19 Jun 2007 00:44:18 +0000 Subject: [PATCH] Working TTXT export, aside from the incomplete header Originally committed to SVN as r1256. --- aegisub/ass_time.cpp | 5 +++-- aegisub/subtitle_format_ttxt.cpp | 23 +++++++++++------------ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/aegisub/ass_time.cpp b/aegisub/ass_time.cpp index 06be9db01..bed7c0066 100644 --- a/aegisub/ass_time.cpp +++ b/aegisub/ass_time.cpp @@ -136,7 +136,8 @@ wxString AssTime::GetASSFormated (bool msPrecision) { int _ms = time; // Centisecond precision - if (!UseMSPrecision && !msPrecision) _ms = _ms/10*10; + msPrecision = msPrecision || UseMSPrecision; + if (!msPrecision) _ms = _ms/10*10; // Reset h = m = s = ms = 0; @@ -169,7 +170,7 @@ wxString AssTime::GetASSFormated (bool msPrecision) { } ms = _ms; - if (UseMSPrecision) return wxString::Format(_T("%01i:%02i:%02i.%03i"),h,m,s,ms); + if (msPrecision) return wxString::Format(_T("%01i:%02i:%02i.%03i"),h,m,s,ms); else return wxString::Format(_T("%01i:%02i:%02i.%02i"),h,m,s,ms/10); } diff --git a/aegisub/subtitle_format_ttxt.cpp b/aegisub/subtitle_format_ttxt.cpp index 984f33c81..842b77649 100644 --- a/aegisub/subtitle_format_ttxt.cpp +++ b/aegisub/subtitle_format_ttxt.cpp @@ -213,14 +213,13 @@ void TTXTSubtitleFormat::WriteFile(wxString filename,wxString encoding) { wxXmlNode *root = new wxXmlNode(NULL,wxXML_ELEMENT_NODE,_T("TextStream")); root->AddProperty(_T("version"),_T("1.1")); doc.SetRoot(root); - wxXmlNode *node,*prevNode; + wxXmlNode *node,*subNode; // Create header - node = new wxXmlNode(root,wxXML_ELEMENT_NODE,_T("TextStreamHeader")); + node = new wxXmlNode(wxXML_ELEMENT_NODE,_T("TextStreamHeader")); node->AddProperty(_T("width"),_T("400")); node->AddProperty(_T("height"),_T("60")); root->AddChild(node); - prevNode = node; // Create lines int i=1; @@ -234,21 +233,21 @@ void TTXTSubtitleFormat::WriteFile(wxString filename,wxString encoding) { // If it doesn't start at the end of previous, add blank if (prev && prev->End != current->Start) { - node = new wxXmlNode(root,wxXML_ELEMENT_NODE,_T("TextSample")); + node = new wxXmlNode(wxXML_ELEMENT_NODE,_T("TextSample")); node->AddProperty(_T("startTime"),_T("0") + prev->End.GetASSFormated(true)); node->AddProperty(_T("xml:space"),_T("preserve")); - node->SetContent(_T("")); - node->SetNext(prevNode); - prevNode = node; + subNode = new wxXmlNode(wxXML_TEXT_NODE,_T(""),_T("")); + node->AddChild(subNode); + root->AddChild(node); } // Generate and insert node - node = new wxXmlNode(root,wxXML_ELEMENT_NODE,_T("TextSample")); - node->AddProperty(_T("startTime"),_T("0") + current->Start.GetASSFormated(true)); + node = new wxXmlNode(wxXML_ELEMENT_NODE,_T("TextSample")); + node->AddProperty(_T("sampleTime"),_T("0") + current->Start.GetASSFormated(true)); node->AddProperty(_T("xml:space"),_T("preserve")); - node->SetContent(current->Text); - node->SetNext(prevNode); - prevNode = node; + subNode = new wxXmlNode(wxXML_TEXT_NODE,_T(""),current->Text); + node->AddChild(subNode); + root->AddChild(node); // Set as previous prev = current;