1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-16 18:19:55 +00:00

Fixes #1240: Don't hardcode drowning time

This commit is contained in:
scrawl 2014-04-27 04:27:26 +02:00
parent 04964595ef
commit e8210c92c6
6 changed files with 17 additions and 12 deletions

View file

@ -156,8 +156,9 @@ namespace MWBase
virtual void setValue (const std::string& id, int value) = 0;
/// Set time left for the player to start drowning (update the drowning bar)
/// @param time value from [0,20]
virtual void setDrowningTimeLeft (float time) =0;
/// @param time time left to start drowning
/// @param maxTime how long we can be underwater (in total) until drowning starts
virtual void setDrowningTimeLeft (float time, float maxTime) = 0;
virtual void setPlayerClass (const ESM::Class &class_) = 0;
///< set current class of player

View file

@ -203,9 +203,9 @@ namespace MWGui
}
}
void HUD::setDrowningTimeLeft(float time)
void HUD::setDrowningTimeLeft(float time, float maxTime)
{
size_t progress = time/20.0*200.0;
size_t progress = time/maxTime*200.0;
mDrowning->setProgressPosition(progress);
bool isDrowning = (progress == 0);

View file

@ -22,8 +22,9 @@ namespace MWGui
void setBatchCount(unsigned int count);
/// Set time left for the player to start drowning
/// @param time value from [0,20]
void setDrowningTimeLeft(float time);
/// @param time time left to start drowning
/// @param maxTime how long we can be underwater (in total) until drowning starts
void setDrowningTimeLeft(float time, float maxTime);
void setDrowningBarVisible(bool visible);
void setHmsVisible(bool visible);

View file

@ -625,9 +625,9 @@ namespace MWGui
mStatsWindow->setValue (id, value);
}
void WindowManager::setDrowningTimeLeft (float time)
void WindowManager::setDrowningTimeLeft (float time, float maxTime)
{
mHud->setDrowningTimeLeft(time);
mHud->setDrowningTimeLeft(time, maxTime);
}
void WindowManager::setPlayerClass (const ESM::Class &class_)

View file

@ -166,8 +166,9 @@ namespace MWGui
virtual void setValue (const std::string& id, int value);
/// Set time left for the player to start drowning (update the drowning bar)
/// @param time value from [0,20]
virtual void setDrowningTimeLeft (float time);
/// @param time time left to start drowning
/// @param maxTime how long we can be underwater (in total) until drowning starts
virtual void setDrowningTimeLeft (float time, float maxTime);
virtual void setPlayerClass (const ESM::Class &class_); ///< set current class of player
virtual void configureSkills (const SkillList& major, const SkillList& minor); ///< configure skill groups, each set contains the skill ID for that group.

View file

@ -298,13 +298,15 @@ namespace MWMechanics
if(stats.getTimeToStartDrowning() != mWatchedStats.getTimeToStartDrowning())
{
const float fHoldBreathTime = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>()
.find("fHoldBreathTime")->getFloat();
mWatchedStats.setTimeToStartDrowning(stats.getTimeToStartDrowning());
if(stats.getTimeToStartDrowning() >= 20.0f)
if(stats.getTimeToStartDrowning() >= fHoldBreathTime)
winMgr->setDrowningBarVisibility(false);
else
{
winMgr->setDrowningBarVisibility(true);
winMgr->setDrowningTimeLeft(stats.getTimeToStartDrowning());
winMgr->setDrowningTimeLeft(stats.getTimeToStartDrowning(), fHoldBreathTime);
}
}