src/newgrf_gui.cpp
branchgamebalance
changeset 9895 7bd07f43b0e3
parent 6492 a1cc60b7a844
child 9906 6f41b8713b65
equal deleted inserted replaced
9894:70d78ac95d6c 9895:7bd07f43b0e3
    89 		}
    89 		}
    90 		y += DrawStringMultiLine(x, y, STR_NEWGRF_PARAMETER, w);
    90 		y += DrawStringMultiLine(x, y, STR_NEWGRF_PARAMETER, w);
    91 	}
    91 	}
    92 
    92 
    93 	/* Show flags */
    93 	/* Show flags */
    94 	if (HASBIT(c->flags, GCF_NOT_FOUND))  y += DrawStringMultiLine(x, y, STR_NEWGRF_NOT_FOUND, w);
    94 	if (c->status == GCS_NOT_FOUND)        y += DrawStringMultiLine(x, y, STR_NEWGRF_NOT_FOUND, w);
    95 	if (HASBIT(c->flags, GCF_DISABLED))   y += DrawStringMultiLine(x, y, STR_NEWGRF_DISABLED, w);
    95 	if (c->status == GCS_DISABLED)         y += DrawStringMultiLine(x, y, STR_NEWGRF_DISABLED, w);
    96 	if (HASBIT(c->flags, GCF_COMPATIBLE)) y += DrawStringMultiLine(x, y, STR_NEWGRF_COMPATIBLE_LOADED, w);
    96 	if (HASBIT(c->flags, GCF_COMPATIBLE)) y += DrawStringMultiLine(x, y, STR_NEWGRF_COMPATIBLE_LOADED, w);
    97 
    97 
    98 	/* Draw GRF info if it exists */
    98 	/* Draw GRF info if it exists */
    99 	if (c->info != NULL && !StrEmpty(c->info)) {
    99 	if (c->info != NULL && !StrEmpty(c->info)) {
   100 		SetDParamStr(0, c->info);
   100 		SetDParamStr(0, c->info);
   104 	}
   104 	}
   105 }
   105 }
   106 
   106 
   107 
   107 
   108 /* Dialogue for adding NewGRF files to the selection */
   108 /* Dialogue for adding NewGRF files to the selection */
   109 typedef struct newgrf_add_d {
   109 struct newgrf_add_d {
   110 	GRFConfig **list;
   110 	GRFConfig **list;
   111 	const GRFConfig *sel;
   111 	const GRFConfig *sel;
   112 } newgrf_add_d;
   112 };
   113 
   113 
   114 
   114 
   115 static void NewGRFAddDlgWndProc(Window *w, WindowEvent *e)
   115 static void NewGRFAddDlgWndProc(Window *w, WindowEvent *e)
   116 {
   116 {
   117 	switch (e->event) {
   117 	switch (e->event) {
   234 	NewGRFAddDlgWndProc,
   234 	NewGRFAddDlgWndProc,
   235 };
   235 };
   236 
   236 
   237 
   237 
   238 /* 'NewGRF Settings' dialogue */
   238 /* 'NewGRF Settings' dialogue */
   239 typedef struct newgrf_d {
   239 struct newgrf_d {
   240 	GRFConfig **orig_list; ///< grf list the window is shown with
   240 	GRFConfig **orig_list; ///< grf list the window is shown with
   241 	GRFConfig **list;      ///< temporary grf list to which changes are made
   241 	GRFConfig **list;      ///< temporary grf list to which changes are made
   242 	GRFConfig *sel;        ///< selected grf item
   242 	GRFConfig *sel;        ///< selected grf item
   243 	bool editable;         ///< is the window editable
   243 	bool editable;         ///< is the window editable
   244 	bool show_params;      ///< are the grf-parameters shown in the info-panel
   244 	bool show_params;      ///< are the grf-parameters shown in the info-panel
   245 	bool execute;          ///< on pressing 'apply changes' are grf changes applied immediately, or only list is updated
   245 	bool execute;          ///< on pressing 'apply changes' are grf changes applied immediately, or only list is updated
   246 } newgrf_d;
   246 };
   247 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(newgrf_d));
   247 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(newgrf_d));
   248 
   248 
   249 
   249 
   250 enum ShowNewGRFStateWidgets {
   250 enum ShowNewGRFStateWidgets {
   251 	SNGRFS_ADD = 3,
   251 	SNGRFS_ADD = 3,
   333 				if (i >= w->vscroll.pos && i < w->vscroll.pos + w->vscroll.cap) {
   333 				if (i >= w->vscroll.pos && i < w->vscroll.pos + w->vscroll.cap) {
   334 					const char *text = (c->name != NULL && !StrEmpty(c->name)) ? c->name : c->filename;
   334 					const char *text = (c->name != NULL && !StrEmpty(c->name)) ? c->name : c->filename;
   335 					SpriteID pal;
   335 					SpriteID pal;
   336 
   336 
   337 					/* Pick a colour */
   337 					/* Pick a colour */
   338 					if (HASBIT(c->flags, GCF_NOT_FOUND) || HASBIT(c->flags, GCF_DISABLED)) {
   338 					switch (c->status) {
   339 						pal = PALETTE_TO_RED;
   339 						case GCS_NOT_FOUND:
   340 					} else if (HASBIT(c->flags, GCF_STATIC)) {
   340 						case GCS_DISABLED:
       
   341 							pal = PALETTE_TO_RED;
       
   342 							break;
       
   343 						case GCS_ACTIVATED:
       
   344 							pal = PALETTE_TO_GREEN;
       
   345 							break;
       
   346 						default:
       
   347 							pal = PALETTE_TO_BLUE;
       
   348 							break;
       
   349 					}
       
   350 
       
   351 					if (HASBIT(c->flags, GCF_STATIC)) {
   341 						pal = PALETTE_TO_GREY;
   352 						pal = PALETTE_TO_GREY;
   342 					} else if (HASBIT(c->flags, GCF_COMPATIBLE)) {
   353 					} else if (HASBIT(c->flags, GCF_COMPATIBLE)) {
   343 						pal = PALETTE_TO_ORANGE;
   354 						pal = PALETTE_TO_ORANGE;
   344 					} else if (HASBIT(c->flags, GCF_ACTIVATED)) {
       
   345 						pal = PALETTE_TO_GREEN;
       
   346 					} else {
       
   347 						pal = PALETTE_TO_BLUE;
       
   348 					}
   355 					}
   349 
   356 
   350 					DrawSprite(SPR_SQUARE, pal, 5, y + 2);
   357 					DrawSprite(SPR_SQUARE, pal, 5, y + 2);
   351 					if (c->error != NULL) DrawSprite(SPR_WARNING_SIGN, 0, 20, y + 2);
   358 					if (c->error != NULL) DrawSprite(SPR_WARNING_SIGN, 0, 20, y + 2);
   352 					DoDrawString(text, c->error != NULL ? 35 : 25, y + 3, WP(w, newgrf_d).sel == c ? 0xC : 0x10);
   359 					DoDrawString(text, c->error != NULL ? 35 : 25, y + 3, WP(w, newgrf_d).sel == c ? 0xC : 0x10);