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