Example #1
0
 protected virtual void InitControls(int width, int height)
 {
     Controls           = new ControlsConsole(width, height);
     Controls.IsVisible = true;
     Controls.IsFocused = false;
     Children.Add(Controls);
 }
        private void CreateControls()
        {
            Controls             = new ControlsConsole(Game.Settings.GameWidth, 3);
            Controls.Theme       = new PaperWindowTheme();
            Controls.ThemeColors = ThemeColors.Clear;
            Controls.Position    = new Coord(0, Game.Settings.GameHeight - 2);
            int currentX = 0;

            foreach (IConsoleComponent visible in Player.Components)
            {
                try
                {
                    IDisplay display = (IDisplay)visible;
                    if (display != null)
                    {
                        Children.Add(display.Window);
                        display.MaximizeButton.Position = new Coord(currentX, 0);
                        currentX += display.MaximizeButton.Width;
                        Controls.Add(display.MaximizeButton);
                    }
                }
                catch
                {
                    // ignored
                }
            }
            Children.Add(Controls);

            LookingGlass = new MagnifyingGlass(new Coord(Game.Settings.GameWidth / 2, Game.Settings.GameHeight / 2));
            Children.Add(LookingGlass);
        }
Example #3
0
        public SelectionScreen(MogwaiController mogwaiController, int width, int height) : base(width, height)
        {
            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);
            Children.Add(borderSurface);

            controlsConsole          = new ControlsConsole(110, 1);
            controlsConsole.Position = new Point(0, 24);
            controlsConsole.Fill(Color.DarkCyan, Color.Black, null);
            Children.Add(controlsConsole);

            infoConsole          = new MogwaiConsole("Info", "", 24, 38);
            infoConsole.Position = new Point(113, -8);
            Children.Add(infoConsole);

            logConsole          = new MogwaiConsole("Log", "", 110, 3);
            logConsole.Position = new Point(0, 27);
            Children.Add(logConsole);

            headerPosition  = 1;
            trailerPosition = height - 2;

            CreateHeader();
            CreateTrailer();

            controller = mogwaiController;
        }
Example #4
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 #5
0
        public (ControlsConsole, Window) CreateM2Window(Size windowSize, string title)
        {
            int viewWidth  = windowSize.Width - 2;
            int viewHeight = windowSize.Height - 2;

            Window menuWindow = new Window(windowSize.Width, windowSize.Height)
            {
                CanDrag           = true,
                Title             = title.Align(HorizontalAlignment.Center, viewWidth),
                DefaultBackground = MG.Color.Black,
            };

            log.DebugFormat("Created menu window, [{0}].", menuWindow.AbsoluteArea);

            var menuConsole = new ControlsConsole(viewWidth, viewHeight)
            {
                DefaultBackground = MG.Color.Black,
            };

            // Fit the Console inside the Window border
            menuConsole.Position = new Coord(1, 1);
            log.DebugFormat("Created menu console, [{0}].", menuConsole.AbsoluteArea);

            menuConsole.Clear();

            menuWindow.Children.Add(menuConsole);
            return(menuConsole, menuWindow);
        }
Example #6
0
        public ScrollingConsole(int width, int height, int bufferHeight, Font font = null)
        {
            UseKeyboard   = false;
            UseMouse      = true;
            _controlsHost = new ControlsConsole(1, height);

            var borderSurface = new Basic(width + 2, height + 2, Font);

            borderSurface.DrawBox(new Rectangle(0, 0, borderSurface.Width, borderSurface.Height),
                                  new Cell(Color.DarkCyan, Color.Black), null, ConnectedLineThick);
            borderSurface.Position = new Point(-1, -1);
            Children.Add(borderSurface);

            _mainConsole = new Console(width - 1, bufferHeight)
            {
                ViewPort = new Rectangle(0, 0, width - 1, height),
                Cursor   = { IsVisible = false },
                Font     = font == null ? Font:font
            };

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

            _controlsHost.Add(_scrollBar);
            _controlsHost.Position = new Point(1 + _mainConsole.Width, Position.Y);

            Children.Add(_mainConsole);
            Children.Add(_controlsHost);

            _scrollingCounter = 0;
        }
