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
|
||||
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);
|
||||
wxString temp;
|
||||
for (size_t i=0;i<over->Tags.size();i++) {
|
||||
|
@ -682,7 +682,7 @@ void AssDialogue::UpdateText () {
|
|||
using std::vector;
|
||||
Text = _T("");
|
||||
for (vector<AssDialogueBlock*>::iterator cur=Blocks.begin();cur!=Blocks.end();cur++) {
|
||||
if ((*cur)->type == BLOCK_OVERRIDE) {
|
||||
if ((*cur)->GetType() == BLOCK_OVERRIDE) {
|
||||
Text += _T("{");
|
||||
Text += (*cur)->GetText();
|
||||
Text += _T("}");
|
||||
|
@ -737,7 +737,7 @@ void AssDialogue::ProcessParameters(void (*callback)(wxString tagName,int par_n,
|
|||
AssDialogueBlockOverride *curBlock;
|
||||
//ParseASSTags();
|
||||
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->ProcessParameters(callback,userData);
|
||||
}
|
||||
|
@ -802,7 +802,6 @@ AssEntry *AssDialogue::Clone() {
|
|||
///////////////
|
||||
// Constructor
|
||||
AssDialogueBlock::AssDialogueBlock () {
|
||||
type = BLOCK_BASE;
|
||||
}
|
||||
|
||||
|
||||
|
@ -818,7 +817,7 @@ AssDialogueBlock::~AssDialogueBlock () {
|
|||
// If it isn't a plain block, returns NULL
|
||||
AssDialogueBlockPlain *AssDialogueBlock::GetAsPlain(AssDialogueBlock *base) {
|
||||
if (!base) return NULL;
|
||||
if (base->type == BLOCK_PLAIN) {
|
||||
if (base->GetType() == BLOCK_PLAIN) {
|
||||
return static_cast<AssDialogueBlockPlain*> (base);
|
||||
}
|
||||
return NULL;
|
||||
|
@ -831,7 +830,7 @@ AssDialogueBlockPlain *AssDialogueBlock::GetAsPlain(AssDialogueBlock *base) {
|
|||
// If it isn't an override block, returns NULL
|
||||
AssDialogueBlockOverride *AssDialogueBlock::GetAsOverride(AssDialogueBlock *base) {
|
||||
if (!base) return NULL;
|
||||
if (base->type == BLOCK_OVERRIDE) {
|
||||
if (base->GetType() == BLOCK_OVERRIDE) {
|
||||
return static_cast<AssDialogueBlockOverride*> (base);
|
||||
}
|
||||
return NULL;
|
||||
|
@ -844,7 +843,7 @@ AssDialogueBlockOverride *AssDialogueBlock::GetAsOverride(AssDialogueBlock *base
|
|||
// If it isn't an drawing block, returns NULL
|
||||
AssDialogueBlockDrawing *AssDialogueBlock::GetAsDrawing(AssDialogueBlock *base) {
|
||||
if (!base) return NULL;
|
||||
if (base->type == BLOCK_DRAWING) {
|
||||
if (base->GetType() == BLOCK_DRAWING) {
|
||||
return static_cast<AssDialogueBlockDrawing*> (base);
|
||||
}
|
||||
return NULL;
|
||||
|
@ -855,14 +854,6 @@ AssDialogueBlockDrawing *AssDialogueBlock::GetAsDrawing(AssDialogueBlock *base)
|
|||
///////////////
|
||||
// Constructor
|
||||
AssDialogueBlockPlain::AssDialogueBlockPlain () {
|
||||
type = BLOCK_PLAIN;
|
||||
}
|
||||
|
||||
|
||||
///////////////////
|
||||
// Return the text
|
||||
wxString AssDialogueBlockPlain::GetText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
|
||||
|
@ -870,14 +861,6 @@ wxString AssDialogueBlockPlain::GetText() {
|
|||
///////////////
|
||||
// Constructor
|
||||
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 other fields in the specific class, and returns the new value.
|
||||
//
|
||||
// TODO: Support for {\p#}...{\p0}
|
||||
//
|
||||
class AssDialogueBlock {
|
||||
public:
|
||||
wxString text;
|
||||
ASS_BlockType type;
|
||||
AssDialogue *parent;
|
||||
|
||||
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 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
|
||||
|
@ -109,8 +107,8 @@ public:
|
|||
//
|
||||
class AssDialogueBlockPlain : public AssDialogueBlock {
|
||||
public:
|
||||
ASS_BlockType GetType() { return BLOCK_PLAIN; }
|
||||
AssDialogueBlockPlain();
|
||||
wxString GetText();
|
||||
};
|
||||
|
||||
|
||||
|
@ -124,9 +122,9 @@ class AssDialogueBlockDrawing : public AssDialogueBlock {
|
|||
public:
|
||||
int Scale;
|
||||
|
||||
ASS_BlockType GetType() { return BLOCK_DRAWING; }
|
||||
AssDialogueBlockDrawing();
|
||||
void TransformCoords(int trans_x,int trans_y,double mult_x,double mult_y);
|
||||
wxString GetText();
|
||||
};
|
||||
|
||||
|
||||
|
@ -142,6 +140,7 @@ public:
|
|||
~AssDialogueBlockOverride();
|
||||
std::vector<AssOverrideTag*> Tags;
|
||||
|
||||
ASS_BlockType GetType() { return BLOCK_OVERRIDE; }
|
||||
wxString GetText();
|
||||
void ParseTags(); // Parses tags
|
||||
void ProcessParameters(void (*callback)(wxString,int,AssOverrideParameter*,void *),void *userData);
|
||||
|
|
|
@ -264,7 +264,7 @@ bool AssFile::CanSave() {
|
|||
if (curdiag) {
|
||||
curdiag->ParseASSTags();
|
||||
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();
|
||||
}
|
||||
|
|
|
@ -56,10 +56,9 @@ void ParseAssKaraokeTags(AssDialogue *line, AssKaraokeVector &syls)
|
|||
for (int i = 0; i < (int)line->Blocks.size(); i++) {
|
||||
AssDialogueBlock *block = line->Blocks[i];
|
||||
|
||||
switch (block->type) {
|
||||
switch (block->GetType()) {
|
||||
|
||||
case BLOCK_BASE:
|
||||
assert(block->type != BLOCK_BASE);
|
||||
break;
|
||||
|
||||
case BLOCK_PLAIN:
|
||||
|
|
|
@ -83,7 +83,6 @@ void AssOverrideParameter::operator= (const AssOverrideParameter ¶m) {
|
|||
///////////////
|
||||
// Constructor
|
||||
AssDialogueBlockOverride::AssDialogueBlockOverride () {
|
||||
type = BLOCK_OVERRIDE;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -773,10 +773,9 @@ namespace Automation4 {
|
|||
for (int i = 0; i < (int)dia->Blocks.size(); i++) {
|
||||
AssDialogueBlock *block = dia->Blocks[i];
|
||||
|
||||
switch (block->type) {
|
||||
switch (block->GetType()) {
|
||||
|
||||
case BLOCK_BASE:
|
||||
assert(block->type != BLOCK_BASE);
|
||||
break;
|
||||
|
||||
case BLOCK_PLAIN:
|
||||
|
|
|
@ -167,6 +167,16 @@ void DialogResample::DoResampleTags (wxString name,int n,AssOverrideParameter *c
|
|||
|
||||
case PARCLASS_RELATIVE_SIZE_Y:
|
||||
//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:
|
||||
return;
|
||||
|
|
|
@ -163,7 +163,7 @@ bool DialogTranslation::JumpToLine(int n,int block) {
|
|||
current->ParseASSTags();
|
||||
size_t size_blocks = current->Blocks.size();
|
||||
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
|
||||
|
@ -200,7 +200,7 @@ bool DialogTranslation::JumpToLine(int n,int block) {
|
|||
int pos=-1;
|
||||
for (vector<AssDialogueBlock*>::iterator cur=current->Blocks.begin();cur!=current->Blocks.end();cur++) {
|
||||
curBlock = *cur;
|
||||
if (curBlock->type == BLOCK_PLAIN) {
|
||||
if (curBlock->GetType() == BLOCK_PLAIN) {
|
||||
pos++;
|
||||
int curLen = OrigText->GetUnicodePosition(OrigText->GetLength());
|
||||
OrigText->AppendText(curBlock->text);
|
||||
|
@ -210,7 +210,7 @@ bool DialogTranslation::JumpToLine(int n,int block) {
|
|||
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();
|
||||
OrigText->SetReadOnly(true);
|
||||
|
@ -312,7 +312,7 @@ void DialogTranslation::OnTransBoxKey(wxKeyEvent &event) {
|
|||
cur->ParseASSTags();
|
||||
int nblock = -1;
|
||||
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) {
|
||||
cur->Blocks.at(i)->text = TransText->GetValue();
|
||||
break;
|
||||
|
@ -346,7 +346,7 @@ void DialogTranslation::OnTransBoxKey(wxKeyEvent &event) {
|
|||
current->ParseASSTags();
|
||||
for (vector<AssDialogueBlock*>::iterator cur=current->Blocks.begin();cur!=current->Blocks.end();cur++) {
|
||||
curBlock = *cur;
|
||||
if (curBlock->type == BLOCK_PLAIN) {
|
||||
if (curBlock->GetType() == BLOCK_PLAIN) {
|
||||
pos++;
|
||||
if (pos == curblock) {
|
||||
TransText->AddText(curBlock->text);
|
||||
|
|
|
@ -1313,7 +1313,7 @@ void SubtitlesGrid::SplitLineByKaraoke(int lineNumber) {
|
|||
// copying lost of code from automation.cpp here
|
||||
// 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++) {
|
||||
switch ((*block)->type) {
|
||||
switch ((*block)->GetType()) {
|
||||
case BLOCK_BASE:
|
||||
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) {
|
||||
dia->ParseASSTags();
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue