Example #1
0
        // account for the thickness of the window border to prevent UI element spillover

        public MessageLogWindow(int width, int height, string title)
            : base(width, height)
        {
            DefaultBackground = Color.DarkOliveGreen;
            // Ensure that the window background is the correct colour
            //Theme.WindowTheme.FillStyle.Background = DefaultBackground;
            //Theme.WindowTheme.BorderStyle.Background = Color.DarkOliveGreen;//the goggles
            lines   = new List <string>();
            CanDrag = true;
            Title   = title.Align(HorizontalAlignment.Center, Width);

            // add the message console, reposition, enable the viewport, and add it to the window
            messageConsole                   = new ScrollingConsole(width - WindowBorderThickness, MaxLines); //0.1: change msgs to rect. font
            messageConsole.Position          = new Coord(1, 1);
            messageConsole.ViewPort          = new Rectangle(0, 0, width - 1, height - WindowBorderThickness);
            messageConsole.DefaultBackground = Color.Black;
            messageConsole.Font              = Global.FontDefault.Master.GetFont(Font.FontSizes.One);

            // create a scrollbar and attach it to an event handler, then add it to the Window
            messageScrollBar = new SadConsole.Controls.ScrollBar(Orientation.Vertical, height - WindowBorderThickness)
            {
                Position  = new Coord(messageConsole.Width + 1, messageConsole.Position.X),
                IsEnabled = false,
            };
            messageScrollBar.ValueChanged += MessageScrollBar_ValueChanged;
            Add(messageScrollBar);

            // enable mouse input
            UseMouse = true;

            // Add the child consoles to the window
            Children.Add(messageConsole);
        }
        // Create a new window with the title centered
        // the window is draggable by default
        public MessageLogWindow(int width, int height, string title) : base(width, height)
        {
            // Ensure that the window background is the correct colour
            //    Theme.WindowTheme.FillStyle.Background = DefaultBackground;
            _lines  = new Queue <string>();
            CanDrag = true;
            Title   = title.Align(HorizontalAlignment.Center, Width);

            // add the message console, reposition, enable the viewport, and add it to the window
            _messageConsole          = new SadConsole.ScrollingConsole(width - _windowBorderThickness, _maxLines);
            _messageConsole.Position = new Point(1, 1);
            _messageConsole.ViewPort = new Rectangle(0, 0, width - 1, height - _windowBorderThickness);

            // create a scrollbar and attach it to an event handler, then add it to the Window
            _messageScrollBar               = new SadConsole.Controls.ScrollBar(SadConsole.Orientation.Vertical, height - _windowBorderThickness);
            _messageScrollBar.Position      = new Point(_messageConsole.Width + 1, _messageConsole.Position.X);
            _messageScrollBar.IsEnabled     = false;
            _messageScrollBar.ValueChanged += MessageScrollBar_ValueChanged;
            Add(_messageScrollBar);

            // enable mouse input
            UseMouse = true;

            // Add the child consoles to the window
            Children.Add(_messageConsole);
        }
Example #3
0
        public ChatLogWindow(int width, int height, string title) : base(width, height)
        {
            _lines  = new Queue <string>();
            CanDrag = true;
            Title   = title.Align(HorizontalAlignment.Center, Width, (char)205);

            _messageConsole          = new SadConsole.ScrollingConsole(width - _windowBorderThickness, _maxLines);
            _messageConsole.Position = new Point(1, 1);
            _messageConsole.ViewPort = new Rectangle(0, 0, width - 1, height - _windowBorderThickness - 3);

            _messageTextBox           = new SadConsole.Controls.TextBox(width - _windowBorderThickness - 3);
            _messageTextBox.Position  = new Point(_windowBorderThickness, height - _windowBorderThickness);
            _messageTextBox.IsEnabled = true;
            Add(_messageTextBox);

            _messageScrollBar               = new SadConsole.Controls.ScrollBar(SadConsole.Orientation.Vertical, height - _windowBorderThickness);
            _messageScrollBar.Position      = new Point(_messageConsole.Width + 1, _messageConsole.Position.X);
            _messageScrollBar.IsEnabled     = false;
            _messageScrollBar.ValueChanged += MessageScrollBar_ValueChanged;
            Add(_messageScrollBar);

            UseMouse = true;

            Children.Add(_messageConsole);
        }
