equal
deleted
inserted
replaced
141 const GRFConfig *c; |
141 const GRFConfig *c; |
142 uint i = (e->we.click.pt.y - w->widget[3].top) / 10 + w->vscroll.pos; |
142 uint i = (e->we.click.pt.y - w->widget[3].top) / 10 + w->vscroll.pos; |
143 |
143 |
144 for (c = _all_grfs; c != NULL && i > 0; c = c->next, i--); |
144 for (c = _all_grfs; c != NULL && i > 0; c = c->next, i--); |
145 WP(w, newgrf_add_d).sel = c; |
145 WP(w, newgrf_add_d).sel = c; |
146 SetWindowDirty(w); |
146 w->SetDirty(); |
147 break; |
147 break; |
148 } |
148 } |
149 |
149 |
150 case 6: /* Add selection to list */ |
150 case 6: /* Add selection to list */ |
151 if (WP(w, newgrf_add_d).sel != NULL) { |
151 if (WP(w, newgrf_add_d).sel != NULL) { |
177 break; |
177 break; |
178 |
178 |
179 case 7: /* Rescan list */ |
179 case 7: /* Rescan list */ |
180 WP(w, newgrf_add_d).sel = NULL; |
180 WP(w, newgrf_add_d).sel = NULL; |
181 ScanNewGRFFiles(); |
181 ScanNewGRFFiles(); |
182 SetWindowDirty(w); |
182 w->SetDirty(); |
183 break; |
183 break; |
184 } |
184 } |
185 break; |
185 break; |
186 } |
186 } |
187 } |
187 } |
242 static void SetupNewGRFState(Window *w) |
242 static void SetupNewGRFState(Window *w) |
243 { |
243 { |
244 bool disable_all = WP(w, newgrf_d).sel == NULL || !WP(w, newgrf_d).editable; |
244 bool disable_all = WP(w, newgrf_d).sel == NULL || !WP(w, newgrf_d).editable; |
245 |
245 |
246 SetWindowWidgetDisabledState(w, 3, !WP(w, newgrf_d).editable); |
246 SetWindowWidgetDisabledState(w, 3, !WP(w, newgrf_d).editable); |
247 SetWindowWidgetsDisabledState(w, disable_all, |
247 w->SetWidgetsDisabledState(disable_all, |
248 SNGRFS_REMOVE, |
248 SNGRFS_REMOVE, |
249 SNGRFS_MOVE_UP, |
249 SNGRFS_MOVE_UP, |
250 SNGRFS_MOVE_DOWN, |
250 SNGRFS_MOVE_DOWN, |
251 WIDGET_LIST_END |
251 WIDGET_LIST_END |
252 ); |
252 ); |
289 for (c = *nd->list; c != NULL && c != nd->sel; c = c->next, i++); |
289 for (c = *nd->list; c != NULL && c != nd->sel; c = c->next, i++); |
290 CopyGRFConfigList(nd->list, *nd->orig_list); |
290 CopyGRFConfigList(nd->list, *nd->orig_list); |
291 for (c = *nd->list; c != NULL && i > 0; c = c->next, i--); |
291 for (c = *nd->list; c != NULL && i > 0; c = c->next, i--); |
292 nd->sel = c; |
292 nd->sel = c; |
293 |
293 |
294 SetWindowDirty(w); |
294 w->SetDirty(); |
295 } |
295 } |
296 } |
296 } |
297 |
297 |
298 |
298 |
299 static void NewGRFWndProc(Window *w, WindowEvent *e) |
299 static void NewGRFWndProc(Window *w, WindowEvent *e) |
378 } |
378 } |
379 } |
379 } |
380 |
380 |
381 WP(w, newgrf_d).sel = newsel; |
381 WP(w, newgrf_d).sel = newsel; |
382 SetupNewGRFWindow(w); |
382 SetupNewGRFWindow(w); |
383 SetWindowDirty(w); |
383 w->SetDirty(); |
384 break; |
384 break; |
385 } |
385 } |
386 |
386 |
387 case SNGRFS_MOVE_UP: { /* Move GRF up */ |
387 case SNGRFS_MOVE_UP: { /* Move GRF up */ |
388 GRFConfig **pc, *c; |
388 GRFConfig **pc, *c; |
394 WP(w, newgrf_d).sel->next = c; |
394 WP(w, newgrf_d).sel->next = c; |
395 *pc = WP(w, newgrf_d).sel; |
395 *pc = WP(w, newgrf_d).sel; |
396 break; |
396 break; |
397 } |
397 } |
398 } |
398 } |
399 SetWindowDirty(w); |
399 w->SetDirty(); |
400 break; |
400 break; |
401 } |
401 } |
402 |
402 |
403 case SNGRFS_MOVE_DOWN: { /* Move GRF down */ |
403 case SNGRFS_MOVE_DOWN: { /* Move GRF down */ |
404 GRFConfig **pc, *c; |
404 GRFConfig **pc, *c; |
410 c->next = c->next->next; |
410 c->next = c->next->next; |
411 (*pc)->next = c; |
411 (*pc)->next = c; |
412 break; |
412 break; |
413 } |
413 } |
414 } |
414 } |
415 SetWindowDirty(w); |
415 w->SetDirty(); |
416 break; |
416 break; |
417 } |
417 } |
418 |
418 |
419 case SNGRFS_FILE_LIST: { /* Select a GRF */ |
419 case SNGRFS_FILE_LIST: { /* Select a GRF */ |
420 GRFConfig *c; |
420 GRFConfig *c; |
421 uint i = (e->we.click.pt.y - w->widget[SNGRFS_FILE_LIST].top) / 14 + w->vscroll.pos; |
421 uint i = (e->we.click.pt.y - w->widget[SNGRFS_FILE_LIST].top) / 14 + w->vscroll.pos; |
422 |
422 |
423 for (c = *WP(w, newgrf_d).list; c != NULL && i > 0; c = c->next, i--); |
423 for (c = *WP(w, newgrf_d).list; c != NULL && i > 0; c = c->next, i--); |
424 WP(w, newgrf_d).sel = c; |
424 WP(w, newgrf_d).sel = c; |
425 |
425 |
426 SetWindowDirty(w); |
426 w->SetDirty(); |
427 break; |
427 break; |
428 } |
428 } |
429 |
429 |
430 case SNGRFS_APPLY_CHANGES: /* Apply changes made to GRF list */ |
430 case SNGRFS_APPLY_CHANGES: /* Apply changes made to GRF list */ |
431 if (WP(w, newgrf_d).execute) { |
431 if (WP(w, newgrf_d).execute) { |
458 c->num_params = parse_intlist(e->we.edittext.str, (int*)c->param, lengthof(c->param)); |
458 c->num_params = parse_intlist(e->we.edittext.str, (int*)c->param, lengthof(c->param)); |
459 |
459 |
460 /* parse_intlist returns -1 on error */ |
460 /* parse_intlist returns -1 on error */ |
461 if (c->num_params == (byte)-1) c->num_params = 0; |
461 if (c->num_params == (byte)-1) c->num_params = 0; |
462 } |
462 } |
463 SetWindowDirty(w); |
463 w->SetDirty(); |
464 break; |
464 break; |
465 |
465 |
466 case WE_DESTROY: |
466 case WE_DESTROY: |
467 /* Remove the temporary copy of grf-list used in window */ |
467 /* Remove the temporary copy of grf-list used in window */ |
468 ClearGRFConfigList(WP(w, newgrf_d).list); |
468 ClearGRFConfigList(WP(w, newgrf_d).list); |