コード例 #1
0
ファイル: MenuEntry.cs プロジェクト: cartman300/Tetraquark
        public void DrawMenu(TextBuffer GUIText)
        {
            ValidateSelected();
            Widget[] Entries = MenuEntries.ToArray();

            // Separator
            int Width = MenuTitle.Length + 5;
            int Height = 3;

            for (int i = 0; i < Entries.Length; i++) {
                Width = Math.Max(Width, Entries[i].Width + 3);
                Height += Entries[i].Height;
            }

            int X = GUIText.BufferWidth / 2 - Width / 2 - 1;
            int Y = GUIText.BufferHeight / 2 - Height / 2 - 1;

            //DrawBox(GUIText, Width, 0, 0, GUIText.BufferHeight - 1);

            // Outline
            for (int x = 0; x < Width; x++)
                for (int y = 0; y < Height; y++)
                    GUIText[X + x, Y + y] = 0;
            GUIText.DrawBox(X, Y, Width, Height);
            GUIText.Print(X + 2, Y, "[" + MenuTitle + "]");

            // Entries
            int YOff = 0;
            for (int i = 0; i < Entries.Length; i++) {
                Entries[i].Draw(GUIText, X + 2, Y + 2 + YOff, i == Selected);
                YOff += Entries[i].Height;
            }
            /*GUIText.Print(X + 2, Y + i + 2, Entries[i],
                i == Selected ? Color.Black : ConsoleColor.Gray.ToColor(), i == Selected ? Color.White : Color.Black);*/
        }
コード例 #2
0
ファイル: Widgets.cs プロジェクト: cartman300/Tetraquark
        public override void Draw(TextBuffer TBuffer, int X, int Y, bool IsSelected)
        {
            Color Fg = ConsoleColor.Gray.ToColor();
            Color Bg = Color.Black;
            if (IsSelected && !CaptureInput) {
                Fg = Color.Black;
                if (Enabled)
                    Bg = Color.White;
                else
                    Bg = ConsoleColor.DarkGray.ToColor();
            }

            TBuffer.DrawBox(X, Y, Width, Entries.Length + 1);
            TBuffer.Print(X + 1, Y, "[" + Txt + "]", Fg, Bg);

            for (int i = 0; i < Entries.Length; i++) {
                Color F = Color.White;
                Color B = Color.Black;
                if (CaptureInput && Selected == i) {
                    F = Color.Black;
                    B = Color.White;
                }
                string Pref = " ";
                if (Selected == i || SelectedActive == i)
                    Pref = ">";
                TBuffer.Print(X + 1, Y + i + 1, Pref, F, B);
                TBuffer.Print(X + 3, Y + i + 1, Entries[i]);
            }
        }