* Draws the small map. * * Basically, the small map is draw column of pixels by column of pixels. The pixels * are drawn directly into the screen buffer. The final map is drawn in multiple passes. * The passes are: * The colours of tiles in the different modes. * Town names (optional) * * @param dpi pointer to pixel to write onto */
| 1055 | * @param dpi pointer to pixel to write onto |
| 1056 | */ |
| 1057 | void DrawSmallMap(DrawPixelInfo *dpi) const |
| 1058 | { |
| 1059 | Blitter *blitter = BlitterFactory::GetCurrentBlitter(); |
| 1060 | AutoRestoreBackup dpi_backup(_cur_dpi, dpi); |
| 1061 | |
| 1062 | /* Clear it */ |
| 1063 | GfxFillRect(dpi->left, dpi->top, dpi->left + dpi->width - 1, dpi->top + dpi->height - 1, PC_BLACK); |
| 1064 | |
| 1065 | /* Which tile is displayed at (dpi->left, dpi->top)? */ |
| 1066 | int dx; |
| 1067 | Point tile = this->PixelToTile(dpi->left, dpi->top, &dx); |
| 1068 | int tile_x = this->scroll_x / (int)TILE_SIZE + tile.x; |
| 1069 | int tile_y = this->scroll_y / (int)TILE_SIZE + tile.y; |
| 1070 | |
| 1071 | void *ptr = blitter->MoveTo(dpi->dst_ptr, -dx - 4, 0); |
| 1072 | int x = - dx - 4; |
| 1073 | int y = 0; |
| 1074 | |
| 1075 | for (;;) { |
| 1076 | /* Distance from left edge */ |
| 1077 | if (x >= -3) { |
| 1078 | if (x >= dpi->width) break; // Exit the loop. |
| 1079 | |
| 1080 | int end_pos = std::min(dpi->width, x + 4); |
| 1081 | int reps = (dpi->height - y + 1) / 2; // Number of lines. |
| 1082 | if (reps > 0) { |
| 1083 | this->DrawSmallMapColumn(ptr, tile_x, tile_y, dpi->pitch * 2, reps, x, end_pos, blitter); |
| 1084 | } |
| 1085 | } |
| 1086 | |
| 1087 | if (y == 0) { |
| 1088 | tile_y += this->zoom; |
| 1089 | y++; |
| 1090 | ptr = blitter->MoveTo(ptr, 0, 1); |
| 1091 | } else { |
| 1092 | tile_x -= this->zoom; |
| 1093 | y--; |
| 1094 | ptr = blitter->MoveTo(ptr, 0, -1); |
| 1095 | } |
| 1096 | ptr = blitter->MoveTo(ptr, 2, 0); |
| 1097 | x += 2; |
| 1098 | } |
| 1099 | |
| 1100 | /* Draw vehicles */ |
| 1101 | if (this->map_type == SMT_CONTOUR || this->map_type == SMT_VEHICLES) this->DrawVehicles(dpi, blitter); |
| 1102 | |
| 1103 | /* Draw link stat overlay */ |
| 1104 | if (this->map_type == SMT_LINKSTATS) this->overlay->Draw(dpi); |
| 1105 | |
| 1106 | const int map_labels_vertical_padding = ScaleGUITrad(2); |
| 1107 | |
| 1108 | /* Draw town names */ |
| 1109 | if (this->show_towns) this->DrawTowns(dpi, map_labels_vertical_padding); |
| 1110 | |
| 1111 | /* Draw industry names */ |
| 1112 | if (this->show_ind_names) this->DrawIndustryNames(dpi, map_labels_vertical_padding); |
| 1113 | |
| 1114 | /* Draw map indicators */ |
no test coverage detected