Example #7
0
        /// <inheritdoc />
        public override void Draw(ControlsConsole console, CellSurface hostSurface)
        {
            hostSurface.DefaultForeground = FillStyle.Foreground;
            hostSurface.DefaultBackground = FillStyle.Background;
            hostSurface.Fill(hostSurface.DefaultForeground, hostSurface.DefaultBackground, FillStyle.Glyph, null);

            if (!(console is Window window))
            {
                return;
            }

            if (BorderLineStyle != null)
            {
                hostSurface.DrawBox(new Rectangle(0, 0, hostSurface.Width, hostSurface.Height), new Cell(BorderStyle.Foreground,
                                                                                                         BorderStyle.Background, 0), null, BorderLineStyle);
            }

            // Draw title
            var adjustedText  = "";
            var adjustedWidth = hostSurface.Width - 2;

            TitleAreaLength = 0;
            TitleAreaX      = 0;

            if (!string.IsNullOrEmpty(window.Title))
            {
                if (window.Title.Length > adjustedWidth)
                {
                    adjustedText = window.Title.Substring(0, window.Title.Length - (window.Title.Length - adjustedWidth));
                }
                else
                {
                    adjustedText = window.Title;
                }
            }

            if (!string.IsNullOrEmpty(adjustedText))
            {
                TitleAreaLength = adjustedText.Length;

                if (window.TitleAlignment == HorizontalAlignment.Left)
                {
                    TitleAreaX = 1;
                }

                else if (window.TitleAlignment == HorizontalAlignment.Center)
                {
                    TitleAreaX = ((adjustedWidth - adjustedText.Length) / 2) + 1;
                }

                else
                {
                    TitleAreaX = hostSurface.Width - 1 - adjustedText.Length;
                }

                hostSurface.Print(TitleAreaX, TitleAreaY, adjustedText, TitleStyle);
            }
        }
        /// <summary>
        /// Draws the theme to the console.
        /// </summary>
        /// <param name="console">Console associated with the theme.</param>
        /// <param name="hostSurface">Surface used for drawing.</param>
        public virtual void Draw(ControlsConsole console, CellSurface hostSurface)
        {
            Colors colors = console.ThemeColors ?? Library.Default.Colors;

            FillStyle = colors.Appearance_ControlNormal;

            hostSurface.DefaultForeground = FillStyle.Foreground;
            hostSurface.DefaultBackground = FillStyle.Background;
            hostSurface.Fill(hostSurface.DefaultForeground, hostSurface.DefaultBackground, FillStyle.Glyph, null);
        }
        public void Init()
        {
            _consoleList.Add(CreateChoice(0, 0, "Hollow Mountain", "Hollow Mountain is the largest peak on Rivenrake Island, which lies at " +
                                          "the northwestern edge of the Varisian Gulf", "icon2s.png", AdventureType.TestRoom));
            _consoleList.Add(CreateChoice(1, 0, "The Manstone Caverns", "The underground complex, a network of caverns accessible only via " +
                                          "the Darklands or through well-defended chambers connected to hideouts " +
                                          "above.", "icon1s.png", AdventureType.Chamber));
            _consoleList.Add(CreateChoice(2, 0, "Gallowspire", "Located in the Hungry Mountains in southwestern Ustalav, the tower of Gallowspire " +
                                          "stands as a crumbling testament to the power of the immortal lich Tar-Baphon.", "icon3s.png", AdventureType.Dungeon));
            _consoleList.Add(CreateChoice(0, 1, "The Pyramid of Kamaria", "Kamaria, which dominates the southern skyline of the Osirian " +
                                          "city of An. Dedicated to the only ruler of the ancient kingdom.", "icon4s.png", AdventureType.Battle));
            _consoleList.Add(CreateChoice(1, 1, "The King Karamoss", "A thousand years ago, the city of Absalom faced one of its most exotic foes. " +
                                          "The mysterious wizard Karamoss.", "icon5s.png", AdventureType.Quest));

            _travelControl = new ControlsConsole(43, 7)
            {
                Position = new Point(47, 14)
            };
            _travelControl.Fill(Color.Transparent, new Color(05, 05, 05, 255), null);
            Children.Add(_travelControl);

            _travelControl.Print(1, 1, "Adventure: ", Color.Gainsboro);
            _travelControl.Print(1, 2, "Difficulty:", Color.Gainsboro);
            _travelControl.Print(1, 4, "Cost:", Color.Gainsboro);

            var button = new MogwaiButton(10, 1)
            {
                Position = new Point(33, 6),
                Text     = "TRAVEL"
            };

            button.Click += (btn, args) => { DoAdventure(); };
            _travelControl.Add(button);

            var bDec = new MogwaiButton(3, 1)
            {
                Position = new Point(34, 2),
                Text     = "-"
            };

            bDec.Click += (btn, args) => { DoDifficulty(false); };
            _travelControl.Add(bDec);

            var bInc = new MogwaiButton(3, 1)
            {
                Position = new Point(38, 2),
                Text     = "+"
            };

            bInc.Click += (btn, args) => { DoDifficulty(true); };
            _travelControl.Add(bInc);

            DoDifficulty(false);
            DoAction(_currentAdventureType);
        }
