コード例 #1
0
ファイル: LfdFile.cs プロジェクト: Happy-Ferret/LfdReader
 void _read(FileStream stream)
 {
     _filePath = stream.Name;
     //System.Diagnostics.Debug.WriteLine("Creating " + FileName);
     if (Resource.GetType(stream, 0) == Resource.ResourceType.Rmap)
     {
         _rmp = new Rmap(stream);
         //System.Diagnostics.Debug.WriteLine("Rmap created");
         _resources = new ResourceCollection(_rmp.NumberOfHeaders);
         for (int i = 0; i < _resources.Count; i++)
         {
             //System.Diagnostics.Debug.WriteLine("Create " + _rmp.SubHeaders[i].Type.ToString() + " " + _rmp.SubHeaders[i].Name + " (" + (i+1) + "/" + _rmp.NumberOfHeaders + ")");
             _assignResource(i, _rmp.SubHeaders[i].Type, stream, _rmp.SubHeaders[i].Offset);
         }
         if (_resources.Count == 2 && _resources[0].Name.StartsWith("battle") && _resources[1].Name.EndsWith("gal"))
         {
             _lfdCategory = LfdCategory.Battle;
         }
     }
     else if (Resource.GetType(stream, 0) == Resource.ResourceType.Panl)
     {
         //System.Diagnostics.Debug.WriteLine("cockpit LFD");
         _lfdCategory  = LfdCategory.Cockpit;
         _resources    = new ResourceCollection(3);
         _resources[0] = new Panl(stream, 0);
         _resources[1] = new Mask(stream, Resource.HeaderLength + _resources[0].Length);
         _resources[2] = new Pltt(stream, Resource.HeaderLength * 2 + _resources[0].Length + _resources[1].Length);
     }
     else
     {
         _resources = new ResourceCollection(1);
         _assignResource(0, Resource.GetType(stream, 0), stream, 0);
         //System.Diagnostics.Debug.WriteLine("Solo resource " + _resources[0].Type + " " + _resources[0].Name);
     }
 }
コード例 #2
0
ファイル: Delt.cs プロジェクト: gtraines/LfdReader
        /// <summary>Creates a new instance from an exsiting file with the supplied Palette array</summary>
        /// <param name="path">The full path to the unopened LFD file</param>
        /// <param name="filePosition">The offset of the beginning of the resource</param>
        /// <param name="palettes">The colors used for the resource</param>
        /// <exception cref="Idmr.Common.LoadFileException">Typically due to file corruption</exception>
        public Delt(string path, long filePosition, Pltt[] palettes)
        {
            _palette = Pltt.ConvertToPalette(palettes);
            FileStream stream = File.OpenRead(path);

            _read(stream, filePosition);
            stream.Close();
        }
コード例 #3
0
ファイル: LfdFile.cs プロジェクト: Happy-Ferret/LfdReader
 void _assignResource(int index, Resource.ResourceType type, FileStream stream, long offset)
 {
     // commented out types redirect to Resource to read and capture _rawData
     if (type == Resource.ResourceType.Anim)
     {
         _resources[index] = new Anim(stream, offset);
     }
     else if (type == Resource.ResourceType.Blas || type == Resource.ResourceType.Voic)
     {
         _resources[index] = new Blas(stream, offset);
     }
     //TODO: else if (type == Resource.ResourceType.Bmap) _resources[index] = new Bmap(stream, offset);
     //TODO: else if (type == Resource.ResourceType.Cust) _resources[index] = new Cust(stream, offset);
     else if (type == Resource.ResourceType.Delt)
     {
         _resources[index] = new Delt(stream, offset);
     }
     else if (type == Resource.ResourceType.Film)
     {
         _resources[index] = new Film(stream, offset);
     }
     else if (type == Resource.ResourceType.Font)
     {
         _resources[index] = new Font(stream, offset);
     }
     //TODO: else if (type == Resource.ResourceType.Gmid) _resources[index] = new Gmid(stream, offset);
     else if (type == Resource.ResourceType.Mask)
     {
         _resources[index] = new Mask(stream, offset);
     }
     //TODO: else if (type == Resource.ResourceType.Mtrx) _resources[index] = new Mtrx(stream, offset);
     else if (type == Resource.ResourceType.Panl)
     {
         _resources[index] = new Panl(stream, offset);
     }
     else if (type == Resource.ResourceType.Pltt)
     {
         _resources[index] = new Pltt(stream, offset);
     }
     // skip Rmap
     //TODO: else if (type == Resource.ResourceType.Ship) _resources[index] = new Ship(stream, offset);
     else if (type == Resource.ResourceType.Text)
     {
         _resources[index] = new Text(stream, offset);
     }
     else if (type == Resource.ResourceType.Xact)
     {
         _resources[index] = new Xact(stream, offset);
     }
     else
     {
         _resources[index] = new Resource(stream, offset);
     }
 }
