Beispiel #1
0
        public void Update(EditorHAMFile datafile, PIGFile piggyFile, int textureID, TMAPInfo info)
        {
            isLocked       = true;
            this.textureID = textureID;
            this.datafile  = datafile;
            this.piggyFile = piggyFile;
            this.info      = info;

            TextureIDTextBox.Text        = datafile.Textures[textureID].ToString();
            txtTexLight.Text             = info.Lighting.ToString();
            txtTexDamage.Text            = info.Damage.ToString();
            cbTexEClip.SelectedIndex     = info.EClipNum + 1;
            txtTexSlideU.Text            = GetFloatFromFixed88(info.SlideU).ToString();
            txtTexSlideV.Text            = GetFloatFromFixed88(info.SlideV).ToString();
            TextureDestroyedTextBox.Text = info.DestroyedID.ToString();
            cbTexLava.Checked            = info.Volatile;
            cbTexWater.Checked           = info.Water;
            cbTexForcefield.Checked      = info.ForceField;
            cbTexRedGoal.Checked         = info.RedGoal;
            cbTexBlueGoal.Checked        = info.BlueGoal;
            cbTexHoardGoal.Checked       = info.HoardGoal;

            UpdatePictureBox(PiggyBitmapUtilities.GetBitmap(piggyFile, palette, datafile.Textures[textureID]), pbTexPrev);
            isLocked = false;
        }
Beispiel #2
0
        private void TextureFlagCheckbox_CheckedChanged(object sender, EventArgs e)
        {
            if (isLocked || transactionManager.TransactionInProgress)
            {
                return;
            }
            TMAPInfo        tmapinfo    = datafile.TMapInfo[textureID];
            CheckBox        control     = (CheckBox)sender;
            BoolTransaction transaction = new BoolTransaction("TMapInfo property", tmapinfo, (string)control.Tag, textureID, 0, control.Checked);

            transactionManager.ApplyTransaction(transaction);
        }
Beispiel #3
0
        public override void Revert()
        {
            TMAPInfo info = datafile.TMapInfo[tmapIndex];

            info.EClipNum = (short)oldValue;
            datafile.EClips[newValue].ChangingWallTexture = (short)oldTmapIndex;

            if (oldTmapIndex != -1)
            {
                datafile.TMapInfo[oldTmapIndex].EClipNum = (short)newValue;
            }
        }
        public AddTextureTransaction(string label, object target, string propertyName, string namesPropertyName, int addPos, ushort addTexture, TMAPInfo addTMAP, int page, int tab) : base(label, target, propertyName, page, tab)
        {
            this.addPos     = addPos;
            this.addTexture = addTexture;
            this.addTMAP    = addTMAP;

            Type targetType = target.GetType();

            if (namesPropertyName != null) //Some element types don't have a namelist (like gauges, since it would be too verbose and useless), so allow that
            {
                tmapProperty = targetType.GetProperty(namesPropertyName);
            }

            RedoPage = addPos;
        }
Beispiel #5
0
 public void UpdateTexturePanel(int num)
 {
     if (datafile.TMapInfo.Count == 0)
     {
         statusBar1.Text      = "No TMAPInfo present.";
         texturePanel.Enabled = false;
     }
     else
     {
         statusBar1.Text      = "";
         texturePanel.Enabled = true;
         TMAPInfo texture = datafile.TMapInfo[num];
         texturePanel.Update(datafile, datafile.piggyFile, num, texture);
     }
 }
Beispiel #6
0
        private void txtTexSlideU_TextChanged(object sender, EventArgs e)
        {
            if (isLocked || transactionManager.TransactionInProgress)
            {
                return;
            }
            double  value;
            TextBox control = (TextBox)sender;

            if (double.TryParse(control.Text, out value))
            {
                TMAPInfo           tmapinfo    = datafile.TMapInfo[textureID];
                IntegerTransaction transaction = new IntegerTransaction("TMapInfo property", tmapinfo, (string)control.Tag, textureID, 0, (int)(value * 256));
                transactionManager.ApplyTransaction(transaction);
            }
        }
Beispiel #7
0
        private void RemapSingleImage_Click(object sender, EventArgs e)
        {
            Button        button   = (Button)sender;
            ImageSelector selector = new ImageSelector(piggyFile, palette, false);

            if (selector.ShowDialog() == DialogResult.OK)
            {
                isLocked = true;
                int                 value       = selector.Selection;
                TMAPInfo            tmapinfo    = datafile.TMapInfo[textureID];
                TMapInfoTransaction transaction = new TMapInfoTransaction("TMapInfo texture change", textureID, 0, datafile, piggyFile, textureID, value);
                transaction.eventHandler += TextureEventHandler;
                transactionManager.ApplyTransaction(transaction);
                isLocked = false;
            }
        }
Beispiel #8
0
        private void TextureProperty_TextChanged(object sender, EventArgs e)
        {
            if (isLocked || transactionManager.TransactionInProgress)
            {
                return;
            }
            TextBox  textBox = (TextBox)sender;
            TMAPInfo info    = datafile.TMapInfo[textureID];
            double   value;

            if (double.TryParse(textBox.Text, out value))
            {
                FixTransaction transaction = new FixTransaction("TMapInfo property", info, (string)textBox.Tag, textureID, 0, value);
                transactionManager.ApplyTransaction(transaction);
            }
        }
