Exemplo n.º 1
0
        //kind of like a menu, but not quite (uses borders)
        //draws the portrait

        public void Draw(SpriteBatch spriteBatch, Loc offset)
        {
            PortraitSheet portrait = GraphicsManager.GetPortrait(Speaker);

            Loc drawLoc = Loc + offset;

            if (!Bordered)
            {
                portrait.DrawPortrait(spriteBatch, new Vector2(drawLoc.X, drawLoc.Y), SpeakerEmotion);
            }
            else
            {
                int addX = 3 * MenuBase.BorderStyle;
                int addY = 3 * MenuBase.BorderFlash;

                TileSheet sheet = GraphicsManager.PicBorder;
                //pic
                portrait.DrawPortrait(spriteBatch, new Vector2(drawLoc.X + sheet.TileWidth, drawLoc.Y + sheet.TileHeight), SpeakerEmotion);

                //top-left
                sheet.DrawTile(spriteBatch, new Vector2(drawLoc.X, drawLoc.Y), addX, addY);
                //top-right
                sheet.DrawTile(spriteBatch, new Vector2(drawLoc.X + sheet.TileWidth + GraphicsManager.PortraitSize, drawLoc.Y), addX + 2, addY);
                //bottom-right
                sheet.DrawTile(spriteBatch, new Vector2(drawLoc.X + sheet.TileWidth + GraphicsManager.PortraitSize, drawLoc.Y + sheet.TileHeight + GraphicsManager.PortraitSize), addX + 2, addY + 2);
                //bottom-left
                sheet.DrawTile(spriteBatch, new Vector2(drawLoc.X, drawLoc.Y + sheet.TileHeight + GraphicsManager.PortraitSize), addX, addY + 2);

                //top
                sheet.DrawTile(spriteBatch, new Rectangle(drawLoc.X + sheet.TileWidth, drawLoc.Y, GraphicsManager.PortraitSize, sheet.TileHeight), addX + 1, addY, Color.White);

                //right
                sheet.DrawTile(spriteBatch, new Rectangle(drawLoc.X + sheet.TileWidth + GraphicsManager.PortraitSize, drawLoc.Y + sheet.TileHeight, sheet.TileWidth, GraphicsManager.PortraitSize), addX + 2, addY + 1, Color.White);

                //bottom
                sheet.DrawTile(spriteBatch, new Rectangle(drawLoc.X + sheet.TileWidth, drawLoc.Y + sheet.TileHeight + GraphicsManager.PortraitSize, GraphicsManager.PortraitSize, sheet.TileHeight), addX + 1, addY + 2, Color.White);

                //left
                sheet.DrawTile(spriteBatch, new Rectangle(drawLoc.X, drawLoc.Y + sheet.TileHeight, sheet.TileWidth, GraphicsManager.PortraitSize), addX, addY + 1, Color.White);
            }
        }
Exemplo n.º 2
0
        private void Export(string currentPath, MonsterID currentForm)
        {
            if (checkSprites)
            {
                CharSheet sheet = GraphicsManager.GetChara(currentForm);
                CharSheet.Export(sheet, currentPath);
            }
            else
            {
                PortraitSheet sheet = GraphicsManager.GetPortrait(currentForm);
                PortraitSheet.Export(sheet, currentPath);
            }


            DiagManager.Instance.LogInfo("Frames from:\n" +
                                         GetFormString(currentForm) +
                                         "\nhave been exported to:" + currentPath);


            btnReimport.Enabled = true;
        }
Exemplo n.º 3
0
        public static void BakePortrait(string spriteDir, Dictionary <MonsterID, byte[]> spriteData, MonsterID formData)
        {
            //check to see if files exist
            string[] pngs = Directory.GetFiles(spriteDir, "*.png", SearchOption.TopDirectoryOnly);
            if (pngs.Length < 1)
            {
                DiagManager.Instance.LogInfo("Skipped loading from " + Path.GetFullPath(spriteDir));
                return;
            }

            using (PortraitSheet sprite = PortraitSheet.Import(spriteDir))
            {
                using (MemoryStream stream = new MemoryStream())
                {
                    using (BinaryWriter writer = new BinaryWriter(stream))
                        sprite.Save(writer);
                    byte[] writingBytes = stream.ToArray();
                    spriteData[formData] = writingBytes;
                }
            }
            DiagManager.Instance.LogInfo("Loaded " + pngs.Length + " files from " + Path.GetFullPath(spriteDir));
        }
