mirror of https://github.com/odrling/Aegisub
Fixed #630 (resample and \clip tags) and cleaned up some of the ASS tag structure.
Originally committed to SVN as r1710.
This commit is contained in:
parent
400e37c2cd
commit
91986412b9
|
@ -561,7 +561,7 @@ void AssDialogue::StripTag (wxString tagName) {
|
||||||
|
|
||||||
// Look for blocks
|
// Look for blocks
|
||||||
for (vector<AssDialogueBlock*>::iterator cur=Blocks.begin();cur!=Blocks.end();cur++) {
|
for (vector<AssDialogueBlock*>::iterator cur=Blocks.begin();cur!=Blocks.end();cur++) {
|
||||||
if ((*cur)->type == BLOCK_OVERRIDE) {
|
if ((*cur)->GetType() == BLOCK_OVERRIDE) {
|
||||||
AssDialogueBlockOverride *over = AssDialogueBlock::GetAsOverride(*cur);
|
AssDialogueBlockOverride *over = AssDialogueBlock::GetAsOverride(*cur);
|
||||||
wxString temp;
|
wxString temp;
|
||||||
for (size_t i=0;i<over->Tags.size();i++) {
|
for (size_t i=0;i<over->Tags.size();i++) {
|
||||||
|
@ -682,7 +682,7 @@ void AssDialogue::UpdateText () {
|
||||||
using std::vector;
|
using std::vector;
|
||||||
Text = _T("");
|
Text = _T("");
|
||||||
for (vector<AssDialogueBlock*>::iterator cur=Blocks.begin();cur!=Blocks.end();cur++) {
|
for (vector<AssDialogueBlock*>::iterator cur=Blocks.begin();cur!=Blocks.end();cur++) {
|
||||||
if ((*cur)->type == BLOCK_OVERRIDE) {
|
if ((*cur)->GetType() == BLOCK_OVERRIDE) {
|
||||||
Text += _T("{");
|
Text += _T("{");
|
||||||
Text += (*cur)->GetText();
|
Text += (*cur)->GetText();
|
||||||
Text += _T("}");
|
Text += _T("}");
|
||||||
|
@ -737,7 +737,7 @@ void AssDialogue::ProcessParameters(void (*callback)(wxString tagName,int par_n,
|
||||||
AssDialogueBlockOverride *curBlock;
|
AssDialogueBlockOverride *curBlock;
|
||||||
//ParseASSTags();
|
//ParseASSTags();
|
||||||
for (std::vector<AssDialogueBlock*>::iterator cur=Blocks.begin();cur!=Blocks.end();cur++) {
|
for (std::vector<AssDialogueBlock*>::iterator cur=Blocks.begin();cur!=Blocks.end();cur++) {
|
||||||
if ((*cur)->type == BLOCK_OVERRIDE) {
|
if ((*cur)->GetType() == BLOCK_OVERRIDE) {
|
||||||
curBlock = static_cast<AssDialogueBlockOverride*> (*cur);
|
curBlock = static_cast<AssDialogueBlockOverride*> (*cur);
|
||||||
curBlock->ProcessParameters(callback,userData);
|
curBlock->ProcessParameters(callback,userData);
|
||||||
}
|
}
|
||||||
|
@ -802,7 +802,6 @@ AssEntry *AssDialogue::Clone() {
|
||||||
///////////////
|
///////////////
|
||||||
// Constructor
|
// Constructor
|
||||||
AssDialogueBlock::AssDialogueBlock () {
|
AssDialogueBlock::AssDialogueBlock () {
|
||||||
type = BLOCK_BASE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -818,7 +817,7 @@ AssDialogueBlock::~AssDialogueBlock () {
|
||||||
// If it isn't a plain block, returns NULL
|
// If it isn't a plain block, returns NULL
|
||||||
AssDialogueBlockPlain *AssDialogueBlock::GetAsPlain(AssDialogueBlock *base) {
|
AssDialogueBlockPlain *AssDialogueBlock::GetAsPlain(AssDialogueBlock *base) {
|
||||||
if (!base) return NULL;
|
if (!base) return NULL;
|
||||||
if (base->type == BLOCK_PLAIN) {
|
if (base->GetType() == BLOCK_PLAIN) {
|
||||||
return static_cast<AssDialogueBlockPlain*> (base);
|
return static_cast<AssDialogueBlockPlain*> (base);
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -831,7 +830,7 @@ AssDialogueBlockPlain *AssDialogueBlock::GetAsPlain(AssDialogueBlock *base) {
|
||||||
// If it isn't an override block, returns NULL
|
// If it isn't an override block, returns NULL
|
||||||
AssDialogueBlockOverride *AssDialogueBlock::GetAsOverride(AssDialogueBlock *base) {
|
AssDialogueBlockOverride *AssDialogueBlock::GetAsOverride(AssDialogueBlock *base) {
|
||||||
if (!base) return NULL;
|
if (!base) return NULL;
|
||||||
if (base->type == BLOCK_OVERRIDE) {
|
if (base->GetType() == BLOCK_OVERRIDE) {
|
||||||
return static_cast<AssDialogueBlockOverride*> (base);
|
return static_cast<AssDialogueBlockOverride*> (base);
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -844,7 +843,7 @@ AssDialogueBlockOverride *AssDialogueBlock::GetAsOverride(AssDialogueBlock *base
|
||||||
// If it isn't an drawing block, returns NULL
|
// If it isn't an drawing block, returns NULL
|
||||||
AssDialogueBlockDrawing *AssDialogueBlock::GetAsDrawing(AssDialogueBlock *base) {
|
AssDialogueBlockDrawing *AssDialogueBlock::GetAsDrawing(AssDialogueBlock *base) {
|
||||||
if (!base) return NULL;
|
if (!base) return NULL;
|
||||||
if (base->type == BLOCK_DRAWING) {
|
if (base->GetType() == BLOCK_DRAWING) {
|
||||||
return static_cast<AssDialogueBlockDrawing*> (base);
|
return static_cast<AssDialogueBlockDrawing*> (base);
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -855,14 +854,6 @@ AssDialogueBlockDrawing *AssDialogueBlock::GetAsDrawing(AssDialogueBlock *base)
|
||||||
///////////////
|
///////////////
|
||||||
// Constructor
|
// Constructor
|
||||||
AssDialogueBlockPlain::AssDialogueBlockPlain () {
|
AssDialogueBlockPlain::AssDialogueBlockPlain () {
|
||||||
type = BLOCK_PLAIN;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////
|
|
||||||
// Return the text
|
|
||||||
wxString AssDialogueBlockPlain::GetText() {
|
|
||||||
return text;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -870,14 +861,6 @@ wxString AssDialogueBlockPlain::GetText() {
|
||||||
///////////////
|
///////////////
|
||||||
// Constructor
|
// Constructor
|
||||||
AssDialogueBlockDrawing::AssDialogueBlockDrawing () {
|
AssDialogueBlockDrawing::AssDialogueBlockDrawing () {
|
||||||
type = BLOCK_DRAWING;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////
|
|
||||||
// Return the text
|
|
||||||
wxString AssDialogueBlockDrawing::GetText() {
|
|
||||||
return text;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -83,18 +83,16 @@ enum ASS_BlockType {
|
||||||
// The GetText() method generates a new value for the "text" field from
|
// The GetText() method generates a new value for the "text" field from
|
||||||
// the other fields in the specific class, and returns the new value.
|
// the other fields in the specific class, and returns the new value.
|
||||||
//
|
//
|
||||||
// TODO: Support for {\p#}...{\p0}
|
|
||||||
//
|
|
||||||
class AssDialogueBlock {
|
class AssDialogueBlock {
|
||||||
public:
|
public:
|
||||||
wxString text;
|
wxString text;
|
||||||
ASS_BlockType type;
|
|
||||||
AssDialogue *parent;
|
AssDialogue *parent;
|
||||||
|
|
||||||
AssDialogueBlock();
|
AssDialogueBlock();
|
||||||
virtual ~AssDialogueBlock();
|
virtual ~AssDialogueBlock();
|
||||||
|
|
||||||
virtual wxString GetText() = 0; // make the class abstract
|
virtual ASS_BlockType GetType() = 0;
|
||||||
|
virtual wxString GetText() { return text; }
|
||||||
static AssDialogueBlockPlain *GetAsPlain(AssDialogueBlock *base); // Returns a block base as a plain block if it is valid, null otherwise
|
static AssDialogueBlockPlain *GetAsPlain(AssDialogueBlock *base); // Returns a block base as a plain block if it is valid, null otherwise
|
||||||
static AssDialogueBlockOverride *GetAsOverride(AssDialogueBlock *base); // Returns a block base as an override block if it is valid, null otherwise
|
static AssDialogueBlockOverride *GetAsOverride(AssDialogueBlock *base); // Returns a block base as an override block if it is valid, null otherwise
|
||||||
static AssDialogueBlockDrawing *GetAsDrawing(AssDialogueBlock *base); // Returns a block base as a drawing block if it is valid, null otherwise
|
static AssDialogueBlockDrawing *GetAsDrawing(AssDialogueBlock *base); // Returns a block base as a drawing block if it is valid, null otherwise
|
||||||
|
@ -109,8 +107,8 @@ public:
|
||||||
//
|
//
|
||||||
class AssDialogueBlockPlain : public AssDialogueBlock {
|
class AssDialogueBlockPlain : public AssDialogueBlock {
|
||||||
public:
|
public:
|
||||||
|
ASS_BlockType GetType() { return BLOCK_PLAIN; }
|
||||||
AssDialogueBlockPlain();
|
AssDialogueBlockPlain();
|
||||||
wxString GetText();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -124,9 +122,9 @@ class AssDialogueBlockDrawing : public AssDialogueBlock {
|
||||||
public:
|
public:
|
||||||
int Scale;
|
int Scale;
|
||||||
|
|
||||||
|
ASS_BlockType GetType() { return BLOCK_DRAWING; }
|
||||||
AssDialogueBlockDrawing();
|
AssDialogueBlockDrawing();
|
||||||
void TransformCoords(int trans_x,int trans_y,double mult_x,double mult_y);
|
void TransformCoords(int trans_x,int trans_y,double mult_x,double mult_y);
|
||||||
wxString GetText();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -142,6 +140,7 @@ public:
|
||||||
~AssDialogueBlockOverride();
|
~AssDialogueBlockOverride();
|
||||||
std::vector<AssOverrideTag*> Tags;
|
std::vector<AssOverrideTag*> Tags;
|
||||||
|
|
||||||
|
ASS_BlockType GetType() { return BLOCK_OVERRIDE; }
|
||||||
wxString GetText();
|
wxString GetText();
|
||||||
void ParseTags(); // Parses tags
|
void ParseTags(); // Parses tags
|
||||||
void ProcessParameters(void (*callback)(wxString,int,AssOverrideParameter*,void *),void *userData);
|
void ProcessParameters(void (*callback)(wxString,int,AssOverrideParameter*,void *),void *userData);
|
||||||
|
|
|
@ -264,7 +264,7 @@ bool AssFile::CanSave() {
|
||||||
if (curdiag) {
|
if (curdiag) {
|
||||||
curdiag->ParseASSTags();
|
curdiag->ParseASSTags();
|
||||||
for (size_t i=0;i<curdiag->Blocks.size();i++) {
|
for (size_t i=0;i<curdiag->Blocks.size();i++) {
|
||||||
if (curdiag->Blocks[i]->type != BLOCK_PLAIN) return false;
|
if (curdiag->Blocks[i]->GetType() != BLOCK_PLAIN) return false;
|
||||||
}
|
}
|
||||||
curdiag->ClearBlocks();
|
curdiag->ClearBlocks();
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,10 +56,9 @@ void ParseAssKaraokeTags(AssDialogue *line, AssKaraokeVector &syls)
|
||||||
for (int i = 0; i < (int)line->Blocks.size(); i++) {
|
for (int i = 0; i < (int)line->Blocks.size(); i++) {
|
||||||
AssDialogueBlock *block = line->Blocks[i];
|
AssDialogueBlock *block = line->Blocks[i];
|
||||||
|
|
||||||
switch (block->type) {
|
switch (block->GetType()) {
|
||||||
|
|
||||||
case BLOCK_BASE:
|
case BLOCK_BASE:
|
||||||
assert(block->type != BLOCK_BASE);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BLOCK_PLAIN:
|
case BLOCK_PLAIN:
|
||||||
|
|
|
@ -83,7 +83,6 @@ void AssOverrideParameter::operator= (const AssOverrideParameter ¶m) {
|
||||||
///////////////
|
///////////////
|
||||||
// Constructor
|
// Constructor
|
||||||
AssDialogueBlockOverride::AssDialogueBlockOverride () {
|
AssDialogueBlockOverride::AssDialogueBlockOverride () {
|
||||||
type = BLOCK_OVERRIDE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -773,10 +773,9 @@ namespace Automation4 {
|
||||||
for (int i = 0; i < (int)dia->Blocks.size(); i++) {
|
for (int i = 0; i < (int)dia->Blocks.size(); i++) {
|
||||||
AssDialogueBlock *block = dia->Blocks[i];
|
AssDialogueBlock *block = dia->Blocks[i];
|
||||||
|
|
||||||
switch (block->type) {
|
switch (block->GetType()) {
|
||||||
|
|
||||||
case BLOCK_BASE:
|
case BLOCK_BASE:
|
||||||
assert(block->type != BLOCK_BASE);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BLOCK_PLAIN:
|
case BLOCK_PLAIN:
|
||||||
|
|
|
@ -167,6 +167,16 @@ void DialogResample::DoResampleTags (wxString name,int n,AssOverrideParameter *c
|
||||||
|
|
||||||
case PARCLASS_RELATIVE_SIZE_Y:
|
case PARCLASS_RELATIVE_SIZE_Y:
|
||||||
//resizer = ry;
|
//resizer = ry;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PARCLASS_DRAWING:
|
||||||
|
{
|
||||||
|
AssDialogueBlockDrawing block;
|
||||||
|
block.text = curParam->AsText();
|
||||||
|
block.TransformCoords(m[0],m[2],rx,ry);
|
||||||
|
curParam->SetText(block.GetText());
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -163,7 +163,7 @@ bool DialogTranslation::JumpToLine(int n,int block) {
|
||||||
current->ParseASSTags();
|
current->ParseASSTags();
|
||||||
size_t size_blocks = current->Blocks.size();
|
size_t size_blocks = current->Blocks.size();
|
||||||
for (size_t i=0;i<size_blocks;i++) {
|
for (size_t i=0;i<size_blocks;i++) {
|
||||||
if (current->Blocks.at(i)->type == BLOCK_PLAIN) nblocks++;
|
if (current->Blocks.at(i)->GetType() == BLOCK_PLAIN) nblocks++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wrap around
|
// Wrap around
|
||||||
|
@ -200,7 +200,7 @@ bool DialogTranslation::JumpToLine(int n,int block) {
|
||||||
int pos=-1;
|
int pos=-1;
|
||||||
for (vector<AssDialogueBlock*>::iterator cur=current->Blocks.begin();cur!=current->Blocks.end();cur++) {
|
for (vector<AssDialogueBlock*>::iterator cur=current->Blocks.begin();cur!=current->Blocks.end();cur++) {
|
||||||
curBlock = *cur;
|
curBlock = *cur;
|
||||||
if (curBlock->type == BLOCK_PLAIN) {
|
if (curBlock->GetType() == BLOCK_PLAIN) {
|
||||||
pos++;
|
pos++;
|
||||||
int curLen = OrigText->GetUnicodePosition(OrigText->GetLength());
|
int curLen = OrigText->GetUnicodePosition(OrigText->GetLength());
|
||||||
OrigText->AppendText(curBlock->text);
|
OrigText->AppendText(curBlock->text);
|
||||||
|
@ -210,7 +210,7 @@ bool DialogTranslation::JumpToLine(int n,int block) {
|
||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (curBlock->type == BLOCK_OVERRIDE) OrigText->AppendText(_T("{") + curBlock->text + _T("}"));
|
else if (curBlock->GetType() == BLOCK_OVERRIDE) OrigText->AppendText(_T("{") + curBlock->text + _T("}"));
|
||||||
}
|
}
|
||||||
current->ClearBlocks();
|
current->ClearBlocks();
|
||||||
OrigText->SetReadOnly(true);
|
OrigText->SetReadOnly(true);
|
||||||
|
@ -312,7 +312,7 @@ void DialogTranslation::OnTransBoxKey(wxKeyEvent &event) {
|
||||||
cur->ParseASSTags();
|
cur->ParseASSTags();
|
||||||
int nblock = -1;
|
int nblock = -1;
|
||||||
for (unsigned int i=0;i<cur->Blocks.size();i++) {
|
for (unsigned int i=0;i<cur->Blocks.size();i++) {
|
||||||
if (cur->Blocks.at(i)->type == BLOCK_PLAIN) nblock++;
|
if (cur->Blocks.at(i)->GetType() == BLOCK_PLAIN) nblock++;
|
||||||
if (nblock == curblock) {
|
if (nblock == curblock) {
|
||||||
cur->Blocks.at(i)->text = TransText->GetValue();
|
cur->Blocks.at(i)->text = TransText->GetValue();
|
||||||
break;
|
break;
|
||||||
|
@ -346,7 +346,7 @@ void DialogTranslation::OnTransBoxKey(wxKeyEvent &event) {
|
||||||
current->ParseASSTags();
|
current->ParseASSTags();
|
||||||
for (vector<AssDialogueBlock*>::iterator cur=current->Blocks.begin();cur!=current->Blocks.end();cur++) {
|
for (vector<AssDialogueBlock*>::iterator cur=current->Blocks.begin();cur!=current->Blocks.end();cur++) {
|
||||||
curBlock = *cur;
|
curBlock = *cur;
|
||||||
if (curBlock->type == BLOCK_PLAIN) {
|
if (curBlock->GetType() == BLOCK_PLAIN) {
|
||||||
pos++;
|
pos++;
|
||||||
if (pos == curblock) {
|
if (pos == curblock) {
|
||||||
TransText->AddText(curBlock->text);
|
TransText->AddText(curBlock->text);
|
||||||
|
|
|
@ -1313,7 +1313,7 @@ void SubtitlesGrid::SplitLineByKaraoke(int lineNumber) {
|
||||||
// copying lost of code from automation.cpp here
|
// copying lost of code from automation.cpp here
|
||||||
// maybe it should be refactored, since a similar proc is also needed in audio_karaoke ?
|
// maybe it should be refactored, since a similar proc is also needed in audio_karaoke ?
|
||||||
for (std::vector<AssDialogueBlock*>::iterator block = line->Blocks.begin(); block != line->Blocks.end(); block++) {
|
for (std::vector<AssDialogueBlock*>::iterator block = line->Blocks.begin(); block != line->Blocks.end(); block++) {
|
||||||
switch ((*block)->type) {
|
switch ((*block)->GetType()) {
|
||||||
case BLOCK_BASE:
|
case BLOCK_BASE:
|
||||||
throw wxString(_T("BLOCK_BASE found processing dialogue blocks. This should never happen."));
|
throw wxString(_T("BLOCK_BASE found processing dialogue blocks. This should never happen."));
|
||||||
|
|
||||||
|
|
|
@ -215,7 +215,7 @@ void TXTSubtitleFormat::WriteFile(wxString filename,wxString encoding) { using n
|
||||||
if (strip_formatting) {
|
if (strip_formatting) {
|
||||||
dia->ParseASSTags();
|
dia->ParseASSTags();
|
||||||
for (std::vector<AssDialogueBlock*>::iterator block = dia->Blocks.begin(); block != dia->Blocks.end(); ++block) {
|
for (std::vector<AssDialogueBlock*>::iterator block = dia->Blocks.begin(); block != dia->Blocks.end(); ++block) {
|
||||||
if ((*block)->type == BLOCK_PLAIN) {
|
if ((*block)->GetType() == BLOCK_PLAIN) {
|
||||||
out_text += (*block)->GetText();
|
out_text += (*block)->GetText();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue