forked from teamnwah/openmw-tes3coop
Remove dependency on Ogre::StringConverter
This commit is contained in:
parent
cc6d5a3ba0
commit
2eec0caca0
2 changed files with 70 additions and 12 deletions
|
@ -56,6 +56,13 @@ void wrap(float& rad)
|
|||
rad = std::fmod(rad-osg::PI, 2.0f*osg::PI)+osg::PI;
|
||||
}
|
||||
|
||||
std::string toString(int num)
|
||||
{
|
||||
std::ostringstream stream;
|
||||
stream << num;
|
||||
return stream.str();
|
||||
}
|
||||
|
||||
std::string getBestAttack (const ESM::Weapon* weapon)
|
||||
{
|
||||
int slash = (weapon->mData.mSlash[0] + weapon->mData.mSlash[1])/2;
|
||||
|
@ -220,13 +227,13 @@ public:
|
|||
std::string CharacterController::chooseRandomGroup (const std::string& prefix, int* num)
|
||||
{
|
||||
int numAnims=0;
|
||||
while (mAnimation->hasAnimation(prefix + Ogre::StringConverter::toString(numAnims+1)))
|
||||
while (mAnimation->hasAnimation(prefix + toString(numAnims+1)))
|
||||
++numAnims;
|
||||
|
||||
int roll = Misc::Rng::rollDice(numAnims) + 1; // [1, numAnims]
|
||||
if (num)
|
||||
*num = roll;
|
||||
return prefix + Ogre::StringConverter::toString(roll);
|
||||
return prefix + toString(roll);
|
||||
}
|
||||
|
||||
void CharacterController::refreshCurrentAnims(CharacterState idle, CharacterState movement, bool force)
|
||||
|
@ -569,7 +576,7 @@ void CharacterController::playDeath(float startpoint, CharacterState death)
|
|||
mCurrentDeath = "deathknockout";
|
||||
break;
|
||||
default:
|
||||
mCurrentDeath = "death" + Ogre::StringConverter::toString(death - CharState_Death1 + 1);
|
||||
mCurrentDeath = "death" + toString(death - CharState_Death1 + 1);
|
||||
}
|
||||
mDeathState = death;
|
||||
|
||||
|
@ -736,9 +743,17 @@ void CharacterController::handleTextKey(const std::string &groupname, const std:
|
|||
split(soundgen, ' ', tokens);
|
||||
soundgen = tokens[0];
|
||||
if (tokens.size() >= 2)
|
||||
volume = Ogre::StringConverter::parseReal(tokens[1]);
|
||||
{
|
||||
std::stringstream stream;
|
||||
stream << tokens[1];
|
||||
stream >> volume;
|
||||
}
|
||||
if (tokens.size() >= 3)
|
||||
pitch = Ogre::StringConverter::parseReal(tokens[2]);
|
||||
{
|
||||
std::stringstream stream;
|
||||
stream << tokens[2];
|
||||
stream >> pitch;
|
||||
}
|
||||
}
|
||||
|
||||
std::string sound = mPtr.getClass().getSoundIdFromSndGen(mPtr, soundgen);
|
||||
|
|
|
@ -1,13 +1,56 @@
|
|||
#include "settings.hpp"
|
||||
|
||||
#include <stdexcept>
|
||||
#include <sstream>
|
||||
|
||||
#include <OgreStringConverter.h>
|
||||
#include <components/misc/stringops.hpp>
|
||||
|
||||
#include <boost/filesystem/fstream.hpp>
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
bool parseBool(const std::string& string)
|
||||
{
|
||||
return (Misc::StringUtils::ciEqual(string, "true"));
|
||||
}
|
||||
|
||||
float parseFloat(const std::string& string)
|
||||
{
|
||||
std::stringstream stream;
|
||||
stream << string;
|
||||
float ret = 0.f;
|
||||
stream >> ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int parseInt(const std::string& string)
|
||||
{
|
||||
std::stringstream stream;
|
||||
stream << string;
|
||||
int ret = 0;
|
||||
stream >> ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::string toString(T val)
|
||||
{
|
||||
std::ostringstream stream;
|
||||
stream << val;
|
||||
return stream.str();
|
||||
}
|
||||
|
||||
template <>
|
||||
std::string toString(bool val)
|
||||
{
|
||||
return val ? "true" : "false";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace Settings
|
||||
{
|
||||
|
||||
|
@ -143,17 +186,17 @@ std::string Manager::getString(const std::string &setting, const std::string &ca
|
|||
|
||||
float Manager::getFloat (const std::string& setting, const std::string& category)
|
||||
{
|
||||
return Ogre::StringConverter::parseReal( getString(setting, category) );
|
||||
return parseFloat( getString(setting, category) );
|
||||
}
|
||||
|
||||
int Manager::getInt (const std::string& setting, const std::string& category)
|
||||
{
|
||||
return Ogre::StringConverter::parseInt( getString(setting, category) );
|
||||
return parseInt( getString(setting, category) );
|
||||
}
|
||||
|
||||
bool Manager::getBool (const std::string& setting, const std::string& category)
|
||||
{
|
||||
return Ogre::StringConverter::parseBool( getString(setting, category) );
|
||||
return parseBool( getString(setting, category) );
|
||||
}
|
||||
|
||||
void Manager::setString(const std::string &setting, const std::string &category, const std::string &value)
|
||||
|
@ -174,17 +217,17 @@ void Manager::setString(const std::string &setting, const std::string &category,
|
|||
|
||||
void Manager::setInt (const std::string& setting, const std::string& category, const int value)
|
||||
{
|
||||
setString(setting, category, Ogre::StringConverter::toString(value));
|
||||
setString(setting, category, toString(value));
|
||||
}
|
||||
|
||||
void Manager::setFloat (const std::string &setting, const std::string &category, const float value)
|
||||
{
|
||||
setString(setting, category, Ogre::StringConverter::toString(value));
|
||||
setString(setting, category, toString(value));
|
||||
}
|
||||
|
||||
void Manager::setBool(const std::string &setting, const std::string &category, const bool value)
|
||||
{
|
||||
setString(setting, category, Ogre::StringConverter::toString(value));
|
||||
setString(setting, category, toString(value));
|
||||
}
|
||||
|
||||
const CategorySettingVector Manager::apply()
|
||||
|
|
Loading…
Reference in a new issue