mirror of https://github.com/odrling/Aegisub
Add float overload to VariableData and use it in visual_tool.cpp rather than pretending that float* and double* are the same thing.
Originally committed to SVN as r4623.
This commit is contained in:
parent
75d9ecd14a
commit
cd0378519d
|
@ -76,6 +76,9 @@ template<class T> static inline VariableDataType get_type();
|
||||||
template<> inline VariableDataType get_type<int>() {
|
template<> inline VariableDataType get_type<int>() {
|
||||||
return VARDATA_INT;
|
return VARDATA_INT;
|
||||||
}
|
}
|
||||||
|
template<> inline VariableDataType get_type<float>() {
|
||||||
|
return VARDATA_FLOAT;
|
||||||
|
}
|
||||||
template<> inline VariableDataType get_type<double>() {
|
template<> inline VariableDataType get_type<double>() {
|
||||||
return VARDATA_FLOAT;
|
return VARDATA_FLOAT;
|
||||||
}
|
}
|
||||||
|
@ -99,6 +102,7 @@ void VariableData::Set(T param) {
|
||||||
value = new T(param);
|
value = new T(param);
|
||||||
}
|
}
|
||||||
template void VariableData::Set<int>(int param);
|
template void VariableData::Set<int>(int param);
|
||||||
|
template void VariableData::Set<float>(float param);
|
||||||
template void VariableData::Set<double>(double param);
|
template void VariableData::Set<double>(double param);
|
||||||
template void VariableData::Set<bool>(bool param);
|
template void VariableData::Set<bool>(bool param);
|
||||||
template void VariableData::Set(wxString param);
|
template void VariableData::Set(wxString param);
|
||||||
|
@ -152,11 +156,18 @@ template<> int VariableData::Get<int>() const {
|
||||||
|
|
||||||
/// @brief Reads as a float
|
/// @brief Reads as a float
|
||||||
/// @return
|
/// @return
|
||||||
|
template<> float VariableData::Get<float>() 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<double>() const {
|
template<> double VariableData::Get<double>() const {
|
||||||
if (!value) throw _T("Null parameter");
|
if (!value) throw _T("Null parameter");
|
||||||
if (type == VARDATA_FLOAT) return *value_float;
|
if (type == VARDATA_FLOAT) return *value_float;
|
||||||
if (type == VARDATA_INT) return (float)(*value_int);
|
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");
|
throw _T("Wrong parameter type, should be float");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -550,9 +550,9 @@ void VisualTool<FeatureType>::GetLineRotation(AssDialogue *diag,float &rx,float
|
||||||
|
|
||||||
diag->ParseASSTags();
|
diag->ParseASSTags();
|
||||||
|
|
||||||
get_value<double>(diag, L"\\frx", 1, &rx);
|
get_value<float>(diag, L"\\frx", 1, &rx);
|
||||||
get_value<double>(diag, L"\\fry", 1, &ry);
|
get_value<float>(diag, L"\\fry", 1, &ry);
|
||||||
get_value<double>(diag, L"\\frz", 1, &rz);
|
get_value<float>(diag, L"\\frz", 1, &rz);
|
||||||
|
|
||||||
diag->ClearBlocks();
|
diag->ClearBlocks();
|
||||||
}
|
}
|
||||||
|
@ -569,8 +569,8 @@ void VisualTool<FeatureType>::GetLineScale(AssDialogue *diag,float &scalX,float
|
||||||
|
|
||||||
diag->ParseASSTags();
|
diag->ParseASSTags();
|
||||||
|
|
||||||
get_value<double>(diag, L"\\fscx", 1, &scalX);
|
get_value<float>(diag, L"\\fscx", 1, &scalX);
|
||||||
get_value<double>(diag, L"\\fscy", 1, &scalY);
|
get_value<float>(diag, L"\\fscy", 1, &scalY);
|
||||||
|
|
||||||
diag->ClearBlocks();
|
diag->ClearBlocks();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue