Merge branch 'spellSearchExtension' into 'master'

Improve spell/magic item search to factor in magic effect names

See merge request OpenMW/openmw!417
pull/593/head
psi29a 4 years ago
commit d0b29cf254

@ -96,6 +96,7 @@ Programmers
Jan Borsodi (am0s)
Jason Hooks (jhooks)
jeaye
jefetienne
Jeffrey Haines (Jyby)
Jengerer
Jiří Kuneš (kunesj)

@ -87,6 +87,7 @@
Feature #5642: Ability to attach arrows to actor skeleton instead of bow mesh
Feature #5649: Skyrim SE compressed BSA format support
Feature #5672: Make stretch menu background configuration more accessible
Feature #5692: Improve spell/magic item search to factor in magic effect names
Task #5480: Drop Qt4 support
Task #5520: Improve cell name autocompleter implementation

@ -42,6 +42,44 @@ namespace MWGui
{
}
bool SpellModel::matchingEffectExists(std::string filter, const ESM::EffectList &effects)
{
auto wm = MWBase::Environment::get().getWindowManager();
const MWWorld::ESMStore &store =
MWBase::Environment::get().getWorld()->getStore();
for (unsigned int i = 0; i < effects.mList.size(); ++i)
{
short effectId = effects.mList[i].mEffectID;
if (effectId != -1)
{
const ESM::MagicEffect *magicEffect =
store.get<ESM::MagicEffect>().search(effectId);
std::string effectIDStr = ESM::MagicEffect::effectIdToString(effectId);
std::string fullEffectName = wm->getGameSettingString(effectIDStr, "");
if (magicEffect->mData.mFlags & ESM::MagicEffect::TargetSkill && effects.mList[i].mSkill != -1)
{
fullEffectName += " " + wm->getGameSettingString(ESM::Skill::sSkillNameIds[effects.mList[i].mSkill], "");
}
if (magicEffect->mData.mFlags & ESM::MagicEffect::TargetAttribute && effects.mList[i].mAttribute != -1)
{
fullEffectName += " " + wm->getGameSettingString(ESM::Attribute::sGmstAttributeIds[effects.mList[i].mAttribute], "");
}
std::string convert = Misc::StringUtils::lowerCaseUtf8(fullEffectName);
if (convert.find(filter) != std::string::npos)
{
return true;
}
}
}
return false;
}
void SpellModel::update()
{
mSpells.clear();
@ -61,8 +99,9 @@ namespace MWGui
continue;
std::string name = Misc::StringUtils::lowerCaseUtf8(spell->mName);
if (name.find(filter) == std::string::npos)
if (name.find(filter) == std::string::npos
&& !matchingEffectExists(filter, spell->mEffects))
continue;
Spell newSpell;
@ -103,7 +142,8 @@ namespace MWGui
std::string name = Misc::StringUtils::lowerCaseUtf8(item.getClass().getName(item));
if (name.find(filter) == std::string::npos)
if (name.find(filter) == std::string::npos
&& !matchingEffectExists(filter, enchant->mEffects))
continue;
Spell newSpell;

@ -2,6 +2,7 @@
#define OPENMW_GUI_SPELLMODEL_H
#include "../mwworld/ptr.hpp"
#include <components/esm/effectlist.hpp>
namespace MWGui
{
@ -57,6 +58,8 @@ namespace MWGui
std::vector<Spell> mSpells;
std::string mFilter;
bool matchingEffectExists(std::string filter, const ESM::EffectList &effects);
};
}

Loading…
Cancel
Save