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_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 } }
void CPlugInManager::DeleteBrushHandle(void * vp) { CPtrArray* pHandles[3]; pHandles[0] = &m_SelectedBrushHandles; pHandles[1] = &m_ActiveBrushHandles; pHandles[2] = &m_BrushHandles; for (int j = 0; j < 3; j++) { for (int i = 0; i < pHandles[j]->GetSize(); i++) { brush_t *pb = reinterpret_cast<brush_t*>(pHandles[j]->GetAt(i)); if (pb == reinterpret_cast<brush_t*>(vp)) { if (j == 2) { // only remove it from the list if it is work area // this allows the selected and active list indexes to remain constant // throughout a session (i.e. between an allocate and release) pHandles[j]->RemoveAt(i); } Brush_Free(pb); Sys_MarkMapModified(); // PGM return; } } } }
void Map_Snapshot(){ CString strMsg; // I hope the modified flag is kept correctly up to date if ( !modified ) { return; } // we need to do the following // 1. make sure the snapshot directory exists (create it if it doesn't) // 2. find out what the lastest save is based on number // 3. inc that and save the map CString strOrgPath, strOrgFile; ExtractPath_and_Filename( currentmap, strOrgPath, strOrgFile ); AddSlash( strOrgPath ); strOrgPath += "snapshots"; bool bGo = true; struct stat Stat; if ( stat( strOrgPath, &Stat ) == -1 ) { #ifdef _WIN32 bGo = ( _mkdir( strOrgPath ) != -1 ); #endif #if defined ( __linux__ ) || defined ( __APPLE__ ) bGo = ( mkdir( strOrgPath,0755 ) != -1 ); #endif } AddSlash( strOrgPath ); if ( bGo ) { int nCount = 0; long lSize = 0; CString strNewPath; strNewPath = strOrgPath; strNewPath += strOrgFile; CString strFile; while ( bGo ) { char buf[PATH_MAX]; sprintf( buf, "%s.%i", strNewPath.GetBuffer(), nCount ); strFile = buf; bGo = DoesFileExist( strFile, lSize ); nCount++; } // strFile has the next available slot Map_SaveFile( strFile, false ); // it is still a modified map (we enter this only if this is a modified map) Sys_SetTitle( currentmap ); Sys_MarkMapModified(); if ( lSize > 12 * 1024 * 1024 ) { // total size of saves > 4 mb Sys_Printf( "The snapshot files in %s total more than 4 megabytes. You might consider cleaning up.", strOrgPath.GetBuffer() ); } } else { strMsg.Format( "Snapshot save failed.. unabled to create directory\n%s", strOrgPath.GetBuffer() ); gtk_MessageBox( g_pParentWnd->m_pWidget, strMsg ); } strOrgPath = ""; strOrgFile = ""; }
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 } }
void Map_ImportBuffer( char *buf ){ Select_Deselect(); Undo_Start( "import buffer" ); MemStream stream; stream.Write( buf, strlen( buf ) ); Map_Import( &stream, "xmap" ); stream.Close(); Sys_UpdateWindows( W_ALL ); Sys_MarkMapModified(); Undo_End(); }
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; } } }
void Select_Delete (void) { brush_t *brush; selected_face = NULL; g_qeglobals.d_select_mode = sel_brush; g_qeglobals.d_select_count = 0; g_qeglobals.d_num_move_points = 0; while (selected_brushes.next != &selected_brushes) { brush = selected_brushes.next; if (brush->patchBrush) Patch_Delete(brush->nPatchID); Brush_Free (brush); } // FIXME: remove any entities with no brushes Sys_MarkMapModified(); Sys_UpdateWindows (W_ALL); }
void Map_Snapshot(){ CString strMsg; // I hope the modified flag is kept correctly up to date if ( !modified ) { return; } // we need to do the following // 1. make sure the snapshot directory exists (create it if it doesn't) // 2. find out what the lastest save is based on number // 3. inc that and save the map CString strOrgPath, strOrgFile; ExtractPath_and_Filename( currentmap, strOrgPath, strOrgFile ); AddSlash( strOrgPath ); strOrgPath += "snapshots"; bool bGo = true; struct stat Stat; if ( stat( strOrgPath, &Stat ) == -1 ) { #ifdef _WIN32 bGo = ( _mkdir( strOrgPath ) != -1 ); #endif #if defined ( __linux__ ) || defined ( __APPLE__ ) bGo = ( mkdir( strOrgPath,0755 ) != -1 ); #endif } AddSlash( strOrgPath ); if ( bGo ) { int nCount = 0; long lSize = 0; CString strNewPath; strNewPath = strOrgPath; strNewPath += strOrgFile; // QB - snapshots now follow the format: <mapname>.<snapnum>.<ext> // **NOTE** atm snapshots must end with a .map (or .xmap) ext (this is why they were broken) CString strOldEXT = "map"; //default to .map const char* type = strrchr( strOrgFile.GetBuffer(),'.' ); if ( type != NULL ) { strOldEXT = ++type; }; // get the ext for later. StripExtension(strNewPath); // then strip it from the new path // CString strFile; while ( bGo ) { char buf[PATH_MAX]; //sprintf( buf, "%s.%i", strNewPath.GetBuffer(), nCount ); // snapshot will now end with a known ext. sprintf( buf, "%s.%i.%s", strNewPath.GetBuffer(), nCount, strOldEXT.GetBuffer() ); strFile = buf; bGo = DoesFileExist( strFile, lSize ); nCount++; } // strFile has the next available slot Map_SaveFile( strFile, false ); // it is still a modified map (we enter this only if this is a modified map) Sys_SetTitle( currentmap ); Sys_MarkMapModified(); if ( lSize > 12 * 1024 * 1024 ) { // total size of saves > 4 mb Sys_Printf( "The snapshot files in %s total more than 4 megabytes. You might consider cleaning up.", strOrgPath.GetBuffer() ); } } else { strMsg.Format( "Snapshot save failed.. unabled to create directory\n%s", strOrgPath.GetBuffer() ); gtk_MessageBox( g_pParentWnd->m_pWidget, strMsg ); } strOrgPath = ""; strOrgFile = ""; }