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 DrawClassic(IDrawer2D drawer, int xOffset, int yOffset)
        {
            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));
        }
        int DrawColumn(IDrawer2D drawer, bool separator, Font font, Font titleFont, Font boldFont,
                       string header, int maxWidth, int x, Func <TableEntry, string> filter)
        {
            int          y           = Y + 3;
            DrawTextArgs args        = new DrawTextArgs(header, titleFont, true);
            TableEntry   headerEntry = default(TableEntry);

            DrawColumnEntry(drawer, ref args, maxWidth, x, ref y, ref headerEntry);
            maxIndex = Count;
            y       += 2;
            int bodyStartY = y;

            y += 3;

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

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

            if (separator)
            {
                drawer.Clear(LauncherSkin.BackgroundCol, x - 7, Y, 2, Height);
            }
            return(maxWidth + 5);
        }
Ejemplo n.º 4
0
        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);
            }
        }
Ejemplo n.º 5
0
        void DrawClassic(IDrawer2D drawer)
        {
            PackedCol highlightCol = Active ? new PackedCol(189, 198, 255) : new PackedCol(168, 168, 168);

            drawer.Clear(highlightCol, X + border * 2, Y + border, Width - border * 4, border);
            drawer.Clear(highlightCol, X + border, Y + border * 2, border, Height - border * 4);
        }
Ejemplo n.º 6
0
        int DrawColumn(IDrawer2D drawer, string header, int columnI, int x, ColumnFilter filter)
        {
            int  y         = table.Y + 3;
            int  maxWidth  = table.ColumnWidths[columnI];
            bool separator = columnI > 0;

            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++)
            {
                TableEntry entry = table.Get(i);
                args = new DrawTextArgs(filter(entry), font, true);

                if ((i == table.SelectedIndex || entry.Featured) && !separator)
                {
                    int startY = y - 3;
                    int height = Math.Min(startY + (entryHeight + 4), table.Y + table.Height) - startY;
                    drawer.Clear(GetGridCol(entry.Featured, i == table.SelectedIndex), table.X, startY, table.Width, height);
                }
                if (!DrawColumnEntry(drawer, ref args, maxWidth, x, ref y, ref entry))
                {
                    maxIndex = i; break;
                }
            }
            if (separator && !game.ClassicBackground)
            {
                drawer.Clear(LauncherSkin.BackgroundCol, x - 7, table.Y, 2, table.Height);
            }
            return(maxWidth + 5);
        }
Ejemplo n.º 7
0
        void DrawBorder(IDrawer2D drawer)
        {
            PackedCol backCol = Window.ClassicBackground ? PackedCol.Black : LauncherSkin.ButtonBorderCol;

            drawer.Clear(backCol, X + border, Y, Width - border * 2, border);
            drawer.Clear(backCol, X + border, Y + Height - border, Width - border * 2, border);
            drawer.Clear(backCol, X, Y + border, border, Height - border * 2);
            drawer.Clear(backCol, X + Width - border, Y + border, border, Height - border * 2);
        }
        void DrawBorder(IDrawer2D drawer)
        {
            FastColour backCol = Window.ClassicMode ? 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 DrawScrollbar(IDrawer2D drawer)
        {
            drawer.Clear(scrollBackCol, Window.Width - 10, Y, 10, Height);
            float scale = Height / (float)Count;

            int y1     = (int)(Y + CurrentIndex * scale);
            int height = (int)((maxIndex - CurrentIndex) * scale);

            drawer.Clear(scrollCol, Window.Width - 10, y1, 10, height + 1);
        }
        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);
        }
Ejemplo n.º 11
0
        void DrawScrollbar(IDrawer2D drawer)
        {
            PackedCol col = game.ClassicBackground ? new PackedCol(80, 80, 80) : LauncherSkin.ButtonBorderCol;

            drawer.Clear(col, game.Width - 10, table.Y, 10, table.Height);
            col = game.ClassicBackground ? new PackedCol(160, 160, 160) : LauncherSkin.ButtonForeActiveCol;
            int yOffset, height;

            table.GetScrollbarCoords(out yOffset, out height);
            drawer.Clear(col, game.Width - 10, table.Y + yOffset, 10, height);
        }
        void DrawScrollbar(IDrawer2D drawer)
        {
            FastColour col = Window.ClassicMode ? new FastColour(80, 80, 80) : LauncherSkin.ButtonBorderCol;

            drawer.Clear(col, Window.Width - 10, Y, 10, Height);
            float scale = Height / (float)Count;

            col = Window.ClassicMode ? new FastColour(160, 160, 160) : LauncherSkin.ButtonForeActiveCol;
            int y1     = (int)(Y + CurrentIndex * scale);
            int height = (int)((maxIndex - CurrentIndex) * scale);

            drawer.Clear(col, Window.Width - 10, y1, 10, height + 1);
        }
Ejemplo n.º 13
0
        internal override void Draw(Location location)
        {
            if (location == null)
            {
                return;
            }

            buf++;
            buf = buf % buffers;
            drawer.Clear(buf, Color.Transparent);
            TileMap tileMap = location.Description as TileMap;

            if (tileMap != null)
            {
                drawer.FillRectangle(buf, tileMap.BackgroundColor, 0, 0, tileMap.Width, tileMap.Height);
            }
            else
            {
                drawer.FillRectangle(buf, this.backgroundColor, 0, 0, this.Width, this.Height);
            }

            List <IDescription> descriptions = location.Draw();

            foreach (IDescription description in descriptions)
            {
                drawer.Draw(buf, description);
            }
        }
Ejemplo n.º 14
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);
            }
        }
        void DrawNormal(IDrawer2D drawer, int xOffset, int yOffset)
        {
            if (Active)
            {
                return;
            }
            FastColour lineCol = LauncherSkin.ButtonHighlightCol;

            drawer.Clear(lineCol, X + border + 1, Y + border, Width - (border * 2 + 1), border);
        }
Ejemplo n.º 16
0
        void DrawNormal(IDrawer2D drawer)
        {
            if (Active)
            {
                return;
            }
            PackedCol lineCol = LauncherSkin.ButtonHighlightCol;

            drawer.Clear(lineCol, X + border * 2, Y + border, Width - border * 4, border);
        }
        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          xOffset = Width - size.Width, yOffset = Height - size.Height;

            FastColour backCol = 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);

            FastColour foreCol = Active ? LauncherSkin.ButtonForeActiveCol : LauncherSkin.ButtonForeCol;

            drawer.Clear(foreCol, X + border, Y + border, Width - border * 2, Height - border * 2);
            args.SkipPartsCheck = true;
            drawer.DrawText(ref args, X + xOffset / 2, Y + yOffset / 2);
            if (!Active)
            {
                FastColour lineCol = LauncherSkin.ButtonHighlightCol;
                drawer.Clear(lineCol, X + border + 1, Y + border, Width - (border * 2 + 1), border);
            }
        }
        void DrawGrid(IDrawer2D drawer, Font font, Font titleFont)
        {
            DrawTextArgs args = new DrawTextArgs("I", titleFont, true);
            Size         size = drawer.MeasureSize(ref args);

            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);
        }
Ejemplo n.º 19
0
        void DrawGrid(IDrawer2D drawer)
        {
            if (!game.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);
        }
        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;
            }
        }
Ejemplo n.º 21
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(0, 0, 0, 127);;
                Size size = elements[i].TitleSize;

                drawer.Clear(col, x, 0, size.Width, size.Height);
                drawer.DrawText(ref args, x + titleSpacing / 2, 0);
                x += size.Width;
            }
        }
        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);
                }
        }