mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-06 07:45:36 +00:00
Add support for scietific notation flag for MessageBox
This commit is contained in:
parent
52d4e25314
commit
579f35511a
5 changed files with 21 additions and 9 deletions
|
@ -557,7 +557,7 @@ namespace Compiler
|
|||
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)
|
||||
{
|
||||
|
|
|
@ -83,7 +83,7 @@ namespace Compiler
|
|||
std::string mArguments;
|
||||
|
||||
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) {}
|
||||
|
||||
public:
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace Interpreter
|
|||
Runtime& mRuntime;
|
||||
|
||||
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;
|
||||
out.fill(padding);
|
||||
|
@ -58,7 +58,11 @@ namespace Interpreter
|
|||
float value = mRuntime[0].mFloat;
|
||||
mRuntime.pop();
|
||||
|
||||
out << std::fixed << value;
|
||||
if (notation == FixedNotation)
|
||||
out << std::fixed << value;
|
||||
else
|
||||
out << std::scientific << value;
|
||||
|
||||
mFormattedMessage += out.str();
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -49,11 +49,13 @@ namespace Misc
|
|||
width = (widthSet) ? width : -1;
|
||||
|
||||
if (m[i] == 'S' || m[i] == 's')
|
||||
visitedPlaceholder(StringPlaceholder, pad, width, precision);
|
||||
else if (m[i] == 'g' || m[i] == 'G')
|
||||
visitedPlaceholder(IntegerPlaceholder, pad, width, precision);
|
||||
visitedPlaceholder(StringPlaceholder, pad, width, precision, FixedNotation);
|
||||
else if (m[i] == 'd' || m[i] == 'i')
|
||||
visitedPlaceholder(IntegerPlaceholder, pad, width, precision, FixedNotation);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,13 @@ namespace Misc
|
|||
FloatPlaceholder
|
||||
};
|
||||
|
||||
virtual void visitedPlaceholder(Placeholder placeholder, char padding, int width, int precision) = 0;
|
||||
enum Notation
|
||||
{
|
||||
FixedNotation,
|
||||
ScientificNotation
|
||||
};
|
||||
|
||||
virtual void visitedPlaceholder(Placeholder placeholder, char padding, int width, int precision, Notation notation) = 0;
|
||||
virtual void visitedCharacter(char c) = 0;
|
||||
|
||||
public:
|
||||
|
|
Loading…
Reference in a new issue