From 2dca72bdb0c3c3913ac734e344cc5b7316eae8d4 Mon Sep 17 00:00:00 2001 From: Evil Eye Date: Sat, 4 Apr 2026 17:43:57 +0200 Subject: [PATCH] Use normalized paths to construct big icon paths --- apps/openmw/mwgui/hud.cpp | 8 ++------ apps/openmw/mwgui/quickkeysmenu.cpp | 7 ++----- apps/openmw/mwgui/tooltips.cpp | 6 ++---- components/misc/resourcehelpers.cpp | 8 ++++++++ components/misc/resourcehelpers.hpp | 1 + 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/apps/openmw/mwgui/hud.cpp b/apps/openmw/mwgui/hud.cpp index 53cfd89f5b..e7b0e94df2 100644 --- a/apps/openmw/mwgui/hud.cpp +++ b/apps/openmw/mwgui/hud.cpp @@ -354,12 +354,8 @@ namespace MWGui // use the icon of the first effect const ESM::MagicEffect* effect = MWBase::Environment::get().getESMStore()->get().find( spell->mEffects.mList.front().mData.mEffectID); - std::string icon = effect->mIcon; - std::replace(icon.begin(), icon.end(), '/', '\\'); - size_t slashPos = icon.rfind('\\'); - icon.insert(slashPos + 1, "b_"); - const VFS::Path::Normalized iconPath = Misc::ResourceHelpers::correctIconPath( - VFS::Path::toNormalized(icon), *MWBase::Environment::get().getResourceSystem()->getVFS()); + const VFS::Path::Normalized iconPath = Misc::ResourceHelpers::correctBigIconPath( + VFS::Path::toNormalized(effect->mIcon), *MWBase::Environment::get().getResourceSystem()->getVFS()); mSpellImage->setSpellIcon(iconPath); } else diff --git a/apps/openmw/mwgui/quickkeysmenu.cpp b/apps/openmw/mwgui/quickkeysmenu.cpp index 3cc0cd177d..d1d20506dc 100644 --- a/apps/openmw/mwgui/quickkeysmenu.cpp +++ b/apps/openmw/mwgui/quickkeysmenu.cpp @@ -323,11 +323,8 @@ namespace MWGui const ESM::MagicEffect* effect = esmStore.get().find(spell->mEffects.mList.front().mData.mEffectID); - std::string path = effect->mIcon; - std::replace(path.begin(), path.end(), '/', '\\'); - path.insert(path.rfind('\\') + 1, "b_"); - const VFS::Path::Normalized iconPath = Misc::ResourceHelpers::correctIconPath( - VFS::Path::toNormalized(path), *MWBase::Environment::get().getResourceSystem()->getVFS()); + const VFS::Path::Normalized iconPath = Misc::ResourceHelpers::correctBigIconPath( + VFS::Path::toNormalized(effect->mIcon), *MWBase::Environment::get().getResourceSystem()->getVFS()); float scale = 1.f; MyGUI::ITexture* texture diff --git a/apps/openmw/mwgui/tooltips.cpp b/apps/openmw/mwgui/tooltips.cpp index 4803fe1c60..cc39043556 100644 --- a/apps/openmw/mwgui/tooltips.cpp +++ b/apps/openmw/mwgui/tooltips.cpp @@ -959,10 +959,8 @@ namespace MWGui const auto& store = MWBase::Environment::get().getESMStore(); const ESM::MagicEffect* effect = store->get().find(effectId); - std::string icon = effect->mIcon; - icon.insert(icon.rfind('\\') + 1, "b_"); - const VFS::Path::Normalized iconPath = Misc::ResourceHelpers::correctIconPath( - VFS::Path::toNormalized(icon), *MWBase::Environment::get().getResourceSystem()->getVFS()); + const VFS::Path::Normalized iconPath = Misc::ResourceHelpers::correctBigIconPath( + VFS::Path::toNormalized(effect->mIcon), *MWBase::Environment::get().getResourceSystem()->getVFS()); widget->setUserString("ToolTipType", "Layout"); widget->setUserString("ToolTipLayout", "MagicEffectToolTip"); diff --git a/components/misc/resourcehelpers.cpp b/components/misc/resourcehelpers.cpp index e861b36fc2..da740f8548 100644 --- a/components/misc/resourcehelpers.cpp +++ b/components/misc/resourcehelpers.cpp @@ -145,6 +145,14 @@ VFS::Path::Normalized Misc::ResourceHelpers::correctIconPath(VFS::Path::Normaliz return correctResourcePath({ { icons } }, resPath, vfs, dds); } +VFS::Path::Normalized Misc::ResourceHelpers::correctBigIconPath( + VFS::Path::NormalizedView resPath, const VFS::Manager& vfs) +{ + std::string name("b_"); + name += resPath.filename().value(); + return correctIconPath(VFS::Path::join(resPath.parent(), name), vfs); +} + VFS::Path::Normalized Misc::ResourceHelpers::correctBookartPath( VFS::Path::NormalizedView resPath, const VFS::Manager& vfs) { diff --git a/components/misc/resourcehelpers.hpp b/components/misc/resourcehelpers.hpp index 74436bb1fd..c73163541d 100644 --- a/components/misc/resourcehelpers.hpp +++ b/components/misc/resourcehelpers.hpp @@ -29,6 +29,7 @@ namespace Misc VFS::Path::NormalizedView resPath, const VFS::Manager& vfs, VFS::Path::ExtensionView ext = {}); VFS::Path::Normalized correctTexturePath(VFS::Path::NormalizedView resPath, const VFS::Manager& vfs); VFS::Path::Normalized correctIconPath(VFS::Path::NormalizedView resPath, const VFS::Manager& vfs); + VFS::Path::Normalized correctBigIconPath(VFS::Path::NormalizedView resPath, const VFS::Manager& vfs); VFS::Path::Normalized correctBookartPath(VFS::Path::NormalizedView resPath, const VFS::Manager& vfs); VFS::Path::Normalized correctBookartPath( VFS::Path::NormalizedView resPath, int width, int height, const VFS::Manager& vfs);