private static void TurnBasedLoopTest(RootConsole console, ref KeyPress key) { console.Clear(); console.PrintLine("Keyboard Test Suite", 40, 5, LineAlignment.Center); console.PrintLine("Press 'F10' to enter Real Time Test.", 40, 6, LineAlignment.Center); console.PrintLine("Press 'q' to quit.", 40, 7, LineAlignment.Center); if (key.KeyCode == KeyCode.TCODK_CHAR) { console.PrintLine("Key Hit = \"" + (char)key.Character + "\"", 10, 10, LineAlignment.Left); } else { console.PrintLine("Special Key Hit = " + key.KeyCode.ToString(), 10, 10, LineAlignment.Left); } PrintStatus(console, "Status", key.Pressed, 10, 12); PrintStatus(console, "lalt", key.LeftAlt, 10, 13); PrintStatus(console, "lctrl", key.LeftControl, 10, 14); PrintStatus(console, "ralt", key.RightAlt, 10, 15); PrintStatus(console, "rctrl", key.RightControl, 10, 16); PrintStatus(console, "shift", key.Shift, 10, 17); console.PrintLine("F1 Key Pressed = " + (Keyboard.IsKeyPressed(KeyCode.TCODK_F1) ? "Yes" : "No"), 10, 20, LineAlignment.Left); console.Flush(); key = Keyboard.WaitForKeyPress(false); if (key.KeyCode == KeyCode.TCODK_F10) { inRealTimeTest = true; } }
/// <summary> /// Call after all drawing is complete to output onto screen /// </summary> public void FlushConsole() { //Get screen handle RootConsole rootConsole = RootConsole.GetInstance(); rootConsole.Flush(); }
void ClearMessageBar() { //Get screen handle RootConsole rootConsole = RootConsole.GetInstance(); rootConsole.DrawRect(msgDisplayTopLeft.x, msgDisplayTopLeft.y, width - msgDisplayTopLeft.x, msgDisplayNumLines, true); }
private static void PaintFOVTest(RootConsole console, int x, int y, TCODFov fov) { fov.CalculateFOV(x, y, 3, false, FovAlgorithm.Basic); for (int i = 0; i < 5; ++i) //width { for (int j = 0; j < 5; ++j) //height { if (room[j, i] == '.') { if (fov.CheckTileFOV(i, j)) { console.PutChar(i, j, '.'); } else { console.PutChar(i, j, '~'); } } else { console.PutChar(i, j, '#'); } } } console.PutChar(x, y, '@'); console.Flush(); }
private void OpeningScreen() { Screen screen = Screen.Instance; //Get screen handle RootConsole rootConsole = RootConsole.GetInstance(); //Draw title titleCentre = new Point(screen.Width / 2, screen.Height / 2); rootConsole.PrintLineRect("Welcome to FlatlineRL!", titleCentre.x, titleCentre.y, screen.Width, 1, LineAlignment.Center); rootConsole.PrintLineRect("7DRL Challenge 2013", titleCentre.x, titleCentre.y + 2, screen.Width, 1, LineAlignment.Center); rootConsole.PrintLineRect("by: flend", titleCentre.x, titleCentre.y + 4, screen.Width, 1, LineAlignment.Center); //Any key to continue anyKeyLocation = new Point(screen.Width / 2, screen.Height - 5); rootConsole.PrintLineRect("Press any key to continue", anyKeyLocation.x, anyKeyLocation.y, screen.Width, 1, LineAlignment.Center); //Update screen Screen.Instance.FlushConsole(); //Wait for key KeyPress userKey = Keyboard.WaitForKeyPress(true); }
internal void ClearMessageLine() { //Get screen handle RootConsole rootConsole = RootConsole.GetInstance(); lastMessage = null; ClearMessageBar(); }
public void Init() { RootConsole.Width = 80; RootConsole.Height = 50; RootConsole.WindowTitle = "Image Testing"; RootConsole.Fullscreen = false; console = RootConsole.GetInstance(); console.Clear(); }
public static void TestTCODMouse() { bool cursorVisible = true; RootConsole.Width = 80; RootConsole.Height = 50; RootConsole.WindowTitle = "Mouse Tester"; RootConsole.Fullscreen = false; using (RootConsole console = RootConsole.GetInstance()) { TCODSystem.FPS = 30; do { console.Clear(); KeyPress pressedKey = Keyboard.CheckForKeypress(KeyPressType.Released); Mouse m = Mouse.GetStatus();; Mouse.ShowCursor(cursorVisible); if (pressedKey.Character == 't') { cursorVisible = !Mouse.IsVisible; } if (pressedKey.Character == 'm') { Mouse.MoveMouse(10, 10); } console.PrintLine("Mouse Test Suite", 40, 5, LineAlignment.Center); console.PrintLine("Close Window to quit.", 40, 7, LineAlignment.Center); console.PrintLine("Press \"t\" to toggle cursor", 40, 8, LineAlignment.Center); console.PrintLine("Press \"m\" to move cursor to (10,10)", 40, 9, LineAlignment.Center); PrintStatus(console, "LeftButton", m.LeftButton, 10, 12); PrintStatus(console, "RightButton", m.RightButton, 10, 13); PrintStatus(console, "MiddleButton", m.MiddleButton, 10, 14); PrintStatus(console, "LeftButtonPressed", m.LeftButtonPressed, 10, 15); PrintStatus(console, "RightButtonPressed", m.RightButtonPressed, 10, 16); PrintStatus(console, "MiddleButtonPressed", m.MiddleButtonPressed, 10, 17); console.PrintLine("Cursor Visible = " + (cursorVisible ? "On" : "Off"), 10, 18, LineAlignment.Left); console.PrintLine("x = " + m.PixelX, 10, 20, LineAlignment.Left); console.PrintLine("y = " + m.PixelY, 10, 21, LineAlignment.Left); console.PrintLine("dx = " + m.PixelVelocityX, 10, 22, LineAlignment.Left); console.PrintLine("dy = " + m.PixelVelocityY, 10, 23, LineAlignment.Left); console.PrintLine("cx = " + m.CellX, 10, 24, LineAlignment.Left); console.PrintLine("cy = " + m.CellY, 10, 25, LineAlignment.Left); console.PrintLine("dcx = " + m.CellVelocityX, 10, 26, LineAlignment.Left); console.PrintLine("dcy = " + m.CellVelocityY, 10, 27, LineAlignment.Left); console.Flush(); }while(!console.IsWindowClosed()); } }
private static void onRender(object sender, UpdateEventArgs e) { // Tell all panels that want to update in real time to do so UpdateRealTimeLayouts?.Invoke(sender, e); // Draw all shown screens RootConsole.Clear(); Render?.Invoke(sender, e); RootConsole.Draw(); }
/// <summary> /// Display equipment select overview /// </summary> private void DrawEquipmentSelect() { //Get screen handle RootConsole rootConsole = RootConsole.GetInstance(); //Draw frame rootConsole.DrawFrame(inventoryTL.x, inventoryTL.y, inventoryTR.x - inventoryTL.x + 1, inventoryBL.y - inventoryTL.y + 1, true); //Draw title rootConsole.PrintLineRect(inventoryTitle, (inventoryTL.x + inventoryTR.x) / 2, inventoryTL.y, inventoryTR.x - inventoryTL.x, 1, LineAlignment.Center); //Draw instructions rootConsole.PrintLineRect(inventoryInstructions, (inventoryTL.x + inventoryTR.x) / 2, inventoryBL.y, inventoryTR.x - inventoryTL.x, 1, LineAlignment.Center); //List the inventory //Inventory area is slightly reduced from frame int inventoryListX = inventoryTL.x + 2; int inventoryListW = inventoryTR.x - inventoryTL.x - 4; int inventoryListY = inventoryTL.y + 2; int inventoryListH = inventoryBL.y - inventoryTL.y - 4; List <InventoryListing> inventoryList = currentInventory.InventoryListing; for (int i = 0; i < inventoryListH; i++) { int inventoryIndex = topInventoryIndex + i; //End of inventory if (inventoryIndex == inventoryList.Count) { break; } //Create entry string char selectionChar = (char)((int)'a' + i); string entryString = "(" + selectionChar.ToString() + ") " + inventoryList[inventoryIndex].Description; //Add equipped status //Only consider the first item in a stack, since equipped items can't stack Item firstItemInStack = currentInventory.Items[inventoryList[inventoryIndex].ItemIndex[0]]; EquipmentSlotInfo equippedInSlot = currentEquipment.Find(x => x.equippedItem == firstItemInStack); if (equippedInSlot != null) { entryString += " (equipped: " + StringEquivalent.EquipmentSlots[equippedInSlot.slotType] + ")"; } //Print entry rootConsole.PrintLineRect(entryString, inventoryListX, inventoryListY + i, inventoryListW, 1, LineAlignment.Left); } }
//This field is used in manual tests, and not a warning #pragma warning disable 0649 static void WaitForDebugger() { RootConsole.Width = 80; RootConsole.Height = 50; RootConsole.WindowTitle = "Waiting for Debugger"; RootConsole.Fullscreen = false; using (RootConsole console = RootConsole.GetInstance()) { Keyboard.WaitForKeyPress(false); } }
/// <summary> /// Display equipment overlay /// </summary> private void DrawEquipment() { //Get screen handle RootConsole rootConsole = RootConsole.GetInstance(); //Use frame and strings from inventory for now //Draw frame rootConsole.DrawFrame(inventoryTL.x, inventoryTL.y, inventoryTR.x - inventoryTL.x + 1, inventoryBL.y - inventoryTL.y + 1, true); //Draw title rootConsole.PrintLineRect(inventoryTitle, (inventoryTL.x + inventoryTR.x) / 2, inventoryTL.y, inventoryTR.x - inventoryTL.x, 1, LineAlignment.Center); //Draw instructions rootConsole.PrintLineRect(inventoryInstructions, (inventoryTL.x + inventoryTR.x) / 2, inventoryBL.y, inventoryTR.x - inventoryTL.x, 1, LineAlignment.Center); //List current slots & items if filled //Equipment area is slightly reduced from frame int inventoryListX = inventoryTL.x + 2; int inventoryListW = inventoryTR.x - inventoryTL.x - 4; int inventoryListY = inventoryTL.y + 2; int inventoryListH = inventoryBL.y - inventoryTL.y - 4; for (int i = 0; i < inventoryListH; i++) { int inventoryIndex = topInventoryIndex + i; //End of inventory if (inventoryIndex == currentEquipment.Count) { break; } //Create entry string EquipmentSlotInfo currentSlot = currentEquipment[inventoryIndex]; char selectionChar = (char)((int)'a' + i); string entryString = "(" + selectionChar.ToString() + ") " + StringEquivalent.EquipmentSlots[currentSlot.slotType] + ": "; if (currentSlot.equippedItem == null) { entryString += "Empty"; } else { entryString += currentSlot.equippedItem.SingleItemDescription; } //Print entry rootConsole.PrintLineRect(entryString, inventoryListX, inventoryListY + i, inventoryListW, 1, LineAlignment.Left); } }
/// <summary> /// Makes the window fullscreen if it is not, or normal if it is fullscreen. /// </summary> public static void ToggleFullscreen() { if (!Fullscreen) { RootConsole.SetWindowState(RLWindowState.Fullscreen); Fullscreen = true; } else { RootConsole.SetWindowState(RLWindowState.Normal); Fullscreen = false; } }
internal void PrintMessage(string message) { //Get screen handle RootConsole rootConsole = RootConsole.GetInstance(); //Update state lastMessage = message; //Clear message bar ClearMessageBar(); //Display new message rootConsole.PrintLineRect(message, msgDisplayTopLeft.x, msgDisplayTopLeft.y, width - msgDisplayTopLeft.x, msgDisplayNumLines, LineAlignment.Left); }
//Draw the current dungeon map and objects public void Draw() { //Get screen handle RootConsole rootConsole = RootConsole.GetInstance(); Dungeon dungeon = Game.Dungeon; Player player = dungeon.Player; //Clear screen rootConsole.Clear(); //Draw the map screen //Draw terrain DrawMap(dungeon.PCMap); //Draw fixed features DrawFeatures(dungeon.Features); //Draw items DrawItems(dungeon.Items); //Draw creatures DrawCreatures(dungeon.Monsters); //Draw PC Point PClocation = player.LocationMap; rootConsole.ForegroundColor = pcColor; rootConsole.PutChar(mapTopLeft.x + PClocation.x, mapTopLeft.y + PClocation.y, player.Representation); //Draw Stats DrawStats(dungeon.Player); //Draw any overlay screens if (displayInventory) { DrawInventory(); } else if (displayEquipment) { DrawEquipment(); } else if (displayEquipmentSelect) { DrawEquipmentSelect(); } }
//Draw a map only (useful for debugging) public void DrawMapDebugHighlight(Map map, int x1, int y1, int x2, int y2) { //Get screen handle RootConsole rootConsole = RootConsole.GetInstance(); //Clear screen rootConsole.Clear(); for (int i = 0; i < map.width; i++) { for (int j = 0; j < map.height; j++) { int screenX = mapTopLeft.x + i; int screenY = mapTopLeft.y + j; char screenChar = StringEquivalent.TerrainChars[map.mapSquares[i, j].Terrain]; Color drawColor = inFOVTerrainColor; if (i == x1 && j == y1) { drawColor = ColorPresets.Red; } if (i == x2 && j == y2) { drawColor = ColorPresets.Red; } rootConsole.ForegroundColor = drawColor; /* * if (!map.mapSquares[i, j].BlocksLight) * { * //In FOV * rootConsole.ForegroundColor = inFOVTerrainColor; * } * else * { * //Not in FOV but seen * rootConsole.ForegroundColor = seenNotInFOVTerrainColor; * }*/ rootConsole.PutChar(screenX, screenY, screenChar); } } //Flush the console rootConsole.Flush(); }
private void DrawItems(List <Item> itemList) { //Get screen handle RootConsole rootConsole = RootConsole.GetInstance(); //Set default colour rootConsole.ForegroundColor = itemColor; //Could consider storing here and sorting to give an accurate representation of multiple objects foreach (Item item in itemList) { //Don't draw items on creatures if (item.InInventory) { continue; } //Don't draw items on other levels if (item.LocationLevel != Game.Dungeon.Player.LocationLevel) { continue; } //Colour depending on FOV (for development) MapSquare itemSquare = Game.Dungeon.Levels[item.LocationLevel].mapSquares[item.LocationMap.x, item.LocationMap.y]; if (itemSquare.InPlayerFOV) { //In FOV rootConsole.ForegroundColor = inFOVTerrainColor; } else if (itemSquare.SeenByPlayer) { //Not in FOV but seen rootConsole.ForegroundColor = seenNotInFOVTerrainColor; } else { //Never in FOV rootConsole.ForegroundColor = neverSeenFOVTerrainColor; } rootConsole.PutChar(mapTopLeft.x + item.LocationMap.x, mapTopLeft.y + item.LocationMap.y, item.Representation); } }
public void DrawFOVDebug(int levelNo) { Map map = Game.Dungeon.Levels[levelNo]; TCODFov fov = Game.Dungeon.FOVs[levelNo]; //Get screen handle RootConsole rootConsole = RootConsole.GetInstance(); //Clear screen rootConsole.Clear(); for (int i = 0; i < map.width; i++) { for (int j = 0; j < map.height; j++) { int screenX = mapTopLeft.x + i; int screenY = mapTopLeft.y + j; bool trans; bool walkable; fov.GetCell(i, j, out trans, out walkable); Color drawColor = inFOVTerrainColor; if (walkable) { drawColor = inFOVTerrainColor; } else { drawColor = inMonsterFOVTerrainColor; } rootConsole.ForegroundColor = drawColor; char screenChar = StringEquivalent.TerrainChars[map.mapSquares[i, j].Terrain]; screenChar = '#'; rootConsole.PutChar(screenX, screenY, screenChar); rootConsole.Flush(); } } }
/// <summary> /// Display inventory overlay /// </summary> private void DrawInventory() { //Get screen handle RootConsole rootConsole = RootConsole.GetInstance(); //Draw frame rootConsole.DrawFrame(inventoryTL.x, inventoryTL.y, inventoryTR.x - inventoryTL.x + 1, inventoryBL.y - inventoryTL.y + 1, true); //Draw title rootConsole.PrintLineRect(inventoryTitle, (inventoryTL.x + inventoryTR.x) / 2, inventoryTL.y, inventoryTR.x - inventoryTL.x, 1, LineAlignment.Center); //Draw instructions rootConsole.PrintLineRect(inventoryInstructions, (inventoryTL.x + inventoryTR.x) / 2, inventoryBL.y, inventoryTR.x - inventoryTL.x, 1, LineAlignment.Center); //List the inventory //Inventory area is slightly reduced from frame int inventoryListX = inventoryTL.x + 2; int inventoryListW = inventoryTR.x - inventoryTL.x - 4; int inventoryListY = inventoryTL.y + 2; int inventoryListH = inventoryBL.y - inventoryTL.y - 4; List <InventoryListing> inventoryList = currentInventory.InventoryListing; for (int i = 0; i < inventoryListH; i++) { int inventoryIndex = topInventoryIndex + i; //End of inventory if (inventoryIndex == inventoryList.Count) { break; } //Create entry string char selectionChar = (char)((int)'a' + i); string entryString = "(" + selectionChar.ToString() + ") " + inventoryList[inventoryIndex].Description; //Print entry rootConsole.PrintLineRect(entryString, inventoryListX, inventoryListY + i, inventoryListW, 1, LineAlignment.Left); } }
private void DrawMap(Map map) { //Get screen handle RootConsole rootConsole = RootConsole.GetInstance(); for (int i = 0; i < map.width; i++) { for (int j = 0; j < map.height; j++) { int screenX = mapTopLeft.x + i; int screenY = mapTopLeft.y + j; char screenChar = StringEquivalent.TerrainChars[map.mapSquares[i, j].Terrain]; Color drawColor = inFOVTerrainColor; if (map.mapSquares[i, j].InPlayerFOV) { //In FOV rootConsole.ForegroundColor = inFOVTerrainColor; } else if (map.mapSquares[i, j].InMonsterFOV) { //Monster can see it rootConsole.ForegroundColor = inMonsterFOVTerrainColor; } else if (map.mapSquares[i, j].SeenByPlayer) { //Not in FOV but seen rootConsole.ForegroundColor = seenNotInFOVTerrainColor; } else { //Never in FOV rootConsole.ForegroundColor = neverSeenFOVTerrainColor; } rootConsole.PutChar(screenX, screenY, screenChar); } } }
private void DrawCreatures(List <Monster> creatureList) { //Get screen handle RootConsole rootConsole = RootConsole.GetInstance(); //Set default colour //rootConsole.ForegroundColor = creatureColor; foreach (Monster creature in creatureList) { //Not on this level if (creature.LocationLevel != Game.Dungeon.Player.LocationLevel) { continue; } //Colour depending on FOV (for development) MapSquare creatureSquare = Game.Dungeon.Levels[creature.LocationLevel].mapSquares[creature.LocationMap.x, creature.LocationMap.y]; if (creatureSquare.InPlayerFOV) { //In FOV rootConsole.ForegroundColor = inFOVTerrainColor; } else if (creatureSquare.SeenByPlayer) { //Not in FOV but seen rootConsole.ForegroundColor = seenNotInFOVTerrainColor; } else { //Never in FOV rootConsole.ForegroundColor = neverSeenFOVTerrainColor; } rootConsole.PutChar(mapTopLeft.x + creature.LocationMap.x, mapTopLeft.y + creature.LocationMap.y, creature.Representation); } }
private void DrawStats(Player player) { //Get screen handle RootConsole rootConsole = RootConsole.GetInstance(); string hitpointsString = "HP: " + player.Hitpoints.ToString(); string maxHitpointsString = "/" + player.MaxHitpoints.ToString(); rootConsole.PrintLine(hitpointsString, statsDisplayTopLeft.x + hitpointsOffset.x, statsDisplayTopLeft.y + hitpointsOffset.y, LineAlignment.Left); rootConsole.PrintLine(maxHitpointsString, statsDisplayTopLeft.x + maxHitpointsOffset.x, statsDisplayTopLeft.y + maxHitpointsOffset.y, LineAlignment.Left); string speedString = "Sp: " + player.Speed.ToString(); rootConsole.PrintLine(speedString, statsDisplayTopLeft.x + speedOffset.x, statsDisplayTopLeft.y + speedOffset.y, LineAlignment.Left); string ticksString = "Tk: " + Game.Dungeon.WorldClock.ToString(); rootConsole.PrintLine(ticksString, statsDisplayTopLeft.x + worldTickOffset.x, statsDisplayTopLeft.y + worldTickOffset.y, LineAlignment.Left); string levelString = "Level: " + Game.Dungeon.Player.LocationLevel.ToString(); rootConsole.PrintLine(levelString, statsDisplayTopLeft.x + levelOffset.x, statsDisplayTopLeft.y + levelOffset.y, LineAlignment.Left); }
private static void RealTimeLoopTest(RootConsole console) { TCODSystem.FPS = 25; console.Clear(); console.PrintLine("Keyboard Test Suite", 40, 5, LineAlignment.Center); console.PrintLine("Press 'F10' to enter Turn Based Test.", 40, 6, LineAlignment.Center); KeyPress pressedKey = Keyboard.CheckForKeypress(KeyPressType.Pressed); console.PrintLine("F2 Key Pressed = " + ((pressedKey.KeyCode == KeyCode.TCODK_F2 && pressedKey.Pressed) ? "Yes" : "No"), 10, 10, LineAlignment.Left); console.PrintLine("'d' to disable repeat keys", 10, 11, LineAlignment.Left); console.PrintLine("'e' to enable repeat keys", 10, 12, LineAlignment.Left); console.PrintLine(string.Format("Ctrl: {0}", pressedKey.LeftControl), 10, 13, LineAlignment.Left); console.PrintLine(string.Format("Ctrl Up: {0}", ctrlUpHit), 10, 14, LineAlignment.Left); if (pressedKey.KeyCode == KeyCode.TCODK_UP && pressedKey.Control) { ctrlUpHit = true; } console.Flush(); if (pressedKey.Character == 'd') { Keyboard.DisableRepeat(); } if (pressedKey.Character == 'e') { Keyboard.SetRepeat(0, 10); } if (pressedKey.KeyCode == KeyCode.TCODK_F10 && pressedKey.Pressed) { inRealTimeTest = false; } }
//Draw a map only (useful for debugging) public void DrawMapDebug(Map map) { //Get screen handle RootConsole rootConsole = RootConsole.GetInstance(); //Clear screen rootConsole.Clear(); for (int i = 0; i < map.width; i++) { for (int j = 0; j < map.height; j++) { int screenX = mapTopLeft.x + i; int screenY = mapTopLeft.y + j; char screenChar = StringEquivalent.TerrainChars[map.mapSquares[i, j].Terrain]; Color drawColor = inFOVTerrainColor; if (!map.mapSquares[i, j].BlocksLight) { //In FOV rootConsole.ForegroundColor = inFOVTerrainColor; } else { //Not in FOV but seen rootConsole.ForegroundColor = seenNotInFOVTerrainColor; } rootConsole.PutChar(screenX, screenY, screenChar); } } //Flush the console rootConsole.Flush(); }
public static void TestKeyboard() { RootConsole.Width = 80; RootConsole.Height = 50; RootConsole.WindowTitle = "Keyboard Tester"; RootConsole.Fullscreen = false; using (RootConsole console = RootConsole.GetInstance()) { KeyPress key = new KeyPress(); do { if (inRealTimeTest) { RealTimeLoopTest(console); } else { TurnBasedLoopTest(console, ref key); } System.Console.Out.WriteLine((char)key.Character); }while (key.Character != 'q' && !console.IsWindowClosed()); } }
public static void TestTCODFovTest() { int x = 1; int y = 1; RootConsole.Width = 80; RootConsole.Height = 50; RootConsole.WindowTitle = "FOV Tester"; RootConsole.Fullscreen = false; using (RootConsole console = RootConsole.GetInstance()) { console.Clear(); using (TCODFov fov = new TCODFov(5, 5)) { for (int i = 0; i < 5; ++i) //width { for (int j = 0; j < 5; ++j) //height { fov.SetCell(i, j, room[j, i] == '.', room[j, i] == '.'); } } KeyPress key; do { PaintFOVTest(console, x, y, fov); key = Keyboard.WaitForKeyPress(false); switch (key.KeyCode) { case KeyCode.TCODK_UP: if (room[y - 1, x] == '.') { y--; } break; case KeyCode.TCODK_DOWN: if (room[y + 1, x] == '.') { y++; } break; case KeyCode.TCODK_LEFT: if (room[y, x - 1] == '.') { x--; } break; case KeyCode.TCODK_RIGHT: if (room[y, x + 1] == '.') { x++; } break; } }while (key.Character != 'q' && !console.IsWindowClosed()); } } }
/// <summary> /// Kick off the entire system. Effectively like calling the run of the root console. /// </summary> public static void Run() => RootConsole.Run();
/// <summary> /// Render the map, with TL in map at mapOffset. Screenviewport is the screen viewport in tile dimensions (for now) /// </summary> /// <param name="mapToRender"></param> /// <param name="mapOffset"></param> /// <param name="screenViewport"></param> public static void RenderMap(TileEngine.TileMap mapToRender, Point mapOffset, Rectangle screenViewport) { //For libtcod //tileID = ascii char //flags = color //Get screen handle RootConsole rootConsole = RootConsole.GetInstance(); if (mapOffset.x >= mapToRender.Columns || mapOffset.y >= mapToRender.Rows) { throw new Exception("Point outside map " + mapOffset); } //Calculate visible area of map int maxColumn = mapOffset.x + screenViewport.Width - 1; int maxRow = mapOffset.y + screenViewport.Height - 1; if (maxColumn >= mapToRender.Columns) { maxColumn = mapToRender.Columns - 1; } if (maxRow >= mapToRender.Rows) { maxRow = mapToRender.Rows - 1; } //Render layers in order foreach (TileEngine.TileLayer layer in mapToRender.Layer) { for (int y = mapOffset.y; y <= maxRow; y++) { for (int x = mapOffset.x; x <= maxColumn; x++) { TileEngine.TileCell thisCell = layer.Rows[y].Columns[x]; if (thisCell.TileID == -1) { continue; } //Flags is a color for libtcod LibtcodColorFlags colorFlags = thisCell.TileFlag as LibtcodColorFlags; if (colorFlags == null) { rootConsole.ForegroundColor = ColorPresets.White; rootConsole.BackgroundColor = ColorPresets.Black; } else { if (colorFlags.BackgroundColor == null) { rootConsole.BackgroundColor = ColorPresets.Black; } else { rootConsole.BackgroundColor = colorFlags.BackgroundColor; } rootConsole.ForegroundColor = colorFlags.ForegroundColor; } //Id is the char char screenChar = Convert.ToChar(thisCell.TileID); //Screen coords int screenX = screenViewport.X + (x - mapOffset.x); int screenY = screenViewport.Y + (y - mapOffset.y); rootConsole.PutChar(screenX, screenY, screenChar); } } } //Reset colors - this matters for systems that don't use the tile renderer rootConsole.ForegroundColor = ColorPresets.White; rootConsole.BackgroundColor = ColorPresets.Black; }
private void PlayerNameScreen() { //Get screen handle RootConsole rootConsole = RootConsole.GetInstance(); //Clear screen rootConsole.Clear(); rootConsole.ForegroundColor = ColorPresets.Khaki; //Draw frame //Why xpos 2 here? rootConsole.DrawFrame(1, 4, Screen.Instance.Width - 2, Screen.Instance.Height - 9, true); //Draw preample preambleTL = new Point(5, 7); rootConsole.ForegroundColor = ColorPresets.MediumSeaGreen; int height; List <string> preamble = new List <string>(); preamble.Add("Welcome to TraumaRL v" + Game.Version + "! post-7DRL 2014"); preamble.Add("flend & shroomarts"); preamble.Add(""); preamble.AddRange(Utility.LoadTextFile("introPreamble", Screen.Instance.Width - 2 * preambleTL.x, out height)); for (int i = 0; i < preamble.Count; i++) { rootConsole.PrintLineRect(preamble[i], preambleTL.x, preambleTL.y + i, Screen.Instance.Width - 2 * preambleTL.x, 1, LineAlignment.Left); } int nameYCoord = 5 + preamble.Count + 2; Point nameIntro = new Point(5, nameYCoord); do { PlayerName = Screen.Instance.GetUserString("Name: Private ", nameIntro, 20); LogFile.Log.LogEntry("Player name: " + PlayerName); } while(PlayerName.Contains(" ") || PlayerName == ""); //Check if this save game exists. If so we can exit now and the game will be loaded /* * if (Utility.DoesSaveGameExist(PlayerName)) * { * return; * }*/ //Settings text int settingsYCoord = nameYCoord + 2; Point settingsTL = new Point(5, settingsYCoord); List <string> settingsText = Utility.LoadTextFile("introSettings", Screen.Instance.Width - 2 * preambleTL.x, out height); for (int i = 0; i < settingsText.Count; i++) { rootConsole.PrintLineRect(settingsText[i], settingsTL.x, settingsTL.y + i, Screen.Instance.Width - 2 * settingsTL.x, 1, LineAlignment.Left); } //Ask settings questions ShowMovies = Screen.Instance.YesNoQuestionWithFrame("Show logs on pickup (recommended)", 8, ColorPresets.Khaki, ColorPresets.MediumSeaGreen); rootConsole.Flush(); //Ask settings questions Difficulty = Screen.Instance.DifficultyQuestionWithFrame("Game difficulty: (E)asy / (M)edium / (H)ard?", 8, ColorPresets.Khaki, ColorPresets.MediumSeaGreen); rootConsole.PrintLineRect("Generating the station...", settingsTL.x, settingsTL.y + settingsText.Count + 5, Screen.Instance.Width - 2 * settingsTL.x, 1, LineAlignment.Left); }