Пример #1
0
        public void Pack(string chars, Font font, string prefix)
        {
            DrawTextArgs args = new DrawTextArgs("", font, true);

            widths = new int[chars.Length];

            using (IDrawer2D drawer = game.Drawer2D) {
                args.Text = prefix;
                Size size = game.Drawer2D.MeasureText(ref args);
                offset      = size.Width;
                size.Width += fontSize * chars.Length;

                using (Bitmap bmp = IDrawer2D.CreatePow2Bitmap(size)) {
                    drawer.SetBitmap(bmp);
                    drawer.DrawText(ref args, 0, 0);

                    for (int i = 0; i < chars.Length; i++)
                    {
                        args.Text = new String(chars[i], 1);
                        widths[i] = game.Drawer2D.MeasureText(ref args).Width;
                        drawer.DrawText(ref args, offset + fontSize * i, 0);
                    }

                    tex = drawer.Make2DTexture(bmp, size, 0, 0);
                    drawer.ReducePadding(ref tex, Utils.Floor(font.Size), 4);

                    uScale    = 1.0f / bmp.Width;
                    tex.U2    = offset * uScale;
                    tex.Width = (ushort)offset;
                }
            }
        }
Пример #2
0
        public void SetText(string value)
        {
            chatInputText.Clear();
            chatInputText.Append(0, value);
            DrawTextArgs args     = new DrawTextArgs(value, font, false);
            Size         textSize = game.Drawer2D.MeasureSize(ref args);
            Size         size     = new Size(Math.Max(textSize.Width, DesiredMaxWidth),
                                             Math.Max(textSize.Height, DesiredMaxHeight));

            yOffset = 0;
            if (textSize.Height < DesiredMaxHeight)
            {
                yOffset = DesiredMaxHeight / 2 - textSize.Height / 2;
            }

            using (Bitmap bmp = IDrawer2D.CreatePow2Bitmap(size))
                using (IDrawer2D drawer = game.Drawer2D)
                {
                    drawer.SetBitmap(bmp);
                    drawer.DrawRect(backColour, 0, 0, size.Width, size.Height);
                    args.SkipPartsCheck = true;
                    drawer.DrawText(ref args, 0, 0);

                    args.Text           = Validator.Range;
                    args.SkipPartsCheck = false;
                    Size hintSize = drawer.MeasureSize(ref args);

                    args.SkipPartsCheck = true;
                    int hintX = size.Width - hintSize.Width;
                    if (textSize.Width < hintX)
                    {
                        drawer.DrawText(ref args, hintX, 0);
                    }
                    chatInputTexture = drawer.Make2DTexture(bmp, size, 0, yOffset);
                }

            X = CalcOffset(game.Width, size.Width, XOffset, HorizontalAnchor);
            Y = CalcOffset(game.Height, size.Height, YOffset, VerticalAnchor);
            chatCaretTexture.X1  = chatInputTexture.X1 = X;
            chatCaretTexture.X1 += textSize.Width;
            chatCaretTexture.Y1  = chatInputTexture.Y1 = Y;
            chatCaretTexture.Y1  = (Y + size.Height) - chatCaretTexture.Height;
            Width  = size.Width;
            Height = size.Height;
        }
Пример #3
0
        public void Redraw( IDrawer2D drawer, string text, Font font )
        {
            DrawTextArgs args = new DrawTextArgs( text, font, true );
            Size size = drawer.MeasureSize( ref args );
            Width = size.Width; Height = size.Height;

            args.SkipPartsCheck = true;
            drawer.DrawText( ref args, X, Y );
            Text = text;
        }
 public void Redraw( IDrawer2D drawer )
 {
     drawer.DrawRect( FastColour.Black, X, Y, Width, Height );
     if( Value ) {
         DrawTextArgs args = new DrawTextArgs( "X", font, false );
         Size size = drawer.MeasureSize( ref args );
         args.SkipPartsCheck = true;
         drawer.DrawText( ref args, X + (Width - size.Width) / 2,
                         Y + (Height - size.Height) / 2 );
     }
     drawer.DrawRectBounds( FastColour.White, 2, X, Y, Width, Height );
 }
