[PATCH 3.0.0] - fix for MyGUI not finding textures

al2950

13-02-2010 18:45:37

Firstly thank you for this great library, I have been using it for a couple of weeks not and i am loving it! The following change is something i did to get it to work the way i wanted, i am not sure if it will break other stuff or is the correct way to fix my problem!

This is a fix to a problem i was having as i had several resource groups and if you initialised MyGUI with 'AUTODETECT_RESOURCE_GROUP_NAME' MyGUI would not find any resources!

The problem lies in MyGUI_OgreDataManager.cpp line 82. The problem is that it check if the resource exists by using the ogre method 'findResourceFileInfo' however that method does not work with 'AUTODETECT_RESOURCE_GROUP_NAME'. To fix this i changed the method OgreDataManager::isDataExist from;


bool OgreDataManager::isDataExist(const std::string& _name)
{
const VectorString& files = getDataListNames(_name);
return (files.size() == 1);
}


TO:


bool OgreDataManager::isDataExist(const std::string& _name)
{
const VectorString& files = getDataListNames(_name);
return Ogre::ResourceGroupManager::getSingleton().resourceExistsInAnyGroup(_name);
}



PS I am using Ogre 1.7

Altren

14-02-2010 01:30:17

First of all, that resource managers wasn't designed to be used with AUTODETECT_RESOURCE_GROUP_NAME. I can't say now if there is more issues with it, but we can try to solve it.
About your patch - it simply ignores result of getDataListNames. The point of that check was not only finding resource, but also check if there is only one file and not more.
In your case we probably can do something like

bool OgreDataManager::isDataExist(const std::string& _name)
{
if (mGroup == Ogre::AUTODETECT_RESOURCE_GROUP_NAME)
{
return Ogre::ResourceGroupManager::getSingleton().resourceExistsInAnyGroup(_name);
}
const VectorString& files = getDataListNames(_name);
return (files.size() == 1);
}
We need to test it though.

al2950

14-02-2010 08:27:25

Ah ok, the reason i was using Ogre::AUTODETECT_RESOURCE_GROUP_NAME was because of the this thread;

viewtopic.php?f=17&t=9370&p=54185&hilit=cant+find+texture#p54185

I am creating a little mini editor with MyGUI so i need to be able to access all the resources, the only other way i could think of doing it was re-writing a lot more more of MyGUI so that you specified a group when you load a texture using the StaticImage class, but i thought that would be a bad idea!!