mirror of https://github.com/odrling/Aegisub
Working TTXT export, aside from the incomplete header
Originally committed to SVN as r1256.
This commit is contained in:
parent
14195cc2bb
commit
b96f4ba5d0
|
@ -136,7 +136,8 @@ wxString AssTime::GetASSFormated (bool msPrecision) {
|
||||||
int _ms = time;
|
int _ms = time;
|
||||||
|
|
||||||
// Centisecond precision
|
// Centisecond precision
|
||||||
if (!UseMSPrecision && !msPrecision) _ms = _ms/10*10;
|
msPrecision = msPrecision || UseMSPrecision;
|
||||||
|
if (!msPrecision) _ms = _ms/10*10;
|
||||||
|
|
||||||
// Reset
|
// Reset
|
||||||
h = m = s = ms = 0;
|
h = m = s = ms = 0;
|
||||||
|
@ -169,7 +170,7 @@ wxString AssTime::GetASSFormated (bool msPrecision) {
|
||||||
}
|
}
|
||||||
ms = _ms;
|
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);
|
else return wxString::Format(_T("%01i:%02i:%02i.%02i"),h,m,s,ms/10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -213,14 +213,13 @@ void TTXTSubtitleFormat::WriteFile(wxString filename,wxString encoding) {
|
||||||
wxXmlNode *root = new wxXmlNode(NULL,wxXML_ELEMENT_NODE,_T("TextStream"));
|
wxXmlNode *root = new wxXmlNode(NULL,wxXML_ELEMENT_NODE,_T("TextStream"));
|
||||||
root->AddProperty(_T("version"),_T("1.1"));
|
root->AddProperty(_T("version"),_T("1.1"));
|
||||||
doc.SetRoot(root);
|
doc.SetRoot(root);
|
||||||
wxXmlNode *node,*prevNode;
|
wxXmlNode *node,*subNode;
|
||||||
|
|
||||||
// Create header
|
// 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("width"),_T("400"));
|
||||||
node->AddProperty(_T("height"),_T("60"));
|
node->AddProperty(_T("height"),_T("60"));
|
||||||
root->AddChild(node);
|
root->AddChild(node);
|
||||||
prevNode = node;
|
|
||||||
|
|
||||||
// Create lines
|
// Create lines
|
||||||
int i=1;
|
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 it doesn't start at the end of previous, add blank
|
||||||
if (prev && prev->End != current->Start) {
|
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("startTime"),_T("0") + prev->End.GetASSFormated(true));
|
||||||
node->AddProperty(_T("xml:space"),_T("preserve"));
|
node->AddProperty(_T("xml:space"),_T("preserve"));
|
||||||
node->SetContent(_T(""));
|
subNode = new wxXmlNode(wxXML_TEXT_NODE,_T(""),_T(""));
|
||||||
node->SetNext(prevNode);
|
node->AddChild(subNode);
|
||||||
prevNode = node;
|
root->AddChild(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate and insert node
|
// Generate and insert node
|
||||||
node = new wxXmlNode(root,wxXML_ELEMENT_NODE,_T("TextSample"));
|
node = new wxXmlNode(wxXML_ELEMENT_NODE,_T("TextSample"));
|
||||||
node->AddProperty(_T("startTime"),_T("0") + current->Start.GetASSFormated(true));
|
node->AddProperty(_T("sampleTime"),_T("0") + current->Start.GetASSFormated(true));
|
||||||
node->AddProperty(_T("xml:space"),_T("preserve"));
|
node->AddProperty(_T("xml:space"),_T("preserve"));
|
||||||
node->SetContent(current->Text);
|
subNode = new wxXmlNode(wxXML_TEXT_NODE,_T(""),current->Text);
|
||||||
node->SetNext(prevNode);
|
node->AddChild(subNode);
|
||||||
prevNode = node;
|
root->AddChild(node);
|
||||||
|
|
||||||
// Set as previous
|
// Set as previous
|
||||||
prev = current;
|
prev = current;
|
||||||
|
|
Loading…
Reference in New Issue