public CustomAdventureStats(Mogwai mogwai, int width, int height) : base("Adventure Extension", "This is a temp. summary expect more here", width, height) { _pictureFont = Global.LoadFont("AutoReiv.font").GetFont(Font.FontSizes.Quarter); _statsFont = Global.LoadFont("AutoReiv.font").GetFont(Font.FontSizes.One); //var pictureFont = Global.FontDefault; _base = new Console(width, height) { Position = new Point(0, 0) }; Children.Add(_base); _statsConsole = new Console(width, height) { Position = new Point(2, 2), Font = _statsFont }; Children.Add(_statsConsole); _rewardConsole = new Console(27, 9) { Position = new Point(5, 26), Font = _statsFont }; Children.Add(_rewardConsole); _mogwai = mogwai; }
public static void WriteCenter(this Console cons, int y, string text, string fg = "default", string bg = "default") { var x = (cons.Width - text.Length) / 2; cons.Cursor.Position = new Point(x, y); cons.Cursor.Print(Decorate(text, fg, bg)); }
// Loads a Map into the MapConsole public void LoadMap(Map map) { //make console short enough to show the window title //and borders, and position it away from borders int mapConsoleWidth = Width - 2; int mapConsoleHeight = Height - 2; Rectangle rec = new BoundedRectangle((0, 0, mapConsoleWidth, mapConsoleHeight), (0, 0, map.Width, map.Height)).Area; // First load the map's tiles into the console MapConsole = new Console(GameLoop.World.CurrentMap.Width, GameLoop.World.CurrentMap.Height, GameLoop.World.CurrentMap.Width, GameLoop.World.CurrentMap.Width, map.Tiles) { View = rec, //reposition the MapConsole so it doesnt overlap with the left/top window edges Position = new Point(1, 1), DefaultBackground = Color.Black }; // Adds the console to the children list of the window Children.Add(MapConsole); // Now Sync all of the map's entities SyncMapEntities(map); IsDirty = true; }
public static void Draw(this Console console, ICell cell, Visibility visibility, bool showExits) { if (visibility == Visibility.Hidden) { console.Cursor.RightWrap(1); return; } Color foreground; int glyphId; if (cell.Type == Core.CellType.StairCaseUp) { foreground = Color.Gray; glyphId = 46; } else { foreground = cell.Color.ToSadColor(); glyphId = cell.GlyphId; } foreground = visibility == Visibility.InFov ? foreground : foreground.GetDarker(); console.Cursor.Position = new Point(cell.Location.X, cell.Location.Y).ToSadPoint(); Draw(console, foreground, glyphId); }
public override void ProcessKeyboard(SadConsole.Console consoleObject, SadConsole.Input.Keyboard info, out bool handled) { // Upcast this because we know we're only using it with a Console type. var console = (ScrollingConsole)consoleObject; if (info.IsKeyDown(Keys.Left)) { console.ViewPort = new Rectangle(console.ViewPort.Left - 1, console.ViewPort.Top, 80, 23); } if (info.IsKeyDown(Keys.Right)) { console.ViewPort = new Rectangle(console.ViewPort.Left + 1, console.ViewPort.Top, 80, 23); } if (info.IsKeyDown(Keys.Up)) { console.ViewPort = new Rectangle(console.ViewPort.Left, console.ViewPort.Top - 1, 80, 23); } if (info.IsKeyDown(Keys.Down)) { console.ViewPort = new Rectangle(console.ViewPort.Left, console.ViewPort.Top + 1, 80, 23); } handled = true; }
public StatsWindow(int width, int height, string title) : base(width, height) { _console = new Console(width, height, Global.FontDefault); int _consoleWidth = width - 1; CanDrag = false; Title = title.Align(HorizontalAlignment.Center, _consoleWidth); _console.Position = new Point(0, 1); Children.Add(_console); var healthBar = new StatBar("Health", .5f); healthBar.Position = new Point(2, 1); _console.Children.Add(healthBar); var waterBar = new StatBar("Water", .75f); waterBar.Position = new Point(2, 4); _console.Children.Add(waterBar); var foodBar = new StatBar("Food", .15f); foodBar.Position = new Point(2, 7); _console.Children.Add(foodBar); var exertionBar = new StatBar("Exertion", .25f); exertionBar.Position = new Point(2, 10); _console.Children.Add(exertionBar); Show(); }
public void Update(SadConsole.Console console, TimeSpan delta) { if (player.Health < 1) { menuConsole.SetMessage("You have died."); //startGame(); } mapConsole.map.GameObjects.RemoveAll(g => g is Missile m && !m.Moving); if (!actions.Any()) { return; } if (turnTimer == null || turnTimer.IsPaused) { turnTimer = new Timer(TimeSpan.FromSeconds(0.2)); turnTimer.TimerElapsed += (timer, e) => { var action = actions.First(); actions.Remove(action); action(); }; } turnTimer.Update(console, delta); }
private void ButtonSave_Click(object sender, EventArgs e) { loadedView.Children.Clear(); if (optionButtonSurface.IsSelected) { basicSurface.Save("basicsurface.surface"); loadedView.Children.Add(SadConsole.Console.Load("basicsurface.surface")); } else if (optionButtonView.IsSelected) { viewSurface.Save("viewsurface.view"); var loaded = Console.Load("viewsurface.view"); loaded.SetSurface(basicSurface, new Rectangle(5, 2, 34 - 10, 15 - 4)); basicSurface.IsDirty = true; viewSurface.IsDirty = true; loadedView.Children.Add(loaded); loaded.Fill(new Rectangle(1, 1, loaded.Width - 2, 3), Color.White, Color.DarkBlue, 0, SpriteEffects.None); loaded.Print(2, 2, "Loaded view"); //loadedView.Children.Add(SadConsole.Surfaces.Basic.Load("viewsurface.view", basicSurface); } else if (optionButtonLayered.IsSelected) { layeredSurface.Save("layeredObject.layered"); var layers = LayeredConsole.Load("layeredObject.layered"); loadedView.Children.Add(layers); } else if (optionButtonAnimated.IsSelected) { animatedSurface.Save("animatedsurface.animation"); var animation = AnimatedConsole.Load("animatedsurface.animation"); animation.Start(); loadedView.Children.Add(animation); } }
// 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, title) { lines = new Queue <string>(); // add the message console, reposition, enable the viewport, and add it to the window messageConsole = new SadConsole.Console(width - windowBorderThickness, maxLines) { Position = new Point(1, 1) }; messageConsole.View = 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.UI.Controls.ScrollBar(Orientation.Vertical, height - windowBorderThickness) { Position = new Point(messageConsole.Width + 1, messageConsole.Position.X), IsEnabled = false }; messageScrollBar.ValueChanged += MessageScrollBarValueChanged; Controls.Add(messageScrollBar); // enable mouse input UseMouse = true; // Add the child consoles to the window Children.Add(messageConsole); }
private static void Init() { // Any setup if (Settings.UnlimitedFPS) { SadConsole.Game.Instance.Components.Add(new SadConsole.Game.FPSCounterComponent(SadConsole.Game.Instance)); } // Setup our custom theme. Theme.SetupThemes(); SadConsole.Game.Instance.Window.Title = "DemoProject Core"; // By default SadConsole adds a blank ready-to-go console to the rendering system. // We don't want to use that for the sample project so we'll remove it. //Global.MouseState.ProcessMouseWhenOffScreen = true; MainConsole = new Container(); // We'll instead use our demo consoles that show various features of SadConsole. Global.CurrentScreen = MainConsole; // Initialize the windows _characterWindow = new Windows.CharacterViewer(); Console con = new Console(80, 25); con.Print(1, 1, "Hello, welcome to SadConsole", Color.Yellow); con.SetForeground(4, 1, Color.Brown); con.SetForeground(5, 1, Color.Brown); con.SetGlyph(6, 1, '!'); con.Cursor.Move(1, 20).Print("Printing with cursor"); }
public FovWindow(int width, int height) : base(width, height) { this.DrawBorders(width, height, "O", "|", "-", Color.Gray); Print(3, 0, "Objects", Color.Orange); _charObjects = new Dictionary <char, CharObj>(); _blueprintTiles = GetTilesFromConfig(); _blueprintTiles.Add('=', new BlueprintTile() { Name = Constants.DoorOpen, Glyph = '=', Foreground = "White", BlocksFov = false }); _maxLineRows = Height - 2; _textConsole = new Console(Width - 2, Height - 2) { Position = new Point(2, 1), }; Position = new Point(Constants.Map.Width + 7, 3 + 25); Children.Add(_textConsole); Global.CurrentScreen.Children.Add(this); }
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); }
public Map(int sx, int sy) { SizeX = sx; SizeY = sy; TerrainInfoArray = new TerrainInfo[sx, sy]; MapConsole = new Console(sx, sy); }
public SubConsoleCursor() { mainView = new Console(80, 23); subView = new Console(new SurfaceView(mainView.TextSurface, new Rectangle(4, 4, 25, 10))); UseKeyboard = true; // Setup main view mainView.FillWithRandomGarbage(); mainView.MouseMove += (s, e) => { if (e.MouseState.Mouse.LeftButtonDown) { e.MouseState.Cell.Background = Color.Blue; } }; // Setup sub view subView.Position = new Point(4, 4); subView.MouseMove += (s, e) => { if (e.MouseState.Mouse.LeftButtonDown) { e.MouseState.Cell.Background = Color.Red; } }; subView.Clear(); subView.VirtualCursor.IsVisible = true; // Ad the consoles to the list. Children.Add(mainView); Children.Add(subView); }
public StatusWindow(int width, int heigth, string title) : base(width, heigth, title) { player = GameLoop.World.Player; statsConsole = new Console(width - windowBorderThickness, heigth - windowBorderThickness) { Position = new Point(1, 1), View = new Rectangle(0, 0, width - 1, heigth - windowBorderThickness), DefaultBackground = Color.Black }; statusScroll = new ScrollBar (Orientation.Vertical, heigth - windowBorderThickness) { Position = new Point(statsConsole.Width + 1, statsConsole.Position.X) //IsEnabled = false }; statusScroll.ValueChanged += StatusScroll_ValueChanged;; Controls.Add(statusScroll); // enable mouse input UseMouse = true; Children.Add(statsConsole); }
public void Draw(Console console, IMap map) { if (!map.GetCell(X, Y).IsExplored) { return; } Symbol = IsOpen ? '-' : '+'; if (map.IsInFov(X, Y)) { Color = Colors.DoorFov; BackgroundColor = Colors.DoorBackgroundFov; } else { Color = Colors.Door; BackgroundColor = Colors.DoorBackground; } //console.CellData.SetCharacter(X, Y, Symbol, Color, BackgroundColor); int tilePos = Y * GameLoop.World.CurrentMap.Width + X; GameLoop.World.CurrentMap.Tiles[tilePos].Glyph = Symbol; GameLoop.World.CurrentMap.Tiles[tilePos].Background = BackgroundColor; GameLoop.World.CurrentMap.Tiles[tilePos].Foreground = Color; }
public void Print(Console console, int x, int y, string str, int length, Color foreColor, Color backColor) { str = str + ' '; int endIndex = str.LastIndexOf(' '); string nextLine = str.Substring(0, endIndex + 1); while (true) { if (nextLine.Length > length + 1) { if (nextLine.Contains(" ")) { endIndex = nextLine.Substring(0, endIndex).LastIndexOf(' '); } nextLine = str.Substring(0, endIndex + 1); } else { console.Print(x, y, nextLine, foreColor, backColor); y++; str = str.Substring(endIndex + 1, str.Length - nextLine.Length); endIndex = str.LastIndexOf(' '); nextLine = str.Substring(0, endIndex + 1); if (str == "") { return; } } } }
private static void Init() { Game.Instance.Window.Title = Constants.WindowTitle; LoadWindowPosition(); Game.Instance.Window.ClientSizeChanged += (sender, e) => { SaveWindowPosition(); }; LoadContent(); _data.DefaultConsole = new Console(Constants.ScreenWidth, Constants.ScreenHeight); _data.DefaultConsole.DefaultForeground = Color.White; _data.DefaultConsole.DefaultBackground = Color.Transparent; _data.DefaultConsole.IsCursorDisabled = true; _data.DefaultConsole.MouseMove += Console_MouseMove; _panel = new Console(Constants.ScreenWidth, Constants.PanelHeight) { Position = new Point(0, Constants.PanelY) }; _data.DefaultConsole.Children.Add(_panel); _data.MenuManager = new MenuManager(); Global.CurrentScreen = _data.DefaultConsole; Global.FocusedConsoles.Set(_data.DefaultConsole); _data.FovRecompute = true; _data.ShowMainMenu = true; _data.ShowLoadErrorMessage = false; }
private static void Init() { currentState = new MainMenu(); console = new Console(window.Width, window.Height); msgConsole = new MsgConsole(0, new TimeSpan(0, 0, 5)); GUI.Console = new SadConsole.Console(Program.Window.Width, Program.Window.Height); queuedAnimations = new List <Animation>(); animations = new List <Animation>(); finishedAnims = new List <Animation>(); rng = new Random(); audioEngine = new AudioPlaybackEngine(); musicHandler = new MusicHandler(); // play main menu theme Program.AudioEngine.PlayMusic("Main_Menu"); // initialize the color schemes and material properties Physics.InitializePhysics(); Themes.InitializeThemes(); SadConsole.Global.CurrentScreen = console; ((SadConsole.Game)SadConsole.Game.Instance).WindowResized += window.ClientSizeChanged; }
public void OnAdded(Console console) { _borderConsole = new Console(console.Width + 2, console.Height + 2, console.Font); _borderConsole.DrawBox(new Rectangle(0, 0, _borderConsole.Width, _borderConsole.Height), _borderCellStyle, null, _borderGlyphs); _borderConsole.Position = new Point(-1, -1); console.Children.Add(_borderConsole); }
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; }
public override void Update(SadConsole.Console console, TimeSpan delta) { var m = ctx.CurMap; foreach (var nPos in m.FOV.NewlyUnseen) { foreach (var vChild in m.GetEntities <DrawableObject>(nPos)) { vChild.DrawEntity.IsVisible = false; } if (m.Explored[nPos]) { var eBG = (m.Terrain[nPos] as Terrain).Name == "Wall" ? Swatch.ExploredWall : Swatch.ExploredFloor; console.SetCellAppearance(nPos.X, nPos.Y, new Cell(Color.Transparent, eBG)); } else { console[nPos.X, nPos.Y].IsVisible = false; } } foreach (var sPos in m.FOV.NewlySeen) { console[sPos.X, sPos.Y].IsVisible = true; console.SetCellAppearance(sPos.X, sPos.Y, (m.Terrain[sPos] as Terrain).DrawCell); foreach (var obj in m.GetEntities <DrawableObject>(sPos)) { obj.DrawEntity.IsVisible = true; } } //console.Update(delta); }
public CustomAdventure(MogwaiController mogwaiController, MogwaiKeys mogwaiKeys, int width, int height) : base("Adventure", "", width, height) { _controller = mogwaiController; _mogwaiKeys = mogwaiKeys; _mogwai = _mogwaiKeys.Mogwai; _adventureFont = Global.LoadFont("Phoebus16.font").GetFont(Font.FontSizes.One); //_mapConsole = new Console(75, 75) { Position = new Point(17, 2) }; _mapConsole = new Console(100, 100) { Position = new Point(-24, 0), Font = _adventureFont, IsVisible = false }; Children.Add(_mapConsole); _entityManager = new SadConsole.Entities.EntityManager { Parent = _mapConsole }; _statsConsole = new MogwaiConsole("stats", "", 21, 6) { Position = new Point(70, 16) }; _statsConsole.Fill(DefaultForeground, new Color(10, 10, 10, 230), null); Children.Add(_statsConsole); }
private static void Init() { // Any custom loading and prep. We will use a sample console for now Console startingConsole = new Console(Width, Height); FontMaster fontMaster = SadConsole.Global.LoadFont("cp437.font"); startingConsole.TextSurface.Font = fontMaster.GetFont(SadConsole.Font.FontSizes.One); SadRex.Image tempImage = SadRex.Image.Load(TitleContainer.OpenStream("temp.xp")); //tempImage.Layers[0].Cells[0].Background and Character SadRex.Layer imageLayer = tempImage.Layers[0]; for (int yPos = 0; yPos < tempImage.Height; yPos++) { for (int xPos = 0; xPos < tempImage.Width; xPos++) { //2-D to 1-D coordinate: (yPos*Width) + xPos SadRex.Cell currentCell = imageLayer.Cells[(yPos * Width) + xPos]; startingConsole.SetGlyph(xPos, yPos, currentCell.Character, new Color( currentCell.Foreground.R, currentCell.Foreground.G, currentCell.Foreground.B), new Color(currentCell.Background.R, currentCell.Background.G, currentCell.Background.B)); } } /* * startingConsole.FillWithRandomGarbage(); * startingConsole.Fill(new Rectangle(3, 3, 27, 5), null, Color.Black, 0); * startingConsole.Print(6, 5, "Hello from SadConsole", ColorAnsi.CyanBright);//*/ // Set our new console as the thing to render and process SadConsole.Global.CurrentScreen = startingConsole; }
void DrawOutline(Console console, Color color) { var rect = new Rectangle(0, 0, console.Width, console.Height); var cell = new Cell(Color.White, color, 0); console.DrawBox(rect, cell); }
public ViewsAndSubViews() : base(1, 1) { mainView = new Console(60, 23); subView = Console.FromSurface(mainView.GetViewSurface(new Rectangle(0, 0, 20, 23))); IsVisible = false; UseMouse = true; mainView.DrawLine(new Point(59, 0), new Point(59, 22), Color.White, glyph: ConnectedLineThin[(int)ConnectedLineIndex.Left]); // Setup main view mainView.Position = new Point(0, 2); mainView.MouseMove += (s, e) => { if (e.MouseState.Mouse.LeftButtonDown) { e.MouseState.Cell.Background = Color.Blue; mainView.IsDirty = true; } }; mainView.DirtyChanged += (s, e) => subView.IsDirty = true; // Setup sub view subView.Position = new Point(60, 2); //subView.SetViewFromSurface(new Rectangle(0, 0, 20, 23), mainView); subView.MouseMove += (s, e) => { if (e.MouseState.Mouse.LeftButtonDown) { e.MouseState.Cell.Background = Color.Red; subView.IsDirty = true; } }; subView.DirtyChanged += (s, e) => mainView.IsDirty = true; // Ad the consoles to the list. Children.Add(mainView); Children.Add(subView); }
private static void Init() { RogueFrontier.System w = new RogueFrontier.System(); w.types.LoadFile("RogueFrontierContent/scripts/Main.xml"); Directory.CreateDirectory("GraphicsContent"); var str = "ARCHCANNON"; var s = new Console(str.Length, 1); //var s = new WorldDraw(2000, 2000, w); s.Print(0, 0, str, Color.White, Color.Black); int x = 0; foreach (var c in str) { s.Print(x, 0, c.ToString(), Color.FromHSL((1f * x) / str.Length, 1, 0.7f), Color.Black); x++; } s.Render(new TimeSpan()); var t = ((ScreenSurfaceRenderer)s.Renderer)._backingTexture; t.Save("GraphicsContent/Archcannon.png"); Environment.Exit(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) { // Ensure that the window background is the correct color Theme.FillStyle.Background = DefaultBackground; _lines = new Queue <string>(); Dragable = true; Title = title.Align(HorizontalAlignment.Center, Width); // Add the message console, reposition, and add it to the window _messageConsole = new SadConsole.Console(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 = 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 input UseMouse = true; // add all child consoles to the window Children.Add(_messageConsole); }
private static void Init() { // Any setup if (Settings.UnlimitedFPS) { SadConsole.Game.Instance.Components.Add(new SadConsole.Game.FPSCounterComponent(SadConsole.Game.Instance)); } // Setup our custom theme. Theme.SetupThemes(); SadConsole.Game.Instance.Window.Title = "DemoProject OpenGL"; // By default SadConsole adds a blank ready-to-go console to the rendering system. // We don't want to use that for the sample project so we'll remove it. //Global.MouseState.ProcessMouseWhenOffScreen = true; Console ctx = new Console(10, 10); MainConsole = new Container(); // We'll instead use our demo consoles that show various features of SadConsole. Global.CurrentScreen = MainConsole; // Initialize the windows _characterWindow = new Windows.CharacterViewer(); }
static void Init() { //set up seed uint seed = TMath.Seed(); //overide //seed = 809171303; System.Console.WriteLine(seed.ToString()); var gen = new XorShift128Generator(seed); for (int i = 0; i < 3; i++) // Becuase of bug in RNG, make sure we are completely pseudo-random { gen.Next(); } GoRogue.Random.SingletonRandom.DefaultRNG = gen; MapGen generator = new MapGen(BuildBlob9()); ArrayMap <Cell> map = generator.GenerateMap(9); var console = new Console(map.Width, map.Height, map); SadConsole.Global.CurrentScreen = console; }