Exemplo n.º 4
0
        public override void DrawDebug(SpriteBatch spriteBatch)
        {
            BaseSheet blank = GraphicsManager.Pixel;

            ZoneManager.Instance.CurrentGround.DrawDebug(ViewRect.X, ViewRect.Y, ViewRect.Width, ViewRect.Height,
                                                         (int x, int y, int w, int h, float alpha) =>
            {
                blank.Draw(spriteBatch, new Rectangle((int)((x - ViewRect.X) * windowScale * scale), (int)((y - ViewRect.Y) * windowScale * scale), (int)(w * windowScale * scale), 1), null, Color.White * alpha);
                blank.Draw(spriteBatch, new Rectangle((int)((x - ViewRect.X) * windowScale * scale), (int)((y - ViewRect.Y) * windowScale * scale), 1, (int)(h * windowScale * scale)), null, Color.White * alpha);
            },
                                                         (AABB.IObstacle box) =>
            {
                if (box is GroundWall)
                {
                    blank.Draw(spriteBatch, new Rectangle((int)((box.Bounds.X - ViewRect.X) * windowScale * scale), (int)((box.Bounds.Y - ViewRect.Y) * windowScale * scale), (int)(box.Bounds.Width * windowScale * scale), (int)(box.Bounds.Height * windowScale * scale)), null, Color.Red * 0.3f);
                }
                else if (box is GroundChar)
                {
                    if (((GroundChar)box).EntEnabled)
                    {
                        blank.Draw(spriteBatch, new Rectangle((int)((box.Bounds.X - ViewRect.X) * windowScale * scale), (int)((box.Bounds.Y - ViewRect.Y) * windowScale * scale), (int)(box.Bounds.Width * windowScale * scale), (int)(box.Bounds.Height * windowScale * scale)), null, Color.Yellow * 0.7f);
                    }
                }
                else if (box is GroundObject)
                {
                    if (((GroundObject)box).EntEnabled)
                    {
                        blank.Draw(spriteBatch, new Rectangle((int)((box.Bounds.X - ViewRect.X) * windowScale * scale), (int)((box.Bounds.Y - ViewRect.Y) * windowScale * scale), (int)(box.Bounds.Width * windowScale * scale), (int)(box.Bounds.Height * windowScale * scale)), null, Color.Cyan * 0.5f);
                    }
                }
                else
                {
                    blank.Draw(spriteBatch, new Rectangle((int)((box.Bounds.X - ViewRect.X) * windowScale * scale), (int)((box.Bounds.Y - ViewRect.Y) * windowScale * scale), (int)(box.Bounds.Width * windowScale * scale), (int)(box.Bounds.Height * windowScale * scale)), null, Color.Gray * 0.5f);
                }
            }, (string message, int x, int y, float alpha) =>
            {
                int size = GraphicsManager.SysFont.SubstringWidth(message);
                GraphicsManager.SysFont.DrawText(spriteBatch, (int)((x - ViewRect.X) * windowScale * scale), (int)((y - ViewRect.Y) * windowScale * scale), message, null, DirV.None, DirH.None);
            });

            base.DrawDebug(spriteBatch);
            if (FocusedCharacter != null)
            {
                GraphicsManager.SysFont.DrawText(spriteBatch, GraphicsManager.WindowWidth - 2, 62, String.Format("Z:{0:D3} S:{1:D3} M:{2:D3}", ZoneManager.Instance.CurrentZoneID, ZoneManager.Instance.CurrentMapID.Segment, ZoneManager.Instance.CurrentMapID.ID), null, DirV.Up, DirH.Right, Color.White);
                GraphicsManager.SysFont.DrawText(spriteBatch, GraphicsManager.WindowWidth - 2, 72, String.Format("X:{0:D3} Y:{1:D3}", FocusedCharacter.MapLoc.X, FocusedCharacter.MapLoc.Y), null, DirV.Up, DirH.Right, Color.White);

                MonsterID monId;
                Loc       offset;
                int       anim;
                int       currentHeight, currentTime, currentFrame;
                FocusedCharacter.GetCurrentSprite(out monId, out offset, out currentHeight, out anim, out currentTime, out currentFrame);
                CharSheet charSheet  = GraphicsManager.GetChara(FocusedCharacter.CurrentForm);
                Color     frameColor = Color.White;
                string    animName   = GraphicsManager.Actions[anim].Name;
                int       resultAnim = charSheet.GetReferencedAnimIndex(anim);
                if (resultAnim == -1)
                {
                    frameColor = Color.Gray;
                }
                else if (resultAnim != anim)
                {
                    animName  += "->" + GraphicsManager.Actions[resultAnim].Name;
                    frameColor = Color.Yellow;
                }

                GraphicsManager.SysFont.DrawText(spriteBatch, GraphicsManager.WindowWidth - 2, 82, String.Format("{0}:{1}:{2:D2}", animName, FocusedCharacter.CharDir.ToString(), currentFrame), null, DirV.Up, DirH.Right, frameColor);
                GraphicsManager.SysFont.DrawText(spriteBatch, GraphicsManager.WindowWidth - 2, 92, String.Format("Frame {0:D3}", currentTime), null, DirV.Up, DirH.Right, Color.White);

                PortraitSheet sheet = GraphicsManager.GetPortrait(FocusedCharacter.CurrentForm);
                sheet.DrawPortrait(spriteBatch, new Vector2(0, GraphicsManager.WindowHeight - GraphicsManager.PortraitSize), new EmoteStyle(DebugEmote));
                frameColor = Color.White;
                string emoteName   = GraphicsManager.Emotions[DebugEmote].Name;
                int    resultEmote = sheet.GetReferencedEmoteIndex(DebugEmote);
                if (resultEmote == -1)
                {
                    frameColor = Color.Gray;
                }
                else if (resultEmote != DebugEmote)
                {
                    emoteName += "->" + GraphicsManager.Emotions[resultEmote].Name;
                    frameColor = Color.Yellow;
                }
                GraphicsManager.SysFont.DrawText(spriteBatch, 2, GraphicsManager.WindowHeight - GraphicsManager.PortraitSize - 2, emoteName, null, DirV.Down, DirH.Left, frameColor);
            }
        }