Example #10
0
        public void RenderMainMenu(EventHandler newGameHandler, EventHandler changeAppearanceHandler)
        {
            int buttonHeight          = 3;
            int spacingBetweenButtons = 2;

            int width  = Console.Width / 2;
            int height = Console.Height / 2;
            int x      = width / 2;
            int y      = height / 2;

            var console = CreateChildConsole(width, height, x, y);

            DrawOutline(console, menuBorderColor);

            var controls = new ControlsConsole(width - GlobalConstants.BorderWidth * 2, (height / 2) - GlobalConstants.BorderWidth)
            {
                Position = new Point(GlobalConstants.BorderWidth, GlobalConstants.BorderWidth / 2),
                Parent   = console
            };

            var newGame = new Button(20, buttonHeight)
            {
                Text        = "New Game",
                Position    = new Point((controls.Width / 2) - 10, spacingBetweenButtons),
                UseMouse    = true,
                UseKeyboard = false,
            };

            newGame.Click += newGameHandler;
            controls.Add(newGame);

            var changeAppearance = new Button(20, buttonHeight)
            {
                Text        = "Change Appearance",
                Position    = new Point((controls.Width / 2) - 10, spacingBetweenButtons * 2 + buttonHeight),
                UseMouse    = true,
                UseKeyboard = false,
            };

            changeAppearance.Click += changeAppearanceHandler;
            controls.Add(changeAppearance);

            var exitGame = new Button(20, buttonHeight)
            {
                Text        = "Exit Game",
                Position    = new Point((controls.Width / 2) - 10, spacingBetweenButtons * 3 + buttonHeight * 2),
                UseMouse    = true,
                UseKeyboard = false,
            };

            exitGame.Click += ButtonPressExitGame;
            controls.Add(exitGame);
        }
