/// <summary> /// Prepares the engine for use. This must be the first method you call on the engine when you provide your own <see cref="GraphicsDeviceManager"/>. /// </summary> /// <param name="deviceManager">The graphics device manager from MonoGame.</param> /// <param name="font">The font to load as the <see cref="DefaultFont"/>.</param> /// <param name="consoleWidth">The width of the default root console (and game window).</param> /// <param name="consoleHeight">The height of the default root console (and game window).</param> /// <returns>The default active console.</returns> public static Consoles.Console Initialize(GraphicsDeviceManager deviceManager, string font, int consoleWidth, int consoleHeight) { if (Device == null) { Device = deviceManager.GraphicsDevice; } SetupFontAndEffects(font); DeviceManager = deviceManager; DefaultFont.ResizeGraphicsDeviceManager(deviceManager, consoleWidth, consoleHeight, 0, 0); // Create the default console. ActiveConsole = new Consoles.Console(consoleWidth, consoleHeight); ActiveConsole.TextSurface.DefaultBackground = Color.Black; ActiveConsole.TextSurface.DefaultForeground = ColorAnsi.White; ((Consoles.Console)ActiveConsole).Clear(); ConsoleRenderStack.Add(ActiveConsole); renderBatch = new SpriteBatch(Device); ResetRendering(); return((Consoles.Console)ActiveConsole); }
public TextTool() { settingsPanel = new RecolorToolPanel(); ControlPanels = new CustomPanel[] { settingsPanel, CharacterPickPanel.SharedInstance }; tempConsole = new Console(1, 1); }
public SubConsoleCursor() { mainView = new Console(80, 25); subView = new Console(25, 10); IsVisible = false; // Setup main view mainView.FillWithRandomGarbage(); mainView.MouseMove += (s, e) => { if (e.LeftButtonDown) { e.Cell.Background = Color.Blue; } }; // Setup sub view subView.Position = new Point(4, 4); subView.TextSurface = new TextSurfaceView(mainView.TextSurface, new Rectangle(4, 4, 25, 10)); subView.MouseMove += (s, e) => { if (e.LeftButtonDown) { e.Cell.Background = Color.Red; } }; subView.Clear(); // Ad the consoles to the list. Add(mainView); //Add(subView); }
public ViewsAndSubViews() { titleAndLine = new Console(80, 25); mainView = new Console(59, 24); subView = new Console(19, 24); IsVisible = false; // Draw border and line stuff titleAndLine.Print(0, 0, " View and Sub View".Align(System.Windows.HorizontalAlignment.Left, 80), ColorHelper.GreenYellow, ColorHelper.DarkGreen); SadConsole.Shapes.Line line = new SadConsole.Shapes.Line(); line.UseStartingCell = false; line.UseEndingCell = false; line.CellAppearance.GlyphIndex = 179; line.StartingLocation = new Point(59, 1); line.EndingLocation = new Point(59, 24); line.Draw(titleAndLine); // Setup main view mainView.Position = new Point(0, 1); mainView.Print(1, 1, "Click on a cell to draw"); mainView.MouseMove += (s, e) => { if (e.LeftButtonDown) e.Cell.Background = Color.Blue; }; // Setup sub view subView.Position = new Point(60, 1); subView.TextSurface = new TextSurfaceView(mainView.TextSurface, new Rectangle(0, 0, 20, 24)); subView.MouseMove += (s, e) => { if (e.LeftButtonDown) e.Cell.Background = Color.Red; }; // Ad the consoles to the list. Add(titleAndLine); Add(mainView); Add(subView); }
protected override void Initialize() { // Let the XNA framework show the mouse. IsMouseVisible = true; IsFixedTimeStep = true; // Uncomment these two lines to run as fast as possible //_graphics.SynchronizeWithVerticalRetrace = false; //IsFixedTimeStep = false; // Initialize the SadConsole engine and the first effects library (provided by the SadConsole.Effects.dll binary) SadConsole.Engine.Initialize(GraphicsDevice); // Tell SadConsole to track the mouse. SadConsole.Engine.UseMouse = true; // Load the default font. using (var stream = System.IO.File.OpenRead("Fonts/IBM.font")) SadConsole.Engine.DefaultFont = SadConsole.Serializer.Deserialize <Font>(stream); // Using the default font, resize the window to a Width,Height of cells. This example uses the MS-DOS default of 80 columns by 25 rows. SadConsole.Engine.DefaultFont.ResizeGraphicsDeviceManager(_graphics, 80, 25, 0, 0); // Create the default console, show the cursor, and let the console accept keyboard input. _defaultConsole = new Console(80, 25); _defaultConsole.VirtualCursor.IsVisible = true; _defaultConsole.CanUseKeyboard = true; // Add the default console to the list of consoles. SadConsole.Engine.ConsoleRenderStack.Add(_defaultConsole); // If you want to use the custom console demo provided by this starter project, uncomment out the line below. SadConsole.Engine.ConsoleRenderStack = new ConsoleList() { new CustomConsoles.CursorConsole(), new CustomConsoles.WorldGenerationConsole(), new CustomConsoles.StaticConsole(), new CustomConsoles.StretchedConsole(), new CustomConsoles.BorderedConsole(80, 25), new CustomConsoles.DOSConsole(), new CustomConsoles.WindowTestConsole(), new CustomConsoles.EntityAndConsole(), new CustomConsoles.RandomScrollingConsole(), new CustomConsoles.SplashScreen(), }; SadConsole.Engine.ConsoleRenderStack[0].IsVisible = true; // Set the first console in the console list as the "active" console. This allows the keyboard to be processed on the console. SadConsole.Engine.ActiveConsole = SadConsole.Engine.ConsoleRenderStack[0]; // Initialize the windows _characterWindow = new Windows.CharacterViewer(); //Components.Add(new FPSCounterComponent(this)); // Call the default initialize of the base class. base.Initialize(); }
/// <summary> /// Creates a new Scene from an existing <see cref="LayeredTextSurface"/>. /// </summary> /// <param name="surface">The surface for the scene.</param> public Scene(LayeredTextSurface surface) { baseConsole = new Console(surface); backgroundSurface = surface; Objects = new GameObjectCollection(); Zones = new List <Zone>(); Hotspots = new List <Hotspot>(); }
/// <summary> /// Creates a new Scene from an existing <see cref="LayeredTextSurface"/>. /// </summary> /// <param name="surface">The surface for the scene.</param> public Scene(LayeredTextSurface surface) { baseConsole = new Console(surface); backgroundSurface = surface; Objects = new GameObjectCollection(); Zones = new List<Zone>(); Hotspots = new List<Hotspot>(); }
protected override void Initialize() { // Let the XNA framework show the mouse. IsMouseVisible = true; IsFixedTimeStep = true; // Initialize the SadConsole engine and the first effects library (provided by the SadConsole.Effects.dll binary) SadConsole.Engine.Initialize(GraphicsDevice); // Tell SadConsole to track the mouse. SadConsole.Engine.UseMouse = true; // Load the default font. using (var stream = System.IO.File.OpenRead("Fonts/IBM.font")) SadConsole.Engine.DefaultFont = SadConsole.Serializer.Deserialize<Font>(stream); // Using the default font, resize the window to a Width,Height of cells. This example uses the MS-DOS default of 80 columns by 25 rows. SadConsole.Engine.DefaultFont.ResizeGraphicsDeviceManager(_graphics, 80, 25, 0, 0); // Create the default console, show the cursor, and let the console accept keyboard input. _defaultConsole = new Console(80, 25); _defaultConsole.VirtualCursor.IsVisible = true; _defaultConsole.CanUseKeyboard = true; // Add the default console to the list of consoles. SadConsole.Engine.ConsoleRenderStack.Add(_defaultConsole); var randomStuffConsole = new SadConsole.Consoles.Console(80, 25); randomStuffConsole.FillWithRandomGarbage(true); randomStuffConsole.IsVisible = false; string text = _defaultConsole.CellData.GetString(2, 0, 27); // If you want to use the custom console demo provided by this starter project, uncomment out the line below. SadConsole.Engine.ConsoleRenderStack = new ConsoleList() { new CustomConsoles.CursorConsole(), new CustomConsoles.StaticConsole(), new CustomConsoles.StretchedConsole(), new CustomConsoles.BorderedConsole(80, 25), new CustomConsoles.DOSConsole(), new CustomConsoles.WindowTestConsole(), new CustomConsoles.EntityAndConsole(), randomStuffConsole, new CustomConsoles.SplashScreen(), }; SadConsole.Engine.ConsoleRenderStack[0].IsVisible = true; // Set the first console in the console list as the "active" console. This allows the keyboard to be processed on the console. SadConsole.Engine.ActiveConsole = SadConsole.Engine.ConsoleRenderStack[0]; // Initialize the windows _characterWindow = new Windows.CharacterViewer(); // Call the default initialize of the base class. base.Initialize(); }
private static Consoles.Console SetupStartingConsole(int consoleWidth, int consoleHeight) { ActiveConsole = new Consoles.Console(consoleWidth, consoleHeight); ActiveConsole.TextSurface.DefaultBackground = Color.Black; ActiveConsole.TextSurface.DefaultForeground = ColorAnsi.White; ((Consoles.Console)ActiveConsole).Clear(); ConsoleRenderStack.Add(ActiveConsole); return((Consoles.Console)ActiveConsole); }
public static Scene Load(string file, Console baseConsole = null, params Type[] types) { var scene = SadConsole.Serializer.Load <Scene>(file, types); if (baseConsole == null) { scene.baseConsole = new Console(scene.backgroundSurface); } return(scene); }
public object Load(string file) { string[] text = System.IO.File.ReadAllLines(file); int maxLineWidth = text.Max(s => s.Length); SadConsole.Consoles.Console importConsole = new SadConsole.Consoles.Console(maxLineWidth, text.Length); importConsole.VirtualCursor.AutomaticallyShiftRowsUp = false; foreach (var line in text) importConsole.VirtualCursor.Print(line); return importConsole.TextSurface; }
public SceneEditor() { consoleWrapper = new Console(1, 1); consoleWrapper.Renderer = new LayeredTextRenderer(); consoleWrapper.MouseHandler = ProcessMouse; consoleWrapper.CanUseKeyboard = false; consoleWrapper.MouseMove += (o, e) => { toolsPanel.SelectedTool?.MouseMoveSurface(e.OriginalMouseInfo, textSurface); }; consoleWrapper.MouseEnter += (o, e) => { toolsPanel.SelectedTool?.MouseEnterSurface(e.OriginalMouseInfo, textSurface); }; consoleWrapper.MouseExit += (o, e) => { toolsPanel.SelectedTool?.MouseExitSurface(e.OriginalMouseInfo, textSurface); }; layerManagementPanel = new LayersPanel() { IsCollapsed = true }; toolsPanel = new ToolsPanel(); // Fill tools tools = new Dictionary<string, Tools.ITool>(); tools.Add(Tools.PaintTool.ID, new Tools.PaintTool()); tools.Add(Tools.LineTool.ID, new Tools.LineTool()); tools.Add(Tools.CircleTool.ID, new Tools.CircleTool()); tools.Add(Tools.RecolorTool.ID, new Tools.RecolorTool()); tools.Add(Tools.FillTool.ID, new Tools.FillTool()); tools.Add(Tools.BoxTool.ID, new Tools.BoxTool()); tools.Add(Tools.SelectionTool.ID, new Tools.SelectionTool()); tools.Add(Tools.SceneObjectMoveResizeTool.ID, new Tools.SceneObjectMoveResizeTool()); tools.Add(Tools.HotspotTool.ID, new Tools.HotspotTool()); toolsPanel.ToolsListBox.Items.Add(tools[Tools.SceneObjectMoveResizeTool.ID]); toolsPanel.ToolsListBox.Items.Add(tools[Tools.HotspotTool.ID]); toolsPanel.ToolsListBox.Items.Add(tools[Tools.PaintTool.ID]); toolsPanel.ToolsListBox.Items.Add(tools[Tools.LineTool.ID]); toolsPanel.ToolsListBox.Items.Add(tools[Tools.CircleTool.ID]); toolsPanel.ToolsListBox.Items.Add(tools[Tools.RecolorTool.ID]); toolsPanel.ToolsListBox.Items.Add(tools[Tools.FillTool.ID]); toolsPanel.ToolsListBox.Items.Add(tools[Tools.BoxTool.ID]); toolsPanel.ToolsListBox.Items.Add(tools[Tools.SelectionTool.ID]); toolsPanel.ToolsListBox.SelectedItemChanged += ToolsListBox_SelectedItemChanged; GameObjectPanel = new Panels.GameObjectManagementPanel(); ZonesPanel = new RegionManagementPanel() { IsCollapsed = true }; HotspotPanel = new HotspotToolPanel() { IsCollapsed = true }; LinkedGameObjects = new Dictionary<GameObject, GameObject>(); Objects = new List<ResizableObject>(); Zones = new List<ResizableObject<Zone>>(); Hotspots = new List<Hotspot>(); panels = new CustomPanel[] { layerManagementPanel, GameObjectPanel, ZonesPanel, HotspotPanel, toolsPanel }; }
public AnsiWriter(Document ansiDocument, Console console) { _ansiDoc = ansiDocument; _console = console; _cursor = new Console.Cursor(console); CharactersPerSecond = 800; _bytes = ansiDocument.AnsiBytes; _ansiState = new State(); _ansiCodeBuilder = new StringBuilder(5); _ansiStringBuilder = new StringBuilder(40); BlinkEffect = new Blink() { BlinkSpeed = 0.35f }; }
public object Load(string file) { string[] text = System.IO.File.ReadAllLines(file); int maxLineWidth = text.Max(s => s.Length); SadConsole.Consoles.Console importConsole = new SadConsole.Consoles.Console(maxLineWidth, text.Length); importConsole.VirtualCursor.AutomaticallyShiftRowsUp = false; foreach (var line in text) { importConsole.VirtualCursor.Print(line); } return(importConsole.TextSurface); }
public FadingExample() { // Simulate two consoles backgroundConsole = new Console(80, 25); foregroundConsole = new Console(80, 25); // To work with our sample project, all consoles default to not visible. If you're using this // on your own, outside of the starter project, delete this line. IsVisible = false; // Setup main view backgroundConsole.FillWithRandomGarbage(); // Setup sub view // Normally the text surface uses a transparent background so you can easily layer. We don't want that. foregroundConsole.TextSurface.DefaultBackground = Color.Black; foregroundConsole.Clear(); // Some visuals on the surface so we can see something fade. var border = SadConsole.Shapes.Box.GetDefaultBox(); border.Location = new Point(0, 0); border.Width = 80; border.Height = 25; border.Draw(foregroundConsole); for (int y = 2; y < 23; y += 2) { foregroundConsole.Print(9, y, "This is a console that will fade, showing whatever is beind it", Color.Black.GetRandomColor(SadConsole.Engine.Random)); } foregroundConsole.Print(2, 0, "[c:r f:Black][c:r b:White] PRESS SPACE TO START FADE "); // Console has been drawn on and is ready to be cached for the fade. foregroundConsole.Renderer = new SadConsole.Consoles.CachedTextSurfaceRenderer(foregroundConsole.TextSurface); // Because of the way the cached renderer handles tinting, we need to set tinting to white // This means "render the cahced surface exactly how it was originally drawn." foregroundConsole.TextSurface.Tint = Color.White; // Ad the consoles to the list. Add(backgroundConsole); Add(foregroundConsole); // Setup the fade animation to go from white to transparent in 2 seconds. tintFade = new SadConsole.Instructions.FadeTextSurfaceTint(foregroundConsole.TextSurface, new ColorGradient(Color.White, Color.Transparent), TimeSpan.FromSeconds(2)); }
public DungeonMapConsole(DungeonScreen screen, int viewWidth, int viewHeight, int mapWidth, int mapHeight) : base(mapWidth, mapHeight) { TextSurface.RenderArea = new Rectangle(0, 0, viewWidth, viewHeight); ActorLayer = new Console(mapWidth, mapHeight); GuiLayer = new Console(mapWidth, mapHeight); this.mapWidth = mapWidth; this.mapHeight = mapHeight; this.screen = screen; GenerateBuilderMap(); PlaceHero(); PlaceMonsters(15); screen.HookUpHero(hero); hero.OnChangedEvent(); UpdateFov(); }
private static void Engine_EngineStart(object sender, EventArgs e) { var defaultConsole = (Console)SadConsole.Engine.ActiveConsole; defaultConsole.TextSurface = new TextSurface(80, 12); defaultConsole.Fill(Color.Blue, Color.Yellow, 0); defaultConsole.Print(1, 1, "Hello from console 1"); var console2 = new Console(80, 13); console2.Position = new Point(0, 12); console2.Fill(Color.Yellow, Color.Blue, 0); console2.Print(1, 1, "Hello from console 2"); SadConsole.Engine.ConsoleRenderStack.Add(console2); SadConsole.Engine.ToggleFullScreen(); }
public FadingExample() { // Simulate two consoles backgroundConsole = new Console(80, 25); foregroundConsole = new Console(80, 25); // To work with our sample project, all consoles default to not visible. If you're using this // on your own, outside of the starter project, delete this line. IsVisible = false; // Setup main view backgroundConsole.FillWithRandomGarbage(); // Setup sub view // Normally the text surface uses a transparent background so you can easily layer. We don't want that. foregroundConsole.TextSurface.DefaultBackground = Color.Black; foregroundConsole.Clear(); // Some visuals on the surface so we can see something fade. var border = SadConsole.Shapes.Box.GetDefaultBox(); border.Location = new Point(0, 0); border.Width = 80; border.Height = 25; border.Draw(foregroundConsole); for (int y = 2; y < 23; y += 2) foregroundConsole.Print(9, y, "This is a console that will fade, showing whatever is beind it", Color.Black.GetRandomColor(SadConsole.Engine.Random)); foregroundConsole.Print(2, 0, "[c:r f:Black][c:r b:White] PRESS SPACE TO START FADE "); // Console has been drawn on and is ready to be cached for the fade. foregroundConsole.Renderer = new SadConsole.Consoles.CachedTextSurfaceRenderer(foregroundConsole.TextSurface); // Because of the way the cached renderer handles tinting, we need to set tinting to white // This means "render the cahced surface exactly how it was originally drawn." foregroundConsole.TextSurface.Tint = Color.White; // Ad the consoles to the list. Add(backgroundConsole); Add(foregroundConsole); // Setup the fade animation to go from white to transparent in 2 seconds. tintFade = new SadConsole.Instructions.FadeTextSurfaceTint(foregroundConsole.TextSurface, new ColorGradient(Color.White, Color.Transparent), TimeSpan.FromSeconds(2)); }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> Default constructor. </summary> /// /// <remarks> Darrellp, 8/26/2016. </remarks> //////////////////////////////////////////////////////////////////////////////////////////////////// public DungeonScreen() { StatsConsole = new CharacterConsole(24, 17); // ReSharper disable once RedundantArgumentDefaultValue DungeonConsole = new DungeonMapConsole(56, 16, 100, 100, Font.FontSizes.One); MessageConsole = new MessagesConsole(80, 6); // Setup the message header to be as wide as the screen but only 1 character high messageHeaderConsole = new Console(80, 1) { DoUpdate = false, CanUseKeyboard = false, CanUseMouse = false }; // Draw the line for the header messageHeaderConsole.Fill(Color.White, Color.Black, 196, null); messageHeaderConsole.SetGlyph(56, 0, 193); // This makes the border match the character console's left-edge border // Print the header text messageHeaderConsole.Print(2, 0, " Messages "); // Move the rest of the consoles into position (DungeonConsole is already in position at 0,0) StatsConsole.Position = new Point(56, 0); MessageConsole.Position = new Point(0, 18); messageHeaderConsole.Position = new Point(0, 17); // Add all consoles to this console list. Add(messageHeaderConsole); Add(StatsConsole); Add(DungeonConsole); Add(MessageConsole); // Placeholder stuff for the stats screen StatsConsole.CharacterName = "Hydorn"; StatsConsole.MaxHealth = 200; StatsConsole.Health = 100; Engine.ActiveConsole = this; Engine.Keyboard.RepeatDelay = 0.1f; Engine.Keyboard.InitialRepeatDelay = 0.1f; }
public ViewsAndSubViews() { titleAndLine = new Console(80, 25); mainView = new Console(59, 24); subView = new Console(19, 24); IsVisible = false; // Draw border and line stuff titleAndLine.Print(0, 0, " View and Sub View".Align(System.Windows.HorizontalAlignment.Left, 80), ColorHelper.GreenYellow, ColorHelper.DarkGreen); SadConsole.Shapes.Line line = new SadConsole.Shapes.Line(); line.UseStartingCell = false; line.UseEndingCell = false; line.CellAppearance.GlyphIndex = 179; line.StartingLocation = new Point(59, 1); line.EndingLocation = new Point(59, 24); line.Draw(titleAndLine); // Setup main view mainView.Position = new Point(0, 1); mainView.Print(1, 1, "Click on a cell to draw"); mainView.MouseMove += (s, e) => { if (e.LeftButtonDown) { e.Cell.Background = Color.Blue; } }; // Setup sub view subView.Position = new Point(60, 1); subView.TextSurface = new TextSurfaceView(mainView.TextSurface, new Rectangle(0, 0, 20, 24)); subView.MouseMove += (s, e) => { if (e.LeftButtonDown) { e.Cell.Background = Color.Red; } }; // Ad the consoles to the list. Add(titleAndLine); Add(mainView); Add(subView); }
public SubConsoleCursor() { mainView = new Console(80, 25); subView = new Console(25, 10); IsVisible = false; // Setup main view mainView.FillWithRandomGarbage(); mainView.MouseMove += (s, e) => { if (e.LeftButtonDown) e.Cell.Background = Color.Blue; }; // Setup sub view subView.Position = new Point(4, 4); subView.TextSurface = new TextSurfaceView(mainView.TextSurface, new Rectangle(4, 4, 25, 10)); subView.MouseMove += (s, e) => { if (e.LeftButtonDown) e.Cell.Background = Color.Red; }; subView.Clear(); // Ad the consoles to the list. Add(mainView); //Add(subView); }
public DungeonScreen() { InventoryConsole = new InventoryConsole(_inventoryWidth, _inventoryHeight); InventoryConsole.FillWithRandomGarbage(); StatsConsole = new StatConsole(_statWidth, _statHeight); MapConsole = new MapConsole(_mapWidth, _mapHeight, dungeonWidth, dungeonHeight); //MapConsole.FillWithRandomGarbage(); // Temporary so we can see where the console is on the screen MessageConsole = new MessagesConsole(_messageWidth, _messageHeight); SadConsole.Engine.Keyboard.RepeatDelay = 0.07f; SadConsole.Engine.Keyboard.InitialRepeatDelay = 0.07f; // Setup the message header to be as wide as the screen but only 1 character high messageHeaderConsole = new Console(_messageWidth, 1); messageHeaderConsole.DoUpdate = false; messageHeaderConsole.CanUseKeyboard = false; messageHeaderConsole.CanUseMouse = false; // Draw the line for the header messageHeaderConsole.Fill(Color.White, Color.Black, 196, null); messageHeaderConsole.SetGlyph(56, 0, 193); // This makes the border match the character console's left-edge border // Print the header text messageHeaderConsole.Print(2, 0, " Messages "); MapConsole.Position = new Point(0, 0); StatsConsole.Position = new Point(_messageWidth, 0); InventoryConsole.Position = new Point(_messageWidth, _statHeight); MessageConsole.Position = new Point(0, _mapHeight + 1); messageHeaderConsole.Position = new Point(0, _mapHeight); // Add all consoles to this console list. Add(messageHeaderConsole); Add(StatsConsole); Add(MapConsole); Add(MessageConsole); Add(InventoryConsole); SadConsole.Engine.ActiveConsole = this; }
public GameObjectEditor() { consoleWrapper = new Console(1, 1); consoleWrapper.Renderer = new LayeredTextRenderer(); consoleWrapper.MouseHandler = ProcessMouse; consoleWrapper.CanUseKeyboard = false; consoleWrapper.MouseMove += (o, e) => { toolsPanel.SelectedTool?.MouseMoveSurface(e.OriginalMouseInfo, textSurface); }; consoleWrapper.MouseEnter += (o, e) => { toolsPanel.SelectedTool?.MouseEnterSurface(e.OriginalMouseInfo, textSurface); }; consoleWrapper.MouseExit += (o, e) => { toolsPanel.SelectedTool?.MouseExitSurface(e.OriginalMouseInfo, textSurface); }; toolsPanel = new ToolsPanel(); animationPanel = new AnimationsPanel(SelectedAnimationChanged); gameObjectNamePanel = new GameObjectNamePanel(); framesPanel = new AnimationFramesPanel(SelectedFrameChanged); // Fill tools tools = new Dictionary<string, Tools.ITool>(); tools.Add(Tools.PaintTool.ID, new Tools.PaintTool()); tools.Add(Tools.LineTool.ID, new Tools.LineTool()); tools.Add(Tools.CircleTool.ID, new Tools.CircleTool()); tools.Add(Tools.RecolorTool.ID, new Tools.RecolorTool()); tools.Add(Tools.FillTool.ID, new Tools.FillTool()); tools.Add(Tools.BoxTool.ID, new Tools.BoxTool()); tools.Add(Tools.SelectionTool.ID, new Tools.SelectionTool()); tools.Add(Tools.EntityCenterTool.ID, new Tools.EntityCenterTool()); toolsPanel.ToolsListBox.Items.Add(tools[Tools.EntityCenterTool.ID]); toolsPanel.ToolsListBox.Items.Add(tools[Tools.PaintTool.ID]); toolsPanel.ToolsListBox.Items.Add(tools[Tools.LineTool.ID]); toolsPanel.ToolsListBox.Items.Add(tools[Tools.CircleTool.ID]); toolsPanel.ToolsListBox.Items.Add(tools[Tools.RecolorTool.ID]); toolsPanel.ToolsListBox.Items.Add(tools[Tools.FillTool.ID]); toolsPanel.ToolsListBox.Items.Add(tools[Tools.BoxTool.ID]); toolsPanel.ToolsListBox.Items.Add(tools[Tools.SelectionTool.ID]); toolsPanel.ToolsListBox.SelectedItemChanged += ToolsListBox_SelectedItemChanged; panels = new CustomPanel[] { gameObjectNamePanel, animationPanel, framesPanel, toolsPanel }; }
public DungeonScreen() { InventoryConsole = new InventoryPanel("Inventory", _inventoryWidth, _inventoryHeight + 1); StatsConsole = new StatsConsole(_statWidth, _statHeight); MessageConsole = new MessagePanel(_messageWidth, _messageHeight); ViewConsole = new MapConsole(_mapWidth, _mapHeight, _screenWidth, _screenHeight); // InventoryConsole.FillWithRandomGarbage(); // Setup the message header to be as wide as the screen but only 1 character high messageHeaderConsole = new Console(_messageWidth + 1, 1); messageHeaderConsole.DoUpdate = false; messageHeaderConsole.CanUseKeyboard = false; messageHeaderConsole.CanUseMouse = false; // Draw the line for the header messageHeaderConsole.Fill(Color.White, Color.Black, 196, null); // Print the header text messageHeaderConsole.Print(2, 0, " Messages "); // Move the rest of the consoles into position (ViewConsole is already in position at 0). InventoryConsole.Position = new Point(112, _statHeight); StatsConsole.Position = new Point(112, 0); MessageConsole.Position = new Point(0, 36); messageHeaderConsole.Position = new Point(0, 34); // Add all consoles to this console list. Add(messageHeaderConsole); Add(StatsConsole); Add(ViewConsole); Add(MessageConsole); Add(InventoryConsole); SadConsole.Engine.ActiveConsole = this; // Keyboard stuff SadConsole.Engine.Keyboard.RepeatDelay = 0.07f; SadConsole.Engine.Keyboard.InitialRepeatDelay = 0.1f; }
public LayeredConsoleEditor() { consoleWrapper = new Console(1, 1); consoleWrapper.Renderer = new LayeredTextRenderer(); consoleWrapper.MouseHandler = ProcessMouse; consoleWrapper.CanUseKeyboard = false; consoleWrapper.MouseMove += (o, e) => { toolsPanel.SelectedTool?.MouseMoveSurface(e.OriginalMouseInfo, textSurface); }; consoleWrapper.MouseEnter += (o, e) => { toolsPanel.SelectedTool?.MouseEnterSurface(e.OriginalMouseInfo, textSurface); }; consoleWrapper.MouseExit += (o, e) => { toolsPanel.SelectedTool?.MouseExitSurface(e.OriginalMouseInfo, textSurface); }; layerManagementPanel = new LayersPanel() { IsCollapsed = true }; toolsPanel = new ToolsPanel(); // Fill tools tools = new Dictionary<string, Tools.ITool>(); tools.Add(Tools.PaintTool.ID, new Tools.PaintTool()); tools.Add(Tools.LineTool.ID, new Tools.LineTool()); tools.Add(Tools.TextTool.ID, new Tools.TextTool()); tools.Add(Tools.CircleTool.ID, new Tools.CircleTool()); tools.Add(Tools.RecolorTool.ID, new Tools.RecolorTool()); tools.Add(Tools.FillTool.ID, new Tools.FillTool()); tools.Add(Tools.BoxTool.ID, new Tools.BoxTool()); tools.Add(Tools.SelectionTool.ID, new Tools.SelectionTool()); toolsPanel.ToolsListBox.Items.Add(tools[Tools.PaintTool.ID]); toolsPanel.ToolsListBox.Items.Add(tools[Tools.LineTool.ID]); toolsPanel.ToolsListBox.Items.Add(tools[Tools.TextTool.ID]); toolsPanel.ToolsListBox.Items.Add(tools[Tools.CircleTool.ID]); toolsPanel.ToolsListBox.Items.Add(tools[Tools.RecolorTool.ID]); toolsPanel.ToolsListBox.Items.Add(tools[Tools.FillTool.ID]); toolsPanel.ToolsListBox.Items.Add(tools[Tools.BoxTool.ID]); toolsPanel.ToolsListBox.Items.Add(tools[Tools.SelectionTool.ID]); toolsPanel.ToolsListBox.SelectedItemChanged += ToolsListBox_SelectedItemChanged; panels = new CustomPanel[] { layerManagementPanel, toolsPanel }; }
public DungeonScreen() { StatsConsole = new CharacterStatusPanel(24, 41); ViewConsole = new DungeonMapConsole(this, 56, 42, 80, 80); MessageConsole = MessagesConsole.Instance; // = new MessagesConsole( ); // defaults to 80,6 // Setup Input CanUseKeyboard = true; SadConsole.Engine.ActiveConsole = this; SadConsole.Engine.Keyboard.RepeatDelay = 0.07f; SadConsole.Engine.Keyboard.InitialRepeatDelay = 0.1f; messageHeaderConsole = new Console(80, 1); messageHeaderConsole.DoUpdate = false; messageHeaderConsole.CanUseKeyboard = false; messageHeaderConsole.CanUseMouse = false; // Draw the line for the header messageHeaderConsole.Fill(Color.White, Color.Black, 196, null); messageHeaderConsole.SetGlyph(56, 0, 193); // This makes the border match the character console's left-edge border // Print the header text messageHeaderConsole.Print(2, 0, " Messages "); // Move the rest of the consoles into position (ViewConsole is already in position at 0,0) StatsConsole.Position = new Point(56, 0); MessageConsole.Position = new Point(0, 42); messageHeaderConsole.Position = new Point(0, 41); // Add all consoles to this console list. Add(messageHeaderConsole); Add(StatsConsole); Add(ViewConsole); Add(MessageConsole); }
public static Scene Load(string file, Console baseConsole = null, params Type[] types) { var scene = SadConsole.Serializer.Load<Scene>(file, types); if (baseConsole == null) scene.baseConsole = new Console(scene.backgroundSurface) { Renderer = new LayeredTextRenderer() }; else scene.baseConsole = baseConsole; return scene; }
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(); }
/// <summary> /// Prepares the engine for use. This must be the first method you call on the engine when you provide your own <see cref="GraphicsDeviceManager"/>. /// </summary> /// <param name="deviceManager">The graphics device manager from MonoGame.</param> /// <param name="font">The font to load as the <see cref="DefaultFont"/>.</param> /// <param name="consoleWidth">The width of the default root console (and game window).</param> /// <param name="consoleHeight">The height of the default root console (and game window).</param> /// <returns>The default active console.</returns> public static Consoles.Console Initialize(GraphicsDeviceManager deviceManager, string font, int consoleWidth, int consoleHeight) { if (Device == null) Device = deviceManager.GraphicsDevice; SetupFontAndEffects(font); DeviceManager = deviceManager; DefaultFont.ResizeGraphicsDeviceManager(deviceManager, consoleWidth, consoleHeight, 0, 0); // Create the default console. ActiveConsole = new Consoles.Console(consoleWidth, consoleHeight); ActiveConsole.TextSurface.DefaultBackground = Color.Black; ActiveConsole.TextSurface.DefaultForeground = ColorAnsi.White; ((Consoles.Console)ActiveConsole).Clear(); ConsoleRenderStack.Add(ActiveConsole); renderBatch = new SpriteBatch(Device); ResetRendering(); return (Consoles.Console)ActiveConsole; }
public WorldGenerationConsole() : base(80, 25) { messageData = new Console(1, 1); messageData.TextSurface = textSurface; IsVisible = false; KeyboardHandler = (cons, info) => { if (info.IsKeyDown(Keys.Left)) { cons.TextSurface.RenderArea = new Rectangle(cons.TextSurface.RenderArea.Left - 1, cons.TextSurface.RenderArea.Top, 80 * 2, 25 * 2); } if (info.IsKeyDown(Keys.Right)) { cons.TextSurface.RenderArea = new Rectangle(cons.TextSurface.RenderArea.Left + 1, cons.TextSurface.RenderArea.Top, 80 * 2, 25 * 2); } if (info.IsKeyDown(Keys.Up)) { cons.TextSurface.RenderArea = new Rectangle(cons.TextSurface.RenderArea.Left, cons.TextSurface.RenderArea.Top - 1, 80 * 2, 25 * 2); } if (info.IsKeyDown(Keys.Down)) { cons.TextSurface.RenderArea = new Rectangle(cons.TextSurface.RenderArea.Left, cons.TextSurface.RenderArea.Top + 1, 80 * 2, 25 * 2); } if (info.IsKeyReleased(Keys.Enter)) { messageData.Fill(Color.White, Color.Black, 0, null); messageData.Print(0, 0, "Generating map, please wait..."); initialized = true; initializedStep2 = false; initializedStep3 = false; } if (info.IsKeyReleased(Keys.Space)) { var oldRenderArea = cons.TextSurface.RenderArea; var oldFont = cons.TextSurface.Font; if (textSurface == generator.HeightMapRenderer) { textSurface = generator.HeatMapRenderer; messageData.Print(0, 0, $"[SPACE] Change Map Info [ENTER] New Map -- Heat ", Color.White, Color.Black); } else if (textSurface == generator.HeatMapRenderer) { textSurface = generator.MoistureMapRenderer; messageData.Print(0, 0, $"[SPACE] Change Map Info [ENTER] New Map -- Moisture", Color.White, Color.Black); } else if (textSurface == generator.MoistureMapRenderer) { textSurface = generator.BiomeMapRenderer; messageData.Print(0, 0, $"[SPACE] Change Map Info [ENTER] New Map -- Biome ", Color.White, Color.Black); } else { textSurface = generator.HeightMapRenderer; messageData.Print(0, 0, $"[SPACE] Change Map Info [ENTER] New Map -- Height ", Color.White, Color.Black); } cons.TextSurface.RenderArea = oldRenderArea; cons.TextSurface.Font = oldFont; } return(true); }; }
public WorldGenerationConsole() : base(80, 25) { messageData = new Console(1, 1); messageData.TextSurface = textSurface; IsVisible = false; KeyboardHandler = (cons, info) => { if (info.IsKeyDown(Keys.Left)) cons.TextSurface.RenderArea = new Rectangle(cons.TextSurface.RenderArea.Left - 1, cons.TextSurface.RenderArea.Top, 80 * 2, 25 * 2); if (info.IsKeyDown(Keys.Right)) cons.TextSurface.RenderArea = new Rectangle(cons.TextSurface.RenderArea.Left + 1, cons.TextSurface.RenderArea.Top, 80 * 2, 25 * 2); if (info.IsKeyDown(Keys.Up)) cons.TextSurface.RenderArea = new Rectangle(cons.TextSurface.RenderArea.Left, cons.TextSurface.RenderArea.Top - 1, 80 * 2, 25 * 2); if (info.IsKeyDown(Keys.Down)) cons.TextSurface.RenderArea = new Rectangle(cons.TextSurface.RenderArea.Left, cons.TextSurface.RenderArea.Top + 1, 80 * 2, 25 * 2); if (info.IsKeyReleased(Keys.Enter)) { messageData.Fill(Color.White, Color.Black, 0, null); messageData.Print(0, 0, "Generating map, please wait..."); initialized = true; initializedStep2 = false; initializedStep3 = false; } if (info.IsKeyReleased(Keys.Space)) { var oldRenderArea = cons.TextSurface.RenderArea; var oldFont = cons.TextSurface.Font; if (textSurface == generator.HeightMapRenderer) { textSurface = generator.HeatMapRenderer; messageData.Print(0, 0, $"[SPACE] Change Map Info [ENTER] New Map -- Heat ", Color.White, Color.Black); } else if (textSurface == generator.HeatMapRenderer) { textSurface = generator.MoistureMapRenderer; messageData.Print(0, 0, $"[SPACE] Change Map Info [ENTER] New Map -- Moisture", Color.White, Color.Black); } else if (textSurface == generator.MoistureMapRenderer) { textSurface = generator.BiomeMapRenderer; messageData.Print(0, 0, $"[SPACE] Change Map Info [ENTER] New Map -- Biome ", Color.White, Color.Black); } else { textSurface = generator.HeightMapRenderer; messageData.Print(0, 0, $"[SPACE] Change Map Info [ENTER] New Map -- Height ", Color.White, Color.Black); } cons.TextSurface.RenderArea = oldRenderArea; cons.TextSurface.Font = oldFont; } return true; }; }