diff --git a/apps/openmw/mwgui/hud.cpp b/apps/openmw/mwgui/hud.cpp
index edcd49738..e7b9f9c01 100644
--- a/apps/openmw/mwgui/hud.cpp
+++ b/apps/openmw/mwgui/hud.cpp
@@ -28,6 +28,7 @@ namespace MWGui
, mStamina(NULL)
, mDrowning(NULL)
, mDrowningFrame(NULL)
+ , mDrowningFlash(NULL)
, mWeapImage(NULL)
, mSpellImage(NULL)
, mWeapStatus(NULL)
@@ -53,6 +54,7 @@ namespace MWGui
, mSpellVisible(true)
, mWorldMouseOver(false)
, mEnemyHealthTimer(0)
+ , mIsDrowning(false)
{
setCoord(0,0, width, height);
@@ -75,6 +77,7 @@ namespace MWGui
//Drowning bar
getWidget(mDrowningFrame, "DrowningFrame");
getWidget(mDrowning, "Drowning");
+ getWidget(mDrowningFlash, "Flash");
mDrowning->setProgressRange(200);
const MyGUI::IntSize& viewSize = MyGUI::RenderManager::getInstance().getViewSize();
@@ -207,7 +210,15 @@ namespace MWGui
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)
@@ -367,6 +378,9 @@ namespace MWGui
mEnemyHealth->setVisible(false);
mWeaponSpellBox->setPosition(mWeaponSpellBox->getPosition() + MyGUI::IntPoint(0,20));
}
+
+ if (mIsDrowning)
+ mDrowningFlashTheta += dt * Ogre::Math::TWO_PI;
}
void HUD::onResChange(int width, int height)
@@ -609,6 +623,12 @@ namespace MWGui
mEnemyHealth->setProgressRange(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)
diff --git a/apps/openmw/mwgui/hud.hpp b/apps/openmw/mwgui/hud.hpp
index c40742a60..04206fbc8 100644
--- a/apps/openmw/mwgui/hud.hpp
+++ b/apps/openmw/mwgui/hud.hpp
@@ -67,7 +67,7 @@ namespace MWGui
MyGUI::ImageBox* mCrosshair;
MyGUI::TextBox* mCellNameBox;
MyGUI::TextBox* mWeaponSpellBox;
- MyGUI::Widget* mDrowningFrame;
+ MyGUI::Widget *mDrowningFrame, *mDrowningFlash;
MyGUI::Widget* mDummy;
@@ -101,6 +101,9 @@ namespace MWGui
MWWorld::Ptr mEnemy;
float mEnemyHealthTimer;
+ bool mIsDrowning;
+ float mDrowningFlashTheta;
+
void onWorldClicked(MyGUI::Widget* _sender);
void onWorldMouseOver(MyGUI::Widget* _sender, int x, int y);
void onWorldMouseLostFocus(MyGUI::Widget* _sender, MyGUI::Widget* _new);
diff --git a/files/mygui/openmw_hud.layout b/files/mygui/openmw_hud.layout
index e39777dd0..72d337e45 100644
--- a/files/mygui/openmw_hud.layout
+++ b/files/mygui/openmw_hud.layout
@@ -45,6 +45,7 @@
+
diff --git a/files/mygui/openmw_progress.skin.xml b/files/mygui/openmw_progress.skin.xml
index 35114ffeb..f5418e3f8 100644
--- a/files/mygui/openmw_progress.skin.xml
+++ b/files/mygui/openmw_progress.skin.xml
@@ -17,6 +17,11 @@
+
+
+
+
+
@@ -65,6 +70,10 @@
+
+
+
+