Пример #1
0
        // This sets up the form to edit the given lines
        public void Setup(ICollection <Linedef> lines)
        {
            preventchanges = true;

            argscontrol.Reset();
            undocreated = false;
            // Keep this list
            this.lines = lines;
            if (lines.Count > 1)
            {
                this.Text = "Edit Linedefs (" + lines.Count + ")";
            }
            linedefprops = new List <LinedefProperties>();

            ////////////////////////////////////////////////////////////////////////
            // Set all options to the first linedef properties
            ////////////////////////////////////////////////////////////////////////

            // Get first line
            Linedef fl = General.GetByIndex(lines, 0);

            // Flags
            foreach (CheckBox c in flags.Checkboxes)
            {
                if (fl.Flags.ContainsKey(c.Tag.ToString()))
                {
                    c.Checked = fl.Flags[c.Tag.ToString()];
                }
            }

            // Activations
            foreach (LinedefActivateInfo ai in activation.Items)
            {
                if ((fl.Activate & ai.Index) == ai.Index)
                {
                    activation.SelectedItem = ai;
                }
            }

            // Action/tags
            action.Value = fl.Action;

            if (General.Map.FormatInterface.HasLinedefTag)            //mxd
            {
                tagSelector.Setup(UniversalType.LinedefTag);
                tagSelector.SetTag(fl.Tag);
            }

            //mxd. Args
            argscontrol.SetValue(fl, true);

            // Front side and back side checkboxes
            frontside.Checked = (fl.Front != null);
            backside.Checked  = (fl.Back != null);

            // Front settings
            if (fl.Front != null)
            {
                fronthigh.TextureName = fl.Front.HighTexture;
                frontmid.TextureName  = fl.Front.MiddleTexture;
                frontlow.TextureName  = fl.Front.LowTexture;
                fronthigh.Required    = fl.Front.HighRequired();
                frontmid.Required     = fl.Front.MiddleRequired();
                frontlow.Required     = fl.Front.LowRequired();
                frontsector.Text      = fl.Front.Sector.Index.ToString();
                frontTextureOffset.SetValues(fl.Front.OffsetX, fl.Front.OffsetY, true);                 //mxd
            }

            // Back settings
            if (fl.Back != null)
            {
                backhigh.TextureName = fl.Back.HighTexture;
                backmid.TextureName  = fl.Back.MiddleTexture;
                backlow.TextureName  = fl.Back.LowTexture;
                backhigh.Required    = fl.Back.HighRequired();
                backmid.Required     = fl.Back.MiddleRequired();
                backlow.Required     = fl.Back.LowRequired();
                backsector.Text      = fl.Back.Sector.Index.ToString();
                backTextureOffset.SetValues(fl.Back.OffsetX, fl.Back.OffsetY, true);                 //mxd
            }

            ////////////////////////////////////////////////////////////////////////
            // Now go for all lines and change the options when a setting is different
            ////////////////////////////////////////////////////////////////////////

            // Go for all lines
            foreach (Linedef l in lines)
            {
                // Flags
                foreach (CheckBox c in flags.Checkboxes)
                {
                    if (c.CheckState == CheckState.Indeterminate)
                    {
                        continue;                                                              //mxd
                    }
                    if (l.IsFlagSet(c.Tag.ToString()) != c.Checked)
                    {
                        c.ThreeState = true;
                        c.CheckState = CheckState.Indeterminate;
                    }
                }

                // Activations
                if (activation.Items.Count > 0)
                {
                    LinedefActivateInfo sai = (activation.Items[0] as LinedefActivateInfo);
                    foreach (LinedefActivateInfo ai in activation.Items)
                    {
                        if ((l.Activate & ai.Index) == ai.Index)
                        {
                            sai = ai;
                        }
                    }
                    if (sai != activation.SelectedItem)
                    {
                        activation.SelectedIndex = -1;
                    }
                }

                // Action/tags
                if (l.Action != action.Value)
                {
                    action.Empty = true;
                }
                if (General.Map.FormatInterface.HasLinedefTag && l.Tag != fl.Tag)
                {
                    tagSelector.ClearTag();                                                                              //mxd
                }
                //mxd. Arguments
                argscontrol.SetValue(l, false);

                // Front side checkbox
                if ((l.Front != null) != frontside.Checked)
                {
                    frontside.ThreeState = true;
                    frontside.CheckState = CheckState.Indeterminate;
                    frontside.AutoCheck  = false;
                }

                // Back side checkbox
                if ((l.Back != null) != backside.Checked)
                {
                    backside.ThreeState = true;
                    backside.CheckState = CheckState.Indeterminate;
                    backside.AutoCheck  = false;
                }

                // Front settings
                if (l.Front != null)
                {
                    //mxd
                    if (!string.IsNullOrEmpty(fronthigh.TextureName) && fronthigh.TextureName != l.Front.HighTexture)
                    {
                        if (!fronthigh.Required && l.Front.HighRequired())
                        {
                            fronthigh.Required = true;
                        }
                        fronthigh.MultipleTextures = true;
                        fronthigh.TextureName      = string.Empty;
                    }
                    if (!string.IsNullOrEmpty(frontmid.TextureName) && frontmid.TextureName != l.Front.MiddleTexture)
                    {
                        if (!frontmid.Required && l.Front.MiddleRequired())
                        {
                            frontmid.Required = true;
                        }
                        frontmid.MultipleTextures = true;
                        frontmid.TextureName      = string.Empty;
                    }
                    if (!string.IsNullOrEmpty(frontlow.TextureName) && frontlow.TextureName != l.Front.LowTexture)
                    {
                        if (!frontlow.Required && l.Front.LowRequired())
                        {
                            frontlow.Required = true;
                        }
                        frontlow.MultipleTextures = true;
                        frontlow.TextureName      = string.Empty;
                    }
                    if (frontsector.Text != l.Front.Sector.Index.ToString())
                    {
                        frontsector.Text = string.Empty;
                    }

                    frontTextureOffset.SetValues(l.Front.OffsetX, l.Front.OffsetY, false);                     //mxd
                }

                // Back settings
                if (l.Back != null)
                {
                    //mxd
                    if (!string.IsNullOrEmpty(backhigh.TextureName) && backhigh.TextureName != l.Back.HighTexture)
                    {
                        if (!backhigh.Required && l.Back.HighRequired())
                        {
                            backhigh.Required = true;
                        }
                        backhigh.MultipleTextures = true;
                        backhigh.TextureName      = string.Empty;
                    }
                    if (!string.IsNullOrEmpty(backmid.TextureName) && backmid.TextureName != l.Back.MiddleTexture)
                    {
                        if (!backmid.Required && l.Back.MiddleRequired())
                        {
                            backmid.Required = true;
                        }
                        backmid.MultipleTextures = true;
                        backmid.TextureName      = string.Empty;
                    }
                    if (!string.IsNullOrEmpty(backlow.TextureName) && backlow.TextureName != l.Back.LowTexture)
                    {
                        if (!backlow.Required && l.Back.LowRequired())
                        {
                            backlow.Required = true;
                        }
                        backlow.MultipleTextures = true;
                        backlow.TextureName      = string.Empty;
                    }
                    if (backsector.Text != l.Back.Sector.Index.ToString())
                    {
                        backsector.Text = string.Empty;
                    }

                    backTextureOffset.SetValues(l.Back.OffsetX, l.Back.OffsetY, false);                     //mxd
                }

                //mxd
                linedefprops.Add(new LinedefProperties(l));
            }

            // Refresh controls so that they show their image
            backhigh.Refresh();
            backmid.Refresh();
            backlow.Refresh();
            fronthigh.Refresh();
            frontmid.Refresh();
            frontlow.Refresh();

            preventchanges = false;

            argscontrol.UpdateScriptControls();             //mxd
            actionhelp.UpdateAction(action.GetValue());     //mxd
        }
