Example #1
0
        public static void Process()
        {
            const string heroesPortrait = @"Heroes of the Storm\Heroes\Portrait\";
            const string heroesLandscape = @"Heroes of the Storm\Heroes\Portrait\";
            const string heroesRound = @"Heroes of the Storm\Heroes\Round\";
            const string heroesBanner = @"Heroes of the Storm\Heroes\Banner\";
            const string talents = @"Heroes of the Storm\Talents\";
            const string ui = @"Heroes of the Storm\UI\";
            string[] directories = { heroesPortrait, heroesLandscape, heroesRound, heroesBanner, talents, ui };
            Helper.BuildDirectoryTree(directories);

            // Get the path of the source
            INIFile ini = new INIFile(Globals.Paths.ConfigurationFile);
            string sourcePath = ini.INIReadValue("Game Paths", "Heroes of the Storm");

            // Get the source
            // string[] filters = { "*portrait*static.dds", "*-unit-*.dds", "*-building-*.dds", "*-ability-*.dds", "*-armor-*.dds", "*-upgrade-*.dds", "*icon-*nobg.dds" };
            string gameData = Path.Combine(sourcePath, @"HeroesData");
            string destinationPath = Path.Combine(Globals.Paths.Assets, "Source", "Heroes of the Storm");

            var cascView = new Process
            {
                StartInfo = new ProcessStartInfo
                {
                    FileName = "CascView.exe",
                    Arguments = $" \"{gameData}\" \"*.dds\" \"{destinationPath}\" /fp",
                    WindowStyle = ProcessWindowStyle.Hidden,
                    UseShellExecute = false,
                    RedirectStandardOutput = true,
                    CreateNoWindow = true
                }
            };
            cascView.Start();
            while (!cascView.StandardOutput.EndOfStream)
            {
                string standardOutputLine = cascView.StandardOutput.ReadLine();
                Console.WriteLine(standardOutputLine);
            }

            // Copy the rest of the source assets
            // Copy jobs take the form { string output path, { string start path, bool recursion flag, string search pattern, string exclude pattern } }
            List<CopyJob> copyJobs = new List<CopyJob>
            {
                new CopyJob(heroesPortrait, Path.Combine(Globals.Paths.Assets, @"Source\Heroes of the Storm"), true, "*portrait_static.dds", null)
            };
            Helper.BatchFileCopy(copyJobs);

            // Rename all the things
            Helper.BatchFileRename("Heroes of the Storm");

            // Scale all the things
            // Scaling jobs take the form { string start path, string search pattern, string exclude pattern }
            List<ScalingJob> scalingJobs = new List<ScalingJob>
            {
                new ScalingJob(heroesPortrait, "*.dds")
            };
            Helper.BatchIMScale(scalingJobs);
        }
