Esempio n. 1
0
        public void SetImageAsData(Image image, string maskColor = "#FF00FF")
        {
            try
            {
                var palette = image.colors.Select(ColorUtils.HexToColor).ToArray();

                var imageExporter = new PNGWriter();

                var exporter = new PixelDataExporter(fileName, image.pixels, image.width, image.height, palette, imageExporter,
                                                     maskColor);

                exporter.CalculateSteps();

                while (exporter.completed == false)
                {
                    exporter.NextStep();
                }

                bytes = exporter.bytes;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Esempio n. 2
0
        public void SavePoseToFile()
        {
            foreach (TMOAnimItem item in items)
            {
                TMOFile tmo = GetTmo(item);

                if (tmo.frames != null)
                {
                    /*
                     * string tmo_file = item.GetTmoPath();
                     * Console.WriteLine("Save File: " + tmo_file);
                     * Directory.CreateDirectory(Path.GetDirectoryName(tmo_file));
                     * tmo.Save(tmo_file);
                     */

                    string png_file = item.GetPngPath();
                    Console.WriteLine("Save File: " + png_file);
                    PNGFile png = CreatePNGFile(item);
                    png.WriteTaOb += delegate(BinaryWriter bw)
                    {
                        PNGWriter pw = new PNGWriter(bw);
                        WritePose(pw, tmo);
                    };
                    png.Save(png_file);
                }
            }
        }
Esempio n. 3
0
 protected void WritePose(PNGWriter pw)
 {
     pw.WriteTDCG();
     pw.WritePOSE();
     WriteCAMI(pw);
     WriteLGTA(pw);
     WriteFTMO(pw);
 }
Esempio n. 4
0
        public ScreenshotService(WorkspaceService workspace)
        {
            // TODO this needs to get teh workspace through the service
//            this.textureFactory = textureFactory;
            this.workspace = workspace;

            imageExporter = new PNGWriter();
        }
Esempio n. 5
0
 protected void WriteHsav(PNGWriter pw)
 {
     pw.WriteTDCG();
     pw.WriteHSAV();
     foreach (string file in Directory.GetFiles(dest_path + @"\" + numTMO, "*.tso"))
     {
         WriteFTSO(pw, file);
     }
 }
Esempio n. 6
0
        protected void WriteCAMI(PNGWriter pw)
        {
            string dest_file = dest_path + @"\Camera.txt";

            Console.WriteLine("CAMI Load File: " + dest_file);

            byte[] cami = ReadFloats(dest_file);
            pw.WriteCAMI(cami);
        }
Esempio n. 7
0
 protected void WriteHsav(PNGWriter pw)
 {
     pw.WriteTDCG();
     pw.WriteHSAV();
     foreach (TSOData tso in fig.TSOList)
     {
         pw.WriteFTSO(tso.opt1, tso.ftso);
     }
 }
Esempio n. 8
0
 public void Save(string dest_file)
 {
     png.WriteTaOb += delegate(BinaryWriter bw)
     {
         PNGWriter pw = new PNGWriter(bw);
         WriteHsav(pw);
     };
     png.Save(dest_file);
 }
Esempio n. 9
0
 protected void WritePtmo(PNGWriter pw)
 {
     pw.WriteTDCG();
     pw.WritePOSE();
     foreach (TSOFigure fig in TSOFigureList)
     {
         pw.WriteFTMO(fig.tmo);
     }
 }
Esempio n. 10
0
        protected void WriteFIGU(PNGWriter pw)
        {
            string dest_file = dest_path + @"\Figure" + numTMO + ".txt";

            Console.WriteLine("FIGU Load File: " + dest_file);

            byte[] figu = ReadFloats(dest_file);
            pw.WriteFIGU(figu);
        }
Esempio n. 11
0
        public void ExportImage(string path, int[] pixelData, IEngine engine, int width, int height)
        {
            Reset();


            var imageExporter = new PNGWriter();

            AddExporter(new PixelDataExporter(path, pixelData, width, height, engine.colorChip.colors, imageExporter,
                                              engine.colorChip.maskColor));
        }
Esempio n. 12
0
        void WritePose(PNGWriter pw, TMOFile tmo)
        {
            byte[] cami = ReadFloats(GetCameraPath());
            byte[] lgta = ReadFloats(GetLightAPath());

            pw.WriteTDCG();
            pw.WritePOSE();
            pw.WriteCAMI(cami);
            pw.WriteLGTA(lgta);
            pw.WriteFTMO(tmo);
        }
Esempio n. 13
0
        protected void WriteFTMO(PNGWriter pw)
        {
            string tmo_file = dest_path + @"\" + numTMO + ".tmo";

            Console.WriteLine("TMO Load File: " + tmo_file);

            using (Stream tmo_stream = File.OpenRead(tmo_file))
            {
                pw.WriteFTMO(tmo_stream);
            }
        }
Esempio n. 14
0
 protected void WritePose(PNGWriter pw)
 {
     pw.WriteTDCG();
     pw.WritePOSE();
     pw.WriteCAMI(cami);
     foreach (TSOFigure fig in TSOFigureList)
     {
         pw.WriteLGTA(fig.lgta);
         pw.WriteFTMO(fig.tmo);
     }
 }
Esempio n. 15
0
        protected void WriteLGTA(PNGWriter pw)
        {
            numTMO++;

            string dest_file = dest_path + @"\LightA" + numTMO + ".txt";

            Console.WriteLine("LGTA Load File: " + dest_file);

            byte[] lgta = ReadFloats(dest_file);
            pw.WriteLGTA(lgta);
        }
Esempio n. 16
0
        protected void WriteFTSO(PNGWriter pw, string tso_file)
        {
            Console.WriteLine("TSO Load File: " + tso_file);

            string code = Path.GetFileNameWithoutExtension(tso_file);
            uint   opt1 = opt_value(code);

            using (Stream tso_stream = File.OpenRead(tso_file))
            {
                pw.WriteFTSO(opt1, tso_stream);
            }
        }
Esempio n. 17
0
 public void SavePoseToFile(TMOFile tmo, string dest_file)
 {
     if (tmo.frames != null)
     {
         PNGFile png = CreatePNGFile();
         png.WriteTaOb += delegate(BinaryWriter bw)
         {
             PNGWriter pw = new PNGWriter(bw);
             WritePose(pw, tmo);
         };
         Debug.WriteLine("Save File: " + dest_file);
         png.Save(dest_file);
     }
 }
Esempio n. 18
0
        public void ExportImage(string path, int[] pixelData, IEngine engine, int width, int height)
        {
            Restart();


            var imageExporter = new PNGWriter();

            // TODO need to double check that we should force this into debug so transparent images have the mask color in them by default
            var colors = ColorUtils.ConvertColors(engine.ColorChip.hexColors, engine.ColorChip.maskColor, true);


            AddExporter(new PixelDataExporter(path, pixelData, width, height, colors, imageExporter,
                                              engine.ColorChip.maskColor));
        }
Esempio n. 19
0
        public static void RenderTile(int width, int height, string number, object context)
        {
            string path = string.Format("/Shared/ShellContent/{0}_{1}_{2}.jpg", width, height, number);

            WriteableBitmap bmp     = null;
            UserControl     control = null;

            ManualResetEventSlim evt = new ManualResetEventSlim(false, 50);

            var act = new Action(() =>
            {
                evt.Reset();
                control             = (width == 0x9f) ? _159_159 as UserControl : _336_336 as UserControl;
                control.DataContext = context;
                control.Measure(new Size((double)width, (double)height));
                control.UpdateLayout();
                control.Arrange(new Rect(0.0, 0.0, (double)width, (double)height));
                control.UpdateLayout();

                bmp = new WriteableBitmap(width, height);
                bmp.Render(control, null);
                bmp.Invalidate();
                evt.Set();
            });

            if (!Deployment.Current.Dispatcher.CheckAccess())
            {
                Deployment.Current.Dispatcher.BeginInvoke(act);
            }
            else
            {
                act();
            }

            evt.Wait();

            if (bmp != null)
            {
                using (IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForApplication())
                {
                    using (IsolatedStorageFileStream stream = new IsolatedStorageFileStream(path, FileMode.Create, FileAccess.Write, file))
                    {
                        PNGWriter.WritePNG(bmp, stream, -1);
                        //Extensions.SaveJpeg(bmp, stream, width, height, 0, 100);
                    }
                }
            }
            bmp = null;
        }
Esempio n. 20
0
 protected void WriteScne(PNGWriter pw)
 {
     pw.WriteTDCG();
     pw.WriteSCNE(FigureCount());
     pw.WriteCAMI(cami);
     foreach (TSOFigure fig in TSOFigureList)
     {
         pw.WriteLGTA(fig.lgta);
         pw.WriteFTMO(fig.tmo);
         pw.WriteFIGU(fig.figu);
         foreach (TSOData tso in fig.TSOList)
         {
             pw.WriteFTSO(tso.opt1, tso.ftso);
         }
     }
 }
Esempio n. 21
0
 protected void WriteScne(PNGWriter pw)
 {
     pw.WriteTDCG();
     pw.WriteSCNE(GetFiguresCount());
     WriteCAMI(pw);
     while (NextFIGUExists())
     {
         WriteLGTA(pw);
         WriteFTMO(pw);
         WriteFIGU(pw);
         foreach (string file in Directory.GetFiles(dest_path + @"\" + numTMO, "*.tso"))
         {
             WriteFTSO(pw, file);
         }
     }
 }
Esempio n. 22
0
        protected void WriteHsavOrPoseOrScne(PNGWriter pw, string source_type)
        {
            switch (source_type)
            {
            case "HSAV":
                WriteHsav(pw);
                break;

            case "POSE":
                WritePose(pw);
                break;

            case "SCNE":
                WriteScne(pw);
                break;
            }
        }
Esempio n. 23
0
        public void CalculateSteps()
        {
            var cols = 16;
            var rows = MathUtil.CeilToInt(totalFlags / (float)cols);

            var w = cols * tileSize.x;
            var h = rows * tileSize.y;

            var canvas = new Pattern(w, h);

            canvas.Clear();

            var totalPixels = tileSize.x * tileSize.y;

            var brush = new int[totalPixels];

            IColor[] colors = new IColor[totalFlags];

            var flagColors = flagColorChip.colors;

            for (int i = 0; i < totalFlags; i++)
            {
                colors[i] = flagColors[i];

                var pos = gameChip.CalculatePosition(i, w);

                pos.x *= tileSize.x;
                pos.y *= tileSize.y;
                // Update the brush
                for (int j = 0; j < totalPixels; j++)
                {
                    brush[j] = i;
                }

                canvas.SetPixels(pos.x, pos.y, tileSize.x, tileSize.y, brush);
            }
            var imageExporter = new PNGWriter();

            exporter = new PixelDataExporter(fullFileName, canvas.pixels, w, h, colors, imageExporter);

            exporter.CalculateSteps();
        }
Esempio n. 24
0
        public int Compose(string dest_path)
        {
            this.dest_path = dest_path;
            PNGFile png = new PNGFile();

            string source_type = ReadSourceType(dest_path + @"\TDCG.txt");

            Console.WriteLine("This is {0} Save File", source_type);

            png.WriteTaOb += delegate(BinaryWriter bw)
            {
                PNGWriter pw = new PNGWriter(bw);
                WriteHsavOrPoseOrScne(pw, source_type);
            };

            png.Load(dest_path + @"\thumbnail.png");
            string dest_file = Path.ChangeExtension(dest_path, @".new" + Path.GetExtension(dest_path) + @".png");

            Console.WriteLine("Save File: " + dest_file);
            png.Save(dest_file);
            return(0);
        }
Esempio n. 25
0
        // TODO this should be a step in the exporter
        public override void ConfigurePixelData()
        {
            var spriteChip = engine.spriteChip;

            var width  = 96; //spriteChip.textureWidth;
            var height = 64; //spriteChip.textureHeight;


            var textureData = new TextureData(width, height);

//            var pixelData = new int[width * height];

            // Go through all of the sprites in the font

            // TODO get font sprites

            var total = 96;

            var maxCol = width / spriteChip.width;

            var tmpPixelData = new int[spriteChip.width * spriteChip.height];

            for (int i = 0; i < total; i++)
            {
                var pos = engine.gameChip.CalculatePosition(i, maxCol);

                spriteChip.ReadSpriteAt(i, tmpPixelData);

                textureData.SetPixels(pos.x * spriteChip.width, pos.y * spriteChip.height, spriteChip.width, spriteChip.height, tmpPixelData);
            }

            var colorMapChip = engine.chipManager.GetChip(ColorMapParser.chipName, false) as ColorChip;

            var colors = colorMapChip == null ? engine.colorChip.colors : colorMapChip.colors;

            var imageExporter = new PNGWriter();

            exporter = new PixelDataExporter(fullFileName, textureData.pixels, width, height, colors, imageExporter);
        }
Esempio n. 26
0
        public bool Process(string source_file)
        {
            List <TSOFigure> fig_list = new List <TSOFigure>();

            Console.WriteLine("Load File: " + source_file);
            PNGFile source      = new PNGFile();
            string  source_type = "";

            try
            {
                TSOFigure fig = null;
                TMOFile   tmo = null;

                source.Hsav += delegate(string type)
                {
                    source_type = type;

                    fig = new TSOFigure();
                    fig_list.Add(fig);
                };
                source.Pose += delegate(string type)
                {
                    source_type = type;
                };
                source.Scne += delegate(string type)
                {
                    source_type = type;
                };
                source.Cami += delegate(Stream dest, int extract_length)
                {
                    cami = new byte[extract_length];
                    dest.Read(cami, 0, extract_length);
                };
                source.Lgta += delegate(Stream dest, int extract_length)
                {
                    byte[] lgta = new byte[extract_length];
                    dest.Read(lgta, 0, extract_length);

                    fig      = new TSOFigure();
                    fig.lgta = lgta;
                    fig_list.Add(fig);
                };
                source.Ftmo += delegate(Stream dest, int extract_length)
                {
                    tmo = new TMOFile();
                    tmo.Load(dest);
                    fig.tmo = tmo;
                };
                source.Figu += delegate(Stream dest, int extract_length)
                {
                    byte[] figu = new byte[extract_length];
                    dest.Read(figu, 0, extract_length);

                    fig.figu = figu;
                };
                source.Ftso += delegate(Stream dest, int extract_length, byte[] opt1)
                {
                    byte[] ftso = new byte[extract_length];
                    dest.Read(ftso, 0, extract_length);

                    TSOData tso = new TSOData();
                    tso.opt1 = BitConverter.ToUInt32(opt1, 0);
                    tso.ftso = ftso;
                    fig.TSOList.Add(tso);
                };

                source.Load(source_file);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(false);
            }

            foreach (TSOFigure fig in fig_list)
            {
                TSOFigureList.Add(fig);
            }

            TDCG.TMOFlip.TMOFlipProcessor processor = new TDCG.TMOFlip.TMOFlipProcessor();

            foreach (TSOFigure fig in TSOFigureList)
            {
                if (fig.tmo != null)
                {
                    if (fig.tmo.nodes[0].Path == "|W_Hips")
                    {
                        processor.Process(fig.tmo);
                    }
                }
            }

            string dest_path = Path.GetDirectoryName(source_file);
            string dest_file = Path.GetFileNameWithoutExtension(source_file) + @".new.png";

            Console.WriteLine("Save File: " + dest_file);
            source.WriteTaOb += delegate(BinaryWriter bw)
            {
                PNGWriter pw = new PNGWriter(bw);
                switch (source_type)
                {
                case "HSAV":
                    WriteHsav(pw);
                    break;

                case "POSE":
                    WritePose(pw);
                    break;

                case "SCNE":
                    WriteScne(pw);
                    break;
                }
            };
            source.Save(dest_file);

            return(true);
        }
Esempio n. 27
0
        public bool CopyNode(string source_file, string motion_file, string node_name)
        {
            List <TSOFigure> fig_list = new List <TSOFigure>();

            Console.WriteLine("Load File: " + source_file);
            PNGFile source      = new PNGFile();
            string  source_type = "";

            try
            {
                TSOFigure fig = null;
                TMOFile   tmo = null;

                source.Hsav += delegate(string type)
                {
                    source_type = type;

                    fig = new TSOFigure();
                    fig_list.Add(fig);
                };
                source.Pose += delegate(string type)
                {
                    source_type = type;
                };
                source.Scne += delegate(string type)
                {
                    source_type = type;
                };
                source.Cami += delegate(Stream dest, int extract_length)
                {
                    cami = new byte[extract_length];
                    dest.Read(cami, 0, extract_length);
                };
                source.Lgta += delegate(Stream dest, int extract_length)
                {
                    byte[] lgta = new byte[extract_length];
                    dest.Read(lgta, 0, extract_length);

                    fig      = new TSOFigure();
                    fig.lgta = lgta;
                    fig_list.Add(fig);
                };
                source.Ftmo += delegate(Stream dest, int extract_length)
                {
                    tmo = new TMOFile();
                    tmo.Load(dest);
                    fig.tmo = tmo;
                };
                source.Figu += delegate(Stream dest, int extract_length)
                {
                    byte[] figu = new byte[extract_length];
                    dest.Read(figu, 0, extract_length);

                    fig.figu = figu;
                };
                source.Ftso += delegate(Stream dest, int extract_length, byte[] opt1)
                {
                    byte[] ftso = new byte[extract_length];
                    dest.Read(ftso, 0, extract_length);

                    TSOData tso = new TSOData();
                    tso.opt1 = BitConverter.ToUInt32(opt1, 0);
                    tso.ftso = ftso;
                    fig.TSOList.Add(tso);
                };

                source.Load(source_file);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(false);
            }

            foreach (TSOFigure fig in fig_list)
            {
                TSOFigureList.Add(fig);
            }

            Console.WriteLine("Load File: " + motion_file);
            PNGFile motion     = new PNGFile();
            TMOFile motion_tmo = null;

            try
            {
                motion.Ftmo += delegate(Stream dest, int extract_length)
                {
                    motion_tmo = new TMOFile();
                    motion_tmo.Load(dest);
                };

                motion.Load(motion_file);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(false);
            }

            if (motion_tmo != null)
            {
                foreach (TSOFigure fig in TSOFigureList)
                {
                    if (fig.tmo != null)
                    {
                        fig.tmo.CopyNodeFrom(motion_tmo, node_name);
                    }
                }
            }

            string dest_file = source_file + ".tmp";

            Console.WriteLine("Save File: " + dest_file);
            source.WriteTaOb += delegate(BinaryWriter bw)
            {
                PNGWriter pw = new PNGWriter(bw);
                switch (source_type)
                {
                case "HSAV":
                    WriteHsav(pw);
                    break;

                case "POSE":
                    WritePose(pw);
                    break;

                case "SCNE":
                    WriteScne(pw);
                    break;
                }
            };
            source.Save(dest_file);

            File.Delete(source_file);
            File.Move(dest_file, source_file);
            Console.WriteLine("updated " + source_file);

            return(true);
        }
Esempio n. 28
0
        public void ExportGame(string path, IEngine engine, SaveFlags saveFlags)
        {
            Reset();

//            exporting = true;

            // Make sure that the texture factory has the current mask color if any images are going to be exported.
//            textureFactory.maskColor = new ColorData(engine.colorChip.maskColor);

//            Console.WriteLine("MASK COLOR " + engine.colorChip.maskColor);

//            Console.WriteLine("Export Game " + path);

            var watch = Stopwatch.StartNew();

            // Save the engine so we can work with it during loading
            targetEngine = engine;

            // Step 1. Load the system snapshot
            if ((saveFlags & SaveFlags.System) == SaveFlags.System)
            {
                AddExporter(new SystemExporter(path + "data.json", targetEngine));
            }

            // Step 2 (optional). Load up the Lua script
            if ((saveFlags & SaveFlags.Code) == SaveFlags.Code)
            {
//                //var scriptExtension = ".lua";
//
//                var paths = files.Keys.Where(s => textExtensions.Any(x => s.EndsWith(x))).ToList();
//
//                foreach (var fileName in paths)
//                {
//                    parser = LoadScript(fileName, files[fileName]);
//                    AddExporter(parser);
//                }
            }

            // Step 3 (optional). Look for new colors
            if ((saveFlags & SaveFlags.Colors) == SaveFlags.Colors)
            {
                var colorChip = targetEngine.colorChip;

                AddExporter(new ColorPaletteExporter(path + "colors.png", colorChip, new PNGWriter()));
            }

            // Step 4 (optional). Look for color map for sprites and tile map
            if ((saveFlags & SaveFlags.ColorMap) == SaveFlags.ColorMap)
            {
                if (targetEngine.GetChip(ColorMapParser.chipName, false) is ColorChip colorChip)
                {
                    AddExporter(new ColorPaletteExporter(path + "color-map.png", colorChip, new PNGWriter()));
                }
            }

            // Step 5 (optional). Look for new sprites
            if ((saveFlags & SaveFlags.Sprites) == SaveFlags.Sprites)
            {
//                Console.WriteLine("Export Sprite");

                var imageExporter = new PNGWriter();

                AddExporter(new SpriteExporter(path + "sprites.png", targetEngine, imageExporter));
//                var spriteChip = targetEngine.spriteChip;
//
//                var pixelData = spriteChip.texture.GetPixels();
//
//                //TODO need to crop the pixel data so we only save out what we need
//
//                AddExporter(new ImageExporter("sprite.cache.png", pixelData, spriteChip.textureWidth, spriteChip.textureHeight, targetEngine.colorChip.colors, textureFactory));
////
////
//                parser = LoadSprites(files);
//                if (parser != null)
//                    AddExporter(parser);
            }

            // Step 6 (optional). Look for tile map to load
//            if ((saveFlags & SaveFlags.Tilemap) == SaveFlags.Tilemap)
//            {
//                var imageExporter = new PNGWriter();
//
//                var tmp = new TilemapExporter(path + "tilemap.png", targetEngine, imageExporter);
//                AddExporter(tmp);
//            }
//
//            if ((saveFlags & SaveFlags.TilemapFlags) == SaveFlags.TilemapFlags)
//            {
//                var imageExporter = new PNGWriter();
//
//                AddExporter(new TilemapFlagExporter(path + "tilemap-flags.png", targetEngine, imageExporter));
//            }

//            if ((saveFlags & SaveFlags.FlagColors) == SaveFlags.FlagColors)
//            {
//                AddExporter(new FlagColorExporter(path + "flags.png", targetEngine, textureFactory));
//                //AddExporter(new FlagTileExporter(path + "flags.png", targetEngine, textureFactory));
//            }

//            if ((saveFlags & SaveFlags.TileColorOffset) == SaveFlags.TileColorOffset)
//            {
//                AddExporter(new TileColorOffsetExporter(path + "tile-color-offsets.json", targetEngine));
//            }

//
            // Step 7 (optional). Look for fonts to load
            if ((saveFlags & SaveFlags.Fonts) == SaveFlags.Fonts)
            {
                var fontChip       = targetEngine.fontChip;
                var spriteChip     = targetEngine.spriteChip;
                var tmpTextureData = new TextureData(96, 64);

                var fonts = fontChip.fonts;

                foreach (var font in fonts)
                {
                    var name    = font.Key;
                    var sprites = font.Value;

                    // Clear the texture
                    tmpTextureData.Clear();

                    // Loop through all the characters and copy their texture data over
                    var total = sprites.Length;
                    for (var i = 0; i < total; i++)
                    {
                    }
                }


//                var fontExtension = ".font.png";
//
//                var paths = files.Keys.Where(s => s.EndsWith(fontExtension)).ToArray();
//
//                foreach (var fileName in paths)
//                {
//                    var fontName = fileName.Split('.')[0];
//
//                    parser = LoadFont(fontName, files[fileName]);
//                    if (parser != null)
//                        AddExporter(parser);
//                }
            }
//


//                if ((saveFlags & SaveFlags.TilemapFlags) == SaveFlags.TilemapFlags)
//                {
////                    ExportUtil.CreateTileMapFlagTexture(ref tex, engine);
////                    SaveTextureToFile(path, "tilemap-flags", tex);
//                }
//
            if ((saveFlags & SaveFlags.Tilemap) == SaveFlags.Tilemap)
            {
                AddExporter(new TilemapJsonExporter(path + "tilemap.json", targetEngine));
            }


            // Step 8 (optional). Look for meta data and override the game
            if ((saveFlags & SaveFlags.Meta) == SaveFlags.Meta)
            {
                AddExporter(new MetadataExporter(path + "info.json", targetEngine));
            }

            // Step 9 (optional). Look for meta data and override the game
            if ((saveFlags & SaveFlags.Sounds) == SaveFlags.Sounds)
            {
                AddExporter(new SoundExporter(path + "sounds.json", targetEngine));
            }

            // Step 10 (optional). Look for meta data and override the game
            if ((saveFlags & SaveFlags.Music) == SaveFlags.Music)
            {
                AddExporter(new MusicExporter(path + "music.json", targetEngine));
            }

            // Step 11 (optional). Look for meta data and override the game
            if ((saveFlags & SaveFlags.SaveData) == SaveFlags.SaveData)
            {
                AddExporter(new SavedDataExporter(path + "saves.json", targetEngine));
            }

            totalParsers    = exporters.Count;
            currentParserID = 0;

            watch.Stop();

//            UnityEngine.Debug.Log("Game Exporter Setup Time - " + watch.ElapsedMilliseconds);
        }
Esempio n. 29
0
        public bool Process(Stream png_stream, Stream ret_stream)
        {
            List <TSOFigure> fig_list = new List <TSOFigure>();

            PNGFile png         = new PNGFile();
            string  source_type = "";

            {
                TSOFigure fig = null;
                TMOFile   tmo = null;

                png.Hsav += delegate(string type)
                {
                    source_type = type;

                    fig = new TSOFigure();
                    fig_list.Add(fig);
                };
                png.Pose += delegate(string type)
                {
                    source_type = type;
                };
                png.Scne += delegate(string type)
                {
                    source_type = type;
                };
                png.Cami += delegate(Stream dest, int extract_length)
                {
                    cami = new byte[extract_length];
                    dest.Read(cami, 0, extract_length);
                };
                png.Lgta += delegate(Stream dest, int extract_length)
                {
                    byte[] lgta = new byte[extract_length];
                    dest.Read(lgta, 0, extract_length);

                    fig      = new TSOFigure();
                    fig.lgta = lgta;
                    fig_list.Add(fig);
                };
                png.Ftmo += delegate(Stream dest, int extract_length)
                {
                    tmo = new TMOFile();
                    tmo.Load(dest);
                    if (fig == null)
                    {
                        source_type = "PTMO";
                        fig         = new TSOFigure();
                        fig.lgta    = null;
                        fig_list.Add(fig);
                    }
                    fig.tmo = tmo;
                };
                png.Figu += delegate(Stream dest, int extract_length)
                {
                    byte[] figu = new byte[extract_length];
                    dest.Read(figu, 0, extract_length);

                    fig.figu = figu;
                };
                png.Ftso += delegate(Stream dest, int extract_length, byte[] opt1)
                {
                    byte[] ftso = new byte[extract_length];
                    dest.Read(ftso, 0, extract_length);

                    TSOData tso = new TSOData();
                    tso.opt1 = BitConverter.ToUInt32(opt1, 0);
                    tso.ftso = ftso;
                    fig.TSOList.Add(tso);
                };

                png.Load(png_stream);
                png_stream.Close();
            }

            foreach (TSOFigure fig in fig_list)
            {
                TSOFigureList.Add(fig);
            }

            foreach (TSOFigure fig in TSOFigureList)
            {
                if (fig.tmo != null)
                {
                    if (fig.tmo.nodes[0].Path == "|W_Hips")
                    {
                        tmo_Transform(fig.tmo);
                    }
                }
            }

            png.WriteTaOb += delegate(BinaryWriter bw)
            {
                PNGWriter pw = new PNGWriter(bw);
                switch (source_type)
                {
                case "HSAV":
                    WriteHsav(pw);
                    break;

                case "POSE":
                    WritePose(pw);
                    break;

                case "SCNE":
                    WriteScne(pw);
                    break;

                case "PTMO":
                    WritePtmo(pw);
                    break;
                }
            };
            png.Save(ret_stream);

            TSOFigureList.Clear();
            return(true);
        }
Esempio n. 30
0
 /// <summary>
 /// Write and PNG file out to a file stream.  Currently compression is not supported.
 /// </summary>
 /// <param name="image">The WriteableBitmap to work on.</param>
 /// <param name="stream">The destination file stream.</param>
 /// <param name="compression">Level of compression to use (-1=auto, 0=none, 1-100 is percentage).</param>
 public static void WritePNG(this WriteableBitmap image, System.IO.Stream stream, int compression)
 {
     PNGWriter.DetectWBByteOrder();
     PNGWriter.WritePNG(image, stream, compression);
 }