Example #4
0
        // Create a new window with the title centered
        // the window is draggable by default
        public MessageLogWindow(int width, int height, string title) : base(width, height)
        {
            _lines  = new Queue <string>();
            CanDrag = true;
            Title   = title.Align(HorizontalAlignment.Left, Width);

            // add the message console, reposition, enable the viewport, and add it to the window
            _messageConsole = new SadConsole.ScrollingConsole(width - _windowBorderThickness, _maxLines);
            _messageConsole.Fill(Color.Black, Color.Black, 176);
            _messageConsole.Position = new Point(1, 1);
            _messageConsole.ViewPort = new Rectangle(0, 0, width - 1, height - _windowBorderThickness);

            // create a scrollbar and attach it to an event handler, then add it to the Window
            _messageScrollBar           = new SadConsole.Controls.ScrollBar(SadConsole.Orientation.Vertical, height - _windowBorderThickness);
            _messageScrollBar.Position  = new Point(_messageConsole.Width + 1, _messageConsole.Position.X);
            _messageScrollBar.IsEnabled = false;

            //_messageScrollBar.Theme.Colors.ControlHostFore = Color.White;
            _messageScrollBar.ValueChanged += MessageScrollBar_ValueChanged;
            Add(_messageScrollBar);

            // enable mouse input
            UseMouse = true;

            // Add the child consoles to the window
            Children.Add(_messageConsole);
        }
Example #5
0
        public ScrollableConsole(string title, int width, int height, int bufferHeight) : base(width - 1, bufferHeight, new Rectangle(0, 0, width - 1, height))
        {
            controlsContainer = new ControlsConsole(1, height);

            ViewPort = new Rectangle(0, 0, width, height);

            scrollBar               = SadConsole.Controls.ScrollBar.Create(Orientation.Vertical, height);
            scrollBar.IsEnabled     = false;
            scrollBar.ValueChanged += ScrollBar_ValueChanged;

            controlsContainer.Add(scrollBar);
            controlsContainer.Position  = new Point(Position.X + width - 1, Position.Y);
            controlsContainer.IsVisible = true;

            borderSurface = new Basic(width + 2, height + 2, base.Font);
            borderSurface.DrawBox(new Rectangle(0, 0, borderSurface.Width, borderSurface.Height),
                                  new Cell(Color.DarkCyan, Color.Black), null, SurfaceBase.ConnectedLineThick);
            borderSurface.Position = new Point(-1, -1);
            borderSurface.Print(2, 0, title, Color.DarkCyan, Color.Black);
            Children.Add(borderSurface);

            Cursor.IsVisible = false;
            IsVisible        = true;

            scrollingCounter = 0;
        }
Example #6
0
        public ScrollingConsole(int width, int height, int bufferHeight)
        {
            controlsContainer = new SadConsole.ControlsConsole(1, height);

            mainConsole = new SadConsole.Console(width - 1, bufferHeight);
            mainConsole.TextSurface.RenderArea  = new Microsoft.Xna.Framework.Rectangle(0, 0, width - 1, height);
            mainConsole.VirtualCursor.IsVisible = false;

            scrollBar               = SadConsole.Controls.ScrollBar.Create(System.Windows.Controls.Orientation.Vertical, height);
            scrollBar.IsEnabled     = false;
            scrollBar.ValueChanged += ScrollBar_ValueChanged;

            controlsContainer.Add(scrollBar);
            controlsContainer.Position = new Microsoft.Xna.Framework.Point(1 + mainConsole.TextSurface.Width, Position.Y);

            Children.Add(mainConsole);
            Children.Add(controlsContainer);

            scrollingCounter = 0;

            borderSurface = new SadConsole.Surfaces.BasicSurface(width + 2, height + 2, mainConsole.TextSurface.Font);
            var editor = new SadConsole.Surfaces.SurfaceEditor(borderSurface);

            SadConsole.Shapes.Box box = SadConsole.Shapes.Box.Thick();
            box.Width  = borderSurface.Width;
            box.Height = borderSurface.Height;
            box.Draw(editor);
            renderer = new SurfaceRenderer();
            renderer.Render(borderSurface);
        }
