pluginmanager.cpp

来自「quake3工具源码。包括生成bsp文件」· C++ 代码 · 共 1,645 行 · 第 1/4 页

CPP
1,645
字号
  
  pData->m_nCount = 0;
  pData->m_pVectors = NULL;

  if (g_bPlugOK && g_nPlugCount > 0)
  {
    pData->m_nCount = g_nPlugCount;
    pData->m_pVectors = reinterpret_cast<vec3_t*>(qmalloc(g_nPlugCount * sizeof(vec3_t)));
    vec3_t *pOut = pData->m_pVectors;
    for (int i = 0; i < g_nPlugCount; i++)
    {
	memcpy(pOut, &g_PathPoints[i],sizeof(vec3_t));
	pOut++;
    }
  }
}

void WINAPI QERApp_AddFaceData(LPVOID pv, _QERFaceData *pData)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());

	brush_t* pBrush = g_pParentWnd->GetPlugInMgr().FindBrushHandle(pv);
  if (pBrush != NULL)
  {
		face_t *f = Face_Alloc();
		f->texdef = g_qeglobals.d_texturewin.texdef;
		f->texdef.flags = pData->m_nFlags;
    f->texdef.contents = pData->m_nContents;
    f->texdef.value = pData->m_nValue;
    f->texdef.rotate = pData->m_fRotate;
    f->texdef.shift[0] = pData->m_fShift[0];
    f->texdef.shift[1] = pData->m_fShift[1];
    f->texdef.scale[0] = pData->m_fScale[0];
    f->texdef.scale[1] = pData->m_fScale[1];
    //strcpy(f->texdef.name, pData->m_TextureName);
    f->texdef.SetName(pData->m_TextureName);
		f->next = pBrush->brush_faces;
		pBrush->brush_faces = f;
		VectorCopy (pData->m_v1, f->planepts[0]);
		VectorCopy (pData->m_v2, f->planepts[1]);
		VectorCopy (pData->m_v3, f->planepts[2]);
		Sys_MarkMapModified();		// PGM
  }
}

int WINAPI QERApp_GetFaceCount(LPVOID pv)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
  int n = 0;
  brush_t *pBrush = g_pParentWnd->GetPlugInMgr().FindBrushHandle(pv);
  if (pBrush != NULL)
  {
	  for (face_t *f = pBrush->brush_faces ; f; f = f->next)
    {
      n++;
    }
  }
  return n;
}

_QERFaceData* WINAPI QERApp_GetFaceData(LPVOID pv, int nFaceIndex)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
  static _QERFaceData face;
  int n = 0;
  brush_t *pBrush = g_pParentWnd->GetPlugInMgr().FindBrushHandle(pv);

  if (pBrush != NULL)
  {
    for (face_t *f = pBrush->brush_faces ; f; f = f->next)
    {

#ifdef _DEBUG
		if (!pBrush->brush_faces)
		{
			Sys_Printf( "Warning : pBrush->brush_faces is NULL in QERApp_GetFaceData\n" );
			return NULL;
		}
#endif

      if (n == nFaceIndex)
      {
        face.m_nContents = f->texdef.contents;
        face.m_nFlags = f->texdef.flags;
        face.m_fRotate = f->texdef.rotate;
        face.m_fScale[0] = f->texdef.scale[0];
        face.m_fScale[1] = f->texdef.scale[1];
        face.m_fShift[0] = f->texdef.shift[0];
        face.m_fShift[1] = f->texdef.shift[1];
        face.m_nValue = f->texdef.value;
        strcpy(face.m_TextureName, f->texdef.name);
        VectorCopy(f->planepts[0], face.m_v1);
        VectorCopy(f->planepts[1], face.m_v2);
        VectorCopy(f->planepts[2], face.m_v3);
        return &face;
      }
      n++;
    }
  }
  return NULL;
}

