mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-19 19:53:53 +00:00
Merged merge request !33
This commit is contained in:
commit
dc9aedca7d
5 changed files with 47 additions and 10 deletions
|
@ -557,7 +557,7 @@ namespace Compiler
|
||||||
mExplicit.clear();
|
mExplicit.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetArgumentsFromMessageFormat::visitedPlaceholder(Placeholder placeholder, char /*padding*/, int /*width*/, int /*precision*/)
|
void GetArgumentsFromMessageFormat::visitedPlaceholder(Placeholder placeholder, char /*padding*/, int /*width*/, int /*precision*/, Notation /*notation*/)
|
||||||
{
|
{
|
||||||
switch (placeholder)
|
switch (placeholder)
|
||||||
{
|
{
|
||||||
|
|
|
@ -83,7 +83,7 @@ namespace Compiler
|
||||||
std::string mArguments;
|
std::string mArguments;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void visitedPlaceholder(Placeholder placeholder, char padding, int width, int precision);
|
virtual void visitedPlaceholder(Placeholder placeholder, char padding, int width, int precision, Notation notation);
|
||||||
virtual void visitedCharacter(char c) {}
|
virtual void visitedCharacter(char c) {}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -24,7 +24,7 @@ namespace Interpreter
|
||||||
Runtime& mRuntime;
|
Runtime& mRuntime;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void visitedPlaceholder(Placeholder placeholder, char padding, int width, int precision)
|
virtual void visitedPlaceholder(Placeholder placeholder, char padding, int width, int precision, Notation notation)
|
||||||
{
|
{
|
||||||
std::ostringstream out;
|
std::ostringstream out;
|
||||||
out.fill(padding);
|
out.fill(padding);
|
||||||
|
@ -58,9 +58,35 @@ namespace Interpreter
|
||||||
float value = mRuntime[0].mFloat;
|
float value = mRuntime[0].mFloat;
|
||||||
mRuntime.pop();
|
mRuntime.pop();
|
||||||
|
|
||||||
|
if (notation == FixedNotation)
|
||||||
|
{
|
||||||
out << std::fixed << value;
|
out << std::fixed << value;
|
||||||
mFormattedMessage += out.str();
|
mFormattedMessage += out.str();
|
||||||
}
|
}
|
||||||
|
else if (notation == ShortestNotation)
|
||||||
|
{
|
||||||
|
std::string scientific;
|
||||||
|
std::string fixed;
|
||||||
|
|
||||||
|
out << std::scientific << value;
|
||||||
|
|
||||||
|
scientific = out.str();
|
||||||
|
|
||||||
|
out.str(std::string());
|
||||||
|
out.clear();
|
||||||
|
|
||||||
|
out << std::fixed << value;
|
||||||
|
|
||||||
|
fixed = out.str();
|
||||||
|
|
||||||
|
mFormattedMessage += fixed.length() < scientific.length() ? fixed : scientific;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
out << std::scientific << value;
|
||||||
|
mFormattedMessage += out.str();
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -49,11 +49,15 @@ namespace Misc
|
||||||
width = (widthSet) ? width : -1;
|
width = (widthSet) ? width : -1;
|
||||||
|
|
||||||
if (m[i] == 'S' || m[i] == 's')
|
if (m[i] == 'S' || m[i] == 's')
|
||||||
visitedPlaceholder(StringPlaceholder, pad, width, precision);
|
visitedPlaceholder(StringPlaceholder, pad, width, precision, FixedNotation);
|
||||||
else if (m[i] == 'g' || m[i] == 'G')
|
else if (m[i] == 'd' || m[i] == 'i')
|
||||||
visitedPlaceholder(IntegerPlaceholder, pad, width, precision);
|
visitedPlaceholder(IntegerPlaceholder, pad, width, precision, FixedNotation);
|
||||||
else if (m[i] == 'f' || m[i] == 'F')
|
else if (m[i] == 'f' || m[i] == 'F')
|
||||||
visitedPlaceholder(FloatPlaceholder, pad, width, precision);
|
visitedPlaceholder(FloatPlaceholder, pad, width, precision, FixedNotation);
|
||||||
|
else if (m[i] == 'e' || m[i] == 'E')
|
||||||
|
visitedPlaceholder(FloatPlaceholder, pad, width, precision, ScientificNotation);
|
||||||
|
else if (m[i] == 'g' || m[i] == 'G')
|
||||||
|
visitedPlaceholder(FloatPlaceholder, pad, width, precision, ShortestNotation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,14 @@ namespace Misc
|
||||||
FloatPlaceholder
|
FloatPlaceholder
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual void visitedPlaceholder(Placeholder placeholder, char padding, int width, int precision) = 0;
|
enum Notation
|
||||||
|
{
|
||||||
|
FixedNotation,
|
||||||
|
ScientificNotation,
|
||||||
|
ShortestNotation
|
||||||
|
};
|
||||||
|
|
||||||
|
virtual void visitedPlaceholder(Placeholder placeholder, char padding, int width, int precision, Notation notation) = 0;
|
||||||
virtual void visitedCharacter(char c) = 0;
|
virtual void visitedCharacter(char c) = 0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Reference in a new issue