VGearsRSDFileManager.cpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 "data/VGearsRSDFileManager.h"
  16. /**
  17. * RSD file manager singleton.
  18. */
  19. template<> VGears::RSDFileManager
  20. *Ogre::Singleton<VGears::RSDFileManager>::msSingleton = nullptr;
  21. namespace VGears{
  22. RSDFileManager *RSDFileManager::GetSingletonPtr(){return msSingleton;}
  23. RSDFileManager &RSDFileManager::GetSingleton(){
  24. assert( msSingleton );
  25. return(*msSingleton );
  26. }
  27. RSDFileManager::RSDFileManager(){
  28. mResourceType = RSDFile::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(
  33. mResourceType, this
  34. );
  35. }
  36. RSDFileManager::~RSDFileManager(){
  37. Ogre::ResourceGroupManager::getSingleton()._unregisterResourceManager(
  38. mResourceType
  39. );
  40. }
  41. void RSDFileManager::ParseScript(
  42. Ogre::DataStreamPtr &stream, const String &group_name
  43. ){
  44. RSDFilePtr rsd = createResource(stream->getName(), group_name)
  45. .staticCast<RSDFile>();
  46. rsd->load();
  47. }
  48. Ogre::Resource *RSDFileManager::createImpl(
  49. const Ogre::String &name, Ogre::ResourceHandle handle,
  50. const Ogre::String &group, bool is_manual,
  51. Ogre::ManualResourceLoader *loader,
  52. const Ogre::NameValuePairList *create_params
  53. ){
  54. return new RSDFile(this, name, handle, group, is_manual, loader);
  55. }
  56. }