125 for (c = _all_grfs; c != NULL; c = c->next) n++; |
125 for (c = _all_grfs; c != NULL; c = c->next) n++; |
126 |
126 |
127 w->vscroll.cap = (w->widget[3].bottom - w->widget[3].top) / 10; |
127 w->vscroll.cap = (w->widget[3].bottom - w->widget[3].top) / 10; |
128 SetVScrollCount(w, n); |
128 SetVScrollCount(w, n); |
129 |
129 |
130 SetWindowWidgetDisabledState(w, 6, WP(w, newgrf_add_d).sel == NULL || WP(w, newgrf_add_d).sel->IsOpenTTDBaseGRF()); |
130 w->SetWidgetDisabledState(6, WP(w, newgrf_add_d).sel == NULL || WP(w, newgrf_add_d).sel->IsOpenTTDBaseGRF()); |
131 DrawWindowWidgets(w); |
131 DrawWindowWidgets(w); |
132 |
132 |
133 GfxFillRect(w->widget[3].left + 1, w->widget[3].top + 1, w->widget[3].right, w->widget[3].bottom, 0xD7); |
133 GfxFillRect(w->widget[3].left + 1, w->widget[3].top + 1, w->widget[3].right, w->widget[3].bottom, 0xD7); |
134 |
134 |
135 n = 0; |
135 n = 0; |
267 |
267 |
268 static void SetupNewGRFState(Window *w) |
268 static void SetupNewGRFState(Window *w) |
269 { |
269 { |
270 bool disable_all = WP(w, newgrf_d).sel == NULL || !WP(w, newgrf_d).editable; |
270 bool disable_all = WP(w, newgrf_d).sel == NULL || !WP(w, newgrf_d).editable; |
271 |
271 |
272 SetWindowWidgetDisabledState(w, 3, !WP(w, newgrf_d).editable); |
272 w->SetWidgetDisabledState(3, !WP(w, newgrf_d).editable); |
273 SetWindowWidgetsDisabledState(w, disable_all, |
273 w->SetWidgetsDisabledState(disable_all, |
274 SNGRFS_REMOVE, |
274 SNGRFS_REMOVE, |
275 SNGRFS_MOVE_UP, |
275 SNGRFS_MOVE_UP, |
276 SNGRFS_MOVE_DOWN, |
276 SNGRFS_MOVE_DOWN, |
277 WIDGET_LIST_END |
277 WIDGET_LIST_END |
278 ); |
278 ); |
279 SetWindowWidgetDisabledState(w, SNGRFS_SET_PARAMETERS, !WP(w, newgrf_d).show_params || disable_all); |
279 w->SetWidgetDisabledState(SNGRFS_SET_PARAMETERS, !WP(w, newgrf_d).show_params || disable_all); |
280 |
280 |
281 if (!disable_all) { |
281 if (!disable_all) { |
282 /* All widgets are now enabled, so disable widgets we can't use */ |
282 /* All widgets are now enabled, so disable widgets we can't use */ |
283 if (WP(w, newgrf_d).sel == *WP(w, newgrf_d).list) DisableWindowWidget(w, SNGRFS_MOVE_UP); |
283 if (WP(w, newgrf_d).sel == *WP(w, newgrf_d).list) w->DisableWidget(SNGRFS_MOVE_UP); |
284 if (WP(w, newgrf_d).sel->next == NULL) DisableWindowWidget(w, SNGRFS_MOVE_DOWN); |
284 if (WP(w, newgrf_d).sel->next == NULL) w->DisableWidget(SNGRFS_MOVE_DOWN); |
285 if (WP(w, newgrf_d).sel->IsOpenTTDBaseGRF()) DisableWindowWidget(w, SNGRFS_REMOVE); |
285 if (WP(w, newgrf_d).sel->IsOpenTTDBaseGRF()) w->DisableWidget(SNGRFS_REMOVE); |
286 } |
286 } |
287 } |
287 } |
288 |
288 |
289 |
289 |
290 static void SetupNewGRFWindow(Window *w) |
290 static void SetupNewGRFWindow(Window *w) |
294 |
294 |
295 for (c = *WP(w, newgrf_d).list, i = 0; c != NULL; c = c->next, i++); |
295 for (c = *WP(w, newgrf_d).list, i = 0; c != NULL; c = c->next, i++); |
296 |
296 |
297 w->vscroll.cap = (w->widget[SNGRFS_FILE_LIST].bottom - w->widget[SNGRFS_FILE_LIST].top) / 14 + 1; |
297 w->vscroll.cap = (w->widget[SNGRFS_FILE_LIST].bottom - w->widget[SNGRFS_FILE_LIST].top) / 14 + 1; |
298 SetVScrollCount(w, i); |
298 SetVScrollCount(w, i); |
299 SetWindowWidgetDisabledState(w, SNGRFS_APPLY_CHANGES, !WP(w, newgrf_d).editable); |
299 w->SetWidgetDisabledState(SNGRFS_APPLY_CHANGES, !WP(w, newgrf_d).editable); |
300 } |
300 } |
301 |
301 |
302 |
302 |
303 /** Callback function for the newgrf 'apply changes' confirmation window |
303 /** Callback function for the newgrf 'apply changes' confirmation window |
304 * @param w Window which is calling this callback |
304 * @param w Window which is calling this callback |