Example #11
0
        public void Apply(ControlsConsole console)
        {
            #region Colors OVERRIDES

            /* Colors overrides
             *  //Colors.MenuBack = MenuBack;
             *  //Colors.MenuLines = MenuLines;
             *  //Colors.TitleText = TitleText;
             *  //Colors.ModalBackground = ModalBackground;
             *
             *  //Colors.ControlBack = Color.Transparent;
             *  //Colors.ControlBackDark = Color.Transparent;
             *  //Colors.ControlBackLight = Color.Transparent;
             *  //Colors.ControlBackSelected = ControlBackSelected;
             *  //Colors.ControlHostBack = ControlHostBack;
             *  //Colors.ControlHostFore = ControlHostFore;
             *
             *  //Colors.Text = Text;
             *  //Colors.TextBright = TextBright;
             *  //Colors.TextDark = TextDark;
             *  //Colors.TextLight = TextLight;
             *  //Colors.TextSelected = TextSelected;
             *  //Colors.TextSelectedDark = TextSelectedDark;
             */
            #endregion

            //Library.Default.Appearance_ControlNormal = new Cell( Text, Color.Transparent );
            //Library.Default.Appearance_ControlDisabled = new Cell( TextDark, ControlBackDark );
            //Library.Default.Appearance_ControlOver = new Cell( TextBright, ControlBackSelected );
            //Library.Default.Appearance_ControlSelected = new Cell( TextSelected, ControlBackSelected );
            //Library.Default.Appearance_ControlMouseDown = new Cell( TextSelected, ControlBackDark );
            //Library.Default.Appearance_ControlFocused = new Cell( TextBright, ControlBackLight );

            Library.Default.ControlsConsoleTheme = new ControlsConsoleTheme();
            Library.Default.WindowTheme          = new WindowTheme();

            Library.Default.ScrollBarTheme       = new ScrollBarTheme();
            Library.Default.ButtonTheme          = new ButtonTheme();
            Library.Default.CheckBoxTheme        = new CheckBoxTheme();
            Library.Default.ListBoxTheme         = new ListBoxTheme();
            Library.Default.ProgressBarTheme     = new ProgressBarTheme();
            Library.Default.RadioButtonTheme     = new RadioButtonTheme();
            Library.Default.TextBoxTheme         = new TextBoxTheme();
            Library.Default.SelectionButtonTheme = new ButtonTheme();

            //Library.Default.ListBoxTheme.ItemTheme.Selected = new Cell( ControlBackSelected, TextLight );

            //Library.Default.WindowTheme.FillStyle.Background = MenuBack;


            //Library.Default.Apply( console );
        }
Example #12
0
    public static void PrintCentre(this ControlsConsole console, int x, int y, string text, Cell cell = null)
    {
        int half_text_width = text.Count() / 2;

        if (cell == null)
        {
            console.Print(x - half_text_width, y, text, new Cell(Color.White, Color.Black));
        }
        else
        {
            console.Print(x - half_text_width, y, text, cell);
        }
    }
Example #13
0
        public SelectionScreen(MogwaiController mogwaiController, int width, int height) : base(width, height)
        {
            _borderSurface = new Basic(width + 2, height + 2, Font);
            _borderSurface.DrawBox(new Rectangle(0, 0, _borderSurface.Width, _borderSurface.Height),
                                   new Cell(Color.DarkCyan, Color.Black), null, ConnectedLineThick);
            _borderSurface.Position = new Point(-1, -1);
            Children.Add(_borderSurface);

            _controlsConsole = new ControlsConsole(110, 1)
            {
                Position = new Point(0, 24)
            };
            _controlsConsole.Fill(Color.DarkCyan, Color.Black, null);
            Children.Add(_controlsConsole);

            _infoConsole = new MogwaiConsole("Info", "", 24, 38)
            {
                Position = new Point(113, -8)
            };
            Children.Add(_infoConsole);

            _debugConsole = new Console(24, 38)
            {
                Position = new Point(113, 22)
            };
            _debugConsole.Fill(Color.Beige, Color.TransparentBlack, null);
            _debugConsole.Print(1, 1, $"Debug Console [{Coloring.Gold("     ")}]:");
            _debugConsole.Print(1, 2, $"..armors: {Armors.Instance.AllBuilders().Count}");
            _debugConsole.Print(1, 3, $"..weapns: {Weapons.Instance.AllBuilders().Count}");
            _debugConsole.Print(1, 4, $"..mnstrs: {Monsters.Instance.AllBuilders().Count}");
            Children.Add(_debugConsole);


            _logConsole = new MogwaiConsole("Log", "", 110, 3)
            {
                Position = new Point(0, 27)
            };
            Children.Add(_logConsole);

            HeaderPosition  = 1;
            TrailerPosition = height - 2;

            CreateHeader();
            CreateTrailer();

            _controller    = mogwaiController;
            _transferFunds = 2;

            Init();
        }
