// Paste properties
        public virtual void OnPasteProperties()
        {
            if (BuilderPlug.Me.CopiedSidedefProps != null)
            {
                mode.CreateUndo("Paste sidedef properties");
                mode.SetActionResult("Pasted sidedef properties.");
                BuilderPlug.Me.CopiedSidedefProps.Apply(Sidedef);

                // Update sectors on both sides
                BaseVisualSector front = (BaseVisualSector)mode.GetVisualSector(Sidedef.Sector);
                if (front != null)
                {
                    front.Changed = true;
                }
                if (Sidedef.Other != null)
                {
                    BaseVisualSector back = (BaseVisualSector)mode.GetVisualSector(Sidedef.Other.Sector);
                    if (back != null)
                    {
                        back.Changed = true;
                    }
                }
                mode.ShowTargetInfo();
            }
        }
        // Edit button released
        public virtual void OnEditEnd()
        {
            if (General.Interface.IsActiveWindow)
            {
                List <Linedef> linedefs = mode.GetSelectedLinedefs();
                DialogResult   result   = General.Interface.ShowEditLinedefs(linedefs);
                if (result == DialogResult.OK)
                {
                    foreach (Linedef l in linedefs)
                    {
                        if (l.Front != null)
                        {
                            if (mode.VisualSectorExists(l.Front.Sector))
                            {
                                BaseVisualSector vs = (BaseVisualSector)mode.GetVisualSector(l.Front.Sector);
                                vs.UpdateSectorGeometry(false);
                            }
                        }

                        if (l.Back != null)
                        {
                            if (mode.VisualSectorExists(l.Back.Sector))
                            {
                                BaseVisualSector vs = (BaseVisualSector)mode.GetVisualSector(l.Back.Sector);
                                vs.UpdateSectorGeometry(false);
                            }
                        }
                    }

                    mode.RebuildElementData();
                }
            }
        }
Beispiel #3
0
        // Raise/lower thing
        public virtual void OnChangeTargetHeight(int amount)
        {
            if (General.Map.FormatInterface.HasThingHeight)
            {
                if ((General.Map.UndoRedo.NextUndo == null) || (General.Map.UndoRedo.NextUndo.TicketID != undoticket))
                {
                    undoticket = mode.CreateUndo("Change thing height");
                }

                Thing.Move(Thing.Position + new Vector3D(0.0f, 0.0f, (float)amount));

                mode.SetActionResult("Changed thing height to " + Thing.Position.z + ".");

                // Update what must be updated
                ThingData td = mode.GetThingData(this.Thing);
                foreach (KeyValuePair <Sector, bool> s in td.UpdateAlso)
                {
                    if (mode.VisualSectorExists(s.Key))
                    {
                        BaseVisualSector vs = (BaseVisualSector)mode.GetVisualSector(s.Key);
                        vs.UpdateSectorGeometry(s.Value);
                    }
                }

                this.Changed = true;
            }
        }
        // This sets the Lower Unpegged flag
        public virtual void ApplyLowerUnpegged(bool set)
        {
            if (!set)
            {
                // Remove flag
                mode.CreateUndo("Remove lower-unpegged setting");
                mode.SetActionResult("Removed lower-unpegged setting.");
                this.Sidedef.Line.SetFlag(General.Map.Config.LowerUnpeggedFlag, false);
            }
            else
            {
                // Add flag
                mode.CreateUndo("Set lower-unpegged setting");
                mode.SetActionResult("Set lower-unpegged setting.");
                this.Sidedef.Line.SetFlag(General.Map.Config.LowerUnpeggedFlag, true);
            }

            // Update sidedef geometry
            VisualSidedefParts parts = Sector.GetSidedefParts(Sidedef);

            parts.SetupAllParts();

            // Update other sidedef geometry
            if (Sidedef.Other != null)
            {
                BaseVisualSector othersector = (BaseVisualSector)mode.GetVisualSector(Sidedef.Other.Sector);
                parts = othersector.GetSidedefParts(Sidedef.Other);
                parts.SetupAllParts();
            }
        }
