Treat comments inside {} as plain text so that typesetting doesn't mess with them

Originally committed to SVN as r1203.
This commit is contained in:
Dan Donovan 2007-06-03 01:54:39 +00:00
parent 50aab0f08f
commit c85d148076

View file

@ -148,21 +148,22 @@ bool AssDialogue::Parse(wxString rawData, int version) {
wxString temp; wxString temp;
// Get type // Get type
if (rawData.substr(pos,9) == _T("Dialogue:")) { if (rawData.StartsWith(_T("Dialogue:"))) {
Comment = false; Comment = false;
pos = 10; pos = 10;
} }
else if (rawData.substr(pos,8) == _T("Comment:")) { else if (rawData.StartsWith(_T("Comment:"))) {
Comment = true; Comment = true;
pos = 9; pos = 9;
} }
else return false; else return false;
wxStringTokenizer tkn(rawData.Mid(pos),_T(","),wxTOKEN_RET_EMPTY_ALL); wxStringTokenizer tkn(rawData.Mid(pos),_T(","),wxTOKEN_RET_EMPTY_ALL);
if (!tkn.HasMoreTokens()) return false;
// Get first token and see if it has "Marked=" in it // Get first token and see if it has "Marked=" in it
if (!tkn.HasMoreTokens()) return false;
temp = tkn.GetNextToken().Trim(false).Trim(true); temp = tkn.GetNextToken().Trim(false).Trim(true);
if (temp.Lower().Left(7) == _T("marked=")) version = 0; if (temp.Lower().StartsWith(_T("marked="))) version = 0;
else if (version == 0) version = 1; else if (version == 0) version = 1;
// Get layer number // Get layer number
@ -239,11 +240,10 @@ bool AssDialogue::Parse(wxString rawData, int version) {
#endif #endif
// Get text // Get text
Text = tkn.GetNextToken(); Text = rawData.Mid(pos+tkn.GetPosition());
while (tkn.HasMoreTokens()) {
Text += _T(",");
Text += tkn.GetNextToken();
}
return true; return true;
} }
@ -507,21 +507,34 @@ void AssDialogue::ParseASSTags () {
end = len; end = len;
} }
else work = Text.substr(cur,end-cur); else work = Text.substr(cur,end-cur);
work = Text.substr(cur+1,end-cur-1);
if (work.Find(_T("\\")) == wxNOT_FOUND) {
//We've found an override block with no backslashes
//We're going to assume it's a comment and not consider it an override block
//Currently we'll treat this as a plain text block, but feel free to create a new class
AssDialogueBlockPlain *block = new AssDialogueBlockPlain;
block->text = work;
Blocks.push_back(block);
// Create block }
AssDialogueBlockOverride *block = new AssDialogueBlockOverride;
block->parent = this;
block->text = work;
block->ParseTags();
Blocks.push_back(block);
// Look for \p in block else {
std::vector<AssOverrideTag*>::iterator curTag; work = Text.substr(cur+1,end-cur-1);
for (curTag = block->Tags.begin();curTag != block->Tags.end();curTag++) {
AssOverrideTag *tag = *curTag; // Create block
if (tag->Name == _T("\\p")) { AssDialogueBlockOverride *block = new AssDialogueBlockOverride;
drawingLevel = tag->Params.at(0)->AsInt(); block->parent = this;
block->text = work;
block->ParseTags();
Blocks.push_back(block);
// Look for \p in block
std::vector<AssOverrideTag*>::iterator curTag;
for (curTag = block->Tags.begin();curTag != block->Tags.end();curTag++) {
AssOverrideTag *tag = *curTag;
if (tag->Name == _T("\\p")) {
drawingLevel = tag->Params.at(0)->AsInt();
}
} }
} }