private void MakeBasicSurface() { basicSurface.Print(0, 0, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890".Repeat(9)); basicSurface.SetGlyph(0, 0, 7); basicSurface.SetGlyph(1, 0, 8); basicSurface.SetGlyph(2, 0, 9); basicSurface.SetGlyph(3, 0, 10); ColorGradient gradient = new ColorGradient(SadConsole.UI.Themes.Library.Default.Colors.Blue, SadConsole.UI.Themes.Library.Default.Colors.Yellow); for (int i = 0; i < 510; i += 10) { Point point = Point.FromIndex(i, basicSurface.Width); basicSurface.Print(point.X, point.Y, gradient.ToColoredString(basicSurface.GetString(i, 10))); } // Mirror 1 int startSet1 = new Point(0, 3).ToIndex(34); int startSet2 = new Point(0, 6).ToIndex(34); int startSet3 = new Point(0, 9).ToIndex(34); for (int i = 0; i < 34 * 3; i++) { basicSurface[startSet1 + i].Mirror = Mirror.Vertical; basicSurface[startSet1 + i].Background = SadConsole.UI.Themes.Library.Default.Colors.PurpleDark; basicSurface[startSet2 + i].Mirror = Mirror.Horizontal; basicSurface[startSet2 + i].Background = SadConsole.UI.Themes.Library.Default.Colors.OrangeDark; basicSurface[startSet3 + i].Mirror = Mirror.Horizontal | Mirror.Vertical; basicSurface[startSet3 + i].Background = SadConsole.UI.Themes.Library.Default.Colors.GreenDark; } }
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); }
// Probably needs to create a way to make it update only when needed, by an event. public override void Update(TimeSpan time) { statsConsole.Print(0, 0, $"{player.Name}"); statsConsole.Print(0, 2, $"Health: {(int)player.Stats.Health} / {player.Stats.MaxHealth} ", Color.Red); statsConsole.Print(0, 3, $"Mana: {(int)player.Stats.PersonalMana} / {player.Stats.MaxPersonalMana}", Color.LightBlue); base.Update(time); }
public static void PrintCentre(this Console 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); } }
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(); }
public void Print(SadConsole.Console console) { int _y = YOffset; foreach (var str in _printable) { str.ButtonIndex.Draw(IndexOffset, _y, console); console.Print(NameOffset, _y, str.Name); console.Print(TypeOffset, _y, str.Type); //console.Print(DATA_OFFSET, _y, str.Data); //console.Print(ID_OFFSET, _y, str.Id); _y++; } }
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 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; } } } }
public ScoreScreen() { ScoreConsole = new Console(Program.Width, Program.Height); ScoreConsole.Parent = this; ScoreConsole.Print(1, 1, "Your Combined Score:"); Global.CurrentScreen = ScoreConsole; this.Position = new Point(0, 0); DrawScoreGrid(); //ScoreTimer = new Timer(TimeSpan.FromSeconds(10.0)); //ScoreTimer.Repeat = true; //ScoreTimer.TimerElapsed += (timer, e) => //{ // if (progress < Program.Player.SunkShips.Count()) // { // AddScore(Program.Player.SunkShips[progress]); // } // progress++; //}; //ScoreConsole.Components.Add(ScoreTimer); ScoreProcessing(); }
public override void Draw(int x, int y, SadConsole.Console console) { var str = new SadConsole.ColoredString(""); str += KeyString + " " + Name; str.SetBackground(console.DefaultBackground); console.Print(x, y, str); }
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 void ShowItems(Actor actorInventory) { int indexInventoryY = 0; foreach (Item item in actorInventory.Inventory) { inventoryConsole.Print(0, indexInventoryY, item.Name); indexInventoryY++; } }
static void Init() { var console = new Console(80, 25); console.FillWithRandomGarbage(); console.Fill(new Rectangle(3, 3, 23, 3), Color.Violet, Color.Black, 0, 0); console.Print(4, 4, "Hello from SadConsole"); SadConsole.Global.CurrentScreen = console; }
static void LogMessage(string message, byte level, int i) { int y = window_height - i - 1; // messages push up switch (level) { case 1: console.Print(0, y, "[warn] ", Color.Yellow, Color.Black); break; case 2: console.Print(0, y, "[err] ", Color.Red, Color.Black); break; default: console.Print(0, y, "[info] ", Color.Cyan, Color.Black); break; } console.Print(7, y, message, Color.Silver, Color.Black); }
public RandomScrollingConsole() : base(80, 23) { messageData = new Console(80, 1); messageData.Print(0, 0, "Generating random console data, please wait..."); mainData = new Console(1, 1); IsVisible = false; mainData.IsVisible = false; Children.Add(mainData); Children.Add(messageData); }
private void RefreshBackingPanel() { topBarPane.Clear(); var text = new SadConsole.ColoredString(" X: ", Settings.Appearance_Text) + new SadConsole.ColoredString(topBarMousePosition.X.ToString(), Settings.Appearance_TextValue) + new SadConsole.ColoredString(" Y: ", Settings.Appearance_Text) + new SadConsole.ColoredString(topBarMousePosition.Y.ToString(), Settings.Appearance_TextValue) + new SadConsole.ColoredString(" Layer: ", Settings.Appearance_Text) + new SadConsole.ColoredString(topBarLayerName, Settings.Appearance_TextValue) + new SadConsole.ColoredString(" Tool: ", Settings.Appearance_Text) + new SadConsole.ColoredString(topBarToolName, Settings.Appearance_TextValue); topBarPane.Print(0, 0, text); }
private static void Init() { // Any custom loading and prep. We will use a sample console for now Console startingConsole = new Console(Width, Height); startingConsole.Print(40, 12, "Hello SadConsole"); // Set our new console as the thing to render and process SadConsole.Global.CurrentScreen = startingConsole; }
private static void Init() { // Any custom loading and prep. We will use a sample console for now SadConsole.Console startingConsole = new Console(80, 25); 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; }
private static void Init() { // Any startup code for your game. We will use an example console for now Console startingConsole = new Console(Width, Height); startingConsole.FillWithRandomGarbage(); startingConsole.Fill(new Rectangle(3, 3, 27, 5), null, Color.Black, 0, SpriteEffects.None); startingConsole.Print(6, 5, "Hello from SadConsole", ColorAnsi.CyanBright); // Set our new console as the main object SadConsole processes SadConsole.Global.CurrentScreen = startingConsole; }
private void SetMessage(string text) { messageData.TextSurface = new BasicSurface(text.Length, 1) { DefaultBackground = new Color(0, 0, 0, 128) }; messageData.Clear(); messageData.Print(0, 0, text); // Center the message console messageData.Position = new Point(40 - text.Length / 2, 0); }
public static void Border(this Console cons, string caption = null) { cons.DrawBox( new Rectangle(0, 0, cons.Width, cons.Height), new Cell(cons.DefaultForeground, cons.DefaultBackground), connectedLineStyle: CellSurface.ConnectedLineThick); if (caption != null) { var cx = (cons.Width - caption.Length) / 2; cons.Print(cx, 0, caption); } }
public void Refresh() { for (int i = 0; i < SizeX; i++) { for (int j = 0; j < SizeY; j++) { if (TerrainInfoArray[i, j].Obstacle) { MapConsole.Print(i, j, "#", Color.White, Color.Black); } } } }
public override void Update(TimeSpan delta) { if (IsVisible) { var specColor = new Color((40 * _controller.QueueSize) % 256, (255 - (_controller.QueueSize * 10)) % 256, (25 * _controller.QueueSize) % 256); _debugConsole.Print(16, 1, "ALPHA", specColor); var deposit = _controller.GetDepositFunds(); var depositStr = deposit < 10000 ? deposit.ToString("###0.0000").PadLeft(9) : "TYCOON".PadRight(9); var lastBlock = _controller.WalletLastBlock; if (lastBlock != null) { Print(1, 0, _controller.WalletLastBlock.Height.ToString("#######0").PadLeft(8), Color.DeepSkyBlue); Print(10, 0, "Block", Color.White); var localTime = DateUtil.GetBlockLocalDateTime(_controller.WalletLastBlock.Time); var localtimeStr = localTime.ToString(CultureInfo.InvariantCulture); var t = DateTime.Now.Subtract(localTime); var timeStr = $"[c:r f:springgreen]{t:hh\\:mm\\:ss}[c:u]"; Print(16, 0, localtimeStr + " " + timeStr, Color.Gainsboro); } Print(62, 0, "+" + _transferFunds, Color.LimeGreen); Print(45, 0, "Funds:", Color.DarkCyan); Print(52, 0, depositStr, Color.Orange); if (WindowOffset > _controller.CurrentMogwaiKeysIndex) { WindowOffset = _controller.CurrentMogwaiKeysIndex; } else if (MaxRows < _controller.CurrentMogwaiKeysIndex + 1) { WindowOffset = _controller.CurrentMogwaiKeysIndex + 1 - MaxRows; } // only updated if we have keys if (_controller.HasMogwaiKeys) { var list = _controller.MogwaiKeysList; for (var i = WindowOffset; i < list.Count && i - WindowOffset < MaxRows; i++) { var mogwaiKeys = list[i]; var pos = i - WindowOffset; PrintRow(pos + HeaderPosition + 1, mogwaiKeys, mogwaiKeys.Address == _controller.CurrentMogwaiKeys.Address, _controller.TaggedMogwaiKeys.Contains(mogwaiKeys)); } //PrintRow(pointer + headerPosition + 1, list[pointer], true); } } base.Update(delta); }
/// <summary> /// Vamos mostrar uma mensagem no centro de uma nova consola vazia /// </summary> /// <param name="msg">A mensagem que queremos mostrar</param> private static void MensagemFim(string msg) { // Vamos marcar o jogo como tendo sido concluído GameComplete = true; // Preparar e mostrar a mensagem de fim var fontMaster = Global.LoadFont("font/SomethingBoxy.font"); var fontVezes2 = fontMaster.GetFont(Font.FontSizes.Two); var fontVezes1 = fontMaster.GetFont(Font.FontSizes.One); var MsgFimConsole = new Console(16, 5); MsgFimConsole.Position = new Point(2, 2); for (int i = 0; i < MsgFimConsole.Width; i++) { MsgFimConsole.Print(i, 0, "-"); } for (int i = 0; i < MsgFimConsole.Width; i++) { MsgFimConsole.Print(i, 3, "-"); } MsgFimConsole.Font = fontVezes2; MsgFimConsole.Cursor.Move(new Point(0, 1)).Print(msg); // Vamos questionar os jogadores se querem jogar outra vez var MsgFimConsole2 = new Console(32, 2); MsgFimConsole2.Font = fontVezes1; MsgFimConsole2.Position = new Point(4, 10); MsgFimConsole2.Print(0, 1, "Jogar novamente? Y/N"); MsgFimConsole.Children.Add(MsgFimConsole2); // Definir este ecrã que acabamos de criar como ativo. Global.CurrentScreen = MsgFimConsole; }
public BorderedConsole() : base(80, 25) { IsVisible = false; Print(1, 1, "Example of using a component to draw a border around consoles"); var console = new Console(12, 4); console.Print(1, 1, "Glyph line"); console.Components.Add(new BorderComponent(176, Color.Red, Color.Black)); console.Position = new Point(2, 5); Children.Add(console); console = new Console(12, 4); console.Print(1, 1, "Glyph line"); console.Components.Add(new BorderComponent(177, Color.Red, Color.Black)); console.Position = new Point(17, 5); Children.Add(console); console = new Console(12, 4); console.Print(1, 1, "Glyph line"); console.Components.Add(new BorderComponent(178, Color.Red, Color.Black)); console.Position = new Point(32, 5); Children.Add(console); console = new Console(12, 4); console.Print(1, 1, "Glyph line"); console.Components.Add(new BorderComponent(219, Color.Red, Color.Black)); console.Position = new Point(47, 5); Children.Add(console); console = new Console(12, 4); console.Print(1, 1, "Thin line"); console.Components.Add(new BorderComponent(ConnectedLineThin, Color.Green, Color.Black)); console.Position = new Point(17, 12); Children.Add(console); console = new Console(12, 4); console.Print(1, 1, "Thick line"); console.Components.Add(new BorderComponent(ConnectedLineThick, Color.Orange, Color.Black)); console.Position = new Point(2, 12); Children.Add(console); console = new Console(12, 4); console.Print(1, 1, "Extd. line"); console.Components.Add(new BorderComponent(console.Font.Master.IsSadExtended ? ConnectedLineThinExtended : ConnectedLineThin, Color.Purple, Color.Black)); console.Position = new Point(32, 12); Children.Add(console); }
private void ProcessTurn(GameTime time) { GameTime++; //MovementSystem.ProcessTurn(Entities); // Print game time and FPS String elapsedTime = $"Time: {GameTime}"; //String fps = $"FPS: {Math.Round(1f / time.ElapsedGameTime.TotalSeconds)}"; MainConsole.Clear(new Rectangle(1, 1, elapsedTime.Length, 1)); //MainConsole.Clear(new Rectangle(1, 2, fps.Length, 1)); MainConsole.Print(1, 1, elapsedTime); //MainConsole.Print(1, 2, fps); }
private static void Init() { // Load the fonts _kenneyFont = Global.LoadFont("Fonts/Kenney/Kenney.font"); _kenneyFontCharacters = Global.LoadFont("Fonts/Kenney/KenneyCharacters.font"); _cheepicusFont = Global.LoadFont("Fonts/DwarfFortress/Cheepicus.font"); _console = new Console(Width, Height, _kenneyFont.GetFont(Font.FontSizes.One)); _uiConsole = new Console(Width, Height, _cheepicusFont.GetFont(Font.FontSizes.One)); _uiConsole.Parent = _console; // Any startup code for your game. We will use an example console for now _uiConsole.FillWithRandomGarbage(); _uiConsole.Fill(new Rectangle(3, 3, 27, 5), null, Color.Black, 0, SpriteEffects.None); _uiConsole.Print(6, 5, "Hello from SadConsole", ColorAnsi.CyanBright); Global.CurrentScreen = _console; }
private static void Init() { Map = new Console(Constants.Map.Width, Constants.Map.Height); GridManager.InitializeBlueprint <HouseBlueprint>(); Grid.RenderObject(Map); SadConsole.Game.Instance.Window.Title = Constants.GameTitle; var mainConsole = new Console(Constants.GameWindowWidth, Constants.GameWindowHeight); mainConsole.Children.Add(Map); mainConsole.Print(Constants.GameWindowWidth / 2 - Constants.GameTitle.Length / 2, 2, Constants.GameTitle); Map.Position = new Point(25, 5); // Instantiate player in the middle of the map Player = EntityManager.Create <Player>(new Point(Constants.Map.Width / 2, Constants.Map.Height / 2)); Player.RenderObject(Map); Global.CurrentScreen = mainConsole; }
public int Print(Console console, int x, int y, string str, int length, Color foreColor, Color backColor) { str = str + ' '; int lines = 1; 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 { if (y >= Program.Window.Height) { return(lines); } console.Print(x, y, nextLine, foreColor, backColor); y++; lines++; str = str.Substring(endIndex + 1, str.Length - nextLine.Length); endIndex = str.LastIndexOf(' '); nextLine = str.Substring(0, endIndex + 1); if (str == "") { return(lines); } } } }
public void Start(Adventure adventure) { _mapConsole.ViewPort = new Microsoft.Xna.Framework.Rectangle(0, 0, _mapViewWidth, _mapViewHeight); _mapConsole.Children.Clear(); _entities.Clear(); Adventure = adventure; DrawExploMap(); _statsConsole.Print(7, 0, "Rounds", Color.MonoGameOrange); _statsConsole.Print(7, 1, "Exploration", Color.Gainsboro); _statsConsole.Print(7, 2, "Monster", Color.Gainsboro); _statsConsole.Print(7, 3, "Boss", Color.Gainsboro); _statsConsole.Print(7, 4, "Treasure", Color.Gainsboro); _statsConsole.Print(7, 5, "Portal", Color.Gainsboro); // Draw entities (Mogwais, Monsters, etc.) foreach (AdventureEntity entity in Adventure.Map.Entities) { // TODO this has to be analyzed !!! if (entity == null) { continue; } if (!entity.IsStatic) { DrawEntity(entity); } } _mapConsole.IsVisible = true; LastUpdate = DateTime.Now; }