forked from mia/Aegisub
Kill the horrifying PrettyFloat function and just use g instead of f everywhere it was used.
Originally committed to SVN as r4280.
This commit is contained in:
parent
1654f4a102
commit
624df412ea
11 changed files with 21 additions and 62 deletions
|
@ -460,16 +460,16 @@ void AssStyle::UpdateData() {
|
|||
font.Replace(_T(","),_T(";"));
|
||||
|
||||
|
||||
final = wxString::Format(_T("Style: %s,%s,%s,%s,%s,%s,%s,%d,%d,%d,%d,%s,%s,%s,%s,%d,%s,%s,%i,%i,%i,%i,%i"),
|
||||
name.c_str(), font.c_str(), PrettyFloatD(fontsize).c_str(),
|
||||
final = wxString::Format(_T("Style: %s,%s,%g,%s,%s,%s,%s,%d,%d,%d,%d,%g,%g,%g,%g,%d,%g,%g,%i,%i,%i,%i,%i"),
|
||||
name.c_str(), font.c_str(), fontsize,
|
||||
primary.GetASSFormatted(true,false,true).c_str(),
|
||||
secondary.GetASSFormatted(true,false,true).c_str(),
|
||||
outline.GetASSFormatted(true,false,true).c_str(),
|
||||
shadow.GetASSFormatted(true,false,true).c_str(),
|
||||
(bold? -1 : 0), (italic ? -1 : 0),
|
||||
(underline?-1:0),(strikeout?-1:0),
|
||||
PrettyFloatD(scalex).c_str(),PrettyFloatD(scaley).c_str(),PrettyFloatD(spacing).c_str(),PrettyFloatD(angle).c_str(),
|
||||
borderstyle,PrettyFloatD(outline_w).c_str(),PrettyFloatD(shadow_w).c_str(),alignment,
|
||||
scalex,scaley,spacing,angle,
|
||||
borderstyle,outline_w,shadow_w,alignment,
|
||||
Margin[0],Margin[1],Margin[2],encoding);
|
||||
|
||||
SetEntryData(final);
|
||||
|
@ -526,13 +526,13 @@ wxString AssStyle::GetSSAText() {
|
|||
name.Replace(_T(","),_T(";"));
|
||||
font.Replace(_T(","),_T(";"));
|
||||
|
||||
output = wxString::Format(_T("Style: %s,%s,%s,%s,%s,0,%s,%d,%d,%d,%s,%s,%d,%d,%d,%d,0,%i"),
|
||||
name.c_str(), font.c_str(), PrettyFloatD(fontsize).c_str(),
|
||||
output = wxString::Format(_T("Style: %s,%s,%g,%s,%s,0,%s,%d,%d,%d,%g,%g,%d,%d,%d,%d,0,%i"),
|
||||
name.c_str(), font.c_str(), fontsize,
|
||||
primary.GetSSAFormatted().c_str(),
|
||||
secondary.GetSSAFormatted().c_str(),
|
||||
shadow.GetSSAFormatted().c_str(),
|
||||
(bold? -1 : 0), (italic ? -1 : 0),
|
||||
borderstyle,PrettyFloatD(outline_w).c_str(),PrettyFloatD(shadow_w).c_str(),align,
|
||||
borderstyle,outline_w,shadow_w,align,
|
||||
Margin[0],Margin[1],Margin[2],encoding);
|
||||
|
||||
return output;
|
||||
|
|
|
@ -622,7 +622,7 @@ nospin:
|
|||
///
|
||||
wxString SerialiseValue()
|
||||
{
|
||||
return PrettyFloatF(value);
|
||||
return AegiFloatToString(value);
|
||||
}
|
||||
|
||||
|
||||
|
@ -646,7 +646,7 @@ nospin:
|
|||
///
|
||||
wxControl *Create(wxWindow *parent)
|
||||
{
|
||||
cw = new wxTextCtrl(parent, -1, PrettyFloatF(value), wxDefaultPosition, wxDefaultSize, 0); //, FloatTextValidator());
|
||||
cw = new wxTextCtrl(parent, -1, AegiFloatToString(value), wxDefaultPosition, wxDefaultSize, 0); //, FloatTextValidator());
|
||||
cw->SetToolTip(hint);
|
||||
return cw;
|
||||
}
|
||||
|
|
|
@ -1497,7 +1497,7 @@ void DialogColorPicker::OnRGBAdjust(wxCommandEvent &evt)
|
|||
double r = double(cur.Red()) / double(old.Red());
|
||||
double g = double(cur.Green()) / double(old.Green());
|
||||
double b = double(cur.Blue()) / double(old.Blue());
|
||||
wxString data = wxString(_T("rgbadjust(")) + PrettyFloatD(r) + _T(",") + PrettyFloatD(g) + _T(",") + PrettyFloatD(b) + _T(")");
|
||||
wxString data = wxString::Format(L"rgbadjust(%g,%g,%g)", r, g, b);
|
||||
|
||||
if (wxTheClipboard->Open()) {
|
||||
wxTheClipboard->SetData(new wxTextDataObject(data));
|
||||
|
|
|
@ -123,52 +123,14 @@ wxString DecodeRelativePath(wxString _path,wxString reference) {
|
|||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// @brief Pretty float
|
||||
/// @param src
|
||||
/// @return
|
||||
///
|
||||
wxString PrettyFloat(wxString src) {
|
||||
if (src.Contains(_T("."))) {
|
||||
size_t len = src.Length();
|
||||
while (src.Right(1) == _T("0")) {
|
||||
len--;
|
||||
src.Truncate(len);
|
||||
}
|
||||
if (src.Right(1) == _T(".")) {
|
||||
len--;
|
||||
src.Truncate(len);
|
||||
}
|
||||
}
|
||||
return src;
|
||||
}
|
||||
|
||||
|
||||
/// @brief DOCME
|
||||
/// @param src
|
||||
/// @return
|
||||
///
|
||||
wxString PrettyFloatF(float src) { return PrettyFloat(wxString::Format(_T("%f"),src)); }
|
||||
|
||||
/// @brief DOCME
|
||||
/// @param src
|
||||
/// @return
|
||||
///
|
||||
wxString PrettyFloatD(double src) { return PrettyFloat(wxString::Format(_T("%f"),src)); }
|
||||
|
||||
|
||||
|
||||
/// @brief Float to string
|
||||
/// @param value
|
||||
/// @return
|
||||
///
|
||||
wxString AegiFloatToString(double value) {
|
||||
return PrettyFloat(wxString::Format(_T("%f"),value));
|
||||
return wxString::Format(_T("%g"),value);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// @brief Int to string
|
||||
/// @param value
|
||||
/// @return
|
||||
|
@ -177,8 +139,6 @@ wxString AegiIntegerToString(int value) {
|
|||
return wxString::Format(_T("%i"),value);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// @brief There shall be no kiB, MiB stuff here Pretty reading of size
|
||||
/// @param bytes
|
||||
/// @return
|
||||
|
|
|
@ -63,9 +63,6 @@ int64_t abs64(int64_t input);
|
|||
int CountMatches(wxString parent,wxString child);
|
||||
wxString MakeRelativePath(wxString path,wxString reference);
|
||||
wxString DecodeRelativePath(wxString path,wxString reference);
|
||||
wxString PrettyFloat(wxString src);
|
||||
wxString PrettyFloatF(float src);
|
||||
wxString PrettyFloatD(double src);
|
||||
wxString AegiFloatToString(double value);
|
||||
wxString AegiIntegerToString(int value);
|
||||
wxString PrettySize(int bytes);
|
||||
|
|
|
@ -213,7 +213,7 @@ void NumValidator::OnChar(wxKeyEvent& event) {
|
|||
///
|
||||
bool NumValidator::TransferToWindow() {
|
||||
wxTextCtrl *ctrl = (wxTextCtrl*) GetWindow();
|
||||
if (isFloat) ctrl->SetValue(PrettyFloatD(fValue));
|
||||
if (isFloat) ctrl->SetValue(wxString::Format(_T("%g"),iValue));
|
||||
else ctrl->SetValue(wxString::Format(_T("%d"),iValue));
|
||||
|
||||
return true;
|
||||
|
|
|
@ -261,7 +261,7 @@ wxString VariableData::AsText() 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 PrettyFloat(wxString::Format(_T("%f"),*value_float));
|
||||
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");
|
||||
|
|
|
@ -133,7 +133,9 @@ VideoDisplay::~VideoDisplay () {
|
|||
}
|
||||
|
||||
void VideoDisplay::ShowCursor(bool show) {
|
||||
if (show) SetCursor(wxNullCursor);
|
||||
if (show) {
|
||||
SetCursor(wxNullCursor);
|
||||
}
|
||||
else {
|
||||
wxCursor cursor(wxCURSOR_BLANK);
|
||||
SetCursor(cursor);
|
||||
|
|
|
@ -235,8 +235,8 @@ void VisualToolRotateXY::UpdateHold() {
|
|||
/// @brief Commit hold
|
||||
///
|
||||
void VisualToolRotateXY::CommitHold() {
|
||||
SetOverride(_T("\\frx"),PrettyFloat(wxString::Format(_T("(%0.3f)"),curAngleX)));
|
||||
SetOverride(_T("\\fry"),PrettyFloat(wxString::Format(_T("(%0.3f)"),curAngleY)));
|
||||
SetOverride(_T("\\frx"),wxString::Format(_T("(%0.3g)"),curAngleX));
|
||||
SetOverride(_T("\\fry"),wxString::Format(_T("(%0.3g)"),curAngleY));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -202,7 +202,7 @@ void VisualToolRotateZ::UpdateHold() {
|
|||
/// @brief Commit hold
|
||||
///
|
||||
void VisualToolRotateZ::CommitHold() {
|
||||
SetOverride(_T("\\frz"),PrettyFloat(wxString::Format(_T("(%0.3f)"),curAngle)));
|
||||
SetOverride(_T("\\frz"),wxString::Format(L"(%0.3g)",curAngle));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -184,8 +184,8 @@ void VisualToolScale::UpdateHold() {
|
|||
/// @brief Commit hold
|
||||
///
|
||||
void VisualToolScale::CommitHold() {
|
||||
SetOverride(_T("\\fscx"),PrettyFloat(wxString::Format(_T("(%0.3f)"),curScaleX)));
|
||||
SetOverride(_T("\\fscy"),PrettyFloat(wxString::Format(_T("(%0.3f)"),curScaleY)));
|
||||
SetOverride(_T("\\fscx"),wxString::Format(L"(%0.3g)",curScaleX));
|
||||
SetOverride(_T("\\fscy"),wxString::Format(L"(%0.3g)",curScaleY));
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue