示例#1
0
        private static void ExportMapSafe(String mapName)
        {
            try
            {
                String relativePath    = FieldMap.GetMapResourcePath(mapName);
                String outputDirectory = Path.Combine(Configuration.Export.Path, relativePath);
                String outputPath      = outputDirectory + "Atlas.png";
                if (File.Exists(outputPath))
                {
                    Log.Warning($"[FieldSceneExporter] Export was skipped bacause a file already exists: [{outputPath}].");
                    return;
                }

                Log.Message("[FieldSceneExporter] Exporting [{0}]...", mapName);

                BGSCENE_DEF scene = new BGSCENE_DEF(true);
                scene.LoadEBG(null, relativePath, mapName);

                String directoryPath = Path.GetDirectoryName(outputPath);
                if (directoryPath != null)
                {
                    Directory.CreateDirectory(directoryPath);
                }
                TextureHelper.WriteTextureToFile(TextureHelper.CopyAsReadable(scene.atlas), outputPath);

                Log.Message("[FieldSceneExporter] Exporting completed successfully.");
            }
            catch (Exception ex)
            {
                Log.Error(ex, "[FieldSceneExporter] Failed to export map [{0}].", mapName);
            }
        }
示例#2
0
    public void SaveFieldMap()
    {
        BGSCENE_DEF scene = this.fieldMap.scene;

        Byte[] ebgBin          = scene.ebgBin;
        String mapName         = this.fieldMap.mapName;
        String fieldMapModName = FieldMapEditor.GetFieldMapModName(mapName);
        String mapResourcePath = FieldMap.GetMapResourcePath(mapName);

        using (BinaryWriter binaryWriter = new BinaryWriter(new MemoryStream(ebgBin)))
        {
            for (Int32 i = 0; i < (Int32)scene.overlayCount; i++)
            {
                BGOVERLAY_DEF bgoverlay_DEF = scene.overlayList[i];
                UInt32        oriData       = bgoverlay_DEF.oriData;
                UInt16        num           = (UInt16)bgoverlay_DEF.transform.localPosition.z;
                UInt16        num2          = (UInt16)(oriData >> 8 & 4095u);
                UInt32        num3          = oriData;
                UInt32        num4          = 1048320u;
                num3 &= ~num4;
                num3 |= (UInt32)((Int64)((Int64)num << 8) & (Int64)((UInt64)num4));
                global::Debug.Log(String.Concat(new Object[]
                {
                    i,
                    " : data  :",
                    oriData,
                    ", curZ : ",
                    num,
                    ", oriZ : ",
                    num2,
                    ", res : ",
                    num3
                }));
                binaryWriter.BaseStream.Seek(bgoverlay_DEF.startOffset, SeekOrigin.Begin);
                binaryWriter.Write(num3);
            }
        }
        String path = "Assets/Resources/" + mapResourcePath + fieldMapModName + ".bgs.bytes";

        File.WriteAllBytes(path, ebgBin);
    }
示例#3
0
        private static void ExportMapSafe(String mapName)
        {
            try
            {
                String relativePath    = FieldMap.GetMapResourcePath(mapName);
                String outputDirectory = Path.Combine(Configuration.Export.Path, relativePath);
                if (Directory.Exists(outputDirectory))
                {
                    Log.Warning($"Export was not skipped because kostyli");
                    //Log.Warning($"[FieldSceneExporter] Export was skipped bacause a directory already exists: [{outputDirectory}].");
                    //return;
                }

                Log.Message("[FieldSceneExporter] Exporting [{0}]...", mapName);

                BGSCENE_DEF scene = new BGSCENE_DEF(true);
                scene.LoadEBG(null, relativePath, mapName);

                //String directoryPath = Path.GetDirectoryName(outputPath);
                Directory.CreateDirectory(outputDirectory);

                Texture2D atlasTexture  = TextureHelper.CopyAsReadable(scene.atlas);
                Int32     factor        = (Int32)scene.SPRITE_W / 16;
                Int32     textureWidth  = (Int32)(scene.overlayList.SelectMany(s => s.spriteList).Max(s => s.offY * factor) + scene.SPRITE_H);
                Int32     textureHeight = (Int32)(scene.overlayList.SelectMany(s => s.spriteList).Max(s => s.offX * factor) + scene.SPRITE_W);

                using (Stream output = File.Create(outputDirectory + "test.psd"))
                {
                    PsdFile file = new PsdFile();
                    file.BitDepth     = 8;
                    file.ChannelCount = 4;
                    file.ColorMode    = PsdColorMode.Rgb;
                    file.RowCount     = textureWidth;
                    file.ColumnCount  = textureHeight;
                    file.Resolution   = new ResolutionInfo
                    {
                        Name = "ResolutionInfo ",

                        HDpi              = new UFixed1616(72, 0),
                        HResDisplayUnit   = ResolutionInfo.ResUnit.PxPerInch,
                        HeightDisplayUnit = ResolutionInfo.Unit.Centimeters,

                        VDpi             = new UFixed1616(72, 0),
                        VResDisplayUnit  = ResolutionInfo.ResUnit.PxPerInch,
                        WidthDisplayUnit = ResolutionInfo.Unit.Centimeters
                    };

                    file.BaseLayer.Name = "Base";
                    for (Int16 i = 0; i < 4; i++)
                    {
                        Channel channel = new Channel(i, file.BaseLayer);
                        channel.ImageCompression = file.ImageCompression;
                        channel.Length           = file.RowCount * Util.BytesPerRow(file.BaseLayer.Rect.Size, file.BitDepth);
                        channel.ImageData        = new Byte[channel.Length];
                        file.BaseLayer.Channels.Add(channel);
                    }

                    file.BaseLayer.Channels.Last().ID = -1;

                    for (Int32 index = scene.overlayList.Count - 1; index >= 0; index--) //scene.overlayList.Count
                    {
                        BGOVERLAY_DEF overlay    = scene.overlayList[index];
                        String        outputPath = outputDirectory + $"Overlay{index}.png";
                        ExportOverlayTest(overlay, atlasTexture, outputPath, scene, file);
                        //return;
                    }

                    file.Save(output, Encoding.UTF8);
                }

                //TextureHelper.WriteTextureToFile(TextureHelper.CopyAsReadable(scene.atlas), outputPath);

                Log.Message("[FieldSceneExporter] Exporting completed successfully.");
            }
            catch (Exception ex)
            {
                Log.Error(ex, "[FieldSceneExporter] Failed to export map [{0}].", mapName);
            }
        }
