public void DrawAt( IDrawer2D drawer, string text, Font font,
            Anchor horAnchor, Anchor verAnchor, int x, int y)
        {
            DrawTextArgs args = new DrawTextArgs( text, font, true );
            Size size = drawer.MeasureSize( ref args );
            Width = size.Width; Height = size.Height;

            CalculateOffset( x, y, horAnchor, verAnchor );
            Redraw( drawer, text, font );
        }
        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 SetDrawData( IDrawer2D drawer, string text, Font font,
            Anchor horAnchor, Anchor verAnchor, int x, int y)
        {
            DrawTextArgs args = new DrawTextArgs( text, font, true );
            Size size = drawer.MeasureSize( ref args );
            Width = size.Width; Height = size.Height;

            CalculateOffset( x, y, horAnchor, verAnchor );
            Text = text;
            this.font = font;
        }
 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 );
 }
 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 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 );
        }
Beispiel #7
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));

            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, 0);
                }

            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;
        }
        public void SetCaretToCursor( int mouseX, int mouseY, IDrawer2D drawer, Font font )
        {
            string text = Text;
            if( Password )
                text = new String( '*', text.Length );
            mouseX -= X; mouseY -= Y;

            DrawTextArgs args = new DrawTextArgs( text, font, true );
            Size size = drawer.MeasureSize( ref args );
            if( mouseX >= size.Width ) {
                CaretPos = -1; return;
            }

            for( int i = 0; i < Text.Length; i++ ) {
                args.Text = text.Substring( 0, i );
                int trimmedWidth = drawer.MeasureChatSize( ref args ).Width;
                args.Text = new String( text[i], 1 );
                int charWidth = drawer.MeasureChatSize( ref args ).Width;
                if( mouseX >= trimmedWidth && mouseX < trimmedWidth + charWidth ) {
                    CaretPos = i; return;
                }
            }
        }
        public void SetDrawData( IDrawer2D drawer, Font font, Font titleFont,
            Anchor horAnchor, Anchor verAnchor, int x, int y)
        {
            CalculateOffset( x, y, horAnchor, verAnchor );
            this.font = font;
            this.titleFont = titleFont;

            DrawTextArgs args = new DrawTextArgs( "IMP", titleFont, true );
            defaultHeaderHeight = drawer.MeasureSize( ref args ).Height;
            args = new DrawTextArgs( "IMP", font, true );
            defaultInputHeight = drawer.MeasureSize( ref args ).Height;
        }
        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 );
        }
        bool DrawColumnEntry( IDrawer2D drawer, ref DrawTextArgs args,
            int maxWidth, int x, ref int y, ref TableEntry entry)
        {
            Size size = drawer.MeasureSize( ref args );
            bool empty = args.Text == "";
            if( empty )
                size.Height = entryHeight;
            if( y + size.Height > table.Y + table.Height ) {
                y = table.Y + table.Height + 2; return false;
            }

            entry.Y = y; entry.Height = size.Height;
            if( !empty ) {
                size.Width = Math.Min( maxWidth, size.Width );
                args.SkipPartsCheck = false;
                drawer.DrawClippedText( ref args, x, y, maxWidth, 30 );
            }
            y += size.Height + 2;
            return true;
        }
        public void SetDrawData( IDrawer2D drawer, Font font, Font titleFont )
        {
            this.font = font;
            this.titleFont = titleFont;

            DrawTextArgs args = new DrawTextArgs( "IMP", titleFont, true );
            headerHeight = drawer.MeasureSize( ref args ).Height;
            args = new DrawTextArgs( "IMP", font, true );
            entryHeight = drawer.MeasureSize( ref args ).Height;
        }
        public void SetDrawData( IDrawer2D drawer, string text )
        {
            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;
        }
        public void SetDrawData( IDrawer2D drawer, string text, Font font, Font hintFont,
            Anchor horAnchor, Anchor verAnchor, int width, int height, int x, int y)
        {
            ButtonWidth = width; ButtonHeight = height;
            Width = width; Height = height;
            CalculateOffset( x, y, horAnchor, verAnchor );

            Text = text;
            if( Password ) text = new String( '*', text.Length );
            this.font = font;
            this.hintFont = hintFont;

            DrawTextArgs args = new DrawTextArgs( text, font, true );
            Size size = drawer.MeasureSize( ref args );
            Width = Math.Max( ButtonWidth, size.Width + 15 );
            textHeight = size.Height;
        }
        void DrawGrid( IDrawer2D drawer, Font font, Font titleFont )
        {
            DrawTextArgs args = new DrawTextArgs( "I", titleFont, true );
            Size size = drawer.MeasureSize( ref args );
            if( !Window.ClassicBackground )
                drawer.Clear( LauncherSkin.BackgroundCol, X, Y + size.Height + 5, Width, 2 );
            headerStartY = Y;

            headerEndY = Y + size.Height + 5;
            int startY = headerEndY + 3;
            numEntries = (Y + Height - startY) / (defaultInputHeight + 3);
        }
        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 );
            }
        }
        public void DrawCaret( IDrawer2D drawer, Font font )
        {
            string text = Text;
            if( Password )
                text = new String( '*', text.Length );

            DrawTextArgs args = new DrawTextArgs( text, font, true );
            if( CaretPos == -1 ) {
                Size size = drawer.MeasureSize( ref args );
                drawer.Clear( FastColour.White, X + 5 + size.Width,
                             Y + Height - 5, 10, 2 );
            } else {
                args.Text = text.Substring( 0, CaretPos );
                int trimmedWidth = drawer.MeasureChatSize( ref args ).Width;
                args.Text = new String( text[CaretPos], 1 );
                int charWidth = drawer.MeasureChatSize( ref args ).Width;

                drawer.Clear( FastColour.White, X + 5 + trimmedWidth, Y + Height - 5, charWidth, 2 );
            }
        }