mirror of
https://github.com/vcmi/vcmi.git
synced 2025-05-23 22:40:07 +02:00
Style cleanup
This commit is contained in:
parent
62151cd20c
commit
ab8b407294
Global.h
client
13
Global.h
13
Global.h
@ -726,17 +726,18 @@ namespace vstd
|
||||
}
|
||||
|
||||
/// converts number into string using metric system prefixes, e.g. 'k' or 'M' to keep resulting strings within specified size
|
||||
template<typename IntType>
|
||||
std::string formatMetric(IntType number, int maxLength)
|
||||
/// Note that resulting string may have more symbols than digits: minus sign and prefix symbol
|
||||
template<typename Arithmetic>
|
||||
std::string formatMetric(Arithmetic number, int maxDigits)
|
||||
{
|
||||
IntType max = pow(10, maxLength);
|
||||
Arithmetic max = std::pow(10, maxDigits);
|
||||
if (std::abs(number) < max)
|
||||
return boost::lexical_cast<std::string>(number);
|
||||
return std::to_string(number);
|
||||
|
||||
std::string symbols = " kMGTPE";
|
||||
auto iter = symbols.begin();
|
||||
|
||||
while (number >= max)
|
||||
while (std::abs(number) >= max)
|
||||
{
|
||||
number /= 1000;
|
||||
iter++;
|
||||
@ -745,8 +746,6 @@ namespace vstd
|
||||
}
|
||||
return std::to_string(number) + *iter;
|
||||
}
|
||||
|
||||
using boost::math::round;
|
||||
}
|
||||
using vstd::operator-=;
|
||||
|
||||
|
@ -77,9 +77,9 @@ std::string CResDataBar::buildDateString()
|
||||
std::string pattern = "%s: %d, %s: %d, %s: %d";
|
||||
|
||||
auto formatted = boost::format(pattern)
|
||||
% CGI->generaltexth->allTexts[62] % LOCPLINT->cb->getDate(Date::MONTH)
|
||||
% CGI->generaltexth->allTexts[63] % LOCPLINT->cb->getDate(Date::WEEK)
|
||||
% CGI->generaltexth->allTexts[64] % LOCPLINT->cb->getDate(Date::DAY_OF_WEEK);
|
||||
% CGI->generaltexth->translate("core.genrltxt.62") % LOCPLINT->cb->getDate(Date::MONTH)
|
||||
% CGI->generaltexth->translate("core.genrltxt.63") % LOCPLINT->cb->getDate(Date::WEEK)
|
||||
% CGI->generaltexth->translate("core.genrltxt.64") % LOCPLINT->cb->getDate(Date::DAY_OF_WEEK);
|
||||
|
||||
return boost::str(formatted);
|
||||
}
|
||||
|
@ -525,9 +525,9 @@ void BattleInterface::setAnimSpeed(int set)
|
||||
int BattleInterface::getAnimSpeed() const
|
||||
{
|
||||
if(settings["session"]["spectate"].Bool() && !settings["session"]["spectate-battle-speed"].isNull())
|
||||
return static_cast<int>(vstd::round(settings["session"]["spectate-battle-speed"].Float()));
|
||||
return static_cast<int>(std::round(settings["session"]["spectate-battle-speed"].Float()));
|
||||
|
||||
return static_cast<int>(vstd::round(settings["battle"]["speedFactor"].Float()));
|
||||
return static_cast<int>(std::round(settings["battle"]["speedFactor"].Float()));
|
||||
}
|
||||
|
||||
CPlayerInterface *BattleInterface::getCurrentPlayerInterface() const
|
||||
|
@ -312,7 +312,7 @@ void CreatureAnimation::playOnce( ECreatureAnimType type )
|
||||
|
||||
inline int getBorderStrength(float time)
|
||||
{
|
||||
float borderStrength = fabs(vstd::round(time) - time) * 2; // generate value in range 0-1
|
||||
float borderStrength = fabs(std::round(time) - time) * 2; // generate value in range 0-1
|
||||
|
||||
return static_cast<int>(borderStrength * 155 + 100); // scale to 0-255
|
||||
}
|
||||
|
@ -187,9 +187,9 @@ std::string CMinorResDataBar::buildDateString()
|
||||
std::string pattern = "%s: %d, %s: %d, %s: %d";
|
||||
|
||||
auto formatted = boost::format(pattern)
|
||||
% CGI->generaltexth->allTexts[62] % LOCPLINT->cb->getDate(Date::MONTH)
|
||||
% CGI->generaltexth->allTexts[63] % LOCPLINT->cb->getDate(Date::WEEK)
|
||||
% CGI->generaltexth->allTexts[64] % LOCPLINT->cb->getDate(Date::DAY_OF_WEEK);
|
||||
% CGI->generaltexth->translate("core.genrltxt.62") % LOCPLINT->cb->getDate(Date::MONTH)
|
||||
% CGI->generaltexth->translate("core.genrltxt.63") % LOCPLINT->cb->getDate(Date::WEEK)
|
||||
% CGI->generaltexth->translate("core.genrltxt.64") % LOCPLINT->cb->getDate(Date::DAY_OF_WEEK);
|
||||
|
||||
return boost::str(formatted);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user