* Draw the field. * @param xpos Position of the left edge. * @param ypos Position of the top edge. */
| 2137 | * @param ypos Position of the top edge. |
| 2138 | */ |
| 2139 | void Draw(int xpos, int ypos) const |
| 2140 | { |
| 2141 | switch (this->type) { |
| 2142 | case CFT_EMPTY: |
| 2143 | case CFT_SMALL_EMPTY: |
| 2144 | break; |
| 2145 | |
| 2146 | case CFT_HEADER: |
| 2147 | ypos += (small_height - GetCharacterHeight(FS_NORMAL)) / 2; |
| 2148 | DrawString(xpos, xpos + industry_width, ypos, this->u.header, TC_WHITE, SA_HOR_CENTER); |
| 2149 | break; |
| 2150 | |
| 2151 | case CFT_INDUSTRY: { |
| 2152 | int ypos1 = ypos + vert_inter_industry_space / 2; |
| 2153 | int ypos2 = ypos + normal_height - 1 - vert_inter_industry_space / 2; |
| 2154 | int xpos2 = xpos + industry_width - 1; |
| 2155 | DrawRectOutline({xpos, ypos1, xpos2, ypos2}, INDUSTRY_LINE_COLOUR); |
| 2156 | ypos += (normal_height - GetCharacterHeight(FS_NORMAL)) / 2; |
| 2157 | if (this->u.industry.ind_type < NUM_INDUSTRYTYPES) { |
| 2158 | const IndustrySpec *indsp = GetIndustrySpec(this->u.industry.ind_type); |
| 2159 | DrawString(xpos, xpos2, ypos, indsp->name, TC_WHITE, SA_HOR_CENTER); |
| 2160 | |
| 2161 | /* Draw the industry legend. */ |
| 2162 | int blob_left, blob_right; |
| 2163 | if (_current_text_dir == TD_RTL) { |
| 2164 | blob_right = xpos2 - blob_distance; |
| 2165 | blob_left = blob_right - CargoesField::legend.width; |
| 2166 | } else { |
| 2167 | blob_left = xpos + blob_distance; |
| 2168 | blob_right = blob_left + CargoesField::legend.width; |
| 2169 | } |
| 2170 | GfxFillRect(blob_left, ypos2 - blob_distance - CargoesField::legend.height, blob_right, ypos2 - blob_distance, PC_BLACK); // Border |
| 2171 | GfxFillRect(blob_left + 1, ypos2 - blob_distance - CargoesField::legend.height + 1, blob_right - 1, ypos2 - blob_distance - 1, indsp->map_colour); |
| 2172 | } else { |
| 2173 | DrawString(xpos, xpos2, ypos, STR_INDUSTRY_CARGOES_HOUSES, TC_FROMSTRING, SA_HOR_CENTER); |
| 2174 | } |
| 2175 | |
| 2176 | /* Draw the other_produced/other_accepted cargoes. */ |
| 2177 | std::span<const CargoType> other_right, other_left; |
| 2178 | if (_current_text_dir == TD_RTL) { |
| 2179 | other_right = this->u.industry.other_accepted; |
| 2180 | other_left = this->u.industry.other_produced; |
| 2181 | } else { |
| 2182 | other_right = this->u.industry.other_produced; |
| 2183 | other_left = this->u.industry.other_accepted; |
| 2184 | } |
| 2185 | ypos1 += CargoesField::cargo_border.height + (GetCharacterHeight(FS_NORMAL) - CargoesField::cargo_line.height) / 2; |
| 2186 | for (uint i = 0; i < CargoesField::max_cargoes; i++) { |
| 2187 | if (IsValidCargoType(other_right[i])) { |
| 2188 | const CargoSpec *csp = CargoSpec::Get(other_right[i]); |
| 2189 | int xp = xpos + industry_width + CargoesField::cargo_stub.width; |
| 2190 | DrawHorConnection(xpos + industry_width, xp - 1, ypos1, csp); |
| 2191 | GfxDrawLine(xp, ypos1, xp, ypos1 + CargoesField::cargo_line.height - 1, CARGO_LINE_COLOUR); |
| 2192 | } |
| 2193 | if (IsValidCargoType(other_left[i])) { |
| 2194 | const CargoSpec *csp = CargoSpec::Get(other_left[i]); |
| 2195 | int xp = xpos - CargoesField::cargo_stub.width; |
| 2196 | DrawHorConnection(xp + 1, xpos - 1, ypos1, csp); |
no test coverage detected