diff --git a/apps/openmw/mwbase/windowmanager.hpp b/apps/openmw/mwbase/windowmanager.hpp index 9c9c448edc..81ef9ee79d 100644 --- a/apps/openmw/mwbase/windowmanager.hpp +++ b/apps/openmw/mwbase/windowmanager.hpp @@ -188,6 +188,7 @@ namespace MWBase virtual void setMinimapVisibility(bool visible) = 0; virtual void setWeaponVisibility(bool visible) = 0; virtual void setSpellVisibility(bool visible) = 0; + virtual void setSneakVisibility(bool visible) = 0; virtual void activateQuickKey (int index) = 0; diff --git a/apps/openmw/mwgui/hud.cpp b/apps/openmw/mwgui/hud.cpp index 4eea0d0d0d..f5cb12e058 100644 --- a/apps/openmw/mwgui/hud.cpp +++ b/apps/openmw/mwgui/hud.cpp @@ -84,6 +84,9 @@ namespace MWGui mSpellBoxBaseLeft = mSpellBox->getLeft(); mSpellBox->eventMouseButtonClick += MyGUI::newDelegate(this, &HUD::onMagicClicked); + getWidget(mSneakBox, "SneakBox"); + mSneakBoxBaseLeft = mSneakBox->getLeft(); + getWidget(mEffectBox, "EffectBox"); mEffectBoxBaseRight = viewSize.width - mEffectBox->getRight(); @@ -503,6 +506,12 @@ namespace MWGui updatePositions(); } + void HUD::setSneakVisible(bool visible) + { + mSneakBox->setVisible(visible); + updatePositions(); + } + void HUD::setEffectVisible(bool visible) { mEffectBox->setVisible (visible); @@ -517,12 +526,18 @@ namespace MWGui void HUD::updatePositions() { - int weapDx = 0, spellDx = 0; + int weapDx = 0, spellDx = 0, sneakDx = 0; if (!mHealth->getVisible()) - spellDx = weapDx = mWeapBoxBaseLeft - mHealthManaStaminaBaseLeft; + sneakDx = spellDx = weapDx = mWeapBoxBaseLeft - mHealthManaStaminaBaseLeft; if (!mWeapBox->getVisible()) + { spellDx += mSpellBoxBaseLeft - mWeapBoxBaseLeft; + sneakDx = spellDx; + } + + if (!mSpellBox->getVisible()) + sneakDx += mSneakBoxBaseLeft - mSpellBoxBaseLeft; mWeaponVisible = mWeapBox->getVisible(); mSpellVisible = mSpellBox->getVisible(); @@ -531,6 +546,7 @@ namespace MWGui mWeapBox->setPosition(mWeapBoxBaseLeft - weapDx, mWeapBox->getTop()); mSpellBox->setPosition(mSpellBoxBaseLeft - spellDx, mSpellBox->getTop()); + mSneakBox->setPosition(mSneakBoxBaseLeft - sneakDx, mSneakBox->getTop()); const MyGUI::IntSize& viewSize = MyGUI::RenderManager::getInstance().getViewSize(); diff --git a/apps/openmw/mwgui/hud.hpp b/apps/openmw/mwgui/hud.hpp index 76d8782696..a3cab2c93a 100644 --- a/apps/openmw/mwgui/hud.hpp +++ b/apps/openmw/mwgui/hud.hpp @@ -21,6 +21,7 @@ namespace MWGui void setHmsVisible(bool visible); void setWeapVisible(bool visible); void setSpellVisible(bool visible); + void setSneakVisible(bool visible); void setEffectVisible(bool visible); void setMinimapVisible(bool visible); @@ -51,7 +52,7 @@ namespace MWGui private: MyGUI::ProgressBar *mHealth, *mMagicka, *mStamina, *mEnemyHealth; MyGUI::Widget* mHealthFrame; - MyGUI::Widget *mWeapBox, *mSpellBox; + MyGUI::Widget *mWeapBox, *mSpellBox, *mSneakBox; MyGUI::ImageBox *mWeapImage, *mSpellImage; MyGUI::ProgressBar *mWeapStatus, *mSpellStatus; MyGUI::Widget *mEffectBox, *mMinimapBox; @@ -70,7 +71,7 @@ namespace MWGui MyGUI::TextBox* mBatchCounter; // bottom left elements - int mHealthManaStaminaBaseLeft, mWeapBoxBaseLeft, mSpellBoxBaseLeft; + int mHealthManaStaminaBaseLeft, mWeapBoxBaseLeft, mSpellBoxBaseLeft, mSneakBoxBaseLeft; // bottom right elements int mMinimapBoxBaseRight, mEffectBoxBaseRight; diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index d0b88b5c26..7924310387 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -834,6 +834,11 @@ namespace MWGui mHud->setEffectVisible (visible); } + void WindowManager::setSneakVisibility(bool visible) + { + mHud->setSneakVisible(visible); + } + void WindowManager::setDragDrop(bool dragDrop) { mToolTips->setEnabled(!dragDrop); diff --git a/apps/openmw/mwgui/windowmanagerimp.hpp b/apps/openmw/mwgui/windowmanagerimp.hpp index cc1eb6df13..a178dc621b 100644 --- a/apps/openmw/mwgui/windowmanagerimp.hpp +++ b/apps/openmw/mwgui/windowmanagerimp.hpp @@ -179,6 +179,7 @@ namespace MWGui virtual void setMinimapVisibility(bool visible); virtual void setWeaponVisibility(bool visible); virtual void setSpellVisibility(bool visible); + virtual void setSneakVisibility(bool visible); virtual void activateQuickKey (int index); diff --git a/apps/openmw/mwworld/player.cpp b/apps/openmw/mwworld/player.cpp index 4d6f50ffd2..0d9399c616 100644 --- a/apps/openmw/mwworld/player.cpp +++ b/apps/openmw/mwworld/player.cpp @@ -123,6 +123,9 @@ namespace MWWorld MWWorld::Ptr ptr = getPlayer(); MWWorld::Class::get (ptr).setStance (ptr, MWWorld::Class::Sneak, sneak); + + // TODO show sneak indicator only when the player is not detected by any actor + MWBase::Environment::get().getWindowManager()->setSneakVisibility(sneak); } void Player::yaw(float yaw) diff --git a/files/mygui/openmw_hud.layout b/files/mygui/openmw_hud.layout index 685d56ce45..16b9f2c205 100644 --- a/files/mygui/openmw_hud.layout +++ b/files/mygui/openmw_hud.layout @@ -65,6 +65,17 @@ + + + + + + + + + + +