void WINAPI QERApp_SetFaceData(LPVOID pv, int nFaceIndex, _QERFaceData *pData)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
	int n = 0;
	brush_t *pBrush = g_pParentWnd->GetPlugInMgr().FindBrushHandle(pv);

	if (pBrush != NULL)
	{
		for (face_t *f = pBrush->brush_faces ; f; f = f->next)
		{
			if (n == nFaceIndex)
			{
				f->texdef.flags = pData->m_nFlags;
				f->texdef.contents = pData->m_nContents;
				f->texdef.value = pData->m_nValue;
				f->texdef.rotate = pData->m_fRotate;
				f->texdef.shift[0] = pData->m_fShift[0];
				f->texdef.shift[1] = pData->m_fShift[1];
				f->texdef.scale[0] = pData->m_fScale[0];
				f->texdef.scale[1] = pData->m_fScale[1];
				//strcpy(f->texdef.name, pData->m_TextureName);
				f->texdef.SetName(pData->m_TextureName);
				VectorCopy(pData->m_v1, f->planepts[0]);
				VectorCopy(pData->m_v2, f->planepts[1]);
				VectorCopy(pData->m_v3, f->planepts[2]);
				Sys_MarkMapModified();		// PGM
				return;						// PGM
			}
			n++;
		}
	}
}

void WINAPI QERApp_DeleteFace(LPVOID pv, int nFaceIndex)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
  int n = 0;
  brush_t *pBrush = g_pParentWnd->GetPlugInMgr().FindBrushHandle(pv);
  if (pBrush != NULL)
  {
    face_t *pPrev = pBrush->brush_faces;
	  for (face_t *f = pBrush->brush_faces; f; f = f->next)
    {
      if (n == nFaceIndex)
      {
        pPrev->next = f->next;
			  Face_Free (f);
		Sys_MarkMapModified();		// PGM
        return;
      }
      n++;
      pPrev = f;
    }
  }
}

//==========
//PGM
void WINAPI QERApp_BuildBrush (LPVOID pv)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
	brush_t *pBrush = g_pParentWnd->GetPlugInMgr().FindBrushHandle(pv);
	if (pBrush != NULL)
	{
		Brush_Build(pBrush);
		Sys_UpdateWindows(W_ALL);
	}
}

//Timo : another version with bConvert flag
//++timo since 1.7 is not compatible with earlier plugin versions, remove this one and update QERApp_BuildBrush
void WINAPI QERApp_BuildBrush2 (LPVOID pv, int bConvert)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
	brush_t *pBrush = g_pParentWnd->GetPlugInMgr().FindBrushHandle(pv);
	if (pBrush != NULL)
	{
		Brush_Build( pBrush, true, true, bConvert );
		Sys_UpdateWindows(W_ALL);
	}
}

void WINAPI QERApp_SelectBrush (LPVOID pv)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
	brush_t *pBrush = g_pParentWnd->GetPlugInMgr().FindBrushHandle(pv);
	if (pBrush != NULL)
	{
		Select_Brush(pBrush, false);
		Sys_UpdateWindows(W_ALL);
	}

}

void WINAPI QERApp_DeselectBrush (LPVOID pv)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
	// FIXME - implement this!
}

void WINAPI QERApp_ResetPlugins()
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
  g_pParentWnd->OnPluginsRefresh();
}

void WINAPI QERApp_DeselectAllBrushes ()
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
	Select_Deselect();
	Sys_UpdateWindows(W_ALL);
}
//PGM
//==========

void WINAPI QERApp_TextureBrush(LPVOID pv, LPCSTR pName)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
  brush_t *pBrush = g_pParentWnd->GetPlugInMgr().FindBrushHandle(pv);
  if (pBrush != NULL)
  {
	  for (face_t *f = pBrush->brush_faces ; f; f = f->next)
    {
      //strcpy(f->texdef.name, pName);
      f->texdef.SetName(pName);
    }
    Sys_MarkMapModified();		// PGM
  }
}

int WINAPI QERApp_SelectedBrushCount()
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
  int n = 0;
	for (brush_t *pb = selected_brushes.next ; pb != &selected_brushes ; pb = pb->next)
	{
    n++;
  }
  return n;
}

int WINAPI QERApp_ActiveBrushCount()
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
  int n = 0;
	for (brush_t *pb = active_brushes.next ; pb != &active_brushes ; pb = pb->next)
	{
    n++;
  }
  return n;
}

