Ejemplo n.º 1
0
        // 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();
                    }
                }
            }
        }
        // Paste properties
        public void OnPasteProperties(bool usecopysettings)
        {
            if (BuilderPlug.Me.CopiedVertexProps != null)
            {
                mode.CreateUndo("Paste vertex properties");
                mode.SetActionResult("Pasted vertex properties.");
                BuilderPlug.Me.CopiedVertexProps.Apply(vertex, usecopysettings);

                //update affected sectors
                UpdateGeometry(vertex);
                changed = true;
                mode.ShowTargetInfo();
            }
        }
Ejemplo n.º 3
0
 // Paste properties
 public virtual void OnPasteProperties()
 {
     if (BuilderPlug.Me.CopiedThingProps != null)
     {
         mode.CreateUndo("Paste thing properties");
         mode.SetActionResult("Pasted thing properties.");
         BuilderPlug.Me.CopiedThingProps.Apply(Thing);
         Thing.UpdateConfiguration();
         this.Rebuild();
         mode.ShowTargetInfo();
     }
 }
Ejemplo n.º 4
0
 // Paste properties
 public void OnPasteProperties(bool usecopysettings)
 {
     if (BuilderPlug.Me.CopiedThingProps != null)
     {
         mode.CreateUndo("Paste thing properties");
         mode.SetActionResult("Pasted thing properties.");
         BuilderPlug.Me.CopiedThingProps.Apply(Thing, usecopysettings);                 //mxd. Added "usecopysettings"
         Thing.UpdateConfiguration();
         this.Rebuild();
         mode.ShowTargetInfo();
     }
 }
Ejemplo n.º 5
0
        // This is called to update UV dragging
        protected virtual void UpdateDragUV()
        {
            float u_ray = 1.0f;

            // Calculate intersection position
            this.Level.plane.GetIntersection(General.Map.VisualCamera.Position, General.Map.VisualCamera.Target, ref u_ray);
            Vector3D intersect = General.Map.VisualCamera.Position + (General.Map.VisualCamera.Target - General.Map.VisualCamera.Position) * u_ray;

            // Calculate offsets
            Vector3D dragdelta = intersect - dragorigin;
            float    offsetx   = dragdelta.x;
            float    offsety   = dragdelta.y;

            bool lockX = General.Interface.CtrlState && !General.Interface.ShiftState;
            bool lockY = !General.Interface.CtrlState && General.Interface.ShiftState;

            if (lockX || lockY)
            {
                float camAngle = Angle2D.RadToDeg(General.Map.VisualCamera.AngleXY);

                if (camAngle > 315 || camAngle < 46)
                {
                    if (lockX)
                    {
                        offsetx = 0;
                    }
                    if (lockY)
                    {
                        offsety = 0;
                    }
                }
                else if (camAngle > 225)
                {
                    if (lockX)
                    {
                        offsety = 0;
                    }
                    if (lockY)
                    {
                        offsetx = 0;
                    }
                }
                else if (camAngle > 135)
                {
                    if (lockX)
                    {
                        offsetx = 0;
                    }
                    if (lockY)
                    {
                        offsety = 0;
                    }
                }
                else
                {
                    if (lockX)
                    {
                        offsety = 0;
                    }
                    if (lockY)
                    {
                        offsetx = 0;
                    }
                }
            }

            //mxd. Modify offsets based on surface and camera angles
            float angle;

            if (GeometryType == VisualGeometryType.CEILING)
            {
                angle = Angle2D.DegToRad(level.sector.Fields.GetValue("rotationceiling", 0f));
            }
            else
            {
                angle = Angle2D.DegToRad(level.sector.Fields.GetValue("rotationfloor", 0f));
            }

            Vector2D v = new Vector2D(offsetx, offsety).GetRotated(angle);

            offsetx = (int)Math.Round(v.x);
            offsety = (int)Math.Round(v.y);

            // Calculate deltas
            int deltax, deltay;

            if (General.Interface.CtrlState && General.Interface.ShiftState)
            {
                //mxd. Clamp to grid size?
                int newoffsetx = startoffsetx - (int)Math.Round(offsetx);
                int newoffsety = startoffsety + (int)Math.Round(offsety);
                deltax = prevoffsetx - newoffsetx;
                deltay = prevoffsety - newoffsety;

                if (Math.Abs(deltax) >= General.Map.Grid.GridSize)
                {
                    deltax      = General.Map.Grid.GridSize * Math.Sign(deltax);
                    prevoffsetx = newoffsetx;
                }
                else
                {
                    deltax = 0;
                }

                if (Math.Abs(deltay) >= General.Map.Grid.GridSize)
                {
                    deltay      = General.Map.Grid.GridSize * Math.Sign(deltay);
                    prevoffsety = newoffsety;
                }
                else
                {
                    deltay = 0;
                }
            }
            else
            {
                int newoffsetx = startoffsetx - (int)Math.Round(offsetx);
                int newoffsety = startoffsety + (int)Math.Round(offsety);

                deltax = prevoffsetx - newoffsetx;
                deltay = prevoffsety - newoffsety;

                prevoffsetx = newoffsetx;
                prevoffsety = newoffsety;
            }

            //mxd. Apply offset?
            if (deltax != 0 || deltay != 0)
            {
                mode.ApplyFlatOffsetChange(deltax, deltay);
            }
            mode.ShowTargetInfo();
        }
Ejemplo n.º 6
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();
                    }
                }
            }
        }