1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-03-29 22:36:43 +00:00

Merge branch 'spellSearchExtension' into 'master'

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

See merge request OpenMW/openmw!417
This commit is contained in:
psi29a 2020-11-20 19:38:42 +00:00
commit d0b29cf254
4 changed files with 48 additions and 3 deletions

View file

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

View file

@ -87,6 +87,7 @@
Feature #5642: Ability to attach arrows to actor skeleton instead of bow mesh Feature #5642: Ability to attach arrows to actor skeleton instead of bow mesh
Feature #5649: Skyrim SE compressed BSA format support Feature #5649: Skyrim SE compressed BSA format support
Feature #5672: Make stretch menu background configuration more accessible 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 #5480: Drop Qt4 support
Task #5520: Improve cell name autocompleter implementation Task #5520: Improve cell name autocompleter implementation

View file

@ -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() void SpellModel::update()
{ {
mSpells.clear(); mSpells.clear();
@ -61,8 +99,9 @@ namespace MWGui
continue; continue;
std::string name = Misc::StringUtils::lowerCaseUtf8(spell->mName); 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; continue;
Spell newSpell; Spell newSpell;
@ -103,7 +142,8 @@ namespace MWGui
std::string name = Misc::StringUtils::lowerCaseUtf8(item.getClass().getName(item)); 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; continue;
Spell newSpell; Spell newSpell;

View file

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