]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - radiant/pluginmanager.h
Revert partially (auto) "reformat code! now the code is only ugly on the *inside*"
[xonotic/netradiant.git] / radiant / pluginmanager.h
index fe096e77bf547e6aa439b06167fe44d9100c8603..6603f6e1e4cc1db1e73449f2ae6c3c20ad3799e2 100644 (file)
-/*\r
-Copyright (C) 1999-2007 id Software, Inc. and contributors.\r
-For a list of contributors, see the accompanying CONTRIBUTORS file.\r
-\r
-This file is part of GtkRadiant.\r
-\r
-GtkRadiant is free software; you can redistribute it and/or modify\r
-it under the terms of the GNU General Public License as published by\r
-the Free Software Foundation; either version 2 of the License, or\r
-(at your option) any later version.\r
-\r
-GtkRadiant is distributed in the hope that it will be useful,\r
-but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
-GNU General Public License for more details.\r
-\r
-You should have received a copy of the GNU General Public License\r
-along with GtkRadiant; if not, write to the Free Software\r
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\r
-*/\r
-\r
-#ifndef _PLUGINMANAGER_H_\r
-#define _PLUGINMANAGER_H_\r
-\r
-#include "plugin.h"\r
-\r
-// global interfaces we are using\r
-extern _QERShadersTable g_ShadersTable;\r
-\r
-// NOTE: it's actually a module manager, the name should change to ModuleManager..\r
-class CPlugInManager  \r
-{\r
-private:\r
-  GSList* m_PlugIns;\r
-  CPtrArray m_BrushHandles;\r
-  CPtrArray m_SelectedBrushHandles;\r
-  CPtrArray m_ActiveBrushHandles;\r
-\r
-  // v1.70\r
-  //! brushes of the current entity ( see m_SelectedBrushHandles and m_ActiveBrushHandles )\r
-  CPtrArray m_EntityBrushHandles;\r
-  //! allocated entities, not commited yet ( see m_BrushHandles )\r
-  CPtrArray m_EntityHandles;\r
-\r
-  //! tells in which array to look when given a patch index\r
-  enum EPatchesMode { EActivePatches, ESelectedPatches, EAllocatedPatches } PatchesMode;\r
-  //! patches handles (brush_t*)\r
-  CPtrArray m_PatchesHandles;\r
-  //! plugin-allocated patches, not commited yet (patchMesh_t*)\r
-  CPtrArray m_PluginPatches;\r
-\r
-  void InitForDir(const Str &dir); ///< init for plguins/modules below this directory\r
-\r
-public:\r
-  CPtrArray& GetActiveHandles() {return m_ActiveBrushHandles; };\r
-  CPtrArray& GetSelectedHandles() {return m_SelectedBrushHandles; };\r
-  CPtrArray& GetPluginPatches() {return m_PluginPatches; };\r
-  brush_t* FindBrushHandle(void *vp);\r
-  patchMesh_t* FindPatchHandle(int index);\r
-  int CreatePatchHandle();\r
-  int AllocateActivePatchHandles();\r
-  int AllocateSelectedPatchHandles();\r
-  void CommitPatchHandleToMap(int index, patchMesh_t *pMesh, char *texName);\r
-  void CommitPatchHandleToEntity(int index, patchMesh_t *pMesh, char *texName, void *vpEntity);\r
-  void ReleasePatchesHandles() { m_PatchesHandles.RemoveAll(); m_PluginPatches.RemoveAll(); }\r
-  void AddFaceToBrushHandle(void *vp, vec3_t v1, vec3_t v2, vec3_t v3);\r
-  void CommitBrushHandleToMap(void *vp);\r
-  void DeleteBrushHandle(void* vp);\r
-  void* CreateBrushHandle();\r
-  void Dispatch(int n, const char *p);\r
-  void Cleanup(); ///< cleanup of data structures allocated for plugins, not a plugin reload\r
-  void Init(); ///< go through the path where we will find modules and plugins\r
-  void LoadImage (const char *name, unsigned char **pic, int *width, int *height);\r
-  void ImportMap (IDataStream *in, CPtrArray *ents, const char *type);\r
-  void ExportMap (CPtrArray *ents, IDataStream *out, const char *type);\r
-  void Shutdown(); ///< shutdown all the plugins/module subsystem\r
-  CPlugInManager();\r
-  virtual ~CPlugInManager();\r
-\r
-  /*! \r
-  the texture manager front ends the single load\r
-  addins (texture, model, map formats.. etc.)\r
-  */\r
-  _QERTextureInfo* GetTextureInfo();\r
-  void LoadTexture(const char *pFilename);\r
-       \r
-void* GetSurfaceFlags();\r
-       \r
-  // v1.70\r
-  CPtrArray& GetEntityBrushHandles() {return m_EntityBrushHandles; };\r
-  CPtrArray& GetEntityHandles() {return m_EntityHandles; };\r
-  //! the vpBrush needs to be in m_BrushHandles\r
-  void CommitBrushHandleToEntity(void* vpBrush, void* vpEntity );\r
-  //! the vpEntity needs to be in m_EntityHandles\r
-  void CommitEntityHandleToMap( void* vpEntity );\r
-\r
-protected:\r
-  //! read the interfaces this plugin implements\r
-  void LoadFromPath(const char *path); ///< load all modules/plugins in specified path\r
-  void RegisterInterfaces();\r
-};\r
-\r
-class CPluginSlot : public IPlugIn\r
-{\r
-  APIDescriptor_t *mpAPI;\r
-  _QERPluginTable *mpTable;\r
-  /*!\r
-  is false until Init() happened\r
-  */\r
-  bool m_bReady;\r
-  /*!\r
-  below is valid only if m_bReady = true\r
-  */\r
-  GSList *m_CommandStrings;\r
-  GSList *m_CommandIDs;\r
-  \r
-public:\r
-  /*!\r
-  build directly from a SYN_PROVIDE interface\r
-  */\r
-  CPluginSlot(APIDescriptor_t *pAPI);\r
-  virtual ~CPluginSlot();\r
-  \r
-  APIDescriptor_t* GetDescriptor() { return mpAPI; }\r
-  /*!\r
-  initialize some management data after the synapse interfaces have been hooked up\r
-  */\r
-  void Init();\r
-  /*!\r
-  dispatching a command by name to the plugin\r
-  */\r
-  void Dispatch(const char *p);\r
-  \r
-  // IPlugIn ------------------------------------------------------------\r
-  const char* getMenuName();\r
-  int getCommandCount();\r
-  const char* getCommand(int n);  \r
-  void addMenuID(int n);\r
-  bool ownsCommandID(int n);\r
-  \r
-};\r
-\r
-class CRadiantPluginManager : public CSynapseAPIManager\r
-{\r
-  list<CPluginSlot *> mSlots;\r
-public:\r
-  CRadiantPluginManager() {}\r
-  virtual ~CRadiantPluginManager();\r
-  \r
-  // CSynapseAPIManager interface -------------------\r
-  APIDescriptor_t *BuildRequireAPI(APIDescriptor_t *pAPI);\r
-  \r
-  // CRadiantPluginManager --------------------------\r
-  void PopulateMenu();\r
-  bool Dispatch(int n, const char* p);\r
-};\r
-\r
-class CImageTableSlot\r
-{\r
-  /*!\r
-  \todo this is a duplicate from the APIDescriptor_t* list that privately stored inside CSynapseAPIManager\r
-  this is probably useless to us in here?\r
-  */\r
-  APIDescriptor_t *mpAPI;\r
-  /*!\r
-  shortcut to mpAPI->mpTable, with correct typing\r
-  this is what we allocate and should free locally\r
-  */\r
-  _QERPlugImageTable *mpTable;\r
-public:\r
-  CImageTableSlot() { }\r
-  virtual ~CImageTableSlot() { } ///\ \todo need to correctly free and release still..\r
-  \r
-  APIDescriptor_t* GetDescriptor() { return mpAPI; }\r
-  _QERPlugImageTable* GetTable() { return mpTable; }\r
-  \r
-  /*!\r
-  don't go through PrepareRequireAPI for init, just get this API and add the table info\r
-  */\r
-  void InitForFillAPITable(APIDescriptor_t *pAPI);\r
-};\r
-\r
-class CRadiantImageManager : public CSynapseAPIManager\r
-{\r
-  list<CImageTableSlot *> mSlots;\r
-  \r
-  list<CImageTableSlot *>::iterator mExtScanSlot;\r
-public:\r
-  CRadiantImageManager() {}\r
-  virtual ~CRadiantImageManager();\r
-  \r
-  // CSynapseAPIManager interface --------------------\r
-  void FillAPITable(APIDescriptor_t *pAPI);\r
-\r
-  // CRadiantImageManager ----------------------------\r
-  /*!\r
-  extract the extension, go through the list of image interfaces, and load\r
-  */\r
-  void LoadImage(const char *name, byte **pic, int *width, int *height);\r
-    \r
-  /*!\r
-  we often need to walk through the extensions\r
-  this used to be hardcoded in texwindow.cpp\r
-  the two functions are related, they use a static to go through the list\r
-  */\r
-  void BeginExtensionsScan();\r
-  const char* GetNextExtension(); ///< \return NULL when the list has been completely scanned\r
-};\r
-\r
-extern CRadiantImageManager g_ImageManager;\r
-\r
-#endif // _PLUGINMANAGER_H_\r
+/*
+   Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+   For a list of contributors, see the accompanying CONTRIBUTORS file.
+
+   This file is part of GtkRadiant.
+
+   GtkRadiant is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+
+   GtkRadiant is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with GtkRadiant; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#if !defined( INCLUDED_PLUGINMANAGER_H )
+#define INCLUDED_PLUGINMANAGER_H
+
+#include <cstddef>
+#include <uilib/uilib.h>
+
+
+/*!
+   \class IPlugin
+   pure virtual interface for a plugin
+   temporary solution for migration from old plugin tech to synapse plugins
+ */
+class IPlugIn
+{
+public:
+IPlugIn() { }
+virtual ~IPlugIn() { }
+
+virtual const char* getMenuName() = 0;
+virtual std::size_t getCommandCount() = 0;
+virtual const char* getCommand( std::size_t ) = 0;
+virtual const char* getCommandTitle( std::size_t ) = 0;
+virtual void addMenuID( std::size_t ) = 0;
+virtual bool ownsCommandID( std::size_t n ) = 0;
+};
+
+class PluginsVisitor
+{
+public:
+virtual void visit( IPlugIn& plugin ) = 0;
+};
+
+class CPlugInManager
+{
+public:
+void Dispatch( std::size_t n, const char *p );
+void Init( ui::Widget main_window );
+void constructMenu( PluginsVisitor& menu );
+void Shutdown();
+};
+
+CPlugInManager& GetPlugInMgr();
+
+#endif