コード例 #1
0
        //mxd. Auto-align texture offsets
        public virtual void OnTextureAlign(bool alignx, bool aligny)
        {
            if (!General.Map.UDMF)
            {
                return;
            }

            //create undo
            string rest;

            if (alignx && aligny)
            {
                rest = "(X and Y)";
            }
            else if (alignx)
            {
                rest = "(X)";
            }
            else
            {
                rest = "(Y)";
            }

            mode.CreateUndo("Auto-align textures " + rest);
            mode.SetActionResult("Auto-aligned textures " + rest + ".");

            //get selection
            List <VisualGeometry> selection = mode.GetSelectedSurfaces();

            //align textures on slopes
            foreach (VisualGeometry vg in selection)
            {
                if (vg.GeometryType == VisualGeometryType.FLOOR || vg.GeometryType == VisualGeometryType.CEILING)
                {
                    if (vg.GeometryType == VisualGeometryType.FLOOR)
                    {
                        ((VisualFloor)vg).AlignTexture(alignx, aligny);
                    }
                    else
                    {
                        ((VisualCeiling)vg).AlignTexture(alignx, aligny);
                    }

                    vg.Sector.Sector.UpdateNeeded = true;
                    vg.Sector.Sector.UpdateCache();
                }
            }

            // Map is changed
            General.Map.Map.Update();
            General.Map.IsChanged = true;
            General.Interface.RefreshInfo();
        }
コード例 #2
0
        //mxd. Auto-align texture offsets
        public virtual void OnTextureAlign(bool alignx, bool aligny)
        {
            if (!General.Map.UDMF)
            {
                return;
            }

            //create undo
            string rest;

            if (alignx && aligny)
            {
                rest = "(X and Y)";
            }
            else if (alignx)
            {
                rest = "(X)";
            }
            else
            {
                rest = "(Y)";
            }

            mode.CreateUndo("Auto-align textures " + rest);
            mode.SetActionResult("Auto-aligned textures " + rest + ".");

            //get selection
            List <VisualGeometry> selection = mode.GetSelectedSurfaces();

            //align textures on slopes
            foreach (VisualGeometry vg in selection)
            {
                if (vg.GeometryType == VisualGeometryType.FLOOR || vg.GeometryType == VisualGeometryType.CEILING)
                {
                    // Might be a 3D floor, so we might need another VisualGeometry
                    VisualGeometry realvg;

                    if (vg.GeometryType == VisualGeometryType.FLOOR)
                    {
                        if (((VisualFloor)vg).ExtraFloor == null)
                        {
                            realvg = vg;
                        }
                        else
                        {
                            Sector           s  = ((VisualFloor)vg).GetControlSector();
                            BaseVisualSector vs = (BaseVisualSector)mode.GetVisualSector(s);
                            realvg = vs.Floor;
                        }
                    }
                    else
                    {
                        if (((VisualCeiling)vg).ExtraFloor == null)
                        {
                            realvg = vg;
                        }
                        else
                        {
                            Sector           s  = ((VisualCeiling)vg).GetControlSector();
                            BaseVisualSector vs = (BaseVisualSector)mode.GetVisualSector(s);
                            realvg = vs.Ceiling;
                        }
                    }

                    if (realvg.GeometryType == VisualGeometryType.FLOOR)
                    {
                        ((VisualFloor)realvg).AlignTexture(alignx, aligny);
                    }
                    else
                    {
                        ((VisualCeiling)realvg).AlignTexture(alignx, aligny);
                    }

                    realvg.Sector.Sector.UpdateNeeded = true;
                    realvg.Sector.Sector.UpdateCache();
                }
            }

            // Map is changed
            General.Map.Map.Update();
            General.Map.IsChanged = true;
            General.Interface.RefreshInfo();
        }