Patch for MyGUI 3.0.1/3.2.0 to search all resource groups

Garthy

20-01-2011 01:26:44

Hi!

I've made a patch to the Ogre platform in MyGUI 3.0.1 to enable MyGUI to search all resource groups rather than just the one provided (default is "General" I believe).

Patch included. :) (gzipped, as the forum won't let me attach a file ending in "patch")

The new behaviour is disabled by default. With this patch, you can optionally do this:


platform = MyGUI::OgrePlatform();
platform->initialise(window, scenemgr);
platform->enableAllResourceGroups(); // <--- This bit is new! :)


And then, whenever MyGUI goes looking for a resource, it'll search all resource groups, not just the one provided.

This is to solve a problem I had where I had resources in multiple resource groups, and I wanted MyGUI to be able to load from all of them. (More info: http://www.ogre3d.org/forums/viewtopic.php?f=1&t=62625 )

Now, I've gone for a simple approach rather than anything complex, it can certainly be improved, but I figured I'd go for something basic to start with.

Now I've tested it against my slightly-tweaked build of MyGUI, and it works fine; I *think* it'll work fine with the stock 3.0.1, but be sure to test it if you use it. :)

To the main MyGUI devs, are you happy with the method name and implementation? Would you be interested in applying the patch to the official distribution?

As a bit of a side note, is there any sort of MyGUI pre-release announcement list I can sign up to? I'd be very keen to try out the next version of MyGUI shortly before official release, particularly to test this patch or a similar one in the official code. :) EDIT: I just noticed the 3.2.0 RC1 announcement. Nice timing. ;)

I hope this is useful. :)

Garthy

20-01-2011 05:13:02

A quick update: The patch doesn't work against 3.2.0 (only 3.0.1). I've just started playing around with version 3.2.0RC1 and may have a suitable patch for the newer version "soon". :)

Garthy

20-01-2011 11:12:13

New patch that works against version 3.2.0rc1! Attached, gzipped. Tested, works nicely under Linux.

Please note that it is presently untested under Windows. I've been having a bit of trouble getting the new version of MyGUI to build under Windows so far, and I probably won't finish it this evening. It *looks* like it'll work though. EDIT: I've built it now, but I've run into some issues with the new version under Windows so I cannot test this patch myself.

I hope it is useful. :)

EDIT: No need for this patch now- see details further down in this thread. The latest svn has a better implementation of this patch, and the 3.2.0 release should include it. :)

Garthy

22-01-2011 02:43:11

A quick update: The patch is tested and works fine under Windows too. :)

Altren

22-01-2011 14:01:12

We still thinking about it. I'm thinking about enabling such search if AUTODETECT_RESOURCE_GROUP_NAME was used during initialisation, and remove additional calls.
And by the way, your patch have few issues (saying this just in case if you plan to write more patches ;) ):
- one major typo - both enableAllResourceGroups and disableAllResourceGroups call mDataManager->enableAllResourceGroups();
- you should include additional functions only in OgreDataManager, there's no reason to add additional functions into OgrePlatform;
- logging list of resource groups for every file is overkill;
- few style issues like for (int i=0; i<(int)search.size(); i++)should befor (size_t i = 0; i < search.size(); i++)or better use iterators.

Altren

22-01-2011 17:59:19

I commited change: whenever OgrePlatform initialised with Ogre::ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME instead of ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME that is used by default OgreDataManager::getDataListNames look through all groups.

Garthy

22-01-2011 22:01:45

- one major typo - both enableAllResourceGroups and disableAllResourceGroups call mDataManager->enableAllResourceGroups();
- logging list of resource groups for every file is overkill;


Yikes, how incredibly embarrassing. :{ Thankyou for catching my silly mistakes.

Re logging groups on every call, I agree completely that it is overkill. I had meant to comment out that trace but leave it there to ease testing.

That's what I get for rushing a patch I guess. :}


- you should include additional functions only in OgreDataManager, there's no reason to add additional functions into OgrePlatform;
- few style issues like


Sure, not a problem. Different projects prefer different styles. :)

saying this just in case if you plan to write more patches

Quite possibly! Although as you can see I'm still feeling my way around the code. :)

I commited change: whenever OgrePlatform initialised with Ogre::ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME instead of ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME that is used by default OgreDataManager::getDataListNames look through all groups.

Sounds good. :) This is more tightly-integrated than the approach I took, and definitely a good thing. I've grabbed and had a quick skim through the latest svn, it looks good, and I'll be playing around with it shortly. :)

Thankyou for going through my patch, fixing up my silly mistakes, and integrating it. :)

Altren

22-01-2011 23:21:52

Thank you for submitting good suggestions and patches. :)

Garthy

23-01-2011 04:01:53

Not a problem. :)

I've built MyGUI from a subversion checkout earlier today, and using Ogre::ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME during initialisation from my project works fine. Great stuff! :)