// Loads a map into the MapConsole. public void LoadMap(Map map) { MapConsole = new SadConsole.ScrollingConsole(GameLoop.World.CurrentMap.Width, GameLoop.World.CurrentMap.Height, Global.FontDefault, new Rectangle(0, 0, GameLoop.GameWidth, GameLoop.GameHeight), map.Tiles); SyncMapEntities(map); }
// 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.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 ScrollingConsole(width - _windowBorderThickness, height - _windowBorderThickness) { Position = new Point(1, 1) }; _messageConsole.ViewPort = new Rectangle(0, 0, width - 1, height - _windowBorderThickness); _messageConsole.DefaultBackground = Color.Black; // 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 Point(_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); }
private static void Init() { // Generate map CurrentMap = TestGameMap.CreateDungeonMap(100, 100); // Entity to test layering var testItem = new Entity(Color.White, Color.Transparent, 'i', (2, 2), 1, true, true); CurrentMap.AddEntity(testItem); Player = new Player(CurrentMap.WalkabilityView.RandomPosition(true)); CurrentMap.AddEntity(Player); MapConsole = new ScrollingConsole(width: CurrentMap.Width, height: CurrentMap.Height, font: SadConsole.Global.FontDefault, viewPort: new XnaRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT), initialCells: CurrentMap.RenderingCellData); MapConsole.CenterViewPortOnPoint(Player.Position); CurrentMap.ConfigureAsRenderer(MapConsole); // Set our new console as the main object SadConsole processes, and set up keyboard input SadConsole.Global.CurrentScreen = MapConsole; SadConsole.Global.FocusedConsoles.Push(Player); }
// This constructor creates a new inventory window and defines the inventory console inside this window public InventoryWindow(int width, int height, string title) : base(width, height) { // Ensure that the window background is the correct colour Theme.FillStyle.Background = DefaultBackground; // instantiete the inventory of the actor, passing the actor value if and when i implement helpers, to make it // possible to see and use their inventory. inventory = new List <Item>(); CanDrag = true; Title = title.Align(HorizontalAlignment.Center, width); // define the inventory console inventoryConsole = new ScrollingConsole(width, height) { Position = new Point(1, 1) }; inventoryConsole.ViewPort = new Rectangle(0, 0, width - 1, height - _windowBorderThickness); inventoryConsole.DefaultBackground = Color.Black; UseMouse = true; UseKeyboard = true; Children.Add(inventoryConsole); }
public (ScrollingConsole, Window) CreateMapWindow(Size windowSize, string title, ICompoundMap fullMap) { int viewWidth = windowSize.Width - 2; int viewHeight = windowSize.Height - 2; Window mapWindow = new Window(windowSize.Width, windowSize.Height, MapFont) { CanDrag = true, Title = title.Align(HorizontalAlignment.Center, viewWidth), }; log.DebugFormat("Created map window, [{0}].", mapWindow.AbsoluteArea); var mapConsole = new ScrollingConsole( fullMap.Width, fullMap.Height, MapFont, new MG.Rectangle(0, 0, viewWidth, viewHeight)); // Fit the MapConsole inside the MapWindow border mapConsole.Position = new Coord(1, 1); mapWindow.Children.Add(mapConsole); log.DebugFormat("Created map console, map size [{0},{1}], viewport size [{2}].", fullMap.Width, fullMap.Height, mapWindow.ViewPort); return(mapConsole, mapWindow); }
public DungeonScreen(SadConsole.Tiles.TileMap map) { // Setup map Map = map; MapConsole = new ScrollingConsole(map.Width, map.Height, SadConsole.Global.FontDefault, new Rectangle(0, 0, ScreenRegionMap.Width, ScreenRegionMap.Height), null); Map.ConfigureAsRenderer(MapConsole); MapConsole.Position = ScreenRegionMap.Location; //MapConsole.ViewPort = new Rectangle(0, 0, ScreenRegionMap.Width, ScreenRegionMap.Height); // Setup actions ActionProcessor = new SadConsole.Actions.ActionStack(); ActionProcessor.Push(new SadConsole.Actions.ActionDelegate(ActionKeyboardProcessor)); _frameManager = new GameFrameManager(map); _frameManager.LogicFrameCompleted += (s, e) => RedrawMap = true; // Setup messages Messages = new MessageConsole(ScreenRegionMessages.Width, ScreenRegionMessages.Height) { Position = ScreenRegionMessages.Location }; Children.Add(Messages); Children.Add(MapConsole); }
public MessageLogWindow(int width, int height, string title) : base(width, height) { _lines = new Queue <string>(); height -= _windowBorder; width -= _windowBorder; Title = title.Align(HorizontalAlignment.Center, Width); _console = new ScrollingConsole(width, _maxLines) { Position = new Point(1, 1), ViewPort = new Rectangle(0, 0, width - 1, height) }; _scrollBar = new ScrollBar(Orientation.Vertical, height) { Position = new Point(width + 1, _console.Position.Y), IsEnabled = false }; _scrollBar.ValueChanged += MessageScrollBar_ValueChanged; Add(_scrollBar); //Different Add() than the local void (see definition) Children.Add(_console); }
public void SetTargetSurface(Console surface) { SurfaceReference = null; SurfaceView = null; SurfaceReference = surface; SurfaceView = new ScrollingConsole(surface.Width, surface.Height, surface.Font, new Rectangle(0, 0, Width - 2 > surface.Width ? surface.Width : Width - 2, Height - 2 > surface.Height ? surface.Height : Height - 2), surface.Cells); SurfaceView.DefaultBackground = surface.DefaultBackground; if (SurfaceView.ViewPort.Width != SurfaceView.Width) { HorizontalBar.IsEnabled = true; HorizontalBar.Maximum = SurfaceView.Width - SurfaceView.ViewPort.Width; } else { HorizontalBar.IsEnabled = false; } if (SurfaceView.ViewPort.Height != SurfaceView.Height) { VerticalBar.IsEnabled = true; VerticalBar.Maximum = SurfaceView.Height - SurfaceView.ViewPort.Height; } else { VerticalBar.IsEnabled = false; } VerticalBar.Value = 0; HorizontalBar.Value = 0; IsDirty = true; }
protected virtual void InitDisplay() { Display = new ScrollingConsole(Game.Settings.GameWidth, Game.Settings.GameHeight); Display.IsVisible = true; Display.IsFocused = false; Children.Add(Display); }
// Loads a Map into the MapConsole private void LoadMap(Map map) { // First load the map's tiles into the console MapConsole = new SadConsole.ScrollingConsole(GameLoop.World.CurrentMap.Width, GameLoop.World.CurrentMap.Height, Global.FontDefault, new Rectangle(0, 0, GameLoop.GameWidth, GameLoop.GameHeight), map.Tiles); // Now Sync all of the map's entities SyncMapEntities(map); }
public GameScreen(int mapWidth, int mapHeight, int screenWidth, int screenHeight) { MapView = new ScrollingConsole(mapWidth, mapHeight, Global.FontDefault, new Rectangle(0, 0, screenWidth, screenHeight - 6)); InfoView = new ScrollingConsole(500, 100, new Rectangle(0, 0, screenWidth / 2, 5)); MessageView = new ScrollingConsole(500, 100, new Rectangle(0, 0, screenWidth / 2, 5)); }
private void LoadMap(Map map) { // First load the map's tiles into the console MapConsole = new SadConsole.ScrollingConsole(GameLoop.World.CurrentMap.Width, GameLoop.World.CurrentMap.Width, Global.FontDefault, new Microsoft.Xna.Framework.Rectangle(0, 0, GameLoop.GameWidth, GameLoop.GameHeight), GameLoop.World.CurrentMap.Tiles); MapConsole.DefaultBackground = Color.Black; // Now Sync all of the map's entities SyncMapEntities(map); }
public MessageWindow(int width, int height, string title) : base(width, height) { _lines = new Queue <string>(); Title = title.Align(HorizontalAlignment.Center, Width); _messageConsole = new ScrollingConsole(width, _maxLines); _messageConsole.Position = new Point(0, 0); _messageConsole.ViewPort = new Rectangle(0, 0, width, height); Children.Add(_messageConsole); Show(); }
public static void InitHUD(TileBase[] tiles) { SadConsole.Themes.Library.Default.Colors.ControlHostBack = Color.Black; SadConsole.Themes.Library.Default.Colors.ControlHostFore = Color.Black; var console = new SadConsole.Console(WindowWidth, WindowHeight); SadConsole.Global.CurrentScreen = console; SkillsConsole = new CustomConsole(Microsoft.Xna.Framework.Color.Blue, SkillsWidth, SkillsHeight) { Position = new Point(0, 0) }; MapConsole = new CustomConsole(Microsoft.Xna.Framework.Color.Black, MapWidth, MapHeight) { Position = new Point(0, 5) }; MapScrollConsole = new ScrollingConsole(MapWidth, MapHeight, Global.FontDefault); SidebarInventory = new CustomConsole(Microsoft.Xna.Framework.Color.Green, InventoryWidth, InventoryHeight) { Position = new Point(60, 0) }; SidebarPlayerProfile = new CustomConsole(Microsoft.Xna.Framework.Color.Red, ProfileWidth, ProfileHeight) { Position = new Point(60, 10) }; MessageConsole = new CustomConsole(Microsoft.Xna.Framework.Color.Black, MessageWidth, MessageHeight) { Position = new Point(0, 25) }; MessageLog = new MessageLogWindow(MessageWidth, MessageHeight, "Message Log"); console.Children.Add(SkillsConsole); console.Children.Add(MapConsole); console.Children.Add(SidebarInventory); console.Children.Add(SidebarPlayerProfile); console.Children.Add(MessageConsole); MapConsole.Children.Add(MapScrollConsole); MessageConsole.Children.Add(MessageLog); MessageConsole.Fill(Color.Black, Color.Black, 176); MessageLog.Fill(Color.Black, Color.Black, 176); MessageLog.Show(); MessageLog.Position = new Point(0, 0); MessageLog.Add("Welcome to the dungeon."); }
public MapScreen(int width, int height, int viewportWidth, int viewportHeight) { Map = GenerateDungeon(width, height); // Create a rendering console, and add it to this container console as a child MapRenderer = Map.CreateRenderer(new Rectangle(0, 0, viewportWidth, viewportHeight), Global.FontDefault); Children.Add(MapRenderer); // Apply focus to the controlled entity, so keyboard input is received Map.ControlledEntity.IsFocused = true; // Apply required events to the controlled entity Map.ControlledEntity.Moved += ControlledEntity_Moved; Map.ControlledEntityChanged += Map_ControlledEntityChanged; // Center viewport and calculate field of view ControlledEntity_Moved(null, null); }
//Generate a map and display it. Could just as easily pass it into public MapScreen(int mapWidth, int mapHeight, int viewportWidth, int viewportHeight) { Map = GenerateDungeon(mapWidth, mapHeight); // Get a console that's set up to render the map, and add it as a child of this container so it renders MapRenderer = Map.CreateRenderer(new XnaRect(0, 0, viewportWidth, viewportHeight), SadConsole.Global.FontDefault); Children.Add(MapRenderer); Map.ControlledGameObject.IsFocused = true; // Set player to receive input, since in this example the player handles movement // Set up to recalculate FOV and set camera position appropriately when the player moves. Also make sure we hook the new // Player if that object is reassigned. Map.ControlledGameObject.Moved += Player_Moved; Map.ControlledGameObjectChanged += ControlledGameObjectChanged; // Calculate initial FOV and center camera Map.CalculateFOV(Map.ControlledGameObject.Position, Map.ControlledGameObject.FOVRadius, Radius.SQUARE); MapRenderer.CenterViewPortOnPoint(Map.ControlledGameObject.Position); }
public void UpdateViewOfCoords(ScrollingConsole console, IEnumerable <Coord> coords) { // Show the BG color of the terrain, then whatever comes first: // The FG of any visible being at the location, or // the FG of the topmost item at the loc'n, or // the FG of the terrain type. // Then (later, 0.5?) modified by lighting, et c. foreach (var position in coords.Where(c => console.ViewPort.Contains(c))) { var targetCell = new Cell(); var rawCell = SpaceMap.GetItem(position).Terrain.Cell; targetCell.Background = rawCell.Background; var beings = BeingMap.GetItems(position).ToList(); var items = ItemMap.GetItems(position).ToList(); if (beings.Any()) { var being = beings.Last(); targetCell.Foreground = being.Foreground; targetCell.Glyph = being.Glyph; } else if (items.Any()) { var item = items.Last(); targetCell.Foreground = item.Foreground; targetCell.Glyph = item.Glyph; } else { targetCell.Foreground = rawCell.Foreground; targetCell.Glyph = rawCell.Glyph; } console.SetCellAppearance(position.X, position.Y, targetCell); var rot = RotMap.GetItem(position); Fade fade = null; if (rot?.Health > 0) { fade = GetFadeForRotExtent(rot.Health, rawCell.Background); } EffectsManager.SetEffect(console.Cells[position.Y * Width + position.X], fade); } }
public NotePadComponent(BasicEntity parent, Coord position) : base(true, true, false, true) { Parent = parent; Name = "Notepad"; InitWindow(); InitBackground(); InitNavigationButtons(); InitMaximizeButton(); Surface = new ScrollingConsole(Width - 2, Height - 2) { UseKeyboard = false, IsVisible = true, Position = new Coord(1, 1), DefaultBackground = Color.Transparent, DefaultForeground = Color.Blue }; Window.Children.Add(Surface); InitTextSurface(); Window.Position = position; }
public MapWindow(int width, int height, string title) : base(width, height) { _console = new ScrollingConsole(Program.World.CurrentMap.Width, Program.World.CurrentMap.Height, Global.FontDefault, new Rectangle(0, 0, Program.GAME_WIDTH, Program.GAME_HEIGHT), Program.World.CurrentMap.Tiles); int _consoleWidth = width; int _consoleHeight = height - 1; CanDrag = false; Title = title.Align(HorizontalAlignment.Center, _consoleWidth); _console.ViewPort = new Rectangle(0, 0, _consoleWidth, _consoleHeight); _console.Position = new Point(0, 1); Children.Add(_console); _console.Children.Add(Program.World.Player); CenterOnActor(Program.World.Player); Show(); }
/// <summary> /// Create's a rendering console for this grid to be rendered on. /// </summary> /// <param name="viewport"></param> /// <param name="font"></param> /// <returns></returns> public ScrollingConsole CreateRenderer(Rectangle viewport, Font font) { if (_cells.Any(a => a == null)) { throw new Exception("Please initialize the grid first."); } var renderer = new ScrollingConsole(Width, Height, font, viewport, _cells); _renderConsole = renderer; renderer.SetSurface(_cells, Width, Height); renderer.IsDirty = true; foreach (var entity in _entities) { renderer.Children.Add(entity); } return(renderer); }
public void UpdateFOV(ScrollingConsole console, Coord position) { FOV.Calculate(position); SpaceMap.SeeCoords(FOV.NewlySeen); // Cells outside of FOV are gray on black, // with only the glyph of the terrain showing. var unseenCell = new Cell(Color.DarkGray, Color.Black, ' '); foreach (var location in FOV.NewlyUnseen.Where(c => console.ViewPort.Contains(c))) { // Wiping the effect restores the original cell colors, // so it must happen before setting OOV appearance EffectsManager.SetEffect(console.Cells[location.Y * Width + location.X], null); unseenCell.Glyph = SpaceMap.GetItem(location).Terrain.Cell.Glyph; console.SetCellAppearance(location.X, location.Y, unseenCell); } UpdateViewOfCoords(console, FOV.NewlySeen); }
private void InitTextSurface() { _textSurface = new ScrollingConsole(Width - 2, Height - 2) { UsePrintProcessor = true, Position = new Coord(1, 1), DefaultBackground = Color.Transparent, DefaultForeground = Color.Blue, }; _textSurface.Cursor.UseStringParser = true; _textSurface.Cursor.Position = new Coord(0, 0); foreach (string detail in GetDetails()) { ColoredString text = new ColoredString(detail, Color.Blue, Color.Transparent); _textSurface.Cursor.Print(text); _textSurface.Cursor.NewLine(); } Window.Children.Add(_textSurface); }
private static void Init() { // Build the room's walls then carve out some floors CreateWalls(); CreateFloors(); Console startingConsole = new ScrollingConsole(Width, Height, Global.FontDefault, new Rectangle(0, 0, Width, Height), _tiles); // Set our new console as the thing to render and process SadConsole.Global.CurrentScreen = startingConsole; //startingConsole.Fill(new Rectangle(3, 3, 27, 5), null, Color.Black, 0, SpriteEffects.None); startingConsole.Print(6, 5, "Hello from SadConsole", ColorAnsi.CyanBright); // create an instance of player CreatePlayer(); // add the player Entity to our only console // so it will display on screen startingConsole.Children.Add(player); }
public void CreateWindows() { int height_1_4 = GameLoop.GameHeight * 1 / 4; int height_3_4 = GameLoop.GameHeight * 3 / 4; int width14 = GameLoop.GameWidth * 1 / 4; int width34 = GameLoop.GameWidth * 3 / 4; MapConsole = new ScrollingConsole(GameLoop.GameWidth, GameLoop.GameHeight); LoadMap(GameLoop.World.CurrentMap); CreateMapWindow(width34, height_3_4, "Map"); SideWindow = new SideWindow(width14, height_3_4, "Inventory / Anatomy") { Position = new Point(width34, 0), CanDrag = false, UseMouse = true, }; Children.Add(SideWindow); SideWindow.Show(); MessageLog = new MessageLogWindow(width34, height_1_4, "Log") { Position = new Point(0, height_3_4), CanDrag = false, UseMouse = true, }; Children.Add(MessageLog); MessageLog.Show(); StatusWindow = new StatusWindow(width14, height_1_4) { Position = new Point(width34, height_3_4), CanDrag = false, UseMouse = true, }; Children.Add(StatusWindow); StatusWindow.Show(); }
/// <summary> Set all cells to blank if unknown, or 'unseen' color of terrain if known. </summary> public void SetInitialConsoleCells(ScrollingConsole console, ISpaceMap spaceMap) { var unknownCell = new Cell(Color.Black, Color.Black, ' '); var knownCell = new Cell(Color.DarkGray, Color.Black, 'i'); for (int y = 0; y < spaceMap.Height; y++) { for (int x = 0; x < spaceMap.Width; x++) { var space = spaceMap.GetItem((x, y)); if (space.IsKnown) { knownCell.Glyph = space.Terrain.Cell.Glyph; console.SetCellAppearance(x, y, knownCell); } else { console.SetCellAppearance(x, y, unknownCell); } } } EffectsManager = new EffectsManager(console); }
// Creates all child consoles to be managed. public void CreateConsoles() { // Temporarily create a console with *no* tile data that will later be replaced with map data MapConsole = new ScrollingConsole(GameLoop.GameWidth, GameLoop.GameHeight); }
public void CreateMeSomeConsoles() { //MapConsole = new SadConsole.ScrollingConsole(MainLoop.World.CurrentMap.Width, MainLoop.World.CurrentMap.Height, Global.FontDefault, new Rectangle(0, 0, MainLoop.width, MainLoop.height), MainLoop.World.CurrentMap.Tiles); MapConsole = new SadConsole.ScrollingConsole(MainLoop.width, MainLoop.height); }
private void LoadMap(Map map) { MapConsole = new SadConsole.ScrollingConsole(MainLoop.World.CurrentMap.Width, MainLoop.World.CurrentMap.Height, Global.FontDefault, new Rectangle(0, 0, MainLoop.width, MainLoop.height), map.Tiles); SyncMapEntities(map); }
public void CreateConsoles() { MapConsole = new ScrollingConsole(GameLoop.GameWidth, GameLoop.GameHeight); }