mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 21:23:52 +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,32 +172,27 @@ namespace MWGui
|
||||||
MWBase::Environment::get().getWindowManager()->getGameSettingString(
|
MWBase::Environment::get().getWindowManager()->getGameSettingString(
|
||||||
ESM::Attribute::sGmstAttributeIds[effectIt->mKey.mArg], "") + ")";
|
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::string timesInt = MWBase::Environment::get().getWindowManager()->getGameSettingString("sXTimesINT", "");
|
||||||
std::stringstream formatter;
|
std::stringstream formatter;
|
||||||
formatter << std::fixed << std::setprecision(1) << " " << (effectIt->mMagnitude / 10.0f) << timesInt;
|
formatter << std::fixed << std::setprecision(1) << " " << (effectIt->mMagnitude / 10.0f) << timesInt;
|
||||||
sourcesDescription += formatter.str();
|
sourcesDescription += formatter.str();
|
||||||
}
|
}
|
||||||
else
|
else if ( displayType != ESM::MagicEffect::MDT_None )
|
||||||
{
|
{
|
||||||
std::string pt = MWBase::Environment::get().getWindowManager()->getGameSettingString("spoint", "");
|
std::string pt = MWBase::Environment::get().getWindowManager()->getGameSettingString("spoint", "");
|
||||||
std::string pts = MWBase::Environment::get().getWindowManager()->getGameSettingString("spoints", "");
|
std::string pts = MWBase::Environment::get().getWindowManager()->getGameSettingString("spoints", "");
|
||||||
std::string pct = MWBase::Environment::get().getWindowManager()->getGameSettingString("spercent", "");
|
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);
|
sourcesDescription += ": " + boost::lexical_cast<std::string>(effectIt->mMagnitude);
|
||||||
if ( usePct )
|
if ( displayType == ESM::MagicEffect::MDT_Percentage )
|
||||||
sourcesDescription += pct;
|
sourcesDescription += pct;
|
||||||
else
|
else // ESM::MagicEffect::MDT_Points
|
||||||
sourcesDescription += " " + ((effectIt->mMagnitude > 1) ? pts : pt);
|
sourcesDescription += " " + ((effectIt->mMagnitude > 1) ? pts : pt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (remainingDuration > 0.f)
|
if (remainingDuration > 0.f)
|
||||||
{
|
{
|
||||||
|
|
|
@ -425,11 +425,9 @@ namespace MWGui
|
||||||
spellLine += " " + MWBase::Environment::get().getWindowManager()->getGameSettingString(ESM::Attribute::sGmstAttributeIds[mEffectParams.mAttribute], "");
|
spellLine += " " + MWBase::Environment::get().getWindowManager()->getGameSettingString(ESM::Attribute::sGmstAttributeIds[mEffectParams.mAttribute], "");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((mEffectParams.mMagnMin >= 0 || mEffectParams.mMagnMax >= 0) && !(magicEffect->mData.mFlags & ESM::MagicEffect::NoMagnitude))
|
if (mEffectParams.mMagnMin >= 0 || mEffectParams.mMagnMax >= 0) {
|
||||||
{
|
int displayType = magicEffect->getMagnitudeDisplayType();
|
||||||
// Fortify Maximum Magicka display rules:
|
if ( displayType == ESM::MagicEffect::MDT_TimesInt ) {
|
||||||
if ( mEffectParams.mEffectID == 84 )
|
|
||||||
{
|
|
||||||
std::string timesInt = MWBase::Environment::get().getWindowManager()->getGameSettingString("sXTimesINT", "");
|
std::string timesInt = MWBase::Environment::get().getWindowManager()->getGameSettingString("sXTimesINT", "");
|
||||||
std::string times = MWBase::Environment::get().getWindowManager()->getGameSettingString("sXTimes", "");
|
std::string times = MWBase::Environment::get().getWindowManager()->getGameSettingString("sXTimes", "");
|
||||||
std::stringstream formatter;
|
std::stringstream formatter;
|
||||||
|
@ -441,20 +439,14 @@ namespace MWGui
|
||||||
|
|
||||||
spellLine += formatter.str();
|
spellLine += formatter.str();
|
||||||
}
|
}
|
||||||
else
|
else if ( displayType != ESM::MagicEffect::MDT_None ) {
|
||||||
{
|
|
||||||
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);
|
spellLine += " " + boost::lexical_cast<std::string>(mEffectParams.mMagnMin);
|
||||||
else
|
if (mEffectParams.mMagnMin != mEffectParams.mMagnMax)
|
||||||
{
|
spellLine += to + boost::lexical_cast<std::string>(mEffectParams.mMagnMax);
|
||||||
spellLine += " " + boost::lexical_cast<std::string>(mEffectParams.mMagnMin) + to + boost::lexical_cast<std::string>(mEffectParams.mMagnMax);
|
|
||||||
}
|
if ( displayType == ESM::MagicEffect::MDT_Percentage )
|
||||||
if ( usePct )
|
|
||||||
spellLine += pct;
|
spellLine += pct;
|
||||||
else
|
else // ESM::MagicEffect::MDT_Points
|
||||||
spellLine += " " + ((mEffectParams.mMagnMin == 1 && mEffectParams.mMagnMax == 1) ? pt : pts );
|
spellLine += " " + ((mEffectParams.mMagnMin == 1 && mEffectParams.mMagnMax == 1) ? pt : pts );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -274,5 +274,16 @@ short MagicEffect::effectStringToId(const std::string &effect)
|
||||||
return name->first;
|
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
|
Negative = 0x0800 // A harmful effect. Will determine whether
|
||||||
// eg. NPCs regard this spell as an attack. (same as 0x10?)
|
// eg. NPCs regard this spell as an attack. (same as 0x10?)
|
||||||
};
|
};
|
||||||
|
enum MagnitudeDisplayType
|
||||||
|
{
|
||||||
|
MDT_None,
|
||||||
|
MDT_Points,
|
||||||
|
MDT_Percentage,
|
||||||
|
MDT_TimesInt
|
||||||
|
};
|
||||||
|
|
||||||
struct MEDTstruct
|
struct MEDTstruct
|
||||||
{
|
{
|
||||||
|
@ -47,6 +54,7 @@ struct MagicEffect
|
||||||
|
|
||||||
static const std::string &effectIdToString(short effectID);
|
static const std::string &effectIdToString(short effectID);
|
||||||
static short effectStringToId(const std::string &effect);
|
static short effectStringToId(const std::string &effect);
|
||||||
|
MagnitudeDisplayType getMagnitudeDisplayType() const;
|
||||||
|
|
||||||
|
|
||||||
MEDTstruct mData;
|
MEDTstruct mData;
|
||||||
|
|
Loading…
Reference in a new issue