Breath meter flashes when drowning

actorid
Alex "rainChu" Haddad 11 years ago
parent 3a3f2a37c8
commit 23eaf90846

@ -28,6 +28,7 @@ namespace MWGui
, mStamina(NULL) , mStamina(NULL)
, mDrowning(NULL) , mDrowning(NULL)
, mDrowningFrame(NULL) , mDrowningFrame(NULL)
, mDrowningFlash(NULL)
, mWeapImage(NULL) , mWeapImage(NULL)
, mSpellImage(NULL) , mSpellImage(NULL)
, mWeapStatus(NULL) , mWeapStatus(NULL)
@ -53,6 +54,7 @@ namespace MWGui
, mSpellVisible(true) , mSpellVisible(true)
, mWorldMouseOver(false) , mWorldMouseOver(false)
, mEnemyHealthTimer(0) , mEnemyHealthTimer(0)
, mIsDrowning(false)
{ {
setCoord(0,0, width, height); setCoord(0,0, width, height);
@ -75,6 +77,7 @@ namespace MWGui
//Drowning bar //Drowning bar
getWidget(mDrowningFrame, "DrowningFrame"); getWidget(mDrowningFrame, "DrowningFrame");
getWidget(mDrowning, "Drowning"); getWidget(mDrowning, "Drowning");
getWidget(mDrowningFlash, "Flash");
mDrowning->setProgressRange(200); mDrowning->setProgressRange(200);
const MyGUI::IntSize& viewSize = MyGUI::RenderManager::getInstance().getViewSize(); const MyGUI::IntSize& viewSize = MyGUI::RenderManager::getInstance().getViewSize();
@ -207,7 +210,15 @@ namespace MWGui
void HUD::setDrowningTimeLeft(float time) void HUD::setDrowningTimeLeft(float time)
{ {
mDrowning->setProgressPosition(time/20.0*200.0); size_t progress = time/20.0*200.0;
mDrowning->setProgressPosition(progress);
bool isDrowning = (progress == 0);
if (isDrowning && !mIsDrowning) // Just started drowning
mDrowningFlashTheta = 0.0f; // Start out on bright red every time.
mDrowningFlash->setVisible(isDrowning);
mIsDrowning = isDrowning;
} }
void HUD::setDrowningBarVisible(bool visible) void HUD::setDrowningBarVisible(bool visible)
@ -367,6 +378,9 @@ namespace MWGui
mEnemyHealth->setVisible(false); mEnemyHealth->setVisible(false);
mWeaponSpellBox->setPosition(mWeaponSpellBox->getPosition() + MyGUI::IntPoint(0,20)); mWeaponSpellBox->setPosition(mWeaponSpellBox->getPosition() + MyGUI::IntPoint(0,20));
} }
if (mIsDrowning)
mDrowningFlashTheta += dt * Ogre::Math::TWO_PI;
} }
void HUD::onResChange(int width, int height) void HUD::onResChange(int width, int height)
@ -609,6 +623,12 @@ namespace MWGui
mEnemyHealth->setProgressRange(100); mEnemyHealth->setProgressRange(100);
mEnemyHealth->setProgressPosition(stats.getHealth().getCurrent() / stats.getHealth().getModified() * 100); mEnemyHealth->setProgressPosition(stats.getHealth().getCurrent() / stats.getHealth().getModified() * 100);
} }
if (mIsDrowning)
{
float intensity = (cos(mDrowningFlashTheta) + 1.0f) / 2.0f;
mDrowningFlash->setColour(MyGUI::Colour(intensity, intensity, intensity));
}
} }
void HUD::setEnemy(const MWWorld::Ptr &enemy) void HUD::setEnemy(const MWWorld::Ptr &enemy)

@ -67,7 +67,7 @@ namespace MWGui
MyGUI::ImageBox* mCrosshair; MyGUI::ImageBox* mCrosshair;
MyGUI::TextBox* mCellNameBox; MyGUI::TextBox* mCellNameBox;
MyGUI::TextBox* mWeaponSpellBox; MyGUI::TextBox* mWeaponSpellBox;
MyGUI::Widget* mDrowningFrame; MyGUI::Widget *mDrowningFrame, *mDrowningFlash;
MyGUI::Widget* mDummy; MyGUI::Widget* mDummy;
@ -101,6 +101,9 @@ namespace MWGui
MWWorld::Ptr mEnemy; MWWorld::Ptr mEnemy;
float mEnemyHealthTimer; float mEnemyHealthTimer;
bool mIsDrowning;
float mDrowningFlashTheta;
void onWorldClicked(MyGUI::Widget* _sender); void onWorldClicked(MyGUI::Widget* _sender);
void onWorldMouseOver(MyGUI::Widget* _sender, int x, int y); void onWorldMouseOver(MyGUI::Widget* _sender, int x, int y);
void onWorldMouseLostFocus(MyGUI::Widget* _sender, MyGUI::Widget* _new); void onWorldMouseLostFocus(MyGUI::Widget* _sender, MyGUI::Widget* _new);

@ -45,6 +45,7 @@
<Widget type="ProgressBar" skin="MW_Progress_Loading" position="12 36 196 8" align="Center Top" name="Drowning"> <Widget type="ProgressBar" skin="MW_Progress_Loading" position="12 36 196 8" align="Center Top" name="Drowning">
<Property key="NeedMouse" value="false"/> <Property key="NeedMouse" value="false"/>
</Widget> </Widget>
<Widget type="Widget" skin="MW_Progress_Drowning" position="14 38 192 4" align="Center Top" name="Flash"/>
</Widget> </Widget>
<!-- Equipped weapon/selected spell name display for a few seconds after it changes --> <!-- Equipped weapon/selected spell name display for a few seconds after it changes -->

@ -17,6 +17,11 @@
<State name="normal" offset="0 28 2 14"/> <State name="normal" offset="0 28 2 14"/>
</BasisSkin> </BasisSkin>
</Skin> </Skin>
<Skin name="MW_BigTrack_Progress_Red_Small" size="2 6" texture="smallbars.png" >
<BasisSkin type="MainSkin" offset="0 0 2 6" align="Stretch">
<State name="normal" offset="0 0 2 8"/>
</BasisSkin>
</Skin>
<Skin name="MW_BigTrack_Progress_Blue_Small" size="2 6" texture="smallbars.png" > <Skin name="MW_BigTrack_Progress_Blue_Small" size="2 6" texture="smallbars.png" >
<BasisSkin type="MainSkin" offset="0 0 2 6" align="Stretch"> <BasisSkin type="MainSkin" offset="0 0 2 6" align="Stretch">
<State name="normal" offset="0 26 2 6"/> <State name="normal" offset="0 26 2 6"/>
@ -65,6 +70,10 @@
<Child type="Widget" skin="BlackBG" offset="2 2 60 2" align="Stretch" name="Client"/> <Child type="Widget" skin="BlackBG" offset="2 2 60 2" align="Stretch" name="Client"/>
</Skin> </Skin>
<Skin name="MW_Progress_Drowning" size="64 6">
<Child type="Widget" skin="MW_BigTrack_Progress_Red_Small" offset="0 0 64 6" align="Stretch"/>
</Skin>
<Skin name="MW_ProgressScroll_Loading" size="64 6"> <Skin name="MW_ProgressScroll_Loading" size="64 6">
<Property key="TrackWidth" value="1"/> <Property key="TrackWidth" value="1"/>
<Property key="TrackRangeMargins" value="0 0"/> <Property key="TrackRangeMargins" value="0 0"/>

Loading…
Cancel
Save