Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="tex"></param>
        /// <param name="start"></param>
        /// <param name="shiftZ"></param>
        /// <param name="CopyTransparent"></param>
        /// <returns>Was the texture clipped when drawing?</returns>
        internal bool CopyTexture(ZBufferedTexture tex, CellStruct start, int shiftZ = 0, bool CopyTransparent = true)
        {
            var clipped = false;

            for (var y = 0; y < tex.Height; ++y)
            {
                for (var x = 0; x < tex.Width; ++x)
                {
                    var oldIx = y * tex.Width + x;
                    var shX   = x + start.X;
                    var shY   = y + start.Y;
                    if (shX >= 0 && shX < Width && shY >= 0 && shY < Height)
                    {
                        var newIx = shY * Width + shX;

                        var oldPx = tex.Pixels[oldIx];
                        if (oldPx != DummyColor || CopyTransparent)
                        {
                            var ixZ = tex.ZIndices[oldIx] + shiftZ;
                            if (ixZ >= ZIndices[newIx])
                            {
                                Pixels[newIx]   = tex.Pixels[oldIx];
                                ZIndices[newIx] = ixZ;
                            }
                        }
                    }
                    else
                    {
                        clipped = true;
                    }
                }
            }

            return(clipped);
        }
Example #2
0
        public IEnumerable<Texture2D> GetLayerTextures(GraphicsDevice gd)
        {
            var Tactical = TacticalClass.Instance;

            Helpers.ZBufferedTexture T;

            if (LayerTextures.Count == 0) {
                T = new Helpers.ZBufferedTexture(Tactical.Width, Tactical.Height);
                LayerTextures.Add(T);
            } else {
                T = LayerTextures[0];
            }

            T.Clear();
            foreach (var c in VisibleCells) {
                c.DrawOverlays(T);
            }

            foreach (var c in VisibleCells) {
                for (var obj = c.FirstObject.Value; obj != null; obj = obj.NextObject.Value) {
                    obj.Draw(T);
                }
            }

            return LayerTextures.Select(TX => TX.Compile(gd));
        }
Example #3
0
        public IEnumerable <Texture2D> GetLayerTextures(GraphicsDevice gd)
        {
            var Tactical = TacticalClass.Instance;

            Helpers.ZBufferedTexture T;

            if (LayerTextures.Count == 0)
            {
                T = new Helpers.ZBufferedTexture(Tactical.Width, Tactical.Height);
                LayerTextures.Add(T);
            }
            else
            {
                T = LayerTextures[0];
            }

            T.Clear();
            foreach (var c in VisibleCells)
            {
                c.DrawOverlays(T);
            }

            foreach (var c in VisibleCells)
            {
                for (var obj = c.FirstObject.Value; obj != null; obj = obj.NextObject.Value)
                {
                    obj.Draw(T);
                }
            }

            return(LayerTextures.Select(TX => TX.Compile(gd)));
        }
Example #4
0
        internal bool CopyBlockFrom(ZBufferedTexture tex, int shiftX, int shiftY, int shiftZ = 0, bool CopyTransparent = true)
        {
            var clipped = false;

            for (var y = 0; y < tex.Height - Math.Abs(shiftY); ++y)
            {
                for (var x = 0; x < tex.Width - Math.Abs(shiftX); ++x)
                {
                    var oldIx = y * tex.Width + x;
                    var shX   = x + shiftX;
                    var shY   = y + shiftY;
                    if (shX >= 0 && shX < Width && shY >= 0 && shY < Height)
                    {
                        var newIx = shY * Width + shX;

                        var oldPx = tex.Pixels[oldIx];
                        if (oldPx != CCClasses.FileFormats.Binary.PAL.TranslucentColor || CopyTransparent)
                        {
                            Pixels[newIx]   = tex.Pixels[oldIx];
                            ZIndices[newIx] = tex.ZIndices[oldIx] + shiftZ;
                        }
                    }
                    else
                    {
                        clipped = true;
                    }
                }
            }

            return(clipped);
        }
Example #5
0
        internal void DrawOverlays(Helpers.ZBufferedTexture T)
        {
            if (OverlayTypeIndex != -1)
            {
                var OTypes = CCFactory <OverlayTypeClass, OverlayClass> .Get().FactoryItems;

                var OT  = OTypes[OverlayTypeIndex];
                var pos = TacticalPosition + new CellStruct(30, 15) + OverlayPosition;
                pos.Y -= (2);// + OverlayPosition.Y);
                var tImage = OT.SHPImage.Value;
                if (OT.Tiberium)
                {
                    var ix = OverlayClass.OverlayToTiberium(OverlayTypeIndex);
                    if (ix != -1)
                    {
                        var t = TiberiumClass.All[ix];
                        OverlayTypeClass tOverlay;
                        if (Slope != 0)
                        {
                            tOverlay = OTypes[t.NumImages + t.NumExtraImages / 4 * (Slope - 1) + t.Overlay.ArrayIndex];
                        }
                        else
                        {
                            tOverlay = OTypes[t.Overlay.ArrayIndex + X * Y % t.NumImages];
                        }
//                        tImage.DrawIntoTexture(T, pos, (uint)OverlayState, MapTheater.TemperatePAL);
                    }
                }
                else if (OT.Wall)
                {
                    //                  tImage.DrawIntoTexture(T, pos, (uint)OverlayState, MapTheater.unitPAL);
                }
            }
        }
