mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-20 16:53:55 +00:00
Type of weather changed from string to enum.
This commit is contained in:
parent
9c6fa29938
commit
04d90b4c47
5 changed files with 128 additions and 127 deletions
|
@ -191,7 +191,7 @@ namespace MWBase
|
||||||
virtual bool toggleSky() = 0;
|
virtual bool toggleSky() = 0;
|
||||||
///< \return Resulting mode
|
///< \return Resulting mode
|
||||||
|
|
||||||
virtual void changeWeather(const std::string& region, unsigned int id) = 0;
|
virtual void changeWeather(const std::string& region, int id) = 0;
|
||||||
|
|
||||||
virtual int getCurrentWeather() const = 0;
|
virtual int getCurrentWeather() const = 0;
|
||||||
|
|
||||||
|
|
|
@ -31,35 +31,62 @@ namespace
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WeatherManager::setFallbackWeather(Weather& weather,const std::string& name)
|
std::string Weather::weatherTypeToStr(Weather::Type type)
|
||||||
{
|
{
|
||||||
std::string upper=name;
|
switch (type) {
|
||||||
upper[0]=toupper(name[0]);
|
case Type_Clear:
|
||||||
weather.mCloudsMaximumPercent = mFallback->getFallbackFloat("Weather_"+upper+"_Clouds_Maximum_Percent");
|
return "Clear";
|
||||||
weather.mTransitionDelta = mFallback->getFallbackFloat("Weather_"+upper+"_Transition_Delta");
|
case Type_Cloudy:
|
||||||
weather.mSkySunriseColor=mFallback->getFallbackColour("Weather_"+upper+"_Sky_Sunrise_Color");
|
return "Cloudy";
|
||||||
weather.mSkyDayColor = mFallback->getFallbackColour("Weather_"+upper+"_Sky_Day_Color");
|
case Type_Foggy:
|
||||||
weather.mSkySunsetColor = mFallback->getFallbackColour("Weather_"+upper+"_Sky_Sunset_Color");
|
return "Foggy";
|
||||||
weather.mSkyNightColor = mFallback->getFallbackColour("Weather_"+upper+"_Sky_Night_Color");
|
case Type_Overcast:
|
||||||
weather.mFogSunriseColor = mFallback->getFallbackColour("Weather_"+upper+"_Fog_Sunrise_Color");
|
return "Overcast";
|
||||||
weather.mFogDayColor = mFallback->getFallbackColour("Weather_"+upper+"_Fog_Day_Color");
|
case Type_Rain:
|
||||||
weather.mFogSunsetColor = mFallback->getFallbackColour("Weather_"+upper+"_Fog_Sunset_Color");
|
return "Rain";
|
||||||
weather.mFogNightColor = mFallback->getFallbackColour("Weather_"+upper+"_Fog_Night_Color");
|
case Type_Thunderstorm:
|
||||||
weather.mAmbientSunriseColor = mFallback->getFallbackColour("Weather_"+upper+"_Ambient_Sunrise_Color");
|
return "Thunderstorm";
|
||||||
weather.mAmbientDayColor = mFallback->getFallbackColour("Weather_"+upper+"_Ambient_Day_Color");
|
case Type_Ashstorm:
|
||||||
weather.mAmbientSunsetColor = mFallback->getFallbackColour("Weather_"+upper+"_Ambient_Sunset_Color");
|
return "Ashstorm";
|
||||||
weather.mAmbientNightColor = mFallback->getFallbackColour("Weather_"+upper+"_Ambient_Night_Color");
|
case Type_Blight:
|
||||||
weather.mSunSunriseColor = mFallback->getFallbackColour("Weather_"+upper+"_Sun_Sunrise_Color");
|
return "Blight";
|
||||||
weather.mSunDayColor = mFallback->getFallbackColour("Weather_"+upper+"_Sun_Day_Color");
|
case Type_Snow:
|
||||||
weather.mSunSunsetColor = mFallback->getFallbackColour("Weather_"+upper+"_Sun_Sunset_Color");
|
return "Snow";
|
||||||
weather.mSunNightColor = mFallback->getFallbackColour("Weather_"+upper+"_Sun_Night_Color");
|
case Type_Blizzard:
|
||||||
weather.mSunDiscSunsetColor = mFallback->getFallbackColour("Weather_"+upper+"_Sun_Disc_Sunset_Color");
|
return "Blizzard";
|
||||||
weather.mLandFogDayDepth = mFallback->getFallbackFloat("Weather_"+upper+"_Land_Fog_Day_Depth");
|
default: // Type_Unknown
|
||||||
weather.mLandFogNightDepth = mFallback->getFallbackFloat("Weather_"+upper+"_Land_Fog_Night_Depth");
|
return "";
|
||||||
weather.mWindSpeed = mFallback->getFallbackFloat("Weather_"+upper+"_Wind_Speed");
|
}
|
||||||
weather.mCloudSpeed = mFallback->getFallbackFloat("Weather_"+upper+"_Cloud_Speed");
|
}
|
||||||
weather.mGlareView = mFallback->getFallbackFloat("Weather_"+upper+"_Glare_View");
|
|
||||||
mWeatherSettings[name] = weather;
|
void WeatherManager::setFallbackWeather(Weather& weather, Weather::Type type)
|
||||||
|
{
|
||||||
|
const std::string weatherName = Weather::weatherTypeToStr(type);
|
||||||
|
weather.mCloudsMaximumPercent = mFallback->getFallbackFloat("Weather_"+weatherName+"_Clouds_Maximum_Percent");
|
||||||
|
weather.mTransitionDelta = mFallback->getFallbackFloat("Weather_"+weatherName+"_Transition_Delta");
|
||||||
|
weather.mSkySunriseColor= mFallback->getFallbackColour("Weather_"+weatherName+"_Sky_Sunrise_Color");
|
||||||
|
weather.mSkyDayColor = mFallback->getFallbackColour("Weather_"+weatherName+"_Sky_Day_Color");
|
||||||
|
weather.mSkySunsetColor = mFallback->getFallbackColour("Weather_"+weatherName+"_Sky_Sunset_Color");
|
||||||
|
weather.mSkyNightColor = mFallback->getFallbackColour("Weather_"+weatherName+"_Sky_Night_Color");
|
||||||
|
weather.mFogSunriseColor = mFallback->getFallbackColour("Weather_"+weatherName+"_Fog_Sunrise_Color");
|
||||||
|
weather.mFogDayColor = mFallback->getFallbackColour("Weather_"+weatherName+"_Fog_Day_Color");
|
||||||
|
weather.mFogSunsetColor = mFallback->getFallbackColour("Weather_"+weatherName+"_Fog_Sunset_Color");
|
||||||
|
weather.mFogNightColor = mFallback->getFallbackColour("Weather_"+weatherName+"_Fog_Night_Color");
|
||||||
|
weather.mAmbientSunriseColor = mFallback->getFallbackColour("Weather_"+weatherName+"_Ambient_Sunrise_Color");
|
||||||
|
weather.mAmbientDayColor = mFallback->getFallbackColour("Weather_"+weatherName+"_Ambient_Day_Color");
|
||||||
|
weather.mAmbientSunsetColor = mFallback->getFallbackColour("Weather_"+weatherName+"_Ambient_Sunset_Color");
|
||||||
|
weather.mAmbientNightColor = mFallback->getFallbackColour("Weather_"+weatherName+"_Ambient_Night_Color");
|
||||||
|
weather.mSunSunriseColor = mFallback->getFallbackColour("Weather_"+weatherName+"_Sun_Sunrise_Color");
|
||||||
|
weather.mSunDayColor = mFallback->getFallbackColour("Weather_"+weatherName+"_Sun_Day_Color");
|
||||||
|
weather.mSunSunsetColor = mFallback->getFallbackColour("Weather_"+weatherName+"_Sun_Sunset_Color");
|
||||||
|
weather.mSunNightColor = mFallback->getFallbackColour("Weather_"+weatherName+"_Sun_Night_Color");
|
||||||
|
weather.mSunDiscSunsetColor = mFallback->getFallbackColour("Weather_"+weatherName+"_Sun_Disc_Sunset_Color");
|
||||||
|
weather.mLandFogDayDepth = mFallback->getFallbackFloat("Weather_"+weatherName+"_Land_Fog_Day_Depth");
|
||||||
|
weather.mLandFogNightDepth = mFallback->getFallbackFloat("Weather_"+weatherName+"_Land_Fog_Night_Depth");
|
||||||
|
weather.mWindSpeed = mFallback->getFallbackFloat("Weather_"+weatherName+"_Wind_Speed");
|
||||||
|
weather.mCloudSpeed = mFallback->getFallbackFloat("Weather_"+weatherName+"_Cloud_Speed");
|
||||||
|
weather.mGlareView = mFallback->getFallbackFloat("Weather_"+weatherName+"_Glare_View");
|
||||||
|
mWeatherSettings[type] = weather;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -91,7 +118,7 @@ float WeatherManager::calculateAngleFade (const std::string& moonName, float ang
|
||||||
}
|
}
|
||||||
|
|
||||||
WeatherManager::WeatherManager(MWRender::RenderingManager* rendering,MWWorld::Fallback* fallback) :
|
WeatherManager::WeatherManager(MWRender::RenderingManager* rendering,MWWorld::Fallback* fallback) :
|
||||||
mHour(14), mCurrentWeather("clear"), mFirstUpdate(true), mWeatherUpdateTime(0),
|
mHour(14), mCurrentWeather(Weather::Type_Clear), mFirstUpdate(true), mWeatherUpdateTime(0),
|
||||||
mThunderFlash(0), mThunderChance(0), mThunderChanceNeeded(50), mThunderSoundDelay(0),
|
mThunderFlash(0), mThunderChance(0), mThunderChanceNeeded(50), mThunderSoundDelay(0),
|
||||||
mRemainingTransitionTime(0), mMonth(0), mDay(0),
|
mRemainingTransitionTime(0), mMonth(0), mDay(0),
|
||||||
mTimePassed(0), mFallback(fallback), mWindSpeed(0.f), mRendering(rendering)
|
mTimePassed(0), mFallback(fallback), mWindSpeed(0.f), mRendering(rendering)
|
||||||
|
@ -125,53 +152,53 @@ WeatherManager::WeatherManager(MWRender::RenderingManager* rendering,MWWorld::Fa
|
||||||
//Weather
|
//Weather
|
||||||
Weather clear;
|
Weather clear;
|
||||||
clear.mCloudTexture = "tx_sky_clear.dds";
|
clear.mCloudTexture = "tx_sky_clear.dds";
|
||||||
setFallbackWeather(clear,"clear");
|
setFallbackWeather(clear, Weather::Type_Clear);
|
||||||
|
|
||||||
Weather cloudy;
|
Weather cloudy;
|
||||||
cloudy.mCloudTexture = "tx_sky_cloudy.dds";
|
cloudy.mCloudTexture = "tx_sky_cloudy.dds";
|
||||||
setFallbackWeather(cloudy,"cloudy");
|
setFallbackWeather(cloudy, Weather::Type_Cloudy);
|
||||||
|
|
||||||
Weather foggy;
|
Weather foggy;
|
||||||
foggy.mCloudTexture = "tx_sky_foggy.dds";
|
foggy.mCloudTexture = "tx_sky_foggy.dds";
|
||||||
setFallbackWeather(foggy,"foggy");
|
setFallbackWeather(foggy, Weather::Type_Foggy);
|
||||||
|
|
||||||
Weather thunderstorm;
|
Weather thunderstorm;
|
||||||
thunderstorm.mCloudTexture = "tx_sky_thunder.dds";
|
thunderstorm.mCloudTexture = "tx_sky_thunder.dds";
|
||||||
thunderstorm.mRainLoopSoundID = "rain heavy";
|
thunderstorm.mRainLoopSoundID = "rain heavy";
|
||||||
setFallbackWeather(thunderstorm,"thunderstorm");
|
setFallbackWeather(thunderstorm, Weather::Type_Thunderstorm);
|
||||||
|
|
||||||
Weather rain;
|
Weather rain;
|
||||||
rain.mCloudTexture = "tx_sky_rainy.dds";
|
rain.mCloudTexture = "tx_sky_rainy.dds";
|
||||||
rain.mRainLoopSoundID = "rain";
|
rain.mRainLoopSoundID = "rain";
|
||||||
setFallbackWeather(rain,"rain");
|
setFallbackWeather(rain, Weather::Type_Rain);
|
||||||
|
|
||||||
Weather overcast;
|
Weather overcast;
|
||||||
overcast.mCloudTexture = "tx_sky_overcast.dds";
|
overcast.mCloudTexture = "tx_sky_overcast.dds";
|
||||||
setFallbackWeather(overcast,"overcast");
|
setFallbackWeather(overcast, Weather::Type_Overcast);
|
||||||
|
|
||||||
Weather ashstorm;
|
Weather ashstorm;
|
||||||
ashstorm.mCloudTexture = "tx_sky_ashstorm.dds";
|
ashstorm.mCloudTexture = "tx_sky_ashstorm.dds";
|
||||||
ashstorm.mAmbientLoopSoundID = "ashstorm";
|
ashstorm.mAmbientLoopSoundID = "ashstorm";
|
||||||
setFallbackWeather(ashstorm,"ashstorm");
|
setFallbackWeather(ashstorm, Weather::Type_Ashstorm);
|
||||||
|
|
||||||
Weather blight;
|
Weather blight;
|
||||||
blight.mCloudTexture = "tx_sky_blight.dds";
|
blight.mCloudTexture = "tx_sky_blight.dds";
|
||||||
blight.mAmbientLoopSoundID = "blight";
|
blight.mAmbientLoopSoundID = "blight";
|
||||||
setFallbackWeather(blight,"blight");
|
setFallbackWeather(blight, Weather::Type_Blight);
|
||||||
|
|
||||||
Weather snow;
|
Weather snow;
|
||||||
snow.mCloudTexture = "tx_bm_sky_snow.dds";
|
snow.mCloudTexture = "tx_bm_sky_snow.dds";
|
||||||
setFallbackWeather(snow, "snow");
|
setFallbackWeather(snow, Weather::Type_Snow);
|
||||||
|
|
||||||
Weather blizzard;
|
Weather blizzard;
|
||||||
blizzard.mCloudTexture = "tx_bm_sky_blizzard.dds";
|
blizzard.mCloudTexture = "tx_bm_sky_blizzard.dds";
|
||||||
blizzard.mAmbientLoopSoundID = "BM Blizzard";
|
blizzard.mAmbientLoopSoundID = "BM Blizzard";
|
||||||
setFallbackWeather(blizzard,"blizzard");
|
setFallbackWeather(blizzard, Weather::Type_Blizzard);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WeatherManager::setWeather(const String& weather, bool instant)
|
void WeatherManager::setWeather(Weather::Type weatherType, bool instant)
|
||||||
{
|
{
|
||||||
if (weather == mCurrentWeather && mNextWeather == "")
|
if (weatherType == mCurrentWeather && mNextWeather == Weather::Type_Unknown)
|
||||||
{
|
{
|
||||||
mFirstUpdate = false;
|
mFirstUpdate = false;
|
||||||
return;
|
return;
|
||||||
|
@ -179,27 +206,27 @@ void WeatherManager::setWeather(const String& weather, bool instant)
|
||||||
|
|
||||||
if (instant || mFirstUpdate)
|
if (instant || mFirstUpdate)
|
||||||
{
|
{
|
||||||
mNextWeather = "";
|
mNextWeather = Weather::Type_Unknown;
|
||||||
mCurrentWeather = weather;
|
mCurrentWeather = weatherType;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (mNextWeather != "")
|
if (mNextWeather != Weather::Type_Unknown)
|
||||||
{
|
{
|
||||||
// transition more than 50% finished?
|
// transition more than 50% finished?
|
||||||
if (mRemainingTransitionTime/(mWeatherSettings[mCurrentWeather].mTransitionDelta * 24.f * 3600) <= 0.5)
|
if (mRemainingTransitionTime/(mWeatherSettings[mCurrentWeather].mTransitionDelta * 24.f * 3600) <= 0.5)
|
||||||
mCurrentWeather = mNextWeather;
|
mCurrentWeather = mNextWeather;
|
||||||
}
|
}
|
||||||
|
|
||||||
mNextWeather = weather;
|
mNextWeather = weatherType;
|
||||||
mRemainingTransitionTime = mWeatherSettings[mCurrentWeather].mTransitionDelta * 24.f * 3600;
|
mRemainingTransitionTime = mWeatherSettings[mCurrentWeather].mTransitionDelta * 24.f * 3600;
|
||||||
}
|
}
|
||||||
mFirstUpdate = false;
|
mFirstUpdate = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
WeatherResult WeatherManager::getResult(const String& weather)
|
WeatherResult WeatherManager::getResult(Weather::Type weatherType)
|
||||||
{
|
{
|
||||||
const Weather& current = mWeatherSettings[weather];
|
const Weather& current = mWeatherSettings[weatherType];
|
||||||
WeatherResult result;
|
WeatherResult result;
|
||||||
|
|
||||||
result.mCloudTexture = current.mCloudTexture;
|
result.mCloudTexture = current.mCloudTexture;
|
||||||
|
@ -336,10 +363,10 @@ void WeatherManager::update(float duration)
|
||||||
mCurrentRegion = regionstr;
|
mCurrentRegion = regionstr;
|
||||||
mWeatherUpdateTime = mHoursBetweenWeatherChanges * 3600;
|
mWeatherUpdateTime = mHoursBetweenWeatherChanges * 3600;
|
||||||
|
|
||||||
std::string weather = "clear";
|
Weather::Type weatherType = Weather::Type_Clear;
|
||||||
|
|
||||||
if (mRegionOverrides.find(regionstr) != mRegionOverrides.end())
|
if (mRegionOverrides.find(regionstr) != mRegionOverrides.end())
|
||||||
weather = mRegionOverrides[regionstr];
|
weatherType = mRegionOverrides[regionstr];
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// get weather probabilities for the current region
|
// get weather probabilities for the current region
|
||||||
|
@ -365,44 +392,44 @@ void WeatherManager::update(float duration)
|
||||||
float random = ((rand()%100)/100.f) * total;
|
float random = ((rand()%100)/100.f) * total;
|
||||||
|
|
||||||
if (random >= snow+blight+ash+thunder+rain+overcast+foggy+cloudy+clear)
|
if (random >= snow+blight+ash+thunder+rain+overcast+foggy+cloudy+clear)
|
||||||
weather = "blizzard";
|
weatherType = Weather::Type_Blizzard;
|
||||||
else if (random >= blight+ash+thunder+rain+overcast+foggy+cloudy+clear)
|
else if (random >= blight+ash+thunder+rain+overcast+foggy+cloudy+clear)
|
||||||
weather = "snow";
|
weatherType = Weather::Type_Snow;
|
||||||
else if (random >= ash+thunder+rain+overcast+foggy+cloudy+clear)
|
else if (random >= ash+thunder+rain+overcast+foggy+cloudy+clear)
|
||||||
weather = "blight";
|
weatherType = Weather::Type_Blight;
|
||||||
else if (random >= thunder+rain+overcast+foggy+cloudy+clear)
|
else if (random >= thunder+rain+overcast+foggy+cloudy+clear)
|
||||||
weather = "ashstorm";
|
weatherType = Weather::Type_Ashstorm;
|
||||||
else if (random >= rain+overcast+foggy+cloudy+clear)
|
else if (random >= rain+overcast+foggy+cloudy+clear)
|
||||||
weather = "thunderstorm";
|
weatherType = Weather::Type_Thunderstorm;
|
||||||
else if (random >= overcast+foggy+cloudy+clear)
|
else if (random >= overcast+foggy+cloudy+clear)
|
||||||
weather = "rain";
|
weatherType = Weather::Type_Rain;
|
||||||
else if (random >= foggy+cloudy+clear)
|
else if (random >= foggy+cloudy+clear)
|
||||||
weather = "overcast";
|
weatherType = Weather::Type_Overcast;
|
||||||
else if (random >= cloudy+clear)
|
else if (random >= cloudy+clear)
|
||||||
weather = "foggy";
|
weatherType = Weather::Type_Foggy;
|
||||||
else if (random >= clear)
|
else if (random >= clear)
|
||||||
weather = "cloudy";
|
weatherType = Weather::Type_Cloudy;
|
||||||
else
|
else
|
||||||
weather = "clear";
|
weatherType = Weather::Type_Clear;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setWeather(weather, false);
|
setWeather(weatherType, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
WeatherResult result;
|
WeatherResult result;
|
||||||
|
|
||||||
if (mNextWeather != "")
|
if (mNextWeather != Weather::Type_Unknown)
|
||||||
{
|
{
|
||||||
mRemainingTransitionTime -= timePassed;
|
mRemainingTransitionTime -= timePassed;
|
||||||
if (mRemainingTransitionTime < 0)
|
if (mRemainingTransitionTime < 0)
|
||||||
{
|
{
|
||||||
mCurrentWeather = mNextWeather;
|
mCurrentWeather = mNextWeather;
|
||||||
mNextWeather = "";
|
mNextWeather = Weather::Type_Unknown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mNextWeather != "")
|
if (mNextWeather != Weather::Type_Unknown)
|
||||||
result = transition(1 - (mRemainingTransitionTime / (mWeatherSettings[mCurrentWeather].mTransitionDelta * 24.f * 3600)));
|
result = transition(1 - (mRemainingTransitionTime / (mWeatherSettings[mCurrentWeather].mTransitionDelta * 24.f * 3600)));
|
||||||
else
|
else
|
||||||
result = getResult(mCurrentWeather);
|
result = getResult(mCurrentWeather);
|
||||||
|
@ -494,7 +521,7 @@ void WeatherManager::update(float duration)
|
||||||
mRendering->getSkyManager()->secundaDisable();
|
mRendering->getSkyManager()->secundaDisable();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mCurrentWeather == "thunderstorm" && mNextWeather == "" && exterior)
|
if (mCurrentWeather == Weather::Type_Thunderstorm && mNextWeather == Weather::Type_Unknown && exterior)
|
||||||
{
|
{
|
||||||
if (mThunderFlash > 0)
|
if (mThunderFlash > 0)
|
||||||
{
|
{
|
||||||
|
@ -555,7 +582,7 @@ void WeatherManager::update(float duration)
|
||||||
}
|
}
|
||||||
|
|
||||||
// play sounds
|
// play sounds
|
||||||
std::string ambientSnd = (mNextWeather == "" ? mWeatherSettings[mCurrentWeather].mAmbientLoopSoundID : "");
|
std::string ambientSnd = (mNextWeather == Weather::Type_Unknown ? mWeatherSettings[mCurrentWeather].mAmbientLoopSoundID : "");
|
||||||
if (!exterior) ambientSnd = "";
|
if (!exterior) ambientSnd = "";
|
||||||
if (ambientSnd != "")
|
if (ambientSnd != "")
|
||||||
{
|
{
|
||||||
|
@ -566,7 +593,7 @@ void WeatherManager::update(float duration)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string rainSnd = (mNextWeather == "" ? mWeatherSettings[mCurrentWeather].mRainLoopSoundID : "");
|
std::string rainSnd = (mNextWeather == Weather::Type_Unknown ? mWeatherSettings[mCurrentWeather].mRainLoopSoundID : "");
|
||||||
if (!exterior) rainSnd = "";
|
if (!exterior) rainSnd = "";
|
||||||
if (rainSnd != "")
|
if (rainSnd != "")
|
||||||
{
|
{
|
||||||
|
@ -605,66 +632,23 @@ void WeatherManager::setDate(const int day, const int month)
|
||||||
unsigned int WeatherManager::getWeatherID() const
|
unsigned int WeatherManager::getWeatherID() const
|
||||||
{
|
{
|
||||||
// Source: http://www.uesp.net/wiki/Tes3Mod:GetCurrentWeather
|
// Source: http://www.uesp.net/wiki/Tes3Mod:GetCurrentWeather
|
||||||
|
return mCurrentWeather;
|
||||||
if (mCurrentWeather == "clear")
|
|
||||||
return 0;
|
|
||||||
else if (mCurrentWeather == "cloudy")
|
|
||||||
return 1;
|
|
||||||
else if (mCurrentWeather == "foggy")
|
|
||||||
return 2;
|
|
||||||
else if (mCurrentWeather == "overcast")
|
|
||||||
return 3;
|
|
||||||
else if (mCurrentWeather == "rain")
|
|
||||||
return 4;
|
|
||||||
else if (mCurrentWeather == "thunderstorm")
|
|
||||||
return 5;
|
|
||||||
else if (mCurrentWeather == "ashstorm")
|
|
||||||
return 6;
|
|
||||||
else if (mCurrentWeather == "blight")
|
|
||||||
return 7;
|
|
||||||
else if (mCurrentWeather == "snow")
|
|
||||||
return 8;
|
|
||||||
else if (mCurrentWeather == "blizzard")
|
|
||||||
return 9;
|
|
||||||
|
|
||||||
else
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WeatherManager::changeWeather(const std::string& region, const unsigned int id)
|
void WeatherManager::changeWeather(const std::string& region, const int id)
|
||||||
{
|
{
|
||||||
// make sure this region exists
|
// make sure this region exists
|
||||||
MWBase::Environment::get().getWorld()->getStore().get<ESM::Region>().find(region);
|
MWBase::Environment::get().getWorld()->getStore().get<ESM::Region>().find(region);
|
||||||
|
|
||||||
std::string weather;
|
Weather::Type weatherType = Weather::Type_Clear;
|
||||||
if (id==0)
|
if (id >= Weather::Type_Clear && id < Weather::Type_Unknown)
|
||||||
weather = "clear";
|
weatherType = (Weather::Type)id;
|
||||||
else if (id==1)
|
|
||||||
weather = "cloudy";
|
|
||||||
else if (id==2)
|
|
||||||
weather = "foggy";
|
|
||||||
else if (id==3)
|
|
||||||
weather = "overcast";
|
|
||||||
else if (id==4)
|
|
||||||
weather = "rain";
|
|
||||||
else if (id==5)
|
|
||||||
weather = "thunderstorm";
|
|
||||||
else if (id==6)
|
|
||||||
weather = "ashstorm";
|
|
||||||
else if (id==7)
|
|
||||||
weather = "blight";
|
|
||||||
else if (id==8)
|
|
||||||
weather = "snow";
|
|
||||||
else if (id==9)
|
|
||||||
weather = "blizzard";
|
|
||||||
else
|
|
||||||
weather = "clear";
|
|
||||||
|
|
||||||
mRegionOverrides[Misc::StringUtils::lowerCase(region)] = weather;
|
mRegionOverrides[Misc::StringUtils::lowerCase(region)] = weatherType;
|
||||||
|
|
||||||
std::string playerRegion = MWBase::Environment::get().getWorld()->getPlayer().getPlayer().getCell()->mCell->mRegion;
|
std::string playerRegion = MWBase::Environment::get().getWorld()->getPlayer().getPlayer().getCell()->mCell->mRegion;
|
||||||
if (Misc::StringUtils::ciEqual(region, playerRegion))
|
if (Misc::StringUtils::ciEqual(region, playerRegion))
|
||||||
setWeather(weather);
|
setWeather(weatherType);
|
||||||
}
|
}
|
||||||
|
|
||||||
float WeatherManager::getWindSpeed() const
|
float WeatherManager::getWindSpeed() const
|
||||||
|
|
|
@ -50,6 +50,21 @@ namespace MWWorld
|
||||||
/// Defines a single weather setting (according to INI)
|
/// Defines a single weather setting (according to INI)
|
||||||
struct Weather
|
struct Weather
|
||||||
{
|
{
|
||||||
|
enum Type
|
||||||
|
{
|
||||||
|
Type_Clear = 0,
|
||||||
|
Type_Cloudy,
|
||||||
|
Type_Foggy,
|
||||||
|
Type_Overcast,
|
||||||
|
Type_Rain,
|
||||||
|
Type_Thunderstorm,
|
||||||
|
Type_Ashstorm,
|
||||||
|
Type_Blight,
|
||||||
|
Type_Snow,
|
||||||
|
Type_Blizzard,
|
||||||
|
Type_Unknown
|
||||||
|
};
|
||||||
|
|
||||||
Ogre::String mCloudTexture;
|
Ogre::String mCloudTexture;
|
||||||
|
|
||||||
// Sky (atmosphere) colors
|
// Sky (atmosphere) colors
|
||||||
|
@ -106,6 +121,8 @@ namespace MWWorld
|
||||||
Ogre::String mRainLoopSoundID;
|
Ogre::String mRainLoopSoundID;
|
||||||
|
|
||||||
/// \todo disease chance
|
/// \todo disease chance
|
||||||
|
|
||||||
|
static std::string weatherTypeToStr(Weather::Type type);
|
||||||
};
|
};
|
||||||
|
|
||||||
///
|
///
|
||||||
|
@ -121,7 +138,7 @@ namespace MWWorld
|
||||||
* @param region that should be changed
|
* @param region that should be changed
|
||||||
* @param ID of the weather setting to shift to
|
* @param ID of the weather setting to shift to
|
||||||
*/
|
*/
|
||||||
void changeWeather(const std::string& region, const unsigned int id);
|
void changeWeather(const std::string& region, const int id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Per-frame update
|
* Per-frame update
|
||||||
|
@ -147,17 +164,17 @@ namespace MWWorld
|
||||||
int mDay, mMonth;
|
int mDay, mMonth;
|
||||||
float mWindSpeed;
|
float mWindSpeed;
|
||||||
MWWorld::Fallback* mFallback;
|
MWWorld::Fallback* mFallback;
|
||||||
void setFallbackWeather(Weather& weather,const std::string& name);
|
void setFallbackWeather(Weather& weather, Weather::Type type);
|
||||||
MWRender::RenderingManager* mRendering;
|
MWRender::RenderingManager* mRendering;
|
||||||
|
|
||||||
std::map<Ogre::String, Weather> mWeatherSettings;
|
std::map<Weather::Type, Weather> mWeatherSettings;
|
||||||
|
|
||||||
std::map<std::string, std::string> mRegionOverrides;
|
std::map<std::string, Weather::Type> mRegionOverrides;
|
||||||
|
|
||||||
std::vector<std::string> mSoundsPlaying;
|
std::vector<std::string> mSoundsPlaying;
|
||||||
|
|
||||||
Ogre::String mCurrentWeather;
|
Weather::Type mCurrentWeather;
|
||||||
Ogre::String mNextWeather;
|
Weather::Type mNextWeather;
|
||||||
|
|
||||||
std::string mCurrentRegion;
|
std::string mCurrentRegion;
|
||||||
|
|
||||||
|
@ -172,12 +189,12 @@ namespace MWWorld
|
||||||
double mTimePassed; // time passed since last update
|
double mTimePassed; // time passed since last update
|
||||||
|
|
||||||
WeatherResult transition(const float factor);
|
WeatherResult transition(const float factor);
|
||||||
WeatherResult getResult(const Ogre::String& weather);
|
WeatherResult getResult(Weather::Type weatherType);
|
||||||
|
|
||||||
float calculateHourFade (const std::string& moonName) const;
|
float calculateHourFade (const std::string& moonName) const;
|
||||||
float calculateAngleFade (const std::string& moonName, float angle) const;
|
float calculateAngleFade (const std::string& moonName, float angle) const;
|
||||||
|
|
||||||
void setWeather(const Ogre::String& weather, bool instant=false);
|
void setWeather(Weather::Type weatherType, bool instant=false);
|
||||||
float mSunriseTime;
|
float mSunriseTime;
|
||||||
float mSunsetTime;
|
float mSunsetTime;
|
||||||
float mSunriseDuration;
|
float mSunriseDuration;
|
||||||
|
|
|
@ -1371,7 +1371,7 @@ namespace MWWorld
|
||||||
return mWeatherManager->getWeatherID();
|
return mWeatherManager->getWeatherID();
|
||||||
}
|
}
|
||||||
|
|
||||||
void World::changeWeather(const std::string& region, const unsigned int id)
|
void World::changeWeather(const std::string& region, const int id)
|
||||||
{
|
{
|
||||||
mWeatherManager->changeWeather(region, id);
|
mWeatherManager->changeWeather(region, id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -225,7 +225,7 @@ namespace MWWorld
|
||||||
virtual bool toggleSky();
|
virtual bool toggleSky();
|
||||||
///< \return Resulting mode
|
///< \return Resulting mode
|
||||||
|
|
||||||
virtual void changeWeather (const std::string& region, unsigned int id);
|
virtual void changeWeather (const std::string& region, int id);
|
||||||
|
|
||||||
virtual int getCurrentWeather() const;
|
virtual int getCurrentWeather() const;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue