// ///////////////////////////////////////////////////////////////////////////////// // ///////////////////////////////////////////////////////////////////////////////// /// <summary> /// Blits this Canvas to the screen at the given coordinates and using the provided /// foreground and background alpha values. /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <param name="fgAlpha"></param> /// <param name="bgAlpha"></param> public void ToScreenAlpha(int x, int y, float fgAlpha, float bgAlpha) { int maxWidth = Application.ScreenSize.Width - x; int maxHeight = Application.ScreenSize.Height - y; if (maxWidth < 1 || maxHeight < 1) { return; } int finalWidth = Size.Width; int finalHeight = Size.Height; if (finalWidth > maxWidth) { finalWidth = maxWidth; } if (finalHeight > maxHeight) { finalHeight = maxHeight; } Size finalSize = new Size(finalWidth, finalHeight); TCODConsole.blit(Console, 0, 0, finalSize.Width, finalSize.Height, TCODConsole.root, x, y, fgAlpha, bgAlpha); }
public override void Render(float deltaTime) { TCODConsole.root.setForegroundColor(Game.Settings.UiForeground); TCODConsole.root.setBackgroundColor(backgroundColor); TCODConsole.root.setBackgroundFlag(TCODBackgroundFlag.Set); TCODConsole.root.clear(); // Render stars and clouds starfield.ForEach(s => s.Render(backgroundColor)); clouds.ForEach(c => c.Render()); // Render buildings. TCODConsole.blit(background, 0, 0, background.getWidth(), background.getHeight(), TCODConsole.root, 0, 0); // Render credits. if (!creditsDoneRendering) { creditsDoneRendering = TCODConsole.renderCredits(1, TCODConsole.root.getHeight() - 3, true); } // Reset colors and render menu TCODConsole.root.setForegroundColor(Game.Settings.UiForeground); TCODConsole.root.setBackgroundColor(Game.Settings.UiBackground); TCODConsole.root.printFrame(9, 13, 15, 13, true); TCODConsole.root.print(11, 15, "[N]ew Game"); TCODConsole.root.print(11, 17, "[L]oad Game"); TCODConsole.root.print(11, 19, "[O]ptions"); TCODConsole.root.print(11, 21, "[C]redits"); TCODConsole.root.print(11, 23, "[Q]uit"); }
private static void RenderAllConsoles(Game game, TCODConsole rootConsole, TCODConsole playConsole, TCODColor fogOfWarColour, TCODConsole playerConsole, TCODConsole competitorConsole, TCODConsole eventsConsole, Rectangle playBounds, Rectangle playerBounds, Rectangle competitorBounds, Rectangle eventBounds) { rootConsole.clear(); rootConsole.setForegroundColor(ColorPresets.White); rootConsole.setBackgroundColor(ColorPresets.Black); RenderPlayConsole(game, playConsole, fogOfWarColour, playBounds); RenderPlayerConsole(game.Player, playerConsole, playerBounds); //RenderThreatConsole(game.Player, game.Actors, threatConsole, threatBounds); RenderCompetitorConsole(game, competitorConsole, competitorBounds); RenderEventsConsole(game, eventsConsole, eventBounds); TCODConsole.blit(playConsole, 0, 0, playBounds.Width, playBounds.Height, rootConsole, playBounds.X, playBounds.Y); TCODConsole.blit(playerConsole, 0, 0, playerBounds.Width, playerBounds.Height, rootConsole, playerBounds.X, playerBounds.Y); TCODConsole.blit(competitorConsole, 0, 0, competitorBounds.Width, competitorBounds.Height, rootConsole, competitorBounds.X, competitorBounds.Y); TCODConsole.blit(eventsConsole, 0, 0, eventBounds.Width, eventBounds.Height, rootConsole, eventBounds.X, eventBounds.Y); //playConsole.Blit(0, 0, playBounds.Width, playBounds.Height, rootConsole, playBounds.X, playBounds.Y); //playerConsole.Blit(0, 0, playerBounds.Width, playerBounds.Height, rootConsole, playerBounds.X, // playerBounds.Y); //competitorConsole.Blit(0, 0, competitorBounds.Width, competitorBounds.Height, rootConsole, // competitorBounds.X, competitorBounds.Y); //eventsConsole.Blit(0, 0, eventBounds.Width, eventBounds.Height, rootConsole, eventBounds.X, eventBounds.Y); }
/// <summary> /// Renders the games HUD elemnts /// Should be called last so that it blits consoles on top of game content if need be /// </summary> private void RenderGameHUD(TCODConsole targetConsole, Camera camera, Vector2 screenCenter) { HUD hud = engine.playerController.hud; // Allow the generalized HUD to render hud.Draw(targetConsole, camera); TCODConsole hudConsole; for (int i = 0; i < hud.windows.Count; i++) { if (!hud.windows[i].isVisible) { continue; } hudConsole = hud.windows[i].GetUpdatedConsole(); if (!hud.windows[i].isVisible) { continue; } TCODConsole.blit(hudConsole, 0, 0, hudConsole.getWidth(), hudConsole.getHeight(), // source targetConsole, hud.windows[i].origin.X, hud.windows[i].origin.Y, 1); // destination } // draw drag drop data if there is any var dragdrop = hud.dragdrop; if (dragdrop.active) { DrawRect(targetConsole, dragdrop.x, dragdrop.y, dragdrop.text.Length + 1, Window.elementDark); DrawText(targetConsole, dragdrop.x + 1, dragdrop.y, dragdrop.text, Constants.COL_FRIENDLY); DrawText(targetConsole, dragdrop.x, dragdrop.y, "" + (char)(25), TCODColor.white); } }
public void render() { map.render(); TCODConsole.blit(lightMapConsole, 0, 0, lightMapConsole.getWidth(), lightMapConsole.getHeight(), TCODConsole.root, 0, 0, 0.7F, 0.7F); lightMapConsole.clear(); actorHandler.render(); map.updateDynFov = false; map.updateFov = false; }
public void Draw(TCODConsole cons) { TCODConsole temp = new TCODConsole(50, 30); int x = 2; foreach (int i in _taken.Keys) { temp.print(2, x, String.Format("{0} - {1}", (char)(i + 97), _items[i].Item)); x++; } TCODConsole.blit(temp, 0, 0, 50, x + 2, cons, 0, 0); }
public override void render(bool insight) { if (owner != null) { Map m = map; lightmap.clear(); int ox = owner.x - m.offsetX + mapx; int oy = owner.y - m.offsetY + mapy; if (ox >= -mapx && ox < width && oy >= -mapy && oy < height) { if (owner.x >= 0 && owner.x < m.tiles.GetLength(0) && owner.y >= 0 && owner.y < m.tiles.GetLength(1)) { for (int x = m.renderX; x < m.renderWidth + m.renderX; x++) { for (int y = m.renderY; y < m.renderHeight + m.renderY; y++) { int mx = x + m.offsetX; int my = y + m.offsetY; if (isInFov(mx, my, 0, m) && (m.isExplored(mx, my) || m.showAllTiles)) { try { double distance = Math.Sqrt(Math.Pow(owner.x - (mx), 2) + Math.Pow(owner.y - (my), 2)); if (distance <= fovRadius) { byte c = (byte)(strenght - (((float)strenght / ((float)fovRadius)) * ((byte)distance))); TCODColor color = new TCODColor(c, c, c); TCODColor newColor = color.Plus(level.lightMapConsole.getCharBackground(x, y)); lightmap.setCharBackground(x, y, newColor, TCODBackgroundFlag.Set); } } catch (Exception e) { Console.WriteLine(e.Message); throw new Exception(e.Message); } } else { //lightmap.setCharBackground(x, y, TCODColor.black, TCODBackgroundFlag.Set); } } } TCODConsole.blit(lightmap, 0, 0, lightmap.getWidth(), lightmap.getHeight(), level.lightMapConsole, 0, 0, (float)strenght / (255 * 2), (float)strenght / (255 * 2)); } } } }
public void Draw() { int lightLenght = (int)((1 - _player.Light.Used) * 80); _root.setBackgroundColor(TCODColor.black); _root.setForegroundColor(TCODColor.white); Map.Draw(_mapConsole); _messages.Draw(); TCODConsole.blit(_mapConsole, 0, 0, 80, 50, _root, 0, 1); TCODConsole.blit(_messages.Console, 0, 0, 80, 10, _root, 0, 51); _root.hline(0, 0, 80, TCODBackgroundFlag.Set); _root.setBackgroundColor(TCODColor.amber); _root.setForegroundColor(TCODColor.amber); _root.hline(0, 0, lightLenght, TCODBackgroundFlag.Set); TCODConsole.flush(); }
public void draw(bool transparency, bool direct) { if (direct) { for (int j = 0; j < height; j++) { for (int i = 0; i < width; i++) { Tile temp = glyphs[i, j]; if (transparency) { TCODConsole.root.putCharEx(i, j, temp.glyph, temp.foreGround.GetTCODColor(TCODConsole.root.getCharForeground(i - x, j - y)), temp.backGround.GetTCODColor(TCODConsole.root.getCharBackground(i - x, j - y))); } else { TCODConsole.root.putCharEx(i, j, temp.glyph, temp.foreGround.GetTCODColor(), temp.backGround.GetTCODColor()); } } } } else { for (int j = 0; j < height; j++) { for (int i = 0; i < width; i++) { Tile temp = glyphs[i, j]; if (transparency) { terminal.putCharEx(i, j, temp.glyph, temp.foreGround.GetTCODColor(TCODConsole.root.getCharForeground(i - x, j - y)), temp.backGround.GetTCODColor(TCODConsole.root.getCharBackground(i - x, j - y))); } else { terminal.putCharEx(i, j, temp.glyph, temp.foreGround.GetTCODColor(), temp.backGround.GetTCODColor()); } } } TCODConsole.blit(terminal, 0, 0, terminal.getWidth(), terminal.getHeight(), TCODConsole.root, x, y); } }
// ///////////////////////////////////////////////////////////////////////////////// /// <summary> /// Scrolls this Canvas by the given delta x and y amounts. /// </summary> /// <param name="deltaX"></param> /// <param name="deltaY"></param> public void Scroll(int deltaX, int deltaY) { Size srcSize = new Size(this.Size.Width - Math.Abs(deltaX), this.Size.Height - Math.Abs(deltaY)); using (Canvas tmpCanvas = new Canvas(srcSize)) { int srcX = 0; int srcY = 0; int destX = 0; int destY = 0; if (deltaX < 0) { srcX = -deltaX; } if (deltaX > 0) { destX = deltaX; } if (deltaY < 0) { srcY = -deltaY; } if (deltaY > 0) { destY = deltaY; } TCODConsole.blit(this.Console, srcX, srcY, srcSize.Width, srcSize.Height, tmpCanvas.Console, destX, destY); this.Clear(); this.Blit(tmpCanvas, 0, 0); } }
// ///////////////////////////////////////////////////////////////////////////////// // ///////////////////////////////////////////////////////////////////////////////// /// <summary> /// Blits the provided Canvas to this Canvas at the specified position /// </summary> /// <param name="source"></param> /// <param name="x"></param> /// <param name="y"></param> /// <exception cref="System.ArgumentNullException">Thrown when <paramref name="source"/> is null</exception> public void Blit(Canvas source, int x, int y) { if (source == null) { throw new ArgumentNullException("source"); } int maxWidth = Application.ScreenSize.Width - x; int maxHeight = Application.ScreenSize.Height - y; if (maxWidth < 1 || maxHeight < 1) { return; } int finalWidth = source.Size.Width; int finalHeight = source.Size.Height; if (finalWidth > maxWidth) { finalWidth = maxWidth; } if (finalHeight > maxHeight) { finalHeight = maxHeight; } Size finalSize = new Size(finalWidth, finalHeight); TCODConsole.blit(source.Console, 0, 0, finalSize.Width, finalSize.Height, this.Console, x, y); }
public void DrawMenu(TCODConsole targetConsole, WindowGameMenu menu) { if (!menu.isVisible) { return; } // ask for sub menus, this is completely optional on the part of the menu List <Window> subMenus = menu.GetSubMenus(); TCODConsole console = menu.GetUpdatedConsole(); TCODConsole.blit(console, 0, 0, console.getWidth(), console.getHeight(), // source targetConsole, menu.origin.X, menu.origin.Y, 1); // handle dragdrops var dragdrop = menu.dragdrop; if (dragdrop.active) { DrawRect(targetConsole, dragdrop.x, dragdrop.y, dragdrop.text.Length + 1, Window.elementDark); DrawText(targetConsole, dragdrop.x + 1, dragdrop.y, dragdrop.text, Constants.COL_FRIENDLY); DrawText(targetConsole, dragdrop.x, dragdrop.y, "" + (char)(25), TCODColor.white); } // sub menus (if any) foreach (Window sub in subMenus) { if (!sub.isVisible) { continue; } console = sub.GetUpdatedConsole(); TCODConsole.blit(console, 0, 0, console.getWidth(), console.getHeight(), // source targetConsole, sub.origin.X, sub.origin.Y, 1); } }
public void Blit(IRConsole src, Rectangle srcRect, int dstX, int dstY, float fgAlpha = 1, float bgAlpha = 1) { TCODConsole.blit(src.UnderlyingConsole, srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height, _console, dstX, dstY, fgAlpha, bgAlpha); }
public override void render(bool insight) { if (!insight && owner != null) { Map m = map; int ox = owner.x - m.offsetX; int oy = owner.y - m.offsetY; if (ox >= -fovRadius && ox < m.renderWidth + fovRadius && oy >= -fovRadius && oy < m.renderHeight + fovRadius) { if (owner.x >= 0 && owner.x < m.tiles.GetLength(0) && owner.y >= 0 && owner.y < m.tiles.GetLength(1)) { lightmap.clear(); int OFX = m.renderX - ox + mapx <= 0 ? 0 : m.renderX - ox + mapx; int OFY = m.renderY - oy + mapy <= 0 ? 0 : m.renderY - oy + mapy; int OFW = ox + width - m.renderWidth <= 0 ? 0 : ox + width - m.renderWidth; int OFH = oy + height - m.renderHeight <= 0 ? 0 : oy + height - m.renderHeight; for (int x = -mapx + OFX; x < width - OFW; x++) { for (int y = -mapy + OFY; y < height - OFH; y++) { int mx = owner.x + x; int my = owner.y + y; double distance = Math.Sqrt(Math.Pow(owner.x - (mx), 2) + Math.Pow(owner.y - (my), 2)); if (distance <= fovRadius) { if ((m.isExplored(mx, my) || m.showAllTiles)) { try { byte rs = (byte)((strenght * color.Red) / 255); byte gs = (byte)((strenght * color.Green) / 255); byte bs = (byte)((strenght * color.Blue) / 255); byte r = (byte)(rs - (((float)rs / ((float)fovRadius)) * ((byte)distance))); byte g = (byte)(gs - (((float)gs / ((float)fovRadius)) * ((byte)distance))); byte b = (byte)(bs - (((float)bs / ((float)fovRadius)) * ((byte)distance))); TCODColor lcolor = level.lightMapConsole.getCharBackground(mx - m.offsetX, my - m.offsetY); if ((int)r + (int)lcolor.Red < 255) { r += lcolor.Red; } else { r = 255; } //r += (byte)(lcolor.Red - ((int)r + (int)lcolor.Red - 255)); if ((int)g + (int)lcolor.Green < 255) { g += lcolor.Green; } else { g = 255; } //g += (byte)(lcolor.Green - ((int)g + (int)lcolor.Green - 255)); if ((int)b + (int)lcolor.Blue < 255) { b += lcolor.Blue; } else { b = 255; } //b += (byte)(lcolor.Blue - ((int)b + (int)lcolor.Blue - 255)); byte tile = calculatedMaps[x + mapx, y + mapy, 0]; /* * if (tile == 2) * { * if (r > (byte)(rs / 3)) * r -= (byte)(rs / 3); * if (g > (byte)(gs / 3)) * g -= (byte)(gs / 3); * if (b > (byte)(bs / 3)) * b -= (byte)(bs / 3); * } */ TCODColor col = new TCODColor(r, g, b); if (tile != 0) { lightmap.setCharBackground(mx - m.offsetX, my - m.offsetY, col, TCODBackgroundFlag.Set); } else if (false) { tile = calculatedMaps[x + mapx, y + mapy, 1]; if (tile != 0) { if (r > (byte)(rs / 3)) { r -= (byte)(rs / 3); } if (g > (byte)(gs / 3)) { g -= (byte)(gs / 3); } if (b > (byte)(bs / 3)) { b -= (byte)(bs / 3); } if (tile == 2) { if (r > (byte)(rs / 5)) { r -= (byte)(rs / 5); } if (g > (byte)(gs / 5)) { g -= (byte)(gs / 5); } if (b > (byte)(bs / 5)) { b -= (byte)(bs / 5); } } col = new TCODColor(r, g, b); lightmap.setCharBackground(mx - m.offsetX, my - m.offsetY, col, TCODBackgroundFlag.Set); } } } catch (Exception e) { Console.WriteLine(e.Message); throw new Exception(e.Message); } } } else { //if (lightmap.getCharBackground(mx - m.offsetX, my - m.offsetY)!= TCODColor.black) //lightmap.setCharBackground(mx - m.offsetX, my - m.offsetY, TCODColor.black, TCODBackgroundFlag.Set); } } } TCODConsole.blit(lightmap, 0, 0, lightmap.getWidth(), lightmap.getHeight(), level.lightMapConsole, 0, 0, (float)strenght / (255 * 2), (float)strenght / (255 * 2)); } } } }