VGearsHRCFileManager.cpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * Copyright (C) 2022 The V-Gears Team
  3. *
  4. * This file is part of V-Gears
  5. *
  6. * V-Gears is free software: you can redistribute it and/or modify it under
  7. * terms of the GNU General Public License as published by the Free Software
  8. * Foundation, version 3.0 (GPLv3) of the License.
  9. *
  10. * V-Gears is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. */
  15. #include <OgreLogManager.h>
  16. #include "data/VGearsHRCFileManager.h"
  17. /**
  18. * HRC file manager singleton.
  19. */
  20. template<> VGears::HRCFileManager *Ogre::Singleton<VGears::HRCFileManager>::msSingleton = nullptr;
  21. namespace VGears{
  22. HRCFileManager* HRCFileManager::GetSingletonPtr(){return msSingleton;}
  23. HRCFileManager& HRCFileManager::GetSingleton(){
  24. assert( msSingleton );
  25. return(*msSingleton );
  26. }
  27. HRCFileManager::HRCFileManager(){
  28. mResourceType = HRCFile::RESOURCE_TYPE;
  29. // Low, because it will likely reference other resources.
  30. mLoadOrder = 30.0f;
  31. // this is how the ResourceManager registers with OGRE.
  32. Ogre::ResourceGroupManager::getSingleton()._registerResourceManager(mResourceType, this);
  33. }
  34. HRCFileManager::~HRCFileManager(){
  35. Ogre::ResourceGroupManager::getSingleton()._unregisterResourceManager(mResourceType);
  36. }
  37. void HRCFileManager::ParseScript( Ogre::DataStreamPtr &stream, const String &group_name){
  38. HRCFilePtr hrc = createResource(stream->getName(), group_name).staticCast<HRCFile>();
  39. hrc->load();
  40. }
  41. Ogre::Resource* HRCFileManager::createImpl(
  42. const String &name, Ogre::ResourceHandle handle, const String &group, bool is_manual,
  43. Ogre::ManualResourceLoader *loader, const Ogre::NameValuePairList *create_params
  44. ){return new HRCFile(this, name, handle, group, is_manual, loader);}
  45. }