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); }
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); }
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; }
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; }
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); }
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); }
public MainScreen(GameContext context) : base("main") { this.context = context; //loadMap(); loadEntities(); mapCons.Components.Add(new MapConsoleLogic(this.context)); CenterOnObject(context.Player); var statDisplay = new PriStatsDisplay(new Point(1, 1)); context.Player.GetComponent <ObPrimaryStats>().Subscribe(statDisplay); statCons.Add(statDisplay); }
public void Init() { _listBox = new MogwaiListBox(26, 12) { Position = new Point(0, 0), HideBorder = false }; foreach (var baseItem in _mogwai.HomeTown.Shop.Inventory) { _listBox.Items.Add(baseItem); } _controlsConsole.Add(_listBox); _listBox.SelectedItemChanged += _listBox_SelectedItemChanged; var _btnBuy = new Button(8, 1) { Text = "BUY", Position = new Point(1, 15) }; _controlsConsole.Add(_btnBuy); }
public void UpdateMenuList() { menuControls.RemoveAll(); int buttonPosition = 1; currentButton = -1; buttons.Clear(); // Continue game button if (GameLogic.GameMapScreen != null) { SadConsole.Controls.Button continueGameButton = new SadConsole.Controls.Button(16); continueGameButton.Text = "Continue Game"; continueGameButton.Position = new Microsoft.Xna.Framework.Point(2, buttonPosition); buttonPosition += 2; continueGameButton.Click += ContinueGameButtonClicked; menuControls.Add(continueGameButton); buttons.Add(continueGameButton); } // New game button SadConsole.Controls.Button newGameButton = new SadConsole.Controls.Button(16); newGameButton.Text = "New Game"; newGameButton.Position = new Microsoft.Xna.Framework.Point(2, buttonPosition); buttonPosition += 2; newGameButton.Click += NewGameButtonClicked; menuControls.Add(newGameButton); buttons.Add(newGameButton); // Exit game button SadConsole.Controls.Button exitGameButton = new SadConsole.Controls.Button(16); exitGameButton.Text = "Exit"; exitGameButton.Position = new Microsoft.Xna.Framework.Point(2, buttonPosition); buttonPosition += 2; exitGameButton.Click += ExitGameButtonClicked; menuControls.Add(exitGameButton); buttons.Add(exitGameButton); }
public void Init() { IsVisible = true; if (_controller.CurrentMogwai != null) { _controller.RefreshCurrent(1); } _command1.BorderSurface.SetGlyph(0, 0, 204, Color.DarkCyan); _command1.BorderSurface.SetGlyph(0, 1, 186, Color.DarkCyan); _command1.BorderSurface.SetGlyph(0, 2, 200, Color.DarkCyan); _playScreenButtons.Add("level", MenuButton(0, "level", DoAction)); _playScreenButtons.Add("inven", MenuButton(1, "inven", DoAction)); _playScreenButtons.Add("adven", MenuButton(2, "adven", DoAction)); _playScreenButtons.Add("heal", MenuButton(3, "heal", DoAction)); _playScreenButtons.Add("modif", MenuButton(4, "modif", DoAction)); _playScreenButtons.Add("breed", MenuButton(5, "breed", DoAction)); _playScreenButtons.Add("shop", MenuButton(6, "shop", DoAction)); _btnEvolve = new MogwaiButton(8, 1) { Position = new Point(0, 0), Text = "evolve" }; _btnEvolve.Click += (btn, args) => { DoAction(((Button)btn).Text); }; _command2.Add(_btnEvolve); _btnFast = new MogwaiButton(8, 1) { Position = new Point(0, 1), Text = "evol++" }; _btnFast.Click += (btn, args) => { DoAction(((Button)btn).Text); }; _command2.Add(_btnFast); }
private void AddButton(int index, string text, Action <string> buttonClicked) { SetGlyph(10 + (index * 11), trailerPosition, 203, Color.DarkCyan); controlsConsole.SetGlyph(10 + (index * 11), 0, 186, Color.DarkCyan); borderSurface.SetGlyph(11 + (index * 11), trailerPosition + 3, 202, Color.DarkCyan); var txt = text; var button = new MogwaiButton(8, 1); button.Position = new Point(1 + (index * 11), 0); button.Text = txt; button.Click += (btn, args) => { buttonClicked(((Button)btn).Text); }; controlsConsole.Add(button); }
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); }
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); }
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(); }
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(); }
public void RedrawPanels() { int activeRow = 0; ToolsConsole.Clear(); ToolsConsole.RemoveAll(); _hotSpots.Clear(); char open = (char)31; char closed = (char)16; List <CustomPanel> allPanels = new List <CustomPanel>() { PanelFiles }; // Custom panels from the selected editor if (MainScreen.Instance.ActiveEditor != null) { if (MainScreen.Instance.ActiveEditor.Panels != null && MainScreen.Instance.ActiveEditor.Panels.Length != 0) { allPanels.AddRange(MainScreen.Instance.ActiveEditor.Panels); } } // Custom panels from the selected tool //if (SelectedTool.ControlPanels != null && SelectedTool.ControlPanels.Length != 0) // allPanels.AddRange(SelectedTool.ControlPanels); // Display all panels needed if (allPanels.Count != 0) { foreach (var pane in allPanels) { if (pane.IsVisible) { pane.Loaded(); _hotSpots.Add(new Tuple <CustomPanel, int>(pane, activeRow)); if (pane.IsCollapsed == false) { ToolsConsole.Print(1, activeRow++, open + " " + pane.Title); ToolsConsole.Print(0, activeRow++, new string((char)196, ToolsConsole.TextSurface.Width)); foreach (var control in pane.Controls) { if (control != null) { if (control.IsVisible) { ToolsConsole.Add(control); control.Position = new Point(1, activeRow); activeRow += pane.Redraw(control) + control.Height; } } else { activeRow++; } } activeRow += 1; } else { ToolsConsole.Print(1, activeRow++, closed + " " + pane.Title); } } } } int scrollAbility = activeRow + 1 - Settings.Config.WindowHeight; if (scrollAbility <= 0) { ToolsPaneScroller.IsEnabled = false; ToolsPaneScroller.Maximum = 0; } else { ToolsPaneScroller.Maximum = scrollAbility; ToolsPaneScroller.IsEnabled = true; } }