forked from mirror/openmw-tes3mp
some cleanup
This commit is contained in:
parent
65c382116f
commit
bdec87e51b
2 changed files with 42 additions and 42 deletions
|
@ -19,7 +19,7 @@ using namespace MWWorld;
|
||||||
using namespace MWSound;
|
using namespace MWSound;
|
||||||
|
|
||||||
#define lerp(x, y) (x * (1-factor) + y * factor)
|
#define lerp(x, y) (x * (1-factor) + y * factor)
|
||||||
std::string WeatherManager::getFallback (const std::string& key)
|
std::string WeatherManager::getFallback (const std::string& key) const
|
||||||
{
|
{
|
||||||
std::map<std::string,std::string>::const_iterator it;
|
std::map<std::string,std::string>::const_iterator it;
|
||||||
if((it = mFallback.find(key)) == mFallback.end())
|
if((it = mFallback.find(key)) == mFallback.end())
|
||||||
|
@ -28,34 +28,34 @@ std::string WeatherManager::getFallback (const std::string& key)
|
||||||
}
|
}
|
||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
std::string WeatherManager::getFallbackString(const std::string& fall)
|
std::string WeatherManager::getFallbackString(const std::string& fall) const
|
||||||
{
|
{
|
||||||
return WeatherManager::getFallback(fall);
|
return getFallback(fall);
|
||||||
}
|
}
|
||||||
|
|
||||||
float WeatherManager::getFallbackFloat(const std::string& fall)
|
float WeatherManager::getFallbackFloat(const std::string& fall) const
|
||||||
{
|
{
|
||||||
std::string fallback=getFallbackString(fall);
|
std::string fallback=getFallbackString(fall);
|
||||||
return boost::lexical_cast<float>(fallback);
|
return boost::lexical_cast<float>(fallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
ColourValue WeatherManager::getFallbackColour(const std::string& fall)
|
ColourValue WeatherManager::getFallbackColour(const std::string& fall) const
|
||||||
{
|
{
|
||||||
std::string sum;
|
std::string sum;
|
||||||
std::string ret[3];
|
std::string ret[3];
|
||||||
sum=getFallback(fall);
|
sum=getFallback(fall);
|
||||||
unsigned int j=0;
|
unsigned int j=0;
|
||||||
for(unsigned int i=0;i<sum.length();i++){
|
for(unsigned int i=0;i<sum.length();i++){
|
||||||
if(sum[i]==',') j++;
|
if(sum[i]==',') j++;
|
||||||
else ret[j]+=sum[i];
|
else ret[j]+=sum[i];
|
||||||
}
|
}
|
||||||
return ColourValue(boost::lexical_cast<int>(ret[0])/255.f,boost::lexical_cast<int>(ret[1])/255.f,boost::lexical_cast<int>(ret[2])/255.f);
|
return ColourValue(boost::lexical_cast<int>(ret[0])/255.f,boost::lexical_cast<int>(ret[1])/255.f,boost::lexical_cast<int>(ret[2])/255.f);
|
||||||
}
|
}
|
||||||
void WeatherManager::setFallbackWeather(Weather& weather,const std::string& name)
|
void WeatherManager::setFallbackWeather(Weather& weather,const std::string& name)
|
||||||
{
|
{
|
||||||
std::string upper=name;
|
std::string upper=name;
|
||||||
upper[0]=toupper(name[0]);
|
upper[0]=toupper(name[0]);
|
||||||
weather.mCloudsMaximumPercent = getFallbackFloat("Weather_"+upper+"_Clouds_Maximum_Percent");
|
weather.mCloudsMaximumPercent = getFallbackFloat("Weather_"+upper+"_Clouds_Maximum_Percent");
|
||||||
weather.mTransitionDelta = getFallbackFloat("Weather_"+upper+"_Transition_Delta");
|
weather.mTransitionDelta = getFallbackFloat("Weather_"+upper+"_Transition_Delta");
|
||||||
weather.mSkySunriseColor=getFallbackColour("Weather_"+upper+"_Sky_Sunrise_Color");
|
weather.mSkySunriseColor=getFallbackColour("Weather_"+upper+"_Sky_Sunrise_Color");
|
||||||
weather.mSkyDayColor = getFallbackColour("Weather_"+upper+"_Sky_Day_Color");
|
weather.mSkyDayColor = getFallbackColour("Weather_"+upper+"_Sky_Day_Color");
|
||||||
|
@ -89,30 +89,30 @@ WeatherManager::WeatherManager(MWRender::RenderingManager* rendering,const std::
|
||||||
mTimePassed(0), mFallback(fallbackMap)
|
mTimePassed(0), mFallback(fallbackMap)
|
||||||
{
|
{
|
||||||
mRendering = rendering;
|
mRendering = rendering;
|
||||||
//Globals
|
//Globals
|
||||||
mThunderSoundID0 = getFallbackString("Weather_Thunderstorm_Thunder_Sound_ID_0");
|
mThunderSoundID0 = getFallbackString("Weather_Thunderstorm_Thunder_Sound_ID_0");
|
||||||
mThunderSoundID1 = getFallbackString("Weather_Thunderstorm_Thunder_Sound_ID_1");
|
mThunderSoundID1 = getFallbackString("Weather_Thunderstorm_Thunder_Sound_ID_1");
|
||||||
mThunderSoundID2 = getFallbackString("Weather_Thunderstorm_Thunder_Sound_ID_2");
|
mThunderSoundID2 = getFallbackString("Weather_Thunderstorm_Thunder_Sound_ID_2");
|
||||||
mThunderSoundID3 = getFallbackString("Weather_Thunderstorm_Thunder_Sound_ID_3");
|
mThunderSoundID3 = getFallbackString("Weather_Thunderstorm_Thunder_Sound_ID_3");
|
||||||
mSunriseTime = getFallbackFloat("Weather_Sunrise_Time");
|
mSunriseTime = getFallbackFloat("Weather_Sunrise_Time");
|
||||||
mSunsetTime = getFallbackFloat("Weather_Sunset_Time");
|
mSunsetTime = getFallbackFloat("Weather_Sunset_Time");
|
||||||
mSunriseDuration = getFallbackFloat("Weather_Sunrise_Duration");
|
mSunriseDuration = getFallbackFloat("Weather_Sunrise_Duration");
|
||||||
mSunsetDuration = getFallbackFloat("Weather_Sunset_Duration");
|
mSunsetDuration = getFallbackFloat("Weather_Sunset_Duration");
|
||||||
mWeatherUpdateTime = getFallbackFloat("Weather_Hours_Between_Weather_Changes");
|
mWeatherUpdateTime = getFallbackFloat("Weather_Hours_Between_Weather_Changes");
|
||||||
mThunderFrequency = getFallbackFloat("Weather_Thunderstorm_Thunder_Frequency");
|
mThunderFrequency = getFallbackFloat("Weather_Thunderstorm_Thunder_Frequency");
|
||||||
mThunderThreshold = getFallbackFloat("Weather_Thunderstorm_Thunder_Threshold");
|
mThunderThreshold = getFallbackFloat("Weather_Thunderstorm_Thunder_Threshold");
|
||||||
mThunderSoundDelay = 0.25;
|
mThunderSoundDelay = 0.25;
|
||||||
//Weather
|
//Weather
|
||||||
Weather clear;
|
Weather clear;
|
||||||
clear.mCloudTexture = "tx_sky_clear.dds";
|
clear.mCloudTexture = "tx_sky_clear.dds";
|
||||||
setFallbackWeather(clear,"clear");
|
setFallbackWeather(clear,"clear");
|
||||||
|
|
||||||
Weather cloudy;
|
Weather cloudy;
|
||||||
cloudy.mCloudTexture = "tx_sky_cloudy.dds";
|
cloudy.mCloudTexture = "tx_sky_cloudy.dds";
|
||||||
setFallbackWeather(cloudy,"cloudy");
|
setFallbackWeather(cloudy,"cloudy");
|
||||||
|
|
||||||
Weather foggy;
|
Weather foggy;
|
||||||
foggy.mCloudTexture = "tx_sky_foggy.dds";
|
foggy.mCloudTexture = "tx_sky_foggy.dds";
|
||||||
setFallbackWeather(foggy,"foggy");
|
setFallbackWeather(foggy,"foggy");
|
||||||
|
|
||||||
Weather thunderstorm;
|
Weather thunderstorm;
|
||||||
|
|
|
@ -142,10 +142,10 @@ namespace MWWorld
|
||||||
float mHour;
|
float mHour;
|
||||||
int mDay, mMonth;
|
int mDay, mMonth;
|
||||||
std::map<std::string,std::string> mFallback;
|
std::map<std::string,std::string> mFallback;
|
||||||
std::string getFallback (const std::string& key);
|
std::string getFallback (const std::string& key) const;
|
||||||
std::string getFallbackString(const std::string& fall);
|
std::string getFallbackString(const std::string& fall) const;
|
||||||
float getFallbackFloat(const std::string& fall);
|
float getFallbackFloat(const std::string& fall) const;
|
||||||
Ogre::ColourValue getFallbackColour(const std::string& fall);
|
Ogre::ColourValue getFallbackColour(const std::string& fall) const;
|
||||||
void setFallbackWeather(Weather& weather,const std::string& name);
|
void setFallbackWeather(Weather& weather,const std::string& name);
|
||||||
MWRender::RenderingManager* mRendering;
|
MWRender::RenderingManager* mRendering;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue