Esempio n. 1
0
        //processing files lists
        public static void ProcessFileLists(string sFolderPath, FolderProcessingParams cfg)
        {
            RefreshInfo(sFolderPath, false, false);
            FileSkipCount = 0;

            var iExcludeCount = 0;
            var argHandler    = new ArgumentsHandler();
            var lConvParms    = new List <ImageManager.ConversionParameters>();

            foreach (var s in fileList)
            {
                if (!argHandler.IsFileExcluded(s, cfg))
                {
                    lConvParms.Add(argHandler.GetConversionParameters(s, cfg));
                }
                else
                {
                    iExcludeCount += 1;
                }
            }

            var iStep = 0;

            MainForm.Log_WriteLine("-----");
            MainForm.Log_WriteLine("Starting conversion of " + fileList.Count + " files.");
            MainForm.Log_WriteLine("    MBM count : " + argHandler.Count_MBM + ".");
            MainForm.Log_WriteLine("    TGA count : " + argHandler.Count_TGA + ".");
            MainForm.Log_WriteLine("    PNG count : " + argHandler.Count_PNG + ".");
            MainForm.Log_WriteLine(iExcludeCount + " files excluded, " + argHandler.Count_NoMipmaps + " files without mipmaps. " + (argHandler.Count_ForceNormal + argHandler.Count_ForceNotNormal) + " files will skip normal detection." + argHandler.Count_NoResize + " files will not be resized.");
            MainForm.Log_WriteLine("-----");

            var sw = Stopwatch.StartNew();

            //processing
            foreach (var c in lConvParms)
            {
                if (c.FileType == ImageManager.FileType.MBM)
                {
                    ImageManager.ConvertMBMtoDDS(c, cfg);
                }
                else
                {
                    ImageManager.ConvertFileToDDS(c, cfg);
                }

                iStep += 1;

                MainForm.ReportProgress(Convert.ToInt32((iStep / lConvParms.Count) * 100), "Processing " + Path.GetFileName(c.FilePath) + ", file " + iStep + "\\" + lConvParms.Count);
                MainForm.Log_WriteLine("---");
                Application.DoEvents();
            }

            sw.Stop();
            MainForm.Log_WriteLine("-----");
            MainForm.Log_WriteLine(String.Format("Conversion done! {0} files processed in {1}ms.", lConvParms.Count, sw.Elapsed.TotalMilliseconds));
            if (FileSkipCount > 0)
            {
                MainForm.Log_WriteLine(FileSkipCount + " files skipped, check log.txt for more informations.");
            }
            MainForm.Log_WriteLine("-----");
        }
Esempio n. 2
0
        //Custom function to call ShowDialog
        public DialogResult CustomShowDialog(string sFilePath)
        {
            sLoadedFile = sFilePath;
            AutomaticDetection(sFilePath);
            if (ShowDialog() == DialogResult.OK)
            {
                var imgCFG    = new ImageManager.ConversionParameters(sFilePath);
                var folderCFG = new FolderProcessingParams();

                if (CheckBox1.Checked)
                {
                    imgCFG.MipmapSetting      = ImageManager.MipmapSetting.Generate;
                    folderCFG.GenerateMipmaps = true;
                }
                else
                {
                    imgCFG.MipmapSetting      = ImageManager.MipmapSetting.DontGenerate;
                    folderCFG.GenerateMipmaps = false;
                }

                if (CheckBox2.Checked)
                {
                    imgCFG.NormalMapConversion  = ImageManager.NormalMapConversion.ForceNormal;
                    folderCFG.NormalsManagement = 1;
                }
                else
                {
                    imgCFG.NormalMapConversion  = ImageManager.NormalMapConversion.ForceNotNormal;
                    folderCFG.NormalsManagement = 2;
                }
                switch ((Formats)ComboBox1.SelectedIndex)
                {
                case Formats.DXT1:
                    imgCFG.OutputFormat  = ImageManager.OutputFormat.ForceDXT1;
                    folderCFG.Compressed = true;
                    break;

                case Formats.DXT5:
                    imgCFG.OutputFormat  = ImageManager.OutputFormat.ForceDXT5;
                    folderCFG.Compressed = true;
                    break;

                case Formats.R8G8B8:
                    imgCFG.OutputFormat  = ImageManager.OutputFormat.ForceRgb8;
                    folderCFG.Compressed = false;
                    break;

                case Formats.A8R8G8B8:
                    imgCFG.OutputFormat  = ImageManager.OutputFormat.ForceArgb8;
                    folderCFG.Compressed = false;
                    break;
                }
                imgCFG.ResizeSetting = ImageManager.ResizeSetting.AllowResize;

                switch (ComboBox2.SelectedIndex)
                {
                case 0:
                    folderCFG.ResizeRatio = 1;
                    break;

                case 1:
                    folderCFG.ResizeRatio = 0.75;
                    break;

                case 2:
                    folderCFG.ResizeRatio = 0.5;
                    break;

                case 3:
                    folderCFG.ResizeRatio = 0.25;
                    break;

                default:
                    folderCFG.ResizeRatio = 1;
                    break;
                }
                folderCFG.DeleteFilesOnSuccess = CheckBox3.Checked;
                folderCFG.BackupFile           = false;

                if (imgCFG.FileType == ImageManager.FileType.MBM)
                {
                    ImageManager.ConvertMBMtoDDS(imgCFG, folderCFG);
                }
                else
                {
                    ImageManager.ConvertFileToDDS(imgCFG, folderCFG);
                }

                return(DialogResult.OK);
            }

            return(DialogResult.Cancel);
        }