| 1129 | } |
| 1130 | |
| 1131 | void OnPaint() override |
| 1132 | { |
| 1133 | const StationSpec *statspec = StationClass::Get(_station_gui.sel_class)->GetSpec(_station_gui.sel_type); |
| 1134 | |
| 1135 | if (_settings_client.gui.station_dragdrop) { |
| 1136 | SetTileSelectSize(1, 1); |
| 1137 | } else { |
| 1138 | int x = _settings_client.gui.station_numtracks; |
| 1139 | int y = _settings_client.gui.station_platlength; |
| 1140 | if (_station_gui.axis == AXIS_X) std::swap(x, y); |
| 1141 | if (!_remove_button_clicked) { |
| 1142 | SetTileSelectSize(x, y); |
| 1143 | } |
| 1144 | } |
| 1145 | |
| 1146 | int rad = (_settings_game.station.modified_catchment) ? CA_TRAIN : CA_UNMODIFIED; |
| 1147 | |
| 1148 | if (_settings_client.gui.station_show_coverage) SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad); |
| 1149 | |
| 1150 | for (uint bits = 0; bits < 7; bits++) { |
| 1151 | bool disable = bits >= _settings_game.station.station_spread; |
| 1152 | if (statspec == nullptr) { |
| 1153 | this->SetWidgetDisabledState(bits + WID_BRAS_PLATFORM_NUM_1, disable); |
| 1154 | this->SetWidgetDisabledState(bits + WID_BRAS_PLATFORM_LEN_1, disable); |
| 1155 | } else { |
| 1156 | this->SetWidgetDisabledState(bits + WID_BRAS_PLATFORM_NUM_1, HasBit(statspec->disallowed_platforms, bits) || disable); |
| 1157 | this->SetWidgetDisabledState(bits + WID_BRAS_PLATFORM_LEN_1, HasBit(statspec->disallowed_lengths, bits) || disable); |
| 1158 | } |
| 1159 | } |
| 1160 | |
| 1161 | this->DrawWidgets(); |
| 1162 | |
| 1163 | if (this->IsShaded()) return; |
| 1164 | /* 'Accepts' and 'Supplies' texts. */ |
| 1165 | Rect r = this->GetWidget<NWidgetBase>(WID_BRAS_COVERAGE_TEXTS)->GetCurrentRect(); |
| 1166 | const int bottom = r.bottom; |
| 1167 | r.bottom = INT_MAX; // Allow overflow as we want to know the required height. |
| 1168 | if (statspec != nullptr) r.top = DrawBadgeNameList(r, statspec->badges, GSF_STATIONS); |
| 1169 | r.top = DrawStationCoverageAreaText(r, SCT_ALL, rad, false) + WidgetDimensions::scaled.vsep_normal; |
| 1170 | r.top = DrawStationCoverageAreaText(r, SCT_ALL, rad, true); |
| 1171 | /* Resize background if the window is too small. |
| 1172 | * Never make the window smaller to avoid oscillating if the size change affects the acceptance. |
| 1173 | * (This is the case, if making the window bigger moves the mouse into the window.) */ |
| 1174 | if (r.top > bottom) { |
| 1175 | this->coverage_height += r.top - bottom; |
| 1176 | this->ReInit(); |
| 1177 | } |
| 1178 | } |
| 1179 | |
| 1180 | void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override |
| 1181 | { |
nothing calls this directly
no test coverage detected