Inheritance: System.Windows.Forms.UserControl
Beispiel #1
0
        /// <summary>
        /// Creates a clone of the passed memory stream and multiple controls of the
        /// passed in control type. Returns DialogResult.None if no changes have been written to the memory stream.
        /// Returns DialogResult.Yes if changes have been written to the original memory stream.
        /// </summary>
        /// <param name="control">Any child of type BaseField</param>
        /// <param name="rd">The associated reflexiveData information</param>
        public MassFieldChanger(BaseField control, reflexiveData rd)
        {
            /* Create "loading" form to show while loading
            Form LoadingForm = new Form();
            this.Tag = LoadingForm;
            */

            InitializeComponent();

            this.FieldControl = control;

            // Temporarily use our BinaryReader to create a Clone of the original memory stream
            this.BR = new BinaryReader(control.meta.MS);
            this.BR.BaseStream.Position = 0;
            this.MS = new MemoryStream(this.BR.ReadBytes((int)this.BR.BaseStream.Length));
            // Set the Reader/Writer to our cloned memory stream
            this.BR = new BinaryReader(MS);
            this.BW = new BinaryWriter(MS);
            this.RD = rd;

            this.Text = ": " + FieldControl.EntName + " (" + FieldControl.Controls[FieldControl.Controls.Count-1].Text + ")";
            reflexiveData RDParent = rd;
            while (RDParent.parent != null)
            {
                string s = "\\" + RDParent.reflexive.name;
                if (RDParent != rd)
                    s += "[" + RDParent.chunkSelected + "]";
                this.Text = s + this.Text;
                RDParent = RDParent.parent;
            }

            #region Fill in Start & End combo boxes ans select starting values
            for (int x = 0; x < RD.chunkCount; x++)
            {
                cbStartChunk.Items.Add(x.ToString());
                cbEndChunk.Items.Add(x.ToString());
            }
            // Start at chunk 0
            cbStartChunk.Text = "0";
            // Only load the first 100 chunks by default for starters
            cbEndChunk.Text = RD.chunkCount > 100 ? "99" : (RD.chunkCount-1).ToString();
            #endregion

            // States that no values have changed
            this.DialogResult = DialogResult.None;
        }
        /// <summary>
        /// Pokes a full reflexive to the xbox
        /// </summary>
        /// <param name="rd">The reflexive to poke</param>
        private void debugPokeReflexive(reflexiveData rd)
        {
            // The end of the block to read
            int endOffset = 0;

            // The start of the block to read
            int startOffset = endOffset;

            // The size of the block to read
            int readSize = 0;

            // For tag main section, use headersize instead of reflexive size
            int size = rd.reflexive == null ? meta.headersize : rd.reflexive.chunkSize;

            // Keeps track of the control we are checking
            int controlNum = panelMetaEditor.Controls.Count;

            // Initialize with chunkOffset & size = 0
            BaseField oldc = new BaseField();

            // Read in blocks, stopping at all 8-byte Idents and reflexives to be handled accordingly
            while (startOffset != size)
            {
                controlNum--;

                BaseField c = null;
                int sizeChange = 0;
                if (controlNum >= 0)
                {
                    c = (BaseField)panelMetaEditor.Controls[controlNum];
                    sizeChange = c.size;
                }
                else
                {
                    readSize = endOffset - startOffset;
                }

                if (readSize > 0)
                {
                    BR.BaseStream.Position = startOffset + rd.baseOffset;
                    byte[] buffer = BR.ReadBytes(readSize);
                    HaloMap.RealTimeHalo.RTH_Imports.Poke(
                        (uint)(meta.offset + rd.baseOffset + startOffset + meta.magic),
                        buffer,
                        readSize);
                    // If second part of Tag/Ident...
                    if (c != null && c.chunkOffset >= endOffset)
                        startOffset = c.chunkOffset;
                    else
                        startOffset = endOffset;
                }

                readSize = 0;

                // Idents must be poked individually with Tag Type, then Tag Name. It doesn't change if both
                // are poked at once.
                if (c is Ident && c.size == 8)
                {

                    // Not positive if this will work, but we can try!
                    readSize = c.chunkOffset - startOffset + 4; // TAG portion as well
                    sizeChange = 4;
                    if (readSize != 0)
                        controlNum++;
                }

                // Check for a reflexive between controls
                if (c != null && c.chunkOffset > endOffset)
                {
                    readSize = endOffset - startOffset;
                    endOffset = c.chunkOffset;
                    controlNum++;
                    sizeChange = 0;
                }
                endOffset += sizeChange;
                oldc = c;
            }
        }
 void MetaEditorControlPage_GotFocus(object sender, EventArgs e)
 {
     // For bitmasks, select the parent's parent
     if ((((Control)sender).Parent) is GroupBox)
         CurrentControl = (BaseField)((Control)sender).Parent.Parent;
     else
         CurrentControl = (BaseField)((Control)sender).Parent;
 }