Ejemplo n.º 1
0
        private void DrawLetter(Type whichFont, float Fade, Color color, Rectangle destRect, Rectangle sourceRect)
        {
            switch (whichFont)
            {
            case Type.menuFont:
            case Type.sysfnt:
                // if you use Memory.SpriteBatchStartAlpha(SamplerState.PointClamp); you won't need
                // to trim last pixel. but it doesn't look good on low res fonts.
                //trim pixels to remove texture filtering artifacts.
                //sourceRect.Width -= 1;
                //sourceRect.Height -= 1;

                Memory.SpriteBatch.Draw(whichFont == Type.menuFont ? menuFont : sysfnt,
                                        destRect,
                                        sourceRect,
                                        color * Fade);

                break;

            case Type.sysFntBig:
                if (sysfntbig != null)
                {
                    if (!sysfntbig.Modded)
                    {
                        var ShadowdestRect = new Rectangle(destRect.Location, destRect.Size);
                        ShadowdestRect.Offset(2, 2);
                        sysfntbig.Draw(ShadowdestRect, sourceRect, Color.Black * Fade * .5f);
                    }
                    sysfntbig.Draw(destRect, sourceRect, color * Fade);
                }
                break;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Draw Item
        /// </summary>
        /// <param name="id"></param>
        /// <param name="dst"></param>
        /// <param name="fade"></param>
        public virtual void Draw(Enum id, Rectangle dst, float fade = 1)
        {
            Rectangle      src = GetEntry(id).GetRectangle;
            TextureHandler tex = GetTexture(id);

            tex.Draw(dst, src, Color.White * fade);
        }
Ejemplo n.º 3
0
        private void DrawLetter(Vector2 zoom, Type whichFont, float Fade, ColorID color, bool blink, Rectangle destRect, Rectangle sourceRect)
        {
            switch (whichFont)
            {
            case Type.menuFont:
            case Type.sysfnt:
                // if you use Memory.SpriteBatchStartAlpha(SamplerState.PointClamp); you won't need
                // to trim last pixel. but it doesn't look good on low res fonts.
                //trim pixels to remove texture filtering artifacts.
                //sourceRect.Width -= 1;
                //sourceRect.Height -= 1;

                Memory.spriteBatch.Draw(whichFont == Type.menuFont ? menuFont : sysfnt,
                                        destRect,
                                        sourceRect,
                                        ColorID2Color[color] * Fade);

                if (blink)
                {
                    Memory.spriteBatch.Draw(whichFont == Type.menuFont ? menuFont : sysfnt,
                                            destRect,
                                            sourceRect,
                                            ColorID2Blink[color] * Fade * Menu.Blink_Amount);
                }
                break;

            case Type.sysFntBig:
                if (!sysfntbig.Modded)
                {
                    Rectangle ShadowdestRect = new Rectangle(destRect.Location, destRect.Size);
                    ShadowdestRect.Offset(zoom);
                    sysfntbig.Draw(ShadowdestRect, sourceRect, Color.Black * Fade * .5f);
                }
                sysfntbig.Draw(destRect, sourceRect, ColorID2Color[color] * Fade);
                if (blink)
                {
                    sysfntbig.Draw(destRect, sourceRect, ColorID2Blink[color] * Fade * Menu.Blink_Amount);
                }
                break;
            }
        }
Ejemplo n.º 4
0
        public virtual void Draw(Enum id, Rectangle dst, Vector2 fill, float fade = 1)
        {
            Rectangle src = GetEntry(id).GetRectangle;

            if (fill == Vector2.UnitX)
            {
                float r = (float)dst.Height / dst.Width;
                src.Height = (int)Math.Round(src.Height * r);
            }
            else if (fill == Vector2.UnitY)
            {
                float r = (float)dst.Width / dst.Height;
                src.Width = (int)Math.Round(src.Width * r);
            }
            TextureHandler tex = GetTexture(id);

            tex.Draw(dst, src, Color.White * fade);
        }
Ejemplo n.º 5
0
        public Rectangle RenderBasicText(FF8String buffer, Vector2 pos, Vector2 zoom, Type whichFont = 0, float Fade = 1.0f, int lineSpacing = 0, bool skipdraw = false, ColorID color = ColorID.White)
        {
            if (buffer == null)
            {
                return(new Rectangle());
            }
            Rectangle ret            = new Rectangle(pos.RoundedPoint(), new Point(0));
            Point     real           = pos.RoundedPoint();
            int       charCountWidth = 21;
            int       charSize       = 12; //pixelhandler does the 2x scaling on the fly.
            Point     size           = (new Vector2(0, charSize) * zoom).RoundedPoint();
            int       width;

            foreach (byte cs in buffer)
            {
                byte[] expanded = cs > 0xE1 && FF8String.BytetoStr.ContainsKey(cs)?
                                  FF8String.BytetoStr[cs].Value : new byte[] { cs };
                foreach (byte c in expanded)
                {
                    if (c == 0)
                    {
                        continue;
                    }
                    int deltaChar = (c - 32);
                    if (deltaChar >= 0 && deltaChar < charWidths.Length)
                    {
                        width  = charWidths[deltaChar];
                        size.X = (int)(charWidths[deltaChar] * zoom.X);
                    }
                    else
                    {
                        width  = charSize;
                        size.X = (int)(charSize * zoom.X);
                    }
                    Point curSize          = size;
                    int   verticalPosition = deltaChar / charCountWidth;
                    //i.e. 1280 is 100%, 640 is 50% and therefore 2560 is 200% which means multiply by 0.5f or 2.0f
                    if (c == 0x02)// \n
                    {
                        real.X  = (int)pos.X;
                        real.Y += size.Y + lineSpacing;
                        continue;
                    }
                    Rectangle destRect = new Rectangle(real, size);
                    // if you use Memory.SpriteBatchStartAlpha(SamplerState.PointClamp); you won't need
                    // to trim last pixel. but it doesn't look good on low res fonts.
                    if (!skipdraw)
                    {
                        Rectangle sourceRect = new Rectangle((deltaChar - (verticalPosition * charCountWidth)) * charSize,
                                                             verticalPosition * charSize,
                                                             width,
                                                             charSize);

                        switch (whichFont)
                        {
                        case Type.menuFont:
                        case Type.sysfnt:
                            //trim pixels to remove texture filtering artifacts.
                            sourceRect.Width  -= 1;
                            sourceRect.Height -= 1;
                            Memory.spriteBatch.Draw(whichFont == Type.menuFont ? menuFont : sysfnt,
                                                    destRect,
                                                    sourceRect,
                                                    ColorID2Color[color] * Fade);
                            break;

                        case Type.sysFntBig:
                            if (!sysfntbig.Modded)
                            {
                                Rectangle ShadowdestRect = new Rectangle(destRect.Location, destRect.Size);
                                ShadowdestRect.Offset(zoom);
                                sysfntbig.Draw(ShadowdestRect, sourceRect, Color.Black * Fade * .5f);
                            }
                            sysfntbig.Draw(destRect, sourceRect, ColorID2Color[color] * Fade);
                            break;
                        }
                    }
                    real.X += size.X;
                    int curWidth = real.X - (int)pos.X;
                    if (curWidth > ret.Width)
                    {
                        ret.Width = curWidth;
                    }
                }
            }
            ret.Height = size.Y + (real.Y - (int)pos.Y);
            return(ret);
        }