MagicEffect: Put magnitude type into ESM::MagicEffect helper.

actorid
Jordan Ayers 11 years ago
parent 065f435225
commit 6ab7002908

@ -172,30 +172,25 @@ namespace MWGui
MWBase::Environment::get().getWindowManager()->getGameSettingString(
ESM::Attribute::sGmstAttributeIds[effectIt->mKey.mArg], "") + ")";
if (!(effect->mData.mFlags & ESM::MagicEffect::NoMagnitude))
int displayType = effect->getMagnitudeDisplayType();
if (displayType == ESM::MagicEffect::MDT_TimesInt)
{
if (it->first == 84) // special handling for fortify maximum magicka
{
std::string timesInt = MWBase::Environment::get().getWindowManager()->getGameSettingString("sXTimesINT", "");
std::stringstream formatter;
formatter << std::fixed << std::setprecision(1) << " " << (effectIt->mMagnitude / 10.0f) << timesInt;
sourcesDescription += formatter.str();
}
else
{
std::string pt = MWBase::Environment::get().getWindowManager()->getGameSettingString("spoint", "");
std::string pts = MWBase::Environment::get().getWindowManager()->getGameSettingString("spoints", "");
std::string pct = MWBase::Environment::get().getWindowManager()->getGameSettingString("spercent", "");
const bool usePct = (
(it->first >= 28 && it->first <= 36) || // Weakness effects
(it->first >= 90 && it->first <= 99) ); // Resistance effects
sourcesDescription += ": " + boost::lexical_cast<std::string>(effectIt->mMagnitude);
if ( usePct )
sourcesDescription += pct;
else
sourcesDescription += " " + ((effectIt->mMagnitude > 1) ? pts : pt);
}
std::string timesInt = MWBase::Environment::get().getWindowManager()->getGameSettingString("sXTimesINT", "");
std::stringstream formatter;
formatter << std::fixed << std::setprecision(1) << " " << (effectIt->mMagnitude / 10.0f) << timesInt;
sourcesDescription += formatter.str();
}
else if ( displayType != ESM::MagicEffect::MDT_None )
{
std::string pt = MWBase::Environment::get().getWindowManager()->getGameSettingString("spoint", "");
std::string pts = MWBase::Environment::get().getWindowManager()->getGameSettingString("spoints", "");
std::string pct = MWBase::Environment::get().getWindowManager()->getGameSettingString("spercent", "");
sourcesDescription += ": " + boost::lexical_cast<std::string>(effectIt->mMagnitude);
if ( displayType == ESM::MagicEffect::MDT_Percentage )
sourcesDescription += pct;
else // ESM::MagicEffect::MDT_Points
sourcesDescription += " " + ((effectIt->mMagnitude > 1) ? pts : pt);
}
}

@ -425,11 +425,9 @@ namespace MWGui
spellLine += " " + MWBase::Environment::get().getWindowManager()->getGameSettingString(ESM::Attribute::sGmstAttributeIds[mEffectParams.mAttribute], "");
}
if ((mEffectParams.mMagnMin >= 0 || mEffectParams.mMagnMax >= 0) && !(magicEffect->mData.mFlags & ESM::MagicEffect::NoMagnitude))
{
// Fortify Maximum Magicka display rules:
if ( mEffectParams.mEffectID == 84 )
{
if (mEffectParams.mMagnMin >= 0 || mEffectParams.mMagnMax >= 0) {
int displayType = magicEffect->getMagnitudeDisplayType();
if ( displayType == ESM::MagicEffect::MDT_TimesInt ) {
std::string timesInt = MWBase::Environment::get().getWindowManager()->getGameSettingString("sXTimesINT", "");
std::string times = MWBase::Environment::get().getWindowManager()->getGameSettingString("sXTimes", "");
std::stringstream formatter;
@ -441,20 +439,14 @@ namespace MWGui
spellLine += formatter.str();
}
else
{
const bool usePct = (
(mEffectParams.mEffectID >= 28 && mEffectParams.mEffectID <= 36) || // Weakness effects
(mEffectParams.mEffectID >= 90 && mEffectParams.mEffectID <= 99) ); // Resistance effects
if (mEffectParams.mMagnMin == mEffectParams.mMagnMax)
spellLine += " " + boost::lexical_cast<std::string>(mEffectParams.mMagnMin);
else
{
spellLine += " " + boost::lexical_cast<std::string>(mEffectParams.mMagnMin) + to + boost::lexical_cast<std::string>(mEffectParams.mMagnMax);
}
if ( usePct )
else if ( displayType != ESM::MagicEffect::MDT_None ) {
spellLine += " " + boost::lexical_cast<std::string>(mEffectParams.mMagnMin);
if (mEffectParams.mMagnMin != mEffectParams.mMagnMax)
spellLine += to + boost::lexical_cast<std::string>(mEffectParams.mMagnMax);
if ( displayType == ESM::MagicEffect::MDT_Percentage )
spellLine += pct;
else
else // ESM::MagicEffect::MDT_Points
spellLine += " " + ((mEffectParams.mMagnMin == 1 && mEffectParams.mMagnMax == 1) ? pt : pts );
}
}

@ -274,5 +274,16 @@ short MagicEffect::effectStringToId(const std::string &effect)
return name->first;
}
MagicEffect::MagnitudeDisplayType MagicEffect::getMagnitudeDisplayType() const {
if ( mData.mFlags & NoMagnitude )
return MDT_None;
if ( mIndex == 84 )
return MDT_TimesInt;
if ( ( mIndex >= 28 && mIndex <= 36 )
|| ( mIndex >= 90 && mIndex <= 99 ) )
return MDT_Percentage;
return MDT_Points;
}
}

@ -32,6 +32,13 @@ struct MagicEffect
Negative = 0x0800 // A harmful effect. Will determine whether
// eg. NPCs regard this spell as an attack. (same as 0x10?)
};
enum MagnitudeDisplayType
{
MDT_None,
MDT_Points,
MDT_Percentage,
MDT_TimesInt
};
struct MEDTstruct
{
@ -47,6 +54,7 @@ struct MagicEffect
static const std::string &effectIdToString(short effectID);
static short effectStringToId(const std::string &effect);
MagnitudeDisplayType getMagnitudeDisplayType() const;
MEDTstruct mData;

Loading…
Cancel
Save