コード例 #4
0
ファイル: Delt.cs プロジェクト: gtraines/LfdReader
 /// <summary>Creates a new instance from an existing opened file with the supplied Palette array</summary>
 /// <param name="stream">The opened LFD file</param>
 /// <param name="filePosition">The offset of the beginning of the resource</param>
 /// <param name="palettes">The colors used for the resource</param>
 /// <exception cref="Idmr.Common.LoadFileException">Typically due to file corruption</exception>
 public Delt(FileStream stream, long filePosition, Pltt[] palettes)
 {
     _palette = Pltt.ConvertToPalette(palettes);
     _read(stream, filePosition);
 }
コード例 #5
0
 /// <summary>Initializes the indexer</summary>
 /// <param name="parent">The parent resource</param>
 internal ColorIndexer(Pltt parent)
 {
     _parent = parent;
     _items  = _parent._entries;
 }
コード例 #6
0
ファイル: Pltt.cs プロジェクト: MikeG621/LfdReader
 /// <summary>Generates a ColorPalette from multiple Pltt resources</summary>
 /// <param name="resources">The resources used to create the palette</param>
 /// <returns>A single ColorPalette to be applied to an image</returns>
 /// <remarks>Unused colors are set to <see cref="Color.Transparent"/>.</remarks>
 public static ColorPalette ConvertToPalette(Pltt[] resources)
 {
     ColorPalette palette = new Bitmap(1, 1, PixelFormat.Format8bppIndexed).Palette;
     for (int i = 0; i < 256; i++) palette.Entries[i] = Color.Transparent;
     foreach (Pltt p in resources)
         for (int i = p.StartIndex; i <= p.EndIndex; i++)
             palette.Entries[i] = p.Entries[i];
     return palette;
 }
コード例 #7
0
ファイル: Delt.cs プロジェクト: MikeG621/LfdReader
 /// <summary>Creates a new instance from an exsiting file with the supplied Palette array</summary>
 /// <param name="path">The full path to the unopened LFD file</param>
 /// <param name="filePosition">The offset of the beginning of the resource</param>
 /// <param name="palettes">The colors used for the resource</param>
 /// <exception cref="Idmr.Common.LoadFileException">Typically due to file corruption</exception>
 public Delt(string path, long filePosition, Pltt[] palettes)
 {
     _palette = Pltt.ConvertToPalette(palettes);
     FileStream stream = File.OpenRead(path);
     _read(stream, filePosition);
     stream.Close();
 }
コード例 #8
0
ファイル: LfdFile.cs プロジェクト: MikeG621/LfdReader
 void _read(FileStream stream)
 {
     _filePath = stream.Name;
     //System.Diagnostics.Debug.WriteLine("Creating " + FileName);
     if (Resource.GetType(stream, 0) == Resource.ResourceType.Rmap)
     {
         _rmp = new Rmap(stream);
         //System.Diagnostics.Debug.WriteLine("Rmap created");
         _resources = new ResourceCollection(_rmp.NumberOfHeaders);
         for (int i = 0; i < _resources.Count; i++)
         {
             //System.Diagnostics.Debug.WriteLine("Create " + _rmp.SubHeaders[i].Type.ToString() + " " + _rmp.SubHeaders[i].Name + " (" + (i+1) + "/" + _rmp.NumberOfHeaders + ")");
             _assignResource(i, _rmp.SubHeaders[i].Type, stream, _rmp.SubHeaders[i].Offset);
         }
         if (_resources.Count == 2 && _resources[0].Name.StartsWith("battle") && _resources[1].Name.EndsWith("gal"))
             _lfdCategory = LfdCategory.Battle;
     }
     else if (Resource.GetType(stream, 0) == Resource.ResourceType.Panl)
     {
         //System.Diagnostics.Debug.WriteLine("cockpit LFD");
         _lfdCategory = LfdCategory.Cockpit;
         _resources = new ResourceCollection(3);
         _resources[0] = new Panl(stream, 0);
         _resources[1] = new Mask(stream, Resource.HeaderLength + _resources[0].Length);
         _resources[2] = new Pltt(stream, Resource.HeaderLength * 2 + _resources[0].Length + _resources[1].Length);
     }
     else
     {
         _resources = new ResourceCollection(1);
         _assignResource(0, Resource.GetType(stream, 0), stream, 0);
         //System.Diagnostics.Debug.WriteLine("Solo resource " + _resources[0].Type + " " + _resources[0].Name);
     }
 }