示例#4
0
        private static void ExportMapSafe(String mapName)
        {
            try
            {
                String relativePath    = FieldMap.GetMapResourcePath(mapName);
                String outputDirectory = Path.Combine(Configuration.Export.Path, relativePath);
                // TODO: uncomment this when all is well
                //if (Directory.Exists(outputDirectory))
                //{

                //    Log.Warning($"[FieldSceneExporter] Export was skipped bacause a directory already exists: [{outputDirectory}].");
                //    //return;
                //}

                Log.Message("[FieldSceneExporter] Exporting [{0}]...", mapName);

                BGSCENE_DEF scene = new BGSCENE_DEF(true);
                scene.LoadResources(null, relativePath, mapName);

                //String directoryPath = Path.GetDirectoryName(outputPath);

                Directory.CreateDirectory(outputDirectory);

                Texture2D atlasTexture  = TextureHelper.CopyAsReadable(scene.atlas);
                Int32     factor        = (Int32)scene.SPRITE_W / 16;
                Int32     textureWidth  = (Int32)(scene.overlayList.SelectMany(s => s.spriteList).Max(s => s.offY * factor) + scene.SPRITE_H);
                Int32     textureHeight = (Int32)(scene.overlayList.SelectMany(s => s.spriteList).Max(s => s.offX * factor) + scene.SPRITE_W);

                using (Stream output = File.Create(outputDirectory + "test.psd"))
                {
                    PsdFile file = new PsdFile();
                    file.BitDepth     = 8;
                    file.ChannelCount = 4;
                    file.ColorMode    = PsdColorMode.Rgb;
                    file.RowCount     = textureWidth;
                    file.ColumnCount  = textureHeight;
                    file.Resolution   = new ResolutionInfo
                    {
                        Name = "ResolutionInfo ",

                        HDpi              = new UFixed1616(72, 0),
                        HResDisplayUnit   = ResolutionInfo.ResUnit.PxPerInch,
                        HeightDisplayUnit = ResolutionInfo.Unit.Centimeters,

                        VDpi             = new UFixed1616(72, 0),
                        VResDisplayUnit  = ResolutionInfo.ResUnit.PxPerInch,
                        WidthDisplayUnit = ResolutionInfo.Unit.Centimeters
                    };

                    file.BaseLayer.Name = "Base";
                    for (Int16 i = 0; i < 4; i++)
                    {
                        Channel channel = new Channel(i, file.BaseLayer);
                        channel.ImageCompression = file.ImageCompression;
                        channel.Length           = file.RowCount * Util.BytesPerRow(file.BaseLayer.Rect.Size, file.BitDepth);
                        channel.ImageData        = new Byte[channel.Length];
                        file.BaseLayer.Channels.Add(channel);
                    }

                    file.BaseLayer.Channels.Last().ID = -1;

                    for (Int32 index = scene.overlayList.Count - 1; index >= 0; index--) //scene.overlayList.Count
                    {
                        BGOVERLAY_DEF overlay    = scene.overlayList[index];
                        String        outputPath = outputDirectory + $"Overlay{index}.png";
                        ExportOverlay(overlay, atlasTexture, outputPath, scene, file);
                    }

                    // get all languages
                    FieldMapLocalizeAreaTitleInfo info = FieldMapInfo.localizeAreaTitle.GetInfo(mapName);
                    if (info != null)
                    {
                        Int32    startOvrIdx  = info.startOvrIdx;
                        Int32    endOvrIdx    = info.endOvrIdx;
                        String[] allLanguages = Configuration.Export.Languages;
                        foreach (var language in allLanguages)
                        {
                            BGSCENE_DEF localeScene = new BGSCENE_DEF(scene.GetUseUpscaleFM());
                            localeScene.LoadLocale(scene, relativePath, mapName, info, language);
                            for (Int32 index = startOvrIdx; index <= endOvrIdx; index++)
                            {
                                BGOVERLAY_DEF overlay    = scene.overlayList[index];
                                String        outputPath = outputDirectory + $"Overlay{index}_{language}.png";
                                ExportOverlay(overlay, atlasTexture, outputPath, scene, file);
                            }
                        }
                    }

                    file.Save(output, Encoding.UTF8);
                }

                string strings            = $"[PsdSection]\nLayerOrder=name\nReversed = 0";
                System.IO.StreamWriter sw = new System.IO.StreamWriter(Path.Combine(outputDirectory, "psd.meta"));
                sw.WriteLine(strings);
                sw.Close();


                TextureHelper.WriteTextureToFile(atlasTexture, Path.Combine(outputDirectory, "atlas.png"));

                Log.Message("[FieldSceneExporter] Exporting completed successfully.");
            }
            catch (Exception ex)
            {
                Log.Error(ex, "[FieldSceneExporter] Failed to export map [{0}].", mapName);
            }
        }