public static async Task ApplyPreviewsAsync([NotNull] string acRoot, [NotNull] string carName, [NotNull] string source, bool resize, [CanBeNull] AcPreviewImageInformation information, IProgress <Tuple <string, double?> > progress = null, CancellationToken cancellation = default(CancellationToken)) { var files = Directory.GetFiles(source, "*.bmp"); for (var i = 0; i < files.Length; i++) { var file = files[i]; var id = Path.GetFileNameWithoutExtension(file); var skinDirectory = AcPaths.GetCarSkinDirectory(acRoot, carName, id); if (!Directory.Exists(skinDirectory)) { continue; } progress?.Report(new Tuple <string, double?>(id, (double)i / files.Length)); await Task.Run(() => { ApplyPreview(file, Path.Combine(skinDirectory, "preview.jpg"), resize, information); }, cancellation); if (cancellation.IsCancellationRequested) { return; } } try { Directory.Delete(source); } catch (Exception) { // ignored } }
public static void ApplyPreviews([NotNull] string acRoot, [NotNull] string carName, [NotNull] string source, bool resize, [CanBeNull] AcPreviewImageInformation information) { foreach (var file in Directory.GetFiles(source, "*.bmp")) { var skinDirectory = AcPaths.GetCarSkinDirectory(acRoot, carName, Path.GetFileNameWithoutExtension(file)); if (!Directory.Exists(skinDirectory)) { continue; } ApplyPreview(file, Path.Combine(skinDirectory, "preview.jpg"), resize, information); } }
public static string GetSfxGuidsFilename(string acRoot) { return(AcPaths.GetSfxGuidsFilename(acRoot)); }
private static bool IsGameProcess(Process process) { var directory = Path.GetDirectoryName(process.GetFilenameSafe()); return(directory == null || AcPaths.IsAcRoot(directory)); }