Пример #2
0
        // This sets up the form to edit the given lines
        public void Setup(ICollection <Linedef> lines)
        {
            LinedefActivateInfo sai;
            Linedef             fl;

            preventchanges = true;

            // Keep this list
            this.lines = lines;
            if (lines.Count > 1)
            {
                this.Text = "Edit Linedefs (" + lines.Count + ")";
            }

            ////////////////////////////////////////////////////////////////////////
            // Set all options to the first linedef properties
            ////////////////////////////////////////////////////////////////////////

            // Get first line
            fl = General.GetByIndex(lines, 0);

            // Flags
            foreach (CheckBox c in flags.Checkboxes)
            {
                if (fl.Flags.ContainsKey(c.Tag.ToString()))
                {
                    c.Checked = fl.Flags[c.Tag.ToString()];
                }
            }

            // Activations
            foreach (LinedefActivateInfo ai in activation.Items)
            {
                if ((fl.Activate & ai.Index) == ai.Index)
                {
                    activation.SelectedItem = ai;
                }
            }

            // UDMF Activations
            foreach (CheckBox c in udmfactivates.Checkboxes)
            {
                LinedefActivateInfo ai = (c.Tag as LinedefActivateInfo);
                if (fl.Flags.ContainsKey(ai.Key))
                {
                    c.Checked = fl.Flags[ai.Key];
                }
            }

            // Action/tags
            action.Value = fl.Action;
            tag.Text     = fl.Tag.ToString();
            arg0.SetValue(fl.Args[0]);
            arg1.SetValue(fl.Args[1]);
            arg2.SetValue(fl.Args[2]);
            arg3.SetValue(fl.Args[3]);
            arg4.SetValue(fl.Args[4]);

            // Front side and back side checkboxes
            frontside.Checked = (fl.Front != null);
            backside.Checked  = (fl.Back != null);

            // Front settings
            if (fl.Front != null)
            {
                fronthigh.TextureName = fl.Front.HighTexture;
                frontmid.TextureName  = fl.Front.MiddleTexture;
                frontlow.TextureName  = fl.Front.LowTexture;
                fronthigh.Required    = fl.Front.HighRequired();
                frontmid.Required     = fl.Front.MiddleRequired();
                frontlow.Required     = fl.Front.LowRequired();
                frontsector.Text      = fl.Front.Sector.Index.ToString();
                frontoffsetx.Text     = fl.Front.OffsetX.ToString();
                frontoffsety.Text     = fl.Front.OffsetY.ToString();
            }

            // Back settings
            if (fl.Back != null)
            {
                backhigh.TextureName = fl.Back.HighTexture;
                backmid.TextureName  = fl.Back.MiddleTexture;
                backlow.TextureName  = fl.Back.LowTexture;
                backhigh.Required    = fl.Back.HighRequired();
                backmid.Required     = fl.Back.MiddleRequired();
                backlow.Required     = fl.Back.LowRequired();
                backsector.Text      = fl.Back.Sector.Index.ToString();
                backoffsetx.Text     = fl.Back.OffsetX.ToString();
                backoffsety.Text     = fl.Back.OffsetY.ToString();
            }

            // Custom fields
            fieldslist.SetValues(fl.Fields, true);

            ////////////////////////////////////////////////////////////////////////
            // Now go for all lines and change the options when a setting is different
            ////////////////////////////////////////////////////////////////////////

            // Go for all lines
            foreach (Linedef l in lines)
            {
                // Flags
                foreach (CheckBox c in flags.Checkboxes)
                {
                    if (l.Flags.ContainsKey(c.Tag.ToString()))
                    {
                        if (l.Flags[c.Tag.ToString()] != c.Checked)
                        {
                            c.ThreeState = true;
                            c.CheckState = CheckState.Indeterminate;
                        }
                    }
                }

                // Activations
                if (activation.Items.Count > 0)
                {
                    sai = (activation.Items[0] as LinedefActivateInfo);
                    foreach (LinedefActivateInfo ai in activation.Items)
                    {
                        if ((l.Activate & ai.Index) == ai.Index)
                        {
                            sai = ai;
                        }
                    }
                    if (sai != activation.SelectedItem)
                    {
                        activation.SelectedIndex = -1;
                    }
                }

                // UDMF Activations
                foreach (CheckBox c in udmfactivates.Checkboxes)
                {
                    LinedefActivateInfo ai = (c.Tag as LinedefActivateInfo);
                    if (l.Flags.ContainsKey(ai.Key))
                    {
                        if (c.Checked != l.Flags[ai.Key])
                        {
                            c.ThreeState = true;
                            c.CheckState = CheckState.Indeterminate;
                        }
                    }
                }

                // Action/tags
                if (l.Action != action.Value)
                {
                    action.Empty = true;
                }
                if (l.Tag.ToString() != tag.Text)
                {
                    tag.Text = "";
                }
                if (l.Args[0] != arg0.GetResult(-1))
                {
                    arg0.ClearValue();
                }
                if (l.Args[1] != arg1.GetResult(-1))
                {
                    arg1.ClearValue();
                }
                if (l.Args[2] != arg2.GetResult(-1))
                {
                    arg2.ClearValue();
                }
                if (l.Args[3] != arg3.GetResult(-1))
                {
                    arg3.ClearValue();
                }
                if (l.Args[4] != arg4.GetResult(-1))
                {
                    arg4.ClearValue();
                }

                // Front side checkbox
                if ((l.Front != null) != frontside.Checked)
                {
                    frontside.ThreeState = true;
                    frontside.CheckState = CheckState.Indeterminate;
                    frontside.AutoCheck  = false;
                }

                // Back side checkbox
                if ((l.Back != null) != backside.Checked)
                {
                    backside.ThreeState = true;
                    backside.CheckState = CheckState.Indeterminate;
                    backside.AutoCheck  = false;
                }

                // Front settings
                if (l.Front != null)
                {
                    if (fronthigh.TextureName != l.Front.HighTexture)
                    {
                        fronthigh.TextureName = "";
                    }
                    if (frontmid.TextureName != l.Front.MiddleTexture)
                    {
                        frontmid.TextureName = "";
                    }
                    if (frontlow.TextureName != l.Front.LowTexture)
                    {
                        frontlow.TextureName = "";
                    }
                    if (fronthigh.Required != l.Front.HighRequired())
                    {
                        fronthigh.Required = false;
                    }
                    if (frontmid.Required != l.Front.MiddleRequired())
                    {
                        frontmid.Required = false;
                    }
                    if (frontlow.Required != l.Front.LowRequired())
                    {
                        frontlow.Required = false;
                    }
                    if (frontsector.Text != l.Front.Sector.Index.ToString())
                    {
                        frontsector.Text = "";
                    }
                    if (frontoffsetx.Text != l.Front.OffsetX.ToString())
                    {
                        frontoffsetx.Text = "";
                    }
                    if (frontoffsety.Text != l.Front.OffsetY.ToString())
                    {
                        frontoffsety.Text = "";
                    }
                }

                // Back settings
                if (l.Back != null)
                {
                    if (backhigh.TextureName != l.Back.HighTexture)
                    {
                        backhigh.TextureName = "";
                    }
                    if (backmid.TextureName != l.Back.MiddleTexture)
                    {
                        backmid.TextureName = "";
                    }
                    if (backlow.TextureName != l.Back.LowTexture)
                    {
                        backlow.TextureName = "";
                    }
                    if (backhigh.Required != l.Back.HighRequired())
                    {
                        backhigh.Required = false;
                    }
                    if (backmid.Required != l.Back.MiddleRequired())
                    {
                        backmid.Required = false;
                    }
                    if (backlow.Required != l.Back.LowRequired())
                    {
                        backlow.Required = false;
                    }
                    if (backsector.Text != l.Back.Sector.Index.ToString())
                    {
                        backsector.Text = "";
                    }
                    if (backoffsetx.Text != l.Back.OffsetX.ToString())
                    {
                        backoffsetx.Text = "";
                    }
                    if (backoffsety.Text != l.Back.OffsetY.ToString())
                    {
                        backoffsety.Text = "";
                    }
                    if (General.Map.FormatInterface.HasCustomFields)
                    {
                        custombackbutton.Visible = true;
                    }
                }

                // Custom fields
                fieldslist.SetValues(l.Fields, false);
            }

            // Refresh controls so that they show their image
            backhigh.Refresh();
            backmid.Refresh();
            backlow.Refresh();
            fronthigh.Refresh();
            frontmid.Refresh();
            frontlow.Refresh();

            preventchanges = false;
        }