Example #7
0
        private void InitializeControls()
        {
            removeSpellButton = new StandardButton(25)
            {
                Position = new Point(Width - 57, 16),
                Text     = "[R] Remove from Library"
            };
            removeSpellButton.Click += (sender, args) => RemoveSpell?.Invoke(this, EventArgs.Empty);
            Add(removeSpellButton);

            editSpellButton = new StandardButton(25)
            {
                Position = new Point(Width - 57, 13),
                Text     = "[E] Edit Spell"
            };
            editSpellButton.Click += (sender, args) => EditSpell?.Invoke(this, EventArgs.Empty);
            Add(editSpellButton);

            spellDetails = new SpellDetailsControl(57, Height - 10)
            {
                Position = new Point(Width - 58, 3)
            };
            Add(spellDetails);

            var scrollBarTheme = new ScrollBarTheme
            {
                Normal = new Cell(DefaultForeground, DefaultBackground)
            };
            var scrollBar = new ScrollBar(Orientation.Vertical, Height - 6)
            {
                Position = new Point(Width - 60, 5),
                Theme    = scrollBarTheme
            };

            Add(scrollBar);
            spellsList = new CustomListBox <SpellListBoxItem>(Width - 61, Height - 6, scrollBar)
            {
                Position = new Point(1, 5)
            };
            spellsList.SelectionChanged += spellsListBox_SelectedItemChanged;
            Add(spellsList);

            var textBoxTheme = new TextBoxTheme
            {
                Normal  = new Cell(Color.White, Color.FromNonPremultiplied(66, 66, 66, 255)),
                Focused = new Cell(Color.White, Color.FromNonPremultiplied(66, 66, 66, 255))
            };

            filterTextBox = new TextBox(Width - 69)
            {
                Position  = new Point(10, 3),
                Theme     = textBoxTheme,
                MaxLength = Width - 70
            };
            Add(filterTextBox);

            UpdateSpellDetails();
        }
Example #8
0
        public ScrollingConsole(int width, int height, int bufferHeight) : base(width - 1, bufferHeight)
        {
            controlsContainer = new ControlsConsole(1, height);

            textSurface.RenderArea = new Rectangle(0, 0, width, height);

            scrollBar               = SadConsole.Controls.ScrollBar.Create(System.Windows.Controls.Orientation.Vertical, height);
            scrollBar.IsEnabled     = false;
            scrollBar.ValueChanged += ScrollBar_ValueChanged;

            controlsContainer.Add(scrollBar);
            controlsContainer.Position                 = new Point(Position.X + width - 1, Position.Y);
            controlsContainer.IsVisible                = true;
            controlsContainer.MouseCanFocus            = false;
            controlsContainer.ProcessMouseWithoutFocus = true;

            scrollingCounter = 0;
        }
        public MessageLogWindow(int width, int height, string title) : base(width, height)

        {
            Theme.FillStyle.Background = Color.Black;
            _lines  = new Queue <string>();
            CanDrag = true;
            Title   = title.Align(HorizontalAlignment.Center, Width);

            _messageConsole          = new SadConsole.ScrollingConsole(width - _windowBorderThickness, _maxLines, SadConsole.Global.FontEmbedded);
            _messageConsole.Position = new Point(1, 1);
            _messageConsole.ViewPort = new Rectangle(0, 0, width - 1, height - _windowBorderThickness);

            _messageScrollBar               = new SadConsole.Controls.ScrollBar(SadConsole.Orientation.Vertical, height - _windowBorderThickness);
            _messageScrollBar.Position      = new Point(_messageConsole.Width + 1, _messageConsole.Position.X);
            _messageScrollBar.IsEnabled     = false;
            _messageScrollBar.ValueChanged += MessageScrollBar_ValueChanged;
            _messageScrollBar.Position      = new Point(_messageConsole.Width, 1);

            Children.Add(_messageConsole);
        }
        public ScrollableConsole(int width, int height, int bufferHeight) : base(width - 1, bufferHeight, new Rectangle(0, 0, width - 1, height))
        {
            controlsContainer = new SadConsole.ControlsConsole(1, height);

            ViewPort = new Rectangle(0, 0, width, height);

            scrollBar               = SadConsole.Controls.ScrollBar.Create(Orientation.Vertical, height);
            scrollBar.IsEnabled     = false;
            scrollBar.ValueChanged += ScrollBar_ValueChanged;

            controlsContainer.Add(scrollBar);
            controlsContainer.Position  = new Point(Position.X + width - 1, Position.Y);
            controlsContainer.IsVisible = true;

            Cursor.IsVisible = true;
            Cursor.Print("Just start typing!");
            IsVisible = false;

            scrollingCounter = 0;
        }
