Example #1
0
        private void AddObjectToTable(FlatChunk.ObjectEntry xiObject)
        {
            Panel.ObjectsTable.RowStyles.Add(new RowStyle(SizeType.AutoSize));

              TextBox lTypeBox = new TextBox();
              lTypeBox.Text = xiObject.ObjtType.ToString();
              lTypeBox.Width = 60;
              Panel.ObjectsTable.Controls.Add(lTypeBox);

              TextBox lXBox = new TextBox();
              lXBox.Text = xiObject.OriginPosition.X.ToString();
              lXBox.Width = 60;
              Panel.ObjectsTable.Controls.Add(lXBox);

              TextBox lYBox = new TextBox();
              lYBox.Text = xiObject.OriginPosition.Y.ToString();
              lYBox.Width = 60;
              Panel.ObjectsTable.Controls.Add(lYBox);

              TextBox lZBox = new TextBox();
              lZBox.Text = xiObject.OriginPosition.Z.ToString();
              lZBox.Width = 60;
              Panel.ObjectsTable.Controls.Add(lZBox);

              TextBox lRXBox = new TextBox();
              lRXBox.Text = xiObject.RotationVector.X.ToString();
              lRXBox.Width = 60;
              Panel.ObjectsTable.Controls.Add(lRXBox);

              TextBox lRYBox = new TextBox();
              lRYBox.Text = xiObject.RotationVector.Y.ToString();
              lRYBox.Width = 60;
              Panel.ObjectsTable.Controls.Add(lRYBox);

              TextBox lRZBox = new TextBox();
              lRZBox.Text = xiObject.RotationVector.Z.ToString();
              lRZBox.Width = 60;
              Panel.ObjectsTable.Controls.Add(lRZBox);

              CheckBox lSolidBox = new CheckBox();
              lSolidBox.Checked = xiObject.IsSolid;
              lSolidBox.Text = "";
              lSolidBox.AutoSize = true;
              Panel.ObjectsTable.Controls.Add(lSolidBox);

              CheckBox lUnkBox1 = new CheckBox();
              lUnkBox1.Checked = xiObject.FlagUnknown;
              lUnkBox1.Text = "";
              lUnkBox1.AutoSize = true;
              Panel.ObjectsTable.Controls.Add(lUnkBox1);

              TextBox lUnkBox2 = new TextBox();
              lUnkBox2.Text = xiObject.ShortUnknown.ToString();
              lUnkBox2.Width = 60;
              lUnkBox2.AutoSize = true;
              Panel.ObjectsTable.Controls.Add(lUnkBox2);

              LinkLabel lDeleteLink = new LinkLabel();
              lDeleteLink.Text = "Delete";
              lDeleteLink.Click += new EventHandler(delegate(object xiSender, System.EventArgs xiArgs)
              {
            Panel.ObjectsTable.SuspendLayout();
            Panel.ObjectsTable.RowStyles.RemoveAt(1);
            Panel.ObjectsTable.Controls.Remove(lTypeBox);
            Panel.ObjectsTable.Controls.Remove(lXBox);
            Panel.ObjectsTable.Controls.Remove(lYBox);
            Panel.ObjectsTable.Controls.Remove(lZBox);
            Panel.ObjectsTable.Controls.Remove(lRXBox);
            Panel.ObjectsTable.Controls.Remove(lRYBox);
            Panel.ObjectsTable.Controls.Remove(lRZBox);
            Panel.ObjectsTable.Controls.Remove(lSolidBox);
            Panel.ObjectsTable.Controls.Remove(lUnkBox1);
            Panel.ObjectsTable.Controls.Remove(lUnkBox2);
            Panel.ObjectsTable.Controls.Remove(lDeleteLink);
            Panel.ObjectsTable.ResumeLayout();
              });
              Panel.ObjectsTable.Controls.Add(lDeleteLink);
        }
