コード例 #1
0
    public void Load()
    {
        String       name         = "EmbeddedAsset/Manifest/FieldMap/mapLocalizeAreaTitle.txt";
        TextAsset    textAsset    = AssetManager.Load <TextAsset>(name, false);
        StringReader stringReader = new StringReader(textAsset.text);
        String       text;

        while ((text = stringReader.ReadLine()) != null)
        {
            String[] array = text.Split(new Char[]
            {
                ','
            });
            FieldMapLocalizeAreaTitleInfo fieldMapLocalizeAreaTitleInfo = new FieldMapLocalizeAreaTitleInfo();
            fieldMapLocalizeAreaTitleInfo.mapName = array[0];
            Int32.TryParse(array[1], out fieldMapLocalizeAreaTitleInfo.atlasWidth);
            Int32.TryParse(array[2], out fieldMapLocalizeAreaTitleInfo.atlasHeight);
            Int32.TryParse(array[3], out fieldMapLocalizeAreaTitleInfo.startOvrIdx);
            Int32.TryParse(array[4], out fieldMapLocalizeAreaTitleInfo.endOvrIdx);
            Int32 num = 0;
            Int32.TryParse(array[5], out num);
            fieldMapLocalizeAreaTitleInfo.hasUK = (num == 1);
            Int32 num2 = 6;
            Int32 num3 = 3;
            for (Int32 i = 0; i < 7; i++)
            {
                Int32 num4 = i * num3 + num2;
                Int32.TryParse(array[num4 + 1], out fieldMapLocalizeAreaTitleInfo.data[i * 2]);
                Int32.TryParse(array[num4 + 2], out fieldMapLocalizeAreaTitleInfo.data[i * 2 + 1]);
            }
            this.dict.Add(fieldMapLocalizeAreaTitleInfo.mapName, fieldMapLocalizeAreaTitleInfo);
        }
    }
コード例 #2
0
    private void _LoadDummyEBG(BGSCENE_DEF sceneUS, String path, String newName, FieldMapLocalizeAreaTitleInfo info, String localizeSymbol)
    {
        this.name = newName;
        TextAsset textAsset = AssetManager.Load <TextAsset>(String.Concat(path, newName, "_", localizeSymbol, ".bgs"), false);

        if (textAsset == null)
        {
            return;
        }
        this.ebgBin = textAsset.bytes;
        using (BinaryReader binaryReader = new BinaryReader(new MemoryStream(this.ebgBin)))
        {
            this.ExtractHeaderData(binaryReader);
            this.ExtractOverlayData(binaryReader);
            Int32 atlasWidth       = info.atlasWidth;
            Int32 startOvrIdx      = info.startOvrIdx;
            Int32 endOvrIdx        = info.endOvrIdx;
            Int32 spriteStartIndex = info.GetSpriteStartIndex(localizeSymbol);
            Int32 num  = atlasWidth / 36;
            Int32 num2 = spriteStartIndex;
            for (Int32 i = startOvrIdx; i <= endOvrIdx; i++)
            {
                BGOVERLAY_DEF bGOVERLAY_DEF = this.overlayList[i];
                binaryReader.BaseStream.Seek(bGOVERLAY_DEF.prmOffset, SeekOrigin.Begin);
                for (Int32 j = 0; j < (Int32)bGOVERLAY_DEF.spriteCount; j++)
                {
                    BGSPRITE_LOC_DEF bGSPRITE_LOC_DEF = new BGSPRITE_LOC_DEF();
                    bGSPRITE_LOC_DEF.ReadData_BGSPRITE_DEF(binaryReader);
                    bGOVERLAY_DEF.spriteList.Add(bGSPRITE_LOC_DEF);
                }
                binaryReader.BaseStream.Seek(bGOVERLAY_DEF.locOffset, SeekOrigin.Begin);
                for (Int32 k = 0; k < (Int32)bGOVERLAY_DEF.spriteCount; k++)
                {
                    BGSPRITE_LOC_DEF bGSPRITE_LOC_DEF2 = bGOVERLAY_DEF.spriteList[k];
                    bGSPRITE_LOC_DEF2.ReadData_BGSPRITELOC_DEF(binaryReader);
                    if (this.useUpscaleFM)
                    {
                        bGSPRITE_LOC_DEF2.atlasX = (UInt16)(2 + num2 % num * 36);
                        bGSPRITE_LOC_DEF2.atlasY = (UInt16)(2 + num2 / num * 36);
                        bGSPRITE_LOC_DEF2.w      = 32;
                        bGSPRITE_LOC_DEF2.h      = 32;
                        num2++;
                    }
                }
            }
            for (Int32 l = startOvrIdx; l <= endOvrIdx; l++)
            {
                sceneUS.overlayList[l] = this.overlayList[l];
            }
        }
    }
コード例 #3
0
    public void LoadEBG(FieldMap fieldMap, String path, String newName)
    {
        this.name = newName;
        if (!this.useUpscaleFM)
        {
            this.InitPSXTextureAtlas();
        }
        else
        {
            Texture2D x = AssetManager.Load <Texture2D>(Path.Combine(path, "atlas"), false);
            if (x != null)
            {
                this.atlas = x;
                if (Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.WindowsEditor)
                {
                    this.atlasAlpha = AssetManager.Load <Texture2D>(Path.Combine(path, "atlas_a"), false);
                }
                else
                {
                    this.atlasAlpha = null;
                }
                this.SPRITE_W = 32u;
                this.SPRITE_H = 32u;
            }
            else
            {
                this.useUpscaleFM = false;
                this.InitPSXTextureAtlas();
            }
        }
        if (!this.useUpscaleFM)
        {
            this.vram.LoadTIMs(path);
        }
        TextAsset textAsset;

        if (!FieldMapEditor.useOriginalVersion)
        {
            textAsset = AssetManager.Load <TextAsset>(path + FieldMapEditor.GetFieldMapModName(newName) + ".bgs", false);
            if (textAsset == null)
            {
                Debug.Log("Cannot find MOD version.");
                textAsset = AssetManager.Load <TextAsset>(path + newName + ".bgs", false);
            }
        }
        else
        {
            textAsset = AssetManager.Load <TextAsset>(path + newName + ".bgs", false);
        }

        if (textAsset == null)
        {
            return;
        }

        this.ebgBin = textAsset.bytes;
        using (BinaryReader binaryReader = new BinaryReader(new MemoryStream(this.ebgBin)))
        {
            this.ReadData(binaryReader);
        }
        String symbol = Localization.GetSymbol();

        if (symbol != "US")
        {
            FieldMapLocalizeAreaTitleInfo info = FieldMapInfo.localizeAreaTitle.GetInfo(newName);
            if (info != null)
            {
                if (symbol != "UK" || info.hasUK)
                {
                    BGSCENE_DEF bGSCENE_DEF = new BGSCENE_DEF(this.useUpscaleFM);
                    bGSCENE_DEF._LoadDummyEBG(this, path, newName, info, symbol);
                }
            }
        }
        FieldMapInfo.fieldmapExtraOffset.SetOffset(newName, this.overlayList);
        if (!this.useUpscaleFM)
        {
            this.GenerateAtlasFromBinary();
        }

        this.CreateMaterials();
        if (fieldMap != null)
        {
            this.CreateScene(fieldMap, this.useUpscaleFM);
        }
    }
コード例 #4
0
ファイル: FieldSceneExporter.cs プロジェクト: ArtReeX/memoria
        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);
            }
        }