static void rmDeactivate(void * /* dummy */ ) { if (FileList) { GfDirFreeList(FileList, NULL); FileList = NULL; } GfuiScreenActivate(rmFs->prevScreen); }
static void rmtsDeactivate(void *screen) { GfuiScreenRelease(scrHandle); GfDirFreeList(CategoryList, rmtsFreeLists, true, true); if (screen) { GfuiScreenActivate(screen); } }
static void rmSelect(void * /* dummy */ ) { if (FileList) { rmFs->select(FileSelected->name); GfDirFreeList(FileList, NULL); FileList = NULL; } else { rmFs->select(NULL); } }
void GfDriver::getPossibleSkinsInFolder(const std::string& strCarId, const std::string& strFolderPath, std::vector<GfDriverSkin>& vecPossSkins) const { //GfLogDebug(" getPossibleSkinsInFolder(%s, %s) ...\n", // strCarId.c_str(), strFolderPath.c_str()); // Search for skinned livery files, and associated preview files if any. tFList *pLiveryFileList = GfDirGetListFiltered(strFolderPath.c_str(), strCarId.c_str(), pszLiveryTexExt); if (pLiveryFileList) { tFList *pCurLiveryFile = pLiveryFileList; do { pCurLiveryFile = pCurLiveryFile->next; // Extract the skin name from the livery file name. const int nSkinNameLen = // Expecting "<car name>-<skin name>.png" strlen(pCurLiveryFile->name) - strCarId.length() - 1 - strlen(pszLiveryTexExt); std::string strSkinName; if (nSkinNameLen > 0) // Otherwise, default/standard "<car name>.png" { strSkinName = std::string(pCurLiveryFile->name) .substr(strCarId.length() + 1, nSkinNameLen); // Ignore skins with an excluded prefix. int nExclPrfxInd = 0; for (; nExclPrfxInd < nExcludedSkinNamePrefixes; nExclPrfxInd++) if (strSkinName.find(apszExcludedSkinNamePrefixes[nExclPrfxInd]) == 0) break; if (nExclPrfxInd < nExcludedSkinNamePrefixes) continue; } // Ignore skins that are already in the list (path search priority). if (findSkin(vecPossSkins, strSkinName) == vecPossSkins.end()) { // Create the new skin. GfDriverSkin skin(strSkinName); // Add the whole car livery to the skin targets. skin.addTargets(RM_CAR_SKIN_TARGET_WHOLE_LIVERY); GfLogDebug(" Found %s%s livery\n", strSkinName.empty() ? "standard" : strSkinName.c_str(), strSkinName.empty() ? "" : "-skinned"); // Add associated preview image, without really checking file existence // (warn only ; up to the client GUI to do what to do if it doesn't exist). std::ostringstream ossPreviewName; ossPreviewName << strFolderPath << '/' << strCarId; if (!strSkinName.empty()) ossPreviewName << '-' << strSkinName; ossPreviewName << pszPreviewTexSufx; skin.setCarPreviewFileName(ossPreviewName.str()); if (!GfFileExists(ossPreviewName.str().c_str())) GfLogWarning("Preview file not found for %s %s skin (%s)\n", strCarId.c_str(), strSkinName.c_str(), ossPreviewName.str().c_str()); //else // GfLogDebug("* found skin=%s, preview=%s\n", // strSkinName.c_str(), ossPreviewName.str().c_str()); // Add the new skin to the list. vecPossSkins.push_back(skin); } } while (pCurLiveryFile != pLiveryFileList); } GfDirFreeList(pLiveryFileList, NULL, true, true); // Search for skinned interior files, if any. std::string strInteriorPrefix(strCarId); strInteriorPrefix += pszInteriorTexSufx; tFList *pIntFileList = GfDirGetListFiltered(strFolderPath.c_str(), strInteriorPrefix.c_str(), pszInteriorTexExt); if (pIntFileList) { tFList *pCurIntFile = pIntFileList; do { pCurIntFile = pCurIntFile->next; // Extract the skin name from the interior file name. const int nSkinNameLen = // Expecting "<car name>-int-<skin name>.png" strlen(pCurIntFile->name) - strInteriorPrefix.length() - 1 - strlen(pszInteriorTexExt); std::string strSkinName; if (nSkinNameLen > 0) { strSkinName = std::string(pCurIntFile->name) .substr(strInteriorPrefix.length() + 1, nSkinNameLen); // If a skin with such name already exists in the list, update it. std::vector<GfDriverSkin>::iterator itSkin = findSkin(vecPossSkins, strSkinName); if (itSkin != vecPossSkins.end()) { itSkin->addTargets(RM_CAR_SKIN_TARGET_INTERIOR); GfLogDebug(" Found %s-skinned interior (targets:%x)\n", strSkinName.c_str(), itSkin->getTargets()); } } } while (pCurIntFile != pIntFileList); } GfDirFreeList(pIntFileList, NULL, true, true); // Search for skinned logo files if any. tFList *pLogoFileList = GfDirGetListFiltered(strFolderPath.c_str(), pszLogoTexName, pszLogoTexExt); if (pLogoFileList) { tFList *pCurLogoFile = pLogoFileList; do { pCurLogoFile = pCurLogoFile->next; // Extract the skin name from the logo file name. const int nSkinNameLen = // Expecting "logo-<skin name>.png" strlen(pCurLogoFile->name) - strlen(pszLogoTexName) - 1 - strlen(pszLogoTexExt); if (nSkinNameLen > 0) { const std::string strSkinName = std::string(pCurLogoFile->name) .substr(strlen(pszLogoTexName) + 1, nSkinNameLen); // If a skin with such name already exists in the list, update it. std::vector<GfDriverSkin>::iterator itSkin = findSkin(vecPossSkins, strSkinName); if (itSkin != vecPossSkins.end()) { itSkin->addTargets(RM_CAR_SKIN_TARGET_PIT_DOOR); GfLogDebug(" Found %s-skinned logo (targets:%x)\n", strSkinName.c_str(), itSkin->getTargets()); } } } while (pCurLogoFile != pLogoFileList); } GfDirFreeList(pLogoFileList, NULL, true, true); // Search for skinned 3D wheel files if any. tFList *pWheel3DFileList = GfDirGetListFiltered(strFolderPath.c_str(), pszWheel3DTexName, pszWheel3DTexExt); if (pWheel3DFileList) { tFList *pCurWheel3DFile = pWheel3DFileList; do { pCurWheel3DFile = pCurWheel3DFile->next; // Extract the skin name from the 3D wheel texture file name. const int nSkinNameLen = // Expecting "wheel3d-<skin name>.png" strlen(pCurWheel3DFile->name) - strlen(pszWheel3DTexName) - 1 - strlen(pszWheel3DTexExt); if (nSkinNameLen > 0) { const std::string strSkinName = std::string(pCurWheel3DFile->name) .substr(strlen(pszWheel3DTexName) + 1, nSkinNameLen); // If a skin with such name already exists in the list, update it. std::vector<GfDriverSkin>::iterator itSkin = findSkin(vecPossSkins, strSkinName); if (itSkin != vecPossSkins.end()) { itSkin->addTargets(RM_CAR_SKIN_TARGET_3D_WHEELS); GfLogDebug(" Found %s-skinned 3D wheels (targets:%x)\n", strSkinName.c_str(), itSkin->getTargets()); } } } while (pCurWheel3DFile != pWheel3DFileList); } GfDirFreeList(pWheel3DFileList, NULL, true, true); // Search for skinned driver files if any. tFList *pDriverFileList = GfDirGetListFiltered(strFolderPath.c_str(), pszDriverTexName, pszDriverTexExt); if (pDriverFileList) { tFList *pCurDriverFile = pDriverFileList; do { pCurDriverFile = pCurDriverFile->next; // Extract the skin name from the 3D wheel texture file name. const int nSkinNameLen = // Expecting "driver-<skin name>.png" strlen(pCurDriverFile->name) - strlen(pszDriverTexName) - 1 - strlen(pszDriverTexExt); if (nSkinNameLen > 0) { const std::string strSkinName = std::string(pCurDriverFile->name) .substr(strlen(pszDriverTexName) + 1, nSkinNameLen); // If a skin with such name already exists in the list, update it. std::vector<GfDriverSkin>::iterator itSkin = findSkin(vecPossSkins, strSkinName); if (itSkin != vecPossSkins.end()) { itSkin->addTargets(RM_CAR_SKIN_TARGET_DRIVER); GfLogDebug(" Found %s-skinned driver (targets:%x)\n", strSkinName.c_str(), itSkin->getTargets()); } } } while (pCurDriverFile != pDriverFileList); } GfDirFreeList(pDriverFileList, NULL, true, true); }
GfTracks::GfTracks() { _pPrivate = new GfTracks::Private; // Get the list of sub-dirs in the "tracks" folder (the track categories). tFList* lstCatFolders = GfDirGetList("tracks"); if (!lstCatFolders) { GfLogFatal("No track category available in the 'tracks' folder\n"); return; } tFList* pCatFolder = lstCatFolders; do { //GfLogDebug("GfTracks::GfTracks() : Examining category %s\n", pCatFolder->name); // Ignore "." and ".." folders. const char* pszCatId = pCatFolder->name; if (pszCatId[0] == '.') continue; // Get the list of sub-dirs in the "tracks" folder (the track categories). std::string strDirName("tracks/"); strDirName += pszCatId; tFList* lstTrackFolders = GfDirGetList(strDirName.c_str()); if (!lstTrackFolders) { GfLogWarning("No track available in the '%s' folder\n", strDirName.c_str()); continue; } // Add new category. _pPrivate->vecCatIds.push_back(pszCatId); // Look at the tracks in this category. tFList* pTrackFolder = lstTrackFolders; do { //GfLogDebug("GfTracks::GfTracks() : Examining track %s\n", pTrackFolder->name); // Determine and check the XML file of the track. const char* pszTrackId = pTrackFolder->name; std::ostringstream ossFileName; ossFileName << "tracks/" << pszCatId << '/' << pszTrackId << '/' << pszTrackId << '.' << TRKEXT; const std::string strTrackFileName(ossFileName.str()); if (!GfFileExists(strTrackFileName.c_str())) { GfLogInfo("Ignoring track %s : %s not found\n", pszTrackId, strTrackFileName.c_str()); continue; } // Get 1st level track info (those which don't need to open any file). ossFileName.str(""); ossFileName << "tracks/" << pszCatId << '/' << pszTrackId << '/' << pszTrackId << ".jpg"; std::string strPreviewFileName(ossFileName.str()); if (!GfFileExists(strPreviewFileName.c_str())) { ossFileName.str(""); ossFileName << "tracks/" << pszCatId << '/' << pszTrackId << '/' << pszTrackId << ".png"; strPreviewFileName = ossFileName.str(); } if (!GfFileExists(strPreviewFileName.c_str())) strPreviewFileName = "data/img/splash-trackselect.jpg"; ossFileName.str(""); ossFileName << "tracks/" << pszCatId << '/' << pszTrackId << '/' << "outline.png"; std::string strOutlineFileName(ossFileName.str()); if (!GfFileExists(strOutlineFileName.c_str())) strOutlineFileName = "data/img/notrackoutline.png"; // Store track info in the GfTrack structure. GfTrack* pTrack = new GfTrack; pTrack->setId(pszTrackId); pTrack->setCategoryId(pszCatId); pTrack->setDescriptorFile(strTrackFileName); pTrack->setPreviewFile(strPreviewFileName); pTrack->setOutlineFile(strOutlineFileName); // Update the GfTracks singleton. _pPrivate->vecTracks.push_back(pTrack); _pPrivate->mapTracksById[pszTrackId] = pTrack; } while ((pTrackFolder = pTrackFolder->next) != lstTrackFolders); GfDirFreeList(lstTrackFolders, NULL, true, true); } while ((pCatFolder = pCatFolder->next) != lstCatFolders); GfDirFreeList(lstCatFolders, NULL, true, true); // Sort the car category ids and driver types vectors. std::sort(_pPrivate->vecCatIds.begin(), _pPrivate->vecCatIds.end()); // Trace what we got. print(false); // No verbose here, otherwise infinite recursion. }
static void rmtsFreeLists(void *vl) { GfDirFreeList((tFList*)(((tFList*)vl)->userData), NULL, true, true); }
static void rmtsFreeLists(void *vl) { GfDirFreeList((tFList*)vl, NULL, true, true); }