Example #2
0
        private void AddWeaponToTable(FlatChunk.WeaponEntry xiWeapon)
        {
            Panel.WeaponsTable.RowStyles.Add(new RowStyle(SizeType.AutoSize));

              ComboBox lWeaponTypeBox = new ComboBox();
              lWeaponTypeBox.Items.AddRange(Enum.GetNames(typeof(eWeaponType)));
              lWeaponTypeBox.Text = xiWeapon.WeaponType.ToString();
              lWeaponTypeBox.Width = 120;
              Panel.WeaponsTable.Controls.Add(lWeaponTypeBox);

              TextBox lUnknownBox = new TextBox();
              lUnknownBox.Text = xiWeapon.ShortUnknown.ToString();
              lUnknownBox.Width = 60;
              Panel.WeaponsTable.Controls.Add(lUnknownBox);

              TextBox lXBox = new TextBox();
              lXBox.Text = xiWeapon.OriginPosition.X.ToString();
              lXBox.Width = 60;
              Panel.WeaponsTable.Controls.Add(lXBox);

              TextBox lYBox = new TextBox();
              lYBox.Text = xiWeapon.OriginPosition.Y.ToString();
              lYBox.Width = 60;
              Panel.WeaponsTable.Controls.Add(lYBox);

              TextBox lZBox = new TextBox();
              lZBox.Text = xiWeapon.OriginPosition.Z.ToString();
              lZBox.Width = 60;
              Panel.WeaponsTable.Controls.Add(lZBox);

              LinkLabel lDeleteLink = new LinkLabel();
              lDeleteLink.Text = "Delete";
              lDeleteLink.Click += new EventHandler(delegate(object xiSender, System.EventArgs xiArgs)
              {
            Panel.WeaponsTable.SuspendLayout();
            Panel.WeaponsTable.RowStyles.RemoveAt(1);
            Panel.WeaponsTable.Controls.Remove(lWeaponTypeBox);
            Panel.WeaponsTable.Controls.Remove(lUnknownBox);
            Panel.WeaponsTable.Controls.Remove(lXBox);
            Panel.WeaponsTable.Controls.Remove(lYBox);
            Panel.WeaponsTable.Controls.Remove(lZBox);
            Panel.WeaponsTable.Controls.Remove(lDeleteLink);
            Panel.WeaponsTable.ResumeLayout();
              });
              Panel.WeaponsTable.Controls.Add(lDeleteLink);
        }
Example #3
0
        public override void SetSubject(Chunk xiChunk)
        {
            mSubject = xiChunk as FlatChunk;

              if (mSubject != null)
              {
            Level lLevel = mMainForm.CurrentLevel;

            Panel.SuspendLayout();
            Panel.WeaponsTable.SuspendLayout();
            Panel.ObjectsTable.SuspendLayout();

            //=====================================================================
            // Set the general Flat properties
            //=====================================================================
            Panel.IdTextBox.Text = mSubject.DeclaredIdx.ToString();
            Panel.NameTextBox.Text = mSubject.DeclaredName;
            Panel.OriginXTextBox.Text = mSubject.OriginPosition.X.ToString();
            Panel.OriginYTextBox.Text = mSubject.OriginPosition.Y.ToString();
            Panel.OriginZTextBox.Text = mSubject.OriginPosition.Z.ToString();
            Panel.RotationXTextBox.Text = mSubject.RotationVector.X.ToString();
            Panel.RotationYTextBox.Text = mSubject.RotationVector.Y.ToString();
            Panel.RotationZTextBox.Text = mSubject.RotationVector.Z.ToString();
            Panel.WidthTextBox.Text = mSubject.Width.ToString();
            Panel.HeightTextBox.Text = mSubject.Height.ToString();
            Panel.ScaleXTextBox.Text = mSubject.ScaleX.ToString();
            Panel.ScaleYTextBox.Text = mSubject.ScaleY.ToString();
            Panel.HasMetaDataCheckBox.Checked = mSubject.HasMetaData;
            Panel.FlagBCheckBox.Checked = mSubject.FlgB;
            Panel.FlagCCheckBox.Checked = mSubject.FlgC;
            Panel.VisibleCheckBox.Checked = mSubject.Visible;
            Panel.FlagECheckBox.Checked = mSubject.FlgE;
            Panel.NextNTextBox.Text = ArrayToString(mSubject.NextN);
            Panel.ByteSizeLabel.Text = string.Format("{0} bytes ({1} bytes free)", mSubject.ByteSize, lLevel.SHET.TrailingZeroByteCount);

            //=====================================================================
            // Set up the Weapons section
            //=====================================================================
            while (Panel.WeaponsTable.RowStyles.Count > 1)
            {
              Panel.WeaponsTable.RowStyles.RemoveAt(1);
              for (int ii = 0; ii < 6; ii++)
              {
            Panel.WeaponsTable.Controls.RemoveAt(6);
              }
            }

            if (mSubject.Weapons != null)
            {
              foreach (FlatChunk.WeaponEntry lWeapon in mSubject.Weapons)
              {
            AddWeaponToTable(lWeapon);
              }
            }

            //=====================================================================
            // Set up the Objects section
            //=====================================================================
            while (Panel.ObjectsTable.RowStyles.Count > 1)
            {
              Panel.ObjectsTable.RowStyles.RemoveAt(1);
              for (int ii = 0; ii < 11; ii++)
              {
            Panel.ObjectsTable.Controls.RemoveAt(11);
              }
            }

            if (mSubject.Objects != null)
            {
              foreach (FlatChunk.ObjectEntry lObject in mSubject.Objects)
              {
            AddObjectToTable(lObject);
              }
            }

            Panel.ObjectsTable.ResumeLayout();
            Panel.WeaponsTable.ResumeLayout();
            Panel.ResumeLayout();
              }
        }
