mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-06 01:15:32 +00:00
MagicEffect: Put magnitude type into ESM::MagicEffect helper.
This commit is contained in:
parent
065f435225
commit
6ab7002908
4 changed files with 46 additions and 40 deletions
|
@ -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
|
||||
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 ( usePct )
|
||||
sourcesDescription += pct;
|
||||
else
|
||||
sourcesDescription += " " + ((effectIt->mMagnitude > 1) ? pts : pt);
|
||||
}
|
||||
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…
Reference in a new issue