Esempio n. 1
0
 public FNT0EditorVM(FNT0 fnt)
 {
     this.fnt           = fnt;
     MaxWidth           = fnt.Width;
     MaxHeight          = fnt.Height;
     Glyph.ClipGeometry = new RectangleGeometry(new Rect(0, 0, MaxWidth, MaxWidth));
     OpenFont();
 }
        /// <summary>
        /// Tries to open a file with the specified data type.
        /// </summary>
        /// <param name="name">Name of file</param>
        /// <param name="data">Data of file</param>
        /// <param name="type">Type of file</param>
        /// <returns>Return ObjectContainer for this file or null if an error occurred.</returns>
        public static GameFile OpenFile(string name, byte[] data, FormatEnum type)
        {
            try
            {
                IGameData Obj;

                if (type == FormatEnum.BIN)
                {
                    Obj = new FileContainer.BIN(data);
                }
                else if (type == FormatEnum.SPR)
                {
                    Obj = new SpriteContainer.SPR(data);
                }
                else if (type == FormatEnum.TMX)
                {
                    Obj = new Sprite.TMX(data);
                }
                else if (type == FormatEnum.BF)
                {
                    Obj = new FileContainer.BF(data, name);
                }
                else if (type == FormatEnum.PM1)
                {
                    Obj = new FileContainer.PM1(data);
                }
                else if (type == FormatEnum.BMD)
                {
                    Obj = new Text.BMD(data);
                }
                else if (type == FormatEnum.PTP)
                {
                    Obj = new Text.PTP(data);
                }
                else if (type == FormatEnum.FNT)
                {
                    Obj = new FNT(data);
                }
                else if (type == FormatEnum.FNT0)
                {
                    Obj = new FNT0(data);
                }
                else if (type == FormatEnum.BVP)
                {
                    Obj = new FileContainer.BVP(name, data);
                }
                else if (type == FormatEnum.TBL)
                {
                    try
                    {
                        Obj = new FileContainer.TBL(data, name);
                    }
                    catch
                    {
                        Obj = new FileContainer.BIN(data);
                    }
                }
                else if (type == FormatEnum.FTD)
                {
                    Obj = new FTD(data);
                }
                else if (type == FormatEnum.DDS)
                {
                    try
                    {
                        Obj = new Sprite.DDS(data);
                    }
                    catch
                    {
                        Obj = new Sprite.DDSAtlus(data);
                    }
                }
                else if (type == FormatEnum.SPD)
                {
                    Obj = new SpriteContainer.SPD(data);
                }
                else
                {
                    Obj = new DAT(data);
                }

                return(new GameFile(name, Obj));
            }
            catch
            {
                return(null);
            }
        }