From 195f044f3bc082c86ec5c9f85f2672b86485b101 Mon Sep 17 00:00:00 2001 From: MiroslavR Date: Sat, 16 Aug 2014 18:12:18 +0200 Subject: [PATCH] Replace more .tga->.dds hacks with ResourceHelpers --- apps/openmw/mwgui/birth.cpp | 6 +++--- apps/openmw/mwgui/hud.cpp | 7 ++++--- apps/openmw/mwgui/widgets.cpp | 21 +++------------------ 3 files changed, 10 insertions(+), 24 deletions(-) diff --git a/apps/openmw/mwgui/birth.cpp b/apps/openmw/mwgui/birth.cpp index 7f58309ba0..a7f90c00ba 100644 --- a/apps/openmw/mwgui/birth.cpp +++ b/apps/openmw/mwgui/birth.cpp @@ -2,6 +2,8 @@ #include +#include + #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" #include "../mwbase/windowmanager.hpp" @@ -182,9 +184,7 @@ namespace MWGui const ESM::BirthSign *birth = store.get().find(mCurrentBirthId); - std::string texturePath = std::string("textures\\") + birth->mTexture; - Widgets::fixTexturePath(texturePath); - mBirthImage->setImageTexture(texturePath); + mBirthImage->setImageTexture(Misc::ResourceHelpers::correctTexturePath(birth->mTexture)); std::vector abilities, powers, spells; diff --git a/apps/openmw/mwgui/hud.cpp b/apps/openmw/mwgui/hud.cpp index 3a9aa7dcdb..77b8c6ccbd 100644 --- a/apps/openmw/mwgui/hud.cpp +++ b/apps/openmw/mwgui/hud.cpp @@ -2,6 +2,8 @@ #include +#include + #include "../mwbase/environment.hpp" #include "../mwbase/soundmanager.hpp" #include "../mwbase/windowmanager.hpp" @@ -430,10 +432,9 @@ namespace MWGui MWBase::Environment::get().getWorld()->getStore().get().find(spell->mEffects.mList.front().mEffectID); std::string icon = effect->mIcon; - int slashPos = icon.find("\\"); + int slashPos = icon.rfind('\\'); icon.insert(slashPos+1, "b_"); - icon = std::string("icons\\") + icon; - Widgets::fixTexturePath(icon); + icon = Misc::ResourceHelpers::correctIconPath(icon); mSpellImage->setItem(MWWorld::Ptr()); mSpellImage->setIcon(icon); diff --git a/apps/openmw/mwgui/widgets.cpp b/apps/openmw/mwgui/widgets.cpp index 41714a9bbd..6a5a43be7f 100644 --- a/apps/openmw/mwgui/widgets.cpp +++ b/apps/openmw/mwgui/widgets.cpp @@ -5,6 +5,8 @@ #include #include +#include + #include #include #include @@ -20,21 +22,6 @@ namespace MWGui { namespace Widgets { - - /* Helper functions */ - - /* - * Fixes the filename of a texture path to use the correct .dds extension. - * This is needed on some ESM entries which point to a .tga file instead. - */ - void fixTexturePath(std::string &path) - { - int offset = path.rfind("."); - if (offset < 0) - return; - path.replace(offset, path.length() - offset, ".dds"); - } - /* MWSkill */ MWSkill::MWSkill() @@ -486,9 +473,7 @@ namespace MWGui static_cast(mTextWidget)->setCaptionWithReplacing(spellLine); mRequestedWidth = mTextWidget->getTextSize().width + 24; - std::string path = std::string("icons\\") + magicEffect->mIcon; - fixTexturePath(path); - mImageWidget->setImageTexture(path); + mImageWidget->setImageTexture(Misc::ResourceHelpers::correctIconPath(magicEffect->mIcon)); } MWSpellEffect::~MWSpellEffect()