Example #11
0
        public ScrollableConsole(int width, int height, int bufferHeight)
            : base(width - 1, bufferHeight)
        {
            controlsContainer = new ControlsConsole(1, height);

            textSurface.RenderArea = new Rectangle(0, 0, width, height);

            scrollBar = SadConsole.Controls.ScrollBar.Create(System.Windows.Controls.Orientation.Vertical, height);
            scrollBar.IsEnabled = false;
            scrollBar.ValueChanged += ScrollBar_ValueChanged;

            controlsContainer.Add(scrollBar);
            controlsContainer.Position = new Point(Position.X + width - 1, Position.Y);
            controlsContainer.IsVisible = true;
            controlsContainer.MouseCanFocus = false;
            controlsContainer.ProcessMouseWithoutFocus = true;

            IsVisible = false;

            scrollingCounter = 0;
        }
        public BorderedScrollingConsole(int width, int height, int bufferHeight) : base(width - 2, bufferHeight)
        {
            controlsContainer      = new SadConsole.Consoles.ControlsConsole(1, height - 2);
            textSurface.RenderArea = new Rectangle(1, 1, width, height - 2);
            scrollBar               = SadConsole.Controls.ScrollBar.Create(System.Windows.Controls.Orientation.Vertical, height - 2);
            scrollBar.IsEnabled     = false;
            scrollBar.ValueChanged += scrollBar_ValueChanged;
            controlsContainer.Add(scrollBar);
            controlsContainer.Position                 = new Point(Position.X + width, Position.Y);
            controlsContainer.IsVisible                = true;
            controlsContainer.MouseCanFocus            = false;
            controlsContainer.ProcessMouseWithoutFocus = true;
            scrollingCounter = 0;
            borderSurface    = new TextSurface(width, height, base.textSurface.Font);
            borderEdit       = new SurfaceEditor(borderSurface);
            Box box = Box.GetDefaultBox();

            box.Width  = width;
            box.Height = height;
            box.Draw(borderEdit);
        }
