plugin.cpp 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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 "plugin.h"
  18. #include "ibrush.h"
  19. #include "ipatch.h"
  20. #include "ifiletypes.h"
  21. #include "ieclass.h"
  22. #include "qerplugin.h"
  23. #include "modulesystem/singletonmodule.h"
  24. #include "typesystem.h"
  25. #include "xmlparse.h"
  26. #include "xmlwrite.h"
  27. class MapXMLDependencies :
  28. public GlobalRadiantModuleRef,
  29. public GlobalBrushModuleRef,
  30. public GlobalPatchModuleRef,
  31. public GlobalFiletypesModuleRef,
  32. public GlobalEntityClassManagerModuleRef,
  33. public GlobalSceneGraphModuleRef
  34. {
  35. public:
  36. MapXMLDependencies() :
  37. GlobalBrushModuleRef(GlobalRadiant().getRequiredGameDescriptionKeyValue("brushtypes")),
  38. GlobalPatchModuleRef(GlobalRadiant().getRequiredGameDescriptionKeyValue("patchtypes")),
  39. GlobalEntityClassManagerModuleRef(GlobalRadiant().getRequiredGameDescriptionKeyValue("entityclass"))
  40. {
  41. }
  42. };
  43. class MapXMLAPI : public TypeSystemRef, public MapFormat
  44. {
  45. public:
  46. typedef MapFormat Type;
  47. STRING_CONSTANT(Name, "xmlq3");
  48. MapXMLAPI()
  49. {
  50. GlobalFiletypesModule::getTable().addType(Type::Name(), Name(), filetype_t("xml quake3 maps", "*.xmap"));
  51. }
  52. MapFormat* getTable()
  53. {
  54. return this;
  55. }
  56. void readGraph(scene::Node& root, TextInputStream& inputStream, EntityCreator& entityTable) const
  57. {
  58. Map_Read(root, inputStream, entityTable);
  59. }
  60. void writeGraph(scene::Node& root, GraphTraversalFunc traverse, TextOutputStream& outputStream) const
  61. {
  62. Map_Write(root, traverse, outputStream);
  63. }
  64. };
  65. typedef SingletonModule<MapXMLAPI, MapXMLDependencies> MapXMLModule;
  66. MapXMLModule g_MapXMLModule;
  67. extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules(ModuleServer& server)
  68. {
  69. GlobalErrorStream::instance().setOutputStream(server.getErrorStream());
  70. GlobalOutputStream::instance().setOutputStream(server.getOutputStream());
  71. GlobalDebugMessageHandler::instance().setHandler(server.getDebugMessageHandler());
  72. GlobalModuleServer::instance().set(server);
  73. g_MapXMLModule.selfRegister();
  74. }