Example #4
0
        public override void SetSubject(Chunk xiChunk)
        {
            if (!(xiChunk is FlatChunk)) xiChunk = null;
              if (mSubject == xiChunk) return;
              mSubject = (FlatChunk)xiChunk;

              mWireFrameCache = null;

              if (xiChunk == null)
              {
            mMainForm.GridDisplayPanel.Width = 100;
            mMainForm.GridDisplayPanel.Height = 100;
            mMainForm.GridDisplayPanel.Controls.Clear();
              }
              else
              {
            //find the width and height of the tex components
            short topLeftTexIdx = mSubject.TextureIds[0][0];
            TIMChunk firstTim = mMainForm.CurrentLevel.GetTileById(topLeftTexIdx);
            mSubjectTileNativeHeight = firstTim.ImageHeight;
            mSubjectTileNativeWidth = firstTim.ImageWidth;
            UpdateZoom();

            //init the selected image display boxes
            const int PADDING = 5, IMG_X_OFF = 32;
            object[] keys = new object[] { MouseButtons.Left, MouseButtons.Right, '1', '2', '3', '4', 'q', 'w', 'e', 'r' };
            mMainForm.GridViewSelPanel.Size = new Size(IMG_X_OFF + PADDING + 64, (64 + PADDING) * keys.Length);
            for (int i = 0; i < keys.Length; i++)
            {
              object key = keys[i];
              if (!mKeyOrMouseToSelPicBoxDict.ContainsKey(key))
              {
            Label lab = new Label();
            lab.Text = (MouseButtons.Left.Equals(key) ? "LMB"
                     : (MouseButtons.Right.Equals(key) ? "RMB" : key.ToString()));
            lab.AutoSize = true;
            mMainForm.GridViewSelPanel.Controls.Add(lab);
            mKeyOrMouseToLabelDict[key] = lab;
            PictureBox lPB = new PictureBox();
            mMainForm.GridViewSelPanel.Controls.Add(lPB);
            lPB.Size = new Size(64, 64);
            lPB.SizeMode = PictureBoxSizeMode.StretchImage;
            mKeyOrMouseToSelPicBoxDict[key] = lPB;
              }
              mKeyOrMouseToLabelDict[key].Location = new Point(0, (int)((i + 0.5) * (64 + PADDING) - 5));
              mKeyOrMouseToSelPicBoxDict[key].Location = new Point(IMG_X_OFF, i * (64 + PADDING));
            }
              }
              //=======================================================================
              // Reset the ViewMode. This will ensure that the currently selected
              // mode is valid for the new subject.
              //=======================================================================
              ViewMode = ViewMode;
        }
Example #5
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++;
              }
        }
Example #6
0
        ///========================================================================
        /// Method : DeleteFlat
        /// 
        /// <summary>
        /// 	Delete a Flat, returning the size of the deleted Flat in bytes
        /// </summary>
        /// <param name="xiFlat"></param>
        /// <returns></returns>
        ///========================================================================
        public int DeleteFlat(FlatChunk xiFlat)
        {
            FlatChunk[] lNewFlats = new FlatChunk[Flats.Length - 1];
              int lIndex = 0;

              foreach (FlatChunk lFlat in Flats)
              {
            if (lFlat != xiFlat)
            {
              lNewFlats[lIndex++] = lFlat;
            }
              }

              Flats = lNewFlats;
              return xiFlat.ByteSize;
        }
Example #7
0
        ///========================================================================
        /// Method : AddFlat
        /// 
        /// <summary>
        /// 	Add a new Flat, returning the size of the added Flat in bytes
        /// </summary>
        /// <param name="xiFlat"></param>
        /// <returns></returns>
        ///========================================================================
        public int AddFlat(FlatChunk xiFlat)
        {
            FlatChunk[] lNewFlats = new FlatChunk[Flats.Length + 1];
              Array.Copy(Flats, lNewFlats, Flats.Length);
              lNewFlats[Flats.Length] = xiFlat;
              Flats = lNewFlats;

              return xiFlat.ByteSize;
        }