示例#1
0
        public void MakeBackground()
        {
            if (Framebuffer == null || (Framebuffer.Width != Width || Framebuffer.Height != Height))
            {
                if (Framebuffer != null)
                {
                    Framebuffer.Dispose();
                }
                Framebuffer = new Bitmap(Width, Height);
            }
            using (IDrawer2D drawer = Drawer) {
                drawer.SetBitmap(Framebuffer);
                ClearArea(0, 0, Width, Height);

                drawer.UseBitmappedChat = useBitmappedFont;
                DrawTextArgs args   = new DrawTextArgs("&eClassical&fSharp", logoFont, false);
                Size         size   = drawer.MeasureChatSize(ref args);
                int          xStart = Width / 2 - size.Width / 2;

                args.Text = "&0Classical&0Sharp";
                drawer.DrawChatText(ref args, xStart + 5, 10 + 5);
                args.Text = "&eClassical&fSharp";
                drawer.DrawChatText(ref args, xStart, 10);
                drawer.UseBitmappedChat = false;
            }
            Dirty = true;
        }
示例#2
0
        protected virtual void MouseMove(object sender, MouseMoveEventArgs e)
        {
            if (supressMove)
            {
                supressMove = false;
                return;
            }
            mouseMoved = true;
            for (int i = 0; i < widgets.Length; i++)
            {
                LauncherWidget widget = widgets[i];
                if (widget == null)
                {
                    continue;
                }
                if (e.X >= widget.X && e.Y >= widget.Y &&
                    e.X < widget.X + widget.Width && e.Y < widget.Y + widget.Height)
                {
                    if (selectedWidget == widget)
                    {
                        return;
                    }

                    using ( drawer ) {
                        drawer.SetBitmap(game.Framebuffer);
                        if (selectedWidget != null)
                        {
                            UnselectWidget(selectedWidget);
                        }
                        SelectWidget(widget);
                    }
                    selectedWidget = widget;
                    return;
                }
            }

            if (selectedWidget == null)
            {
                return;
            }
            using ( drawer ) {
                drawer.SetBitmap(game.Framebuffer);
                UnselectWidget(selectedWidget);
            }
            selectedWidget = null;
        }
        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);
                }
        }