Beispiel #5
0
        // This resets this sector data and all sectors that require updating after me
        public void Reset()
        {
            if (isupdating)
            {
                return;
            }

            isupdating = true;

            // This is set to false so that this sector is rebuilt the next time it is needed!
            updated = false;

            // The visual sector associated is now outdated
            if (mode.VisualSectorExists(sector))
            {
                BaseVisualSector vs = (BaseVisualSector)mode.GetVisualSector(sector);
                vs.UpdateSectorGeometry(false);
            }

            // Also reset the sectors that depend on this sector
            foreach (KeyValuePair <Sector, bool> s in updatesectors)
            {
                SectorData sd = mode.GetSectorData(s.Key);
                sd.Reset();
            }

            isupdating = false;
        }
        // Auto-align texture X offsets
        public virtual void OnTextureAlign(bool alignx, bool aligny)
        {
            mode.CreateUndo("Auto-align textures");
            mode.SetActionResult("Auto-aligned textures.");

            // Make sure the texture is loaded (we need the texture size)
            if (!base.Texture.IsImageLoaded)
            {
                base.Texture.LoadImage();
            }

            if (mode.IsSingleSelection)
            {
                // Clear all marks, this will align everything it can
                General.Map.Map.ClearMarkedSidedefs(false);
            }
            else
            {
                // Limit the alignment to selection only
                General.Map.Map.ClearMarkedSidedefs(true);
                List <Sidedef> sides = mode.GetSelectedSidedefs();
                foreach (Sidedef sd in sides)
                {
                    sd.Marked = false;
                }
            }

            SidedefPart part;

            if (this is VisualLower)
            {
                part = SidedefPart.Lower;
            }
            else if (this is VisualUpper)
            {
                part = SidedefPart.Upper;
            }
            else
            {
                part = SidedefPart.Middle;
            }

            // Do the alignment
            BuilderPlug.AutoAlignTextures(this.Sidedef, part, base.Texture, alignx, aligny, false);

            // Get the changed sidedefs
            List <Sidedef> changes = General.Map.Map.GetMarkedSidedefs(true);

            foreach (Sidedef sd in changes)
            {
                // Update the parts for this sidedef!
                if (mode.VisualSectorExists(sd.Sector))
                {
                    BaseVisualSector   vs    = (mode.GetVisualSector(sd.Sector) as BaseVisualSector);
                    VisualSidedefParts parts = vs.GetSidedefParts(sd);
                    parts.SetupAllParts();
                }
            }
        }
        // Flood-fill textures
        public virtual void OnTextureFloodfill()
        {
            if (BuilderPlug.Me.CopiedTexture != null)
            {
                string oldtexture     = GetTextureName();
                long   oldtexturelong = Lump.MakeLongName(oldtexture);
                string newtexture     = BuilderPlug.Me.CopiedTexture;
                if (newtexture != oldtexture)
                {
                    mode.CreateUndo("Flood-fill textures with " + newtexture);
                    mode.SetActionResult("Flood-filled textures with " + newtexture + ".");

                    mode.Renderer.SetCrosshairBusy(true);
                    General.Interface.RedrawDisplay();

                    // Get the texture
                    ImageData newtextureimage = General.Map.Data.GetTextureImage(newtexture);
                    if (newtextureimage != null)
                    {
                        if (mode.IsSingleSelection)
                        {
                            // Clear all marks, this will align everything it can
                            General.Map.Map.ClearMarkedSidedefs(false);
                        }
                        else
                        {
                            // Limit the alignment to selection only
                            General.Map.Map.ClearMarkedSidedefs(true);
                            List <Sidedef> sides = mode.GetSelectedSidedefs();
                            foreach (Sidedef sd in sides)
                            {
                                sd.Marked = false;
                            }
                        }

                        // Do the alignment
                        Tools.FloodfillTextures(this.Sidedef, oldtexturelong, newtextureimage, false);

                        // Get the changed sidedefs
                        List <Sidedef> changes = General.Map.Map.GetMarkedSidedefs(true);
                        foreach (Sidedef sd in changes)
                        {
                            // Update the parts for this sidedef!
                            if (mode.VisualSectorExists(sd.Sector))
                            {
                                BaseVisualSector   vs    = (mode.GetVisualSector(sd.Sector) as BaseVisualSector);
                                VisualSidedefParts parts = vs.GetSidedefParts(sd);
                                parts.SetupAllParts();
                            }
                        }

                        General.Map.Data.UpdateUsedTextures();
                        mode.Renderer.SetCrosshairBusy(false);
                        mode.ShowTargetInfo();
                    }
                }
            }
        }
