mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-29 09:15:33 +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;
|
virtual void setValue (const std::string& id, int value) = 0;
|
||||||
|
|
||||||
/// Set time left for the player to start drowning (update the drowning bar)
|
/// Set time left for the player to start drowning (update the drowning bar)
|
||||||
/// @param time value from [0,20]
|
/// @param time time left to start drowning
|
||||||
virtual void setDrowningTimeLeft (float time) =0;
|
/// @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;
|
virtual void setPlayerClass (const ESM::Class &class_) = 0;
|
||||||
///< set current class of player
|
///< 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);
|
mDrowning->setProgressPosition(progress);
|
||||||
|
|
||||||
bool isDrowning = (progress == 0);
|
bool isDrowning = (progress == 0);
|
||||||
|
|
|
@ -22,8 +22,9 @@ namespace MWGui
|
||||||
void setBatchCount(unsigned int count);
|
void setBatchCount(unsigned int count);
|
||||||
|
|
||||||
/// Set time left for the player to start drowning
|
/// Set time left for the player to start drowning
|
||||||
/// @param time value from [0,20]
|
/// @param time time left to start drowning
|
||||||
void setDrowningTimeLeft(float time);
|
/// @param maxTime how long we can be underwater (in total) until drowning starts
|
||||||
|
void setDrowningTimeLeft(float time, float maxTime);
|
||||||
void setDrowningBarVisible(bool visible);
|
void setDrowningBarVisible(bool visible);
|
||||||
|
|
||||||
void setHmsVisible(bool visible);
|
void setHmsVisible(bool visible);
|
||||||
|
|
|
@ -625,9 +625,9 @@ namespace MWGui
|
||||||
mStatsWindow->setValue (id, value);
|
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_)
|
void WindowManager::setPlayerClass (const ESM::Class &class_)
|
||||||
|
|
|
@ -166,8 +166,9 @@ namespace MWGui
|
||||||
virtual void setValue (const std::string& id, int value);
|
virtual void setValue (const std::string& id, int value);
|
||||||
|
|
||||||
/// Set time left for the player to start drowning (update the drowning bar)
|
/// Set time left for the player to start drowning (update the drowning bar)
|
||||||
/// @param time value from [0,20]
|
/// @param time time left to start drowning
|
||||||
virtual void setDrowningTimeLeft (float time);
|
/// @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 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.
|
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())
|
if(stats.getTimeToStartDrowning() != mWatchedStats.getTimeToStartDrowning())
|
||||||
{
|
{
|
||||||
|
const float fHoldBreathTime = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>()
|
||||||
|
.find("fHoldBreathTime")->getFloat();
|
||||||
mWatchedStats.setTimeToStartDrowning(stats.getTimeToStartDrowning());
|
mWatchedStats.setTimeToStartDrowning(stats.getTimeToStartDrowning());
|
||||||
if(stats.getTimeToStartDrowning() >= 20.0f)
|
if(stats.getTimeToStartDrowning() >= fHoldBreathTime)
|
||||||
winMgr->setDrowningBarVisibility(false);
|
winMgr->setDrowningBarVisibility(false);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
winMgr->setDrowningBarVisibility(true);
|
winMgr->setDrowningBarVisibility(true);
|
||||||
winMgr->setDrowningTimeLeft(stats.getTimeToStartDrowning());
|
winMgr->setDrowningTimeLeft(stats.getTimeToStartDrowning(), fHoldBreathTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue