Example #1
0
        public cv5 GetCV5(Control.MapEditor.DrawType drawType, TileType tileType, ushort MTXM)
        {
            int group = (MTXM >> 4);
            int index = (MTXM & 0xf);

            return(cv5data[tileType][group]);
        }
Example #2
0
        public Dictionary <FileData.TileSet.TileType, List <Texture2D> > GetTileDic(Control.MapEditor.DrawType drawType)
        {
            switch (drawType)
            {
            case Control.MapEditor.DrawType.SD:
                return(SDTileSet);

            case Control.MapEditor.DrawType.HD:
                return(HDTileSet);

            case Control.MapEditor.DrawType.CB:
                return(CBTileSet);
            }
            return(null);
        }
Example #3
0
        public Texture2D GetTile(Control.MapEditor.DrawType drawType, TileType tileType, ushort group, ushort index)
        {
            var t = cv5data[tileType];

            if (t.Length <= group)
            {
                return(null);
            }
            if (t[group].Index >= 256)
            {
                return(null);
            }


            return(GetTileDic(drawType)[tileType][t[group].tiles[index]]);
        }
Example #4
0
        public Color GetTileColor(Control.MapEditor.DrawType drawType, UseMapEditor.FileData.TileSet.TileType tileType, ushort MTXM)
        {
            int group = (MTXM >> 4);
            int index = (MTXM & 0xf);

            switch (drawType)
            {
            case Control.MapEditor.DrawType.SD:
                return(SDTileSetMiniMap[tileType][cv5data[tileType][group].tiles[index]]);

            case Control.MapEditor.DrawType.HD:
                return(HDTileSetMiniMap[tileType][cv5data[tileType][group].tiles[index]]);

            case Control.MapEditor.DrawType.CB:
                return(CBTileSetMiniMap[tileType][cv5data[tileType][group].tiles[index]]);
            }
            return(Color.Black);
        }
Example #5
0
        public ushort GetMegaTileIndex(Control.MapEditor.DrawType drawType, TileType tileType, ushort MTXM)
        {
            int group = (MTXM >> 4);
            int index = (MTXM & 0xf);

            var t = cv5data[tileType];

            if (t.Length <= group)
            {
                return(0);
            }
            if (t[group].Index >= 256)
            {
                return(0);
            }

            return(t[group].tiles[index]);
        }
Example #6
0
 public Texture2D GetMegaTileGrp(Control.MapEditor.DrawType drawType, TileType tileType, ushort megatileindex)
 {
     return(GetTileDic(drawType)[tileType][megatileindex]);
 }
Example #7
0
 public vf4 GetVf4(Control.MapEditor.DrawType drawType, TileType tileType, ushort megatileindex)
 {
     return(vf4data[tileType][megatileindex]);
 }
Example #8
0
        public GRP GetImageTexture(Control.MapEditor.DrawType drawType, int imageindex)
        {
            imageindex = GetImageIndex(imageindex);

            GRP rgrp = GRPDATA[drawType][imageindex];

            float scale;

            if (drawType == Control.MapEditor.DrawType.SD)
            {
                scale = 1;
            }
            else
            {
                scale = 2;
            }

            if (!rgrp.IsLoad)
            {
                //GRP로드가 되지 않았을 경우.
                string fname         = AppDomain.CurrentDomain.BaseDirectory + $"CascData\\{drawType.ToString()}\\anim\\" + imageindex.ToString() + "\\diffuse.png";
                string fcolorname    = AppDomain.CurrentDomain.BaseDirectory + $"CascData\\{drawType.ToString()}\\anim\\" + imageindex.ToString() + "\\teamcolor.png";
                string framedataname = AppDomain.CurrentDomain.BaseDirectory + $"CascData\\{drawType.ToString()}\\anim\\" + imageindex.ToString() + "\\framedata";
                rgrp.GRPFile = fname;
                if (File.Exists(fname))
                {
                    rgrp.MainGRP = LoadFromFile(fname);
                }
                if (File.Exists(fcolorname))
                {
                    rgrp.Color = LoadFromFile(fcolorname);
                }

                if (File.Exists(framedataname))
                {
                    BinaryReader br = new BinaryReader(new MemoryStream(File.ReadAllBytes(framedataname)));

                    rgrp.frameDatas = new GRP.FrameData[br.BaseStream.Length / 16];
                    rgrp.frameCount = br.ReadUInt16();
                    rgrp.grpwidth   = br.ReadUInt16();
                    rgrp.grpheight  = br.ReadUInt16();
                    for (int i = 0; i < rgrp.frameDatas.Length; i++)
                    {
                        GRP.FrameData frameData = new GRP.FrameData();

                        frameData.x       = (short)(br.ReadInt16() / scale);
                        frameData.y       = (short)(br.ReadInt16() / scale);
                        frameData.xoff    = (short)(br.ReadInt16() / scale);
                        frameData.yoff    = (short)(br.ReadInt16() / scale);
                        frameData.fwidth  = (short)(br.ReadInt16() / scale);
                        frameData.fheight = (short)(br.ReadInt16() / scale);
                        frameData.funk1   = (short)(br.ReadInt16() / scale);
                        frameData.funk2   = (short)(br.ReadInt16() / scale);

                        rgrp.frameDatas[i] = frameData;
                    }
                    if (drawType == Control.MapEditor.DrawType.SD)
                    {
                        rgrp.grpwidth  = (ushort)SDGRPSIZE[imageindex].X;
                        rgrp.grpheight = (ushort)SDGRPSIZE[imageindex].Y;
                    }



                    br.Close();
                }


                rgrp.IsLoad = true;
            }



            return(rgrp);
        }
Example #9
0
        private void DrawImage(Control.MapEditor.DrawType drawType, CImage cImage, float scale, float grpscale)
        {
            if (!mapeditor.view_Unit_StartLoc & cImage.imageID == 588)
            {
                return;
            }
            if (!mapeditor.view_Unit_Maprevealer & cImage.imageID == 582)
            {
                return;
            }



            Vector2 pos = cImage.screen;

            GRP  gRP    = null;
            bool setgrp = false;

            if (cImage.imageID == 588)
            {
                //스타트로케이션
                if (drawType == Control.MapEditor.DrawType.CB)
                {
                    gRP    = GetImageTexture(Control.MapEditor.DrawType.HD, cImage.imageID);
                    setgrp = true;
                }
            }

            if (!setgrp)
            {
                gRP = GetImageTexture(drawType, cImage.imageID);
            }


            if (gRP.frameCount == 0)
            {
                return;
            }
            int frame = cImage.Frame % gRP.frameCount;

            if (cImage.Turnable)
            {
                frame += cImage.turnFrame;
            }


            GRP.FrameData fd = gRP.frameDatas[frame];

            Vector2 p = pos;


            int x = 0, y = 0;

            switch (cImage.imageID)
            {
            case 235:
                break;

            case 251:
                if (drawType != Control.MapEditor.DrawType.CB)
                {
                    x = -8;
                    y = -16;
                }
                break;

            case 254:
                if (drawType != Control.MapEditor.DrawType.CB)
                {
                    x = -8;
                    y = -16;
                }
                break;

            case 588:
                //스타트로케이션
                if (drawType != Control.MapEditor.DrawType.SD)
                {
                    x = -61;
                    y = -32;
                }
                break;

            case 582:
                //맵리빌러
                if (drawType == Control.MapEditor.DrawType.HD)
                {
                    x = -16;
                    y = -16;
                }
                break;
            }


            Vector2 lol       = new Vector2(x, y);
            Vector2 grppos    = new Vector2(fd.xoff, fd.yoff) / grpscale;
            Vector2 grpsize   = new Vector2(gRP.grpwidth, gRP.grpheight) / grpscale / grpscale;
            Vector2 imgpospos = new Vector2(cImage.XOffset, cImage.YOffset);
            Vector2 framesize = new Vector2(fd.fwidth, fd.fheight) / grpscale;



            Vector2 LastPos = new Vector2();

            SpriteEffects spriteEffects = SpriteEffects.None;

            if (cImage.IsLeft)
            {
                spriteEffects = SpriteEffects.FlipHorizontally;

                LastPos.X = grpsize.X / 2 - grppos.X - framesize.X;
                LastPos.Y = grppos.Y - grpsize.Y / 2;

                LastPos += imgpospos + lol;
            }
            else
            {
                LastPos = grppos - grpsize / 2 + imgpospos + lol;
            }



            LastPos *= scale;

            p += LastPos;



            Color color = Color.White;

            bool drawcmp   = false;
            bool nonecolor = false;

            switch (cImage.drawType)
            {
            case CImage.DrawType.Shadow:
                color = new Color(0, 0, 0, 128);
                _spriteBatch.Begin(SpriteSortMode.FrontToBack, blendState: BlendState.NonPremultiplied, samplerState: SamplerState.PointClamp);
                _spriteBatch.Draw(gRP.MainGRP, p, new Rectangle(fd.x, fd.y, fd.fwidth, fd.fheight), color, 0, Vector2.Zero, scale / grpscale, spriteEffects, 1 - cImage.Level / 30f);
                _spriteBatch.End();
                return;

            case CImage.DrawType.Clock:
                color = new Color(255, 255, 255, 64);
                break;

            case CImage.DrawType.Hallaction:
                color     = new Color(64, 64, 255, 255);
                nonecolor = true;
                break;

            case CImage.DrawType.UnitSprite:
                color = Color.White;
                if (mapeditor.view_SpriteColor)
                {
                    color = mapeditor.SpriteOverlay;
                }
                //color = new Color(255, 0, 0, 255);
                break;

            case CImage.DrawType.PureSprite:
                if (mapeditor.view_SpriteColor)
                {
                    color = mapeditor.SpriteOverlay;
                }
                //color = new Color(0, 255, 0, 255);
                break;

            case CImage.DrawType.Doodad:
                if (mapeditor.view_DoodadColor)
                {
                    color = mapeditor.DoodadOverlay;
                }
                //color = new Color(0, 255, 0, 255);
                break;
            }
            if (!drawcmp)
            {
                _spriteBatch.Begin(SpriteSortMode.FrontToBack, blendState: BlendState.NonPremultiplied, samplerState: SamplerState.PointClamp);
                _spriteBatch.Draw(gRP.MainGRP, p, new Rectangle(fd.x, fd.y, fd.fwidth, fd.fheight), color, 0, Vector2.Zero, scale / grpscale, spriteEffects, 1 - cImage.Level / 30f);
            }


            _spriteBatch.End();
            if (!nonecolor)
            {
                if (cImage.color >= 0)
                {
                    if (gRP.Color != null)
                    {
                        Color unitColor = mapeditor.mapdata.UnitColor(cImage.color);

                        if (cImage.drawType == CImage.DrawType.Clock)
                        {
                            unitColor.A = 64;
                        }

                        //BlendState blendState = GraphicsDevice.BlendState;
                        //GraphicsDevice.BlendState = ColorBlend;

                        _colorBatch.Begin(SpriteSortMode.FrontToBack, ColorBlend, samplerState: SamplerState.PointClamp);
                        _colorBatch.Draw(gRP.Color, p, new Rectangle(fd.x, fd.y, fd.fwidth, fd.fheight), unitColor, 0, Vector2.Zero, scale / grpscale, spriteEffects, 1 - cImage.Level / 30f);

                        //GraphicsDevice.BlendState = blendState;

                        _colorBatch.End();
                    }
                }
            }



            _spriteBatch.Begin(blendState: BlendState.NonPremultiplied);

            if (cImage.IsHover | cImage.IsSelect)
            {
                Vector2 rectpos;
                Vector2 rectsize;
                if (cImage.IsUnitRect)
                {
                    rectpos  = pos - new Vector2(cImage.Left, cImage.Up) * scale;
                    rectsize = new Vector2(cImage.Left + cImage.Right, cImage.Up + cImage.Down) * scale;
                }
                else
                {
                    rectpos  = p;
                    rectsize = new Vector2(fd.fwidth, fd.fheight);

                    if (rectsize.LengthSquared() < 8)
                    {
                        rectpos  -= new Vector2(4 * scale);
                        rectsize += new Vector2(8);
                    }


                    rectsize *= scale / grpscale;
                }


                if (cImage.IsHover)
                {
                    _spriteBatch.Draw(gridtexture, new Rectangle((int)rectpos.X, (int)rectpos.Y, (int)rectsize.X, (int)rectsize.Y), null, new Color(128, 128, 255, 48), 0, new Vector2(), SpriteEffects.None, 1);
                    DrawRect(_spriteBatch, rectpos, rectpos + rectsize, Color.Red);
                }
                else if (cImage.IsSelect)
                {
                    _spriteBatch.Draw(gridtexture, new Rectangle((int)rectpos.X, (int)rectpos.Y, (int)rectsize.X, (int)rectsize.Y), null, new Color(128, 255, 128, 48), 0, new Vector2(), SpriteEffects.None, 1);
                    DrawRect(_spriteBatch, rectpos, rectpos + rectsize, Color.Red);
                }
            }
            _spriteBatch.End();
        }