| 71 | }; |
| 72 | |
| 73 | static void paint_screen(const PaintCtx & ctx, const unordered_set<df::coord> & targets, |
| 74 | bool show_hidden, std::function<bool(const df::coord & pos)> get_can_walk) |
| 75 | { |
| 76 | auto dims = Gui::getDwarfmodeViewDims().map(); |
| 77 | for (int y = dims.first.y; y <= dims.second.y; ++y) { |
| 78 | for (int x = dims.first.x; x <= dims.second.x; ++x) { |
| 79 | df::coord map_pos(*window_x + x, *window_y + y, *window_z); |
| 80 | |
| 81 | if (!Maps::isValidTilePos(map_pos)) |
| 82 | continue; |
| 83 | |
| 84 | if (!show_hidden && !Maps::isTileVisible(map_pos)) { |
| 85 | TRACE(log).print("skipping hidden tile\n"); |
| 86 | continue; |
| 87 | } |
| 88 | |
| 89 | DEBUG(log).print("scanning map tile at offset {}, {}\n", x, y); |
| 90 | Screen::Pen cur_tile = Screen::readTile(x, y, true); |
| 91 | DEBUG(log).print("tile data: ch={}, fg={}, bg={}, bold={}\n", |
| 92 | cur_tile.ch, cur_tile.fg, cur_tile.bg, cur_tile.bold ? "true" : "false"); |
| 93 | DEBUG(log).print("tile data: tile={}, tile_mode={}, tile_fg={}, tile_bg={}\n", |
| 94 | cur_tile.tile, static_cast<int>(cur_tile.tile_mode), cur_tile.tile_fg, cur_tile.tile_bg); |
| 95 | |
| 96 | if (!cur_tile.valid()) { |
| 97 | DEBUG(log).print("cannot read tile at offset {}, {}\n", x, y); |
| 98 | continue; |
| 99 | } |
| 100 | |
| 101 | bool can_walk = get_can_walk(map_pos); |
| 102 | DEBUG(log).print("tile is {}walkable at offset {}, {}\n", |
| 103 | can_walk ? "" : "not ", x, y); |
| 104 | |
| 105 | if (ctx.use_graphics) { |
| 106 | if (targets.contains(map_pos)) { |
| 107 | cur_tile.tile = ctx.selected_tile_texpos; |
| 108 | } else{ |
| 109 | cur_tile.tile = can_walk ? |
| 110 | ctx.pathable_tile_texpos : ctx.unpathable_tile_texpos; |
| 111 | } |
| 112 | } else { |
| 113 | int color = can_walk ? COLOR_GREEN : COLOR_RED; |
| 114 | if (targets.contains(map_pos)) |
| 115 | color = COLOR_CYAN; |
| 116 | if (cur_tile.fg && cur_tile.ch != ' ') { |
| 117 | cur_tile.fg = color; |
| 118 | cur_tile.bg = 0; |
| 119 | } else { |
| 120 | cur_tile.fg = 0; |
| 121 | cur_tile.bg = color; |
| 122 | } |
| 123 | |
| 124 | cur_tile.bold = false; |
| 125 | |
| 126 | if (cur_tile.tile) |
| 127 | cur_tile.tile_mode = Screen::Pen::CharColor; |
| 128 | } |
| 129 | |
| 130 | Screen::paintTile(cur_tile, x, y, true); |
no test coverage detected