| 48 | } |
| 49 | |
| 50 | void ImagePartReader::forEachTileAt(Vec2I pos, TileCallback const& callback) const { |
| 51 | for (auto const& entry : m_images) { |
| 52 | String const& file = entry.first; |
| 53 | ImageConstPtr const& image = entry.second; |
| 54 | Vec4B tileColor = image->get(pos.x(), pos.y()); |
| 55 | |
| 56 | if (auto const& tile = m_tileset->getTile(tileColor)) { |
| 57 | bool exitEarly = callback(pos, *tile); |
| 58 | if (exitEarly) |
| 59 | return; |
| 60 | } else { |
| 61 | throw StarException::format("Dungeon image {} uses unknown tile color: #{:02x}{:02x}{:02x}{:02x}", |
| 62 | file, |
| 63 | tileColor[0], |
| 64 | tileColor[1], |
| 65 | tileColor[2], |
| 66 | tileColor[3]); |
| 67 | } |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | String connectorColorValue(Vec4B const& color) { |
| 72 | return strf("{},{},{},{}", color[0], color[1], color[2], color[3]); |