コード例 #9
0
ファイル: Delt.cs プロジェクト: MikeG621/LfdReader
 /// <summary>Creates a new instance from an existing opened file with the supplied Palette array</summary>
 /// <param name="stream">The opened LFD file</param>
 /// <param name="filePosition">The offset of the beginning of the resource</param>
 /// <param name="palettes">The colors used for the resource</param>
 /// <exception cref="Idmr.Common.LoadFileException">Typically due to file corruption</exception>
 public Delt(FileStream stream, long filePosition, Pltt[] palettes)
 {
     _palette = Pltt.ConvertToPalette(palettes);
     _read(stream, filePosition);
 }
コード例 #10
0
ファイル: LfdFile.cs プロジェクト: MikeG621/LfdReader
 void _assignResource(int index, Resource.ResourceType type, FileStream stream, long offset)
 {
     // commented out types redirect to Resource to read and capture _rawData
     if (type == Resource.ResourceType.Anim) _resources[index] = new Anim(stream, offset);
     else if (type == Resource.ResourceType.Blas || type == Resource.ResourceType.Voic) _resources[index] = new Blas(stream, offset);
     //TODO: else if (type == Resource.ResourceType.Bmap) _resources[index] = new Bmap(stream, offset);
     //TODO: else if (type == Resource.ResourceType.Cust) _resources[index] = new Cust(stream, offset);
     else if (type == Resource.ResourceType.Delt) _resources[index] = new Delt(stream, offset);
     else if (type == Resource.ResourceType.Film) _resources[index] = new Film(stream, offset);
     else if (type == Resource.ResourceType.Font) _resources[index] = new Font(stream, offset);
     //TODO: else if (type == Resource.ResourceType.Gmid) _resources[index] = new Gmid(stream, offset);
     else if (type == Resource.ResourceType.Mask) _resources[index] = new Mask(stream, offset);
     //TODO: else if (type == Resource.ResourceType.Mtrx) _resources[index] = new Mtrx(stream, offset);
     else if (type == Resource.ResourceType.Panl) _resources[index] = new Panl(stream, offset);
     else if (type == Resource.ResourceType.Pltt) _resources[index] = new Pltt(stream, offset);
     // skip Rmap
     //TODO: else if (type == Resource.ResourceType.Ship) _resources[index] = new Ship(stream, offset);
     else if (type == Resource.ResourceType.Text) _resources[index] = new Text(stream, offset);
     else if (type == Resource.ResourceType.Xact) _resources[index] = new Xact(stream, offset);
     else _resources[index] = new Resource(stream, offset);
 }
コード例 #11
0
 /// <summary>Sets the colors used for the Anim</summary>
 /// <param name="palettes">The colors to be used</param>
 /// <remarks>All <see cref="Frame.Image">Images</see> are updated</remarks>
 public void SetPalette(Pltt[] palettes)
 {
     SetPalette(Pltt.ConvertToPalette(palettes));
 }
コード例 #12
0
ファイル: Anim.cs プロジェクト: MikeG621/LfdReader
 /// <summary>Creates a new instance from an existing opened file with the supplied Palette array</summary>
 /// <param name="stream">The opened LFD file</param>
 /// <param name="filePosition">The offset of the beginning of the resource</param>
 /// <param name="palettes">The colors used for the resource</param>
 /// <exception cref="Idmr.Common.LoadFileException">Typically due to file corruption</exception>
 public Anim(FileStream stream, long filePosition, Pltt[] palettes)
 {
     _palette = new Bitmap(1, 1, PixelFormat.Format8bppIndexed).Palette;
     _read(stream, filePosition);
     SetPalette(palettes);
 }
コード例 #13
0
ファイル: Anim.cs プロジェクト: MikeG621/LfdReader
 /// <summary>Sets the colors used for the Anim</summary>
 /// <param name="palettes">The colors to be used</param>
 /// <remarks>All <see cref="Frame.Image">Images</see> are updated</remarks>
 public void SetPalette(Pltt[] palettes)
 {
     SetPalette(Pltt.ConvertToPalette(palettes));
 }
コード例 #14
0
ファイル: Anim.cs プロジェクト: MikeG621/LfdReader
 /// <summary>Creates a new instance from an exsiting file with the supplied Palette array</summary>
 /// <param name="path">The full path to the unopened LFD file</param>
 /// <param name="filePosition">The offset of the beginning of the resource</param>
 /// <param name="palettes">The colors used for the resource</param>
 /// <exception cref="Idmr.Common.LoadFileException">Typically due to file corruption</exception>
 public Anim(string path, long filePosition, Pltt[] palettes)
 {
     FileStream stream = File.OpenRead(path);
     _read(stream, filePosition);
     stream.Close();
     SetPalette(palettes);
 }