1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-30 12:32:36 +00:00
OpenMW/apps/openmw/mwgui/widgets.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

518 lines
17 KiB
C++
Raw Normal View History

#include "widgets.hpp"
#include <iomanip>
#include <MyGUI_Button.h>
#include <MyGUI_ControllerManager.h>
#include <MyGUI_ImageBox.h>
#include <MyGUI_ProgressBar.h>
2023-11-23 19:52:18 +01:00
#include <MyGUI_UString.h>
#include <components/esm/attr.hpp>
#include <components/esm3/loadmgef.hpp>
#include <components/esm3/loadspel.hpp>
#include <components/misc/resourcehelpers.hpp>
#include <components/resource/resourcesystem.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwmechanics/magiceffects.hpp"
2015-01-10 02:50:43 +01:00
#include "../mwworld/esmstore.hpp"
namespace MWGui::Widgets
2013-04-17 18:56:48 -04:00
{
/* MWSkill */
2013-04-17 18:56:48 -04:00
MWSkill::MWSkill()
2023-06-06 17:24:22 +02:00
: mSkillNameWidget(nullptr)
2018-10-09 10:21:12 +04:00
, mSkillValueWidget(nullptr)
{
}
2013-04-17 18:56:48 -04:00
2023-06-06 17:24:22 +02:00
void MWSkill::setSkillId(ESM::RefId skill)
{
2013-04-17 18:56:48 -04:00
mSkillId = skill;
updateWidgets();
}
2013-04-17 18:56:48 -04:00
void MWSkill::setSkillValue(const SkillValue& value)
{
mValue = value;
updateWidgets();
}
2013-04-17 18:56:48 -04:00
void MWSkill::updateWidgets()
2022-09-22 21:26:05 +03:00
{
2013-04-17 18:56:48 -04:00
if (mSkillNameWidget)
{
2023-06-06 17:24:22 +02:00
const ESM::Skill* skill = MWBase::Environment::get().getESMStore()->get<ESM::Skill>().search(mSkillId);
if (skill == nullptr)
mSkillNameWidget->setCaption({});
2022-09-22 21:26:05 +03:00
else
mSkillNameWidget->setCaption(skill->mName);
2013-04-17 18:56:48 -04:00
}
if (mSkillValueWidget)
{
SkillValue::Type modified = mValue.getModified(), base = mValue.getBase();
mSkillValueWidget->setCaption(MyGUI::utility::toString(modified));
2013-04-17 18:56:48 -04:00
if (modified > base)
mSkillValueWidget->_setWidgetState("increased");
else if (modified < base)
mSkillValueWidget->_setWidgetState("decreased");
2022-09-22 21:26:05 +03:00
else
2013-04-17 18:56:48 -04:00
mSkillValueWidget->_setWidgetState("normal");
}
2022-09-22 21:26:05 +03:00
}
2012-03-20 20:24:36 +01:00
2013-04-17 18:56:48 -04:00
void MWSkill::onClicked(MyGUI::Widget* _sender)
{
eventClicked(this);
2022-09-22 21:26:05 +03:00
}
2013-04-17 18:56:48 -04:00
MWSkill::~MWSkill() {}
2013-04-17 18:56:48 -04:00
void MWSkill::initialiseOverride()
{
Base::initialiseOverride();
2013-04-17 18:56:48 -04:00
assignWidget(mSkillNameWidget, "StatName");
assignWidget(mSkillValueWidget, "StatValue");
2013-04-17 18:56:48 -04:00
MyGUI::Button* button;
2018-10-09 10:21:12 +04:00
assignWidget(button, "StatNameButton");
if (button)
{
2013-04-17 18:56:48 -04:00
mSkillNameWidget = button;
button->eventMouseButtonClick += MyGUI::newDelegate(this, &MWSkill::onClicked);
}
2013-04-17 18:56:48 -04:00
button = nullptr;
assignWidget(button, "StatValueButton");
if (button)
{
2013-04-17 18:56:48 -04:00
mSkillValueWidget = button;
button->eventMouseButtonClick += MyGUI::newDelegate(this, &MWSkill::onClicked);
}
2022-09-22 21:26:05 +03:00
}
2013-04-17 18:56:48 -04:00
/* MWAttribute */
2013-04-17 18:56:48 -04:00
MWAttribute::MWAttribute()
2023-08-03 20:21:44 +02:00
: mAttributeNameWidget(nullptr)
2018-10-09 10:21:12 +04:00
, mAttributeValueWidget(nullptr)
2022-09-22 21:26:05 +03:00
{
}
2023-08-03 20:21:44 +02:00
void MWAttribute::setAttributeId(ESM::RefId attributeId)
2013-04-17 18:56:48 -04:00
{
mId = attributeId;
2013-04-17 18:56:48 -04:00
updateWidgets();
}
2013-04-17 18:56:48 -04:00
void MWAttribute::setAttributeValue(const AttributeValue& value)
2022-09-22 21:26:05 +03:00
{
2013-04-17 18:56:48 -04:00
mValue = value;
updateWidgets();
2022-09-22 21:26:05 +03:00
}
2013-04-17 18:56:48 -04:00
void MWAttribute::onClicked(MyGUI::Widget* _sender)
2022-09-22 21:26:05 +03:00
{
2013-04-17 18:56:48 -04:00
eventClicked(this);
2022-09-22 21:26:05 +03:00
}
2013-04-17 18:56:48 -04:00
void MWAttribute::updateWidgets()
2022-09-22 21:26:05 +03:00
{
2013-04-17 18:56:48 -04:00
if (mAttributeNameWidget)
{
2023-06-18 16:21:06 +02:00
const ESM::Attribute* attribute
= MWBase::Environment::get().getESMStore()->get<ESM::Attribute>().search(mId);
if (!attribute)
2013-04-17 18:56:48 -04:00
{
mAttributeNameWidget->setCaption({});
2013-04-17 18:56:48 -04:00
}
2022-09-22 21:26:05 +03:00
else
2013-04-17 18:56:48 -04:00
{
mAttributeNameWidget->setCaption(MyGUI::UString(attribute->mName));
2013-04-17 18:56:48 -04:00
}
}
if (mAttributeValueWidget)
{
int modified = mValue.getModified(), base = mValue.getBase();
mAttributeValueWidget->setCaption(MyGUI::utility::toString(modified));
2013-04-17 18:56:48 -04:00
if (modified > base)
mAttributeValueWidget->_setWidgetState("increased");
else if (modified < base)
mAttributeValueWidget->_setWidgetState("decreased");
2022-09-22 21:26:05 +03:00
else
2013-04-17 18:56:48 -04:00
mAttributeValueWidget->_setWidgetState("normal");
}
2022-09-22 21:26:05 +03:00
}
2013-04-17 18:56:48 -04:00
void MWAttribute::initialiseOverride()
2022-09-22 21:26:05 +03:00
{
2013-04-17 18:56:48 -04:00
Base::initialiseOverride();
2013-04-17 18:56:48 -04:00
assignWidget(mAttributeNameWidget, "StatName");
assignWidget(mAttributeValueWidget, "StatValue");
2013-04-17 18:56:48 -04:00
MyGUI::Button* button;
2018-10-09 10:21:12 +04:00
assignWidget(button, "StatNameButton");
if (button)
2013-04-17 18:56:48 -04:00
{
mAttributeNameWidget = button;
button->eventMouseButtonClick += MyGUI::newDelegate(this, &MWAttribute::onClicked);
}
2013-04-17 18:56:48 -04:00
button = nullptr;
assignWidget(button, "StatValueButton");
if (button)
{
mAttributeValueWidget = button;
button->eventMouseButtonClick += MyGUI::newDelegate(this, &MWAttribute::onClicked);
}
2022-09-22 21:26:05 +03:00
}
2013-04-17 18:56:48 -04:00
/* MWSpell */
2013-04-17 18:56:48 -04:00
MWSpell::MWSpell()
: mSpellNameWidget(nullptr)
2022-09-22 21:26:05 +03: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 MWSpell::setSpellId(const ESM::RefId& spellId)
2013-04-17 18:56:48 -04:00
{
2014-09-26 17:12:48 +02:00
mId = spellId;
2013-04-17 18:56:48 -04:00
updateWidgets();
}
2013-04-17 18:56:48 -04:00
void MWSpell::createEffectWidgets(
std::vector<MyGUI::Widget*>& effects, MyGUI::Widget* creator, MyGUI::IntCoord& coord, int flags)
{
2023-04-20 21:07:53 +02:00
const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore();
2022-09-22 21:26:05 +03:00
2013-04-17 18:56:48 -04:00
const ESM::Spell* spell = store.get<ESM::Spell>().search(mId);
2014-09-13 04:07:40 +02:00
MYGUI_ASSERT(spell, "spell with id '" << mId << "' not found");
2022-09-22 21:26:05 +03:00
for (const ESM::IndexedENAMstruct& effectInfo : spell->mEffects.mList)
2022-09-22 21:26:05 +03:00
{
2013-04-17 18:56:48 -04:00
MWSpellEffectPtr effect
2014-09-13 04:07:40 +02:00
= creator->createWidget<MWSpellEffect>("MW_EffectImage", coord, MyGUI::Align::Default);
2013-04-17 18:56:48 -04:00
SpellEffectParams params;
params.mEffectID = effectInfo.mData.mEffectID;
params.mSkill = ESM::Skill::indexToRefId(effectInfo.mData.mSkill);
params.mAttribute = ESM::Attribute::indexToRefId(effectInfo.mData.mAttribute);
params.mDuration = effectInfo.mData.mDuration;
params.mMagnMin = effectInfo.mData.mMagnMin;
params.mMagnMax = effectInfo.mData.mMagnMax;
params.mRange = effectInfo.mData.mRange;
params.mIsConstant = (flags & MWEffectList::EF_Constant) != 0;
2013-04-17 18:56:48 -04:00
params.mNoTarget = (flags & MWEffectList::EF_NoTarget);
2019-05-06 23:48:13 +00:00
params.mNoMagnitude = (flags & MWEffectList::EF_NoMagnitude);
2014-09-13 04:07:40 +02:00
effect->setSpellEffect(params);
2013-04-17 18:56:48 -04:00
effects.push_back(effect);
coord.top += effect->getHeight();
coord.width = std::max(coord.width, effect->getRequestedWidth());
}
2022-09-22 21:26:05 +03:00
}
2012-04-18 18:09:30 +02:00
2013-04-17 18:56:48 -04:00
void MWSpell::updateWidgets()
2022-09-22 21:26:05 +03:00
{
2013-04-17 18:56:48 -04:00
if (mSpellNameWidget && MWBase::Environment::get().getWindowManager())
{
2023-04-20 21:07:53 +02:00
const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore();
2012-04-18 18:09:30 +02:00
2013-04-17 18:56:48 -04:00
const ESM::Spell* spell = store.get<ESM::Spell>().search(mId);
if (spell)
mSpellNameWidget->setCaption(spell->mName);
2022-09-22 21:26:05 +03:00
else
mSpellNameWidget->setCaption({});
2013-04-17 18:56:48 -04:00
}
2022-09-22 21:26:05 +03:00
}
2012-04-18 18:09:30 +02:00
2013-04-17 18:56:48 -04:00
void MWSpell::initialiseOverride()
2022-09-22 21:26:05 +03:00
{
2013-04-17 18:56:48 -04:00
Base::initialiseOverride();
2022-09-22 21:26:05 +03:00
2013-04-17 18:56:48 -04:00
assignWidget(mSpellNameWidget, "StatName");
}
2013-04-17 18:56:48 -04:00
MWSpell::~MWSpell() {}
2013-04-17 18:56:48 -04:00
/* MWEffectList */
2022-09-22 21:26:05 +03:00
2013-04-17 18:56:48 -04:00
MWEffectList::MWEffectList()
: mEffectList(0)
2022-09-22 21:26:05 +03:00
{
}
2013-04-17 18:56:48 -04:00
void MWEffectList::setEffectList(const SpellEffectList& list)
{
2013-04-17 18:56:48 -04:00
mEffectList = list;
updateWidgets();
}
2022-09-22 21:26:05 +03:00
2013-04-17 18:56:48 -04:00
void MWEffectList::createEffectWidgets(
std::vector<MyGUI::Widget*>& effects, MyGUI::Widget* creator, MyGUI::IntCoord& coord, bool center, int flags)
2022-09-22 21:26:05 +03:00
{
2013-04-17 18:56:48 -04:00
// We don't know the width of all the elements beforehand, so we do it in
// 2 steps: first, create all widgets and check their width....
2018-10-09 10:21:12 +04:00
MWSpellEffectPtr effect = nullptr;
2013-04-17 18:56:48 -04:00
int maxwidth = coord.width;
for (auto& effectInfo : mEffectList)
{
2013-04-17 18:56:48 -04:00
effect = creator->createWidget<MWSpellEffect>("MW_EffectImage", coord, MyGUI::Align::Default);
effectInfo.mIsConstant = (flags & EF_Constant) || effectInfo.mIsConstant;
effectInfo.mNoTarget = (flags & EF_NoTarget) || effectInfo.mNoTarget;
2019-05-06 23:48:13 +00:00
effectInfo.mNoMagnitude = (flags & EF_NoMagnitude) || effectInfo.mNoMagnitude;
effect->setSpellEffect(effectInfo);
2013-04-17 18:56:48 -04:00
effects.push_back(effect);
if (effect->getRequestedWidth() > maxwidth)
maxwidth = effect->getRequestedWidth();
2022-09-22 21:26:05 +03:00
2013-04-17 18:56:48 -04:00
coord.top += effect->getHeight();
}
2012-04-18 18:09:30 +02:00
2013-04-17 18:56:48 -04:00
// ... then adjust the size for all widgets
for (MyGUI::Widget* effectWidget : effects)
{
2018-10-09 10:21:12 +04:00
effect = effectWidget->castType<MWSpellEffect>();
bool needcenter = center && (maxwidth > effect->getRequestedWidth());
2013-04-17 18:56:48 -04:00
int diff = maxwidth - effect->getRequestedWidth();
if (needcenter)
2013-04-17 18:56:48 -04:00
{
effect->setCoord(
diff / 2, effect->getCoord().top, effect->getRequestedWidth(), effect->getCoord().height);
}
else
{
effect->setCoord(0, effect->getCoord().top, effect->getRequestedWidth(), effect->getCoord().height);
}
}
2012-10-03 15:06:54 +02:00
2013-04-17 18:56:48 -04:00
// inform the parent about width
coord.width = maxwidth;
}
2012-10-03 15:06:54 +02:00
2013-04-17 18:56:48 -04:00
void MWEffectList::updateWidgets() {}
2012-10-03 15:06:54 +02:00
2013-04-17 18:56:48 -04:00
void MWEffectList::initialiseOverride()
{
2013-04-17 18:56:48 -04:00
Base::initialiseOverride();
}
2013-04-17 18:56:48 -04:00
MWEffectList::~MWEffectList() {}
2022-09-22 21:26:05 +03:00
2013-04-17 18:56:48 -04:00
SpellEffectList MWEffectList::effectListFromESM(const ESM::EffectList* effects)
{
2013-04-17 18:56:48 -04:00
SpellEffectList result;
for (const ESM::IndexedENAMstruct& effectInfo : effects->mList)
2013-04-17 18:56:48 -04:00
{
SpellEffectParams params;
params.mEffectID = effectInfo.mData.mEffectID;
params.mSkill = ESM::Skill::indexToRefId(effectInfo.mData.mSkill);
params.mAttribute = ESM::Attribute::indexToRefId(effectInfo.mData.mAttribute);
params.mDuration = effectInfo.mData.mDuration;
params.mMagnMin = effectInfo.mData.mMagnMin;
params.mMagnMax = effectInfo.mData.mMagnMax;
params.mRange = effectInfo.mData.mRange;
params.mArea = effectInfo.mData.mArea;
2013-04-17 18:56:48 -04:00
result.push_back(params);
}
return result;
}
2012-04-30 01:53:22 +02:00
2013-04-17 18:56:48 -04:00
/* MWSpellEffect */
MWSpellEffect::MWSpellEffect()
2018-10-09 10:21:12 +04:00
: mImageWidget(nullptr)
, mTextWidget(nullptr)
2013-04-17 18:56:48 -04:00
, mRequestedWidth(0)
2012-10-11 18:26:29 +02:00
{
}
2013-04-17 18:56:48 -04:00
void MWSpellEffect::setSpellEffect(const SpellEffectParams& params)
2022-09-22 21:26:05 +03:00
{
2013-04-17 18:56:48 -04:00
mEffectParams = params;
updateWidgets();
2022-09-22 21:26:05 +03:00
}
2013-04-17 18:56:48 -04:00
void MWSpellEffect::updateWidgets()
2022-09-22 21:26:05 +03:00
{
2013-04-17 18:56:48 -04:00
if (!mEffectParams.mKnown)
{
2013-04-17 18:56:48 -04:00
mTextWidget->setCaption("?");
mTextWidget->setCoord(sIconOffset / 2, mTextWidget->getCoord().top, mTextWidget->getCoord().width,
2013-04-17 18:56:48 -04:00
mTextWidget->getCoord().height); // Compensates for the missing image when effect is not known
mRequestedWidth = mTextWidget->getTextSize().width + sIconOffset;
mImageWidget->setImageTexture({});
2022-09-22 21:26:05 +03:00
return;
}
2012-10-03 15:06:54 +02:00
2023-04-20 21:07:53 +02:00
const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore();
2012-10-03 15:06:54 +02:00
const ESM::MagicEffect* magicEffect = store.get<ESM::MagicEffect>().find(mEffectParams.mEffectID);
const ESM::Attribute* attribute = store.get<ESM::Attribute>().search(mEffectParams.mAttribute);
2023-08-03 20:21:44 +02:00
const ESM::Skill* skill = store.get<ESM::Skill>().search(mEffectParams.mSkill);
2023-03-20 19:59:11 +01:00
auto windowManager = MWBase::Environment::get().getWindowManager();
std::string_view pt = windowManager->getGameSettingString("spoint", {});
std::string_view pts = windowManager->getGameSettingString("spoints", {});
std::string_view pct = windowManager->getGameSettingString("spercent", {});
std::string_view ft = windowManager->getGameSettingString("sfeet", {});
std::string_view lvl = windowManager->getGameSettingString("sLevel", {});
std::string_view lvls = windowManager->getGameSettingString("sLevels", {});
std::string to = " " + std::string{ windowManager->getGameSettingString("sTo", {}) } + " ";
std::string sec = " " + std::string{ windowManager->getGameSettingString("ssecond", {}) };
std::string secs = " " + std::string{ windowManager->getGameSettingString("sseconds", {}) };
std::string spellLine = MWMechanics::getMagicEffectString(*magicEffect, attribute, skill);
if ((mEffectParams.mMagnMin || mEffectParams.mMagnMax) && !mEffectParams.mNoMagnitude)
2013-04-17 18:56:48 -04:00
{
ESM::MagicEffect::MagnitudeDisplayType displayType = magicEffect->getMagnitudeDisplayType();
if (displayType == ESM::MagicEffect::MDT_TimesInt)
2013-04-17 18:56:48 -04:00
{
2023-03-20 19:59:11 +01:00
std::string_view timesInt = windowManager->getGameSettingString("sXTimesINT", {});
std::stringstream formatter;
formatter << std::fixed << std::setprecision(1) << " " << (mEffectParams.mMagnMin / 10.0f);
if (mEffectParams.mMagnMin != mEffectParams.mMagnMax)
formatter << to << (mEffectParams.mMagnMax / 10.0f);
formatter << timesInt;
spellLine += formatter.str();
2013-04-17 18:56:48 -04:00
}
else if (displayType != ESM::MagicEffect::MDT_None)
2013-04-17 18:56:48 -04:00
{
spellLine += " " + MyGUI::utility::toString(mEffectParams.mMagnMin);
if (mEffectParams.mMagnMin != mEffectParams.mMagnMax)
spellLine += to + MyGUI::utility::toString(mEffectParams.mMagnMax);
2014-11-05 00:46:33 +13:00
if (displayType == ESM::MagicEffect::MDT_Percentage)
spellLine += pct;
else if (displayType == ESM::MagicEffect::MDT_Feet)
2013-04-17 18:56:48 -04:00
{
spellLine += ' ';
spellLine += ft;
2013-04-17 18:56:48 -04:00
}
else if (displayType == ESM::MagicEffect::MDT_Level)
{
spellLine += ' ';
if (mEffectParams.mMagnMin == mEffectParams.mMagnMax && std::abs(mEffectParams.mMagnMin) == 1)
spellLine += lvl;
2022-09-22 21:26:05 +03:00
else
spellLine += lvls;
2013-04-17 18:56:48 -04:00
}
else // ESM::MagicEffect::MDT_Points
{
spellLine += ' ';
2013-04-17 18:56:48 -04:00
if (mEffectParams.mMagnMin == mEffectParams.mMagnMax && std::abs(mEffectParams.mMagnMin) == 1)
spellLine += pt;
else
spellLine += pts;
2013-04-17 18:56:48 -04:00
}
}
}
// constant effects have no duration and no target
if (!mEffectParams.mIsConstant)
{
if (!(magicEffect->mData.mFlags & ESM::MagicEffect::AppliedOnce))
mEffectParams.mDuration = std::max(1, mEffectParams.mDuration);
2014-11-05 00:46:33 +13:00
if (mEffectParams.mDuration > 0 && !(magicEffect->mData.mFlags & ESM::MagicEffect::NoDuration))
2022-09-22 21:26:05 +03:00
{
spellLine += ' ';
2023-03-20 19:59:11 +01:00
spellLine += windowManager->getGameSettingString("sfor", {});
2013-04-17 18:56:48 -04:00
spellLine += ' ' + MyGUI::utility::toString(mEffectParams.mDuration)
+ ((mEffectParams.mDuration == 1) ? sec : secs);
2022-09-22 21:26:05 +03:00
}
if (mEffectParams.mArea > 0)
2022-09-22 21:26:05 +03:00
{
2013-04-17 18:56:48 -04:00
spellLine += " #{sin} " + MyGUI::utility::toString(mEffectParams.mArea) + " #{sfootarea}";
2022-09-22 21:26:05 +03:00
}
2013-04-17 18:56:48 -04:00
// potions have no target
if (!mEffectParams.mNoTarget)
2022-09-22 21:26:05 +03:00
{
spellLine += ' ';
2023-03-20 19:59:11 +01:00
spellLine += windowManager->getGameSettingString("sonword", {});
spellLine += ' ';
2013-04-17 18:56:48 -04:00
if (mEffectParams.mRange == ESM::RT_Self)
2023-03-20 19:59:11 +01:00
spellLine += windowManager->getGameSettingString("sRangeSelf", {});
2013-04-17 18:56:48 -04:00
else if (mEffectParams.mRange == ESM::RT_Touch)
2023-03-20 19:59:11 +01:00
spellLine += windowManager->getGameSettingString("sRangeTouch", {});
2013-04-17 18:56:48 -04:00
else if (mEffectParams.mRange == ESM::RT_Target)
2023-03-20 19:59:11 +01:00
spellLine += windowManager->getGameSettingString("sRangeTarget", {});
2022-09-22 21:26:05 +03:00
}
2013-04-17 18:56:48 -04:00
}
2014-09-13 04:07:40 +02:00
mTextWidget->setCaptionWithReplacing(spellLine);
2013-04-17 18:56:48 -04:00
mRequestedWidth = mTextWidget->getTextSize().width + sIconOffset;
mImageWidget->setImageTexture(Misc::ResourceHelpers::correctIconPath(
magicEffect->mIcon, MWBase::Environment::get().getResourceSystem()->getVFS()));
2022-09-22 21:26:05 +03:00
}
2014-09-26 17:12:48 +02:00
MWSpellEffect::~MWSpellEffect() {}
2022-09-22 21:26:05 +03:00
2013-04-17 18:56:48 -04:00
void MWSpellEffect::initialiseOverride()
2022-09-22 21:26:05 +03:00
{
2013-04-17 18:56:48 -04:00
Base::initialiseOverride();
2022-09-22 21:26:05 +03:00
2013-04-17 18:56:48 -04:00
assignWidget(mTextWidget, "Text");
assignWidget(mImageWidget, "Image");
2022-09-22 21:26:05 +03:00
}
2013-04-17 18:56:48 -04:00
/* MWDynamicStat */
2022-09-22 21:26:05 +03:00
2013-04-17 18:56:48 -04:00
MWDynamicStat::MWDynamicStat()
: mValue(0)
, mMax(1)
2018-10-09 10:21:12 +04:00
, mTextWidget(nullptr)
, mBarWidget(nullptr)
, mBarTextWidget(nullptr)
2013-04-17 18:56:48 -04:00
{
}
void MWDynamicStat::setValue(int cur, int max)
2022-09-22 21:26:05 +03:00
{
mValue = cur;
2013-04-17 18:56:48 -04:00
mMax = max;
2013-04-17 18:56:48 -04:00
if (mBarWidget)
{
mBarWidget->setProgressRange(std::max(0, mMax));
mBarWidget->setProgressPosition(std::max(0, mValue));
2013-04-17 18:56:48 -04:00
}
2013-04-17 18:56:48 -04:00
if (mBarTextWidget)
{
std::stringstream out;
out << mValue << "/" << mMax;
mBarTextWidget->setCaption(out.str());
2013-04-17 18:56:48 -04:00
}
2022-09-22 21:26:05 +03:00
}
void MWDynamicStat::setTitle(std::string_view text)
2022-09-22 21:26:05 +03:00
{
2013-04-17 18:56:48 -04:00
if (mTextWidget)
mTextWidget->setCaption(MyGUI::UString(text));
2022-09-22 21:26:05 +03:00
}
2013-04-17 18:56:48 -04:00
MWDynamicStat::~MWDynamicStat() {}
2013-04-17 18:56:48 -04:00
void MWDynamicStat::initialiseOverride()
2022-09-22 21:26:05 +03:00
{
2013-04-17 18:56:48 -04:00
Base::initialiseOverride();
2022-09-22 21:26:05 +03:00
2013-04-17 18:56:48 -04:00
assignWidget(mTextWidget, "Text");
assignWidget(mBarWidget, "Bar");
assignWidget(mBarTextWidget, "BarText");
}
2022-09-22 21:26:05 +03:00
}