private static void SetImageSource(ImageBrush brush, PackageFileInfo path) { ImageSource ddsSource; if (!_materialImages.TryGetValue(path.ToString(), out ddsSource)) { string packagePath; if (!PackageStream.IsFileExisted(path.PackagePath, path.FileInPackagePath)) { packagePath = Path.Combine(Path.GetFullPath(Path.GetDirectoryName(path.PackagePath)), "shared_content.pkg"); } else { packagePath = path.PackagePath; } using (var Stream = new PackageStream(packagePath, path.FileInPackagePath)) { var dds = new DDSImage(Stream); ddsSource = dds.BitmapSource(0); } } brush.ImageSource = ddsSource; }
private static BitmapSource CreateCamouflagePreview(LocalGameClient client, Camouflage camouflage, WpfColor baseColor) { if (!PackageStream.IsFileExisted(client.PackageIndexer, camouflage.Texture)) { return(null); } var image = new Image(); image.Width = 64; image.Height = 64; using (var stream = new PackageStream(client.PackageIndexer, camouflage.Texture)) { image.Source = (new DDSImage(stream)).BitmapSource(0); } var colors = camouflage.GetColors(); image.Effect = new CamouflageEffect() { BaseColor = baseColor, Color1 = colors[0], Color2 = colors[1], Color3 = colors[2], Color4 = colors[3], }; image.MeasureAndArrange(); var imageSource = image.RenderToBitmap(); imageSource.Freeze(); return(imageSource); }
private PackageStream OpenPrimitiveFile(string modelFile) { var primitiveFile = Path.ChangeExtension(modelFile, ".primitives"); // pre 10.0 if (!PackageStream.IsFileExisted(this.Database.PackageDatabase, primitiveFile)) { primitiveFile = Path.ChangeExtension(modelFile, ".primitives_processed"); // post 10.0 } return(new PackageStream(this.Database.PackageDatabase, primitiveFile)); }
private PackageStream OpenVisualFile(string modelFile) { var visualFile = Path.ChangeExtension(modelFile, ".visual"); // pre 10.0 if (!PackageStream.IsFileExisted(this.Database.PackageDatabase, visualFile)) { visualFile = Path.ChangeExtension(modelFile, ".visual_processed"); // post 10.0 } return(new PackageStream(this.Database.PackageDatabase, visualFile)); }
private ImageSource LoadTankIcon(string relativePath, string hyphenKey) { var localPath = string.Format("{0}/{1}.png", relativePath, hyphenKey); if (PackageStream.IsFileExisted(_paths.GuiPackageFile, localPath)) { return(PackageImage.Load(_paths.GuiPackageFile, localPath)); } localPath = string.Format("{0}/noImage.png", relativePath); return(PackageImage.Load(_paths.GuiPackageFile, localPath)); }
private string GetPackagePath(string filename, string declaredPackagePath) { string actualPackagePath; if (!PackageStream.IsFileExisted(declaredPackagePath, filename)) { actualPackagePath = Path.Combine(Path.GetFullPath(Path.GetDirectoryName(declaredPackagePath)), "shared_content.pkg"); } else { actualPackagePath = declaredPackagePath; } return(actualPackagePath); }
public bool TryOpenRead(string path, out Stream stream) { if (this.Source == FileSource.ModFolder) { var modFile = Path.Combine(this.Client.ModDirectory, path); if (File.Exists(modFile)) { stream = File.OpenRead(modFile); return(true); } } if (PackageStream.IsFileExisted(this.Client.PackageIndexer, path)) { stream = new PackageStream(this.Client.PackageIndexer, path); return(true); } stream = null; return(false); }