src/newgrf_gui.cpp
branchnoai
changeset 9629 66dde6412125
parent 9627 6a7c8ead2328
child 9694 e72987579514
equal deleted inserted replaced
9628:b5c2449616b5 9629:66dde6412125
   154 				ShowNewGRFInfo(WP(w, newgrf_add_d).sel, wi->left + 2, wi->top + 2, wi->right - wi->left - 2, wi->bottom, false);
   154 				ShowNewGRFInfo(WP(w, newgrf_add_d).sel, wi->left + 2, wi->top + 2, wi->right - wi->left - 2, wi->bottom, false);
   155 			}
   155 			}
   156 			break;
   156 			break;
   157 		}
   157 		}
   158 
   158 
       
   159 		case WE_DOUBLE_CLICK:
       
   160 			if (e->we.click.widget != 3) break;
       
   161 			e->we.click.widget = 6;
       
   162 			/* Fall through */
       
   163 
   159 		case WE_CLICK:
   164 		case WE_CLICK:
   160 			switch (e->we.click.widget) {
   165 			switch (e->we.click.widget) {
   161 				case 3: {
   166 				case 3: {
   162 					/* Get row... */
   167 					/* Get row... */
   163 					const GRFConfig *c;
   168 					const GRFConfig *c;
   184 
   189 
   185 						/* Copy GRF details from scanned list */
   190 						/* Copy GRF details from scanned list */
   186 						GRFConfig *c = CallocT<GRFConfig>(1);
   191 						GRFConfig *c = CallocT<GRFConfig>(1);
   187 						*c = *src;
   192 						*c = *src;
   188 						c->filename = strdup(src->filename);
   193 						c->filename = strdup(src->filename);
   189 						if (src->full_path != NULL) c->full_path = strdup(src->full_path);
       
   190 						if (src->name      != NULL) c->name      = strdup(src->name);
   194 						if (src->name      != NULL) c->name      = strdup(src->name);
   191 						if (src->info      != NULL) c->info      = strdup(src->info);
   195 						if (src->info      != NULL) c->info      = strdup(src->info);
   192 						c->next = NULL;
   196 						c->next = NULL;
   193 
   197 
   194 						/* Append GRF config to configuration list */
   198 						/* Append GRF config to configuration list */
   305 	if (confirmed) {
   309 	if (confirmed) {
   306 		newgrf_d *nd = &WP(w, newgrf_d);
   310 		newgrf_d *nd = &WP(w, newgrf_d);
   307 		GRFConfig *c;
   311 		GRFConfig *c;
   308 		int i = 0;
   312 		int i = 0;
   309 
   313 
   310 		CopyGRFConfigList(nd->orig_list, *nd->list);
   314 		CopyGRFConfigList(nd->orig_list, *nd->list, false);
   311 		ReloadNewGRFData();
   315 		ReloadNewGRFData();
   312 
   316 
   313 		/* Show new, updated list */
   317 		/* Show new, updated list */
   314 		for (c = *nd->list; c != NULL && c != nd->sel; c = c->next, i++);
   318 		for (c = *nd->list; c != NULL && c != nd->sel; c = c->next, i++);
   315 		CopyGRFConfigList(nd->list, *nd->orig_list);
   319 		CopyGRFConfigList(nd->list, *nd->orig_list, false);
   316 		for (c = *nd->list; c != NULL && i > 0; c = c->next, i--);
   320 		for (c = *nd->list; c != NULL && i > 0; c = c->next, i--);
   317 		nd->sel = c;
   321 		nd->sel = c;
   318 
   322 
   319 		SetWindowDirty(w);
   323 		SetWindowDirty(w);
   320 	}
   324 	}
   467 							STR_NEWGRF_CONFIRMATION_TEXT,
   471 							STR_NEWGRF_CONFIRMATION_TEXT,
   468 							w,
   472 							w,
   469 							NewGRFConfirmationCallback
   473 							NewGRFConfirmationCallback
   470 						);
   474 						);
   471 					} else {
   475 					} else {
   472 						CopyGRFConfigList(WP(w, newgrf_d).orig_list, *WP(w, newgrf_d).list);
   476 						CopyGRFConfigList(WP(w, newgrf_d).orig_list, *WP(w, newgrf_d).list, true);
       
   477 						ResetGRFConfig(false);
       
   478 						ReloadNewGRFData();
   473 					}
   479 					}
   474 					break;
   480 					break;
   475 
   481 
   476 				case SNGRFS_SET_PARAMETERS: { // Edit parameters
   482 				case SNGRFS_SET_PARAMETERS: { // Edit parameters
   477 					char buff[512];
   483 					char buff[512];
   496 			SetWindowDirty(w);
   502 			SetWindowDirty(w);
   497 			break;
   503 			break;
   498 
   504 
   499 		case WE_DESTROY:
   505 		case WE_DESTROY:
   500 			if (!WP(w, newgrf_d).execute) {
   506 			if (!WP(w, newgrf_d).execute) {
   501 				CopyGRFConfigList(WP(w, newgrf_d).orig_list, *WP(w, newgrf_d).list);
   507 				CopyGRFConfigList(WP(w, newgrf_d).orig_list, *WP(w, newgrf_d).list, true);
       
   508 				ResetGRFConfig(false);
       
   509 				ReloadNewGRFData();
   502 			}
   510 			}
   503 			/* Remove the temporary copy of grf-list used in window */
   511 			/* Remove the temporary copy of grf-list used in window */
   504 			ClearGRFConfigList(WP(w, newgrf_d).list);
   512 			ClearGRFConfigList(WP(w, newgrf_d).list);
   505 			break;
   513 			break;
   506 
   514 
   563 	DeleteWindowByClass(WC_GAME_OPTIONS);
   571 	DeleteWindowByClass(WC_GAME_OPTIONS);
   564 	w = AllocateWindowDesc(&_newgrf_desc);
   572 	w = AllocateWindowDesc(&_newgrf_desc);
   565 	if (w == NULL) return;
   573 	if (w == NULL) return;
   566 
   574 
   567 	w->resize.step_height = 14;
   575 	w->resize.step_height = 14;
   568 	CopyGRFConfigList(&local, *config);
   576 	CopyGRFConfigList(&local, *config, false);
   569 
   577 
   570 	/* Clear selections */
   578 	/* Clear selections */
   571 	WP(w, newgrf_d).sel         = NULL;
   579 	WP(w, newgrf_d).sel         = NULL;
   572 	WP(w, newgrf_d).list        = &local;
   580 	WP(w, newgrf_d).list        = &local;
   573 	WP(w, newgrf_d).orig_list   = config;
   581 	WP(w, newgrf_d).orig_list   = config;