143 |
143 |
144 static void BuildAirportPickerWndProc(Window *w, WindowEvent *e) |
144 static void BuildAirportPickerWndProc(Window *w, WindowEvent *e) |
145 { |
145 { |
146 switch (e->event) { |
146 switch (e->event) { |
147 case WE_CREATE: |
147 case WE_CREATE: |
148 SetWindowWidgetLoweredState(w, 16, !_station_show_coverage); |
148 w->SetWidgetLoweredState(16, !_station_show_coverage); |
149 SetWindowWidgetLoweredState(w, 17, _station_show_coverage); |
149 w->SetWidgetLoweredState(17, _station_show_coverage); |
150 LowerWindowWidget(w, _selected_airport_type + 7); |
150 w->LowerWidget(_selected_airport_type + 7); |
151 break; |
151 break; |
152 |
152 |
153 case WE_PAINT: { |
153 case WE_PAINT: { |
154 int i; // airport enabling loop |
154 int i; // airport enabling loop |
155 uint32 avail_airports; |
155 uint32 avail_airports; |
157 |
157 |
158 if (WP(w, def_d).close) return; |
158 if (WP(w, def_d).close) return; |
159 |
159 |
160 avail_airports = GetValidAirports(); |
160 avail_airports = GetValidAirports(); |
161 |
161 |
162 RaiseWindowWidget(w, _selected_airport_type + 7); |
162 w->RaiseWidget(_selected_airport_type + 7); |
163 if (!HasBit(avail_airports, 0) && _selected_airport_type == AT_SMALL) _selected_airport_type = AT_LARGE; |
163 if (!HasBit(avail_airports, 0) && _selected_airport_type == AT_SMALL) _selected_airport_type = AT_LARGE; |
164 if (!HasBit(avail_airports, 1) && _selected_airport_type == AT_LARGE) _selected_airport_type = AT_SMALL; |
164 if (!HasBit(avail_airports, 1) && _selected_airport_type == AT_LARGE) _selected_airport_type = AT_SMALL; |
165 LowerWindowWidget(w, _selected_airport_type + 7); |
165 w->LowerWidget(_selected_airport_type + 7); |
166 |
166 |
167 /* 'Country Airport' starts at widget 7, and if its bit is set, it is |
167 /* 'Country Airport' starts at widget 7, and if its bit is set, it is |
168 * available, so take its opposite value to set the disabled state. |
168 * available, so take its opposite value to set the disabled state. |
169 * There are 9 buildable airports |
169 * There are 9 buildable airports |
170 * XXX TODO : all airports should be held in arrays, with all relevant data. |
170 * XXX TODO : all airports should be held in arrays, with all relevant data. |
171 * This should be part of newgrf-airports, i suppose |
171 * This should be part of newgrf-airports, i suppose |
172 */ |
172 */ |
173 for (i = 0; i < 9; i++) SetWindowWidgetDisabledState(w, i + 7, !HasBit(avail_airports, i)); |
173 for (i = 0; i < 9; i++) w->SetWidgetDisabledState(i + 7, !HasBit(avail_airports, i)); |
174 |
174 |
175 // select default the coverage area to 'Off' (16) |
175 // select default the coverage area to 'Off' (16) |
176 airport = GetAirport(_selected_airport_type); |
176 airport = GetAirport(_selected_airport_type); |
177 SetTileSelectSize(airport->size_x, airport->size_y); |
177 SetTileSelectSize(airport->size_x, airport->size_y); |
178 |
178 |
188 } |
188 } |
189 |
189 |
190 case WE_CLICK: { |
190 case WE_CLICK: { |
191 switch (e->we.click.widget) { |
191 switch (e->we.click.widget) { |
192 case 7: case 8: case 9: case 10: case 11: case 12: case 13: case 14: case 15: |
192 case 7: case 8: case 9: case 10: case 11: case 12: case 13: case 14: case 15: |
193 RaiseWindowWidget(w, _selected_airport_type + 7); |
193 w->RaiseWidget(_selected_airport_type + 7); |
194 _selected_airport_type = e->we.click.widget - 7; |
194 _selected_airport_type = e->we.click.widget - 7; |
195 LowerWindowWidget(w, _selected_airport_type + 7); |
195 w->LowerWidget(_selected_airport_type + 7); |
196 SndPlayFx(SND_15_BEEP); |
196 SndPlayFx(SND_15_BEEP); |
197 SetWindowDirty(w); |
197 SetWindowDirty(w); |
198 break; |
198 break; |
199 case 16: case 17: |
199 case 16: case 17: |
200 _station_show_coverage = (e->we.click.widget != 16); |
200 _station_show_coverage = (e->we.click.widget != 16); |
201 SetWindowWidgetLoweredState(w, 16, !_station_show_coverage); |
201 w->SetWidgetLoweredState(16, !_station_show_coverage); |
202 SetWindowWidgetLoweredState(w, 17, _station_show_coverage); |
202 w->SetWidgetLoweredState(17, _station_show_coverage); |
203 SndPlayFx(SND_15_BEEP); |
203 SndPlayFx(SND_15_BEEP); |
204 SetWindowDirty(w); |
204 SetWindowDirty(w); |
205 break; |
205 break; |
206 } |
206 } |
207 } break; |
207 } break; |