예제 #1
0
 public override void ReplaceChild(Chunk xiFrom, Chunk xiTo)
 {
     if (xiFrom is FlatChunk)
     {
         for (int i = 0; i < Flats.Length; i++)
         {
             if (xiFrom == Flats[i])
             {
                 Flats[i] = (FlatChunk)xiTo;
                 return;
             }
         }
         throw new ArgumentException("xifrom not found!");
     }
     else if (xiFrom == KeyWaypoints)
     {
         KeyWaypoints = (KeyWaypointsChunk)xiTo;
     }
     else if (xiFrom == SteeringImages)
     {
         SteeringImages = (GroupingChunk)xiTo;
     }
     else if (xiFrom == CameraPositions)
     {
         CameraPositions = (GroupingChunk)xiTo;
     }
     else if (xiFrom == BumpImages)
     {
         BumpImages = (GroupingChunk)xiTo;
     }
     else
     {
         throw new ArgumentException("xifrom not found!");
     }
 }
예제 #2
0
        public override List <string> GetDifferences(Chunk xiChunk)
        {
            KeyWaypointsChunk lOther = xiChunk as KeyWaypointsChunk;

            if (!Utils.ArrayCompare(KeySections, lOther.KeySections))
            {
                List <string> lRet = base.GetDifferences(xiChunk);
                lRet.Add("Changed key waypoints");
                return(lRet);
            }

            return(base.GetDifferences(xiChunk));
        }
예제 #3
0
        public void Deserialise(Stream inStr, BinaryReader bin)
        {
            //header
            HeaderString1 = StreamUtils.ReadASCIINullTermString(inStr);
            HeaderString2 = StreamUtils.ReadASCIINullTermString(inStr);
            HeaderShort1  = bin.ReadInt16();
            HeaderShort2  = bin.ReadInt16();
            HeaderByte    = bin.ReadByte();
            int lSheetCount = bin.ReadInt16();

            Flats = new FlatChunk[lSheetCount];
            for (int i = 0; i < lSheetCount; i++)
            {
                Flats[i] = new FlatChunk(bin);
            }

            //key waypoints
            KeyWaypoints = new KeyWaypointsChunk(bin);

            //now the first set of images. I don't really know
            //what these do. They might be referred to by TexMetaData[7]
            short steeringImgCount = bin.ReadInt16();

            SteeringImageChunk[] steeringImages = new SteeringImageChunk[steeringImgCount];
            for (int i = 0; i < steeringImgCount; i++)
            {
                steeringImages[i] = new SteeringImageChunk(i, inStr);
            }
            this.SteeringImages = new GroupingChunk("SteeringImages", steeringImages);

            //now some camera positions:
            short cameraPositionCount = bin.ReadInt16();

            CameraPosChunk[] cameraPositions = new CameraPosChunk[cameraPositionCount];
            for (int i = 0; i < cameraPositionCount; i++)
            {
                cameraPositions[i] = new CameraPosChunk(i, bin);
            }
            this.CameraPositions = new GroupingChunk("CameraPositions", cameraPositions);

            //now the bump map prototypes. These are referred to by TexMetaData[6]
            short bumpImgCount = bin.ReadInt16();

            BumpImageChunk[] bumpImages = new BumpImageChunk[bumpImgCount];
            for (int i = 0; i < bumpImgCount; i++)
            {
                bumpImages[i] = new BumpImageChunk(i, inStr);
            }
            this.BumpImages = new GroupingChunk("BumpImages", bumpImages);

            //now trailing zeroes:
            int lNextByte;

            while (-1 != (lNextByte = inStr.ReadByte()))
            {
                if (lNextByte != 0)
                {
                    throw new DeserialisationException(string.Format("Expecting SHET to be followed by a block of zeroes. Found {0}", lNextByte), inStr.Position);
                }
                TrailingZeroByteCount++;
            }
        }
