public override void DrawNewFrame(TCODConsole screen) { if (m_enabled) { screen.printFrame(SelectedItemOffsetX, SelectedItemOffsetY, SelectedItemWidth, SelectedItemHeight, true); // Draw Header. screen.hline(SelectedItemOffsetX + 1, SelectedItemOffsetY + 2, SelectedItemWidth - 2); screen.putChar(SelectedItemOffsetX, SelectedItemOffsetY + 2, (int)TCODSpecialCharacter.TeeEast); screen.putChar(SelectedItemOffsetX + SelectedItemWidth - 1, SelectedItemOffsetY + 2, (int)TCODSpecialCharacter.TeeWest); screen.printEx(SelectedItemOffsetX + (SelectedItemWidth / 2), SelectedItemOffsetY + 1, TCODBackgroundFlag.Set, TCODAlignment.CenterAlignment, m_selectedItem.DisplayName); // Split in half for description. screen.vline(SelectedItemOffsetX + (SelectedItemWidth / 3), SelectedItemOffsetY + 2, SelectedItemHeight - 3); screen.putChar(SelectedItemOffsetX + (SelectedItemWidth / 3), SelectedItemOffsetY + 2, (int)TCODSpecialCharacter.TeeSouth); screen.putChar(SelectedItemOffsetX + (SelectedItemWidth / 3), SelectedItemOffsetY + SelectedItemHeight - 1, (int)TCODSpecialCharacter.TeeNorth); DrawItemInRightPane(screen); m_dialogColorHelper.SaveColors(screen); // Print option list. for (int i = 0; i < m_optionList.Count; ++i) { m_dialogColorHelper.SetColors(screen, i == m_cursorPosition, m_optionList[i].Enabled); screen.print(SelectedItemOffsetX + 2, SelectedItemOffsetY + 4 + (i * 2), m_optionList[i].Option); } m_dialogColorHelper.ResetColors(screen); } }
public void Draw(TCODConsole cons) { cons.setForegroundColor(TCODColor.white); for (int i = 0; i < MAP_WIDTH; i++) { for (int j = 0; j < MAP_HEIGHT; j++) { cons.putChar(i, j, this[i, j] ? '#' : '.'); } } _stair.Draw(cons); cons.putChar(StartPosX, StartPosY, '<'); foreach (Item item in _items) { item.Draw(cons); } foreach (Monster mons in _monsters) { mons.Draw(cons); } Player.Draw(cons); for (int i = 0; i < MAP_WIDTH; i++) { for (int j = 0; j < MAP_HEIGHT; j++) { /*int intens; * Light light = LightAt(i, j); * * if (light == null) * intens = 0; * else * { * intens = light.IntensityAt(i, j); * color = color.Multiply(light.Color); * } * float value = (float)intens / 20 + (Game.ShowWall ? 0.05f : 0f); * color.setValue(System.Math.Min(value, 1f));//*/ TCODColor color = cons.getCharForeground(i, j); TCODColor newCol = ColorAt(i, j); if (newCol.NotEqual(TCODColor.black)) { _known[i, j] = true; } color = color.Multiply(newCol); cons.setCharForeground(i, j, color); } } }
private static void RenderPlayConsole(Game gameInstance, TCODConsole console, TCODColor fogOfWarColour, Rectangle bounds) { console.clear(); console.setForegroundColor(ColorPresets.White); console.printFrame(0, 0, bounds.Width, bounds.Height, true); for (int y = 0; y < gameInstance.Terrain.Height; y++) { for (int x = 0; x < gameInstance.Terrain.Width; x++) { if (gameInstance.Player.VisibilityMap[x, y].WasSeen) { TCODColor lightColour = new TCODColor(gameInstance.LightMap[x, y].Colour.R, gameInstance.LightMap[x, y].Colour.G, gameInstance.LightMap[x, y].Colour.B); if (lightColour.getValue() < fogOfWarColour.getValue()) { lightColour = fogOfWarColour; } console.setForegroundColor(gameInstance.Player.VisibilityMap[x, y].IsVisible ? lightColour : fogOfWarColour); console.putChar(x + 1, y + 1, gameInstance.Terrain[x, y].Symbol); } } } console.setForegroundColor( new TCODColor(gameInstance.LightMap[gameInstance.Player.Location.Coordinate].Colour.R, gameInstance.LightMap[gameInstance.Player.Location.Coordinate].Colour.G, gameInstance.LightMap[gameInstance.Player.Location.Coordinate].Colour.B)); console.putChar(gameInstance.Player.Location.Coordinate.X + 1, gameInstance.Player.Location.Coordinate.Y + 1, '@'); foreach (IActor actor in gameInstance.Actors.Where(x => x != gameInstance.Player)) { if (gameInstance.Player.VisibilityMap[actor.Location.Coordinate].IsVisible) { TCODColor lightColour = new TCODColor(gameInstance.LightMap[actor.Location.Coordinate].Colour.R, gameInstance.LightMap[actor.Location.Coordinate].Colour.G, gameInstance.LightMap[actor.Location.Coordinate].Colour.B); if (lightColour.getValue() < fogOfWarColour.getValue()) { lightColour = fogOfWarColour; } console.setForegroundColor(lightColour); console.putChar(actor.Location.Coordinate.X + 1, actor.Location.Coordinate.Y + 1, actor.Race.Symbol); } } }
public static void hline(this TCODConsole console, int x, int y, int l, char c) { for (int i = 0; i < l; ++i) { console.putChar(x + i, y, c); } }
public override void DrawNewFrame(TCODConsole screen) { if (m_enabled) { int lowX = m_cursorPosition.X - (MapDrawnWidth / 2); int lowY = m_cursorPosition.Y - (MapDrawnHeight / 2); for (int i = lowX; i < lowX + MapDrawnWidth; ++i) { for (int j = lowY; j < lowY + MapDrawnHeight; ++j) { int screenPlacementX = m_mapCorner.X + i + 1; int screenPlacementY = m_mapCorner.Y + j + 1; if (IsDrawableTile(screenPlacementX, screenPlacementY)) { if (m_map.IsPointOnMap(new Point(i, j))) { TileVisibility isVisible = m_tileVisibility[i, j]; if (isVisible == TileVisibility.Unvisited) { // If it's unvisisted, nuke the square completed black screen.setCharBackground(screenPlacementX, screenPlacementY, ColorPresets.Black); screen.setCharForeground(screenPlacementX, screenPlacementY, ColorPresets.Black); screen.putChar(screenPlacementX, screenPlacementY, ' '); } } } } } } }
public void Draw(TCODConsole cons) { cons.putChar(PosX, PosY, _tile); cons.setCharForeground(PosX, PosY, Color); }
private void DrawTabBar(TCODConsole screen) { const int HorizontalTabOffset = 2; screen.rect(UpperLeft + 1, UpperLeft + 1, SkillTreeWidth - 2, HorizontalTabOffset - 1, true); screen.putChar(UpperLeft, UpperLeft + HorizontalTabOffset, (int)TCODSpecialCharacter.TeeEast); screen.putChar(UpperLeft + SkillTreeWidth - 1, UpperLeft + HorizontalTabOffset, (int)TCODSpecialCharacter.TeeWest); screen.hline(UpperLeft + 1, UpperLeft + HorizontalTabOffset, SkillTreeWidth - 2); int x = UpperLeft + 2; int y = UpperLeft + HorizontalTabOffset - 1; foreach (string name in m_skillTreeTabs.Keys) { int xOffset = name == "Water" ? 1 : 0; screen.print(x + xOffset, y, name); x += name.Length + 1; if (name != "Water") { screen.putChar(x, y, (int)TCODSpecialCharacter.VertLine); // This is a bit of a hack. We don't want to overwrite the color'ed background title of the frame, so we check first // This can break if libtcod changes that background title color if (!screen.getCharBackground(x, y - 1).Equal(new TCODColor(211, 211, 211))) screen.putChar(x, y - 1, (int)TCODSpecialCharacter.TeeSouth); screen.putChar(x, y + 1, (int)TCODSpecialCharacter.TeeNorth); } x += 2; if (m_currentTabName == name) { int lengthReductionToDueTee = name == "Water" ? 0 : 2; for (int i = x - 4 - name.Length; i < x - lengthReductionToDueTee; i++) { screen.setCharBackground(i, y, TCODColor.grey); } } } }
private void DrawSkillPointTotalFrame(TCODConsole screen) { screen.printFrame(5, 48, 16, 7, true); screen.putChar(5, 48, (int)TCODSpecialCharacter.TeeEast); screen.putChar(20, 54, (int)TCODSpecialCharacter.TeeNorth); screen.print(6, 49, "Skill Points:"); screen.print(6, 51, "SP Earned:" + m_engine.Player.SkillPoints.ToString()); int selectedSkillCost = NewlySelectedSkills.Sum(x => x.Cost); screen.print(6, 52, "SP Spent: " + selectedSkillCost); screen.print(6, 53, "SP Left: " + (m_engine.Player.SkillPoints - selectedSkillCost).ToString()); }
private void DrawPoint(TCODConsole screen, Point p, char c) { Point screenPosition = new Point(m_mapUpCorner.X + p.X + 1, m_mapUpCorner.Y + p.Y + 1); screen.putChar(screenPosition.X, screenPosition.Y, c, TCODBackgroundFlag.None); screen.setCharForeground(screenPosition.X, screenPosition.Y, m_color); }
public int Run(string[] args) { fillSampleList(); int curSample = 0; // index of the current sample bool first = true; // first time we render a sample TCODKey key = new TCODKey(); string font = "celtic_garamond_10x10_gs_tc.png"; int numberCharsHorz = 32; int numberCharsVert = 8; int fullscreenWidth = 0; int fullscreenHeight = 0; bool fullscreen = false; bool credits = false; TCODFontFlags flags = TCODFontFlags.Grayscale | TCODFontFlags.LayoutTCOD; TCODFontFlags newFlags = 0; for (int i = 1; i < args.Length; i++) { if (args[i] == "-font" && ArgsRemaining(args, i, 1)) { i++; font = args[i]; } else if (args[i] == "-font-char-numberRows" && ArgsRemaining(args, i, 2)) { i++; numberCharsHorz = System.Convert.ToInt32(args[i]); i++; numberCharsVert = System.Convert.ToInt32(args[i]); } else if (args[i] == "-fullscreen-resolution" && ArgsRemaining(args, i, 2)) { i++; fullscreenWidth = System.Convert.ToInt32(args[i]); i++; fullscreenHeight = System.Convert.ToInt32(args[i]); } else if (args[i] == "-fullscreen") { fullscreen = true; } else if (args[i] == "-font-in-row") { flags = 0; newFlags |= TCODFontFlags.LayoutAsciiInRow; } else if (args[i] == "-font-greyscale") { flags = 0; newFlags |= TCODFontFlags.Grayscale; } else if (args[i] == "-font-tcod") { flags = 0; newFlags |= TCODFontFlags.LayoutTCOD; } else if (args[i] == "-help") { System.Console.Out.WriteLine("options : \n"); System.Console.Out.WriteLine("-font <filename> : use a custom font\n"); System.Console.Out.WriteLine("-font-char-size <char_width> <char_height> : size of the custom font's characters\n"); System.Console.Out.WriteLine("-font-in-row : the font layout is in row instead of columns\n"); System.Console.Out.WriteLine("-font-tcod : the font uses TCOD layout instead of ASCII\n"); System.Console.Out.WriteLine("-font-greyscale : antialiased font using greyscale bitmap\n"); System.Console.Out.WriteLine("-fullscreen : start in fullscreen\n"); System.Console.Out.WriteLine("-fullscreen-resolution <screen_width> <screen_height> : force fullscreen resolution\n"); return 0; } } if (flags == 0) flags = newFlags; if (fullscreenWidth > 0) TCODSystem.forceFullscreenResolution(fullscreenWidth, fullscreenHeight); TCODConsole.setCustomFont(font, (int)flags, numberCharsHorz, numberCharsVert); TCODConsole.initRoot(80, 50, "tcodlib C# sample", fullscreen, TCODRendererType.SDL); rootConsole = TCODConsole.root; sampleConsole = new TCODConsole(SAMPLE_SCREEN_WIDTH, SAMPLE_SCREEN_HEIGHT); setupStaticData(); rootConsole.setBackgroundFlag(TCODBackgroundFlag.Set); rootConsole.setAlignment(TCODAlignment.LeftAlignment); do { rootConsole.clear(); if (!credits) credits = TCODConsole.renderCredits(60, 42, false); for (int i = 0; i < sampleList.Length; i++) { if (i == curSample) { // set colors for currently selected sample rootConsole.setForegroundColor(TCODColor.white); rootConsole.setBackgroundColor(TCODColor.blue); } else { // set colors for other samples rootConsole.setForegroundColor(TCODColor.grey); rootConsole.setBackgroundColor(TCODColor.black); } rootConsole.print(2, 45 - sampleList.Length + i, sampleList[i].name); } rootConsole.setForegroundColor(TCODColor.grey); rootConsole.setBackgroundColor(TCODColor.black); rootConsole.printEx(79, 46, TCODBackgroundFlag.Set, TCODAlignment.RightAlignment, "last frame : " + ((int)(TCODSystem.getLastFrameLength() * 1000)).ToString() + " ms ( " + TCODSystem.getFps() + "fps)"); rootConsole.printEx(79, 47, TCODBackgroundFlag.Set, TCODAlignment.RightAlignment, "elapsed : " + TCODSystem.getElapsedMilli() + "ms " + (TCODSystem.getElapsedSeconds().ToString("0.00")) + "s"); rootConsole.putChar(2, 47, (char)TCODSpecialCharacter.ArrowNorth); rootConsole.putChar(3, 47, (char)TCODSpecialCharacter.ArrowSouth); rootConsole.print(4, 47, " : select a sample"); rootConsole.print(2, 48, "ALT-ENTER : switch to " + (TCODConsole.isFullscreen() ? "windowed mode " : "fullscreen mode")); sampleList[curSample].render(first, key); first = false; TCODConsole.blit(sampleConsole, 0, 0, SAMPLE_SCREEN_WIDTH, SAMPLE_SCREEN_HEIGHT, rootConsole, SAMPLE_SCREEN_X, SAMPLE_SCREEN_Y); TCODConsole.flush(); key = TCODConsole.checkForKeypress((int)TCODKeyStatus.KeyPressed); if (key.KeyCode == TCODKeyCode.Down) { // down arrow : next sample curSample = (curSample + 1) % sampleList.Length; first = true; } else if (key.KeyCode == TCODKeyCode.Up) { // up arrow : previous sample curSample--; if (curSample < 0) curSample = sampleList.Length - 1; first = true; } else if (key.KeyCode == TCODKeyCode.Enter && (key.LeftAlt || key.RightAlt)) { // ALT-ENTER : switch fullscreen TCODConsole.setFullscreen(!TCODConsole.isFullscreen()); } else if (key.KeyCode == TCODKeyCode.F1) { System.Console.Out.WriteLine("key.pressed" + " " + key.LeftAlt + " " + key.LeftControl + " " + key.RightAlt + " " + key.RightControl + " " + key.Shift); } } while (!TCODConsole.isWindowClosed()); return 0; }
public void SetCharacter(int x, int y, int character) { _console.putChar(x, y, character); }
private static void DrawThingIfMultipleSpecialSymbol(Point mapUpCorner, Point position, TCODConsole screen, char symbol, char multipleSymbol) { int screenPlacementX = mapUpCorner.X + position.X + 1; int screenPlacementY = mapUpCorner.Y + position.Y + 1; if (IsDrawableTile(screenPlacementX, screenPlacementY)) { char currentChar = (char)screen.getChar(screenPlacementX, screenPlacementY); // If we already have one of those, or the multipleSymbol, draw the multipleSymbole, else draw normal. if (currentChar == symbol || currentChar == multipleSymbol) screen.putChar(screenPlacementX, screenPlacementY, multipleSymbol, TCODBackgroundFlag.None); else screen.putChar(screenPlacementX, screenPlacementY, symbol, TCODBackgroundFlag.None); } }
private static void DrawThing(Point mapUpCorner, Point position, TCODConsole screen, char symbol) { int screenPlacementX = mapUpCorner.X + position.X + 1; int screenPlacementY = mapUpCorner.Y + position.Y + 1; if (IsDrawableTile(screenPlacementX, screenPlacementY)) screen.putChar(screenPlacementX, screenPlacementY, symbol, TCODBackgroundFlag.None); }
public void Draw(TCODConsole cons) { cons.setForegroundColor(TCODColor.white); for (int i = 0; i < MAP_WIDTH; i++) for (int j = 0; j < MAP_HEIGHT; j++) { cons.putChar(i, j, this[i, j] ? '#' : '.'); } _stair.Draw(cons); cons.putChar(StartPosX, StartPosY, '<'); foreach (Item item in _items) { item.Draw(cons); } foreach (Monster mons in _monsters) { mons.Draw(cons); } Player.Draw(cons); for (int i = 0; i < MAP_WIDTH; i++) for (int j = 0; j < MAP_HEIGHT; j++) { /*int intens; Light light = LightAt(i, j); if (light == null) intens = 0; else { intens = light.IntensityAt(i, j); color = color.Multiply(light.Color); } float value = (float)intens / 20 + (Game.ShowWall ? 0.05f : 0f); color.setValue(System.Math.Min(value, 1f));//*/ TCODColor color = cons.getCharForeground(i, j); TCODColor newCol = ColorAt(i, j); if (newCol.NotEqual(TCODColor.black)) _known[i, j] = true; color = color.Multiply(newCol); cons.setCharForeground(i, j, color); } }
public void Draw(TCODConsole cons) { cons.putChar(PosX, PosY, _tile); cons.setCharForeground(PosX, PosY, _color); }
public static void DrawCharacter(IntVector2 pos, char c) { displayConsole.putChar(pos.X, pos.Y, c); }