Beispiel #8
0
        // This updates this virtual the sector and neightbours if needed
        public void UpdateSectorGeometry(bool includeneighbours)
        {
            if (isupdating)
            {
                return;
            }

            isupdating = true;
            changed    = true;

            // Not sure what from this part we need, so commented out for now
            SectorData data = GetSectorData();

            data.Reset();

            // Update sectors that rely on this sector
            foreach (KeyValuePair <Sector, bool> s in data.UpdateAlso)
            {
                if (mode.VisualSectorExists(s.Key))
                {
                    BaseVisualSector vs = (BaseVisualSector)mode.GetVisualSector(s.Key);
                    vs.UpdateSectorGeometry(s.Value);
                }
            }

            // Go for all things in this sector
            foreach (Thing t in General.Map.Map.Things)
            {
                if (t.Sector == this.Sector)
                {
                    if (mode.VisualThingExists(t))
                    {
                        // Update thing
                        BaseVisualThing vt = (mode.GetVisualThing(t) as BaseVisualThing);
                        vt.Changed = true;
                    }
                }
            }

            if (includeneighbours)
            {
                // Also rebuild surrounding sectors, because outside sidedefs may need to be adjusted
                foreach (Sidedef sd in this.Sector.Sidedefs)
                {
                    if (sd.Other != null)
                    {
                        if (mode.VisualSectorExists(sd.Other.Sector))
                        {
                            BaseVisualSector bvs = (BaseVisualSector)mode.GetVisualSector(sd.Other.Sector);
                            bvs.Changed = true;
                        }
                    }
                }
            }

            isupdating = false;
        }
        // Constructor
        public EffectThingLineSlope(SectorData data, Thing sourcething) : base(data)
        {
            thing = sourcething;

            // New effect added: This sector needs an update!
            if (data.Mode.VisualSectorExists(data.Sector))
            {
                BaseVisualSector vs = (BaseVisualSector)data.Mode.GetVisualSector(data.Sector);
                vs.UpdateSectorGeometry(true);
            }
        }
Beispiel #10
0
        // Constructor
        public Effect3DFloor(SectorData data, Linedef sourcelinedef) : base(data)
        {
            linedef = sourcelinedef;

            // New effect added: This sector needs an update!
            if (data.Mode.VisualSectorExists(data.Sector))
            {
                BaseVisualSector vs = (BaseVisualSector)data.Mode.GetVisualSector(data.Sector);
                vs.UpdateSectorGeometry(true);
            }
        }
        // Constructor
        public EffectThingVertexSlope(SectorData data, List <Thing> sourcethings, bool floor) : base(data)
        {
            things     = sourcethings;
            slopefloor = floor;

            // New effect added: This sector needs an update!
            if (data.Mode.VisualSectorExists(data.Sector))
            {
                BaseVisualSector vs = (BaseVisualSector)data.Mode.GetVisualSector(data.Sector);
                vs.UpdateSectorGeometry(true);
            }
        }
Beispiel #12
0
        // Sector height change
        public virtual void OnChangeTargetHeight(int amount)
        {
            changed = true;

            ChangeHeight(amount);

            // Rebuild sector
            if (mode.VisualSectorExists(level.sector))
            {
                BaseVisualSector vs = (BaseVisualSector)mode.GetVisualSector(level.sector);
                vs.UpdateSectorGeometry(true);
            }
        }
