2012-05-13 18:14:03 +02:00
|
|
|
#include "hud.hpp"
|
2010-09-18 01:30:23 +02:00
|
|
|
|
2015-01-10 02:50:43 +01:00
|
|
|
#include <MyGUI_Button.h>
|
|
|
|
#include <MyGUI_ImageBox.h>
|
|
|
|
#include <MyGUI_InputManager.h>
|
|
|
|
#include <MyGUI_ProgressBar.h>
|
|
|
|
#include <MyGUI_RenderManager.h>
|
|
|
|
#include <MyGUI_ScrollView.h>
|
|
|
|
|
2022-09-05 19:35:15 +02:00
|
|
|
#include <components/esm3/loadgmst.hpp>
|
|
|
|
#include <components/esm3/loadmgef.hpp>
|
2022-06-29 00:32:11 +02:00
|
|
|
#include <components/misc/resourcehelpers.hpp>
|
|
|
|
#include <components/resource/resourcesystem.hpp>
|
2015-01-31 23:27:34 +01:00
|
|
|
#include <components/settings/settings.hpp>
|
2014-08-16 18:12:18 +02:00
|
|
|
|
2012-05-13 18:35:56 +02:00
|
|
|
#include "../mwbase/environment.hpp"
|
2012-08-12 18:11:09 +02:00
|
|
|
#include "../mwbase/windowmanager.hpp"
|
2014-12-19 11:26:54 +01:00
|
|
|
#include "../mwbase/world.hpp"
|
2012-07-03 12:30:50 +02:00
|
|
|
|
2013-05-11 18:38:27 +02:00
|
|
|
#include "../mwworld/class.hpp"
|
2014-12-19 11:26:54 +01:00
|
|
|
#include "../mwworld/esmstore.hpp"
|
2012-05-13 18:35:56 +02:00
|
|
|
|
2015-08-21 21:12:39 +12:00
|
|
|
#include "../mwmechanics/actorutil.hpp"
|
2013-08-06 00:07:24 +02:00
|
|
|
#include "../mwmechanics/npcstats.hpp"
|
2013-07-30 06:00:20 +02:00
|
|
|
|
2015-01-10 01:21:17 +01:00
|
|
|
#include "draganddrop.hpp"
|
2012-06-02 14:19:02 +02:00
|
|
|
#include "inventorywindow.hpp"
|
2013-05-11 18:38:27 +02:00
|
|
|
#include "itemmodel.hpp"
|
2015-01-10 01:21:17 +01:00
|
|
|
#include "spellicons.hpp"
|
2010-09-18 01:44:40 +02:00
|
|
|
|
2014-06-05 22:13:18 +02:00
|
|
|
#include "itemwidget.hpp"
|
2014-05-16 03:19:38 +02:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
namespace MWGui
|
2010-09-18 21:24:05 +02:00
|
|
|
{
|
|
|
|
|
2014-05-16 03:19:38 +02:00
|
|
|
/**
|
|
|
|
* Makes it possible to use ItemModel::moveItem to move an item from an inventory to the world.
|
|
|
|
*/
|
|
|
|
class WorldItemModel : public ItemModel
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
WorldItemModel(float left, float top)
|
|
|
|
: mLeft(left)
|
|
|
|
, mTop(top)
|
|
|
|
{
|
|
|
|
}
|
2020-10-16 22:18:54 +04:00
|
|
|
virtual ~WorldItemModel() override {}
|
|
|
|
MWWorld::Ptr copyItem(const ItemStack& item, size_t count, bool /*allowAutoEquip*/) override
|
2014-05-16 03:19:38 +02:00
|
|
|
{
|
|
|
|
MWBase::World* world = MWBase::Environment::get().getWorld();
|
|
|
|
|
|
|
|
MWWorld::Ptr dropped;
|
|
|
|
if (world->canPlaceObject(mLeft, mTop))
|
|
|
|
dropped = world->placeObject(item.mBase, mLeft, mTop, count);
|
|
|
|
else
|
|
|
|
dropped = world->dropObjectOnGround(world->getPlayerPtr(), item.mBase, count);
|
2023-02-17 19:20:29 +01:00
|
|
|
dropped.getCellRef().setOwner(ESM::RefId());
|
2014-05-16 03:19:38 +02:00
|
|
|
|
|
|
|
return dropped;
|
|
|
|
}
|
|
|
|
|
2020-10-16 22:18:54 +04:00
|
|
|
void removeItem(const ItemStack& item, size_t count) override
|
|
|
|
{
|
|
|
|
throw std::runtime_error("removeItem not implemented");
|
|
|
|
}
|
2021-08-15 19:50:28 +02:00
|
|
|
ModelIndex getIndex(const ItemStack& item) override { throw std::runtime_error("getIndex not implemented"); }
|
2020-10-16 22:18:54 +04:00
|
|
|
void update() override {}
|
|
|
|
size_t getItemCount() override { return 0; }
|
|
|
|
ItemStack getItem(ModelIndex index) override { throw std::runtime_error("getItem not implemented"); }
|
2021-07-15 22:31:26 +02:00
|
|
|
bool usesContainer(const MWWorld::Ptr&) override { return false; }
|
2014-05-16 03:19:38 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
// Where to drop the item
|
|
|
|
float mLeft;
|
|
|
|
float mTop;
|
|
|
|
};
|
|
|
|
|
2015-11-07 00:13:13 +01:00
|
|
|
HUD::HUD(CustomMarkerCollection& customMarkers, DragAndDrop* dragAndDrop, MWRender::LocalMap* localMapRender)
|
2017-09-23 21:45:52 +02:00
|
|
|
: WindowBase("openmw_hud.layout")
|
2016-01-07 01:08:30 +01:00
|
|
|
, LocalMapBase(customMarkers, localMapRender, Settings::Manager::getBool("local map hud fog of war", "Map"))
|
2018-10-09 10:21:12 +04:00
|
|
|
, mHealth(nullptr)
|
|
|
|
, mMagicka(nullptr)
|
|
|
|
, mStamina(nullptr)
|
|
|
|
, mDrowning(nullptr)
|
|
|
|
, mWeapImage(nullptr)
|
|
|
|
, mSpellImage(nullptr)
|
|
|
|
, mWeapStatus(nullptr)
|
|
|
|
, mSpellStatus(nullptr)
|
|
|
|
, mEffectBox(nullptr)
|
|
|
|
, mMinimap(nullptr)
|
|
|
|
, mCrosshair(nullptr)
|
|
|
|
, mCellNameBox(nullptr)
|
2021-12-02 17:01:40 +00:00
|
|
|
, mDrowningBar(nullptr)
|
2018-10-09 10:21:12 +04:00
|
|
|
, mDrowningFlash(nullptr)
|
2013-04-17 18:56:48 -04:00
|
|
|
, mHealthManaStaminaBaseLeft(0)
|
|
|
|
, mWeapBoxBaseLeft(0)
|
|
|
|
, mSpellBoxBaseLeft(0)
|
|
|
|
, mMinimapBoxBaseRight(0)
|
2015-04-25 13:37:42 -05:00
|
|
|
, mEffectBoxBaseRight(0)
|
2013-04-17 18:56:48 -04:00
|
|
|
, mDragAndDrop(dragAndDrop)
|
|
|
|
, mCellNameTimer(0.0f)
|
2015-04-25 13:37:42 -05:00
|
|
|
, mWeaponSpellTimer(0.f)
|
2013-04-17 18:56:48 -04:00
|
|
|
, mMapVisible(true)
|
|
|
|
, mWeaponVisible(true)
|
|
|
|
, mSpellVisible(true)
|
|
|
|
, mWorldMouseOver(false)
|
2014-07-23 22:04:18 +02:00
|
|
|
, mEnemyActorId(-1)
|
2015-04-25 13:37:42 -05:00
|
|
|
, mEnemyHealthTimer(-1)
|
2013-10-27 04:05:01 -04:00
|
|
|
, mIsDrowning(false)
|
2013-12-30 23:08:53 +01:00
|
|
|
, mDrowningFlashTheta(0.f)
|
2013-04-17 18:56:48 -04:00
|
|
|
{
|
|
|
|
// Energy bars
|
|
|
|
getWidget(mHealthFrame, "HealthFrame");
|
|
|
|
getWidget(mHealth, "Health");
|
|
|
|
getWidget(mMagicka, "Magicka");
|
|
|
|
getWidget(mStamina, "Stamina");
|
2013-07-30 06:00:20 +02:00
|
|
|
getWidget(mEnemyHealth, "EnemyHealth");
|
2013-04-17 18:56:48 -04:00
|
|
|
mHealthManaStaminaBaseLeft = mHealthFrame->getLeft();
|
2012-05-29 15:36:48 +02:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
MyGUI::Widget *healthFrame, *magickaFrame, *fatigueFrame;
|
|
|
|
getWidget(healthFrame, "HealthFrame");
|
|
|
|
getWidget(magickaFrame, "MagickaFrame");
|
|
|
|
getWidget(fatigueFrame, "FatigueFrame");
|
|
|
|
healthFrame->eventMouseButtonClick += MyGUI::newDelegate(this, &HUD::onHMSClicked);
|
|
|
|
magickaFrame->eventMouseButtonClick += MyGUI::newDelegate(this, &HUD::onHMSClicked);
|
|
|
|
fatigueFrame->eventMouseButtonClick += MyGUI::newDelegate(this, &HUD::onHMSClicked);
|
2012-07-13 03:51:58 -07:00
|
|
|
|
2013-08-07 15:34:11 +02:00
|
|
|
// Drowning bar
|
2021-12-02 17:01:40 +00:00
|
|
|
getWidget(mDrowningBar, "DrowningBar");
|
2013-08-07 15:34:11 +02:00
|
|
|
getWidget(mDrowningFrame, "DrowningFrame");
|
|
|
|
getWidget(mDrowning, "Drowning");
|
2013-10-27 04:05:01 -04:00
|
|
|
getWidget(mDrowningFlash, "Flash");
|
2013-08-07 15:34:11 +02:00
|
|
|
mDrowning->setProgressRange(200);
|
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
const MyGUI::IntSize& viewSize = MyGUI::RenderManager::getInstance().getViewSize();
|
2012-07-13 03:51:58 -07:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
// Item and spell images and status bars
|
|
|
|
getWidget(mWeapBox, "WeapBox");
|
|
|
|
getWidget(mWeapImage, "WeapImage");
|
|
|
|
getWidget(mWeapStatus, "WeapStatus");
|
|
|
|
mWeapBoxBaseLeft = mWeapBox->getLeft();
|
|
|
|
mWeapBox->eventMouseButtonClick += MyGUI::newDelegate(this, &HUD::onWeaponClicked);
|
2012-07-13 03:51:58 -07:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
getWidget(mSpellBox, "SpellBox");
|
|
|
|
getWidget(mSpellImage, "SpellImage");
|
|
|
|
getWidget(mSpellStatus, "SpellStatus");
|
|
|
|
mSpellBoxBaseLeft = mSpellBox->getLeft();
|
|
|
|
mSpellBox->eventMouseButtonClick += MyGUI::newDelegate(this, &HUD::onMagicClicked);
|
2010-09-18 21:24:05 +02:00
|
|
|
|
2013-08-03 02:43:56 +02:00
|
|
|
getWidget(mSneakBox, "SneakBox");
|
|
|
|
mSneakBoxBaseLeft = mSneakBox->getLeft();
|
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
getWidget(mEffectBox, "EffectBox");
|
|
|
|
mEffectBoxBaseRight = viewSize.width - mEffectBox->getRight();
|
2012-05-26 23:06:15 +02:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
getWidget(mMinimapBox, "MiniMapBox");
|
|
|
|
mMinimapBoxBaseRight = viewSize.width - mMinimapBox->getRight();
|
|
|
|
getWidget(mMinimap, "MiniMap");
|
|
|
|
getWidget(mCompass, "Compass");
|
|
|
|
getWidget(mMinimapButton, "MiniMapButton");
|
|
|
|
mMinimapButton->eventMouseButtonClick += MyGUI::newDelegate(this, &HUD::onMapClicked);
|
2010-09-18 21:24:05 +02:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
getWidget(mCellNameBox, "CellName");
|
|
|
|
getWidget(mWeaponSpellBox, "WeaponSpellName");
|
2012-04-13 13:17:50 +02:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
getWidget(mCrosshair, "Crosshair");
|
2010-09-18 21:24:05 +02:00
|
|
|
|
2020-06-16 18:43:01 +04:00
|
|
|
LocalMapBase::init(mMinimap, mCompass);
|
2013-03-03 12:01:19 +01:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
mMainWidget->eventMouseButtonClick += MyGUI::newDelegate(this, &HUD::onWorldClicked);
|
|
|
|
mMainWidget->eventMouseMove += MyGUI::newDelegate(this, &HUD::onWorldMouseOver);
|
|
|
|
mMainWidget->eventMouseLostFocus += MyGUI::newDelegate(this, &HUD::onWorldMouseLostFocus);
|
2010-09-18 21:24:05 +02:00
|
|
|
|
2022-08-31 18:03:46 +02:00
|
|
|
mSpellIcons = std::make_unique<SpellIcons>();
|
2013-04-17 18:56:48 -04:00
|
|
|
}
|
2012-04-13 13:17:50 +02:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
HUD::~HUD()
|
2012-04-13 13:17:50 +02:00
|
|
|
{
|
2015-01-31 16:26:15 +01:00
|
|
|
mMainWidget->eventMouseLostFocus.clear();
|
|
|
|
mMainWidget->eventMouseMove.clear();
|
|
|
|
mMainWidget->eventMouseButtonClick.clear();
|
2012-04-13 13:17:50 +02:00
|
|
|
}
|
2013-04-17 18:56:48 -04:00
|
|
|
|
2022-10-02 23:16:43 +02:00
|
|
|
void HUD::setValue(std::string_view id, const MWMechanics::DynamicStat<float>& value)
|
2013-04-17 18:56:48 -04:00
|
|
|
{
|
2017-08-29 18:04:31 +04:00
|
|
|
int current = static_cast<int>(value.getCurrent());
|
2013-12-10 00:41:36 +01:00
|
|
|
int modified = static_cast<int>(value.getModified());
|
2017-08-29 18:04:31 +04:00
|
|
|
// Fatigue can be negative
|
2022-10-02 23:16:43 +02:00
|
|
|
if (id != "FBar")
|
2017-08-29 18:04:31 +04:00
|
|
|
current = std::max(0, current);
|
|
|
|
|
2013-12-10 00:41:36 +01:00
|
|
|
MyGUI::Widget* w;
|
2017-04-30 22:39:05 +04:00
|
|
|
std::string valStr = MyGUI::utility::toString(current) + " / " + MyGUI::utility::toString(modified);
|
2022-10-02 23:16:43 +02:00
|
|
|
if (id == "HBar")
|
2013-12-10 00:41:36 +01:00
|
|
|
{
|
2017-08-29 18:04:31 +04:00
|
|
|
mHealth->setProgressRange(std::max(0, modified));
|
|
|
|
mHealth->setProgressPosition(std::max(0, current));
|
2013-12-10 00:41:36 +01:00
|
|
|
getWidget(w, "HealthFrame");
|
|
|
|
w->setUserString("Caption_HealthDescription", "#{sHealthDesc}\n" + valStr);
|
|
|
|
}
|
2022-10-02 23:16:43 +02:00
|
|
|
else if (id == "MBar")
|
2010-09-18 18:04:53 +02:00
|
|
|
{
|
2017-08-29 18:04:31 +04:00
|
|
|
mMagicka->setProgressRange(std::max(0, modified));
|
|
|
|
mMagicka->setProgressPosition(std::max(0, current));
|
2013-12-10 00:41:36 +01:00
|
|
|
getWidget(w, "MagickaFrame");
|
2015-11-21 02:05:27 +01:00
|
|
|
w->setUserString("Caption_HealthDescription", "#{sMagDesc}\n" + valStr);
|
2013-12-10 00:41:36 +01:00
|
|
|
}
|
2022-10-02 23:16:43 +02:00
|
|
|
else if (id == "FBar")
|
2013-12-10 00:41:36 +01:00
|
|
|
{
|
2017-08-29 18:04:31 +04:00
|
|
|
mStamina->setProgressRange(std::max(0, modified));
|
|
|
|
mStamina->setProgressPosition(std::max(0, current));
|
2013-12-10 00:41:36 +01:00
|
|
|
getWidget(w, "FatigueFrame");
|
|
|
|
w->setUserString("Caption_HealthDescription", "#{sFatDesc}\n" + valStr);
|
|
|
|
}
|
2013-04-17 18:56:48 -04:00
|
|
|
}
|
2012-08-13 01:26:15 +02:00
|
|
|
|
2014-04-27 04:27:26 +02:00
|
|
|
void HUD::setDrowningTimeLeft(float time, float maxTime)
|
2013-08-07 15:34:11 +02:00
|
|
|
{
|
2015-03-08 13:07:29 +13:00
|
|
|
size_t progress = static_cast<size_t>(time / maxTime * 200);
|
2013-10-27 04:05:01 -04:00
|
|
|
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;
|
2013-08-07 15:34:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void HUD::setDrowningBarVisible(bool visible)
|
|
|
|
{
|
2021-12-02 17:01:40 +00:00
|
|
|
mDrowningBar->setVisible(visible);
|
2013-08-07 15:34:11 +02:00
|
|
|
}
|
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
void HUD::onWorldClicked(MyGUI::Widget* _sender)
|
2012-05-13 18:35:56 +02:00
|
|
|
{
|
2013-04-17 18:56:48 -04:00
|
|
|
if (!MWBase::Environment::get().getWindowManager()->isGuiMode())
|
|
|
|
return;
|
2012-05-13 18:35:56 +02:00
|
|
|
|
2019-05-16 10:28:56 +04:00
|
|
|
MWBase::WindowManager* winMgr = MWBase::Environment::get().getWindowManager();
|
2013-04-17 18:56:48 -04:00
|
|
|
if (mDragAndDrop->mIsOnDragAndDrop)
|
|
|
|
{
|
|
|
|
// drop item into the gameworld
|
2014-05-12 02:20:56 +02:00
|
|
|
MWBase::Environment::get().getWorld()->breakInvisibility(MWMechanics::getPlayer());
|
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
MyGUI::IntSize viewSize = MyGUI::RenderManager::getInstance().getViewSize();
|
|
|
|
MyGUI::IntPoint cursorPosition = MyGUI::InputManager::getInstance().getMousePosition();
|
|
|
|
float mouseX = cursorPosition.left / float(viewSize.width);
|
|
|
|
float mouseY = cursorPosition.top / float(viewSize.height);
|
2012-05-15 23:28:04 +02:00
|
|
|
|
2014-05-16 03:19:38 +02:00
|
|
|
WorldItemModel drop(mouseX, mouseY);
|
2018-10-09 10:21:12 +04:00
|
|
|
mDragAndDrop->drop(&drop, nullptr);
|
2012-05-14 17:41:17 +02:00
|
|
|
|
2019-05-16 10:28:56 +04:00
|
|
|
winMgr->changePointer("arrow");
|
2013-04-17 18:56:48 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-05-16 10:28:56 +04:00
|
|
|
GuiMode mode = winMgr->getMode();
|
2012-06-02 12:25:24 +02:00
|
|
|
|
2019-05-16 10:28:56 +04:00
|
|
|
if (!winMgr->isConsoleMode() && (mode != GM_Container) && (mode != GM_Inventory))
|
2013-04-17 18:56:48 -04:00
|
|
|
return;
|
2012-06-02 12:25:24 +02:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
MWWorld::Ptr object = MWBase::Environment::get().getWorld()->getFacedObject();
|
|
|
|
|
2019-05-16 10:28:56 +04:00
|
|
|
if (winMgr->isConsoleMode())
|
|
|
|
winMgr->setConsoleSelectedObject(object);
|
2019-02-17 11:42:22 +04:00
|
|
|
else // if ((mode == GM_Container) || (mode == GM_Inventory))
|
2013-04-17 18:56:48 -04:00
|
|
|
{
|
|
|
|
// pick up object
|
2014-01-17 15:27:59 +01:00
|
|
|
if (!object.isEmpty())
|
2019-05-16 10:28:56 +04:00
|
|
|
winMgr->getInventoryWindow()->pickUpObject(object);
|
2013-04-17 18:56:48 -04:00
|
|
|
}
|
2012-06-02 12:25:24 +02:00
|
|
|
}
|
|
|
|
}
|
2012-05-13 18:35:56 +02:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
void HUD::onWorldMouseOver(MyGUI::Widget* _sender, int x, int y)
|
2012-05-15 16:47:23 +02:00
|
|
|
{
|
2013-04-17 18:56:48 -04:00
|
|
|
if (mDragAndDrop->mIsOnDragAndDrop)
|
|
|
|
{
|
|
|
|
mWorldMouseOver = false;
|
|
|
|
|
|
|
|
MyGUI::IntSize viewSize = MyGUI::RenderManager::getInstance().getViewSize();
|
|
|
|
MyGUI::IntPoint cursorPosition = MyGUI::InputManager::getInstance().getMousePosition();
|
|
|
|
float mouseX = cursorPosition.left / float(viewSize.width);
|
|
|
|
float mouseY = cursorPosition.top / float(viewSize.height);
|
2012-06-02 12:25:24 +02:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
MWBase::World* world = MWBase::Environment::get().getWorld();
|
2012-05-15 16:47:23 +02:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
// if we can't drop the object at the wanted position, show the "drop on ground" cursor.
|
|
|
|
bool canDrop = world->canPlaceObject(mouseX, mouseY);
|
2012-05-15 16:47:23 +02:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
if (!canDrop)
|
|
|
|
MWBase::Environment::get().getWindowManager()->changePointer("drop_ground");
|
|
|
|
else
|
|
|
|
MWBase::Environment::get().getWindowManager()->changePointer("arrow");
|
|
|
|
}
|
2012-05-15 16:47:23 +02:00
|
|
|
else
|
2013-04-17 18:56:48 -04:00
|
|
|
{
|
2013-03-07 12:46:26 +01:00
|
|
|
MWBase::Environment::get().getWindowManager()->changePointer("arrow");
|
2013-04-17 18:56:48 -04:00
|
|
|
mWorldMouseOver = true;
|
|
|
|
}
|
2012-05-15 16:47:23 +02:00
|
|
|
}
|
2013-04-17 18:56:48 -04:00
|
|
|
|
|
|
|
void HUD::onWorldMouseLostFocus(MyGUI::Widget* _sender, MyGUI::Widget* _new)
|
2012-05-15 16:47:23 +02:00
|
|
|
{
|
2013-03-07 12:46:26 +01:00
|
|
|
MWBase::Environment::get().getWindowManager()->changePointer("arrow");
|
2013-04-17 18:56:48 -04:00
|
|
|
mWorldMouseOver = false;
|
2012-05-15 16:47:23 +02:00
|
|
|
}
|
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
void HUD::onHMSClicked(MyGUI::Widget* _sender)
|
|
|
|
{
|
|
|
|
MWBase::Environment::get().getWindowManager()->toggleVisible(GW_Stats);
|
|
|
|
}
|
2012-05-26 21:09:21 +02:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
void HUD::onMapClicked(MyGUI::Widget* _sender)
|
|
|
|
{
|
|
|
|
MWBase::Environment::get().getWindowManager()->toggleVisible(GW_Map);
|
|
|
|
}
|
2012-05-26 23:06:15 +02:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
void HUD::onWeaponClicked(MyGUI::Widget* _sender)
|
2012-05-26 23:06:15 +02:00
|
|
|
{
|
2015-08-21 21:12:39 +12:00
|
|
|
const MWWorld::Ptr& player = MWMechanics::getPlayer();
|
2014-05-22 20:37:22 +02:00
|
|
|
if (player.getClass().getNpcStats(player).isWerewolf())
|
2013-08-12 15:36:16 +02:00
|
|
|
{
|
|
|
|
MWBase::Environment::get().getWindowManager()->messageBox("#{sWerewolfRefusal}");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
MWBase::Environment::get().getWindowManager()->toggleVisible(GW_Inventory);
|
|
|
|
}
|
2012-05-26 23:06:15 +02:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
void HUD::onMagicClicked(MyGUI::Widget* _sender)
|
|
|
|
{
|
2015-08-21 21:12:39 +12:00
|
|
|
const MWWorld::Ptr& player = MWMechanics::getPlayer();
|
2014-05-22 20:37:22 +02:00
|
|
|
if (player.getClass().getNpcStats(player).isWerewolf())
|
2013-08-12 15:36:16 +02:00
|
|
|
{
|
|
|
|
MWBase::Environment::get().getWindowManager()->messageBox("#{sWerewolfRefusal}");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
MWBase::Environment::get().getWindowManager()->toggleVisible(GW_Magic);
|
2012-05-26 23:06:15 +02:00
|
|
|
}
|
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
void HUD::setCellName(const std::string& cellName)
|
|
|
|
{
|
|
|
|
if (mCellName != cellName)
|
|
|
|
{
|
|
|
|
mCellNameTimer = 5.0f;
|
|
|
|
mCellName = cellName;
|
2012-05-28 09:19:25 +02:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
mCellNameBox->setCaptionWithReplacing("#{sCell=" + mCellName + "}");
|
|
|
|
mCellNameBox->setVisible(mMapVisible);
|
|
|
|
}
|
|
|
|
}
|
2012-05-29 18:33:01 +02:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
void HUD::onFrame(float dt)
|
|
|
|
{
|
2014-06-17 16:27:33 +02:00
|
|
|
LocalMapBase::onFrame(dt);
|
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
mCellNameTimer -= dt;
|
|
|
|
mWeaponSpellTimer -= dt;
|
|
|
|
if (mCellNameTimer < 0)
|
|
|
|
mCellNameBox->setVisible(false);
|
|
|
|
if (mWeaponSpellTimer < 0)
|
|
|
|
mWeaponSpellBox->setVisible(false);
|
2013-07-30 06:00:20 +02:00
|
|
|
|
|
|
|
mEnemyHealthTimer -= dt;
|
|
|
|
if (mEnemyHealth->getVisible() && mEnemyHealthTimer < 0)
|
|
|
|
{
|
|
|
|
mEnemyHealth->setVisible(false);
|
|
|
|
mWeaponSpellBox->setPosition(mWeaponSpellBox->getPosition() + MyGUI::IntPoint(0, 20));
|
|
|
|
}
|
2013-10-27 04:05:01 -04:00
|
|
|
|
2017-09-23 22:24:22 +02:00
|
|
|
mSpellIcons->updateWidgets(mEffectBox, true);
|
|
|
|
|
|
|
|
if (mEnemyActorId != -1 && mEnemyHealth->getVisible())
|
|
|
|
{
|
|
|
|
updateEnemyHealthBar();
|
|
|
|
}
|
|
|
|
|
2021-12-02 17:01:40 +00:00
|
|
|
if (mDrowningBar->getVisible())
|
|
|
|
mDrowningBar->setPosition(
|
|
|
|
mMainWidget->getWidth() / 2 - mDrowningFrame->getWidth() / 2, mMainWidget->getTop());
|
|
|
|
|
2017-09-23 22:24:22 +02:00
|
|
|
if (mIsDrowning)
|
|
|
|
{
|
2021-12-02 17:01:40 +00:00
|
|
|
mDrowningFlashTheta += dt * osg::PI * 2;
|
|
|
|
|
2017-09-23 22:24:22 +02:00
|
|
|
float intensity = (cos(mDrowningFlashTheta) + 2.0f) / 3.0f;
|
|
|
|
|
|
|
|
mDrowningFlash->setAlpha(intensity);
|
|
|
|
}
|
2013-04-17 18:56:48 -04:00
|
|
|
}
|
2012-11-05 23:41:26 +04:00
|
|
|
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
void HUD::setSelectedSpell(const ESM::RefId& spellId, int successChancePercent)
|
2013-04-17 18:56:48 -04:00
|
|
|
{
|
2023-04-20 21:07:53 +02:00
|
|
|
const ESM::Spell* spell = MWBase::Environment::get().getESMStore()->get<ESM::Spell>().find(spellId);
|
2012-05-29 18:33:01 +02:00
|
|
|
|
2022-08-28 15:06:31 +02:00
|
|
|
const std::string& spellName = spell->mName;
|
2013-04-17 18:56:48 -04:00
|
|
|
if (spellName != mSpellName && mSpellVisible)
|
|
|
|
{
|
|
|
|
mWeaponSpellTimer = 5.0f;
|
|
|
|
mSpellName = spellName;
|
|
|
|
mWeaponSpellBox->setCaption(mSpellName);
|
|
|
|
mWeaponSpellBox->setVisible(true);
|
|
|
|
}
|
2012-05-29 18:33:01 +02:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
mSpellStatus->setProgressRange(100);
|
|
|
|
mSpellStatus->setProgressPosition(successChancePercent);
|
2012-05-29 18:33:01 +02:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
mSpellBox->setUserString("ToolTipType", "Spell");
|
2023-03-24 01:32:27 +01:00
|
|
|
mSpellBox->setUserString("Spell", spellId.serialize());
|
2012-05-29 18:33:01 +02:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
// use the icon of the first effect
|
2023-04-20 21:07:53 +02:00
|
|
|
const ESM::MagicEffect* effect = MWBase::Environment::get().getESMStore()->get<ESM::MagicEffect>().find(
|
2013-04-17 18:56:48 -04:00
|
|
|
spell->mEffects.mList.front().mEffectID);
|
|
|
|
|
|
|
|
std::string icon = effect->mIcon;
|
2023-02-10 18:34:20 +03:00
|
|
|
std::replace(icon.begin(), icon.end(), '/', '\\');
|
2014-08-16 18:12:18 +02:00
|
|
|
int slashPos = icon.rfind('\\');
|
2013-04-17 18:56:48 -04:00
|
|
|
icon.insert(slashPos + 1, "b_");
|
2022-06-29 00:32:11 +02:00
|
|
|
icon = Misc::ResourceHelpers::correctIconPath(icon, MWBase::Environment::get().getResourceSystem()->getVFS());
|
2014-06-05 22:13:18 +02:00
|
|
|
|
2019-01-24 22:16:42 +04:00
|
|
|
mSpellImage->setSpellIcon(icon);
|
2012-05-29 18:33:01 +02:00
|
|
|
}
|
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
void HUD::setSelectedEnchantItem(const MWWorld::Ptr& item, int chargePercent)
|
|
|
|
{
|
2022-08-16 21:15:03 +02:00
|
|
|
std::string_view itemName = item.getClass().getName(item);
|
2013-04-17 18:56:48 -04:00
|
|
|
if (itemName != mSpellName && mSpellVisible)
|
|
|
|
{
|
|
|
|
mWeaponSpellTimer = 5.0f;
|
|
|
|
mSpellName = itemName;
|
|
|
|
mWeaponSpellBox->setCaption(mSpellName);
|
|
|
|
mWeaponSpellBox->setVisible(true);
|
|
|
|
}
|
2012-05-29 18:33:01 +02:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
mSpellStatus->setProgressRange(100);
|
|
|
|
mSpellStatus->setProgressPosition(chargePercent);
|
2012-05-29 18:33:01 +02:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
mSpellBox->setUserString("ToolTipType", "ItemPtr");
|
2017-03-13 02:47:52 +01:00
|
|
|
mSpellBox->setUserData(MWWorld::Ptr(item));
|
2012-05-29 18:33:01 +02:00
|
|
|
|
2014-06-05 22:13:18 +02:00
|
|
|
mSpellImage->setItem(item);
|
2012-05-29 18:33:01 +02:00
|
|
|
}
|
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
void HUD::setSelectedWeapon(const MWWorld::Ptr& item, int durabilityPercent)
|
|
|
|
{
|
2022-08-16 21:15:03 +02:00
|
|
|
std::string_view itemName = item.getClass().getName(item);
|
2013-04-17 18:56:48 -04:00
|
|
|
if (itemName != mWeaponName && mWeaponVisible)
|
|
|
|
{
|
|
|
|
mWeaponSpellTimer = 5.0f;
|
|
|
|
mWeaponName = itemName;
|
|
|
|
mWeaponSpellBox->setCaption(mWeaponName);
|
|
|
|
mWeaponSpellBox->setVisible(true);
|
|
|
|
}
|
|
|
|
|
2014-08-25 03:15:28 +02:00
|
|
|
mWeapBox->clearUserStrings();
|
2013-04-17 18:56:48 -04:00
|
|
|
mWeapBox->setUserString("ToolTipType", "ItemPtr");
|
2017-03-13 02:47:52 +01:00
|
|
|
mWeapBox->setUserData(MWWorld::Ptr(item));
|
2012-05-29 18:33:01 +02:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
mWeapStatus->setProgressRange(100);
|
|
|
|
mWeapStatus->setProgressPosition(durabilityPercent);
|
2012-05-29 18:33:01 +02:00
|
|
|
|
2014-06-05 22:13:18 +02:00
|
|
|
mWeapImage->setItem(item);
|
2012-05-29 18:33:01 +02:00
|
|
|
}
|
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
void HUD::unsetSelectedSpell()
|
2012-05-29 18:33:01 +02:00
|
|
|
{
|
2023-03-22 22:54:42 +01:00
|
|
|
std::string_view spellName = "#{Interface:None}";
|
2013-04-17 18:56:48 -04:00
|
|
|
if (spellName != mSpellName && mSpellVisible)
|
|
|
|
{
|
|
|
|
mWeaponSpellTimer = 5.0f;
|
|
|
|
mSpellName = spellName;
|
|
|
|
mWeaponSpellBox->setCaptionWithReplacing(mSpellName);
|
|
|
|
mWeaponSpellBox->setVisible(true);
|
|
|
|
}
|
2012-05-29 18:33:01 +02:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
mSpellStatus->setProgressRange(100);
|
|
|
|
mSpellStatus->setProgressPosition(0);
|
2014-06-05 22:13:18 +02:00
|
|
|
mSpellImage->setItem(MWWorld::Ptr());
|
2013-04-17 18:56:48 -04:00
|
|
|
mSpellBox->clearUserStrings();
|
|
|
|
}
|
2012-05-29 18:33:01 +02:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
void HUD::unsetSelectedWeapon()
|
2012-05-29 18:33:01 +02:00
|
|
|
{
|
2013-04-17 18:56:48 -04:00
|
|
|
std::string itemName = "#{sSkillHandtohand}";
|
|
|
|
if (itemName != mWeaponName && mWeaponVisible)
|
|
|
|
{
|
|
|
|
mWeaponSpellTimer = 5.0f;
|
|
|
|
mWeaponName = itemName;
|
|
|
|
mWeaponSpellBox->setCaptionWithReplacing(mWeaponName);
|
|
|
|
mWeaponSpellBox->setVisible(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
mWeapStatus->setProgressRange(100);
|
|
|
|
mWeapStatus->setProgressPosition(0);
|
2013-08-06 00:07:24 +02:00
|
|
|
|
|
|
|
MWBase::World* world = MWBase::Environment::get().getWorld();
|
2014-01-08 18:39:44 +01:00
|
|
|
MWWorld::Ptr player = world->getPlayerPtr();
|
2014-06-05 22:13:18 +02:00
|
|
|
|
|
|
|
mWeapImage->setItem(MWWorld::Ptr());
|
2014-08-25 03:15:28 +02:00
|
|
|
std::string icon = (player.getClass().getNpcStats(player).isWerewolf()) ? "icons\\k\\tx_werewolf_hand.dds"
|
|
|
|
: "icons\\k\\stealth_handtohand.dds";
|
|
|
|
mWeapImage->setIcon(icon);
|
2013-08-06 00:07:24 +02:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
mWeapBox->clearUserStrings();
|
2014-08-25 03:15:28 +02:00
|
|
|
mWeapBox->setUserString("ToolTipType", "Layout");
|
|
|
|
mWeapBox->setUserString("ToolTipLayout", "HandToHandToolTip");
|
|
|
|
mWeapBox->setUserString("Caption_HandToHandText", itemName);
|
|
|
|
mWeapBox->setUserString("ImageTexture_HandToHandImage", icon);
|
2012-05-29 18:33:01 +02:00
|
|
|
}
|
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
void HUD::setCrosshairVisible(bool visible)
|
|
|
|
{
|
|
|
|
mCrosshair->setVisible(visible);
|
|
|
|
}
|
2022-09-22 21:26:05 +03:00
|
|
|
|
2015-07-17 17:29:00 +02:00
|
|
|
void HUD::setCrosshairOwned(bool owned)
|
|
|
|
{
|
|
|
|
if (owned)
|
|
|
|
{
|
2015-07-18 21:29:38 +02:00
|
|
|
mCrosshair->changeWidgetSkin("HUD_Crosshair_Owned");
|
2015-07-17 17:29:00 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-07-18 21:29:38 +02:00
|
|
|
mCrosshair->changeWidgetSkin("HUD_Crosshair");
|
2015-07-17 17:29:00 +02:00
|
|
|
}
|
|
|
|
}
|
2022-09-22 21:26:05 +03:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
void HUD::setHmsVisible(bool visible)
|
|
|
|
{
|
|
|
|
mHealth->setVisible(visible);
|
|
|
|
mMagicka->setVisible(visible);
|
|
|
|
mStamina->setVisible(visible);
|
|
|
|
updatePositions();
|
|
|
|
}
|
2012-08-27 19:18:55 +02:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
void HUD::setWeapVisible(bool visible)
|
|
|
|
{
|
|
|
|
mWeapBox->setVisible(visible);
|
|
|
|
updatePositions();
|
|
|
|
}
|
2012-08-27 19:18:55 +02:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
void HUD::setSpellVisible(bool visible)
|
|
|
|
{
|
|
|
|
mSpellBox->setVisible(visible);
|
|
|
|
updatePositions();
|
|
|
|
}
|
2012-08-27 19:18:55 +02:00
|
|
|
|
2013-08-03 02:43:56 +02:00
|
|
|
void HUD::setSneakVisible(bool visible)
|
|
|
|
{
|
|
|
|
mSneakBox->setVisible(visible);
|
|
|
|
updatePositions();
|
|
|
|
}
|
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
void HUD::setEffectVisible(bool visible)
|
|
|
|
{
|
|
|
|
mEffectBox->setVisible(visible);
|
|
|
|
updatePositions();
|
|
|
|
}
|
2012-08-27 19:18:55 +02:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
void HUD::setMinimapVisible(bool visible)
|
|
|
|
{
|
|
|
|
mMinimapBox->setVisible(visible);
|
|
|
|
updatePositions();
|
|
|
|
}
|
2012-08-27 19:18:55 +02:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
void HUD::updatePositions()
|
|
|
|
{
|
2013-08-03 02:43:56 +02:00
|
|
|
int weapDx = 0, spellDx = 0, sneakDx = 0;
|
2013-04-17 18:56:48 -04:00
|
|
|
if (!mHealth->getVisible())
|
2013-08-03 02:43:56 +02:00
|
|
|
sneakDx = spellDx = weapDx = mWeapBoxBaseLeft - mHealthManaStaminaBaseLeft;
|
2012-08-27 19:18:55 +02:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
if (!mWeapBox->getVisible())
|
2013-08-03 02:43:56 +02:00
|
|
|
{
|
2013-04-17 18:56:48 -04:00
|
|
|
spellDx += mSpellBoxBaseLeft - mWeapBoxBaseLeft;
|
2013-08-03 02:43:56 +02:00
|
|
|
sneakDx = spellDx;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!mSpellBox->getVisible())
|
|
|
|
sneakDx += mSneakBoxBaseLeft - mSpellBoxBaseLeft;
|
2012-08-27 19:18:55 +02:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
mWeaponVisible = mWeapBox->getVisible();
|
|
|
|
mSpellVisible = mSpellBox->getVisible();
|
|
|
|
if (!mWeaponVisible && !mSpellVisible)
|
|
|
|
mWeaponSpellBox->setVisible(false);
|
2012-08-27 19:18:55 +02:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
mWeapBox->setPosition(mWeapBoxBaseLeft - weapDx, mWeapBox->getTop());
|
|
|
|
mSpellBox->setPosition(mSpellBoxBaseLeft - spellDx, mSpellBox->getTop());
|
2013-08-03 02:43:56 +02:00
|
|
|
mSneakBox->setPosition(mSneakBoxBaseLeft - sneakDx, mSneakBox->getTop());
|
2012-08-27 19:18:55 +02:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
const MyGUI::IntSize& viewSize = MyGUI::RenderManager::getInstance().getViewSize();
|
2012-08-27 19:18:55 +02:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
// effect box can have variable width -> variable left coordinate
|
|
|
|
int effectsDx = 0;
|
|
|
|
if (!mMinimapBox->getVisible())
|
2021-01-09 14:41:10 +04:00
|
|
|
effectsDx = mEffectBoxBaseRight - mMinimapBoxBaseRight;
|
2012-08-27 19:18:55 +02:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
mMapVisible = mMinimapBox->getVisible();
|
2014-05-20 09:45:39 +02:00
|
|
|
if (!mMapVisible)
|
|
|
|
mCellNameBox->setVisible(false);
|
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
mEffectBox->setPosition(
|
|
|
|
(viewSize.width - mEffectBoxBaseRight) - mEffectBox->getWidth() + effectsDx, mEffectBox->getTop());
|
|
|
|
}
|
2012-08-27 19:18:55 +02:00
|
|
|
|
2014-03-15 20:48:54 +01:00
|
|
|
void HUD::updateEnemyHealthBar()
|
|
|
|
{
|
2014-07-23 22:04:18 +02:00
|
|
|
MWWorld::Ptr enemy = MWBase::Environment::get().getWorld()->searchPtrViaActorId(mEnemyActorId);
|
|
|
|
if (enemy.isEmpty())
|
|
|
|
return;
|
|
|
|
MWMechanics::CreatureStats& stats = enemy.getClass().getCreatureStats(enemy);
|
2014-03-15 20:48:54 +01:00
|
|
|
mEnemyHealth->setProgressRange(100);
|
|
|
|
// Health is usually cast to int before displaying. Actors die whenever they are < 1 health.
|
|
|
|
// Therefore any value < 1 should show as an empty health bar. We do the same in statswindow :)
|
2022-02-10 22:10:46 +01:00
|
|
|
mEnemyHealth->setProgressPosition(static_cast<size_t>(stats.getHealth().getRatio() * 100));
|
2014-12-19 19:51:36 +01:00
|
|
|
|
2018-08-29 18:38:12 +03:00
|
|
|
static const float fNPCHealthBarFade = MWBase::Environment::get()
|
2023-04-20 21:07:53 +02:00
|
|
|
.getESMStore()
|
|
|
|
->get<ESM::GameSetting>()
|
2018-08-29 18:38:12 +03:00
|
|
|
.find("fNPCHealthBarFade")
|
|
|
|
->mValue.getFloat();
|
2014-12-19 19:51:36 +01:00
|
|
|
if (fNPCHealthBarFade > 0.f)
|
2021-11-06 07:30:28 +03:00
|
|
|
mEnemyHealth->setAlpha(std::clamp(mEnemyHealthTimer / fNPCHealthBarFade, 0.f, 1.f));
|
2014-03-15 20:48:54 +01:00
|
|
|
}
|
|
|
|
|
2013-07-30 06:00:20 +02:00
|
|
|
void HUD::setEnemy(const MWWorld::Ptr& enemy)
|
|
|
|
{
|
2014-07-23 22:04:18 +02:00
|
|
|
mEnemyActorId = enemy.getClass().getCreatureStats(enemy).getActorId();
|
2018-08-29 18:38:12 +03:00
|
|
|
mEnemyHealthTimer = MWBase::Environment::get()
|
2023-04-20 21:07:53 +02:00
|
|
|
.getESMStore()
|
|
|
|
->get<ESM::GameSetting>()
|
2018-08-29 18:38:12 +03:00
|
|
|
.find("fNPCHealthBarTime")
|
|
|
|
->mValue.getFloat();
|
2013-07-30 06:00:20 +02:00
|
|
|
if (!mEnemyHealth->getVisible())
|
|
|
|
mWeaponSpellBox->setPosition(mWeaponSpellBox->getPosition() - MyGUI::IntPoint(0, 20));
|
|
|
|
mEnemyHealth->setVisible(true);
|
2014-03-15 20:48:54 +01:00
|
|
|
updateEnemyHealthBar();
|
2013-04-17 18:56:48 -04:00
|
|
|
}
|
2013-03-03 12:01:19 +01:00
|
|
|
|
2014-04-23 19:49:09 +02:00
|
|
|
void HUD::resetEnemy()
|
|
|
|
{
|
2014-07-23 22:04:18 +02:00
|
|
|
mEnemyActorId = -1;
|
2014-04-23 19:49:09 +02:00
|
|
|
mEnemyHealthTimer = -1;
|
|
|
|
}
|
|
|
|
|
2017-09-23 23:09:41 +02:00
|
|
|
void HUD::clear()
|
|
|
|
{
|
|
|
|
unsetSelectedSpell();
|
|
|
|
unsetSelectedWeapon();
|
|
|
|
resetEnemy();
|
|
|
|
}
|
|
|
|
|
2015-02-20 00:00:13 +01:00
|
|
|
void HUD::customMarkerCreated(MyGUI::Widget* marker)
|
|
|
|
{
|
|
|
|
marker->eventMouseButtonClick += MyGUI::newDelegate(this, &HUD::onMapClicked);
|
|
|
|
}
|
|
|
|
|
|
|
|
void HUD::doorMarkerCreated(MyGUI::Widget* marker)
|
|
|
|
{
|
|
|
|
marker->eventMouseButtonClick += MyGUI::newDelegate(this, &HUD::onMapClicked);
|
|
|
|
}
|
|
|
|
|
2013-03-03 12:01:19 +01:00
|
|
|
}
|