double's should now be displayed with only 1 decimal.

This commit is contained in:
Tleety
2016-03-04 02:19:13 +01:00
parent 00b5a1771c
commit 778bbd13ca
3 changed files with 14 additions and 4 deletions
+10 -2
View File
@@ -35,9 +35,17 @@ void TextFieldReader::UpdateComponent(EntityWrapper& entity, ComponentWrapper& c
if (field.Type == "int") {
text = boost::lexical_cast<std::string>((const int&)component[fieldName]);
} else if (field.Type == "float") {
text = boost::lexical_cast<std::string>((const float&)component[fieldName]);
std::ostringstream ss;
float f = (float)component[fieldName];
ss << std::fixed << std::setprecision(2);
ss << f;
text = ss.str();
} else if (field.Type == "double") {
text = boost::lexical_cast<std::string>((const double&)component[fieldName]);
std::ostringstream ss;
double d = (double)component[fieldName];
ss << std::fixed << std::setprecision(1);
ss << d;
text = ss.str();
} else if (field.Type == "bool") {
text = boost::lexical_cast<std::string>((const bool&)component[fieldName]);
} else if (field.Type == "string") {