void DrawTitles( IDrawer2D drawer, Font font )
        {
            int x = 0;
            DrawTextArgs args = new DrawTextArgs( null, font, false );
            for( int i = 0; i < elements.Length; i++ ) {
                args.Text = elements[i].Title;
                FastColour col = i == selectedIndex ? new FastColour( 30, 30, 30, 200 ) :
                    new FastColour( 60, 60, 60, 200 );
                Size size = elements[i].TitleSize;

                drawer.Clear( col, x, 0, size.Width, size.Height );
                drawer.DrawChatText( ref args, x + titleSpacing / 2, 0 );
                x += size.Width;
            }
        }
示例#2
0
        void DrawTitles(IDrawer2D drawer, Font font)
        {
            int          x    = 0;
            DrawTextArgs args = new DrawTextArgs(null, font, false);

            for (int i = 0; i < elements.Length; i++)
            {
                args.Text = elements[i].Title;
                FastColour col = i == selectedIndex ? new FastColour(30, 30, 30, 200) :
                                 new FastColour(60, 60, 60, 200);
                Size size = elements[i].TitleSize;

                drawer.Clear(col, x, 0, size.Width, size.Height);
                drawer.DrawChatText(ref args, x + titleSpacing / 2, 0);
                x += size.Width;
            }
        }
示例#3
0
        unsafe void Make(Element e, Font font)
        {
            Size *sizes = stackalloc Size[e.Contents.Length / e.CharsPerItem];

            MeasureContentSizes(e, font, sizes);
            Size bodySize = CalculateContentSize(e, sizes, out elementSize);
            int  titleWidth = MeasureTitles(font), titleHeight = elements[0].TitleSize.Height;
            Size size = new Size(Math.Max(bodySize.Width, titleWidth), bodySize.Height + titleHeight);

            using (Bitmap bmp = IDrawer2D.CreatePow2Bitmap(size))
                using (IDrawer2D drawer = game.Drawer2D)
                {
                    drawer.SetBitmap(bmp);
                    DrawTitles(drawer, font);
                    drawer.Clear(new FastColour(30, 30, 30, 200), 0, titleHeight,
                                 size.Width, bodySize.Height);

                    DrawContent(drawer, font, e, titleHeight);
                    texture = drawer.Make2DTexture(bmp, size, X, Y);
                }
        }
 void DrawClassic( IDrawer2D drawer )
 {
     FastColour highlightCol = Active ? new FastColour( 189, 198, 255 ) : new FastColour( 168, 168, 168 );
     drawer.Clear( highlightCol, X + border + 1, Y + border, Width - (border * 2 + 1), border );
     drawer.Clear( highlightCol, X + border, Y + border + 1, border, Height - (border * 2 + 1) );
 }
 void DrawBorder( IDrawer2D drawer )
 {
     FastColour backCol = Window.ClassicBackground ? FastColour.Black : LauncherSkin.ButtonBorderCol;
     drawer.Clear( backCol, X + 1, Y, Width - 2, border );
     drawer.Clear( backCol, X + 1, Y + Height - border, Width - 2, border );
     drawer.Clear( backCol, X, Y + 1, border, Height - 2 );
     drawer.Clear( backCol, X + Width - border, Y + 1, border, Height - 2 );
 }
 void DrawNormal( IDrawer2D drawer )
 {
     if( Active ) return;
     FastColour lineCol = LauncherSkin.ButtonHighlightCol;
     drawer.Clear( lineCol, X + border + 1, Y + border, Width - (border * 2 + 1), border );
 }
        int DrawColumn( IDrawer2D drawer, bool separator, Font font, Font titleFont,
            string header, int maxWidth, int x, Func<TableEntry, string> filter)
        {
            int y = table.Y + 3;
            DrawTextArgs args = new DrawTextArgs( header, titleFont, true );
            TableEntry headerEntry = default( TableEntry );
            DrawColumnEntry( drawer, ref args, maxWidth, x, ref y, ref headerEntry );
            maxIndex = table.Count;
            y += 5;

            for( int i = table.CurrentIndex; i < table.Count; i++ ) {
                args = new DrawTextArgs( filter( table.usedEntries[i] ), font, true );
                if( i == table.SelectedIndex && !separator ) {
                    int startY = y - 3;
                    int height = Math.Min( startY + (entryHeight + 4), table.Y + table.Height ) - startY;
                    drawer.Clear( foreGridCol, table.X, startY, table.Width, height );
                }

                if( !DrawColumnEntry( drawer, ref args, maxWidth, x, ref y, ref table.usedEntries[i] ) ) {
                    maxIndex = i; break;
                }
            }

            if( separator && !window.ClassicBackground )
                drawer.Clear( LauncherSkin.BackgroundCol, x - 7, table.Y, 2, table.Height );
            return maxWidth + 5;
        }
 void DrawScrollbar( IDrawer2D drawer )
 {
     FastColour col = window.ClassicBackground ? new FastColour( 80, 80, 80 ) : LauncherSkin.ButtonBorderCol;
     drawer.Clear( col, window.Width - 10, table.Y, 10, table.Height );
     col = window.ClassicBackground ? new FastColour( 160, 160, 160 ) : LauncherSkin.ButtonForeActiveCol;
     int yOffset, height;
     table.GetScrollbarCoords( out yOffset, out height );
     drawer.Clear( col, window.Width - 10, table.Y + yOffset, 10, height );
 }
        void DrawGrid( IDrawer2D drawer )
        {
            if( !window.ClassicBackground )
                drawer.Clear( LauncherSkin.BackgroundCol,
                             table.X, table.Y + headerHeight + 5, table.Width, 2 );
            headerStartY = table.Y;

            headerEndY = table.Y + headerHeight + 5;
            int startY = headerEndY + 3;
            numEntries = (table.Y + table.Height - startY) / (entryHeight + 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 );
            }
        }
        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);
        }