Beispiel #13
0
 // This changes the texture
 protected override void SetTexture(string texturename)
 {
     level.sector.SetCeilTexture(texturename);
     General.Map.Data.UpdateUsedTextures();
     if (level.sector == this.Sector.Sector)
     {
         this.Setup();
     }
     else if (mode.VisualSectorExists(level.sector))
     {
         BaseVisualSector vs = (BaseVisualSector)mode.GetVisualSector(level.sector);
         vs.UpdateSectorGeometry(false);
     }
 }
Beispiel #14
0
 // Paste properties
 public virtual void OnPasteProperties()
 {
     if (BuilderPlug.Me.CopiedSectorProps != null)
     {
         mode.CreateUndo("Paste sector properties");
         mode.SetActionResult("Pasted sector properties.");
         BuilderPlug.Me.CopiedSectorProps.Apply(level.sector);
         if (mode.VisualSectorExists(level.sector))
         {
             BaseVisualSector vs = (BaseVisualSector)mode.GetVisualSector(level.sector);
             vs.UpdateSectorGeometry(true);
         }
         mode.ShowTargetInfo();
     }
 }
Beispiel #15
0
 // Edit button released
 public virtual void OnEditEnd()
 {
     if (General.Interface.IsActiveWindow)
     {
         List <Sector> sectors = mode.GetSelectedSectors();
         DialogResult  result  = General.Interface.ShowEditSectors(sectors);
         if (result == DialogResult.OK)
         {
             // Rebuild sector
             foreach (Sector s in sectors)
             {
                 if (mode.VisualSectorExists(s))
                 {
                     BaseVisualSector vs = (BaseVisualSector)mode.GetVisualSector(s);
                     vs.UpdateSectorGeometry(true);
                 }
             }
         }
     }
 }
Beispiel #16
0
        // Flood-fill textures
        public virtual void OnTextureFloodfill()
        {
            if (BuilderPlug.Me.CopiedFlat != null)
            {
                string oldtexture     = GetTextureName();
                long   oldtexturelong = Lump.MakeLongName(oldtexture);
                string newtexture     = BuilderPlug.Me.CopiedFlat;
                if (newtexture != oldtexture)
                {
                    // Get the texture
                    ImageData newtextureimage = General.Map.Data.GetFlatImage(newtexture);
                    if (newtextureimage != null)
                    {
                        bool fillceilings = (this is VisualCeiling);

                        if (fillceilings)
                        {
                            mode.CreateUndo("Flood-fill ceilings with " + newtexture);
                            mode.SetActionResult("Flood-filled ceilings with " + newtexture + ".");
                        }
                        else
                        {
                            mode.CreateUndo("Flood-fill floors with " + newtexture);
                            mode.SetActionResult("Flood-filled floors with " + newtexture + ".");
                        }

                        mode.Renderer.SetCrosshairBusy(true);
                        General.Interface.RedrawDisplay();

                        if (mode.IsSingleSelection)
                        {
                            // Clear all marks, this will align everything it can
                            General.Map.Map.ClearMarkedSectors(false);
                        }
                        else
                        {
                            // Limit the alignment to selection only
                            General.Map.Map.ClearMarkedSectors(true);
                            List <Sector> sectors = mode.GetSelectedSectors();
                            foreach (Sector s in sectors)
                            {
                                s.Marked = false;
                            }
                        }

                        // Do the fill
                        Tools.FloodfillFlats(this.Sector.Sector, fillceilings, oldtexturelong, newtextureimage, false);

                        // Get the changed sectors
                        List <Sector> changes = General.Map.Map.GetMarkedSectors(true);
                        foreach (Sector s in changes)
                        {
                            // Update the visual sector
                            if (mode.VisualSectorExists(s))
                            {
                                BaseVisualSector vs = (mode.GetVisualSector(s) as BaseVisualSector);
                                if (fillceilings)
                                {
                                    vs.Ceiling.Setup();
                                }
                                else
                                {
                                    vs.Floor.Setup();
                                }
                            }
                        }

                        General.Map.Data.UpdateUsedTextures();
                        mode.Renderer.SetCrosshairBusy(false);
                        mode.ShowTargetInfo();
                    }
                }
            }
        }