Example #6
0
        internal bool DrawSubTile(int IsoTileTypeSubIndex, Helpers.ZBufferedTexture tex, CellStruct TopLeft, int CellLevel, bool highlight = false)
        {
            var t = getSubTile(IsoTileTypeSubIndex);

            var clipped = tex.CopyTexture(t.GetTextureStandalone(isoPAL), new CellStruct(TopLeft.X + t.Bounds.X, TopLeft.Y + t.Bounds.Y), CellLevel * 30, false);

            if (highlight)
            {
                t.Highlight(tex, TopLeft);
            }

            return(clipped);
        }
Example #7
0
        public Texture2D GetTexture(GraphicsDevice gd)
        {
            var Tactical = TacticalClass.Instance;

            var Reusable = Rectangle.Intersect(LastScreenArea, Tactical.ScreenArea);

            var shiftX = LastScreenArea.X - Tactical.ScreenArea.X;
            var shiftY = LastScreenArea.Y - Tactical.ScreenArea.Y;

            if (TileTexture == null)
            {
                TileTexture = new Helpers.ZBufferedTexture(Tactical.Width, Tactical.Height);
            }
            else
            {
                TileTexture.Clear();
            }

            //if (LastTextureData != null) {
            //    //TileTexture.CopyBlockFrom(LastTextureData, shiftX, shiftY);
            //}

            VisibleCells.Clear();

            foreach (var c in cellIter.Range())
            {
                Tactical.UpdateCellPosition(c);
                if (c.VisibleInTactical)
                {
                    VisibleCells.Add(c);
                }
            }

            foreach (var c in VisibleCells)
            {
                c.Draw(TileTexture);
            }

            LastScreenArea = Tactical.ScreenArea;

            return(TileTexture.Compile(gd));
        }
Example #8
0
        public void Draw(Helpers.ZBufferedTexture tex)
        {
            var tile  = IsoTile;
            var start = TacticalPosition;

            if (tile != null)
            {
//                if (!PreviouslyVisibleInTactical || PreviouslyClippedInTactical) {
                //ClippedInTactical =
                tile.DrawSubTile(IsoTileTypeSubIndex, tex, start, Level, OverlayTypeIndex != -1);
                //              }
            }

            //if (!PreviouslyVisibleInTactical || PreviouslyClippedInTactical) {
            //    if (ClippedInTactical) {
            //        //Debug.WriteLine("Cell {0},{1} was clipped", X, Y);
            //    }
            //} else if (!PreviouslyClippedInTactical) {
            //    //Debug.WriteLine("Cell {0},{1} was preclipped", X, Y);
            //}
        }
Example #9
0
        public Texture2D GetTexture(GraphicsDevice gd)
        {
            var Tactical = TacticalClass.Instance;

            var Reusable = Rectangle.Intersect(LastScreenArea, Tactical.ScreenArea);

            var shiftX = LastScreenArea.X - Tactical.ScreenArea.X;
            var shiftY = LastScreenArea.Y - Tactical.ScreenArea.Y;

            if (TileTexture == null) {
                TileTexture = new Helpers.ZBufferedTexture(Tactical.Width, Tactical.Height);
            } else {
                TileTexture.Clear();
            }

            //if (LastTextureData != null) {
            //    //TileTexture.CopyBlockFrom(LastTextureData, shiftX, shiftY);
            //}

            VisibleCells.Clear();

            foreach(var c in cellIter.Range()) {
                Tactical.UpdateCellPosition(c);
                if (c.VisibleInTactical) {
                    VisibleCells.Add(c);
                }
            }

            foreach (var c in VisibleCells) {
                c.Draw(TileTexture);
            }

            LastScreenArea = Tactical.ScreenArea;

            return TileTexture.Compile(gd);
        }
Example #10
0
        internal bool CopyBlockFrom(ZBufferedTexture tex, int shiftX, int shiftY, int shiftZ = 0, bool CopyTransparent = true)
        {
            var clipped = false;
            for (var y = 0; y < tex.Height - Math.Abs(shiftY); ++y) {
                for (var x = 0; x < tex.Width - Math.Abs(shiftX); ++x) {
                    var oldIx = y * tex.Width + x;
                    var shX = x + shiftX;
                    var shY = y + shiftY;
                    if (shX >= 0 && shX < Width && shY >= 0 && shY < Height) {
                        var newIx = shY * Width + shX;

                        var oldPx = tex.Pixels[oldIx];
                        if (oldPx != CCClasses.FileFormats.Binary.PAL.TranslucentColor || CopyTransparent) {
                            Pixels[newIx] = tex.Pixels[oldIx];
                            ZIndices[newIx] = tex.ZIndices[oldIx] + shiftZ;
                        }
                    } else {
                        clipped = true;
                    }
                }
            }

            return clipped;
        }
Example #11
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="tex"></param>
        /// <param name="start"></param>
        /// <param name="shiftZ"></param>
        /// <param name="CopyTransparent"></param>
        /// <returns>Was the texture clipped when drawing?</returns>
        internal bool CopyTexture(ZBufferedTexture tex, CellStruct start, int shiftZ = 0, bool CopyTransparent = true)
        {
            var clipped = false;
            for (var y = 0; y < tex.Height; ++y) {
                for (var x = 0; x < tex.Width; ++x) {
                    var oldIx = y * tex.Width + x;
                    var shX = x + start.X;
                    var shY = y + start.Y;
                    if (shX >= 0 && shX < Width && shY >= 0 && shY < Height) {
                        var newIx = shY * Width + shX;

                        var oldPx = tex.Pixels[oldIx];
                        if (oldPx != DummyColor || CopyTransparent) {
                            var ixZ = tex.ZIndices[oldIx] + shiftZ;
                            if (ixZ >= ZIndices[newIx]) {
                                Pixels[newIx] = tex.Pixels[oldIx];
                                ZIndices[newIx] = ixZ;
                            }
                        }
                    } else {
                        clipped = true;
                    }
                }
            }

            return clipped;
        }