forked from teamnwah/openmw-tes3coop
Merge remote-tracking branch 'jordan-ayers/topic/MagicEffectDisplayFormat'
This commit is contained in:
commit
3c580fbc59
4 changed files with 90 additions and 12 deletions
|
@ -2,6 +2,9 @@
|
|||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
||||
#include "../mwbase/world.hpp"
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/windowmanager.hpp"
|
||||
|
@ -169,13 +172,34 @@ namespace MWGui
|
|||
MWBase::Environment::get().getWindowManager()->getGameSettingString(
|
||||
ESM::Attribute::sGmstAttributeIds[effectIt->mKey.mArg], "") + ")";
|
||||
|
||||
if (!(effect->mData.mFlags & ESM::MagicEffect::NoMagnitude))
|
||||
ESM::MagicEffect::MagnitudeDisplayType displayType = effect->getMagnitudeDisplayType();
|
||||
if (displayType == ESM::MagicEffect::MDT_TimesInt)
|
||||
{
|
||||
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", "");
|
||||
|
||||
sourcesDescription += ": " + boost::lexical_cast<std::string>(effectIt->mMagnitude);
|
||||
sourcesDescription += " " + ((effectIt->mMagnitude > 1) ? pts : pt);
|
||||
|
||||
if ( displayType == ESM::MagicEffect::MDT_Percentage )
|
||||
sourcesDescription += MWBase::Environment::get().getWindowManager()->getGameSettingString("spercent", "");
|
||||
else if ( displayType == ESM::MagicEffect::MDT_Feet )
|
||||
sourcesDescription += " " + MWBase::Environment::get().getWindowManager()->getGameSettingString("sfeet", "");
|
||||
else if ( displayType == ESM::MagicEffect::MDT_Level )
|
||||
{
|
||||
sourcesDescription += " " + ((effectIt->mMagnitude > 1) ?
|
||||
MWBase::Environment::get().getWindowManager()->getGameSettingString("sLevels", "") :
|
||||
MWBase::Environment::get().getWindowManager()->getGameSettingString("sLevel", "") );
|
||||
}
|
||||
else // ESM::MagicEffect::MDT_Points
|
||||
{
|
||||
sourcesDescription += " " + ((effectIt->mMagnitude > 1) ?
|
||||
MWBase::Environment::get().getWindowManager()->getGameSettingString("spoints", "") :
|
||||
MWBase::Environment::get().getWindowManager()->getGameSettingString("spoint", "") );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
||||
#include <MyGUI_ProgressBar.h>
|
||||
#include <MyGUI_ImageBox.h>
|
||||
#include <MyGUI_ControllerManager.h>
|
||||
|
@ -405,6 +408,10 @@ namespace MWGui
|
|||
|
||||
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", "");
|
||||
std::string ft = MWBase::Environment::get().getWindowManager()->getGameSettingString("sfeet", "");
|
||||
std::string lvl = MWBase::Environment::get().getWindowManager()->getGameSettingString("sLevel", "");
|
||||
std::string lvls = MWBase::Environment::get().getWindowManager()->getGameSettingString("sLevels", "");
|
||||
std::string to = " " + MWBase::Environment::get().getWindowManager()->getGameSettingString("sTo", "") + " ";
|
||||
std::string sec = " " + MWBase::Environment::get().getWindowManager()->getGameSettingString("ssecond", "");
|
||||
std::string secs = " " + MWBase::Environment::get().getWindowManager()->getGameSettingString("sseconds", "");
|
||||
|
@ -421,13 +428,32 @@ 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))
|
||||
{
|
||||
if (mEffectParams.mMagnMin == mEffectParams.mMagnMax)
|
||||
spellLine += " " + boost::lexical_cast<std::string>(mEffectParams.mMagnMin) + " " + ((mEffectParams.mMagnMin == 1) ? pt : pts);
|
||||
else
|
||||
{
|
||||
spellLine += " " + boost::lexical_cast<std::string>(mEffectParams.mMagnMin) + to + boost::lexical_cast<std::string>(mEffectParams.mMagnMax) + " " + pts;
|
||||
if (mEffectParams.mMagnMin >= 0 || mEffectParams.mMagnMax >= 0) {
|
||||
ESM::MagicEffect::MagnitudeDisplayType displayType = magicEffect->getMagnitudeDisplayType();
|
||||
if ( displayType == ESM::MagicEffect::MDT_TimesInt ) {
|
||||
std::string timesInt = MWBase::Environment::get().getWindowManager()->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();
|
||||
}
|
||||
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 if ( displayType == ESM::MagicEffect::MDT_Feet )
|
||||
spellLine += " " + ft;
|
||||
else if ( displayType == ESM::MagicEffect::MDT_Level )
|
||||
spellLine += " " + ((mEffectParams.mMagnMin == 1 && mEffectParams.mMagnMax == 1) ? lvl : lvls );
|
||||
else // ESM::MagicEffect::MDT_Points
|
||||
spellLine += " " + ((mEffectParams.mMagnMin == 1 && mEffectParams.mMagnMax == 1) ? pt : pts );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -274,5 +274,23 @@ 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 == 59 ||
|
||||
( mIndex >= 64 && mIndex <= 66) )
|
||||
return MDT_Feet;
|
||||
if ( mIndex == 118 || mIndex == 119 )
|
||||
return MDT_Level;
|
||||
if ( ( mIndex >= 28 && mIndex <= 36 )
|
||||
|| ( mIndex >= 90 && mIndex <= 99 )
|
||||
|| mIndex == 40 || mIndex == 47
|
||||
|| mIndex == 57 || mIndex == 68 )
|
||||
return MDT_Percentage;
|
||||
|
||||
return MDT_Points;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -32,6 +32,15 @@ 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_Feet,
|
||||
MDT_Level,
|
||||
MDT_Percentage,
|
||||
MDT_Points,
|
||||
MDT_TimesInt
|
||||
};
|
||||
|
||||
struct MEDTstruct
|
||||
{
|
||||
|
@ -47,6 +56,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