Example #13
0
        //Create the message window
        public MessageLogWindow(int width, int height, string title) : base(width, height)
        {
            Theme.FillStyle.Background = Color.Black;
            _lines   = new Queue <string>();
            Dragable = true;
            Title    = title.Align(HorizontalAlignment.Left, width);

            //add the console and viewport
            _messageConsole          = new SadConsole.Console(width - _windowBorderThickness, _maxLines);
            _messageConsole.Position = new Point(1, 1);
            _messageConsole.ViewPort = new Rectangle(0, 0, width - 1, height - _windowBorderThickness);

            //create the scrollbar and add it to the window
            _messageScrollBar               = SadConsole.Controls.ScrollBar.Create(SadConsole.Orientation.Vertical, height - _windowBorderThickness);
            _messageScrollBar.Position      = new Point(_messageConsole.Width + 1, _messageConsole.Position.X);
            _messageScrollBar.IsEnabled     = false;
            _messageScrollBar.ValueChanged += MessageScrollBar_ValueChanged;
            Add(_messageScrollBar);

            //Enable mouse support
            UseMouse = true;
        }
        public static void Initialize()
        {
            Consoles = new CustomConsoleList();

            // Hook the update event that happens each frame so we can trap keys and respond.
            SadConsole.Engine.ConsoleRenderStack = Consoles;
            SadConsole.Engine.ActiveConsole = Consoles;

            // Create the basic consoles
            QuickSelectPane = new SadConsoleEditor.Consoles.QuickSelectPane();
            QuickSelectPane.Redraw();
            QuickSelectPane.IsVisible = false;

            topBarPane = new SadConsole.Consoles.Console(Settings.Config.WindowWidth, 1);
            topBarPane.TextSurface.DefaultBackground = Settings.Color_MenuBack;
            topBarPane.Clear();
            topBarPane.MouseCanFocus = false;
            topBarPane.IsVisible = false;

            borderConsole = new SadConsoleEditor.Consoles.BorderConsole(10, 10);
            borderConsole.IsVisible = false;
            borderConsole.CanUseMouse = false;

            ToolsPane = new Consoles.ToolPane();
            ToolsPane.Position = new Point(Settings.Config.WindowWidth - ToolsPane.Width - 1, 1);
            ToolsPane.IsVisible = false;

            // Scroll bar for toolpane
            // Create scrollbar
            ToolsPaneScroller = SadConsole.Controls.ScrollBar.Create(System.Windows.Controls.Orientation.Vertical, Settings.Config.WindowHeight - 1);
            ToolsPaneScroller.Maximum = ToolsPane.TextSurface.Height - Settings.Config.WindowHeight;
            ToolsPaneScroller.ValueChanged += (o, e) =>
            {
                ToolsPane.TextSurface.RenderArea = new Rectangle(0, ToolsPaneScroller.Value, ToolsPane.Width, Settings.Config.WindowHeight);
            };
            scrollerContainer = new ControlsConsole(1, ToolsPaneScroller.Height);
            scrollerContainer.Add(ToolsPaneScroller);
            scrollerContainer.Position = new Point(Settings.Config.WindowWidth - 1, 1);
            scrollerContainer.IsVisible = false;
            scrollerContainer.MouseCanFocus = false;
            scrollerContainer.ProcessMouseWithoutFocus = true;

            var boundsLocation = new Point(0, topBarPane.TextSurface.Height).TranslateFont(topBarPane.TextSurface.Font, Settings.Config.ScreenFont) + new Point(1);
            InnerEmptyBounds = new Rectangle(boundsLocation, new Point(0, QuickSelectPane.Position.Y).WorldLocationToConsole(QuickSelectPane.TextSurface.Font.Size.X, QuickSelectPane.TextSurface.Font.Size.Y)  - boundsLocation);
            InnerEmptyBounds.Width = new Point(ToolsPane.Position.X, 0).TranslateFont(ToolsPane.TextSurface.Font, Settings.Config.ScreenFont).X - 1;

            // Add the consoles to the main console list
            Consoles.Add(QuickSelectPane);
            Consoles.Add(topBarPane);
            Consoles.Add(ToolsPane);
            Consoles.Add(scrollerContainer);

            // Setup the file types for base editors.
            EditorFileTypes = new Dictionary<Type, FileLoaders.IFileLoader[]>(3);
            OpenEditors = new List<SadConsoleEditor.Editors.IEditor>();
            //EditorFileTypes.Add(typeof(Editors.DrawingEditor), new FileLoaders.IFileLoader[] { new FileLoaders.TextSurface() });

            // Add valid editors
            Editors = new Dictionary<string, SadConsoleEditor.Editors.Editors>();
            Editors.Add("Console Draw", SadConsoleEditor.Editors.Editors.Console);
            Editors.Add("Animated Game Object", SadConsoleEditor.Editors.Editors.GameObject);
            Editors.Add("Game Scene", SadConsoleEditor.Editors.Editors.Scene);
            //Editors.Add("User Interface Console", SadConsoleEditor.Editors.Editors.GUI);

            // Show new window
            ShowStartup();
        }
