private void TextureListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var file = (string)textureListBox.SelectedItem;

            try
            {
                var blp = new WoWFormatLib.FileReaders.BLPReader();
                blp.LoadBLP(file);

                var bmp = blp.bmp;

                using (var memory = new MemoryStream())
                {
                    bmp.Save(memory, ImageFormat.Png);

                    memory.Position = 0;

                    var bitmapImage = new BitmapImage();

                    bitmapImage.BeginInit();
                    bitmapImage.StreamSource = memory;
                    bitmapImage.CacheOption  = BitmapCacheOption.OnLoad;
                    bitmapImage.EndInit();

                    blpImage.Source = bitmapImage;
                }
            }
            catch (Exception blpException)
            {
                Console.WriteLine(blpException.Message);
            }
        }
예제 #2
0
        public static void ExportThisFolder(string path, string to)
        {
            WoWFormatLib.FileReaders.BLPReader minireader = new WoWFormatLib.FileReaders.BLPReader();
            for (int i = 0; i < lines.Count(); i++)
            {
                string file = lines[i].Substring(0, lines[i].IndexOf("\t"));                                                //path + filenames
                string hash = lines[i].Substring(lines[i].IndexOf("\t") + 1, lines[i].Length - lines[i].IndexOf("\t") - 1); //filehash

                if (file.StartsWith(path.ToLower() + "\\"))
                {
                    try
                    {
                        minireader.LoadBLP(ArchiveManager.ReadThisFile(@"textures\minimap\" + hash));
                        if (!Directory.Exists(Path.Combine(to + "\\", Path.GetDirectoryName(file))))
                        {
                            Directory.CreateDirectory(Path.Combine(to + "\\", Path.GetDirectoryName(file)));
                        }
                        minireader.bmp.Save(Path.Combine(to + "\\", Path.GetDirectoryName(file) + "\\" + Path.GetFileNameWithoutExtension(file) + ".png"));
                    }
                    catch (Exception e)
                    {
                        throw new Exception(e.Message);
                    }
                }
            }
        }
예제 #3
0
        private void TextureListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var file = (string)textureListBox.SelectedItem;

            if (file == null)
            {
                return;
            }

            try
            {
                using (var memory = new MemoryStream())
                {
                    var blp = new WoWFormatLib.FileReaders.BLPReader();
                    if (Listfile.TryGetFileDataID(file, out var filedataid))
                    {
                        blp.LoadBLP(filedataid);
                    }
                    else
                    {
                        return;
                    }

                    var bmp = blp.bmp;

                    if (ignoreTextureAlpha)
                    {
                        bmp.Clone(new Rectangle(0, 0, bmp.Width, bmp.Height), System.Drawing.Imaging.PixelFormat.Format32bppRgb).Save(memory, ImageFormat.Bmp);
                    }
                    else
                    {
                        bmp.Save(memory, ImageFormat.Png);
                    }

                    memory.Position = 0;

                    var bitmapImage = new BitmapImage();
                    bitmapImage.BeginInit();
                    bitmapImage.StreamSource = memory;
                    bitmapImage.CacheOption  = BitmapCacheOption.OnLoad;
                    bitmapImage.EndInit();
                    blpImage.Source    = bitmapImage;
                    blpImage.MaxWidth  = bitmapImage.Width;
                    blpImage.MaxHeight = bitmapImage.Height;
                }
            }
            catch (Exception blpException)
            {
                Console.WriteLine(blpException.Message);
            }

            e.Handled = true;
        }
예제 #4
0
        private void exportworker_DoWork(object sender, DoWorkEventArgs e)
        {
            var selectedFiles = (System.Collections.IList)e.Argument;

            foreach (string selectedFile in selectedFiles)
            {
                if (!CASC.FileExists(selectedFile))
                {
                    continue;
                }
                if (selectedFile.EndsWith(".wmo"))
                {
                    Exporters.OBJ.WMOExporter.exportWMO(selectedFile, exportworker);
                }
                else if (selectedFile.EndsWith(".m2"))
                {
                    Exporters.OBJ.M2Exporter.exportM2(selectedFile, exportworker);
                }
                else if (selectedFile.EndsWith(".adt"))
                {
                    Exporters.OBJ.ADTExporter.exportADT(selectedFile, exportworker);
                }
                else if (selectedFile.EndsWith(".blp"))
                {
                    try
                    {
                        var blp = new WoWFormatLib.FileReaders.BLPReader();
                        blp.LoadBLP(selectedFile);

                        var bmp = blp.bmp;

                        if (!Directory.Exists(Path.Combine(outdir, Path.GetDirectoryName(selectedFile))))
                        {
                            Directory.CreateDirectory(Path.Combine(outdir, Path.GetDirectoryName(selectedFile)));
                        }

                        bmp.Save(Path.Combine(outdir, Path.GetDirectoryName(selectedFile), Path.GetFileNameWithoutExtension(selectedFile)) + ".png");
                    }
                    catch (Exception blpException)
                    {
                        Console.WriteLine(blpException.Message);
                    }
                }
            }
        }
        private void TileListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                var file = (string)tileListBox.SelectedItem;

                var selectedItem = (MapListItem)mapListBox.SelectedItem;

                var minimapFile = "world\\minimaps\\" + selectedItem.Internal + "\\map" + file + ".blp";

                if (!CASC.FileExists(minimapFile))
                {
                    minimapFile = @"interface\icons\inv_misc_questionmark.blp";
                }

                var blp = new WoWFormatLib.FileReaders.BLPReader();
                blp.LoadBLP(minimapFile);

                var bmp = blp.bmp;

                using (var memory = new MemoryStream())
                {
                    bmp.Save(memory, ImageFormat.Png);

                    memory.Position = 0;

                    var bitmapImage = new BitmapImage();

                    bitmapImage.BeginInit();
                    bitmapImage.StreamSource = memory;
                    bitmapImage.CacheOption  = BitmapCacheOption.OnLoad;
                    bitmapImage.EndInit();

                    tileImage.Source = bitmapImage;
                }

                selectedTileLabel.Content = "Selected tile: " + file.Insert(2, "_");
            }
            catch (Exception blpException)
            {
                Console.WriteLine(blpException.Message);
            }
        }
        private void Exportworker_DoWork(object sender, DoWorkEventArgs e)
        {
            var selectedFiles = (System.Collections.IList)e.Argument;

            var exportFormat = "OBJ";

            ConfigurationManager.RefreshSection("appSettings");
            if (ConfigurationManager.AppSettings["exportFormat"] != null && ConfigurationManager.AppSettings["exportFormat"] == "glTF")
            {
                exportFormat = "glTF";
            }

            Logger.WriteLine("ExportWorker: Export format is {0}", exportFormat);

            foreach (string selectedFile in selectedFiles)
            {
                if (!CASC.FileExists(selectedFile))
                {
                    Logger.WriteLine("ExportWorker: File {0} does not exist, skipping export!", selectedFile);
                    continue;
                }

                Logger.WriteLine("ExportWorker: Exporting {0}..", selectedFile);
                try
                {
                    if (selectedFile.EndsWith(".wmo"))
                    {
                        if (exportFormat == "OBJ")
                        {
                            Exporters.OBJ.WMOExporter.exportWMO(selectedFile, exportworker);
                        }
                        else if (exportFormat == "glTF")
                        {
                            Exporters.glTF.WMOExporter.ExportWMO(selectedFile, exportworker);
                        }
                    }
                    else if (selectedFile.EndsWith(".m2"))
                    {
                        if (exportFormat == "OBJ")
                        {
                            Exporters.OBJ.M2Exporter.ExportM2(selectedFile, exportworker);
                        }
                        else if (exportFormat == "glTF")
                        {
                            Exporters.glTF.M2Exporter.ExportM2(selectedFile, exportworker);
                        }
                    }
                    else if (selectedFile.EndsWith(".adt"))
                    {
                        if (exportFormat == "OBJ")
                        {
                            Exporters.OBJ.ADTExporter.exportADT(selectedFile, exportworker);
                        }
                        else if (exportFormat == "glTF")
                        {
                            Exporters.glTF.ADTExporter.ExportADT(selectedFile, exportworker);
                        }
                    }
                    else if (selectedFile.EndsWith(".blp"))
                    {
                        ConfigurationManager.RefreshSection("appSettings");
                        var outdir = ConfigurationManager.AppSettings["outdir"];
                        try
                        {
                            var blp = new WoWFormatLib.FileReaders.BLPReader();
                            blp.LoadBLP(selectedFile);

                            var bmp = blp.bmp;

                            if (!Directory.Exists(Path.Combine(outdir, Path.GetDirectoryName(selectedFile))))
                            {
                                Directory.CreateDirectory(Path.Combine(outdir, Path.GetDirectoryName(selectedFile)));
                            }

                            bmp.Save(Path.Combine(outdir, Path.GetDirectoryName(selectedFile), Path.GetFileNameWithoutExtension(selectedFile)) + ".png");
                        }
                        catch (Exception blpException)
                        {
                            Console.WriteLine(blpException.Message);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Logger.WriteLine("ExportWorker: Exception occured in " + ex.Source + " " + ex.Message + " " + ex.StackTrace);
                }
            }
        }
예제 #7
0
        private void Exportworker_DoWork(object sender, DoWorkEventArgs e)
        {
            var selectedFiles = (System.Collections.IList)e.Argument;

            var exportFormat = "OBJ";

            ConfigurationManager.RefreshSection("appSettings");
            if (ConfigurationManager.AppSettings["exportFormat"] != null && ConfigurationManager.AppSettings["exportFormat"] == "glTF")
            {
                exportFormat = "glTF";
            }

            Logger.WriteLine("ExportWorker: Export format is {0}", exportFormat);

            foreach (string selectedFile in selectedFiles)
            {
                if (!Listfile.TryGetFileDataID(selectedFile, out var fileDataID))
                {
                    Logger.WriteLine("ExportWorker: File {0} does not exist in listfile, skipping export!", selectedFile);
                    continue;
                }

                if (!CASC.FileExists(fileDataID))
                {
                    Logger.WriteLine("ExportWorker: File {0} does not exist, skipping export!", selectedFile);
                    continue;
                }

                Logger.WriteLine("ExportWorker: Exporting {0}..", selectedFile);
                try
                {
                    if (selectedFile.EndsWith(".wmo"))
                    {
                        if (exportFormat == "OBJ")
                        {
                            Exporters.OBJ.WMOExporter.ExportWMO(selectedFile, exportworker);
                        }
                        else if (exportFormat == "glTF")
                        {
                            Exporters.glTF.WMOExporter.ExportWMO(selectedFile, exportworker);
                        }
                    }
                    else if (selectedFile.EndsWith(".m2"))
                    {
                        if (exportFormat == "OBJ")
                        {
                            Exporters.OBJ.M2Exporter.ExportM2(selectedFile, exportworker);
                        }
                        else if (exportFormat == "glTF")
                        {
                            Exporters.glTF.M2Exporter.ExportM2(selectedFile, exportworker);
                        }
                    }
                    else if (selectedFile.EndsWith(".blp"))
                    {
                        ConfigurationManager.RefreshSection("appSettings");
                        var outdir = ConfigurationManager.AppSettings["outdir"];
                        try
                        {
                            if (!Listfile.FilenameToFDID.TryGetValue(selectedFile, out uint blpFileDataID))
                            {
                                throw new Exception("Unable to find filedata for filename " + selectedFile);
                            }

                            var blp = new WoWFormatLib.FileReaders.BLPReader();
                            blp.LoadBLP(blpFileDataID);

                            var bmp = blp.bmp;

                            if (!Directory.Exists(Path.Combine(outdir, Path.GetDirectoryName(selectedFile))))
                            {
                                Directory.CreateDirectory(Path.Combine(outdir, Path.GetDirectoryName(selectedFile)));
                            }

                            if (ignoreTextureAlpha)
                            {
                                bmp.Clone(new Rectangle(0, 0, bmp.Width, bmp.Height), System.Drawing.Imaging.PixelFormat.Format32bppRgb).Save(Path.Combine(outdir, Path.GetDirectoryName(selectedFile), Path.GetFileNameWithoutExtension(selectedFile)) + ".png");
                            }
                            else
                            {
                                bmp.Save(Path.Combine(outdir, Path.GetDirectoryName(selectedFile), Path.GetFileNameWithoutExtension(selectedFile)) + ".png");
                            }
                        }
                        catch (Exception blpException)
                        {
                            Console.WriteLine(blpException.Message);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Logger.WriteLine("ExportWorker: Exception occured in " + ex.Source + " " + ex.Message + " " + ex.StackTrace);
                }
            }
        }