diff --git a/aegisub/src/variable_data.cpp b/aegisub/src/variable_data.cpp index 1968e5c6d..4026f7bf4 100644 --- a/aegisub/src/variable_data.cpp +++ b/aegisub/src/variable_data.cpp @@ -76,6 +76,9 @@ template static inline VariableDataType get_type(); template<> inline VariableDataType get_type() { return VARDATA_INT; } +template<> inline VariableDataType get_type() { + return VARDATA_FLOAT; +} template<> inline VariableDataType get_type() { return VARDATA_FLOAT; } @@ -99,6 +102,7 @@ void VariableData::Set(T param) { value = new T(param); } template void VariableData::Set(int param); +template void VariableData::Set(float param); template void VariableData::Set(double param); template void VariableData::Set(bool param); template void VariableData::Set(wxString param); @@ -151,12 +155,19 @@ template<> int VariableData::Get() const { } /// @brief Reads as a float -/// @return +/// @return +template<> float VariableData::Get() const { + if (!value) throw _T("Null parameter"); + if (type == VARDATA_FLOAT) return (float)*value_float; + if (type == VARDATA_INT) return (float)(*value_int); + if (type == VARDATA_TEXT) return 0.0f; + throw _T("Wrong parameter type, should be float"); +} 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); - if (type == VARDATA_TEXT) return 0.0f; + if (type == VARDATA_TEXT) return 0.0; throw _T("Wrong parameter type, should be float"); } diff --git a/aegisub/src/visual_tool.cpp b/aegisub/src/visual_tool.cpp index c5dbbc1b9..b3dc0fc3d 100644 --- a/aegisub/src/visual_tool.cpp +++ b/aegisub/src/visual_tool.cpp @@ -550,9 +550,9 @@ void VisualTool::GetLineRotation(AssDialogue *diag,float &rx,float diag->ParseASSTags(); - get_value(diag, L"\\frx", 1, &rx); - get_value(diag, L"\\fry", 1, &ry); - get_value(diag, L"\\frz", 1, &rz); + get_value(diag, L"\\frx", 1, &rx); + get_value(diag, L"\\fry", 1, &ry); + get_value(diag, L"\\frz", 1, &rz); diag->ClearBlocks(); } @@ -569,8 +569,8 @@ void VisualTool::GetLineScale(AssDialogue *diag,float &scalX,float diag->ParseASSTags(); - get_value(diag, L"\\fscx", 1, &scalX); - get_value(diag, L"\\fscy", 1, &scalY); + get_value(diag, L"\\fscx", 1, &scalX); + get_value(diag, L"\\fscy", 1, &scalY); diag->ClearBlocks(); }