Example #15
0
        public void Initialize()
        {
            closeButton = new StandardButton(15)
            {
                Position = new Point(Width - 17, Height - 4),
                Text     = "[ESC] Close"
            };
            closeButton.Click += (sender, args) => Exit?.Invoke(this, EventArgs.Empty);
            Add(closeButton);

            editSpellButton = new StandardButton(25)
            {
                Position = new Point(Width - 57, 13),
                Text     = "[E] Edit Spell"
            };
            editSpellButton.Click += (sender, args) => EditSpell?.Invoke(this, EventArgs.Empty);
            Add(editSpellButton);

            castSpellButton = new StandardButton(25)
            {
                Position = new Point(Width - 57, 16),
                Text     = "[C] Cast Spell"
            };
            castSpellButton.Click += (sender, args) => CastSpell?.Invoke(this, EventArgs.Empty);
            Add(castSpellButton);

            removeSpellButton = new StandardButton(25)
            {
                Position = new Point(Width - 57, 19),
                Text     = "[R] Remove Spell"
            };
            removeSpellButton.Click += (sender, args) => RemoveSpell?.Invoke(this, EventArgs.Empty);
            Add(removeSpellButton);

            scribeSpellButton = new StandardButton(25)
            {
                Position = new Point(Width - 57, 22),
                Text     = "[G] Write Scroll"
            };
            scribeSpellButton.Click += (sender, args) => ScribeSpell?.Invoke(this, EventArgs.Empty);
            Add(scribeSpellButton);

            saveToLibraryButton = new StandardButton(25)
            {
                Position = new Point(Width - 30, 16),
                Text     = "[T] Save to Library"
            };
            saveToLibraryButton.Click += (sender, args) => SaveToLibrary?.Invoke(this, EventArgs.Empty);
            Add(saveToLibraryButton);

            loadFromLibraryButton = new StandardButton(25)
            {
                Position = new Point(Width - 30, 13),
                Text     = "[L] Load from Library"
            };
            loadFromLibraryButton.Click += (sender, args) => LoadFromLibrary?.Invoke(this, EventArgs.Empty);
            Add(loadFromLibraryButton);

            spellDetails = new SpellDetailsControl(57, Height - 10, PlayerMana)
            {
                Position = new Point(Width - 58, 3)
            };
            Add(spellDetails);

            var scrollBarTheme = new ScrollBarTheme
            {
                Normal = new Cell(DefaultForeground, DefaultBackground)
            };
            var scrollBar = new ScrollBar(Orientation.Vertical, Height - 4)
            {
                Position = new Point(Width - 60, 3),
                Theme    = scrollBarTheme
            };

            Add(scrollBar);
            spellsListBox = new CustomListBox <SpellListBoxItem>(Width - 61, Height - 4, scrollBar)
            {
                Position = new Point(1, 3)
            };
            spellsListBox.SelectionChanged += spellsListBox_SelectedItemChanged;
            Add(spellsListBox);

            RefreshSpells();

            UpdateSpellDetails();
        }
Example #16
0
        private void InitializeControls()
        {
#if DEBUG
            var cheatsButton = new StandardButton(3)
            {
                Text     = "*",
                Position = new Point(Width - 39, 37)
            };
            cheatsButton.Click += (sender, args) => OpenCheats?.Invoke(this, EventArgs.Empty);
            Add(cheatsButton);
#endif

            var playerStatsControl = new PlayerStatsVisualControl(
                new Rectangle(Width - 40, 1, 39, 65),
                Game);
            AddVisualControl(playerStatsControl);

            gameArea = new GameAreaControl(Game)
            {
                Position = new Point(1, 1)
            };
            Add(gameArea);

            journalScroll = new ScrollBar(Orientation.Vertical, 9)
            {
                Position = new Point(1, Height - 10),
                CanFocus = false,
                Theme    = new ScrollBarTheme
                {
                    Normal = new Cell(Color.White, Color.Black)
                }
            };
            Add(journalScroll);

            journalBox = new JournalBoxControl(Width - 3, 10, journalScroll, Game.Journal)
            {
                Position = new Point(2, Height - 11)
            };
            Add(journalBox);


            openInventoryButton = new StandardButton(30)
            {
                Position = new Point(Width - 39, 22),
                Text     = "[I] Inventory"
            };
            openInventoryButton.Click += (sender, args) => OpenInventory?.Invoke(this, EventArgs.Empty);
            Add(openInventoryButton);

            openSpellBookButton = new StandardButton(30)
            {
                Position = new Point(Width - 39, 25),
                Text     = "[C] Spell Book"
            };
            openSpellBookButton.Click    += (sender, args) => OpenSpellBook?.Invoke(this, EventArgs.Empty);
            openSpellBookButton.IsEnabled = true;
            Add(openSpellBookButton);

            showItemsOnFloorButton = new StandardButton(30)
            {
                Position = new Point(Width - 39, 28),
                Text     = "[G] Check Floor"
            };
            showItemsOnFloorButton.Click += (sender, args) => OpenGroundView?.Invoke(this, EventArgs.Empty);
            Add(showItemsOnFloorButton);

            openPlayerStatsButton = new StandardButton(30)
            {
                Position = new Point(Width - 39, 31),
                Text     = "[V] Player Status"
            };
            openPlayerStatsButton.Click += (sender, args) => OpenPlayerStats?.Invoke(this, EventArgs.Empty);
            Add(openPlayerStatsButton);
        }