Example #14
0
        public static void Apply(this Library library, ControlsConsole controlsHost)
        {
            controlsHost.Theme = library.ControlsConsoleTheme;

            if (controlsHost is Window window)
            {
                window.Theme = library.WindowTheme;
            }

            foreach (var c in controlsHost.Controls)
            {
                switch (c)
                {
                case SelectionButton control:
                    control.Theme = library.SelectionButtonTheme;
                    break;

                case Button control:
                    control.Theme = library.ButtonTheme;
                    break;

                case ScrollBar control:
                    control.Theme = library.ScrollBarTheme;
                    break;

                case RadioButton control:
                    control.Theme = library.RadioButtonTheme;
                    break;

                case ListBox control:
                    control.Theme        = library.ListBoxTheme;
                    control.Slider.Theme = library.ScrollBarTheme;
                    break;

                case CheckBox control:
                    control.Theme = library.CheckBoxTheme;
                    break;

                case TextBox control:
                    control.Theme = library.TextBoxTheme;
                    break;

                case ProgressBar control:
                    control.Theme = library.ProgressBarTheme;
                    break;
                }
            }
        }
Example #15
0
        public MenuScreen()
        {
            // Initialize the main console
            menuConsole = new SadConsole.Console(GameLogic.WindowWidth, GameLogic.WindowHeight);
            menuConsole.Components.Add(new Controls.MenuKeyboardControlComponent(this));
            menuConsole.IsFocused = true;

            // Create control console
            menuControls          = new ControlsConsole(20, 30);
            menuControls.Position = new Microsoft.Xna.Framework.Point(GameLogic.WindowWidth / 2 - 10, GameLogic.WindowHeight - 41);

            buttons = new List <SadConsole.Controls.ButtonBase>();

            UpdateMenuList();

            // Add control console to the main console
            menuConsole.Children.Add(menuControls);
        }
        private MogwaiChooseButton CreateChoice(int index, int row, string name, string description, string pathIcon, AdventureType adventureType)
        {
            var choiceConsole = new Console(32, 7)
            {
                Position = new Point(13 + row * 45, 0 + index * 7)
            };

            choiceConsole.Fill(Color.TransparentBlack, Color.Black, null);
            choiceConsole.Print(0, 0, name, Color.White);
            choiceConsole.Print(0, 1, $"[c:g b:darkred:black:black:{description.Length}]" + description, Color.DarkGray);
            Children.Add(choiceConsole);

            var controls = new ControlsConsole(10, 5)
            {
                Position = new Point(-12, 1)
            };

            controls.Fill(Color.Transparent, Color.DarkGray, null);
            choiceConsole.Children.Add(controls);
            var button = new MogwaiChooseButton(10, 5)
            {
                Position = new Point(0, 0)
            };

            button.Click += (btn, args) => { DoAction(adventureType); };
            controls.Add(button);
            button.Unselect();

            // Load the logo
            System.IO.Stream imageStream = TitleContainer.OpenStream(pathIcon);
            var image = Texture2D.FromStream(Global.GraphicsDevice, imageStream);

            imageStream.Dispose();

            Font pictureFont = Global.LoadFont("Cheepicus12.font").GetFont(Font.FontSizes.Quarter);

            // Configure the logo
            SadConsole.Surfaces.Basic consoleImage = image.ToSurface(pictureFont, true);
            consoleImage.Position = new Point(85 + row * 75, 12 + 30 * index);
            //consoleImage.Tint = Color.DarkSlateBlue;
            controls.Children.Add(consoleImage);

            return(button);
        }
