mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-04-28 21:07:59 +03:00
Make fallback map static to simplify constructors
This commit is contained in:
parent
886c77bced
commit
a302ec9c65
50 changed files with 279 additions and 332 deletions
|
@ -6,10 +6,14 @@
|
|||
|
||||
namespace Fallback
|
||||
{
|
||||
Map::Map(const std::map<std::string,std::string>& fallback):mFallbackMap(fallback)
|
||||
{}
|
||||
std::map<std::string,std::string> Map::mFallbackMap;
|
||||
|
||||
std::string Map::getFallbackString(const std::string& fall) const
|
||||
void Map::init(const std::map<std::string,std::string>& fallback)
|
||||
{
|
||||
mFallbackMap = fallback;
|
||||
}
|
||||
|
||||
std::string Map::getString(const std::string& fall)
|
||||
{
|
||||
std::map<std::string,std::string>::const_iterator it;
|
||||
if ((it = mFallbackMap.find(fall)) == mFallbackMap.end())
|
||||
|
@ -19,9 +23,9 @@ namespace Fallback
|
|||
return it->second;
|
||||
}
|
||||
|
||||
float Map::getFallbackFloat(const std::string& fall) const
|
||||
float Map::getFloat(const std::string& fall)
|
||||
{
|
||||
std::string fallback = getFallbackString(fall);
|
||||
const std::string& fallback = getString(fall);
|
||||
if (!fallback.empty())
|
||||
{
|
||||
try
|
||||
|
@ -39,9 +43,9 @@ namespace Fallback
|
|||
return 0;
|
||||
}
|
||||
|
||||
int Map::getFallbackInt(const std::string& fall) const
|
||||
int Map::getInt(const std::string& fall)
|
||||
{
|
||||
std::string fallback = getFallbackString(fall);
|
||||
const std::string& fallback = getString(fall);
|
||||
if (!fallback.empty())
|
||||
{
|
||||
try
|
||||
|
@ -61,15 +65,15 @@ namespace Fallback
|
|||
return 0;
|
||||
}
|
||||
|
||||
bool Map::getFallbackBool(const std::string& fall) const
|
||||
bool Map::getBool(const std::string& fall)
|
||||
{
|
||||
std::string fallback = getFallbackString(fall);
|
||||
const std::string& fallback = getString(fall);
|
||||
return !fallback.empty() && fallback != "0";
|
||||
}
|
||||
|
||||
osg::Vec4f Map::getFallbackColour(const std::string& fall) const
|
||||
osg::Vec4f Map::getColour(const std::string& fall)
|
||||
{
|
||||
std::string sum = getFallbackString(fall);
|
||||
const std::string& sum = getString(fall);
|
||||
if (!sum.empty())
|
||||
{
|
||||
try
|
||||
|
|
|
@ -11,16 +11,15 @@ namespace Fallback
|
|||
/// @brief contains settings imported from the Morrowind INI file.
|
||||
class Map
|
||||
{
|
||||
std::map<std::string,std::string> mFallbackMap;
|
||||
static std::map<std::string,std::string> mFallbackMap;
|
||||
public:
|
||||
Map(const std::map<std::string,std::string>& fallback);
|
||||
Map() {}
|
||||
static void init(const std::map<std::string,std::string>& fallback);
|
||||
|
||||
std::string getFallbackString(const std::string& fall) const;
|
||||
float getFallbackFloat(const std::string& fall) const;
|
||||
int getFallbackInt(const std::string& fall) const;
|
||||
bool getFallbackBool(const std::string& fall) const;
|
||||
osg::Vec4f getFallbackColour(const std::string& fall) const;
|
||||
static std::string getString(const std::string& fall);
|
||||
static float getFloat(const std::string& fall);
|
||||
static int getInt(const std::string& fall);
|
||||
static bool getBool(const std::string& fall);
|
||||
static osg::Vec4f getColour(const std::string& fall);
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue