Пример #1
0
        // Flood-fill textures
        public virtual void OnTextureFloodfill()
        {
            if (BuilderPlug.Me.CopiedFlat != null)
            {
                string oldtexture = GetTextureName();
                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;
                            }
                        }

                        //mxd. We potentially need to deal with 2 textures (because of long and short texture names)...
                        HashSet <long> oldtexturehashes = new HashSet <long> {
                            Texture.LongName, Lump.MakeLongName(oldtexture)
                        };

                        // Do the fill
                        Tools.FloodfillFlats(this.Sector.Sector, fillceilings, oldtexturehashes, newtexture, 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 = (BaseVisualSector)mode.GetVisualSector(s);
                                if (fillceilings)
                                {
                                    vs.Ceiling.Setup();
                                }
                                else
                                {
                                    vs.Floor.Setup();
                                }
                            }
                        }

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