int WINAPI QERApp_AllocateSelectedBrushHandles()
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
  int n = 0;
	for (brush_t *pb = selected_brushes.next ; pb != &selected_brushes ; pb = pb->next)
	{
    n++;
    g_pParentWnd->GetPlugInMgr().GetSelectedHandles().Add(pb);
  }
  return n;
}

int WINAPI QERApp_AllocateActiveBrushHandles()
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
  int n = 0;
	for (brush_t *pb = active_brushes.next ; pb != &active_brushes ; pb = pb->next)
	{
    n++;
    g_pParentWnd->GetPlugInMgr().GetActiveHandles().Add(pb);
  }
  return n;
}

void WINAPI QERApp_ReleaseSelectedBrushHandles()
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
  g_pParentWnd->GetPlugInMgr().GetSelectedHandles().RemoveAll();
  Sys_UpdateWindows(W_ALL);
}

void WINAPI QERApp_ReleaseActiveBrushHandles()
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
  g_pParentWnd->GetPlugInMgr().GetActiveHandles().RemoveAll();
  Sys_UpdateWindows(W_ALL);
}

LPVOID WINAPI QERApp_GetActiveBrushHandle(int nIndex)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
  if (nIndex < g_pParentWnd->GetPlugInMgr().GetActiveHandles().GetSize())
  {
    return reinterpret_cast<LPVOID>(g_pParentWnd->GetPlugInMgr().GetActiveHandles().GetAt(nIndex));
  }
  return NULL;
}

LPVOID WINAPI QERApp_GetSelectedBrushHandle(int nIndex)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
  if (nIndex < g_pParentWnd->GetPlugInMgr().GetSelectedHandles().GetSize())
  {
    return reinterpret_cast<LPVOID>(g_pParentWnd->GetPlugInMgr().GetSelectedHandles().GetAt(nIndex));
  }
  return NULL;
}

int WINAPI QERApp_TextureCount()
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
	Texture_StartPos ();
  int x, y;
  int n = 0;
	while (1)
	{
		qtexture_t *q = Texture_NextPos (&x, &y);
		if (!q)
			break;
    n++;
  }
  return n;
}

LPCSTR WINAPI QERApp_GetTexture(int nIndex)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
  static char name[QER_MAX_NAMELEN];
	Texture_StartPos ();
  int x, y;
  int n = 0;
	while (1)
	{
		qtexture_t *q = Texture_NextPos (&x, &y);
		if (!q)
			break;
    if (n == nIndex)
    {
      strcpy(name, q->name);
      return name;
    }
    n++;
  }
  return NULL;
}

LPCSTR WINAPI QERApp_GetCurrentTexture()
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
  return g_qeglobals.d_texturewin.texdef.name;
}

void WINAPI QERApp_SetCurrentTexture(LPCSTR strName)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
	//++timo hu ?? tex is not initialized ?? can be any value ..
  texdef_t tex;
  //++timo added a brushprimit_texdef ..
  // smthg to be done here
  brushprimit_texdef_t brushprimit_tex;
  //strcpy(tex.name, strName);
  tex.SetName(strName);
  Texture_SetTexture(&tex,&brushprimit_tex);
}

int WINAPI QERApp_GetEClassCount()
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
  int n = 0;
  for (eclass_t *e = eclass ; e ; e = e->next)
	{
    n++;
  }
  return n;
}

LPCSTR WINAPI QERApp_GetEClass(int nIndex)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
  int n = 0;
  for (eclass_t *e = eclass ; e ; e = e->next)
	{
    if (n == nIndex)
    {
      return e->name;
    }
  }
  return NULL;
}

void WINAPI QERApp_LoadTextureRGBA(LPVOID vp)
{
  Texture_LoadFromPlugIn(vp);
}

// v1.70 code
// world_entity holds the worldspawn and is indexed as 0
// other entities are in the entities doubly linked list
// QERApp_GetEntityCount counts the entities like in any C array: [0..length-1]
int WINAPI QERApp_GetEntityCount()
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
	int n = 1;
	for (entity_t *pe = entities.next ; pe != &entities ; pe = pe->next)
	{
		n++;
	}
	return n;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?