示例#1
0
        /// <summary>Initializes <see cref="Rmap"/> using the contents of the LfdFile. If Rmap is already defined, it is updated</summary>
        /// <remarks>Processes individual <see cref="Resource.EncodeResource"/> functions, thus updating all <see cref="Resource.RawData"/> properties</remarks>
        public void CreateRmap()
        {
            if (_lfdCategory == LfdCategory.Cockpit)
            {
                throw new ArgumentException(_cockpitRmapErrorMessage);
            }
            string name = null;

            if (_rmp != null)
            {
                name = _rmp.Name;
            }
            _encodeResources();
            if (_lfdCategory == LfdCategory.Battle)
            {
                _rmp = new Rmap(_lfdCategory);
            }
            else
            {
                _rmp = new Rmap(_resources.Count);
            }
            for (int i = 0; i < _rmp.NumberOfHeaders; i++)
            {
                _rmp.SubHeaders[i].Type   = _resources[i].Type;
                _rmp.SubHeaders[i].Name   = _resources[i].Name;
                _rmp.SubHeaders[i].Length = _resources[i].Length;
                _rmp.SubHeaders[i].Offset = Resource.HeaderLength +
                                            (i > 0 ? _rmp.SubHeaders[i - 1].Offset + _rmp.SubHeaders[i - 1].Length : 0);
            }
            if (name != null)
            {
                _rmp.Name = name;
            }
            _rmp.EncodeResource();
        }
示例#2
0
 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);
     }
 }
示例#3
0
 /// <summary>Creates an empty file with the appropriate file structure</summary>
 /// <param name="category">Preset type</param>
 /// <remarks><see cref="Rmap"/> and <see cref="Resources"/> are initialized accordingly.</remarks>
 public LfdFile(LfdCategory category)
 {
     _resources = new ResourceCollection(category);
     if (category == LfdCategory.Battle)
     {
         _rmp = new Rmap(category);
     }
     _lfdCategory = category;
 }
示例#4
0
 /// <summary>Creates an empty file with the appropriate file structure</summary>
 /// <param name="category">Preset type</param>
 /// <remarks><see cref="Rmap"/> and <see cref="Resources"/> are initialized accordingly.</remarks>
 public LfdFile(LfdCategory category)
 {
     _resources = new ResourceCollection(category);
     if (category == LfdCategory.Battle) _rmp = new Rmap(category);
     _lfdCategory = category;
 }
示例#5
0
 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);
     }
 }
示例#6
0
 /// <summary>Initializes <see cref="Rmap"/> using the contents of the LfdFile. If Rmap is already defined, it is updated</summary>
 /// <remarks>Processes individual <see cref="Resource.EncodeResource"/> functions, thus updating all <see cref="Resource.RawData"/> properties</remarks>
 public void CreateRmap()
 {
     if (_lfdCategory == LfdCategory.Cockpit) throw new ArgumentException(_cockpitRmapErrorMessage);
     string name = null;
     if (_rmp != null) name = _rmp.Name;
     _encodeResources();
     if (_lfdCategory == LfdCategory.Battle) _rmp = new Rmap(_lfdCategory);
     else _rmp = new Rmap(_resources.Count);
     for (int i = 0; i < _rmp.NumberOfHeaders; i++)
     {
         _rmp.SubHeaders[i].Type = _resources[i].Type;
         _rmp.SubHeaders[i].Name = _resources[i].Name;
         _rmp.SubHeaders[i].Length = _resources[i].Length;
         _rmp.SubHeaders[i].Offset = Resource.HeaderLength +
             (i > 0 ? _rmp.SubHeaders[i - 1].Offset + _rmp.SubHeaders[i - 1].Length : 0);
     }
     if (name != null) _rmp.Name = name;
     _rmp.EncodeResource();
 }