示例#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();
        }
示例#2
0
        public ColoredButton(string text, Font font, Brush textColor, ButtonSkin skin, float width, float height)
        {
            label = new Label(text, font, textColor);

            Skin = skin.Clone();
            Initialize(width, height);
            AddChild(label);

            Resize();
        }
示例#3
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');
        }
示例#4
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();
        }
示例#5
0
        private void PushText(string text)
        {
            output = output + text + "\n";

            visuals.RemoveChild(consoleText);
            consoleText = new Label(output, new Font("Consolas", 10), Brushes.White, new global::FireflyGL.Rectangle(0, 0, Firefly.Window.Width, 0));
            visuals.AddChild(consoleText);
            consoleText.Y = Firefly.Window.Height / 2 - 20 - consoleText.Height - 3;
        }
示例#6
0
        private void SetupUI()
        {
            performanceLabel = new Label("", new System.Drawing.Font("Courier New", 8), System.Drawing.Brushes.White, new FireflyGL.Rectangle(0, 0, 150, 150));
            performanceLabel.X = 650;
            performanceLabel.IgnoresCamera = true;
            performanceLabel.Active = false;

            startButton = new ColoredButton("Start!", new Font("Consolas", 12), Brushes.White, 0.2F, 0.2F, 0.2F, 1);
            startButton.X = Firefly.Window.Width - startButton.Width - 5;
            startButton.Y = Firefly.Window.Height - startButton.Height - 5;
            startButton.OnClick += delegate(Button button)
            {
                started = true;
            };

            Console = new DebugConsole();
        }