vfspk3.cpp 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. Copyright (C) 2001-2006, William Joseph.
  3. All Rights Reserved.
  4. This file is part of GtkRadiant.
  5. GtkRadiant is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. GtkRadiant is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with GtkRadiant; if not, write to the Free Software
  15. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  16. */
  17. #include "vfspk3.h"
  18. #include "qerplugin.h"
  19. #include "iarchive.h"
  20. #include "ifilesystem.h"
  21. #include "modulesystem/singletonmodule.h"
  22. #include "modulesystem/modulesmap.h"
  23. #include "vfs.h"
  24. class FileSystemDependencies : public GlobalRadiantModuleRef
  25. {
  26. ArchiveModulesRef m_archive_modules;
  27. public:
  28. FileSystemDependencies() :
  29. m_archive_modules(GlobalRadiant().getRequiredGameDescriptionKeyValue("archivetypes"))
  30. {
  31. }
  32. ArchiveModules& getArchiveModules()
  33. {
  34. return m_archive_modules.get();
  35. }
  36. };
  37. class FileSystemQ3API
  38. {
  39. VirtualFileSystem* m_filesystemq3;
  40. public:
  41. typedef VirtualFileSystem Type;
  42. STRING_CONSTANT(Name, "*");
  43. FileSystemQ3API()
  44. {
  45. FileSystem_Init();
  46. m_filesystemq3 = &GetFileSystem();
  47. }
  48. ~FileSystemQ3API()
  49. {
  50. FileSystem_Shutdown();
  51. }
  52. VirtualFileSystem* getTable()
  53. {
  54. return m_filesystemq3;
  55. }
  56. };
  57. typedef SingletonModule<FileSystemQ3API, FileSystemDependencies> FileSystemQ3Module;
  58. FileSystemQ3Module g_FileSystemQ3Module;
  59. ArchiveModules& FileSystemQ3API_getArchiveModules()
  60. {
  61. return g_FileSystemQ3Module.getDependencies().getArchiveModules();
  62. }
  63. extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules(ModuleServer& server)
  64. {
  65. GlobalErrorStream::instance().setOutputStream(server.getErrorStream());
  66. GlobalOutputStream::instance().setOutputStream(server.getOutputStream());
  67. GlobalDebugMessageHandler::instance().setHandler(server.getDebugMessageHandler());
  68. GlobalModuleServer::instance().set(server);
  69. g_FileSystemQ3Module.selfRegister();
  70. }