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:
parent
04964595ef
commit
e8210c92c6
6 changed files with 17 additions and 12 deletions
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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_)
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue