void CModViewView::OnTimer(UINT nIDEvent) { if (nIDEvent != th_100FPS) { CView::OnTimer(nIDEvent); return; } // otherwise, it's one of our timer events, so... { // new bit, poll the remote control stuff 10 times per second (it's also done in OnIdle(), but that's not always fast enough when animating) static float fTime = 0.0f; float fTimeNow = GetFloatTime(); #define UPDATE_FRAMES_PER_SECOND 10.0f if (fTimeNow - fTime > 1.0f/UPDATE_FRAMES_PER_SECOND) { fTime = fTimeNow; // OutputDebugString(va("Time = %f seconds\n",GetFloatTime())); if (WinTalk_HandleMessages()) { // app exit requested AppVars.bAnimate = qfalse; // groan... stop the animation so the app doesn't spend all it's time // in the render loop. This allows the App::OnIdle() version // of the Wintalk_HandleMessages() handler to get a look in, // and therefore spot that an exit is being requested. } } } // if (!DraggingMouse()) { if (ModelList_Animation()) { // one or more models have updated frames (or lerping)... // Invalidate(false); } } if (Gallery_Active()) { extern bool gbInRenderer; if (!gbInRenderer) { static bool bAlreadyHere = false; if (!bAlreadyHere) // jic. { bAlreadyHere = true; extern int giRenderCount; static CString strCaption; static CString strScript; static bool bSnapshotTakingPlace = false; if (!bSnapshotTakingPlace) { int iRemainingPlusOne = GalleryRead_ExtractEntry(strCaption, strScript); if (iRemainingPlusOne) // because 0 would be fail/empty { giGalleryItemsRemaining = iRemainingPlusOne-1; StatusMessage( va("( Gallery: %d remaining )", giGalleryItemsRemaining) ); OutputDebugString(va("\"%s\" (script len %d)\n",(LPCSTR)strCaption,strScript.GetLength())); strScript += "\n"; string strOutputFileName( va("%s\\%s",scGetTempPath(),"temp.mvs") ); int iReturn = SaveFile(strOutputFileName.c_str(),(LPCSTR)strScript, strScript.GetLength()); if (iReturn != -1) { extern bool Document_ModelLoadPrimary(LPCSTR psFilename); if (Document_ModelLoadPrimary(strOutputFileName.c_str())) { if (Model_Loaded()) { ModelHandle_t hModel = AppVars.Container.hModel; Model_Sequence_Lock( hModel, Gallery_GetSeqToLock(), true, false); } giRenderCount = 0; bSnapshotTakingPlace = true; } } } else { // all done... // gbTextInhibit = false; Gallery_Done(); StatusMessage( NULL ); // // report... // CString strReport; if (!strGalleryErrors.IsEmpty()) { strReport += "====================== Errors: ===================\n\n"; strReport += strGalleryErrors; strReport += "\n\n"; } if (!strGalleryWarnings.IsEmpty()) { strReport += "====================== Warnings: ===================\n\n"; strReport += strGalleryWarnings; strReport += "\n\n"; } if (!strGalleryInfo.IsEmpty()) { strReport += "====================== Info: ===================\n\n"; strReport += strGalleryInfo; strReport += "\n\n"; } if (!strReport.IsEmpty()) { strReport.Insert(0,"The following messages appeared during gallery-snapshots....\n\n"); } else { strReport = va("All gallery-snapshots done\n\nOutput dir was: \"%s\\n",Gallery_GetOutputDir()); } SendStringToNotepad(strReport,"gallery_report.txt"); } } else { if (giRenderCount == 2) // ... so it's rendered to back buffer for snapshot, and front for user { // // generate a filename... // char sOutputFileName[MAX_PATH]; CString strBaseName(strCaption); while (strBaseName.Replace("\t"," ")); while (strBaseName.Replace(" "," ")); sprintf(sOutputFileName, "%s\\%s.bmp",Gallery_GetOutputDir(),strBaseName); ScreenShot(sOutputFileName,/*strCaption*/strBaseName); BMP_Free(); bSnapshotTakingPlace = false; // trigger next snapshot } else { Invalidate(false); // cause another screen update until render count satisfied } } bAlreadyHere = false; } } } }
void UI_Dump_f(void) { string sFinalOutput; vector <string> vStripEdFiles; #define OUTPUT sFinalOutput+= #define OUTPUTSTRIP vStripEdFiles[vStripEdFiles.size()-1] += OUTPUT("### UI_Dump(): Top\n"); for (ReferencesAndPackages_t::iterator it = ReferencesAndPackage.begin(); it!=ReferencesAndPackage.end(); ++it) { if ( (*it).second.size()>1) { OUTPUT(va("!!!DUP: Ref \"%s\" exists in:\n",(*it).first.c_str())); StringSet_t &Set = (*it).second; for (StringSet_t::iterator itS = Set.begin(); itS!=Set.end(); ++itS) { OUTPUT(va("%s\n",(*itS).c_str())); } } } OUTPUT("\nSP Package Reference list:\n"); for (StringSet_t::iterator itS = MenusUsed.begin(); itS!=MenusUsed.end(); ++itS) { OUTPUT(va("%s\n",(*itS).c_str())); } OUTPUT("\nBad Text list:\n"); for (References_t::iterator itBad=BadReferences.begin(); itBad!=BadReferences.end();++itBad) { Reference_t &BadReference = (*itBad); OUTPUT(va("File: %30s \"%s\"\n",BadReference.sMenu.c_str(), BadReference.sString.c_str())); } OUTPUT("\nAdding bad references to final correction list...\n"); for (itBad=BadReferences.begin(); itBad!=BadReferences.end();++itBad) { Reference_t &BadReference = (*itBad); EnterRef("", BadReference.sString.c_str(), BadReference.sMenu.c_str() ); } OUTPUT("\nFinal correction list:\n"); // qboolean bIsMulti = !!strstr((*CorrectionData.begin()).sMenuFile.c_str(),"jk2mp"); // actually do the find/replace... // for (CorrectionData_t::iterator itCorrectionData = CorrectionData.begin(); itCorrectionData != CorrectionData.end(); ++itCorrectionData) { CorrectionDataItem_t &CorrectionDataItem = (*itCorrectionData); if (CorrectionDataItem.sTextToFind.c_str()[0] && CorrectionDataItem.sTextToReplaceWith.c_str()[0]) { OUTPUT( va("Load File: \"%s\", find \"%s\", replace with \"%s\"\n", CorrectionDataItem.sMenuFile.c_str(), CorrectionDataItem.sTextToFind.c_str(), CorrectionDataItem.sTextToReplaceWith.c_str() ) ); // if (strstr(CorrectionDataItem.sTextToReplaceWith.c_str(),"START_A_NEW_GAME")) // { // int z=1; // } assert( CorrectionDataItem.sTextToReplaceWith.c_str()[0] ); string sReplace( CorrectionDataItem.sTextToReplaceWith.c_str() ); sReplace.insert(1,"_"); sReplace.insert(1,CorrectionDataItem.sStripEdFileRef.c_str()); DoFileFindReplace( CorrectionDataItem.sMenuFile.c_str(), CorrectionDataItem.sTextToFind.c_str(), sReplace.c_str()//CorrectionDataItem.sTextToReplaceWith.c_str() ); } } // scan in all SP files into one huge string, so I can pick out any foreign translations to add in when generating // new StripEd files... // char **ppsFiles; char *buffers[1000]; // max # SP files, well-OTT. int iNumFiles; int i; string sStripFiles; // scan for shader files ppsFiles = FS_ListFiles( "strip", ".sp", &iNumFiles ); if ( !ppsFiles || !iNumFiles ) { assert(0); } else { // load files... // for (i=0; i<iNumFiles; i++) { char sFilename[MAX_QPATH]; Com_sprintf( sFilename, sizeof( sFilename ), "strip/%s", ppsFiles[i] ); OutputDebugString( va("...loading '%s'\n", sFilename ) ); int iLen = FS_ReadFile( sFilename, (void **)&buffers[i] ); if ( iLen<1 ) { assert(0);//Com_Error( ERR_DROP, "Couldn't load %s", filename ); } } // free up memory... // FS_FreeFileList( ppsFiles ); // build single large buffer and free up buffers as we go... // // ( free in reverse order, so the temp files are all dumped ) for ( i=iNumFiles-1; i>=0; i-- ) { sStripFiles += buffers[i]; sStripFiles += "\r\n"; FS_FreeFile( buffers[i] ); } } int iIndex=0; for (itCorrectionData = CorrectionData.begin(); itCorrectionData != CorrectionData.end(); ++itCorrectionData) { CorrectionDataItem_t &CorrectionDataItem = (*itCorrectionData); if (CorrectionDataItem.sStripEdReference.c_str()[0] // skip over duplicate-resolving entries // && CorrectionDataItem.sStripEdText.c_str()[0] // ) { string strAnyForeignStringsFound; // will be entire line plus CR string strNotes; // will be just the bit within quotes LPCSTR psFoundExisting; int iInitialSearchPos = 0; while (iInitialSearchPos < sStripFiles.size() && (strAnyForeignStringsFound.empty() || strNotes.empty()) ) { if ( (psFoundExisting = strstr( sStripFiles.c_str()+iInitialSearchPos, va("\"%s\"",CorrectionDataItem.sStripEdText.c_str()))) != NULL ) { // see if we can find any NOTES entry above this... // LPCSTR p; if (strNotes.empty()) { p = psFoundExisting; while (p > sStripFiles.c_str() && *p!='{') { if (!strnicmp(p,"NOTES",5) && isspace(p[-1]) && isspace(p[5])) { p = strchr(p,'"'); if (!p++) break; while (*p != '"') strNotes += *p++; break; } p--; } } // now search for any foreign versions we already have translated... // if (strAnyForeignStringsFound.empty()) { p = psFoundExisting; LPCSTR psNextBrace = strchr(p,'}'); assert(psNextBrace); if (psNextBrace) { for (int i=2; i<10; i++) { LPCSTR psForeign = strstr(p,va("TEXT_LANGUAGE%d",i)); if (psForeign && psForeign < psNextBrace) { strAnyForeignStringsFound += " "; while (*psForeign != '\n' && *psForeign != '\0') { strAnyForeignStringsFound += *psForeign++; } strAnyForeignStringsFound += "\n"; } } } } iInitialSearchPos = psFoundExisting - sStripFiles.c_str(); iInitialSearchPos++; // one past, so we don't re-find ourselves } else { break; } } if (!strNotes.empty()) { strNotes = va(" NOTES \"%s\"\n",strNotes.c_str()); } // now do output... // if (!(iIndex%256)) { string s; vStripEdFiles.push_back(s); OUTPUTSTRIP( va( "VERSION 1\n" "CONFIG W:\\bin\\striped.cfg\n" "ID %d\n" "REFERENCE MENUS%d\n" "DESCRIPTION \"menu text\"\n" "COUNT 256\n", // count will need correcting for last one 250 + (iIndex/256), // 250 range seems to be unused iIndex/256 ) ); // OUTPUTSTRIP( va("REFERENCE %s\n", va("%sMENUS%d",bIsMulti?"MP":"SP",iIndex/256)) ); // OUTPUTSTRIP( va("REFERENCE %s\n", va( "MENUS%d",iIndex/256)) ); } OUTPUTSTRIP( va( "INDEX %d\n" "{\n" " REFERENCE %s\n" "%s" " TEXT_LANGUAGE1 \"%s\"\n" "%s" "}\n", iIndex%256, CorrectionDataItem.sStripEdReference.c_str(), (strNotes.empty()?"":strNotes.c_str()), CorrectionDataItem.sStripEdText.c_str(), strAnyForeignStringsFound.c_str() ) ); iIndex++; } } OUTPUT("### UI_Dump(): Bottom\n"); SendStringToNotepad(sFinalOutput.c_str(), "temp.txt"); // output the SP files... // for (i=0; i<vStripEdFiles.size(); i++) { // need to make local string, because ingame va() is crippled to 2 depths... // char sName[MAX_PATH]; sprintf(sName,"Source\\StarWars\\code\\base\\strip\\MENUS%d.sp",i); SendStringToNotepad(vStripEdFiles[i].c_str(), sName); } }
bool Skins_Validate( ModelContainer_t *pContainer, int iSkinNumber ) { bool bReturn = true; bool bPREV_bReportImageLoadErrors = g_bReportImageLoadErrors; g_bReportImageLoadErrors = false; bool bCheckMissingMaterials = true;//GetYesNo("Check for materials referenced by model but missing in skinfile(s)?\n\n( Note: This can give false alarms for skins which don't use (eg) \"scarf\" )"); // first, build up a list of all model materials... // StringSet_t MaterialsPresentInModel; for (int iSurface = 0; iSurface < pContainer->iNumSurfaces; iSurface++) { bool bOnOff = GLMModel_SurfaceIsON(pContainer->hModel, iSurface); if (bOnOff) { LPCSTR psMaterial = GLMModel_GetSurfaceShaderName( pContainer->hModel, iSurface); MaterialsPresentInModel.insert(MaterialsPresentInModel.end(),psMaterial); } } // build up a list of shaders used... // StringSet_t UniqueSkinShaders; SkinFileMaterialsMissing_t SkinFileMaterialsMissing; int iThisSkinIndex = 0; for (SkinSets_t::iterator itSkins = pContainer->SkinSets.begin(); itSkins != pContainer->SkinSets.end(); ++itSkins, iThisSkinIndex++) { if (iSkinNumber == iThisSkinIndex || iSkinNumber == -1) { SkinSet_Validate_BuildList(UniqueSkinShaders, itSkins, MaterialsPresentInModel, SkinFileMaterialsMissing); } } // now process the unique list we've just built... // CWaitCursor wait; string strFoundList; string strNotFoundList; int iUniqueIndex = 0; for (StringSet_t::iterator it = UniqueSkinShaders.begin(); it != UniqueSkinShaders.end(); ++it, iUniqueIndex++) { string strShader(*it); StatusMessage(va("Processing shader %d/%d: \"%s\"\n",iUniqueIndex,UniqueSkinShaders.size(),strShader.c_str())); OutputDebugString(va("Unique: \"%s\"... ",strShader.c_str())); int iTextureHandle = Texture_Load(strShader.c_str(), true); // bInhibitStatus GLuint uiGLBind = Texture_GetGLBind( iTextureHandle ); if (uiGLBind == 0) { OutputDebugString("NOT FOUND\n"); strNotFoundList += strShader; strNotFoundList += "\n"; } else { OutputDebugString("found\n"); strFoundList += strShader; strFoundList += "\n"; } } StatusMessage(NULL); // see if we were missing any model materials in these skins... // CString strModelMaterialsMissing; if (SkinFileMaterialsMissing.size()) { for (SkinFileMaterialsMissing_t::iterator itSkinFileMaterialsMissing = SkinFileMaterialsMissing.begin(); itSkinFileMaterialsMissing != SkinFileMaterialsMissing.end(); ++itSkinFileMaterialsMissing) { string strSkinFileName((*itSkinFileMaterialsMissing).first); if (iSkinNumber == -1) { strModelMaterialsMissing += va("\nSkin \"%s\":\n",strSkinFileName.c_str()); } for (EthnicMaterials_t::iterator itSkinFile = (*itSkinFileMaterialsMissing).second.begin(); itSkinFile != (*itSkinFileMaterialsMissing).second.end(); ++itSkinFile) { string strEthnicFileName((*itSkinFile).first); strModelMaterialsMissing += va("Ethnic \"%s\": ",strEthnicFileName.c_str()); StringVector_t& MaterialStrings = (*itSkinFile).second; for (int iMaterial = 0; iMaterial != MaterialStrings.size(); ++iMaterial) { string strMaterial(MaterialStrings[iMaterial]); strModelMaterialsMissing += va("%s\"%s\"",(iMaterial==0)?"":", ",strMaterial.c_str()); } strModelMaterialsMissing += "\n"; } } } if (!strModelMaterialsMissing.IsEmpty()) { if (iSkinNumber == -1) { strModelMaterialsMissing.Insert(0, "One or more skin files are missing some material definitions referenced by this model's currently-active surfaces.\nList follows...\n\n"); } else { strModelMaterialsMissing.Insert(0, "This skin file is missing one or more material definitions referenced by this model's currently-active surfaces.\nList follows...\n\n"); } } if (!strModelMaterialsMissing.IsEmpty()) { if (bCheckMissingMaterials) { WarningBox(va("Summary Part 1: Missing materials\n\n%s",(LPCSTR)strModelMaterialsMissing)); } } // Now output results... // If too many lines to fit on screen (which is now happening), send 'em to notepad instead... // // ( tacky way of counting lines...) CString strTackyCount(strNotFoundList.c_str()); strTackyCount += strFoundList.c_str(); int iLines = strTackyCount.Replace('\n','?'); // :-) #define MAX_BOX_LINES_HERE 50 if (strNotFoundList.empty()) { if (iLines > MAX_BOX_LINES_HERE) { if (GetYesNo(va("All shaders found... :-)\n\nList has > %d entries, send to Notepad?",MAX_BOX_LINES_HERE))) { SendStringToNotepad(va("All shaders found... :-)\n\nList follows:\n\n%s",strFoundList.c_str()),"found_shaders.txt"); } } else { InfoBox(va("All shaders found... :-)\n\nList follows:\n\n%s",strFoundList.c_str())); } } else { if (iLines > MAX_BOX_LINES_HERE) { if (GetYesNo(va("Some missing shader, some found, but list is > %d entries, send to Notepad?",MAX_BOX_LINES_HERE))) { SendStringToNotepad(va("Missing shaders:\n\n%s\n\nFound shaders:\n\n%s",strNotFoundList.c_str(),strFoundList.c_str()),"found_shaders.txt"); } } else { WarningBox(va("Missing shaders:\n\n%s\n\nFound shaders:\n\n%s",strNotFoundList.c_str(),strFoundList.c_str())); } bReturn = false; } g_bReportImageLoadErrors = bPREV_bReportImageLoadErrors; return bReturn; }