Пример #3
0
        // Apply clicked
        private void apply_Click(object sender, EventArgs e)
        {
            string undodesc = "linedef";
            Sector s;
            int    index;

            // Verify the tag
            if (General.Map.FormatInterface.HasLinedefTag && ((tag.GetResult(0) < General.Map.FormatInterface.MinTag) || (tag.GetResult(0) > General.Map.FormatInterface.MaxTag)))
            {
                General.ShowWarningMessage("Linedef tag must be between " + General.Map.FormatInterface.MinTag + " and " + General.Map.FormatInterface.MaxTag + ".", MessageBoxButtons.OK);
                return;
            }

            // Verify the action
            if ((action.Value < General.Map.FormatInterface.MinAction) || (action.Value > General.Map.FormatInterface.MaxAction))
            {
                General.ShowWarningMessage("Linedef action must be between " + General.Map.FormatInterface.MinAction + " and " + General.Map.FormatInterface.MaxAction + ".", MessageBoxButtons.OK);
                return;
            }

            // Verify texture offsets
            if ((backoffsetx.GetResult(0) < General.Map.FormatInterface.MinTextureOffset) || (backoffsetx.GetResult(0) > General.Map.FormatInterface.MaxTextureOffset) ||
                (backoffsety.GetResult(0) < General.Map.FormatInterface.MinTextureOffset) || (backoffsety.GetResult(0) > General.Map.FormatInterface.MaxTextureOffset) ||
                (frontoffsetx.GetResult(0) < General.Map.FormatInterface.MinTextureOffset) || (frontoffsetx.GetResult(0) > General.Map.FormatInterface.MaxTextureOffset) ||
                (frontoffsety.GetResult(0) < General.Map.FormatInterface.MinTextureOffset) || (frontoffsety.GetResult(0) > General.Map.FormatInterface.MaxTextureOffset))
            {
                General.ShowWarningMessage("Texture offset must be between " + General.Map.FormatInterface.MinTextureOffset + " and " + General.Map.FormatInterface.MaxTextureOffset + ".", MessageBoxButtons.OK);
                return;
            }

            // Make undo
            if (lines.Count > 1)
            {
                undodesc = lines.Count + " linedefs";
            }
            General.Map.UndoRedo.CreateUndo("Edit " + undodesc);

            // Go for all the lines
            foreach (Linedef l in lines)
            {
                // Apply all flags
                foreach (CheckBox c in flags.Checkboxes)
                {
                    if (c.CheckState == CheckState.Checked)
                    {
                        l.SetFlag(c.Tag.ToString(), true);
                    }
                    else if (c.CheckState == CheckState.Unchecked)
                    {
                        l.SetFlag(c.Tag.ToString(), false);
                    }
                }

                // Apply chosen activation flag
                if (activation.SelectedIndex > -1)
                {
                    l.Activate = (activation.SelectedItem as LinedefActivateInfo).Index;
                }

                // UDMF activations
                foreach (CheckBox c in udmfactivates.Checkboxes)
                {
                    LinedefActivateInfo ai = (c.Tag as LinedefActivateInfo);
                    if (c.CheckState == CheckState.Checked)
                    {
                        l.SetFlag(ai.Key, true);
                    }
                    else if (c.CheckState == CheckState.Unchecked)
                    {
                        l.SetFlag(ai.Key, false);
                    }
                }

                // Action/tags
                l.Tag = General.Clamp(tag.GetResult(l.Tag), General.Map.FormatInterface.MinTag, General.Map.FormatInterface.MaxTag);
                if (!action.Empty)
                {
                    l.Action = action.Value;
                }
                l.Args[0] = arg0.GetResult(l.Args[0]);
                l.Args[1] = arg1.GetResult(l.Args[1]);
                l.Args[2] = arg2.GetResult(l.Args[2]);
                l.Args[3] = arg3.GetResult(l.Args[3]);
                l.Args[4] = arg4.GetResult(l.Args[4]);

                // Remove front side?
                if ((l.Front != null) && (frontside.CheckState == CheckState.Unchecked))
                {
                    l.Front.Dispose();
                }
                // Create or modify front side?
                else if (frontside.CheckState == CheckState.Checked)
                {
                    // Make sure we have a valid sector (make a new one if needed)
                    if (l.Front != null)
                    {
                        index = l.Front.Sector.Index;
                    }
                    else
                    {
                        index = -1;
                    }
                    index = frontsector.GetResult(index);
                    if ((index > -1) && (index < General.Map.Map.Sectors.Count))
                    {
                        s = General.Map.Map.GetSectorByIndex(index);
                        if (s == null)
                        {
                            s = General.Map.Map.CreateSector();
                        }
                        if (s != null)
                        {
                            // Create new sidedef?
                            if (l.Front == null)
                            {
                                General.Map.Map.CreateSidedef(l, true, s);
                            }
                            if (l.Front != null)
                            {
                                // Change sector?
                                if (l.Front.Sector != s)
                                {
                                    l.Front.SetSector(s);
                                }

                                // Apply settings
                                l.Front.OffsetX = General.Clamp(frontoffsetx.GetResult(l.Front.OffsetX), General.Map.FormatInterface.MinTextureOffset, General.Map.FormatInterface.MaxTextureOffset);
                                l.Front.OffsetY = General.Clamp(frontoffsety.GetResult(l.Front.OffsetY), General.Map.FormatInterface.MinTextureOffset, General.Map.FormatInterface.MaxTextureOffset);
                                l.Front.SetTextureHigh(fronthigh.GetResult(l.Front.HighTexture));
                                l.Front.SetTextureMid(frontmid.GetResult(l.Front.MiddleTexture));
                                l.Front.SetTextureLow(frontlow.GetResult(l.Front.LowTexture));
                            }
                        }
                    }
                }

                // Remove back side?
                if ((l.Back != null) && (backside.CheckState == CheckState.Unchecked))
                {
                    l.Back.Dispose();
                }
                // Create or modify back side?
                else if (backside.CheckState == CheckState.Checked)
                {
                    // Make sure we have a valid sector (make a new one if needed)
                    if (l.Back != null)
                    {
                        index = l.Back.Sector.Index;
                    }
                    else
                    {
                        index = -1;
                    }
                    index = backsector.GetResult(index);
                    if ((index > -1) && (index < General.Map.Map.Sectors.Count))
                    {
                        s = General.Map.Map.GetSectorByIndex(index);
                        if (s == null)
                        {
                            s = General.Map.Map.CreateSector();
                        }
                        if (s != null)
                        {
                            // Create new sidedef?
                            if (l.Back == null)
                            {
                                General.Map.Map.CreateSidedef(l, false, s);
                            }
                            if (l.Back != null)
                            {
                                // Change sector?
                                if (l.Back.Sector != s)
                                {
                                    l.Back.SetSector(s);
                                }

                                // Apply settings
                                l.Back.OffsetX = General.Clamp(backoffsetx.GetResult(l.Back.OffsetX), General.Map.FormatInterface.MinTextureOffset, General.Map.FormatInterface.MaxTextureOffset);
                                l.Back.OffsetY = General.Clamp(backoffsety.GetResult(l.Back.OffsetY), General.Map.FormatInterface.MinTextureOffset, General.Map.FormatInterface.MaxTextureOffset);
                                l.Back.SetTextureHigh(backhigh.GetResult(l.Back.HighTexture));
                                l.Back.SetTextureMid(backmid.GetResult(l.Back.MiddleTexture));
                                l.Back.SetTextureLow(backlow.GetResult(l.Back.LowTexture));
                            }
                        }
                    }
                }

                // Custom fields
                fieldslist.Apply(l.Fields);
            }

            // Update the used textures
            General.Map.Data.UpdateUsedTextures();

            // Done
            General.Map.IsChanged = true;
            this.DialogResult     = DialogResult.OK;
            this.Close();
        }
