From 472b215975b51c97683c58d8d577b3b68b785afe Mon Sep 17 00:00:00 2001 From: MouriNaruto Date: Sat, 22 Jun 2024 12:27:31 +0800 Subject: [PATCH] Implemeent NanaZip.ProjectAssetsGenerator project. --- NanaZip.ProjectAssetsGenerator/Program.cs | 152 +++++++++++++++++++++- 1 file changed, 151 insertions(+), 1 deletion(-) diff --git a/NanaZip.ProjectAssetsGenerator/Program.cs b/NanaZip.ProjectAssetsGenerator/Program.cs index c7d71ec7b..5e26f2721 100644 --- a/NanaZip.ProjectAssetsGenerator/Program.cs +++ b/NanaZip.ProjectAssetsGenerator/Program.cs @@ -1,9 +1,159 @@ -namespace NanaZip.ProjectAssetsGenerator +using ImageMagick; +using Mile.Project.Helpers; +using System.Collections.Concurrent; + +namespace NanaZip.ProjectAssetsGenerator { internal class Program { + static string RepositoryRoot = GitRepository.GetRootPath(); + static void Main(string[] args) { + { + string SourcePath = RepositoryRoot + @"\Assets\OriginalAssets\NanaZip"; + + string OutputPath = RepositoryRoot + @"\Assets\PackageAssets"; + + ConcurrentDictionary StandardSources = + new ConcurrentDictionary(); + ConcurrentDictionary ContrastBlackSources = + new ConcurrentDictionary(); + ConcurrentDictionary ContrastWhiteSources = + new ConcurrentDictionary(); + + ConcurrentDictionary ArchiveFileSources = + new ConcurrentDictionary(); + + ConcurrentDictionary SfxStubSources = + new ConcurrentDictionary(); + + foreach (var AssetSize in ProjectAssetsUtilities.AssetSizes) + { + StandardSources[AssetSize] = new MagickImage(string.Format( + @"{0}\{1}\{1}_{2}.png", + SourcePath, + "Standard", + AssetSize)); + ContrastBlackSources[AssetSize] = new MagickImage(string.Format( + @"{0}\{1}\{1}_{2}.png", + SourcePath, + "ContrastBlack", + AssetSize)); + ContrastWhiteSources[AssetSize] = new MagickImage(string.Format( + @"{0}\{1}\{1}_{2}.png", + SourcePath, + "ContrastWhite", + AssetSize)); + + ArchiveFileSources[AssetSize] = new MagickImage(string.Format( + @"{0}\{1}\{1}_{2}.png", + SourcePath, + "ArchiveFile", + AssetSize)); + + SfxStubSources[AssetSize] = new MagickImage(string.Format( + @"{0}\{1}\{1}_{2}.png", + SourcePath, + "SelfExtractingExecutable", + AssetSize)); + } + + ProjectAssetsUtilities.GeneratePackageApplicationImageAssets( + StandardSources, + ContrastBlackSources, + ContrastWhiteSources, + OutputPath); + + ProjectAssetsUtilities.GeneratePackageFileAssociationImageAssets( + ArchiveFileSources, + OutputPath, + @"ArchiveFile"); + + ProjectAssetsUtilities.GenerateIconFile( + StandardSources, + OutputPath + @"\..\NanaZip.ico"); + + ProjectAssetsUtilities.GenerateIconFile( + SfxStubSources, + OutputPath + @"\..\NanaZipSfx.ico"); + + StandardSources[64].Write( + OutputPath + @"\..\NanaZip.png"); + } + + { + string SourcePath = RepositoryRoot + @"\Assets\OriginalAssets\NanaZipPreview"; + + string OutputPath = RepositoryRoot + @"\Assets\PreviewPackageAssets"; + + ConcurrentDictionary StandardSources = + new ConcurrentDictionary(); + ConcurrentDictionary ContrastBlackSources = + new ConcurrentDictionary(); + ConcurrentDictionary ContrastWhiteSources = + new ConcurrentDictionary(); + + ConcurrentDictionary ArchiveFileSources = + new ConcurrentDictionary(); + + ConcurrentDictionary SfxStubSources = + new ConcurrentDictionary(); + + foreach (var AssetSize in ProjectAssetsUtilities.AssetSizes) + { + StandardSources[AssetSize] = new MagickImage(string.Format( + @"{0}\{1}\{1}_{2}.png", + SourcePath, + "Standard", + AssetSize)); + ContrastBlackSources[AssetSize] = new MagickImage(string.Format( + @"{0}\{1}\{1}_{2}.png", + SourcePath, + "ContrastBlack", + AssetSize)); + ContrastWhiteSources[AssetSize] = new MagickImage(string.Format( + @"{0}\{1}\{1}_{2}.png", + SourcePath, + "ContrastWhite", + AssetSize)); + + ArchiveFileSources[AssetSize] = new MagickImage(string.Format( + @"{0}\{1}\{1}_{2}.png", + SourcePath, + "ArchiveFile", + AssetSize)); + + SfxStubSources[AssetSize] = new MagickImage(string.Format( + @"{0}\{1}\{1}_{2}.png", + SourcePath, + "SelfExtractingExecutable", + AssetSize)); + } + + ProjectAssetsUtilities.GeneratePackageApplicationImageAssets( + StandardSources, + ContrastBlackSources, + ContrastWhiteSources, + OutputPath); + + ProjectAssetsUtilities.GeneratePackageFileAssociationImageAssets( + ArchiveFileSources, + OutputPath, + @"ArchiveFile"); + + ProjectAssetsUtilities.GenerateIconFile( + StandardSources, + OutputPath + @"\..\NanaZipPreview.ico"); + + ProjectAssetsUtilities.GenerateIconFile( + SfxStubSources, + OutputPath + @"\..\NanaZipPreviewSfx.ico"); + + StandardSources[64].Write( + OutputPath + @"\..\NanaZipPreview.png"); + } + Console.WriteLine( "NanaZip.ProjectAssetsGenerator task has been completed."); Console.ReadKey();