/* Load race managers selection menu */ void ReAddRacemanListButton(void *menuHandle) { tFList *racemanList; tFList *racemanCur; racemanList = GfDirGetListFiltered("config/raceman", "xml"); if (!racemanList) { GfOut("No race manager available\n"); return; } racemanCur = racemanList; do { reRegisterRaceman(racemanCur); racemanCur = racemanCur->next; } while (racemanCur != racemanList); reSortRacemanList(&racemanList); racemanCur = racemanList; do { GfuiMenuButtonCreate(menuHandle, racemanCur->dispName, GfParmGetStr(racemanCur->userData, RM_SECT_HEADER, RM_ATTR_DESCR, ""), racemanCur->userData, reSelectRaceman); racemanCur = racemanCur->next; } while (racemanCur != racemanList); // The list contains at least one element, checked above. tFList *rl = racemanList; do { tFList *tmp = rl; rl = rl->next; // Do not free userData and dispName, is in use. freez(tmp->name); free(tmp); } while (rl != racemanList); }
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); }