Beispiel #1
0
        public ColoredButton(string text, Font font, Brush textColor, float r, float g, float b, float a)
        {
            label = new Label(text, font, textColor);

            float width = label.Width + 20, height = label.Height + 10;

            var up =
                new ColoredRectangle(0, 0, width, height / 2, r, g, b, a);
            var upBottom =
                new ColoredRectangle(0, height / 2, width, height / 2, Math.Max(r - 0.1F, 0), Math.Max(g - 0.1F, 0), Math.Max(b - 0.1F, 0), a);
            up.AddChild(upBottom);

            var down =
                new ColoredRectangle(0, 0, width, height / 2, Math.Max(r - 0.05F, 0), Math.Max(g - 0.05F, 0), Math.Max(b - 0.05F, 0), a);
            var downBottom =
                new ColoredRectangle(0, height / 2, width, height / 2, Math.Min(r + 0.05F, 1), Math.Min(g + 0.05F, 1), Math.Min(b + 0.05F, 1), a);
            down.AddChild(downBottom);

            var hover =
                new ColoredRectangle(0, 0, width, height / 2, Math.Min(r + 0.1F, 1), Math.Min(g + 0.1F, 1), Math.Min(b + 0.1F, 1), a);
            var hoverBottom =
                new ColoredRectangle(0, height / 2, width, height / 2, r, g, b, a);
            hover.AddChild(hoverBottom);

            Skin = new ButtonSkin(up, down, hover);
            Initialize(width, height);
            AddChild(label);

            Resize();
        }
Beispiel #2
0
        public DebugConsole()
        {
            ExposedReferences = new Dictionary<string, object>();

            visuals = new DisplayObject();
            AddChild(visuals);

            var background = new ColoredRectangle(0, 0, Firefly.Window.Width, Firefly.Window.Height / 2, 0, 0, 0, 0.85F);
            visuals.AddChild(background);
            var line = new ColoredShape();
            line.OutlinePolygons.AddLast(new Polygon(false,
                4, 0, 1, 1, 1, 1,
                Firefly.Window.Width - 4, 0, 1, 1, 1, 1));
            line.SetPolygons();
            line.Y = Firefly.Window.Height / 2 - 20;
            visuals.AddChild(line);

            input = new TextField(new System.Drawing.Font("Consolas", 10), System.Drawing.Brushes.White, 0x0, Firefly.Window.Width, 20);
            input.Y = Firefly.Window.Height / 2 - 17;
            input.IllegalChars.AppendMany('\r', '\n');
            visuals.AddChild(input);

            consoleText = new Label("", new Font("Consolas", 10), Brushes.White);
            visuals.AddChild(consoleText);

            history = new List<string>();

            CloseConsole();
        }
Beispiel #3
0
        public TexturedButton(Texture button)
        {
            var up = new TexturedRectangle(button);

            var down = new TexturedRectangle(button);
            var shadow = new ColoredRectangle(0, 0, button.Width, button.Height, 0, 0, 0, 0.1F);
            down.AddChild(shadow);

            var hover = new TexturedRectangle(button);
            var light = new ColoredRectangle(0, 0, button.Width, button.Height, 1, 1, 1, 0.1F);
            hover.AddChild(light);

            var skin = new ButtonSkin(up, down, hover);

            Initialize(button.Width, button.Height);
        }
Beispiel #4
0
        public TextField(Font font, Brush textColor, uint backgroundColor, float width, float height, Rectangle? wordWrap = null)
        {
            layer = new Layer();
            AddChild(layer);
            float a = (backgroundColor & 0xFF) / 255F;
            float b = ((backgroundColor >> 8) & 0xFF) / 255F;
            float g = ((backgroundColor >> 16) & 0xFF) / 255F;
            float r = ((backgroundColor >> 24) & 0xFF) / 255F;
            background = new ColoredRectangle(0, 0, width, height, r, g, b, a);
            layer.AddChild(background);
            layer.StencilMasks.AddLast(background);

            text = new Label("", font, textColor, wordWrap, LabelSizeMethod.SmallestPossible);
            layer.AddChild(text);

            InteractsWithMouse = true;

            arrow = new ColoredShape();
            arrow.FilledPolygons.AddLast(new Polygon(false,
                0, 5, 1, 1, 1, 1,
                5, 0, 1, 1, 1, 1,
                5, 10, 1, 1, 1, 1));
            arrow.FilledPolygons.AddLast(new Polygon(false,
                5, 3, 1, 1, 1, 1,
                5, 7, 1, 1, 1, 1,
                10, 7, 1, 1, 1, 1,
                10, 3, 1, 1, 1, 1));
            arrow.SetPolygons();
            arrow.Visible = false;
            AddChild(arrow);

            CursorPosition = 0;
            OnChange += OnChangeHandler;

            IllegalChars = new List<char>();
            IllegalChars.Add('\b');
        }
Beispiel #5
0
        private void MakeBackground()
        {
            background = new ColoredShape();

            var brush = new ColoredRectangle(0, 0, SIZE, SIZE, 0.2F, 0.2F, 0.2F, 1);
            brush.AddOutline(0.7F, 0.7F, 0.7F, 1);

            background.BeginMassUpdate();
            for (int i = 0; i < width; ++i)
            {
                for (int j = 0; j < height; j++)
                {
                    brush.X = i * (SIZE + PADDING);
                    brush.Y = j * (SIZE + PADDING);
                    brush.DrawToShapeGlobal(background);
                }
            }
            background.EndMassUpdate();
        }