Ejemplo n.º 1
0
        // 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();
            }
        }
Ejemplo n.º 2
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();
                    }
                }
            }
        }
Ejemplo n.º 3
0
        // Paste texture offsets
        public virtual void OnPasteTextureOffsets()
        {
            mode.CreateUndo("Paste texture offsets");
            Sidedef.OffsetX = BuilderPlug.Me.CopiedOffsets.X;
            Sidedef.OffsetY = BuilderPlug.Me.CopiedOffsets.Y;
            mode.SetActionResult("Pasted texture offsets " + Sidedef.OffsetX + ", " + Sidedef.OffsetY + ".");

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

            parts.SetupAllParts();
        }
Ejemplo n.º 4
0
        // Reset texture offsets
        public virtual void OnResetTextureOffset()
        {
            mode.CreateUndo("Reset texture offsets");
            mode.SetActionResult("Texture offsets reset.");

            // Apply offsets
            Sidedef.OffsetX = 0;
            Sidedef.OffsetY = 0;

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

            parts.SetupAllParts();
        }
Ejemplo n.º 5
0
        // Texture offset change
        public virtual void OnChangeTextureOffset(int horizontal, int vertical)
        {
            if ((General.Map.UndoRedo.NextUndo == null) || (General.Map.UndoRedo.NextUndo.TicketID != undoticket))
            {
                undoticket = mode.CreateUndo("Change texture offsets");
            }

            // Apply offsets
            Sidedef.OffsetX -= horizontal;
            Sidedef.OffsetY -= vertical;

            mode.SetActionResult("Changed texture offsets to " + Sidedef.OffsetX + ", " + Sidedef.OffsetY + ".");

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

            parts.SetupAllParts();
        }
Ejemplo n.º 6
0
        // 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;
                }
            }

            // Do the alignment
            Tools.AutoAlignTextures(this.Sidedef, 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();
                }
            }
        }
Ejemplo n.º 7
0
        // This usually happens when geometry is changed by undo, redo, cut or paste actions
        // and uses the marks to check what needs to be reloaded.
        protected override void ResourcesReloadedPartial()
        {
            bool sectorsmarked = false;

            if (General.Map.UndoRedo.GeometryChanged)
            {
                // Let the core do this (it will just dispose the sectors that were changed)
                base.ResourcesReloadedPartial();
            }
            else
            {
                // Neighbour sectors must be updated as well
                foreach (Sector s in General.Map.Map.Sectors)
                {
                    if (s.Marked)
                    {
                        sectorsmarked = true;
                        foreach (Sidedef sd in s.Sidedefs)
                        {
                            sd.Marked = true;
                            if (sd.Other != null)
                            {
                                sd.Other.Marked = true;
                            }
                        }
                    }
                }

                // Go for all sidedefs to update
                foreach (Sidedef sd in General.Map.Map.Sidedefs)
                {
                    if (sd.Marked && VisualSectorExists(sd.Sector))
                    {
                        BaseVisualSector   vs    = (BaseVisualSector)GetVisualSector(sd.Sector);
                        VisualSidedefParts parts = vs.GetSidedefParts(sd);
                        parts.SetupAllParts();
                    }
                }

                // Go for all sectors to update
                foreach (Sector s in General.Map.Map.Sectors)
                {
                    if (s.Marked && VisualSectorExists(s))
                    {
                        BaseVisualSector vs = (BaseVisualSector)GetVisualSector(s);
                        vs.Floor.Setup();
                        vs.Ceiling.Setup();
                    }
                }

                if (!sectorsmarked)
                {
                    // No sectors or geometry changed. So we only have
                    // to update things when they have changed.
                    foreach (KeyValuePair <Thing, VisualThing> vt in allthings)
                    {
                        if (vt.Key.Marked)
                        {
                            (vt.Value as BaseVisualThing).Rebuild();
                        }
                    }
                }
                else
                {
                    // Things depend on the sector they are in and because we can't
                    // easily determine which ones changed, we dispose all things
                    foreach (KeyValuePair <Thing, VisualThing> vt in allthings)
                    {
                        vt.Value.Dispose();
                    }

                    // Apply new lists
                    allthings = new Dictionary <Thing, VisualThing>(allthings.Count);
                }

                // Clear visibility collections
                visiblesectors.Clear();
                visibleblocks.Clear();
                visiblegeometry.Clear();
                visiblethings.Clear();

                // Make new blockmap
                if (sectorsmarked || General.Map.UndoRedo.PopulationChanged)
                {
                    FillBlockMap();
                }

                // Visibility culling (this re-creates the needed resources)
                DoCulling();
            }

            // Determine what we're aiming at now
            PickTarget();
        }