2 Copyright (C) 1999-2007 id Software, Inc. and contributors.
3 For a list of contributors, see the accompanying CONTRIBUTORS file.
5 This file is part of GtkRadiant.
7 GtkRadiant is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 GtkRadiant is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GtkRadiant; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #ifndef _PLUGINMANAGER_H_
23 #define _PLUGINMANAGER_H_
27 // global interfaces we are using
28 extern _QERShadersTable g_ShadersTable;
30 // NOTE: it's actually a module manager, the name should change to ModuleManager..
35 CPtrArray m_BrushHandles;
36 CPtrArray m_SelectedBrushHandles;
37 CPtrArray m_ActiveBrushHandles;
40 //! brushes of the current entity ( see m_SelectedBrushHandles and m_ActiveBrushHandles )
41 CPtrArray m_EntityBrushHandles;
42 //! allocated entities, not commited yet ( see m_BrushHandles )
43 CPtrArray m_EntityHandles;
45 //! tells in which array to look when given a patch index
46 enum EPatchesMode { EActivePatches, ESelectedPatches, EAllocatedPatches } PatchesMode;
47 //! patches handles (brush_t*)
48 CPtrArray m_PatchesHandles;
49 //! plugin-allocated patches, not commited yet (patchMesh_t*)
50 CPtrArray m_PluginPatches;
52 void InitForDir(const Str &dir); ///< init for plguins/modules below this directory
55 CPtrArray& GetActiveHandles() {return m_ActiveBrushHandles; };
56 CPtrArray& GetSelectedHandles() {return m_SelectedBrushHandles; };
57 CPtrArray& GetPluginPatches() {return m_PluginPatches; };
58 brush_t* FindBrushHandle(void *vp);
59 patchMesh_t* FindPatchHandle(int index);
60 int CreatePatchHandle();
61 int AllocateActivePatchHandles();
62 int AllocateSelectedPatchHandles();
63 void CommitPatchHandleToMap(int index, patchMesh_t *pMesh, char *texName);
64 void CommitPatchHandleToEntity(int index, patchMesh_t *pMesh, char *texName, void *vpEntity);
65 void ReleasePatchesHandles() { m_PatchesHandles.RemoveAll(); m_PluginPatches.RemoveAll(); }
66 void AddFaceToBrushHandle(void *vp, vec3_t v1, vec3_t v2, vec3_t v3);
67 void CommitBrushHandleToMap(void *vp);
68 void DeleteBrushHandle(void* vp);
69 void* CreateBrushHandle();
70 void Dispatch(int n, const char *p);
71 void Cleanup(); ///< cleanup of data structures allocated for plugins, not a plugin reload
72 void Init(); ///< go through the path where we will find modules and plugins
73 void LoadImage (const char *name, unsigned char **pic, int *width, int *height);
74 void ImportMap (IDataStream *in, CPtrArray *ents, const char *type);
75 void ExportMap (CPtrArray *ents, IDataStream *out, const char *type);
76 void Shutdown(); ///< shutdown all the plugins/module subsystem
78 virtual ~CPlugInManager();
81 the texture manager front ends the single load
82 addins (texture, model, map formats.. etc.)
84 _QERTextureInfo* GetTextureInfo();
85 void LoadTexture(const char *pFilename);
87 void* GetSurfaceFlags();
90 CPtrArray& GetEntityBrushHandles() {return m_EntityBrushHandles; };
91 CPtrArray& GetEntityHandles() {return m_EntityHandles; };
92 //! the vpBrush needs to be in m_BrushHandles
93 void CommitBrushHandleToEntity(void* vpBrush, void* vpEntity );
94 //! the vpEntity needs to be in m_EntityHandles
95 void CommitEntityHandleToMap( void* vpEntity );
98 //! read the interfaces this plugin implements
99 void LoadFromPath(const char *path); ///< load all modules/plugins in specified path
100 void RegisterInterfaces();
103 class CPluginSlot : public IPlugIn
105 APIDescriptor_t *mpAPI;
106 _QERPluginTable *mpTable;
108 is false until Init() happened
112 below is valid only if m_bReady = true
114 GSList *m_CommandStrings;
115 GSList *m_CommandIDs;
119 build directly from a SYN_PROVIDE interface
121 CPluginSlot(APIDescriptor_t *pAPI);
122 virtual ~CPluginSlot();
124 APIDescriptor_t* GetDescriptor() { return mpAPI; }
126 initialize some management data after the synapse interfaces have been hooked up
130 dispatching a command by name to the plugin
132 void Dispatch(const char *p);
134 // IPlugIn ------------------------------------------------------------
135 const char* getMenuName();
136 int getCommandCount();
137 const char* getCommand(int n);
138 void addMenuID(int n);
139 bool ownsCommandID(int n);
143 class CRadiantPluginManager : public CSynapseAPIManager
145 list<CPluginSlot *> mSlots;
147 CRadiantPluginManager() {}
148 virtual ~CRadiantPluginManager();
150 // CSynapseAPIManager interface -------------------
151 APIDescriptor_t *BuildRequireAPI(APIDescriptor_t *pAPI);
153 // CRadiantPluginManager --------------------------
155 bool Dispatch(int n, const char* p);
158 class CImageTableSlot
161 \todo this is a duplicate from the APIDescriptor_t* list that privately stored inside CSynapseAPIManager
162 this is probably useless to us in here?
164 APIDescriptor_t *mpAPI;
166 shortcut to mpAPI->mpTable, with correct typing
167 this is what we allocate and should free locally
169 _QERPlugImageTable *mpTable;
171 CImageTableSlot() { }
172 virtual ~CImageTableSlot() { } ///\ \todo need to correctly free and release still..
174 APIDescriptor_t* GetDescriptor() { return mpAPI; }
175 _QERPlugImageTable* GetTable() { return mpTable; }
178 don't go through PrepareRequireAPI for init, just get this API and add the table info
180 void InitForFillAPITable(APIDescriptor_t *pAPI);
183 class CRadiantImageManager : public CSynapseAPIManager
185 list<CImageTableSlot *> mSlots;
187 list<CImageTableSlot *>::iterator mExtScanSlot;
189 CRadiantImageManager() {}
190 virtual ~CRadiantImageManager();
192 // CSynapseAPIManager interface --------------------
193 void FillAPITable(APIDescriptor_t *pAPI);
195 // CRadiantImageManager ----------------------------
197 extract the extension, go through the list of image interfaces, and load
199 void LoadImage(const char *name, byte **pic, int *width, int *height);
202 we often need to walk through the extensions
203 this used to be hardcoded in texwindow.cpp
204 the two functions are related, they use a static to go through the list
206 void BeginExtensionsScan();
207 const char* GetNextExtension(); ///< \return NULL when the list has been completely scanned
210 extern CRadiantImageManager g_ImageManager;
212 #endif // _PLUGINMANAGER_H_