예제 #4
0
        private void DrawWaypointOverlayLine(
            Graphics g,
            byte xiCurrentWaypoint,
            KeyWaypointsChunk.KeySection xiCurrentKeySection,
            int xNeighbour,
            int yNeighbour,
            Point xiLineStart,
            Point xiLineEnd)
        {
            Color lColor = Color.Transparent;

              // Check for the edge of the flat.
              if (xNeighbour < 0 ||
            yNeighbour < 0 ||
            xNeighbour >= mSubject.Width ||
            yNeighbour >= mSubject.Height)
              {
            lColor = xiCurrentKeySection == null ? Color.White : Color.Red;
              }
              else
              {
            // Compare to neighbouring square
            byte lNeighbourWaypoint =
              mSubject.TexMetaData[xNeighbour][yNeighbour][(byte)eTexMetaDataEntries.Waypoint];

            if (xiCurrentKeySection != null)
            {
              // If this is a key section, outline in red unless the neighbour is in
              // the same section.
              KeyWaypointsChunk.KeySection lNeighbourKeySection =
            mMainForm.CurrentLevel.SHET.GetKeySectionByWaypoint(lNeighbourWaypoint);

              if (xiCurrentKeySection != lNeighbourKeySection)
              {
            lColor = Color.Red;
              }
            }
            else if (lNeighbourWaypoint == 0)
            {
              // For non-key sections, just draw a white border around the
              // waypoint squares. Ideally it should also test whether the neighbour
              // falls into the same non-key section and draw a white line if not,
              // but that's a sufficiently borderline case that it's ignored.
              lColor = Color.White;
            }
              }

              if (lColor != Color.Transparent)
              {
            g.DrawLine(new Pen(lColor), xiLineStart, xiLineEnd);
              }
        }
예제 #5
0
 public override void ReplaceChild(Chunk xiFrom, Chunk xiTo)
 {
     if (xiFrom is FlatChunk)
       {
     for (int i = 0; i < Flats.Length; i++)
       if (xiFrom == Flats[i])
       {
     Flats[i] = (FlatChunk)xiTo;
     return;
       }
     throw new ArgumentException("xifrom not found!");
       }
       else if (xiFrom == KeyWaypoints)
       {
     KeyWaypoints = (KeyWaypointsChunk)xiTo;
       }
       else if (xiFrom == SteeringImages)
       {
     SteeringImages = (GroupingChunk)xiTo;
       }
       else if (xiFrom == CameraPositions)
       {
     CameraPositions = (GroupingChunk)xiTo;
       }
       else if (xiFrom == BumpImages)
       {
     BumpImages = (GroupingChunk)xiTo;
       }
       else
       {
     throw new ArgumentException("xifrom not found!");
       }
 }
예제 #6
0
        public void Deserialise(Stream inStr, BinaryReader bin)
        {
            //header
              HeaderString1 = StreamUtils.ReadASCIINullTermString(inStr);
              HeaderString2 = StreamUtils.ReadASCIINullTermString(inStr);
              HeaderShort1 = bin.ReadInt16();
              HeaderShort2 = bin.ReadInt16();
              HeaderByte = bin.ReadByte();
              int lSheetCount = bin.ReadInt16();

              Flats = new FlatChunk[lSheetCount];
              for (int i = 0; i < lSheetCount; i++)
              {
            Flats[i] = new FlatChunk(bin);
              }

              //key waypoints
              KeyWaypoints = new KeyWaypointsChunk(bin);

              //now the first set of images. I don't really know
              //what these do. They might be referred to by TexMetaData[7]
              short steeringImgCount = bin.ReadInt16();
              SteeringImageChunk[] steeringImages = new SteeringImageChunk[steeringImgCount];
              for (int i = 0; i < steeringImgCount; i++)
              {
            steeringImages[i] = new SteeringImageChunk(i, inStr);
              }
              this.SteeringImages = new GroupingChunk("SteeringImages", steeringImages);

              //now some camera positions:
              short cameraPositionCount = bin.ReadInt16();
              CameraPosChunk[] cameraPositions = new CameraPosChunk[cameraPositionCount];
              for (int i = 0; i < cameraPositionCount; i++)
              {
            cameraPositions[i] = new CameraPosChunk(i, bin);
              }
              this.CameraPositions = new GroupingChunk("CameraPositions", cameraPositions);

              //now the bump map prototypes. These are referred to by TexMetaData[6]
              short bumpImgCount = bin.ReadInt16();
              BumpImageChunk[] bumpImages = new BumpImageChunk[bumpImgCount];
              for (int i = 0; i < bumpImgCount; i++)
              {
            bumpImages[i] = new BumpImageChunk(i, inStr);
              }
              this.BumpImages = new GroupingChunk("BumpImages", bumpImages);

              //now trailing zeroes:
              int lNextByte;
              while (-1 != (lNextByte = inStr.ReadByte()))
              {
            if (lNextByte != 0) throw new DeserialisationException(string.Format("Expecting SHET to be followed by a block of zeroes. Found {0}", lNextByte), inStr.Position);
            TrailingZeroByteCount++;
              }
        }