Пример #5
0
 public override void Redraw( IDrawer2D drawer )
 {
     if( Window.Minimised ) return;
     drawer.DrawRect( FastColour.Black, X, Y, Width, Height );
     if( Value ) {
         DrawTextArgs args = new DrawTextArgs( "X", font, false );
         Size size = drawer.MeasureSize( ref args );
         args.SkipPartsCheck = true;
         drawer.DrawText( ref args, X + (Width + 2 - size.Width) / 2, // account for border
                         Y + (Height - size.Height) / 2 );
     }
     drawer.DrawRectBounds( FastColour.White, 2, X, Y, Width, Height );
 }
        public override void Redraw( IDrawer2D drawer )
        {
            if( Window.Minimised ) return;
            string text = Text;
            if( !Active ) text = "&7" + text;
            int xOffset = Width - textSize.Width, yOffset = Height - textSize.Height;
            DrawTextArgs args = new DrawTextArgs( text, font, true );

            DrawBorder( drawer );
            if( Window.ClassicBackground ) DrawClassic( drawer );
            else DrawNormal( drawer );

            drawer.DrawText( ref args, X + xOffset / 2, Y + yOffset / 2 );
        }
        public void Redraw( IDrawer2D drawer, string text, Font font )
        {
            if( !Active )
                text = "&7" + Text;
            DrawTextArgs args = new DrawTextArgs( text, font, true );
            Size size = drawer.MeasureSize( ref args );
            int width = ButtonWidth, height = ButtonHeight;
            int xOffset = width - size.Width, yOffset = height - size.Height;

            if( Shadow )
                drawer.DrawRoundedRect( Active ? shadowColActive : shadowCol,
                                       3, X + IDrawer2D.Offset, Y + IDrawer2D.Offset, width, height );
            drawer.DrawRoundedRect( Active ? boxColActive : boxCol,
                                   3, X, Y, width, height );

            args.SkipPartsCheck = true;
            drawer.DrawText( ref args, X + 1 + xOffset / 2, Y + 1 + yOffset / 2 );
        }
Пример #8
0
 public override void Redraw( IDrawer2D drawer )
 {
     if( Window.Minimised ) return;
     DrawTextArgs args = new DrawTextArgs( Text, font, true );
     drawer.DrawText( ref args, X, Y );
 }
Пример #9
0
        public override void Redraw( IDrawer2D drawer )
        {
            string text = Text;
            if( Password ) text = new String( '*', text.Length );
            DrawTextArgs args = new DrawTextArgs( text, font, true );

            Size size = drawer.MeasureSize( ref args );
            Width = Math.Max( ButtonWidth, size.Width + 15 );
            textHeight = size.Height;
            args.SkipPartsCheck = true;
            if( Window.Minimised ) return;

            FastColour col = Active ? new FastColour( 240, 240, 240 ) : new FastColour( 180, 180, 180 );
            drawer.Clear( col, X + 1, Y, Width - 2, 2 );
            drawer.Clear( col, X + 1, Y + Height - 2, Width - 2, 2 );
            drawer.Clear( col, X, Y + 1, 2, Height - 2 );
            drawer.Clear( col, X + Width - 2, Y + 1, 2, Height - 2 );
            drawer.Clear( FastColour.Black, X + 2, Y + 2, Width - 4, Height - 4 );

            if( Text.Length != 0 || HintText == null ) {
                int y = Y + 2 + (Height - textHeight) / 2;
                drawer.DrawText( ref args, X + 5, y );
            } else {
                args.SkipPartsCheck = false;
                args.Text = HintText;
                args.Font = hintFont;

                Size hintSize = drawer.MeasureSize( ref args );
                int y = Y + (Height - hintSize.Height) / 2;
                args.SkipPartsCheck = true;
                drawer.DrawText( ref args, X + 5, y );
            }
        }
Пример #10
0
        public void Redraw( IDrawer2D drawer, string text, Font font )
        {
            Text = text;
            if( Password )
                text = new String( '*', text.Length );
            DrawTextArgs args = new DrawTextArgs( text, font, true );
            Size size = drawer.MeasureSize( ref args );
            Width = Math.Max( ButtonWidth, size.Width + 7 );

            FastColour col = Active ? FastColour.White : new FastColour( 160, 160, 160 );
            drawer.DrawRectBounds( col, 2, X, Y, Width, Height );
            drawer.DrawRect( FastColour.Black, X + 2, Y + 2, Width - 4, Height - 4 );

            args.SkipPartsCheck = true;
            drawer.DrawText( ref args, X + 7, Y + 2 );
        }