diff --git a/aegisub/src/ass_dialogue.cpp b/aegisub/src/ass_dialogue.cpp index 585f0a8c3..806b99427 100644 --- a/aegisub/src/ass_dialogue.cpp +++ b/aegisub/src/ass_dialogue.cpp @@ -486,7 +486,7 @@ void AssDialogue::ParseASSTags () { for (curTag = block->Tags.begin();curTag != block->Tags.end();curTag++) { AssOverrideTag *tag = *curTag; if (tag->Name == _T("\\p")) { - drawingLevel = tag->Params.at(0)->AsInt(); + drawingLevel = tag->Params.at(0)->Get(); } } } @@ -591,7 +591,7 @@ void AssDialogue::ConvertTagsToSRT () { if (curTag->IsValid()) { // Italics if (curTag->Name == _T("\\i")) { - temp = curTag->Params.at(0)->AsBool(); + temp = curTag->Params.at(0)->Get(); if (temp && !isItalic) { isItalic = true; final += _T(""); @@ -604,7 +604,7 @@ void AssDialogue::ConvertTagsToSRT () { // Underline if (curTag->Name == _T("\\u")) { - temp = curTag->Params.at(0)->AsBool(); + temp = curTag->Params.at(0)->Get(); if (temp && !isUnder) { isUnder = true; final += _T(""); @@ -617,7 +617,7 @@ void AssDialogue::ConvertTagsToSRT () { // Strikeout if (curTag->Name == _T("\\s")) { - temp = curTag->Params.at(0)->AsBool(); + temp = curTag->Params.at(0)->Get(); if (temp && !isStrike) { isStrike = true; final += _T(""); @@ -630,7 +630,7 @@ void AssDialogue::ConvertTagsToSRT () { // Bold if (curTag->Name == _T("\\b")) { - temp = curTag->Params.at(0)->AsBool(); + temp = curTag->Params.at(0)->Get(); if (temp && !isBold) { isBold = true; final += _T(""); diff --git a/aegisub/src/ass_karaoke.cpp b/aegisub/src/ass_karaoke.cpp index 01703e94a..6c604bf4d 100644 --- a/aegisub/src/ass_karaoke.cpp +++ b/aegisub/src/ass_karaoke.cpp @@ -102,7 +102,7 @@ void ParseAssKaraokeTags(const AssDialogue *line, AssKaraokeVector &syls) syl.unstripped_text = _T(""); syl.tag = tag; syl.type = tag->Name; - syl.duration = tag->Params[0]->AsInt(); + syl.duration = tag->Params[0]->Get(); } else { // not karaoke tag diff --git a/aegisub/src/ass_override.cpp b/aegisub/src/ass_override.cpp index 245035c88..79f193b72 100644 --- a/aegisub/src/ass_override.cpp +++ b/aegisub/src/ass_override.cpp @@ -61,15 +61,7 @@ AssOverrideParameter::~AssOverrideParameter () { /// @param param /// void AssOverrideParameter::CopyFrom (const AssOverrideParameter ¶m) { - switch(param.GetType()) { - case VARDATA_INT: SetInt(param.AsInt()); break; - case VARDATA_FLOAT: SetFloat(param.AsFloat()); break; - case VARDATA_TEXT: SetText(param.AsText()); break; - case VARDATA_BOOL: SetBool(param.AsBool()); break; - case VARDATA_COLOUR: SetColour(param.AsColour()); break; - case VARDATA_BLOCK: SetBlock(param.AsBlock()); break; - default: DeleteValue(); - } + *static_cast(this) = static_cast(param); classification = param.classification; ommited = param.ommited; } @@ -165,7 +157,7 @@ void AssDialogueBlockOverride::ProcessParameters(AssDialogueBlockOverride::Proce // Go recursive if it's a block parameter if (curPar->GetType() == VARDATA_BLOCK) { - curPar->AsBlock()->ProcessParameters(callback,userData); + curPar->Get()->ProcessParameters(callback,userData); } } @@ -466,25 +458,25 @@ void AssOverrideTagProto::LoadProtos () { i++; proto[i].name = _T("\\b"); proto[i].params.push_back(AssOverrideParamProto(VARDATA_INT,OPTIONAL_1,PARCLASS_NORMAL)); - proto[i].params.back().defaultValue.SetBool(false); + proto[i].params.back().defaultValue.Set(false); // \i<0/1> i++; proto[i].name = _T("\\i"); proto[i].params.push_back(AssOverrideParamProto(VARDATA_BOOL,OPTIONAL_1,PARCLASS_NORMAL)); - proto[i].params.back().defaultValue.SetBool(false); + proto[i].params.back().defaultValue.Set(false); // \u<0/1> i++; proto[i].name = _T("\\u"); proto[i].params.push_back(AssOverrideParamProto(VARDATA_BOOL,OPTIONAL_1,PARCLASS_NORMAL)); - proto[i].params.back().defaultValue.SetBool(false); + proto[i].params.back().defaultValue.Set(false); // \s<0/1> i++; proto[i].name = _T("\\s"); proto[i].params.push_back(AssOverrideParamProto(VARDATA_BOOL,OPTIONAL_1,PARCLASS_NORMAL)); - proto[i].params.back().defaultValue.SetBool(false); + proto[i].params.back().defaultValue.Set(false); // \a i++; @@ -689,7 +681,7 @@ end_tokenizing: wxChar firstChar = curtok[0]; bool auto4 = (firstChar == _T('!') || firstChar == _T('$') || firstChar == _T('%')) && curproto->type != VARDATA_BLOCK; if (auto4) { - newparam->SetText(curtok); + newparam->Set(curtok); } else { // Determine parameter type and set value @@ -697,29 +689,29 @@ end_tokenizing: case VARDATA_INT: { long temp = 0; curtok.ToLong(&temp); - newparam->SetInt(temp); + newparam->Set(temp); break; } case VARDATA_FLOAT: { double temp = 0.0; curtok.ToDouble(&temp); - newparam->SetFloat(temp); + newparam->Set(temp); break; } case VARDATA_TEXT: - newparam->SetText(curtok); + newparam->Set(curtok); break; case VARDATA_BOOL: { long temp = false; curtok.ToLong(&temp); - newparam->SetBool(temp != 0); + newparam->Set(temp != 0); break; } case VARDATA_BLOCK: { AssDialogueBlockOverride *temp = new AssDialogueBlockOverride; temp->text = curtok; temp->ParseTags(); - newparam->SetBlock(temp); + newparam->Set(temp); break; } default: @@ -761,7 +753,7 @@ wxString AssOverrideTag::ToString() { int n = 0; for (std::vector::iterator cur=Params.begin();cur!=Params.end();cur++) { if ((*cur)->GetType() != VARDATA_NONE && (*cur)->ommited == false) { - result += (*cur)->AsText(); + result += (*cur)->Get(); result += _T(","); n++; } diff --git a/aegisub/src/audio_karaoke.cpp b/aegisub/src/audio_karaoke.cpp index 0bb9661d6..25dbac678 100644 --- a/aegisub/src/audio_karaoke.cpp +++ b/aegisub/src/audio_karaoke.cpp @@ -183,7 +183,7 @@ void AudioKaraoke::Commit() { // Some weird people have text before the first karaoke tag on a line. // Check that a karaoke tag actually exists for the (non-)syllable to avoid a crash. if (syl->tag && syl->tag->Params.size()>0) - syl->tag->Params[0]->SetInt(syl->duration); + syl->tag->Params[0]->Set(syl->duration); // Of course, if the user changed the duration of such a non-syllable, its timing can't be updated and will stay zero. // There is no way to check for that right now, and I can't bother to fix it. } diff --git a/aegisub/src/auto4_lua_assfile.cpp b/aegisub/src/auto4_lua_assfile.cpp index 8f3985c92..13c7cc680 100644 --- a/aegisub/src/auto4_lua_assfile.cpp +++ b/aegisub/src/auto4_lua_assfile.cpp @@ -932,11 +932,11 @@ namespace Automation4 { ktag = tag->Name.Mid(1); // check if it's a "set time" tag, special handling for that (depends on previous syllable duration) if (ktag == _T("kt")) { - ktime = tag->Params[0]->AsInt() * 10; + ktime = tag->Params[0]->Get() * 10; kdur = 0; } else { ktime += kdur; // duration of previous syllable - kdur = tag->Params[0]->AsInt() * 10; + kdur = tag->Params[0]->Get() * 10; } ktext.clear(); ktext_stripped.clear(); diff --git a/aegisub/src/dialog_fonts_collector.cpp b/aegisub/src/dialog_fonts_collector.cpp index b1b239cf4..ffed27332 100644 --- a/aegisub/src/dialog_fonts_collector.cpp +++ b/aegisub/src/dialog_fonts_collector.cpp @@ -639,7 +639,7 @@ bool FontsCollectorThread::AttachFont(wxString filename) { /// void FontsCollectorThread::GetFonts (wxString tagName,int par_n,AssOverrideParameter *param,void *usr) { if (tagName == _T("\\fn")) { - if (instance) instance->AddFont(param->AsText(),1); + if (instance) instance->AddFont(param->Get(),1); } } diff --git a/aegisub/src/dialog_resample.cpp b/aegisub/src/dialog_resample.cpp index ae8ad5410..7555dabc6 100644 --- a/aegisub/src/dialog_resample.cpp +++ b/aegisub/src/dialog_resample.cpp @@ -191,9 +191,9 @@ void DialogResample::DoResampleTags (wxString name,int n,AssOverrideParameter *c case PARCLASS_DRAWING: { AssDialogueBlockDrawing block; - block.text = curParam->AsText(); + block.text = curParam->Get(); block.TransformCoords(m[0],m[2],rx,ry); - curParam->SetText(block.GetText()); + curParam->Set(block.GetText()); } return; @@ -203,16 +203,16 @@ void DialogResample::DoResampleTags (wxString name,int n,AssOverrideParameter *c VariableDataType curType = curParam->GetType(); if (curType == VARDATA_FLOAT) { - float par = curParam->AsFloat(); + float par = curParam->Get(); if (isX) par += m[0]; if (isY) par += m[2]; - curParam->SetFloat(par * resizer); + curParam->Set(par * resizer); } if (curType == VARDATA_INT) { - int par = curParam->AsInt(); + int par = curParam->Get(); if (isX) par += m[0]; if (isY) par += m[2]; - curParam->SetInt(int(double(par) * resizer + 0.5)); + curParam->Set(int(double(par) * resizer + 0.5)); } } diff --git a/aegisub/src/dialog_style_editor.cpp b/aegisub/src/dialog_style_editor.cpp index f25cc634b..869ac94ef 100644 --- a/aegisub/src/dialog_style_editor.cpp +++ b/aegisub/src/dialog_style_editor.cpp @@ -510,8 +510,8 @@ void ReplaceStyle(wxString tag,int n,AssOverrideParameter* param,void *userData) wxArrayString strings = *((wxArrayString*)userData); if (tag == _T("\\r")) { if (param->GetType() == VARDATA_TEXT) { - if (param->AsText() == strings[0]) { - param->SetText(strings[1]); + if (param->Get() == strings[0]) { + param->Set(strings[1]); } } } diff --git a/aegisub/src/export_framerate.cpp b/aegisub/src/export_framerate.cpp index 600c3882c..95d1e0039 100644 --- a/aegisub/src/export_framerate.cpp +++ b/aegisub/src/export_framerate.cpp @@ -213,7 +213,7 @@ void AssTransformFramerateFilter::TransformTimeTags (wxString name,int n,AssOver } // Parameter value - int parVal = curParam->AsInt() * mult; + int parVal = curParam->Get() * mult; // Karaoke preprocess int curKarPos = 0; @@ -263,7 +263,7 @@ void AssTransformFramerateFilter::TransformTimeTags (wxString name,int n,AssOver value -= curKarPos; } - curParam->SetInt(value/mult); + curParam->Set(value/mult); } diff --git a/aegisub/src/subs_edit_box.cpp b/aegisub/src/subs_edit_box.cpp index de7786b43..b88fbc1b3 100644 --- a/aegisub/src/subs_edit_box.cpp +++ b/aegisub/src/subs_edit_box.cpp @@ -1182,14 +1182,14 @@ void SubsEditBox::SetOverride (wxString tagname,wxString preValue,int forcePos,b for (size_t j=0;jTags.size();j++) { tag = override->Tags.at(j); if (tag->Name == tagname || tag->Name == alttagname || tagname == _T("\\fn")) { - if (isColor) startcolor = tag->Params.at(0)->AsColour(); - if (isFlag) state = tag->Params.at(0)->AsBool(); + if (isColor) startcolor = tag->Params.at(0)->Get(); + if (isFlag) state = tag->Params.at(0)->Get(); if (isFont) { - if (tag->Name == _T("\\fn")) startfont.SetFaceName(tag->Params.at(0)->AsText()); - if (tag->Name == _T("\\fs")) startfont.SetPointSize(tag->Params.at(0)->AsInt()); - if (tag->Name == _T("\\b")) startfont.SetWeight((tag->Params.at(0)->AsInt() > 0) ? wxFONTWEIGHT_BOLD : wxFONTWEIGHT_NORMAL); - if (tag->Name == _T("\\i")) startfont.SetStyle(tag->Params.at(0)->AsBool() ? wxFONTSTYLE_ITALIC : wxFONTSTYLE_NORMAL); - if (tag->Name == _T("\\u")) startfont.SetUnderlined(tag->Params.at(0)->AsBool()); + if (tag->Name == _T("\\fn")) startfont.SetFaceName(tag->Params.at(0)->Get()); + if (tag->Name == _T("\\fs")) startfont.SetPointSize(tag->Params.at(0)->Get()); + if (tag->Name == _T("\\b")) startfont.SetWeight((tag->Params.at(0)->Get() > 0) ? wxFONTWEIGHT_BOLD : wxFONTWEIGHT_NORMAL); + if (tag->Name == _T("\\i")) startfont.SetStyle(tag->Params.at(0)->Get() ? wxFONTSTYLE_ITALIC : wxFONTSTYLE_NORMAL); + if (tag->Name == _T("\\u")) startfont.SetUnderlined(tag->Params.at(0)->Get()); } } } diff --git a/aegisub/src/variable_data.cpp b/aegisub/src/variable_data.cpp index 554c4f464..05bc15f6e 100644 --- a/aegisub/src/variable_data.cpp +++ b/aegisub/src/variable_data.cpp @@ -32,8 +32,6 @@ /// @file variable_data.cpp /// @brief A variant-type implementation /// @ingroup utility subs_storage -/// - //////////// // Includes @@ -44,27 +42,19 @@ #include "utils.h" #include "variable_data.h" - /// @brief Constructor -/// VariableData::VariableData () { type = VARDATA_NONE; value = NULL; } - - /// @brief Destructor -/// VariableData::~VariableData () { DeleteValue (); } - - /// @brief Deletes the stored value /// @return -/// void VariableData::DeleteValue () { if (!value) return; if (type == VARDATA_NONE) return; @@ -81,129 +71,88 @@ void VariableData::DeleteValue () { value = NULL; } +template static inline VariableDataType get_type(); - -/// @brief Sets to an integer -/// @param param -/// -void VariableData::SetInt(int param) { - DeleteValue(); - type = VARDATA_INT; - value_int = new int(param); +template<> inline VariableDataType get_type() { + return VARDATA_INT; +} +template<> inline VariableDataType get_type() { + return VARDATA_FLOAT; +} +template<> inline VariableDataType get_type() { + return VARDATA_BOOL; +} +template<> inline VariableDataType get_type() { + return VARDATA_TEXT; +} +template<> inline VariableDataType get_type() { + return VARDATA_COLOUR; +} +template<> inline VariableDataType get_type() { + return VARDATA_BLOCK; } - - -/// @brief Sets to a float -/// @param param -/// -void VariableData::SetFloat(double param) { +template +void VariableData::Set(T param) { DeleteValue(); - type = VARDATA_FLOAT; - value_float = new double(param); + type = get_type(); + value = new T(param); } - - - -/// @brief Sets to a boolean -/// @param param -/// -void VariableData::SetBool(bool param) { - DeleteValue(); - type = VARDATA_BOOL; - value_bool = new bool(param); -} - - - -/// @brief Sets to a string -/// @param param -/// -void VariableData::SetText(wxString param) { - DeleteValue(); - type = VARDATA_TEXT; - value_text = new wxString (param); -} - - - -/// @brief Sets to a colour -/// @param param -/// -void VariableData::SetColour(wxColour param) { - DeleteValue(); - type = VARDATA_COLOUR; - value_colour = new wxColour (param); -} - - - -/// @brief Sets to a block -/// @param param -/// -void VariableData::SetBlock(AssDialogueBlockOverride *param) { - DeleteValue(); - type = VARDATA_BLOCK; - value_block = param; -} - - +template void VariableData::Set(int param); +template void VariableData::Set(double param); +template void VariableData::Set(bool param); +template void VariableData::Set(wxString param); +template void VariableData::Set(wxColour param); +template void VariableData::Set(AssDialogueBlockOverride * param); /// @brief Resets a value with a string, preserving current type /// @param value -/// void VariableData::ResetWith(wxString value) { switch (type) { case VARDATA_INT: { long temp = 0; value.ToLong(&temp); - SetInt(temp); + Set(temp); break; } case VARDATA_FLOAT: { double temp = 0; value.ToDouble(&temp); - SetFloat(temp); + Set(temp); break; } case VARDATA_BOOL: - if (value == _T("1")) SetBool(true); - else SetBool(false); + if (value == _T("1")) Set(true); + else Set(false); break; case VARDATA_COLOUR: { long r=0,g=0,b=0; value.Mid(1,2).ToLong(&r,16); value.Mid(3,2).ToLong(&g,16); value.Mid(5,2).ToLong(&b,16); - SetColour(wxColour(r,g,b)); + Set(wxColour(r,g,b)); break; } default: - SetText(value); + Set(value); break; } } - - /// @brief Reads as an int /// @return -/// -int VariableData::AsInt() const { +template<> int VariableData::Get() const { if (!value) throw _T("Null parameter"); - if (type == VARDATA_BOOL) return (*value_bool)?1:0; + if (type == VARDATA_BOOL) return !!(*value_bool); if (type == VARDATA_INT) return *value_int; if (type == VARDATA_FLOAT) return (int)(*value_float); if (type == VARDATA_TEXT) return 0; throw _T("Wrong parameter type, should be int"); } - - /// @brief Reads as a float /// @return -/// -double VariableData::AsFloat() const { +template<> double VariableData::Get() const { if (!value) throw _T("Null parameter"); if (type == VARDATA_FLOAT) return *value_float; if (type == VARDATA_INT) return (float)(*value_int); @@ -211,12 +160,9 @@ double VariableData::AsFloat() const { throw _T("Wrong parameter type, should be float"); } - - /// @brief Reads as a bool /// @return -/// -bool VariableData::AsBool() const { +template<> bool VariableData::Get() const { if (!value) throw _T("Null parameter"); if (type == VARDATA_BOOL) return *value_bool; if (type == VARDATA_INT) return ((*value_int)!=0); @@ -225,12 +171,9 @@ bool VariableData::AsBool() const { throw _T("Wrong parameter type, should be bool"); } - - /// @brief Reads as a colour /// @return -/// -wxColour VariableData::AsColour() const { +template<> wxColour VariableData::Get() const { if (!value) throw _T("Null parameter"); if (type == VARDATA_COLOUR) return *value_colour; else if (type == VARDATA_TEXT) { @@ -241,62 +184,45 @@ wxColour VariableData::AsColour() const { else throw _T("Wrong parameter type, should be colour"); } - - /// @brief Reads as a block /// @return -/// -AssDialogueBlockOverride *VariableData::AsBlock() const { +template<> AssDialogueBlockOverride *VariableData::Get() const { if (!value) throw _T("Null parameter"); if (type != VARDATA_BLOCK) throw _T("Wrong parameter type, should be block"); - return value_block; + return *value_block; } - - /// @brief Reads as a string /// @return -/// -wxString VariableData::AsText() const { +template<> wxString VariableData::Get() const { if (!value) throw _T("Null parameter"); if (type != VARDATA_TEXT) { - if (type == VARDATA_INT) return wxString::Format(_T("%i"),*value_int); - else if (type == VARDATA_FLOAT) return wxString::Format(_T("%g"),*value_float); - else if (type == VARDATA_COLOUR) return wxString::Format(_T("#%02X%02X%02X"),value_colour->Red(),value_colour->Green(),value_colour->Blue()); - else if (type == VARDATA_BOOL) { - if (*value_bool) return _T("1"); - else return _T("0"); - } - else if (type == VARDATA_BLOCK) return value_block->GetText(); + if (type == VARDATA_INT) return wxString::Format("%i",*value_int); + else if (type == VARDATA_FLOAT) return wxString::Format("%g",*value_float); + else if (type == VARDATA_COLOUR) return wxString::Format("#%02X%02X%02X",value_colour->Red(),value_colour->Green(),value_colour->Blue()); + else if (type == VARDATA_BOOL) return *value_bool ? "1" : "0"; + else if (type == VARDATA_BLOCK) return (*value_block)->GetText(); else throw _T("Wrong parameter type, should be text"); } return *value_text; } - - /// @brief Gets type /// @return -/// VariableDataType VariableData::GetType() const { return type; } - - /// @brief Copy /// @param param -/// void VariableData::operator= (const VariableData ¶m) { switch(param.GetType()) { - case VARDATA_INT: SetInt(param.AsInt()); break; - case VARDATA_FLOAT: SetFloat(param.AsFloat()); break; - case VARDATA_TEXT: SetText(param.AsText()); break; - case VARDATA_BOOL: SetBool(param.AsBool()); break; - case VARDATA_COLOUR: SetColour(param.AsColour()); break; - case VARDATA_BLOCK: SetBlock(param.AsBlock()); break; + case VARDATA_INT: Set(param.Get()); break; + case VARDATA_FLOAT: Set(param.Get()); break; + case VARDATA_TEXT: Set(param.Get()); break; + case VARDATA_BOOL: Set(param.Get()); break; + case VARDATA_COLOUR: Set(param.Get()); break; + case VARDATA_BLOCK: Set(param.Get()); break; default: DeleteValue(); } } - - diff --git a/aegisub/src/variable_data.h b/aegisub/src/variable_data.h index 6178c629d..547424c03 100644 --- a/aegisub/src/variable_data.h +++ b/aegisub/src/variable_data.h @@ -70,13 +70,9 @@ enum VariableDataType { VARDATA_BLOCK }; - -////////////// -// Prototypes class AssDialogueBlockOverride; - /// DOCME /// @class VariableData /// @brief DOCME @@ -85,7 +81,6 @@ class AssDialogueBlockOverride; class VariableData { private: union { - /// DOCME void *value; @@ -105,7 +100,7 @@ private: wxColour *value_colour; /// DOCME - AssDialogueBlockOverride *value_block; + AssDialogueBlockOverride **value_block; }; /// DOCME @@ -119,23 +114,9 @@ public: virtual ~VariableData(); VariableDataType GetType() const; - - void SetInt(int param); - void SetFloat(double param); - void SetBool(bool param); - void SetText(wxString param); - void SetColour(wxColour param); - void SetBlock(AssDialogueBlockOverride *param); + template void Set(T param); void ResetWith(wxString value); - - int AsInt() const; - double AsFloat() const; - bool AsBool() const; - wxString AsText() const; - wxColour AsColour() const; - AssDialogueBlockOverride *AsBlock() const; + template T Get() const; void operator= (const VariableData ¶m); }; - - diff --git a/aegisub/src/visual_tool.cpp b/aegisub/src/visual_tool.cpp index 6a9efbbf1..f155081be 100644 --- a/aegisub/src/visual_tool.cpp +++ b/aegisub/src/visual_tool.cpp @@ -473,15 +473,15 @@ void VisualTool::GetLinePosition(AssDialogue *diag,int &x, int &y, // Position if ((tag->Name == L"\\pos" || tag->Name == L"\\move") && tag->Params.size() >= 2) { if (!posSet) { - x = tag->Params[0]->AsInt(); - y = tag->Params[1]->AsInt(); + x = tag->Params[0]->Get(); + y = tag->Params[1]->Get(); posSet = true; } } // Alignment else if ((tag->Name == L"\\an" || tag->Name == L"\\a") && tag->Params.size() >= 1) { - align = tag->Params[0]->AsInt(); + align = tag->Params[0]->Get(); if (tag->Name == L"\\a") { switch(align) { case 1: case 2: case 3: @@ -501,8 +501,8 @@ void VisualTool::GetLinePosition(AssDialogue *diag,int &x, int &y, // Origin else if (!orgSet && tag->Name == L"\\org" && tag->Params.size() >= 2) { - orgx = tag->Params[0]->AsInt(); - orgy = tag->Params[1]->AsInt(); + orgx = tag->Params[0]->Get(); + orgy = tag->Params[1]->Get(); parent->FromScriptCoords(&orgx, &orgy); orgSet = true; } @@ -562,18 +562,18 @@ void VisualTool::GetLineMove(AssDialogue *diag,bool &hasMove,int &x // Position if (tag->Name == L"\\move" && tag->Params.size() >= 4) { hasMove = true; - x1 = tag->Params[0]->AsInt(); - y1 = tag->Params[1]->AsInt(); - x2 = tag->Params[2]->AsInt(); - y2 = tag->Params[3]->AsInt(); + x1 = tag->Params[0]->Get(); + y1 = tag->Params[1]->Get(); + x2 = tag->Params[2]->Get(); + y2 = tag->Params[3]->Get(); parent->FromScriptCoords(&x1, &y1); parent->FromScriptCoords(&x2, &y2); if (tag->Params.size() >= 6 && !tag->Params[4]->ommited && !tag->Params[5]->ommited) { - t1 = tag->Params[4]->AsInt(); - t2 = tag->Params[5]->AsInt(); + t1 = tag->Params[4]->Get(); + t2 = tag->Params[5]->Get(); } return; } @@ -617,13 +617,13 @@ void VisualTool::GetLineRotation(AssDialogue *diag,float &rx,float for (size_t j=0;jTags.size();j++) { tag = override->Tags.at(j); if (tag->Name == L"\\frx" && tag->Params.size() == 1) { - rx = tag->Params[0]->AsFloat(); + rx = tag->Params[0]->Get(); } if (tag->Name == L"\\fry" && tag->Params.size() == 1) { - ry = tag->Params[0]->AsFloat(); + ry = tag->Params[0]->Get(); } if ((tag->Name == L"\\frz" || tag->Name == L"\fr") && tag->Params.size() == 1) { - rz = tag->Params[0]->AsFloat(); + rz = tag->Params[0]->Get(); } } } @@ -655,10 +655,10 @@ void VisualTool::GetLineScale(AssDialogue *diag,float &scalX,float for (size_t j=0;jTags.size();j++) { tag = override->Tags.at(j); if (tag->Name == L"\\fscx" && tag->Params.size() == 1) { - scalX = tag->Params[0]->AsFloat(); + scalX = tag->Params[0]->Get(); } if (tag->Name == L"\\fscy" && tag->Params.size() == 1) { - scalY = tag->Params[0]->AsFloat(); + scalY = tag->Params[0]->Get(); } } } @@ -698,17 +698,17 @@ void VisualTool::GetLineClip(AssDialogue *diag,int &x1,int &y1,int for (size_t j=0;jTags.size();j++) { tag = override->Tags.at(j); if (tag->Name == L"\\clip" && tag->Params.size() == 4) { - x1 = tag->Params[0]->AsInt(); - y1 = tag->Params[1]->AsInt(); - x2 = tag->Params[2]->AsInt(); - y2 = tag->Params[3]->AsInt(); + x1 = tag->Params[0]->Get(); + y1 = tag->Params[1]->Get(); + x2 = tag->Params[2]->Get(); + y2 = tag->Params[3]->Get(); inverse = false; } else if (tag->Name == L"\\iclip" && tag->Params.size() == 4) { - x1 = tag->Params[0]->AsInt(); - y1 = tag->Params[1]->AsInt(); - x2 = tag->Params[2]->AsInt(); - y2 = tag->Params[3]->AsInt(); + x1 = tag->Params[0]->Get(); + y1 = tag->Params[1]->Get(); + x2 = tag->Params[2]->Get(); + y2 = tag->Params[3]->Get(); inverse = true; } } @@ -745,17 +745,17 @@ wxString VisualTool::GetLineVectorClip(AssDialogue *diag,int &scale tag = override->Tags.at(j); if (tag->Name == L"\\clip" || tag->Name == L"\\iclip") { if (tag->Params.size() == 1) { - result = tag->Params[0]->AsText(); + result = tag->Params[0]->Get(); } else if (tag->Params.size() == 2) { - scale = tag->Params[0]->AsInt(); - result = tag->Params[1]->AsText(); + scale = tag->Params[0]->Get(); + result = tag->Params[1]->Get(); } else if (tag->Params.size() == 4) { - int x1 = tag->Params[0]->AsInt(), - y1 = tag->Params[1]->AsInt(), - x2 = tag->Params[2]->AsInt(), - y2 = tag->Params[3]->AsInt(); + int x1 = tag->Params[0]->Get(), + y1 = tag->Params[1]->Get(), + x2 = tag->Params[2]->Get(), + y2 = tag->Params[3]->Get(); result = wxString::Format(L"m %d %d l %d %d %d %d %d %d", x1, y1, x2, y1, x2, y2, x1, y2); } inverse = tag->Name == L"\\iclip";