Add functions for converting between SSA and ASS aligns to AssStyle
Originally committed to SVN as r6598.
This commit is contained in:
parent
2036712acb
commit
6f167e9293
3 changed files with 40 additions and 34 deletions
|
@ -246,20 +246,8 @@ AssStyle::AssStyle(wxString rawData, int version)
|
||||||
shadow_w = get_next_double(tkn);
|
shadow_w = get_next_double(tkn);
|
||||||
alignment = get_next_int(tkn);
|
alignment = get_next_int(tkn);
|
||||||
|
|
||||||
if (version == 0) {
|
if (version == 0)
|
||||||
switch(alignment) {
|
alignment = SsaToAss(alignment);
|
||||||
case 1: alignment = 1; break;
|
|
||||||
case 2: alignment = 2; break;
|
|
||||||
case 3: alignment = 3; break;
|
|
||||||
case 5: alignment = 7; break;
|
|
||||||
case 6: alignment = 8; break;
|
|
||||||
case 7: alignment = 9; break;
|
|
||||||
case 9: alignment = 4; break;
|
|
||||||
case 10: alignment = 5; break;
|
|
||||||
case 11: alignment = 6; break;
|
|
||||||
default: alignment = 2; break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read left margin
|
// Read left margin
|
||||||
Margin[0] = mid(0, get_next_int(tkn), 9999);
|
Margin[0] = mid(0, get_next_int(tkn), 9999);
|
||||||
|
@ -350,18 +338,7 @@ void AssStyle::UpdateData() {
|
||||||
|
|
||||||
wxString AssStyle::GetSSAText() const {
|
wxString AssStyle::GetSSAText() const {
|
||||||
wxString output;
|
wxString output;
|
||||||
int align = 0;
|
int align = AssToSsa(alignment);
|
||||||
switch (alignment) {
|
|
||||||
case 1: align = 1; break;
|
|
||||||
case 2: align = 2; break;
|
|
||||||
case 3: align = 3; break;
|
|
||||||
case 4: align = 9; break;
|
|
||||||
case 5: align = 10; break;
|
|
||||||
case 6: align = 11; break;
|
|
||||||
case 7: align = 5; break;
|
|
||||||
case 8: align = 6; break;
|
|
||||||
case 9: align = 7; break;
|
|
||||||
}
|
|
||||||
wxString n = name;
|
wxString n = name;
|
||||||
n.Replace(",", ";");
|
n.Replace(",", ";");
|
||||||
wxString f = font;
|
wxString f = font;
|
||||||
|
@ -405,3 +382,33 @@ void AssStyle::GetEncodings(wxArrayString &encodingStrings) {
|
||||||
encodingStrings.Add(wxString("238 - ") + _("East European"));
|
encodingStrings.Add(wxString("238 - ") + _("East European"));
|
||||||
encodingStrings.Add(wxString("255 - ") + _("OEM"));
|
encodingStrings.Add(wxString("255 - ") + _("OEM"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int AssStyle::AssToSsa(int ass_align) {
|
||||||
|
switch (ass_align) {
|
||||||
|
case 1: return 1;
|
||||||
|
case 2: return 2;
|
||||||
|
case 3: return 3;
|
||||||
|
case 4: return 9;
|
||||||
|
case 5: return 10;
|
||||||
|
case 6: return 11;
|
||||||
|
case 7: return 5;
|
||||||
|
case 8: return 6;
|
||||||
|
case 9: return 7;
|
||||||
|
default: return 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int AssStyle::SsaToAss(int ssa_align) {
|
||||||
|
switch(ssa_align) {
|
||||||
|
case 1: return 1;
|
||||||
|
case 2: return 2;
|
||||||
|
case 3: return 3;
|
||||||
|
case 5: return 7;
|
||||||
|
case 6: return 8;
|
||||||
|
case 7: return 9;
|
||||||
|
case 9: return 4;
|
||||||
|
case 10: return 5;
|
||||||
|
case 11: return 6;
|
||||||
|
default: return 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -111,4 +111,9 @@ public:
|
||||||
wxString GetSSAText() const;
|
wxString GetSSAText() const;
|
||||||
ASS_EntryType GetType() const { return ENTRY_STYLE; }
|
ASS_EntryType GetType() const { return ENTRY_STYLE; }
|
||||||
AssEntry *Clone() const;
|
AssEntry *Clone() const;
|
||||||
|
|
||||||
|
/// Convert an ASS alignment to the equivalent SSA alignment
|
||||||
|
static int AssToSsa(int ass_align);
|
||||||
|
/// Convert a SSA alignment to the equivalent ASS alignment
|
||||||
|
static int SsaToAss(int ssa_align);
|
||||||
};
|
};
|
||||||
|
|
|
@ -423,14 +423,8 @@ Vector2D VisualToolBase::GetLinePosition(AssDialogue *diag) {
|
||||||
int ovr_align = 0;
|
int ovr_align = 0;
|
||||||
if ((align_tag = find_tag(diag, "\\an")) && !(*align_tag)[0]->omitted)
|
if ((align_tag = find_tag(diag, "\\an")) && !(*align_tag)[0]->omitted)
|
||||||
ovr_align = (*align_tag)[0]->Get<int>();
|
ovr_align = (*align_tag)[0]->Get<int>();
|
||||||
else if ((align_tag = find_tag(diag, "\\a"))) {
|
else if ((align_tag = find_tag(diag, "\\a")))
|
||||||
ovr_align = (*align_tag)[0]->Get<int>(2);
|
ovr_align = AssStyle::SsaToAss((*align_tag)[0]->Get<int>(2));
|
||||||
|
|
||||||
// \a -> \an values mapping
|
|
||||||
static int align_mapping[] = { 0, 1, 2, 3, 7, 7, 8, 9, 7, 4, 5, 6 };
|
|
||||||
if (static_cast<size_t>(ovr_align) < sizeof(align_mapping) / sizeof(int))
|
|
||||||
ovr_align = align_mapping[ovr_align];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ovr_align > 0 && ovr_align <= 9)
|
if (ovr_align > 0 && ovr_align <= 9)
|
||||||
align = ovr_align;
|
align = ovr_align;
|
||||||
|
|
Loading…
Reference in a new issue