コード例 #1
0
            //return a conversion parameter for a single file, according to modsExceptions.txt
            public ImageManager.ConversionParameters GetConversionParameters(string sFilePath, FolderProcessingParams folderParams)
            {
                //resfresh counts
                var extension = Path.GetExtension(sFilePath);

                switch (extension)
                {
                case ".mbm":
                    Count_MBM += 1;
                    break;

                case ".tga":
                    Count_TGA += 1;
                    break;

                case ".png":
                    Count_PNG += 1;
                    break;
                }
                //resfresh parameters
                var cpRet = new ImageManager.ConversionParameters(sFilePath);

                if (folderParams.IgnoreExceptions)
                {
                    //normals flag
                    switch (folderParams.NormalsManagement)
                    {
                    case 0:
                        cpRet.NormalMapConversion = ImageManager.NormalMapConversion.Automatic;
                        break;

                    case 1:
                        cpRet.NormalMapConversion = ImageManager.NormalMapConversion.ForceNormal;
                        Count_ForceNormal        += 1;
                        break;

                    case 2:
                        cpRet.NormalMapConversion = ImageManager.NormalMapConversion.ForceNotNormal;
                        Count_ForceNotNormal     += 1;
                        break;
                    }
                    //mipmaps flag
                    cpRet.MipmapSetting = folderParams.GenerateMipmaps ? ImageManager.MipmapSetting.Generate : ImageManager.MipmapSetting.DontGenerate;
                    cpRet.ResizeSetting = ImageManager.ResizeSetting.AllowResize;
                }
                else
                {
                    //normals flag
                    var bB = false;
                    for (var i = 0; i <= forceNormalList.Count - 1; i++)
                    {
                        if (sFilePath.Contains(forceNormalList[i]))
                        {
                            cpRet.NormalMapConversion = ImageManager.NormalMapConversion.ForceNormal;
                            Count_ForceNormal        += 1;
                            i  = forceNormalList.Count - 1;
                            bB = true;
                        }
                    }
                    if (!bB)
                    {
                        for (var i = 0; i <= forceNotNormalList.Count - 1; i++)
                        {
                            if (sFilePath.Contains(forceNotNormalList[i]))
                            {
                                cpRet.NormalMapConversion = ImageManager.NormalMapConversion.ForceNotNormal;
                                Count_ForceNotNormal     += 1;
                                i  = forceNotNormalList.Count - 1;
                                bB = true;
                            }
                        }
                    }
                    if (!bB)
                    {
                        switch (folderParams.NormalsManagement)
                        {
                        case 0:
                            cpRet.NormalMapConversion = ImageManager.NormalMapConversion.Automatic;
                            break;

                        case 1:
                            cpRet.NormalMapConversion = ImageManager.NormalMapConversion.ForceNormal;
                            Count_ForceNormal        += 1;
                            break;

                        case 2:
                            cpRet.NormalMapConversion = ImageManager.NormalMapConversion.ForceNotNormal;
                            Count_ForceNotNormal     += 1;
                            break;
                        }
                    }
                    //no mipmaps flag
                    bB = false;
                    for (var i = 0; i <= noMipmapList.Count - 1; i++)
                    {
                        if (sFilePath.Contains(noMipmapList[i]))
                        {
                            cpRet.MipmapSetting = ImageManager.MipmapSetting.DontGenerate;
                            Count_NoMipmaps    += 1;
                            i  = noMipmapList.Count - 1;
                            bB = true;
                        }
                    }
                    if (!bB)
                    {
                        if (folderParams.GenerateMipmaps)
                        {
                            cpRet.MipmapSetting = ImageManager.MipmapSetting.Generate;
                        }
                        else
                        {
                            cpRet.MipmapSetting = ImageManager.MipmapSetting.DontGenerate;
                            Count_NoMipmaps    += 1;
                        }
                    }
                    //resize flag
                    cpRet.ResizeSetting = ImageManager.ResizeSetting.AllowResize;
                    for (var i = 0; i <= noResizeList.Count - 1; i++)
                    {
                        if (sFilePath.Contains(noResizeList[i]))
                        {
                            cpRet.ResizeSetting = ImageManager.ResizeSetting.DontAllowResize;
                            Count_NoResize     += 1;
                        }
                    }
                }
                return(cpRet);
            }
コード例 #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);
        }