pluginmanager.cpp
来自「quake3工具源码。包括生成bsp文件」· C++ 代码 · 共 1,645 行 · 第 1/4 页
CPP
1,645 行
for (brush_t *pb = active_brushes.next ; pb != &active_brushes ; pb = pb->next)
{
if (pb->patchBrush)
{
n++;
m_PatchesHandles.Add(pb);
}
}
return n;
}
int WINAPI QERApp_AllocateSelectedPatchHandles()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
return g_pParentWnd->GetPlugInMgr().AllocateSelectedPatchHandles();
}
int CPlugInManager::AllocateSelectedPatchHandles()
{
int n = 0;
for (brush_t *pb = selected_brushes.next ; pb != &selected_brushes ; pb = pb->next)
{
if (pb->patchBrush)
{
n++;
m_PatchesHandles.Add(pb);
}
}
return n;
}
void WINAPI QERApp_ReleasePatchHandles()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
g_pParentWnd->GetPlugInMgr().ReleasePatchesHandles();
}
patchMesh_t* WINAPI QERApp_GetPatchData(int index)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
static patchMesh_t patch;
patchMesh_t *pPatch = g_pParentWnd->GetPlugInMgr().FindPatchHandle(index);
if (pPatch)
{
memcpy( &patch, pPatch, sizeof(patchMesh_t) );
return &patch;
}
return NULL;
}
void WINAPI QERApp_DeletePatch(int index)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
patchMesh_t *pPatch = g_pParentWnd->GetPlugInMgr().FindPatchHandle(index);
if (pPatch)
{
brush_t *pb = pPatch->pSymbiot;
Patch_Delete( pPatch );
if (pb)
Brush_Free( pb );
}
#ifdef _DEBUG
Sys_Printf("Warning: QERApp_DeletePatch: FindPatchHandle failed\n");
#endif
}
int WINAPI QERApp_CreatePatchHandle()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
return g_pParentWnd->GetPlugInMgr().CreatePatchHandle();
}
int CPlugInManager::CreatePatchHandle()
{
// NOTE: we can't call the AddBrushForPatch until we have filled the patchMesh_t structure
patchMesh_t *pPatch = MakeNewPatch();
m_PluginPatches.Add( pPatch );
// change mode
PatchesMode = EAllocatedPatches;
return m_PluginPatches.GetSize()-1;
}
void WINAPI QERApp_CommitPatchHandleToMap(int index, patchMesh_t *pMesh, char *texName)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
g_pParentWnd->GetPlugInMgr().CommitPatchHandleToMap(index, pMesh, texName);
}
void CPlugInManager::CommitPatchHandleToMap(int index, patchMesh_t *pMesh, char *texName)
{
if (PatchesMode==EAllocatedPatches)
{
patchMesh_t *pPatch = reinterpret_cast<patchMesh_t *>( m_PluginPatches.GetAt(index) );
memcpy( pPatch, pMesh, sizeof( patchMesh_t ) );
// patch texturing, if none given use current texture
if (texName)
pPatch->d_texture = Texture_ForName(texName);
if ( !pPatch->d_texture )
{
pPatch->d_texture = Texture_ForName(g_qeglobals.d_texturewin.texdef.name);
// checking .. just in case
if (!pPatch->d_texture)
{
#ifdef _DEBUG
Sys_Printf("WARNING: failed to set patch to current texture in CPlugInManager::CommitPatchHandleToMap\n");
#endif
pPatch->d_texture = notexture;
}
}
g_bScreenUpdates = false;
// the bLinkToWorld flag in AddBrushForPatch takes care of Brush_AddToList Entity_linkBrush and Brush_Build
brush_t *pb = AddBrushForPatch( pPatch, true );
Select_Brush( pb );
g_bScreenUpdates = true;
Sys_UpdateWindows(W_ALL);
}
else
{
brush_t *pBrush = reinterpret_cast<brush_t *>( m_PatchesHandles.GetAt(index) );
patchMesh_t *pPatch = pBrush->pPatch;
pPatch->width = pMesh->width;
pPatch->height = pMesh->height;
pPatch->contents = pMesh->contents;
pPatch->flags = pMesh->flags;
pPatch->value = pMesh->value;
pPatch->type = pMesh->type;
memcpy( pPatch->ctrl, pMesh->ctrl, sizeof(drawVert_t)*MAX_PATCH_HEIGHT*MAX_PATCH_WIDTH );
pPatch->bDirty = true;
}
}
// this gets called when the plugin needs specific services, for example the OpenGL drawing interface
//++timo plugins should be able to dynamically register their own interfaces in there
int WINAPI QERApp_RequestInterface( REFGUID refGUID, LPVOID pInterface )
{
if (IsEqualGUID( refGUID, QERQglTable_GUID ))
{
_QERQglTable *pQglTable = static_cast<_QERQglTable *>(pInterface);
if ( pQglTable->m_nSize != sizeof(_QERQglTable) )
{
Sys_Printf("wrong m_nSize in plugin-requested _QERQglTable interface\n");
return 0;
}
pQglTable->m_pfn_qglAlphaFunc = qglAlphaFunc;
pQglTable->m_pfn_qglBegin = qglBegin;
pQglTable->m_pfn_qglBindTexture = qglBindTexture;
pQglTable->m_pfn_qglBlendFunc = qglBlendFunc;
pQglTable->m_pfn_qglCallList = qglCallList;
pQglTable->m_pfn_qglCallLists = qglCallLists;
pQglTable->m_pfn_qglClear = qglClear;
pQglTable->m_pfn_qglClearColor = qglClearColor;
pQglTable->m_pfn_qglClearDepth = qglClearDepth;
pQglTable->m_pfn_qglColor3f = qglColor3f;
pQglTable->m_pfn_qglColor4f = qglColor4f;
pQglTable->m_pfn_qglCullFace = qglCullFace;
pQglTable->m_pfn_qglDisable = qglDisable;
pQglTable->m_pfn_qglDeleteLists = qglDeleteLists;
pQglTable->m_pfn_qglEnable = qglEnable;
pQglTable->m_pfn_qglEnd = qglEnd;
pQglTable->m_pfn_qglEndList = qglEndList;
pQglTable->m_pfn_qglGenLists = qglGenLists;
pQglTable->m_pfn_qglListBase = qglListBase;
pQglTable->m_pfn_qglLoadIdentity = qglLoadIdentity;
pQglTable->m_pfn_qglMatrixMode = qglMatrixMode;
pQglTable->m_pfn_qglNewList = qglNewList;
pQglTable->m_pfn_qglNormal3f = qglNormal3f;
pQglTable->m_pfn_qglOrtho = qglOrtho;
pQglTable->m_pfn_qglPointSize = qglPointSize;
pQglTable->m_pfn_qglPolygonMode = qglPolygonMode;
pQglTable->m_pfn_qglPopMatrix = qglPopMatrix;
pQglTable->m_pfn_qglPushMatrix = qglPushMatrix;
pQglTable->m_pfn_qglRotated = qglRotated;
pQglTable->m_pfn_qglRotatef = qglRotatef;
pQglTable->m_pfn_qglScalef = qglScalef;
pQglTable->m_pfn_qglTexCoord2f = qglTexCoord2f;
pQglTable->m_pfn_qglTexEnvf = qglTexEnvf;
pQglTable->m_pfn_qglTexGenf = qglTexGenf;
pQglTable->m_pfn_qglTexParameterf = qglTexParameterf;
pQglTable->m_pfn_qglTranslated = qglTranslated;
pQglTable->m_pfn_qglTranslatef = qglTranslatef;
pQglTable->m_pfn_qglVertex2f = qglVertex2f;
pQglTable->m_pfn_qglVertex3f = qglVertex3f;
pQglTable->m_pfn_qglViewport = qglViewport;
pQglTable->m_pfn_QE_CheckOpenGLForErrors = &QE_CheckOpenGLForErrors;
pQglTable->m_pfn_QEW_SetupPixelFormat = &QEW_SetupPixelFormat;
pQglTable->m_pfn_qwglCreateContext = qwglCreateContext;
pQglTable->m_pfn_qwglDeleteContext = qwglDeleteContext;
pQglTable->m_pfn_qwglMakeCurrent = qwglMakeCurrent;
pQglTable->m_pfn_qwglShareLists = qwglShareLists;
pQglTable->m_pfn_qwglSwapBuffers = qwglSwapBuffers;
pQglTable->m_pfn_qwglUseFontBitmaps = qwglUseFontBitmaps;
pQglTable->m_pfnGetQeglobalsHGLRC = &QERApp_GetQeglobalsHGLRC;
pQglTable->m_pfn_qgluPerspective = qgluPerspective;
pQglTable->m_pfn_qgluLookAt = qgluLookAt;
pQglTable->m_pfnHookXYGLWindow = QERApp_HookXYGLWindow;
pQglTable->m_pfnUnHookGLWindow = QERApp_UnHookGLWindow;
return 1;
}
else if (IsEqualGUID( refGUID, QERSelectedFaceTable_GUID ))
{
_QERSelectedFaceTable *pSelectedFaceTable = static_cast<_QERSelectedFaceTable *>(pInterface);
if ( pSelectedFaceTable->m_nSize != sizeof(_QERSelectedFaceTable) )
{
Sys_Printf("wrong m_nSize in plugin-requested _QERSelectedFaceTable interface\n");
return 0;
}
pSelectedFaceTable->m_pfnGetTextureNumber = &QERApp_ISelectedFace_GetTextureNumber;
pSelectedFaceTable->m_pfnGetFaceInfo = &QERApp_GetFaceInfo;
pSelectedFaceTable->m_pfnSetFaceInfo = &QERApp_SetFaceInfo;
pSelectedFaceTable->m_pfnGetTextureSize = &QERApp_GetTextureSize;
pSelectedFaceTable->m_pfnTextureForName = &QERApp_Texture_ForName;
pSelectedFaceTable->m_pfnSelect_SetTexture = &Select_SetTexture;
return 1;
}
else if (IsEqualGUID( refGUID, QERPluginEntitiesTable_GUID ))
{
_QERPluginEntitiesTable *pPluginEntitiesTable = static_cast<_QERPluginEntitiesTable *>(pInterface);
if ( pPluginEntitiesTable->m_nSize != sizeof(_QERPluginEntitiesTable) )
{
Sys_Printf("wrong m_nSize in plugin-requested _QERPluginEntitiesTable interface\n");
return 0;
}
pPluginEntitiesTable->m_pfnEClassScanDir = &QERApp_EClassScanDir;
return 1;
}
else if (IsEqualGUID( refGUID, QERScripLibTable_GUID ))
{
_QERScripLibTable *pScripLibTable = static_cast<_QERScripLibTable *>(pInterface);
if ( pScripLibTable->m_nSize != sizeof( _QERScripLibTable ) )
{
Sys_Printf("wrong m_nSize in plugin-requested _QERScripLibTable\n");
return 0;
}
pScripLibTable->m_pfnGetToken = &GetToken;
pScripLibTable->m_pfnToken = &QERApp_Token;
pScripLibTable->m_pfnUnGetToken = &UngetToken;
return 1;
}
else if (IsEqualGUID( refGUID, QERAppSurfaceTable_GUID ))
{
_QERAppSurfaceTable *pSurfaceTable = static_cast<_QERAppSurfaceTable *>(pInterface);
if ( pSurfaceTable->m_nSize != sizeof( _QERAppSurfaceTable ) )
{
Sys_Printf("wrong m_nSize in plugin-requested _QERAppSurfaceTable\n");
return 0;
}
pSurfaceTable->m_pfnAnyPatchesSelected = &AnyPatchesSelected;
pSurfaceTable->m_pfnOnlyPatchesSelected = &OnlyPatchesSelected;
pSurfaceTable->m_pfnQeglobalsTexturewin = &QERApp_QeglobalsTexturewin;
pSurfaceTable->m_pfnGetSelectedPatch = &QERApp_GetSelectedPatch;
pSurfaceTable->m_pfnPatchRebuild = &Patch_Rebuild;
pSurfaceTable->m_pfnGetTwoSelectedPatch = &QERApp_GetTwoSelectedPatch;
return 1;
}
else if (IsEqualGUID( refGUID, QERAppBSPFrontendTable_GUID ))
{
_QERAppBSPFrontendTable *pBSPFrontendTable = static_cast<_QERAppBSPFrontendTable *>(pInterface);
if ( pBSPFrontendTable->m_nSize != sizeof( _QERAppBSPFrontendTable ) )
{
Sys_Printf("wrong m_nSize in plugin-requested _QERAppBSPFrontendTable\n");
return 0;
}
pBSPFrontendTable->m_pfnGetMapName = &QERApp_GetMapName;
pBSPFrontendTable->m_pfnLoadPointFile = &Pointfile_Check;
return 1;
}
else if (IsEqualGUID( refGUID, QERMessaging_GUID ))
{
_QERMessagingTable *pMessagingTable = static_cast<_QERMessagingTable *>(pInterface);
if ( pMessagingTable->m_nSize != sizeof( _QERMessagingTable ) )
{
Sys_Printf("wrong m_nSize in plugin-requested _QERMessagingTable\n");
return 0;
}
pMessagingTable->m_pfnHookWindow = QERApp_HookWindow;
pMessagingTable->m_pfnUnHookWindow = QERApp_UnHookWindow;
pMessagingTable->m_pfnGetXYWndWrapper = QERApp_GetXYWndWrapper;
pMessagingTable->m_pfnHookListener = QERApp_HookListener;
pMessagingTable->m_pfnUnHookListener = QERApp_UnHookListener;
return 1;
}
else if (IsEqualGUID( refGUID, QERShadersTable_GUID ))
{
_QERShadersTable *pShadersTable = static_cast<_QERShadersTable *>(pInterface);
if ( pShadersTable->m_nSize != sizeof( _QERShadersTable ) )
{
Sys_Printf("wring m_nSize in plugin-requested _QERShadersTable\n");
return 0;
}
pShadersTable->m_pfnTryTextureForName = QERApp_TryTextureForName;
return 1;
}
return 0;
}
int CPlugInManager::FillFuncTable(CPlugIn *pPlug)
{
_QERFuncTable_1 *pTable = reinterpret_cast<_QERFuncTable_1*>(pPlug->getFuncTable());
if (pTable != NULL)
{
if (pTable->m_fVersion != QER_PLUG_VERSION)
{
Sys_Printf("Radiant plugin manager was built with version %.2f, Plugin %s is version %.2f\n", QER_PLUG_VERSION, pPlug->getVersionStr() , pTable->m_fVersion);
}
if (pTable->m_fVersion >= QER_PLUG_VERSION_1)
{
pTable->m_pfnCreateBrush = &QERApp_CreateBrush;
pTable->m_pfnCreateBrushHandle = &QERApp_CreateBrushHandle;
pTable->m_pfnDeleteBrushHandle = &QERApp_DeleteBrushHandle;
pTable->m_pfnCommitBrushHandle = &QERApp_CommitBrushHandleToMap;
pTable->m_pfnAddFace = &QERApp_AddFace;
pTable->m_pfnAddFaceData = &QERApp_AddFaceData;
pTable->m_pfnGetFaceData = &QERApp_GetFaceData;
pTable->m_pfnGetFaceCount = &QERApp_GetFaceCount;
pTable->m_pfnSetFaceData = &QERApp_SetFaceData;
pTable->m_pfnDeleteFace = &QERApp_DeleteFace;
pTable->m_pfnTextureBrush = &QERApp_TextureBrush;
pTable->m_pfnBuildBrush = &QERApp_BuildBrush; // PGM
pTable->m_pfnSelectBrush = &QERApp_SelectBrush; // PGM
pTable->m_pfnDeselectBrush = &QERApp_DeselectBrush; // PGM
pTable->m_pfnDeselectAllBrushes = &QERApp_DeselectAllBrushes; // PGM
pTable->m_pfnDeleteSelection = &QERApp_DeleteSelection;
pTable->m_pfnGetPoints = &QERApp_GetPoints;
pTable->m_pfnSysMsg = &QERApp_SysMsg;
pTable->m_pfnInfoMsg = &QERApp_InfoMsg;
pTable->m_pfnHideInfoMsg = &QERApp_HideInfoMsg;
pTable->m_pfnPositionView = &QERApp_PositionView; // PGM
pTable->m_pfnSelectedBrushCount = &QERApp_SelectedBrushCount;
pTable->m_pfnAllocateSelectedBrushHandles = &QERApp_AllocateSelectedBrushHandles;
pTable->m_pfnReleaseSelectedBrushHandles = &QERApp_ReleaseSelectedBrushHandles;
pTable->m_pfnGetSelectedBrushHandle = &QERApp_GetSelectedBrushHandle;
pTable->m_pfnActiveBrushCount = &QERApp_ActiveBrushCount;
pTable->m_pfnAllocateActiveBrushHandles = &QERApp_AllocateActiveBrushHandles;
pTable->m_pfnReleaseActiveBrushHandles = &QERApp_ReleaseActiveBrushHandles;
pTable->m_pfnGetActiveBrushHandle = &QERApp_GetActiveBrushHandle;
pTable->m_pfnTextureCount = &QERApp_TextureCount;
pTable->m_pfnGetTexture = &QERApp_GetTexture;
pTable->m_pfnGetCurrentTexture = &QERApp_GetCurrentTexture;
pTable->m_pfnSetCurrentTexture = &QERApp_SetCurrentTexture;
pTable->m_pfnGetEClassCount = &QERApp_GetEClassCount;
pTable->m_pfnGetEClass = &QERApp_GetEClass;
pTable->m_pfnResetPlugins = &QERApp_ResetPlugins;
}
// end of v1.00
if (pTable->m_fVersion >= 1.5f)
{
// v1.50 starts
pTable->m_pfnLoadTextureRGBA = &QERApp_LoadTextureRGBA;
// end of v1.50
}
if (pTable->m_fVersion >= 1.7f)
{
pTable->m_pfnGetEntityCount = &QERApp_GetEntityCount;
pTable->m_pfnGetEntityHandle = &QERApp_GetEntityHandle;
pTable->m_pfnGetEntityKeyValList = &QERApp_GetEntityKeyValList;
pTable->m_pfnAllocateEpair = &QERApp_AllocateEpair;
pTable->m_pfnSetEntityKeyValList = &QERApp_SetEntityKeyValList;
pTable->m_pfnAllocateEntityBrushHandles = &QERApp_AllocateEntityBrushHandles;
pTable->m_pfnReleaseEntityBrushHandles = &QERApp_ReleaseEntityBrushHandles;
pTable->m_pfnGetEntityBrushHandle = &QERApp_GetEntityBrushHandle;
pTable->m_pfnCreateEntityHandle = &QERApp_CreateEntityHandle;
pTable->m_pfnCommitBrushHandleToEntity = &QERApp_CommitBrushHandleToEntity;
pTable->m_pfnCommitEntityHandleToMap = &QERApp_CommitEntityHandleToMap;
pTable->m_pfnSetScreenUpdate = &QERApp_SetScreenUpdate;
pTable->m_pfnSysUpdateWindows = &Sys_UpdateWindows;
pTable->m_pfnBuildBrush2 = &QERApp_BuildBrush2;
pTable->m_pfnReadProjectKey = &QERApp_ReadProjectKey;
pTable->m_pfnScanFileForEClass = &QERApp_ScanFileForEClass;
pTable->m_pfnRequestInterface = &QERApp_RequestInterface;
pTable->m_pfnErrorMsg = &QERApp_ErrorMsg;
pTable->m_pfnLoadFile = &QERApp_LoadFile;
pTable->m_pfnExpandReletivePath = &QERApp_ExpandReletivePath;
pTable->m_pfnQE_ConvertDOSToUnixName = &QE_ConvertDOSToUnixName;
pTable->m_pfnHasShader = &QERApp_HasShader;
pTable->m_pfnTexture_LoadSkin = &Texture_LoadSkin;
pTable->m_pfnRadiantFree = &QERApp_RadiantFree;
pTable->m_pfnGetGamePath = &QERApp_GetGamePath;
pTable->m_pfnGetQERPath = &QERApp_GetQERPath;
// patches
pTable->m_pfnAllocateActivePatchHandles = &QERApp_AllocateActivePatchHandles;
pTable->m_pfnAllocateSelectedPatchHandles = &QERApp_AllocateSelectedPatchHandles;
pTable->m_pfnReleasePatchHandles = &QERApp_ReleasePatchHandles;
pTable->m_pfnGetPatchData = &QERApp_GetPatchData;
pTable->m_pfnDeletePatch = &QERApp_DeletePatch;
pTable->m_pfnCreatePatchHandle = &QERApp_CreatePatchHandle;
pTable->m_pfnCommitPatchHandleToMap = &QERApp_CommitPatchHandleToMap;
}
return true;
}
else
{
Sys_Printf("Unable to load %s because the function tables are not the same size\n", pPlug->getVersionStr());
}
return false;
}
CPlugIn * CPlugInManager::PluginForModule(HMODULE hPlug)
{
int i;
for( i=0; i!=m_PlugIns.GetSize(); i++ )
{
if ( reinterpret_cast<CPlugIn *>(m_PlugIns[i])->GetDLLModule() == hPlug )
return reinterpret_cast<CPlugIn *>(m_PlugIns[i]);
}
return NULL;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?