From 4e53ab3eabdc52e9a1644b4129455f395cfc5a10 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Fri, 6 Jul 2012 02:14:46 +0000 Subject: [PATCH] Remove the uses of wxNumberFormatter We currently require mismatched locales for non-English since we don't distinguish between locale-independent things like the config file and UI things, which wxNumberFormatter barfs on. Originally committed to SVN as r6930. --- aegisub/src/agi_pre.h | 1 - aegisub/src/vector2d.cpp | 16 +++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/aegisub/src/agi_pre.h b/aegisub/src/agi_pre.h index b2664a7a4..706756c72 100644 --- a/aegisub/src/agi_pre.h +++ b/aegisub/src/agi_pre.h @@ -152,7 +152,6 @@ #include #include #include -#include #include #include #include diff --git a/aegisub/src/vector2d.cpp b/aegisub/src/vector2d.cpp index 8fb9477b7..d1e3640ca 100644 --- a/aegisub/src/vector2d.cpp +++ b/aegisub/src/vector2d.cpp @@ -27,8 +27,6 @@ #ifndef AGI_PRE #include - -#include #endif Vector2D::Vector2D() @@ -91,9 +89,13 @@ wxString Vector2D::DStr(char sep) const { return wxString::Format("%d%c%d", (int)x, sep, (int)y); } -wxString Vector2D::Str(char sep) const { - return - wxNumberFormatter::ToString(x, 3, wxNumberFormatter::Style_NoTrailingZeroes) + - sep + - wxNumberFormatter::ToString(y, 3, wxNumberFormatter::Style_NoTrailingZeroes); +static wxString float_to_string(float val) { + wxString s = wxString::Format("%.3f", val); + size_t pos = s.find_last_not_of("0"); + if (pos != s.find(".")) ++pos; + return s.Left(pos); +} + +wxString Vector2D::Str(char sep) const { + return float_to_string(x) + sep + float_to_string(y); }