/*=========================================================================== * * Class CSrLoadDlg Method - void UpdateFile (ListIndex, pFileData); * *=========================================================================*/ void CSrLoadDlg::UpdateFile (const int ListIndex, srloaddlgfileinfo_t* pFileData) { CString Buffer; int64 FileSize; m_FileList.SetItemText(ListIndex, SRFILELIST_FILENAME, pFileData->FindData.cFileName); CTime FileTime(pFileData->FindData.ftLastWriteTime); m_FileList.SetItemText(ListIndex, SRFILELIST_DATE, FileTime.Format(_T("%c"))); FileSize = (int64)pFileData->FindData.nFileSizeLow + (((int64) pFileData->FindData.nFileSizeHigh) << 32); Buffer.Format(_T("%I64d"), FileSize); m_FileList.SetItemText(ListIndex, SRFILELIST_SIZE, Buffer); if (pFileData->IsActive) { if (pFileData->IsMaster) m_FileList.SetItemText(ListIndex, SRFILELIST_DEFAULTSORT, _T("Active Master")); else m_FileList.SetItemText(ListIndex, SRFILELIST_DEFAULTSORT, _T("Active")); } else if (pFileData->IsMaster) { m_FileList.SetItemText(ListIndex, SRFILELIST_DEFAULTSORT, _T("Master")); } else { m_FileList.SetItemText(ListIndex, SRFILELIST_DEFAULTSORT, _T("")); } }
bool C4Shader::Refresh(const char *szWhat, const char **szUniforms) { // Find a slice where the source file has updated ShaderSliceList::iterator pSlice; for (pSlice = FragmentSlices.begin(); pSlice != FragmentSlices.end(); pSlice++) if (pSlice->Source.getLength() && FileExists(pSlice->Source.getData()) && FileTime(pSlice->Source.getData()) > pSlice->SourceTime) break; if (pSlice == FragmentSlices.end()) return true; StdCopyStrBuf Source = pSlice->Source; // Okay, remove all slices that came from this file ShaderSliceList::iterator pNext; for (; pSlice != FragmentSlices.end(); pSlice = pNext) { pNext = pSlice; pNext++; if (SEqual(pSlice->Source.getData(), Source.getData())) FragmentSlices.erase(pSlice); } // Load new shader char szParentPath[_MAX_PATH+1]; C4Group Group; StdStrBuf Shader; GetParentPath(Source.getData(),szParentPath); if(!Group.Open(szParentPath) || !Group.LoadEntryString(GetFilename(Source.getData()),&Shader) || !Group.Close()) { ShaderLogF(" gl: Failed to refresh %s shader from %s!", szWhat, Source.getData()); return Refresh(szWhat, szUniforms); } // Load slices int iSourceTime = FileTime(Source.getData()); StdStrBuf WhatSrc = FormatString("file %s", Config.AtRelativePath(Source.getData())); AddFragmentSlices(WhatSrc.getData(), Shader.getData(), Source.getData(), iSourceTime); // Reinitialise if (!Init(szWhat, szUniforms)) return false; // Retry return Refresh(szWhat, szUniforms); }
char *FindFrameFile (char *frame) { int time1; char file1[1024]; static char retname[1024]; char base[32]; char suffix[32]; char *s; if (strstr (frame, ".")) return frame; // allready in dot format // split 'run1' into 'run' and '1' s = frame + strlen(frame)-1; while (s != frame && *s >= '0' && *s <= '9') s--; strcpy (suffix, s+1); strcpy (base, frame); base[s-frame+1] = 0; // check for 'run1.tri' sprintf (file1, "%s/%s%s.%s",cddir, base, suffix, trifileext); time1 = FileTime (file1); if (time1 != -1) { sprintf (retname, "%s%s.%s", base, suffix, trifileext); return retname; } // check for 'run.1' sprintf (file1, "%s/%s.%s",cddir, base, suffix); time1 = FileTime (file1); if (time1 != -1) { sprintf (retname, "%s.%s", base, suffix); return retname; } Error ("frame %s could not be found",frame); return NULL; }
/* ================= Cmd_Environment ================= */ void Cmd_Environment( void ){ char name[1024]; int i, x, y; byte image[256 * 256]; byte *tga; GetToken( qfalse ); if ( g_release ) { for ( i = 0 ; i < 6 ; i++ ) { sprintf( name, "env/%s%s.pcx", token, suf[i] ); ReleaseFile( name ); sprintf( name, "env/%s%s.tga", token, suf[i] ); ReleaseFile( name ); } return; } // get the palette BuildPalmap(); sprintf( name, "%senv/", gamedir ); CreatePath( name ); // convert the images for ( i = 0 ; i < 6 ; i++ ) { sprintf( name, "%senv/%s%s.tga", gamedir, token, suf[i] ); printf( "loading %s...\n", name ); LoadTGA( name, &tga, NULL, NULL ); for ( y = 0 ; y < 256 ; y++ ) { for ( x = 0 ; x < 256 ; x++ ) { image[y * 256 + x] = FindColor( tga[( y * 256 + x ) * 4 + 0],tga[( y * 256 + x ) * 4 + 1],tga[( y * 256 + x ) * 4 + 2] ); } } free( tga ); sprintf( name, "%senv/%s%s.pcx", writedir, token, suf[i] ); if ( FileTime( name ) != -1 ) { printf( "%s already exists, not overwriting.\n", name ); } else{ WritePCXfile( name, image, 256, 256, colormap_palette ); } } }
bool C4Shader::LoadSlices(C4GroupSet *pGroups, const char *szFile) { // Search for our shaders C4Group *pGroup = pGroups->FindEntry(szFile); if(!pGroup) return false; // Load it, save the path for later reloading StdStrBuf Shader; if(!pGroup->LoadEntryString(szFile, &Shader)) return false; // If it physically exists, save back creation time so we // can automatically reload it if it changes StdStrBuf Source = FormatString("%s" DirSep "%s", pGroup->GetFullName().getData(), szFile); int iSourceTime = 0; if(FileExists(Source.getData())) iSourceTime = FileTime(Source.getData()); // Load StdStrBuf What = FormatString("file %s", Config.AtRelativePath(Source.getData())); AddFragmentSlices(What.getData(), Shader.getData(), Source.getData(), iSourceTime); return true; }
/** * name: Compare * desc: compare a filetime with the value of current object and return difference as number of seconds * param: ft - FILETIME to compare with * return: number of seconds the ft differs from the class value **/ LONG MTime::Compare(const FILETIME &ft) const { const FILETIME ft1 = FileTime(); return (LONG)((*(__int64*)&ft1 - *(__int64*)&ft) / 10000000i64); }
/* ================= Cmd_Base ================= */ void Cmd_Base (void) { vec3_t base_xyz[MAX_VERTS]; triangle_t *ptri; int i, j, k; #if 1 #else int time1; #endif char file1[1024]; char file2[1024]; GetScriptToken (false); if (g_skipmodel || g_release || g_archive) return; printf ("---------------------\n"); #if 1 sprintf (file1, "%s/%s", cdpartial, token); printf ("%s ", file1); ExpandPathAndArchive (file1); sprintf (file1, "%s/%s", cddir, token); #else sprintf (file1, "%s/%s.%s", cdarchive, token, trifileext); printf ("%s\n", file1); ExpandPathAndArchive (file1); sprintf (file1, "%s/%s.%s", cddir, token, trifileext); time1 = FileTime (file1); if (time1 == -1) Error ("%s doesn't exist", file1); #endif // // load the base triangles // if (do3ds) Load3DSTriangleList (file1, &ptri, &model.num_tris, NULL, NULL); else LoadTriangleList (file1, &ptri, &model.num_tris, NULL, NULL); GetScriptToken (false); sprintf (file2, "%s/%s.pcx", cddir, token); // sprintf (trans_file, "%s/!%s_a.pcx", cddir, token); printf ("skin: %s\n", file2); Load256Image (file2, &BasePixels, &BasePalette, &BaseWidth, &BaseHeight); if (BaseWidth != SKINPAGE_WIDTH || BaseHeight != SKINPAGE_HEIGHT) { if (g_allow_newskin) { ScaleWidth = BaseWidth; ScaleHeight = BaseHeight; } else { Error("Invalid skin page size: (%d,%d) should be (%d,%d)", BaseWidth,BaseHeight,SKINPAGE_WIDTH,SKINPAGE_HEIGHT); } } else { ScaleWidth = (float)ExtractNumber(BasePixels, ENCODED_WIDTH_X, ENCODED_WIDTH_Y); ScaleHeight = (float)ExtractNumber(BasePixels, ENCODED_HEIGHT_X, ENCODED_HEIGHT_Y); } // // get the ST values // BuildST (ptri, model.num_tris,false); // // run through all the base triangles, storing each unique vertex in the // base vertex list and setting the indirect triangles to point to the base // vertices // for (i=0 ; i<model.num_tris ; i++) { for (j=0 ; j<3 ; j++) { // get the xyz index for (k=0 ; k<model.num_xyz ; k++) if (VectorCompare (ptri[i].verts[j], base_xyz[k])) break; // this vertex is already in the base vertex list if (k == model.num_xyz) { // new index VectorCopy (ptri[i].verts[j], base_xyz[model.num_xyz]); if(clustered) ReplaceClusterIndex(k, ptri[i].indicies[j], (int **)&clusters, (IntListNode_t **)&vertLists, (int *)&num_verts, (int *)&new_num_verts); model.num_xyz++; } triangles[i].index_xyz[j] = k; // get the st index for (k=0 ; k<model.num_st ; k++) if (triangle_st[i][j][0] == base_st[k].s && triangle_st[i][j][1] == base_st[k].t) break; // this vertex is already in the base vertex list if (k == model.num_st) { // new index base_st[model.num_st].s = triangle_st[i][j][0]; base_st[model.num_st].t = triangle_st[i][j][1]; model.num_st++; } triangles[i].index_st[j] = k; } } // build triangle strips / fans BuildGlCmds (); }
/* ================= Cmd_Base ================= */ void Cmd_Base (void) { triangle_t *ptri; int i, j, k; int time1; char file1[1024]; GetToken (false); if (g_skipmodel || g_release || g_archive) return; printf ("---------------------\n"); sprintf (file1, "%s/%s.%s", cdarchive, token, trifileext); printf ("%s\n", file1); ExpandPathAndArchive (file1); sprintf (file1, "%s/%s.%s", cddir, token, trifileext); time1 = FileTime (file1); if (time1 == -1) Error ("%s doesn't exist", file1); // // load the base triangles // if (do3ds) Load3DSTriangleList (file1, &ptri, &model.num_tris); else LoadTriangleList (file1, &ptri, &model.num_tris); // // get the ST values // BuildST (ptri, model.num_tris); // // run through all the base triangles, storing each unique vertex in the // base vertex list and setting the indirect triangles to point to the base // vertices // for (i=0 ; i<model.num_tris ; i++) { for (j=0 ; j<3 ; j++) { // get the xyz index for (k=0 ; k<model.num_xyz ; k++) if (VectorCompare (ptri[i].verts[j], base_xyz[k])) break; // this vertex is already in the base vertex list if (k == model.num_xyz) { // new index VectorCopy (ptri[i].verts[j], base_xyz[model.num_xyz]); model.num_xyz++; } triangles[i].index_xyz[j] = k; // get the st index for (k=0 ; k<model.num_st ; k++) if (triangle_st[i][j][0] == base_st[k].s && triangle_st[i][j][1] == base_st[k].t) break; // this vertex is already in the base vertex list if (k == model.num_st) { // new index base_st[model.num_st].s = triangle_st[i][j][0]; base_st[model.num_st].t = triangle_st[i][j][1]; model.num_st++; } triangles[i].index_st[j] = k; } } // build triangle strips / fans BuildGlCmds (); }
void GetFileList(HWND hwndLV, PROJECTITEM *pj, int *items, BOOL changed) { if (pj->type == PJ_FILE) { int rv = FALSE; if (changed) { FILETIME time; if (!pj->resData) { DWINFO *ptr = GetFileInfo(pj->realName); if (ptr) { int a = FileAttributes(ptr->dwName); rv = FALSE; if (a == - 1) a = 0; if (FileTime(&time, ptr->dwName)) { rv = (time.dwHighDateTime != ptr->time.dwHighDateTime || time.dwLowDateTime != ptr->time.dwLowDateTime); ptr->time = time; } if (a &FILE_ATTRIBUTE_READONLY) SendMessage(ptr->dwHandle, EM_SETREADONLY, 1, 0); else SendMessage(ptr->dwHandle, EM_SETREADONLY, 0, 0); } } else { FILETIME time; if (FileTime(&time, pj->realName)) { rv = (time.dwHighDateTime != pj->resData->time.dwHighDateTime || time.dwLowDateTime != pj->resData->time.dwLowDateTime); pj->resData->time = time; } } } else if (!pj->resData) { DWINFO *ptr = GetFileInfo(pj->realName); if (ptr) rv = SendMessage(ptr->dwHandle, EM_GETMODIFY, 0, 0); } else { rv = ResCheckChanged(pj->resData->resources->resources); } if (rv) { int v; LV_ITEM item; struct saveData *sd = calloc(1, sizeof(struct saveData)); if (sd) { DWINFO *ptr; sd->asProject = TRUE; sd->data = pj; memset(&item, 0, sizeof(item)); item.iItem = (*items)++; item.iSubItem = 0; item.mask = LVIF_PARAM; item.lParam = (LPARAM)sd; item.pszText = ""; // LPSTR_TEXTCALLBACK ; v = ListView_InsertItem(hwndLV, &item); ListView_SetCheckState(hwndLV, v, TRUE); ptr = GetFileInfo(pj->realName); if (ptr) ptr->inSaveDialog = TRUE; } } } else { PROJECTITEM *cur = pj->children; while (cur) { GetFileList(hwndLV, cur, items, changed); cur = cur->next; } } }
void GetSecondaryFileList(HWND hwndLV, int *items, BOOL changed) { DWINFO *ptr; MSG msg; MsgWait(ewSem, INFINITE); ptr = editWindows; while (ptr) { ptr->deferClose = TRUE; ptr = ptr->next; } SetEvent(ewSem); ptr = editWindows; while (ptr) { if (!ptr->inSaveDialog) { int rv = FALSE; if (changed) { FILETIME time; int a = FileAttributes(ptr->dwName); rv = FALSE; if (a == - 1) a = 0; if (FileTime(&time, ptr->dwName)) { rv = (time.dwHighDateTime != ptr->time.dwHighDateTime || time.dwLowDateTime != ptr->time.dwLowDateTime); ptr->time = time; } if (a &FILE_ATTRIBUTE_READONLY) SendMessage(ptr->dwHandle, EM_SETREADONLY, 1, 0); else SendMessage(ptr->dwHandle, EM_SETREADONLY, 0, 0); } else { rv = SendMessage(ptr->dwHandle, EM_GETMODIFY, 0, 0); } if (rv) { int v; LV_ITEM item; struct saveData *sd = calloc(1, sizeof(struct saveData)); if (sd) { sd->asProject = FALSE; sd->data = ptr; memset(&item, 0, sizeof(item)); item.iItem = (*items)++; item.iSubItem = 0; item.mask = LVIF_PARAM; item.lParam = (LPARAM)sd; item.pszText = ""; // LPSTR_TEXTCALLBACK ; v = ListView_InsertItem(hwndLV, &item); ListView_SetCheckState(hwndLV, v, TRUE); } } } ptr = ptr->next; } ptr = editWindows; while (ptr) { HWND xx = ptr->self; ptr = ptr->next; PostMessage(xx, WM_DEFERREDCLOSE, 0, 0); } while (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) ProcessMessage(&msg); }
FileTime mxDataStream::GetTimeStamp() { return FileTime(); }