Beispiel #9
0
        private void TextureIDTextBox_TextChanged(object sender, EventArgs e)
        {
            if (isLocked || transactionManager.TransactionInProgress)
            {
                return;
            }
            int     value;
            TextBox control = (TextBox)sender;

            if (int.TryParse(control.Text, out value))
            {
                TMAPInfo            tmapinfo    = datafile.TMapInfo[textureID];
                TMapInfoTransaction transaction = new TMapInfoTransaction("TMapInfo texture change", textureID, 0, datafile, piggyFile, textureID, value);
                transaction.eventHandler += TextureEventHandler;
                transactionManager.ApplyTransaction(transaction);
            }
        }
Beispiel #10
0
        private void TMAPInfoEClip_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (isLocked || transactionManager.TransactionInProgress)
            {
                return;
            }

            isLocked = true;
            int      eclipNum = cbTexEClip.SelectedIndex - 1;
            EClip    clip     = datafile.GetEClip(eclipNum);
            TMAPInfo tmapInfo = datafile.TMapInfo[textureID];
            TMapInfoEClipTransaction transaction = null;

            if (clip == null)
            {
                transaction = new TMapInfoEClipTransaction("TMapInfo EClip change", textureID, 0, datafile, piggyFile, textureID, -1);
            }
            else
            {
                int clipCurrentID = clip.ChangingWallTexture;
                if (clipCurrentID != -1 && clipCurrentID != textureID)
                {
                    if (MessageBox.Show("This EClip is already assigned to another wall texture, do you want to change it?", "EClip in use", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        transaction = new TMapInfoEClipTransaction("TMapInfo EClip change", textureID, 0, datafile, piggyFile, textureID, eclipNum);
                    }
                    else
                    {
                        cbTexEClip.SelectedIndex = tmapInfo.EClipNum + 1;
                        isLocked = false;
                        return;
                    }
                }
                //this was commented out and I have no idea if there was a good reason for it
                else
                {
                    transaction = new TMapInfoEClipTransaction("TMapInfo EClip change", textureID, 0, datafile, piggyFile, textureID, eclipNum);
                }
            }
            if (transaction != null)
            {
                transactionManager.ApplyTransaction(transaction);
            }

            isLocked = false;
        }
Beispiel #11
0
        public override bool Apply()
        {
            TMAPInfo info = datafile.TMapInfo[tmapIndex];

            oldValue = info.EClipNum;

            if (newValue != -1)
            {
                oldTmapIndex = datafile.EClips[newValue].ChangingWallTexture;
                if (oldTmapIndex != -1)
                {
                    datafile.TMapInfo[oldTmapIndex].EClipNum = -1;
                }
            }
            info.EClipNum = (short)newValue;
            if (newValue != -1)
            {
                datafile.EClips[newValue].ChangingWallTexture = (short)tmapIndex;
            }


            return(true);
        }
Beispiel #12
0
        public void UpdateTexturePanel(int num)
        {
            TMAPInfo texture = datafile.TMapInfo[num];

            texturePanel.Update(datafile, datafile.piggyFile, num, texture);
        }
Beispiel #13
0
        public override bool Apply()
        {
            lastTexture = datafile.Textures[deleteNum];
            lastValue   = datafile.TMapInfo[deleteNum];

            datafile.Textures.RemoveAt(deleteNum);
            datafile.TMapInfo.RemoveAt(deleteNum);

            references.Clear();

            if (datafile.Textures.Count != 0)
            {
                //Change every reference to the deleted element
                for (int i = 0; i < datafile.EClips.Count(); i++)
                {
                    EClip temp = datafile.EClips[i].Clone();
                    //Change references that exactly reference the object to -1
                    if (datafile.EClips[i].ChangingObjectTexture == deleteNum)
                    {
                        datafile.EClips[i].ChangingWallTexture = -1;
                        references.Add(new ChangedHAMReference(temp, datafile.EClips, i));
                    }

                    //Change references to further elements by subtracting one
                    else if (datafile.EClips[i].ChangingObjectTexture > deleteNum)
                    {
                        datafile.EClips[i].ChangingWallTexture--;
                        references.Add(new ChangedHAMReference(temp, datafile.EClips, i));
                    }
                }

                for (int i = 0; i < datafile.TMapInfo.Count(); i++)
                {
                    TMAPInfo temp = datafile.TMapInfo[i].Clone();
                    //Change references that exactly reference the object to -1
                    if (datafile.TMapInfo[i].DestroyedID == deleteNum)
                    {
                        datafile.TMapInfo[i].DestroyedID = -1;
                        references.Add(new ChangedHAMReference(temp, datafile.TMapInfo, i));
                    }

                    //Change references to further elements by subtracting one
                    else if (datafile.TMapInfo[i].DestroyedID > deleteNum)
                    {
                        datafile.TMapInfo[i].DestroyedID--;
                        references.Add(new ChangedHAMReference(temp, datafile.TMapInfo, i));
                    }
                }

                for (int i = 0; i < datafile.WClips.Count(); i++)
                {
                    WClip temp   = datafile.WClips[i].Clone();
                    bool  change = false;
                    //Change references that exactly reference the object to -1
                    for (int j = 0; j < datafile.WClips[i].NumFrames; j++)
                    {
                        if (datafile.WClips[i].Frames[j] == deleteNum)
                        {
                            datafile.WClips[i].Frames[j] = 0;
                            change = true;
                        }

                        //Change references to further elements by subtracting one
                        else if (datafile.WClips[i].Frames[j] > deleteNum)
                        {
                            datafile.WClips[i].Frames[j]--;
                            change = true;
                        }
                    }

                    if (change)
                    {
                        references.Add(new ChangedHAMReference(temp, datafile.WClips, i));
                    }
                }
            }
            return(true);
        }