Пример #4
0
        // This sets up the form to edit the given lines
        public void Setup(ICollection <Linedef> lines)
        {
            LinedefActivateInfo sai;
            Linedef             fl;

            // Keep this list
            this.lines = lines;
            if (lines.Count > 1)
            {
                this.Text = "Edit Linedefs (" + lines.Count + ")";
            }

            ////////////////////////////////////////////////////////////////////////
            // Set all options to the first linedef properties
            ////////////////////////////////////////////////////////////////////////

            // 20120219 villsa - Disable checkboxes if multiple lines are selected...
            // I am lazy, go away...
            if (lines.Count > 1)
            {
                chkSwitchTextureLower.Enabled  = false;
                chkSwitchTextureMiddle.Enabled = false;
                chkSwitchTextureUpper.Enabled  = false;
                chkSwitchDisplayLower.Enabled  = false;
                chkSwitchDisplayMiddle.Enabled = false;
                chkSwitchDisplayUpper.Enabled  = false;
            }
            else
            {
                chkSwitchTextureLower.Enabled  = true;
                chkSwitchTextureMiddle.Enabled = true;
                chkSwitchTextureUpper.Enabled  = true;
                chkSwitchDisplayLower.Enabled  = true;
                chkSwitchDisplayMiddle.Enabled = true;
                chkSwitchDisplayUpper.Enabled  = true;
            }

            // Get first line
            fl = General.GetByIndex(lines, 0);

            // Flags
            foreach (CheckBox c in flags.Checkboxes)
            {
                if (fl.Flags.ContainsKey(c.Tag.ToString()))
                {
                    c.Checked = fl.Flags[c.Tag.ToString()];
                }
            }

            // Activations
            foreach (LinedefActivateInfo ai in activation.Items)
            {
                if ((fl.Activate & ai.Index) == ai.Index)
                {
                    activation.SelectedItem = ai;
                }
            }

            // UDMF Activations
            foreach (CheckBox c in udmfactivates.Checkboxes)
            {
                LinedefActivateInfo ai = (c.Tag as LinedefActivateInfo);
                if (fl.Flags.ContainsKey(ai.Key))
                {
                    c.Checked = fl.Flags[ai.Key];
                }
            }

            // Action/tags
            action.Value = fl.Action;
            tag.Text     = fl.Tag.ToString();
            arg0.SetValue(fl.Args[0]);
            arg1.SetValue(fl.Args[1]);
            arg2.SetValue(fl.Args[2]);
            arg3.SetValue(fl.Args[3]);
            arg4.SetValue(fl.Args[4]);

            // Front side and back side checkboxes
            frontside.Checked = (fl.Front != null);
            backside.Checked  = (fl.Back != null);

            // Front settings
            if (fl.Front != null)
            {
                fronthigh.TextureName = fl.Front.HighTexture;
                frontmid.TextureName  = fl.Front.MiddleTexture;
                frontlow.TextureName  = fl.Front.LowTexture;
                fronthigh.Required    = fl.Front.HighRequired();
                frontmid.Required     = fl.Front.MiddleRequired();
                frontlow.Required     = fl.Front.LowRequired();
                frontsector.Text      = fl.Front.Sector.Index.ToString();
                frontoffsetx.Text     = fl.Front.OffsetX.ToString();
                frontoffsety.Text     = fl.Front.OffsetY.ToString();
            }

            // Back settings
            if (fl.Back != null)
            {
                backhigh.TextureName = fl.Back.HighTexture;
                backmid.TextureName  = fl.Back.MiddleTexture;
                backlow.TextureName  = fl.Back.LowTexture;
                backhigh.Required    = fl.Back.HighRequired();
                backmid.Required     = fl.Back.MiddleRequired();
                backlow.Required     = fl.Back.LowRequired();
                backsector.Text      = fl.Back.Sector.Index.ToString();
                backoffsetx.Text     = fl.Back.OffsetX.ToString();
                backoffsety.Text     = fl.Back.OffsetY.ToString();
            }

            // Custom fields
            fieldslist.SetValues(fl.Fields, true);

            ////////////////////////////////////////////////////////////////////////
            // Now go for all lines and change the options when a setting is different
            ////////////////////////////////////////////////////////////////////////

            // Go for all lines
            foreach (Linedef l in lines)
            {
                // Flags
                foreach (CheckBox c in flags.Checkboxes)
                {
                    if (l.Flags.ContainsKey(c.Tag.ToString()))
                    {
                        if (l.Flags[c.Tag.ToString()] != c.Checked)
                        {
                            c.ThreeState = true;
                            c.CheckState = CheckState.Indeterminate;
                        }
                    }
                }

                // Activations

                // villsa
                if (General.Map.FormatInterface.InDoom64Mode)
                {
                    if (l.Activate > 0)
                    {
                        // 20120219 villsa
                        l.Activate -= (l.Activate & 511);
                        PreSetActivationFlag(activationtypered, l.Activate, 512);
                        PreSetActivationFlag(activationtypeblue, l.Activate, 1024);
                        PreSetActivationFlag(activationtypeyellow, l.Activate, 2048);
                        PreSetActivationFlag(activationtypecross, l.Activate, 4096);
                        PreSetActivationFlag(activationtypeshoot, l.Activate, 8192);
                        PreSetActivationFlag(activationtypeuse, l.Activate, 16384);
                        PreSetActivationFlag(activationtyperepeat, l.Activate, 32768);
                    }

                    SwitchTextureMask(l);
                }
                else
                {
                    if (activation.Items.Count > 0)
                    {
                        sai = (activation.Items[0] as LinedefActivateInfo);
                        foreach (LinedefActivateInfo ai in activation.Items)
                        {
                            if ((l.Activate & ai.Index) == ai.Index)
                            {
                                sai = ai;
                            }
                        }
                        if (sai != activation.SelectedItem)
                        {
                            activation.SelectedIndex = -1;
                        }
                    }
                }

                // UDMF Activations
                foreach (CheckBox c in udmfactivates.Checkboxes)
                {
                    LinedefActivateInfo ai = (c.Tag as LinedefActivateInfo);
                    if (l.Flags.ContainsKey(ai.Key))
                    {
                        if (c.Checked != l.Flags[ai.Key])
                        {
                            c.ThreeState = true;
                            c.CheckState = CheckState.Indeterminate;
                        }
                    }
                }

                // Action/tags
                if (l.Action != action.Value)
                {
                    action.Empty = true;
                }
                if (l.Tag.ToString() != tag.Text)
                {
                    tag.Text = "";
                }
                if (l.Args[0] != arg0.GetResult(-1))
                {
                    arg0.ClearValue();
                }
                if (l.Args[1] != arg1.GetResult(-1))
                {
                    arg1.ClearValue();
                }
                if (l.Args[2] != arg2.GetResult(-1))
                {
                    arg2.ClearValue();
                }
                if (l.Args[3] != arg3.GetResult(-1))
                {
                    arg3.ClearValue();
                }
                if (l.Args[4] != arg4.GetResult(-1))
                {
                    arg4.ClearValue();
                }

                // Front side checkbox
                if ((l.Front != null) != frontside.Checked)
                {
                    frontside.ThreeState = true;
                    frontside.CheckState = CheckState.Indeterminate;
                    frontside.AutoCheck  = false;
                }

                // Back side checkbox
                if ((l.Back != null) != backside.Checked)
                {
                    backside.ThreeState = true;
                    backside.CheckState = CheckState.Indeterminate;
                    backside.AutoCheck  = false;
                }

                // Front settings
                if (l.Front != null)
                {
                    if (fronthigh.TextureName != l.Front.HighTexture)
                    {
                        fronthigh.TextureName = "";
                    }
                    if (frontmid.TextureName != l.Front.MiddleTexture)
                    {
                        frontmid.TextureName = "";
                    }
                    if (frontlow.TextureName != l.Front.LowTexture)
                    {
                        frontlow.TextureName = "";
                    }
                    if (fronthigh.Required != l.Front.HighRequired())
                    {
                        fronthigh.Required = false;
                    }
                    if (frontmid.Required != l.Front.MiddleRequired())
                    {
                        frontmid.Required = false;
                    }
                    if (frontlow.Required != l.Front.LowRequired())
                    {
                        frontlow.Required = false;
                    }
                    if (frontsector.Text != l.Front.Sector.Index.ToString())
                    {
                        frontsector.Text = "";
                    }
                    if (frontoffsetx.Text != l.Front.OffsetX.ToString())
                    {
                        frontoffsetx.Text = "";
                    }
                    if (frontoffsety.Text != l.Front.OffsetY.ToString())
                    {
                        frontoffsety.Text = "";
                    }
                }

                // Back settings
                if (l.Back != null)
                {
                    if (backhigh.TextureName != l.Back.HighTexture)
                    {
                        backhigh.TextureName = "";
                    }
                    if (backmid.TextureName != l.Back.MiddleTexture)
                    {
                        backmid.TextureName = "";
                    }
                    if (backlow.TextureName != l.Back.LowTexture)
                    {
                        backlow.TextureName = "";
                    }
                    if (backhigh.Required != l.Back.HighRequired())
                    {
                        backhigh.Required = false;
                    }
                    if (backmid.Required != l.Back.MiddleRequired())
                    {
                        backmid.Required = false;
                    }
                    if (backlow.Required != l.Back.LowRequired())
                    {
                        backlow.Required = false;
                    }
                    if (backsector.Text != l.Back.Sector.Index.ToString())
                    {
                        backsector.Text = "";
                    }
                    if (backoffsetx.Text != l.Back.OffsetX.ToString())
                    {
                        backoffsetx.Text = "";
                    }
                    if (backoffsety.Text != l.Back.OffsetY.ToString())
                    {
                        backoffsety.Text = "";
                    }
                    if (General.Map.FormatInterface.HasCustomFields)
                    {
                        custombackbutton.Visible = true;
                    }
                }

                // Custom fields
                fieldslist.SetValues(l.Fields, false);
            }

            foreach (Linedef l in lines)
            {
                // 20120219 villsa
                l.Activate -= (l.Activate & 511);
                CheckActivationState(activationtypered, l.Activate, 512);
                CheckActivationState(activationtypeblue, l.Activate, 1024);
                CheckActivationState(activationtypeyellow, l.Activate, 2048);
                CheckActivationState(activationtypecross, l.Activate, 4096);
                CheckActivationState(activationtypeshoot, l.Activate, 8192);
                CheckActivationState(activationtypeuse, l.Activate, 16384);
                CheckActivationState(activationtyperepeat, l.Activate, 32768);
            }

            // Refresh controls so that they show their image
            backhigh.Refresh();
            backmid.Refresh();
            backlow.Refresh();
            fronthigh.Refresh();
            frontmid.Refresh();
            frontlow.Refresh();
        }