Skip to content

Commit 7b210c9

Browse files
committed
Merge branch 'bigiconmode' into 'master'
Use normalized paths to construct big icon paths See merge request OpenMW/openmw!5259
2 parents 8a9d316 + 2dca72b commit 7b210c9

File tree

5 files changed

+15
-15
lines changed

5 files changed

+15
-15
lines changed

apps/openmw/mwgui/hud.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -354,12 +354,8 @@ namespace MWGui
354354
// use the icon of the first effect
355355
const ESM::MagicEffect* effect = MWBase::Environment::get().getESMStore()->get<ESM::MagicEffect>().find(
356356
spell->mEffects.mList.front().mData.mEffectID);
357-
std::string icon = effect->mIcon;
358-
std::replace(icon.begin(), icon.end(), '/', '\\');
359-
size_t slashPos = icon.rfind('\\');
360-
icon.insert(slashPos + 1, "b_");
361-
const VFS::Path::Normalized iconPath = Misc::ResourceHelpers::correctIconPath(
362-
VFS::Path::toNormalized(icon), *MWBase::Environment::get().getResourceSystem()->getVFS());
357+
const VFS::Path::Normalized iconPath = Misc::ResourceHelpers::correctBigIconPath(
358+
VFS::Path::toNormalized(effect->mIcon), *MWBase::Environment::get().getResourceSystem()->getVFS());
363359
mSpellImage->setSpellIcon(iconPath);
364360
}
365361
else

apps/openmw/mwgui/quickkeysmenu.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -323,11 +323,8 @@ namespace MWGui
323323
const ESM::MagicEffect* effect
324324
= esmStore.get<ESM::MagicEffect>().find(spell->mEffects.mList.front().mData.mEffectID);
325325

326-
std::string path = effect->mIcon;
327-
std::replace(path.begin(), path.end(), '/', '\\');
328-
path.insert(path.rfind('\\') + 1, "b_");
329-
const VFS::Path::Normalized iconPath = Misc::ResourceHelpers::correctIconPath(
330-
VFS::Path::toNormalized(path), *MWBase::Environment::get().getResourceSystem()->getVFS());
326+
const VFS::Path::Normalized iconPath = Misc::ResourceHelpers::correctBigIconPath(
327+
VFS::Path::toNormalized(effect->mIcon), *MWBase::Environment::get().getResourceSystem()->getVFS());
331328

332329
float scale = 1.f;
333330
MyGUI::ITexture* texture

apps/openmw/mwgui/tooltips.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -959,10 +959,8 @@ namespace MWGui
959959
const auto& store = MWBase::Environment::get().getESMStore();
960960
const ESM::MagicEffect* effect = store->get<ESM::MagicEffect>().find(effectId);
961961

962-
std::string icon = effect->mIcon;
963-
icon.insert(icon.rfind('\\') + 1, "b_");
964-
const VFS::Path::Normalized iconPath = Misc::ResourceHelpers::correctIconPath(
965-
VFS::Path::toNormalized(icon), *MWBase::Environment::get().getResourceSystem()->getVFS());
962+
const VFS::Path::Normalized iconPath = Misc::ResourceHelpers::correctBigIconPath(
963+
VFS::Path::toNormalized(effect->mIcon), *MWBase::Environment::get().getResourceSystem()->getVFS());
966964

967965
widget->setUserString("ToolTipType", "Layout");
968966
widget->setUserString("ToolTipLayout", "MagicEffectToolTip");

components/misc/resourcehelpers.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,14 @@ VFS::Path::Normalized Misc::ResourceHelpers::correctIconPath(VFS::Path::Normaliz
145145
return correctResourcePath({ { icons } }, resPath, vfs, dds);
146146
}
147147

148+
VFS::Path::Normalized Misc::ResourceHelpers::correctBigIconPath(
149+
VFS::Path::NormalizedView resPath, const VFS::Manager& vfs)
150+
{
151+
std::string name("b_");
152+
name += resPath.filename().value();
153+
return correctIconPath(VFS::Path::join(resPath.parent(), name), vfs);
154+
}
155+
148156
VFS::Path::Normalized Misc::ResourceHelpers::correctBookartPath(
149157
VFS::Path::NormalizedView resPath, const VFS::Manager& vfs)
150158
{

components/misc/resourcehelpers.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ namespace Misc
2929
VFS::Path::NormalizedView resPath, const VFS::Manager& vfs, VFS::Path::ExtensionView ext = {});
3030
VFS::Path::Normalized correctTexturePath(VFS::Path::NormalizedView resPath, const VFS::Manager& vfs);
3131
VFS::Path::Normalized correctIconPath(VFS::Path::NormalizedView resPath, const VFS::Manager& vfs);
32+
VFS::Path::Normalized correctBigIconPath(VFS::Path::NormalizedView resPath, const VFS::Manager& vfs);
3233
VFS::Path::Normalized correctBookartPath(VFS::Path::NormalizedView resPath, const VFS::Manager& vfs);
3334
VFS::Path::Normalized correctBookartPath(
3435
VFS::Path::NormalizedView resPath, int width, int height, const VFS::Manager& vfs);

0 commit comments

Comments
 (0)