forked from mirror/openmw-tes3mp
Use fMagicStartIconBlink for spell effect indicator fading
This commit is contained in:
parent
877e07823d
commit
0081a68376
5 changed files with 21 additions and 10 deletions
|
@ -24,7 +24,7 @@ namespace MWGui
|
||||||
|
|
||||||
void EffectSourceVisitor::visit (MWMechanics::EffectKey key,
|
void EffectSourceVisitor::visit (MWMechanics::EffectKey key,
|
||||||
const std::string& sourceName, int casterActorId,
|
const std::string& sourceName, int casterActorId,
|
||||||
float magnitude, float remainingTime)
|
float magnitude, float remainingTime, float totalTime)
|
||||||
{
|
{
|
||||||
MagicEffectInfo newEffectSource;
|
MagicEffectInfo newEffectSource;
|
||||||
newEffectSource.mKey = key;
|
newEffectSource.mKey = key;
|
||||||
|
@ -32,6 +32,7 @@ namespace MWGui
|
||||||
newEffectSource.mPermanent = mIsPermanent;
|
newEffectSource.mPermanent = mIsPermanent;
|
||||||
newEffectSource.mRemainingTime = remainingTime;
|
newEffectSource.mRemainingTime = remainingTime;
|
||||||
newEffectSource.mSource = sourceName;
|
newEffectSource.mSource = sourceName;
|
||||||
|
newEffectSource.mTotalTime = totalTime;
|
||||||
|
|
||||||
mEffectSources[key.mId].push_back(newEffectSource);
|
mEffectSources[key.mId].push_back(newEffectSource);
|
||||||
}
|
}
|
||||||
|
@ -67,10 +68,11 @@ namespace MWGui
|
||||||
MWBase::Environment::get().getWorld ()->getStore ().get<ESM::MagicEffect>().find(it->first);
|
MWBase::Environment::get().getWorld ()->getStore ().get<ESM::MagicEffect>().find(it->first);
|
||||||
|
|
||||||
float remainingDuration = 0;
|
float remainingDuration = 0;
|
||||||
|
float totalDuration = 0;
|
||||||
|
|
||||||
std::string sourcesDescription;
|
std::string sourcesDescription;
|
||||||
|
|
||||||
const float fadeTime = 5.f;
|
static const float fadeTime = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fMagicStartIconBlink")->getFloat();
|
||||||
|
|
||||||
for (std::vector<MagicEffectInfo>::const_iterator effectIt = it->second.begin();
|
for (std::vector<MagicEffectInfo>::const_iterator effectIt = it->second.begin();
|
||||||
effectIt != it->second.end(); ++effectIt)
|
effectIt != it->second.end(); ++effectIt)
|
||||||
|
@ -80,9 +82,15 @@ namespace MWGui
|
||||||
|
|
||||||
// if at least one of the effect sources is permanent, the effect will never wear off
|
// if at least one of the effect sources is permanent, the effect will never wear off
|
||||||
if (effectIt->mPermanent)
|
if (effectIt->mPermanent)
|
||||||
|
{
|
||||||
remainingDuration = fadeTime;
|
remainingDuration = fadeTime;
|
||||||
|
totalDuration = fadeTime;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
remainingDuration = std::max(remainingDuration, effectIt->mRemainingTime);
|
remainingDuration = std::max(remainingDuration, effectIt->mRemainingTime);
|
||||||
|
totalDuration = std::max(totalDuration, effectIt->mTotalTime);
|
||||||
|
}
|
||||||
|
|
||||||
sourcesDescription += effectIt->mSource;
|
sourcesDescription += effectIt->mSource;
|
||||||
|
|
||||||
|
@ -158,7 +166,8 @@ namespace MWGui
|
||||||
ToolTipInfo* tooltipInfo = image->getUserData<ToolTipInfo>();
|
ToolTipInfo* tooltipInfo = image->getUserData<ToolTipInfo>();
|
||||||
tooltipInfo->text = sourcesDescription;
|
tooltipInfo->text = sourcesDescription;
|
||||||
|
|
||||||
// Fade out during the last 5 seconds
|
// Fade out
|
||||||
|
if (totalDuration >= fadeTime && fadeTime > 0.f)
|
||||||
image->setAlpha(std::min(remainingDuration/fadeTime, 1.f));
|
image->setAlpha(std::min(remainingDuration/fadeTime, 1.f));
|
||||||
}
|
}
|
||||||
else if (mWidgetMap.find(it->first) != mWidgetMap.end())
|
else if (mWidgetMap.find(it->first) != mWidgetMap.end())
|
||||||
|
|
|
@ -26,12 +26,14 @@ namespace MWGui
|
||||||
MagicEffectInfo()
|
MagicEffectInfo()
|
||||||
: mPermanent(false)
|
: mPermanent(false)
|
||||||
, mMagnitude(0)
|
, mMagnitude(0)
|
||||||
, mRemainingTime(0)
|
, mRemainingTime(0.f)
|
||||||
|
, mTotalTime(0.f)
|
||||||
{}
|
{}
|
||||||
std::string mSource; // display name for effect source (e.g. potion name)
|
std::string mSource; // display name for effect source (e.g. potion name)
|
||||||
MWMechanics::EffectKey mKey;
|
MWMechanics::EffectKey mKey;
|
||||||
int mMagnitude;
|
int mMagnitude;
|
||||||
float mRemainingTime;
|
float mRemainingTime;
|
||||||
|
float mTotalTime;
|
||||||
bool mPermanent; // the effect is permanent
|
bool mPermanent; // the effect is permanent
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -46,7 +48,7 @@ namespace MWGui
|
||||||
|
|
||||||
virtual void visit (MWMechanics::EffectKey key,
|
virtual void visit (MWMechanics::EffectKey key,
|
||||||
const std::string& sourceName, int casterActorId,
|
const std::string& sourceName, int casterActorId,
|
||||||
float magnitude, float remainingTime = -1);
|
float magnitude, float remainingTime = -1, float totalTime = -1);
|
||||||
};
|
};
|
||||||
|
|
||||||
class SpellIcons
|
class SpellIcons
|
||||||
|
|
|
@ -195,7 +195,7 @@ namespace MWMechanics
|
||||||
float magnitude = effectIt->mMagnitude;
|
float magnitude = effectIt->mMagnitude;
|
||||||
|
|
||||||
if (magnitude)
|
if (magnitude)
|
||||||
visitor.visit(MWMechanics::EffectKey(effectIt->mEffectId, effectIt->mArg), name, it->second.mCasterActorId, magnitude, remainingTime);
|
visitor.visit(MWMechanics::EffectKey(effectIt->mEffectId, effectIt->mArg), name, it->second.mCasterActorId, magnitude, remainingTime, effectIt->mDuration);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,7 +102,7 @@ public:
|
||||||
|
|
||||||
virtual void visit (MWMechanics::EffectKey key,
|
virtual void visit (MWMechanics::EffectKey key,
|
||||||
const std::string& sourceName, int casterActorId,
|
const std::string& sourceName, int casterActorId,
|
||||||
float magnitude, float remainingTime = -1)
|
float magnitude, float remainingTime = -1, float totalTime = -1)
|
||||||
{
|
{
|
||||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
||||||
if ( ((key.mId == ESM::MagicEffect::CommandHumanoid && mActor.getClass().isNpc())
|
if ( ((key.mId == ESM::MagicEffect::CommandHumanoid && mActor.getClass().isNpc())
|
||||||
|
@ -200,7 +200,7 @@ namespace MWMechanics
|
||||||
|
|
||||||
virtual void visit (MWMechanics::EffectKey key,
|
virtual void visit (MWMechanics::EffectKey key,
|
||||||
const std::string& sourceName, int casterActorId,
|
const std::string& sourceName, int casterActorId,
|
||||||
float magnitude, float remainingTime = -1)
|
float magnitude, float remainingTime = -1, float totalTime = -1)
|
||||||
{
|
{
|
||||||
if (key.mId != ESM::MagicEffect::Soultrap)
|
if (key.mId != ESM::MagicEffect::Soultrap)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -74,7 +74,7 @@ namespace MWMechanics
|
||||||
{
|
{
|
||||||
virtual void visit (MWMechanics::EffectKey key,
|
virtual void visit (MWMechanics::EffectKey key,
|
||||||
const std::string& sourceName, int casterActorId,
|
const std::string& sourceName, int casterActorId,
|
||||||
float magnitude, float remainingTime = -1) = 0;
|
float magnitude, float remainingTime = -1, float totalTime = -1) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// \brief Effects currently affecting a NPC or creature
|
/// \brief Effects currently affecting a NPC or creature
|
||||||
|
|
Loading…
Reference in a new issue