Example #17
0
        public ToolPane()
        {
            ToolsConsole = new ControlsConsole(Settings.Config.ToolPaneWidth - 1, Settings.Config.WindowHeight * 3);
            ToolsConsole.MouseHandler = ProcessMouse;
            ToolsConsole.UseKeyboard  = false;

            // Create scrollbar
            ToolsPaneScroller               = SadConsole.Controls.ScrollBar.Create(System.Windows.Controls.Orientation.Vertical, Settings.Config.WindowHeight - 1);
            ToolsPaneScroller.Maximum       = ToolsConsole.TextSurface.Height - Settings.Config.WindowHeight;
            ToolsPaneScroller.ValueChanged += (o, e) =>
            {
                ToolsConsole.TextSurface.RenderArea = new Rectangle(0, ToolsPaneScroller.Value, ToolsConsole.Width, Settings.Config.WindowHeight);
            };

            ScrollerConsole = new ControlsConsole(1, Settings.Config.WindowHeight - 1);
            ScrollerConsole.Add(ToolsPaneScroller);
            ScrollerConsole.Position          = new Point(Width, 0);
            ScrollerConsole.IsVisible         = true;
            ScrollerConsole.FocusOnMouseClick = false;



            PanelWidth         = Settings.Config.ToolPaneWidth - 1;
            PanelWidthControls = PanelWidth - 2;

            _tools = new Dictionary <string, ITool>();

            ToolsConsole.TextSurface.DefaultBackground = Settings.Color_MenuBack;
            ToolsConsole.TextSurface.DefaultForeground = Settings.Color_TitleText;
            ToolsConsole.Clear();

            _hotSpots = new List <Tuple <CustomPanel, int> >();

            // Create tools
            _tools.Add(PaintTool.ID, new PaintTool());
            ToolsConsole.TextSurface.RenderArea = new Rectangle(0, 0, ToolsConsole.Width, Settings.Config.WindowHeight - 1);

            // Create panels
            PanelFiles = new FilesPanel();
            //PanelTools = new ToolsPanel();

            Children.Add(ToolsConsole);
            Children.Add(ScrollerConsole);
        }
Example #18
0
 private void SetupViews(int screenWidth, int screenHeight, CellSurface title)
 {
     mapgenButton             = UIFactory.CreateButton(15, "New World", 27, 13);
     chargenButton            = UIFactory.CreateButton(15, "New Character", 35, 15);
     startGameButton          = UIFactory.CreateButton(15, "Start game", 43, 17);
     licenseButton            = UIFactory.CreateButton(15, "License", 45, 13);
     quitGameButton           = UIFactory.CreateButton(15, "Quit", 27, 17);
     closeCGWindowButton      = UIFactory.CreateButton(1, "x", 0, 0);
     closeMGWindowButton      = UIFactory.CreateButton(1, "x", 0, 0);
     closeLicenseWindowButton = UIFactory.CreateButton(1, "x", 0, 0);
     MenuView = new ControlsConsole(screenWidth, screenHeight);
     MenuView.Add(chargenButton);
     MenuView.Add(mapgenButton);
     MenuView.Add(startGameButton);
     MenuView.Add(licenseButton);
     MenuView.Add(quitGameButton);
     MenuView.UseMouse = true;
     Children.Add(MenuView);
     MenuView.SetSurface(title);
 }
