mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 08:23:53 +00:00
Added enemy health meter
This commit is contained in:
parent
90ab7b2bf5
commit
3961c276b8
9 changed files with 67 additions and 2 deletions
|
@ -265,6 +265,8 @@ namespace MWBase
|
|||
|
||||
virtual void changePointer (const std::string& name) = 0;
|
||||
|
||||
virtual void setEnemy (const MWWorld::Ptr& enemy) = 0;
|
||||
|
||||
virtual const Translation::Storage& getTranslationDataStorage() const = 0;
|
||||
|
||||
virtual void setKeyFocusWidget (MyGUI::Widget* widget) = 0;
|
||||
|
|
|
@ -418,6 +418,9 @@ namespace MWClass
|
|||
|
||||
// NOTE: 'object' and/or 'attacker' may be empty.
|
||||
|
||||
if(!attacker.isEmpty() && attacker.getRefData().getHandle() == "player")
|
||||
MWBase::Environment::get().getWindowManager()->setEnemy(ptr);
|
||||
|
||||
if(!successful)
|
||||
{
|
||||
// TODO: Handle HitAttemptOnMe script function
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
#include "../mwworld/player.hpp"
|
||||
#include "../mwworld/class.hpp"
|
||||
|
||||
#include "../mwmechanics/creaturestats.hpp"
|
||||
|
||||
#include "inventorywindow.hpp"
|
||||
#include "console.hpp"
|
||||
#include "spellicons.hpp"
|
||||
|
@ -47,6 +49,7 @@ namespace MWGui
|
|||
, mWeaponVisible(true)
|
||||
, mSpellVisible(true)
|
||||
, mWorldMouseOver(false)
|
||||
, mEnemyHealthTimer(0)
|
||||
{
|
||||
setCoord(0,0, width, height);
|
||||
|
||||
|
@ -55,6 +58,7 @@ namespace MWGui
|
|||
getWidget(mHealth, "Health");
|
||||
getWidget(mMagicka, "Magicka");
|
||||
getWidget(mStamina, "Stamina");
|
||||
getWidget(mEnemyHealth, "EnemyHealth");
|
||||
mHealthManaStaminaBaseLeft = mHealthFrame->getLeft();
|
||||
|
||||
MyGUI::Widget *healthFrame, *magickaFrame, *fatigueFrame;
|
||||
|
@ -320,6 +324,13 @@ namespace MWGui
|
|||
mCellNameBox->setVisible(false);
|
||||
if (mWeaponSpellTimer < 0)
|
||||
mWeaponSpellBox->setVisible(false);
|
||||
|
||||
mEnemyHealthTimer -= dt;
|
||||
if (mEnemyHealth->getVisible() && mEnemyHealthTimer < 0)
|
||||
{
|
||||
mEnemyHealth->setVisible(false);
|
||||
mWeaponSpellBox->setPosition(mWeaponSpellBox->getPosition() + MyGUI::IntPoint(0,20));
|
||||
}
|
||||
}
|
||||
|
||||
void HUD::onResChange(int width, int height)
|
||||
|
@ -535,6 +546,25 @@ namespace MWGui
|
|||
void HUD::update()
|
||||
{
|
||||
mSpellIcons->updateWidgets(mEffectBox, true);
|
||||
|
||||
if (!mEnemy.isEmpty() && mEnemyHealth->getVisible())
|
||||
{
|
||||
MWMechanics::CreatureStats& stats = MWWorld::Class::get(mEnemy).getCreatureStats(mEnemy);
|
||||
mEnemyHealth->setProgressRange(100);
|
||||
mEnemyHealth->setProgressPosition(stats.getHealth().getCurrent() / stats.getHealth().getModified() * 100);
|
||||
}
|
||||
}
|
||||
|
||||
void HUD::setEnemy(const MWWorld::Ptr &enemy)
|
||||
{
|
||||
mEnemy = enemy;
|
||||
mEnemyHealthTimer = 5;
|
||||
if (!mEnemyHealth->getVisible())
|
||||
mWeaponSpellBox->setPosition(mWeaponSpellBox->getPosition() - MyGUI::IntPoint(0,20));
|
||||
mEnemyHealth->setVisible(true);
|
||||
MWMechanics::CreatureStats& stats = MWWorld::Class::get(mEnemy).getCreatureStats(mEnemy);
|
||||
mEnemyHealth->setProgressRange(100);
|
||||
mEnemyHealth->setProgressPosition(stats.getHealth().getCurrent() / stats.getHealth().getModified() * 100);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -46,12 +46,14 @@ namespace MWGui
|
|||
|
||||
void update();
|
||||
|
||||
void setEnemy(const MWWorld::Ptr& enemy);
|
||||
|
||||
private:
|
||||
MyGUI::ProgressPtr mHealth, mMagicka, mStamina;
|
||||
MyGUI::ProgressBar *mHealth, *mMagicka, *mStamina, *mEnemyHealth;
|
||||
MyGUI::Widget* mHealthFrame;
|
||||
MyGUI::Widget *mWeapBox, *mSpellBox;
|
||||
MyGUI::ImageBox *mWeapImage, *mSpellImage;
|
||||
MyGUI::ProgressPtr mWeapStatus, mSpellStatus;
|
||||
MyGUI::ProgressBar *mWeapStatus, *mSpellStatus;
|
||||
MyGUI::Widget *mEffectBox, *mMinimapBox;
|
||||
MyGUI::Button* mMinimapButton;
|
||||
MyGUI::ScrollView* mMinimap;
|
||||
|
@ -89,6 +91,9 @@ namespace MWGui
|
|||
|
||||
SpellIcons* mSpellIcons;
|
||||
|
||||
MWWorld::Ptr mEnemy;
|
||||
float mEnemyHealthTimer;
|
||||
|
||||
void onWorldClicked(MyGUI::Widget* _sender);
|
||||
void onWorldMouseOver(MyGUI::Widget* _sender, int x, int y);
|
||||
void onWorldMouseLostFocus(MyGUI::Widget* _sender, MyGUI::Widget* _new);
|
||||
|
|
|
@ -1300,4 +1300,9 @@ namespace MWGui
|
|||
SDL_StopTextInput();
|
||||
}
|
||||
|
||||
void WindowManager::setEnemy(const MWWorld::Ptr &enemy)
|
||||
{
|
||||
mHud->setEnemy(enemy);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -256,6 +256,8 @@ namespace MWGui
|
|||
|
||||
virtual void changePointer (const std::string& name);
|
||||
|
||||
virtual void setEnemy (const MWWorld::Ptr& enemy);
|
||||
|
||||
virtual const Translation::Storage& getTranslationDataStorage() const;
|
||||
|
||||
void onSoulgemDialogButtonPressed (int button);
|
||||
|
|
|
@ -3,6 +3,11 @@
|
|||
<MyGUI type="Layout">
|
||||
<Widget type="Widget" layer="HUD" position="0 0 300 200" name="_Main">
|
||||
<!-- Energy bars -->
|
||||
<Widget type="Widget" skin="" position="13 131 65 12" align="Left Bottom" name="EnemyHealthFrame">
|
||||
<Widget type="ProgressBar" skin="MW_EnergyBar_Yellow" position="0 0 65 12" align="Left Bottom" name="EnemyHealth">
|
||||
<Property key="Visible" value="false"/>
|
||||
</Widget>
|
||||
</Widget>
|
||||
<Widget type="Button" skin="" position="13 146 65 12" align="Left Bottom" name="HealthFrame">
|
||||
<UserString key="ToolTipType" value="Layout"/>
|
||||
<UserString key="ToolTipLayout" value="HealthToolTip"/>
|
||||
|
|
|
@ -42,6 +42,11 @@
|
|||
<State name="normal" offset = "0 8 4 8"/>
|
||||
</BasisSkin>
|
||||
</Skin>
|
||||
<Skin name = "MW_BarTrack_Yellow" size = "4 8" texture = "smallbars.png" >
|
||||
<BasisSkin type="MainSkin" offset = "0 0 4 8" align = "ALIGN_STRETCH">
|
||||
<State name="normal" offset = "0 32 4 8"/>
|
||||
</BasisSkin>
|
||||
</Skin>
|
||||
|
||||
<!-- Main energy bar widget definitions. There's one for each color.-->
|
||||
|
||||
|
@ -69,4 +74,12 @@
|
|||
<Child type="Widget" skin="BlackBG" offset = "2 2 60 8" align = "ALIGN_STRETCH" name="Client"/>
|
||||
</Skin>
|
||||
|
||||
<Skin name="MW_EnergyBar_Yellow" size="64 12">
|
||||
<Property key="TrackSkin" value = "MW_BarTrack_Yellow" />
|
||||
<Property key="TrackWidth" value = "1" />
|
||||
|
||||
<Child type="Widget" skin="MW_BarFrame" offset="0 0 64 12" align="ALIGN_STRETCH"/>
|
||||
<Child type="Widget" skin="BlackBG" offset = "2 2 60 8" align = "ALIGN_STRETCH" name="Client"/>
|
||||
</Skin>
|
||||
|
||||
</MyGUI>
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 2.9 KiB |
Loading…
Reference in a new issue