Example #2
0
        public static void Process()
        {
            const string heroes = @"Heroes of Newerth\Heroes\";
            const string abilities = @"Heroes of Newerth\Abilities\";
            const string items = @"Heroes of Newerth\Items\";
            string[] directories = { heroes, abilities, items };
            Helper.BuildDirectoryTree(directories);

            // Get the path of the source
            INIFile ini = new INIFile(Globals.Paths.ConfigurationFile);
            string sourcePath = ini.INIReadValue("Game Paths", "Heroes of Newerth");

            // Get the source
            string resourcePath = Path.Combine(sourcePath, @"game\textures.s2z");
            string extractPath = Path.Combine(Globals.Paths.Assets, "Source", "Heroes of Newerth");

            Regex[] filters = {
                new Regex(@"00000000/items/[\w/]*icon*.dds"),
                new Regex(@"00000000/heroes/[\w]*/hero.*.dds"),
                new Regex(@"00000000/heroes/[\w]*/ability.*icon.*.dds"),
                new Regex(@"00000000/heroes/[\w]*/icon.*.dds")
            };

            ZipFile zf = null;
            try
            {
                FileStream fs = File.OpenRead(resourcePath);
                zf = new ZipFile(fs);

                foreach (ZipEntry zipEntry in zf)
                {
                    string entryFileName = zipEntry.Name;
                    foreach (var filter in filters)
                    {
                        if (filter.IsMatch(entryFileName))
                        {
                            Console.WriteLine("Extracting {0}", entryFileName);
                            byte[] buffer = new byte[4096];
                            Stream zipStream = zf.GetInputStream(zipEntry);

                            string fullZipToPath = Path.Combine(extractPath, entryFileName);
                            string directoryName = Path.GetDirectoryName(fullZipToPath);
                            if (!string.IsNullOrEmpty(directoryName))
                            {
                                Directory.CreateDirectory(directoryName);
                            }

                            using (FileStream streamWriter = File.Create(fullZipToPath))
                            {
                                StreamUtils.Copy(zipStream, streamWriter, buffer);
                            }
                        }
                    }
                }
            }
            finally
            {
                if (zf != null)
                {
                    zf.IsStreamOwner = true;
                    zf.Close();
                }
            }

            //
            // Make the filenames somewhat sane
            foreach (string textureFile in Directory.GetFiles(Path.Combine(Globals.Paths.Assets, "Source", "Heroes of Newerth"), "*.dds", SearchOption.AllDirectories).ToList())
            {
                int counter = 0;
                List<string> pathLeaves = new List<string>();

                var directoryName = Path.GetDirectoryName(textureFile);
                if (directoryName != null)
                {
                    string[] leaves = directoryName.Split('\\');
                    Array.Reverse(leaves);

                    do
                    {
                        counter++;
                        string leaf = leaves[counter - 1];
                        pathLeaves.Add(leaf);
                    } while (!pathLeaves.Contains("heroes") && !pathLeaves.Contains("items"));
                }

                pathLeaves = pathLeaves.Where(item => !item.Contains("heroes") && !item.Contains("items") && !item.Contains("icons") && !item.Contains("icon")).ToList();
                pathLeaves.Reverse();

                string leafString = string.Join("_", pathLeaves.ToArray()).Replace(' ','_').ToLower();
                string newName = leafString + Path.GetExtension(textureFile);

                if (!string.Equals(Path.GetFileNameWithoutExtension(textureFile), "icon", StringComparison.OrdinalIgnoreCase))
                {
                    newName = leafString + '_' + Path.GetFileName(textureFile);
                }

                Console.WriteLine("Renaming {0} to {1}", textureFile, newName);
                File.Move(textureFile, Path.Combine(Path.GetDirectoryName(textureFile), newName));
            }

            // Copy the rest of the source assets
            // Copy jobs take the form { output path = string, { string start path, bool recursion flag, string search pattern, string exclude pattern } }
            string destination = Path.Combine(Globals.Paths.Assets, "Source" ,"Heroes of Newerth");
            List<CopyJob> copyJobs = new List<CopyJob>
            {
                new CopyJob(abilities, Path.Combine(destination, @"00000000\heroes\"), true, "*ability*.dds", null),
                new CopyJob(heroes, Path.Combine(destination, @"00000000\heroes\"), true, "*.dds", "*ability*.dds"),
                new CopyJob(items, Path.Combine(destination, @"00000000\items\"), true, "*.dds", null)
            };
            Helper.BatchFileCopy(copyJobs);

            // Rename all the things
            Helper.BatchFileRename("Heroes of Newerth");

            // Scale all the things
            // Scaling jobs take the form { string start path, string search pattern, string exclude pattern }
            List<ScalingJob> scalingJobs = new List<ScalingJob>
            {
                new ScalingJob(heroes, "*.dds"),
                new ScalingJob(abilities, "*.dds"),
                new ScalingJob(items, "*.dds")
            };
            Helper.BatchIMScale(scalingJobs);
        }
Example #3
0
        public static void Process()
        {
            const string heroesMini = @"Dota 2\Heroes\Mini\";
            const string heroesLandscape = @"Dota 2\Heroes\Landscape\";
            const string heroesPortrait = @"Dota 2\Heroes\Portrait\";
            const string items = @"Dota 2\Items\";
            const string spells = @"Dota 2\Spells\";
            string[] directories = { heroesMini, heroesLandscape, heroesPortrait, items, spells };
            Helper.BuildDirectoryTree(directories);

            // Get the path of the source
            INIFile ini = new INIFile(Globals.Paths.ConfigurationFile);
            string sourcePath = ini.INIReadValue("Game Paths", "Dota 2");

            string vpkPath = Path.Combine(sourcePath, @"dota\pak01_dir.vpk");
            const string archivePrepend = @"resource/flash3/images/{0}";

            // Get the source
            string[] valvePackages = {"heroes", @"heroes\selection", "miniheroes", "spellicons", "items"};
            foreach(string valvePackage in valvePackages)
            {
                var valveArchive = new VpkArchive();
                valveArchive.Load(vpkPath);
                foreach (var directory in valveArchive.Directories)
                {
                    string rootDirectory = string.Format(archivePrepend, valvePackage);
                    if (directory.ToString().Contains(rootDirectory)) {
                        foreach (var entry in directory.Entries)
                        {
                            string destPath = Path.Combine(Globals.Paths.Assets, @"Source\Dota 2", entry.ToString().Replace("resource/flash3/images/",""));
                            FileInfo destInfo = new FileInfo(destPath);
                            string destDirectory = destInfo.Directory.ToString();
                            if (!Directory.Exists(destDirectory))
                            {
                                Directory.CreateDirectory(destDirectory);
                                Console.WriteLine("Creating directory {0}", destDirectory);
                            }
                            if (Directory.Exists(destDirectory)) {
                                Console.WriteLine("Extracting {0}", destPath);
                                File.WriteAllBytes(destPath, entry.Data);
                            }
                        }
                    }
                }
            }

            // Copy the rest of the source assets
            // Copy jobs take the form { string output path, { string start path, bool recursion flag, string search pattern, string exclude pattern } }
            List<CopyJob> copyJobs = new List<CopyJob>
            {
                new CopyJob(heroesPortrait, Path.Combine(Globals.Paths.Assets, @"Source\Dota 2\heroes\selection"), true, "npc_dota_hero_*.png", null),
                new CopyJob(heroesLandscape, Path.Combine(Globals.Paths.Assets, @"Source\Dota 2\heroes"), false, "*.png", null),
                new CopyJob(heroesMini, Path.Combine(Globals.Paths.Assets, @"Source\Dota 2\miniheroes"), true, "*.png", null),
                new CopyJob(spells, Path.Combine(Globals.Paths.Assets, @"Source\Dota 2\spellicons"), true, "*.png", null),
                new CopyJob(items, Path.Combine(Globals.Paths.Assets, @"Source\Dota 2\items"), true, "*.png", null)
            };
            Helper.BatchFileCopy(copyJobs);

            // Rename all the things
            Helper.BatchFileRename("Dota 2");

            // Scale all the things
            // Scaling jobs take the form { string start path, string search pattern, string exclude pattern }
            List<ScalingJob> scalingJobs = new List<ScalingJob>
            {
                new ScalingJob(heroesLandscape, "*.png"),
                new ScalingJob(heroesMini, "*.png"),
                new ScalingJob(heroesPortrait, "*.png"),
                new ScalingJob(items, "*.png"),
                new ScalingJob(spells, "*.png")
            };
            Helper.BatchIMScale(scalingJobs);
        }
Example #4
0
        public static void Process()
        {
            const string championsSquare = @"League of Legends\Champions\Square\";
            const string championsPortrait = @"League of Legends\Champions\Portrait\";
            const string championsLandscape = @"League of Legends\Champions\Landscape\";
            const string abilities = @"League of Legends\Abilities\";
            const string items = @"League of Legends\Items\";
            const string spells = @"League of Legends\Spells\";
            const string masteries = @"League of Legends\Masteries\";
            const string runes = @"League of Legends\Runes\";
            const string wards = @"League of Legends\Wards\";
            string[] directories =
            {
                championsSquare, championsPortrait, championsLandscape, abilities, items, spells,
                masteries, runes, wards
            };
            Helper.BuildDirectoryTree(directories);

            // Get the path of the source
            var ini = new INIFile(Globals.Paths.ConfigurationFile);
            var sourcePath = ini.INIReadValue("Game Paths", "League of Legends");

            // Get the source
            string[] neededSwFs = {"ImagePack_spells.swf", "ImagePack_masteryIcons.swf", "ImagePack_items.swf"};
            foreach (
                var neededSwf in
                    Directory.GetFiles(sourcePath, "ImagePack_*.swf", SearchOption.AllDirectories)
                        .Where(f => neededSwFs.Contains(Path.GetFileName(f), StringComparer.OrdinalIgnoreCase))
                        .ToList())
            {
                File.Copy(neededSwf,
                    Path.Combine(Globals.Paths.Assets, "Source", "League of Legends", Path.GetFileName(neededSwf)), true);
                Console.WriteLine("Copying {0}", neededSwf);
            }

            // Extract the SWFs
            foreach (
                var swfFile in
                    Directory.GetFiles(Path.Combine(Globals.Paths.Assets, "Source", "League of Legends"), "*.swf",
                        SearchOption.AllDirectories).ToList())
            {
                string outputPath = null;
                switch (Path.GetFileName(swfFile))
                {
                    case "ImagePack_items.swf":
                        outputPath = items;
                        break;
                    case "ImagePack_spells.swf":
                        outputPath = spells;
                        break;
                    case "ImagePack_masteryIcons.swf":
                        outputPath = masteries;
                        break;
                    default:
                        break;
                }

                var swf = new SwfFile(swfFile);
                if (outputPath != null) swf.ExtractImages(Path.Combine(Globals.Paths.Assets, outputPath, "Source"));
            }

            // Copy the rest of the source assets
            // Copy jobs take the form { output path = string, { string start path, bool recursion flag, string search pattern, string exclude pattern } }
            const string sourceReleases = @"RADS\projects\lol_air_client\releases";
            var sourceVersion = Directory.GetDirectories(Path.Combine(sourcePath, sourceReleases))[0];
            var sourceAssets = Path.Combine(sourcePath, sourceReleases, sourceVersion, @"deploy\assets");

            var copyJobs = new List<CopyJob>
            {
                new CopyJob(championsPortrait, Path.Combine(sourceAssets, @"images\champions"), false, "*_0.jpg",
                    "*_S*_*.jpg"),
                new CopyJob(championsLandscape, Path.Combine(sourceAssets, @"images\champions"), false, "*_Splash_0.jpg",
                    null),
                new CopyJob(championsSquare, Path.Combine(sourceAssets, @"images\champions"), false, "*_Square_0.png",
                    null),
                new CopyJob(abilities, Path.Combine(sourceAssets, @"images\abilities"), false, "*.png", null),
                new CopyJob(runes, Path.Combine(sourceAssets, @"images\runes"), true, "*.png", null),
                new CopyJob(wards, Path.Combine(sourceAssets, @"images\misc\wards"), false, "wardImage_*.png", null)
            };
            Helper.BatchFileCopy(copyJobs);

            // Rename all the things
            Helper.BatchFileRename("League of Legends");

            // Scale all the things
            // Scaling jobs take the form { string start path, string search pattern, string exclude pattern }
            var scalingJobs = new List<ScalingJob>
            {
                new ScalingJob(championsLandscape, "*.jpg"),
                new ScalingJob(championsPortrait, "*.jpg"),
                new ScalingJob(championsSquare, "*.png"),
                new ScalingJob(abilities, "*.png"),
                new ScalingJob(items, "*.png"),
                new ScalingJob(spells, "*.png"),
                new ScalingJob(masteries, "*.png"),
                new ScalingJob(runes, "*.png"),
                new ScalingJob(wards, "*.png")
            };
            Helper.BatchIMScale(scalingJobs);
        }
Example #5
0
        public static void Process()
        {
            const string abilities = @"Dawngate\Abilities\";
            const string items = @"Dawngate\Items\";
            const string shapersPortrait = @"Dawngate\Shapers\Portrait\";
            const string shapersSquare = @"Dawngate\Shapers\Square\";
            const string sparks = @"Dawngate\Sparks\";
            const string spells = @"Dawngate\Spells\";
            const string spiritstones = @"Dawngate\Spiritstones\";
            string[] directories = { abilities, items, shapersPortrait, shapersSquare, sparks, spells, spiritstones };
            Helper.BuildDirectoryTree(directories);

            // Get the path of the source
            INIFile ini = new INIFile(Globals.Paths.ConfigurationFile);
            string sourcePath = ini.INIReadValue("Game Paths", "Dawngate");

            // Get the source
            string quickBmsSnapFile = Path.Combine(Globals.Paths.Home, @"lib\quickbms_snap.txt");
            string[] sourcePackages = Directory.GetFiles(Path.Combine(sourcePath, "data"), "*.snap", SearchOption.AllDirectories);

            foreach(string sourcePackage in sourcePackages)
            {
                var quickBms = new Process
                {
                    StartInfo = new ProcessStartInfo {
                        FileName = "quickbms.exe",
                        Arguments =
                            $" -o -. -Y -f \"*_full.dds,*_portrait.dds,*_purchase.dds\" \"{quickBmsSnapFile}\" \"{sourcePackage}\" \"{Path.Combine(Globals.Paths.Assets, @"Source\Dawngate")}\"",
                        WindowStyle = ProcessWindowStyle.Hidden,
                        UseShellExecute = false,
                        RedirectStandardOutput = true,
                        CreateNoWindow = true
                    }
                };
                quickBms.Start();
                while (!quickBms.StandardOutput.EndOfStream)
                {
                    string standardOutputLine = quickBms.StandardOutput.ReadLine();
                    Console.WriteLine(standardOutputLine);
                }
            }
            var stragglingQuickBms = new Process
            {
                StartInfo = new ProcessStartInfo {
                    FileName = "quickbms.exe",
                    Arguments =
                        $" -o -. -Y -f \"*advanced_*.dds,*basic_*.dds,*legendary_*.dds,*consumable_*.dds,*Spell_*.dds,*inventory_perk_shape_*.dds,*perk_gem_*.dds\" \"{quickBmsSnapFile}\" \"{Path.Combine(sourcePath, @"Data\UI_Icons.snap")}\" \"{Path.Combine(Globals.Paths.Assets, @"Source\Dawngate")}\"",
                    WindowStyle = ProcessWindowStyle.Hidden,
                    UseShellExecute = false,
                    RedirectStandardOutput = true,
                    CreateNoWindow = true
                }
            };
            stragglingQuickBms.Start();
            while (!stragglingQuickBms.StandardOutput.EndOfStream)
            {
                string line = stragglingQuickBms.StandardOutput.ReadLine();
                Console.WriteLine(line);
            }

            // Copy the rest of the source assets
            // Copy jobs take the form { output path = string, { string start path, bool recursion flag, string search pattern, string exclude pattern } }
            List<CopyJob> copyJobs = new List<CopyJob>
            {
                new CopyJob(abilities, Path.Combine(Globals.Paths.Assets, @"Source\Dawngate\heroes"), true, "*_full.dds", null),
                new CopyJob(items, Path.Combine(Globals.Paths.Assets, @"Source\Dawngate\UI\Icons\ShopIcons\textures"), true, "*.dds", "Spell_*.dds"),
                new CopyJob(shapersPortrait, Path.Combine(Globals.Paths.Assets, @"Source\Dawngate\heroes"), true, "*_Purchase.dds", "*_*_Purchase.dds"),
                new CopyJob(shapersSquare, Path.Combine(Globals.Paths.Assets, @"Source\Dawngate\heroes"), true, "*_Portrait.dds", null),
                new CopyJob(sparks, Path.Combine(Globals.Paths.Assets, @"Source\Dawngate\UI\Icons\GemIcons\textures"), true, "perk_gem_*.dds", null),
                new CopyJob(spells, Path.Combine(Globals.Paths.Assets, @"Source\Dawngate\UI\Icons\ShopIcons\textures"), true, "Spell_*.dds", null),
                new CopyJob(spiritstones, Path.Combine(Globals.Paths.Assets, @"Source\Dawngate\UI\Icons\ShapeIcons\textures"), true, "inventory_perk_shape_*.dds", null)
            };
            Helper.BatchFileCopy(copyJobs);

            // Rename all the things
            Helper.BatchFileRename("Dawngate");

            // Scale all the things
            // Scaling jobs take the form { string start path, string search pattern, string exclude pattern }
            List<ScalingJob> scalingJobs = new List<ScalingJob>
            {
                new ScalingJob(abilities),
                new ScalingJob(items),
                new ScalingJob(shapersPortrait),
                new ScalingJob(shapersSquare),
                new ScalingJob(sparks),
                new ScalingJob(spells),
                new ScalingJob(spiritstones)
            };
            Helper.BatchIMScale(scalingJobs);
        }
Example #6
0
 /// <summary>
 /// Validates and stores the installation paths for games to be processed
 /// </summary>
 /// <param name="gameTitle">The name of the game to validate</param>
 public static void ValidateINI(string gameTitle)
 {
     const string iniSection = "Game Paths";
     GameInfo game = GameInfo.GetGamebyProp(gameTitle);
     INIFile ini = new INIFile(Globals.Paths.ConfigurationFile);
     if (!File.Exists(Globals.Paths.ConfigurationFile))
     {
         InitINI();
     }
     if (!Directory.Exists(ini.INIReadValue(iniSection, game.Title)))
     {
         Console.WriteLine("Finding {0}", game.Title);
         foreach (string drive in Globals.Paths.Drives)
         {
             Parallel.ForEach(EnumerateFiles(drive, game.Binary, SearchOption.AllDirectories), matchedFile =>
             {
                 Console.WriteLine("Found {0}", matchedFile);
                 string leafPath = matchedFile;
                 for (int i = 0; i < game.Leaf; ++i)
                 {
                     leafPath = Directory.GetParent(leafPath).ToString();
                 }
                 ini.INIWriteValue(iniSection, game.Title, leafPath + @"\");
                 Console.WriteLine("Storing {0}", leafPath + @"\");
             });
         }
     }
 }
Example #7
0
        /// <summary>
        /// Processes scaling jobs to scale image assets
        /// </summary>
        /// <param name="scalingJobs">The jobs to be processed</param>
        public static void BatchIMScale(List<ScalingJob> scalingJobs)
        {
            var options = new Options();
            if (Parser.Default.ParseArgumentsStrict(Globals.Paths.Arguments, options) && options.Scale)
            {
                foreach (var scalingJob in scalingJobs)
                {
                    string[] filePathInfo = (scalingJob.Path).Split('\\');
                    string game = filePathInfo[0];
                    string category = filePathInfo[1];
                    if (filePathInfo.Length > 3)
                    {
                        category += @"\" + filePathInfo[2];
                    }

                    // Get the images to scale
                    string[] inputImages;
                    string startPath = Path.Combine(Globals.Paths.Assets, scalingJob.Path, "Source");
                    if (string.IsNullOrEmpty(scalingJob.ExcludePattern))
                    {
                        inputImages = Directory.GetFiles(startPath, scalingJob.SearchPattern, SearchOption.AllDirectories);
                    }
                    else
                    {
                        string excludePattern = scalingJob.ExcludePattern;
                        Regex r = new Regex($"^{excludePattern.Replace("*", ".*")}$", RegexOptions.IgnoreCase);
                        inputImages = (Directory.GetFiles(startPath, scalingJob.SearchPattern, SearchOption.AllDirectories).Where(f => !r.IsMatch(Path.GetFileName(f)))).ToArray();
                    }

                    //Get the desired image sizes
                    if (File.Exists(Globals.Paths.ConfigurationFile))
                    {
                        INIFile ini = new INIFile(Globals.Paths.ConfigurationFile);
                        string[] outputDimensions = (ini.INIReadValue(game, category).Split(','));

                        foreach (string outputDimension in outputDimensions)
                        {
                            //Create a destination directory
                            string outputWidth = outputDimension.Split('x')[0];
                            Directory.CreateDirectory(Path.Combine(Globals.Paths.Assets, scalingJob.Path, outputWidth));
                            foreach (string inputImage in inputImages)
                            {
                                // Get the extension so we only have to use IM identify when necessary
                                string imageExtension = Path.GetExtension(inputImage);
                                string inputDimensions = null;
                                if (imageExtension == ".dds" || imageExtension == ".tga")
                                {
                                    var imageMagickIdentify = new Process
                                    {
                                        StartInfo = new ProcessStartInfo
                                        {
                                            FileName = "identify.exe",
                                            Arguments = $" -format %wx%h {inputImage}",
                                            WindowStyle = ProcessWindowStyle.Hidden,
                                            UseShellExecute = false,
                                            RedirectStandardOutput = true,
                                            CreateNoWindow = true
                                        }
                                    };
                                    imageMagickIdentify.Start();
                                    inputDimensions = imageMagickIdentify.StandardOutput.ReadLine();
                                }
                                else
                                {
                                    Bitmap bitmap = new Bitmap(inputImage);
                                    inputDimensions = $"{bitmap.Width}x{bitmap.Height}";
                                    bitmap.Dispose();
                                }
                                string outputName = $"{Path.GetFileNameWithoutExtension(inputImage)}.png";
                                string destinationPath = Path.Combine(Globals.Paths.Assets, scalingJob.Path, outputWidth, outputName);

                                // Only convert when the sizes are different otherwise just copy
                                if (inputDimensions != outputDimension)
                                {
                                    string imageMagickSettings = null;

                                    // Take care of the numerous cases
                                    switch (scalingJob.Path)
                                    {
                                        // Dota 2 Items
                                        case @"Dota 2\Items\":
                                            imageMagickSettings += "-gravity west -crop ";
                                            switch (inputDimensions)
                                            {
                                                case "128x64":
                                                    imageMagickSettings += "87x64+0+0";
                                                    break;
                                                case "124x62":
                                                    imageMagickSettings += "86x62+0+0";
                                                    break;
                                                case "128x128":
                                                    imageMagickSettings += "128x128+0+0";
                                                    break;
                                                case "124x64":
                                                    imageMagickSettings += "88x64+0+0";
                                                    break;
                                            }
                                            imageMagickSettings += " +repage";
                                            break;
                                        // Smite Abilities
                                        case @"Smite\Abilities\":
                                            imageMagickSettings += "-alpha off";
                                            switch (inputDimensions)
                                            {
                                                // Ability Banners
                                                case "256x128":
                                                    imageMagickSettings += "-gravity center -crop 128x128+0+0 +repage";
                                                    break;
                                                default:
                                                    break;
                                            }
                                            break;
                                        // Smite Gods
                                        case @"Smite\Gods\Portrait\":
                                            imageMagickSettings += "-alpha off -gravity west -crop 388x512+0+0 +repage";
                                            break;
                                        default:
                                            // StarCraft II Upgrades and Abilities
                                            if ((scalingJob.Path == @"StarCraft II\Upgrades\") || (scalingJob.Path == @"StarCraft II\Abilities\"))
                                            {
                                                imageMagickSettings += "-shave 7x7 +repage";
                                            }
                                            // Heroes of Newerth
                                            if (scalingJob.Path.StartsWith("Heroes of Newerth"))
                                            {
                                                imageMagickSettings += "-flip";
                                            }
                                            break;
                                    }
                                    //
                                    Console.WriteLine("Scaling {0} from {1} to {2}", Path.GetFileName(inputImage), inputDimensions, outputDimension);
                                    var imageMagickMagick = new Process
                                    {
                                        StartInfo = new ProcessStartInfo
                                        {
                                            FileName = "magick.exe",
                                            Arguments =
                                                $" \"{inputImage}\" -colorspace RGB -size \"{inputDimensions}\" +sigmoidal-contrast 11.6933 -define filter:filter=Sinc -define filter:window=Jinc -define filter:lobes=3 {imageMagickSettings} -resize \"{outputDimension}\"! -sigmoidal-contrast 11.6933 -colorspace sRGB \"{destinationPath}\"",
                                            WindowStyle = ProcessWindowStyle.Hidden,
                                            UseShellExecute = false,
                                            RedirectStandardOutput = false,
                                            CreateNoWindow = true
                                        }
                                    };
                                    imageMagickMagick.Start();
                                }
                                else
                                {
                                    File.Copy(inputImage, destinationPath, true);
                                    Console.WriteLine("Copying {0} to {1}", Path.GetFileName(inputImage), outputDimension);
                                }
                            }
                        }
                    }
                }
            }
        }
Example #8
0
        public static void Process()
        {
            const string unitsPortrait = @"StarCraft II\Units\Portrait\";
            const string unitsSquare = @"StarCraft II\Units\Square\";
            const string buildings = @"StarCraft II\Buildings\";
            const string abilities = @"StarCraft II\Abilities\";
            const string upgrades = @"StarCraft II\Upgrades\";
            const string ui = @"StarCraft II\UI\";
            string[] directories = { unitsPortrait, unitsSquare, buildings, abilities, upgrades, ui };
            Helper.BuildDirectoryTree(directories);

            // Get the path of the source
            INIFile ini = new INIFile(Globals.Paths.ConfigurationFile);
            string sourcePath = ini.INIReadValue("Game Paths", "StarCraft II");

            // Get the source
            string[] filters = { "*portrait*static.dds", "*-unit-*.dds", "*-building-*.dds", "*-ability-*.dds", "*-armor-*.dds", "*-upgrade-*.dds", "*icon-*nobg.dds" };
            string[] packages = Directory.GetFiles(Path.Combine(sourcePath, @"Mods"), "Base.SC2Assets", SearchOption.AllDirectories);
            foreach(string package in packages)
            {
                string pathLeaf = (Directory.GetParent(package).Name).Replace(".SC2Mod", "");
                string destination = Path.Combine(Globals.Paths.Assets,"Source","StarCraft II",pathLeaf);
                foreach (string filter in filters)
                {
                    var mpqEditor = new Process
                    {
                        StartInfo = new ProcessStartInfo
                        {
                            FileName = "MPQEditor.exe",
                            Arguments = $" e \"{package}\" \"{filter}\" \"{destination}\" /fp",
                            WindowStyle = ProcessWindowStyle.Hidden,
                            UseShellExecute = false,
                            RedirectStandardOutput = true,
                            CreateNoWindow = true
                        }
                    };
                    mpqEditor.Start();
                    while (!mpqEditor.StandardOutput.EndOfStream)
                    {
                        string standardOutputLine = mpqEditor.StandardOutput.ReadLine();
                        Console.WriteLine(standardOutputLine);
                    }
                }
            }

            // Copy the rest of the source assets
            // Copy jobs take the form { string output path, { string start path, bool recursion flag, string search pattern, string exclude pattern } }
            List<CopyJob> copyJobs = new List<CopyJob>
            {
                new CopyJob(unitsPortrait, Path.Combine(Globals.Paths.Assets, @"Source\StarCraft II"), true, "*portrait_static.dds", null),
                new CopyJob(unitsSquare, Path.Combine(Globals.Paths.Assets, @"Source\StarCraft II"), true, "btn-unit-*.dds", null),
                new CopyJob(buildings, Path.Combine(Globals.Paths.Assets, @"Source\StarCraft II"), true, "btn-building-*.dds", null),
                new CopyJob(abilities, Path.Combine(Globals.Paths.Assets, @"Source\StarCraft II"), true, "btn-ability-*.dds", null),
                new CopyJob(abilities, Path.Combine(Globals.Paths.Assets, @"Source\StarCraft II"), true, "btn-armor-*.dds", null),
                new CopyJob(upgrades, Path.Combine(Globals.Paths.Assets, @"Source\StarCraft II"), true, "btn-upgrade-*.dds", null),
                new CopyJob(ui, Path.Combine(Globals.Paths.Assets, @"Source\StarCraft II"), true, "icon-*-nobg.dds", null),
                new CopyJob(ui, Path.Combine(Globals.Paths.Assets, @"Source\StarCraft II"), true, "icon-supply*_nobg.dds", null)
            };
            Helper.BatchFileCopy(copyJobs);

            // Rename all the things
            Helper.BatchFileRename("StarCraft II");

            // Scale all the things
            // Scaling jobs take the form { string start path, string search pattern, string exclude pattern }
            List<ScalingJob> scalingJobs = new List<ScalingJob>
            {
                new ScalingJob(unitsPortrait, "*.dds"),
                new ScalingJob(unitsSquare, "*.dds"),
                new ScalingJob(buildings, "*.dds"),
                new ScalingJob(abilities, "*.dds"),
                new ScalingJob(upgrades, "*.dds"),
                new ScalingJob(ui, "*.dds")
            };
            Helper.BatchIMScale(scalingJobs);
        }
Example #9
0
        public static void Process()
        {
            const string abilities = @"Smite\Abilities\";
            const string godsPortrait = @"Smite\Gods\Portrait\";
            const string godsSquare = @"Smite\Gods\Square";
            const string items = @"Smite\Items\";
            string[] directories = { abilities, items, godsPortrait, godsSquare };

            Helper.BuildDirectoryTree(directories);

            // Get the path of the source
            var ini = new INIFile(Globals.Paths.ConfigurationFile);
            string sourcePath = ini.INIReadValue("Game Paths", "Smite");

            // Get the source
            string[] smitePackages = { "GodSkins_Cards.upk", "GodSkins_Portraits_and_Icons.upk", "Icons.upk", "Portraits.upk" };
            foreach (string packageName in smitePackages)
            {
                string package = Path.Combine(sourcePath, @"BattleGame\CookedPC\GUI\Icons", packageName);

                var umodel = new Process
                {
                    StartInfo = new ProcessStartInfo {
                        FileName = "umodel.exe",
                        Arguments =
                            $" -export -uncook -groups -nomesh -noanim -nostat -out=\"{Path.Combine(Globals.Paths.Assets, @"Source\Smite")}\" \"{Path.GetFileName(package)}\" -path=\"{Path.Combine(sourcePath, @"BattleGame\CookedPC\GUI\Icons")}\"",
                        WindowStyle = ProcessWindowStyle.Hidden,
                        UseShellExecute = false,
                        RedirectStandardOutput = true,
                        CreateNoWindow = true
                    }
                };
                umodel.Start();
                while (!umodel.StandardOutput.EndOfStream)
                {
                    string standardOutputLine = umodel.StandardOutput.ReadLine();
                    Console.WriteLine(standardOutputLine);
                }
            }

            // Copy the rest of the source assets
            // Copy jobs take the form { string output path, { string start path, bool recursion flag, string search pattern, string exclude pattern } }
            List<CopyJob> copyJobs = new List<CopyJob>
            {
                new CopyJob(abilities, Path.Combine(Globals.Paths.Assets, @"Source\Smite\icons\abilities"), true, "*.tga", null),
                new CopyJob(abilities, Path.Combine(Globals.Paths.Assets, @"Source\Smite\icons\abilitybanners"), true, "Icons_Agni_A01.tga", null),
                new CopyJob(abilities, Path.Combine(Globals.Paths.Assets, @"Source\Smite\icons\abilitybanners"), true, "Icons_Ymir_GlacialStrike.tga", null),
                new CopyJob(godsPortrait, Path.Combine(Globals.Paths.Assets, @"Source\Smite\GodSkins_Cards"), false, "*_Default_Card.tga", null),
                new CopyJob(godsSquare, Path.Combine(Globals.Paths.Assets, @"Source\Smite\GodSkins_Portraits_and_Icons"), true, "*_Default_Icon.tga", null)
                // new CopyJob(items, Path.Combine(Globals.Paths.Assets, @"Source\Smite\icons\items_delete"), true, "*.tga", null)
            };
            Helper.BatchFileCopy(copyJobs);

            // Rename all the things
            Helper.BatchFileRename("Smite");

            // Scale all the things
            // Scaling jobs take the form { string start path, string search pattern, string exclude pattern }
            List<ScalingJob> scalingJobs = new List<ScalingJob>
            {
                new ScalingJob(abilities, "agni-q.tga", null),
                new ScalingJob(abilities, "ymir-w.tga", null),
                new ScalingJob(abilities, "*.tga", "agni-q.tga"),
                new ScalingJob(abilities, "*.tga", "ymir-w.tga"),
                new ScalingJob(godsPortrait, "*.tga", null),
                new ScalingJob(godsSquare, "*.tga", null),
                new ScalingJob(items, "*.tga", null)
            };
            Helper.BatchIMScale(scalingJobs);
        }