Example #19
0
        public CustomShop(Mogwai mogwai, int width, int height) : base("Home Town Shop", "", width, height)
        {
            _mogwai = mogwai;
            Fill(DefaultForeground, new Color(100, 0, 200, 150), null);

            _controlsConsole = new ControlsConsole(26, 20)
            {
                Position = new Point(1, 1)
            };
            _controlsConsole.Fill(Color.Transparent, new Color(100, 0, 200, 150), null);
            Children.Add(_controlsConsole);

            _itemConsole = new MogwaiConsole("Item", "", 50, 20)
            {
                Position = new Point(30, 1)
            };
            //_itemConsole.Fill(Color.Transparent, Color.DarkKhaki, null);
            Children.Add(_itemConsole);

            Init();
        }
Example #20
0
        public Container()
        {
            EditingColors = SadConsole.UI.Themes.Library.Default.Colors.Clone();
            //EditingColors = SadConsole.UI.Colors.CreateSadConsoleBlue();

            OptionsPanel = new ControlsConsole(6, 2);
            Border.AddToSurface(OptionsPanel, "");
            OptionsPanel.Position = (2, 1);

            Button button = new Button(6, 1)
            {
                Text = "Load", Position = (0, 0)
            };

            button.Click += ButtonLoad_Click;
            OptionsPanel.Controls.Add(button);

            button = new Button(6, 1)
            {
                Text = "Save", Position = (0, 1)
            };
            button.Click += ButtonSave_Click;
            OptionsPanel.Controls.Add(button);

            SettingsPanel = new SettingsConsole(30, 36);
            Border.AddToSurface(SettingsPanel, "Settings");
            SettingsPanel.Position = (4, 3);

            TestingPanel = new ControlsTest();
            Border.AddToSurface(TestingPanel, "Preview");
            TestingPanel.Position             = SettingsPanel.Position + (SettingsPanel.Surface.Area.Width, 0) + (4, 0);
            TestingPanel.Controls.ThemeColors = EditingColors;

            Children.Add(SettingsPanel);
            Children.Add(OptionsPanel);
            Children.Add(TestingPanel);
        }
Example #21
0
        public SerializationTests()
        {
            controlsConsole = new ControlsConsole(80, 4);

            masterView = new Console(34, 15);
            loadedView = new Console(34, 15);

            masterView.Fill(Color.White, Color.Red, 0);
            loadedView.Fill(Color.White, Color.Blue, 0);

            UseMouse = true;

            // Add the consoles to the list.
            Children.Add(controlsConsole);
            Children.Add(masterView);
            Children.Add(loadedView);

            // Setup main view
            masterView.Position = new Point(3, 6);

            // Setup sub view
            loadedView.Position = new Point(80 - 37, 6);


            // Setup controls
            controlsConsole.Position = new Point(0, 0);

            optionButtonSurface = new SadConsole.Controls.RadioButton(18, 1)
            {
                Text     = "Surface",
                Position = new Point(1, 1),
            };
            optionButtonSurface.IsSelectedChanged += OptionButton_IsSelectedChanged;
            controlsConsole.Add(optionButtonSurface);

            optionButtonView = new SadConsole.Controls.RadioButton(18, 1)
            {
                Text     = "Surface View",
                Position = new Point(1, 2)
            };
            optionButtonView.IsSelectedChanged += OptionButton_IsSelectedChanged;
            controlsConsole.Add(optionButtonView);

            optionButtonLayered = new SadConsole.Controls.RadioButton(21, 1)
            {
                Text     = "Layered Surface",
                Position = new Point(optionButtonSurface.Bounds.Right + 1, 1)
            };
            optionButtonLayered.IsSelectedChanged += OptionButton_IsSelectedChanged;
            controlsConsole.Add(optionButtonLayered);

            optionButtonAnimated = new SadConsole.Controls.RadioButton(21, 1)
            {
                Text     = "Animated Surface",
                Position = new Point(optionButtonSurface.Bounds.Right + 1, 2)
            };
            optionButtonAnimated.IsSelectedChanged += OptionButton_IsSelectedChanged;
            controlsConsole.Add(optionButtonAnimated);

            var buttonSave = new SadConsole.Controls.Button(17)
            {
                Text     = "Save and Load",
                Position = new Point(controlsConsole.Width - 19, 1)
            };

            buttonSave.Click += ButtonSave_Click;
            controlsConsole.Add(buttonSave);

            basicSurface    = new SadConsole.Surfaces.BasicSurface(34, 15);
            layeredSurface  = new SadConsole.Surfaces.LayeredSurface(34, 15, 3);
            animatedSurface = SadConsole.GameHelpers.Animations.CreateStatic(34, 15, 15, 0.3d);
            viewSurface     = new SadConsole.Surfaces.SurfaceView(basicSurface, new Rectangle(5, 2, 34 - 10, 15 - 4));
            emptySurface    = (SadConsole.Surfaces.BasicSurface)loadedView.TextSurface;

            MakeBasicSurface();
            MakeLayeredSurface();
        }
Example #22
0
 /// <summary>
 /// Draws the theme to the console.
 /// </summary>
 /// <param name="console">Console associated with the theme.</param>
 /// <param name="hostSurface">Surface used for drawing.</param>
 public virtual void Draw(ControlsConsole console, CellSurface hostSurface)
 {
     hostSurface.DefaultForeground = FillStyle.Foreground;
     hostSurface.DefaultBackground = FillStyle.Background;
     hostSurface.Fill(hostSurface.DefaultForeground, hostSurface.DefaultBackground, FillStyle.Glyph, null);
 }
Example #23
0
        public override void Draw(ControlsConsole console, CellSurface hostSurface)
        {
            this.FillStyle.Background = Color.Black;

            base.Draw(console, hostSurface);
        }
Example #24
0
        public PlayScreen(MogwaiController mogwaiController, int width, int height) : base(width, height)
        {
            _controller = mogwaiController;
            var mogwaiKeys = _controller.CurrentMogwaiKeys ?? _controller.TestMogwaiKeys();

            _mogwai = mogwaiKeys.Mogwai;

            _playScreenButtons = new Dictionary <string, MogwaiButton>();

            var playStatsConsole = new PlayStatsConsole(_mogwai, 44, 22)
            {
                Position = new Point(0, 0)
            };

            Children.Add(playStatsConsole);

            _welcome = new CustomWelcome(91, 22)
            {
                Position = new Point(46, 0)
            };

            _adventureChoose = new CustomAdventureChoose(mogwaiController, 91, 22)
            {
                Position = new Point(46, 0)
            };


            _shop = new CustomShop(_mogwai, 91, 22)
            {
                Position = new Point(46, 0)
            };
            _adventure = new CustomAdventure(mogwaiController, mogwaiKeys, 91, 22)
            {
                Position = new Point(46, 0)
            };
            _adventureStats = new CustomAdventureStats(_mogwai, 91, 22)
            {
                Position = new Point(46, 0)
            };

            //var logFont = Global.LoadFont("Bakus8.font").GetFont(Font.FontSizes.One);
            _log = new ScrollingConsole(85, 13, 100, null)
            {
                Position = new Point(0, 25)
            };
            Children.Add(_log);

            var playInfoConsole = new PlayInfoConsole(mogwaiController, mogwaiKeys, 49, 14)
            {
                Position = new Point(88, 24)
            };

            Children.Add(playInfoConsole);

            _command1 = new TestControls(86, 1)
            {
                Position = new Point(0, 23)
            };
            _command1.Fill(Color.Transparent, Color.Black, null);
            Children.Add(_command1);

            _command2 = new ControlsConsole(8, 2)
            {
                Position = new Point(40, 2)
            };
            _command2.Fill(Color.Transparent, Color.DarkGray, null);
            playInfoConsole.Children.Add(_command2);

            State = SadGuiState.Play;

            SetCustomWindowState(PlayScreenState.Welcome);

            Init();
        }
        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();
        }