Changeset - r6203:98501730446a
[Not reviewed]
master
0 1 0
peter1138 - 17 years ago 2007-03-03 09:58:20
peter1138@openttd.org
(svn r8989) -Fix: more indenting and variable scoping
1 file changed with 235 insertions and 252 deletions:
0 comments (0 inline, 0 general)
src/graph_gui.cpp
Show inline comments
 
@@ -243,56 +243,56 @@ static void DrawGraph(const GraphDrawer 
 
/****************/
 
/* GRAPH LEGEND */
 
/****************/
 

	
 
static void GraphLegendWndProc(Window *w, WindowEvent *e)
 
{
 
	const Player* p;
 
	switch (e->event) {
 
		case WE_CREATE:
 
			for (uint i = 3; i < w->widget_count; i++) {
 
				if (!HASBIT(_legend_excluded_players, i - 3)) LowerWindowWidget(w, i);
 
			}
 
			break;
 

	
 
	switch (e->event) {
 
	case WE_CREATE: {
 
		uint i;
 
		for (i = 3; i < w->widget_count; i++) {
 
			if (!HASBIT(_legend_excluded_players, i - 3)) LowerWindowWidget(w, i);
 
		}
 
		break;
 
	}
 
		case WE_PAINT: {
 
			const Player *p;
 

	
 
	case WE_PAINT:
 
		FOR_ALL_PLAYERS(p) {
 
			if (!p->is_active) {
 
			FOR_ALL_PLAYERS(p) {
 
				if (p->is_active) continue;
 

	
 
				SETBIT(_legend_excluded_players, p->index);
 
				RaiseWindowWidget(w, p->index + 3);
 
			}
 
		}
 
		DrawWindowWidgets(w);
 

	
 
			DrawWindowWidgets(w);
 

	
 
		FOR_ALL_PLAYERS(p) {
 
			if (!p->is_active) continue;
 
			FOR_ALL_PLAYERS(p) {
 
				if (!p->is_active) continue;
 

	
 
			DrawPlayerIcon(p->index, 4, 18+p->index*12);
 
				DrawPlayerIcon(p->index, 4, 18+p->index*12);
 

	
 
			SetDParam(0, p->name_1);
 
			SetDParam(1, p->name_2);
 
			SetDParam(2, GetPlayerNameString(p->index, 3));
 
			DrawString(21, 17 + p->index * 12, STR_7021, HASBIT(_legend_excluded_players, p->index) ? 0x10 : 0xC);
 
				SetDParam(0, p->name_1);
 
				SetDParam(1, p->name_2);
 
				SetDParam(2, GetPlayerNameString(p->index, 3));
 
				DrawString(21, 17 + p->index * 12, STR_7021, HASBIT(_legend_excluded_players, p->index) ? 0x10 : 0xC);
 
			}
 
			break;
 
		}
 
		break;
 

	
 
	case WE_CLICK:
 
		if (IS_INT_INSIDE(e->we.click.widget, 3, 11)) {
 
		case WE_CLICK:
 
			if (!IS_INT_INSIDE(e->we.click.widget, 3, 11)) return;
 

	
 
			TOGGLEBIT(_legend_excluded_players, e->we.click.widget - 3);
 
			ToggleWidgetLoweredState(w, e->we.click.widget);
 
			SetWindowDirty(w);
 
			InvalidateWindow(WC_INCOME_GRAPH, 0);
 
			InvalidateWindow(WC_OPERATING_PROFIT, 0);
 
			InvalidateWindow(WC_DELIVERED_CARGO, 0);
 
			InvalidateWindow(WC_PERFORMANCE_HISTORY, 0);
 
			InvalidateWindow(WC_COMPANY_VALUE, 0);
 
		}
 
		break;
 
			break;
 
	}
 
}
 

	
 
static const Widget _graph_legend_widgets[] = {
 
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                       STR_018B_CLOSE_WINDOW},
 
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   249,     0,    13, STR_704E_KEY_TO_COMPANY_GRAPHS, STR_018C_WINDOW_TITLE_DRAG_THIS},
 
@@ -338,17 +338,17 @@ static void SetupGraphDrawerForPlayers(G
 
	}
 
	gd->excluded_data = excluded_players;
 
	gd->num_vert_lines = 24;
 

	
 
	nums = 0;
 
	FOR_ALL_PLAYERS(p) {
 
		if (p->is_active) nums = max(nums,p->num_valid_stat_ent);
 
		if (p->is_active) nums = max(nums, p->num_valid_stat_ent);
 
	}
 
	gd->num_on_x_axis = min(nums,24);
 
	gd->num_on_x_axis = min(nums, 24);
 

	
 
	mo = (_cur_month/3-nums)*3;
 
	mo = (_cur_month / 3 - nums) * 3;
 
	yr = _cur_year;
 
	while (mo < 0) {
 
		yr--;
 
		mo += 12;
 
	}
 

	
 
@@ -356,48 +356,48 @@ static void SetupGraphDrawerForPlayers(G
 
	gd->month = mo;
 
}
 

	
 
static void OperatingProfitWndProc(Window *w, WindowEvent *e)
 
{
 
	switch (e->event) {
 
	case WE_PAINT: {
 
		GraphDrawer gd;
 
		const Player* p;
 
		int i,j;
 
		int numd;
 
		case WE_PAINT: {
 
			GraphDrawer gd;
 
			const Player* p;
 

	
 
			DrawWindowWidgets(w);
 

	
 
		DrawWindowWidgets(w);
 
			gd.left = 2;
 
			gd.top = 18;
 
			gd.height = 136;
 
			gd.has_negative_values = true;
 
			gd.format_str_y_axis = STR_CURRCOMPACT;
 

	
 
			SetupGraphDrawerForPlayers(&gd);
 

	
 
		gd.left = 2;
 
		gd.top = 18;
 
		gd.height = 136;
 
		gd.has_negative_values = true;
 
		gd.format_str_y_axis = STR_CURRCOMPACT;
 

	
 
		SetupGraphDrawerForPlayers(&gd);
 
			int numd = 0;
 
			FOR_ALL_PLAYERS(p) {
 
				if (p->is_active) {
 
					gd.colors[numd] = _colour_gradient[p->player_color][6];
 
					for (int j = gd.num_on_x_axis, i = 0; --j >= 0;) {
 
						gd.cost[numd][i] = (j >= p->num_valid_stat_ent) ? INVALID_DATAPOINT : (p->old_economy[j].income + p->old_economy[j].expenses);
 
						i++;
 
					}
 
				}
 
				numd++;
 
			}
 

	
 
		numd = 0;
 
		FOR_ALL_PLAYERS(p) {
 
			if (p->is_active) {
 
				gd.colors[numd] = _colour_gradient[p->player_color][6];
 
				for (j = gd.num_on_x_axis, i = 0; --j >= 0;) {
 
					gd.cost[numd][i] = (j >= p->num_valid_stat_ent) ? INVALID_DATAPOINT : (p->old_economy[j].income + p->old_economy[j].expenses);
 
					i++;
 
				}
 
			}
 
			numd++;
 
			gd.num_dataset = numd;
 

	
 
			DrawGraph(&gd);
 
			break;
 
		}
 

	
 
		gd.num_dataset = numd;
 

	
 
		DrawGraph(&gd);
 
	}	break;
 
	case WE_CLICK:
 
		if (e->we.click.widget == 2) /* Clicked on Legend */
 
			ShowGraphLegend();
 
		break;
 
		case WE_CLICK:
 
			/* Clicked on legend? */
 
			if (e->we.click.widget == 2) ShowGraphLegend();
 
			break;
 
	}
 
}
 

	
 
static const Widget _operating_profit_widgets[] = {
 
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                        STR_018B_CLOSE_WINDOW},
 
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   525,     0,    13, STR_7025_OPERATING_PROFIT_GRAPH, STR_018C_WINDOW_TITLE_DRAG_THIS},
 
@@ -427,49 +427,46 @@ void ShowOperatingProfitGraph(void)
 
/* INCOME GRAPH */
 
/****************/
 

	
 
static void IncomeGraphWndProc(Window *w, WindowEvent *e)
 
{
 
	switch (e->event) {
 
	case WE_PAINT: {
 
		GraphDrawer gd;
 
		const Player* p;
 
		int i,j;
 
		int numd;
 
		case WE_PAINT: {
 
			GraphDrawer gd;
 
			const Player* p;
 

	
 
			DrawWindowWidgets(w);
 

	
 
		DrawWindowWidgets(w);
 
			gd.left = 2;
 
			gd.top = 18;
 
			gd.height = 104;
 
			gd.has_negative_values = false;
 
			gd.format_str_y_axis = STR_CURRCOMPACT;
 
			SetupGraphDrawerForPlayers(&gd);
 

	
 
		gd.left = 2;
 
		gd.top = 18;
 
		gd.height = 104;
 
		gd.has_negative_values = false;
 
		gd.format_str_y_axis = STR_CURRCOMPACT;
 
		SetupGraphDrawerForPlayers(&gd);
 
			int numd = 0;
 
			FOR_ALL_PLAYERS(p) {
 
				if (p->is_active) {
 
					gd.colors[numd] = _colour_gradient[p->player_color][6];
 
					for (int j = gd.num_on_x_axis, i = 0; --j >= 0;) {
 
						gd.cost[numd][i] = (j >= p->num_valid_stat_ent) ? INVALID_DATAPOINT : p->old_economy[j].income;
 
						i++;
 
					}
 
				}
 
				numd++;
 
			}
 

	
 
		numd = 0;
 
		FOR_ALL_PLAYERS(p) {
 
			if (p->is_active) {
 
				gd.colors[numd] = _colour_gradient[p->player_color][6];
 
				for (j = gd.num_on_x_axis, i = 0; --j >= 0;) {
 
					gd.cost[numd][i] = (j >= p->num_valid_stat_ent) ? INVALID_DATAPOINT : p->old_economy[j].income;
 
					i++;
 
				}
 
			}
 
			numd++;
 
			gd.num_dataset = numd;
 

	
 
			DrawGraph(&gd);
 
			break;
 
		}
 

	
 
		gd.num_dataset = numd;
 

	
 
		DrawGraph(&gd);
 
		break;
 
	}
 

	
 
	case WE_CLICK:
 
		if (e->we.click.widget == 2)
 
			ShowGraphLegend();
 
		break;
 
		case WE_CLICK:
 
			if (e->we.click.widget == 2) ShowGraphLegend();
 
			break;
 
	}
 
}
 

	
 
static const Widget _income_graph_widgets[] = {
 
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,              STR_018B_CLOSE_WINDOW},
 
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   525,     0,    13, STR_7022_INCOME_GRAPH, STR_018C_WINDOW_TITLE_DRAG_THIS},
 
@@ -497,49 +494,46 @@ void ShowIncomeGraph(void)
 
/* DELIVERED CARGO */
 
/*******************/
 

	
 
static void DeliveredCargoGraphWndProc(Window *w, WindowEvent *e)
 
{
 
	switch (e->event) {
 
	case WE_PAINT: {
 
		GraphDrawer gd;
 
		const Player* p;
 
		int i,j;
 
		int numd;
 
		case WE_PAINT: {
 
			GraphDrawer gd;
 
			const Player* p;
 

	
 
			DrawWindowWidgets(w);
 

	
 
		DrawWindowWidgets(w);
 
			gd.left = 2;
 
			gd.top = 18;
 
			gd.height = 104;
 
			gd.has_negative_values = false;
 
			gd.format_str_y_axis = STR_7024;
 
			SetupGraphDrawerForPlayers(&gd);
 

	
 
		gd.left = 2;
 
		gd.top = 18;
 
		gd.height = 104;
 
		gd.has_negative_values = false;
 
		gd.format_str_y_axis = STR_7024;
 
		SetupGraphDrawerForPlayers(&gd);
 
			int numd = 0;
 
			FOR_ALL_PLAYERS(p) {
 
				if (p->is_active) {
 
					gd.colors[numd] = _colour_gradient[p->player_color][6];
 
					for (int j = gd.num_on_x_axis, i = 0; --j >= 0;) {
 
						gd.cost[numd][i] = (j >= p->num_valid_stat_ent) ? INVALID_DATAPOINT : p->old_economy[j].delivered_cargo;
 
						i++;
 
					}
 
				}
 
				numd++;
 
			}
 

	
 
		numd = 0;
 
		FOR_ALL_PLAYERS(p) {
 
			if (p->is_active) {
 
				gd.colors[numd] = _colour_gradient[p->player_color][6];
 
				for (j = gd.num_on_x_axis, i = 0; --j >= 0;) {
 
					gd.cost[numd][i] = (j >= p->num_valid_stat_ent) ? INVALID_DATAPOINT : p->old_economy[j].delivered_cargo;
 
					i++;
 
				}
 
			}
 
			numd++;
 
			gd.num_dataset = numd;
 

	
 
			DrawGraph(&gd);
 
			break;
 
		}
 

	
 
		gd.num_dataset = numd;
 

	
 
		DrawGraph(&gd);
 
		break;
 
	}
 

	
 
	case WE_CLICK:
 
		if (e->we.click.widget == 2)
 
			ShowGraphLegend();
 
		break;
 
		case WE_CLICK:
 
			if (e->we.click.widget == 2) ShowGraphLegend();
 
			break;
 
	}
 
}
 

	
 
static const Widget _delivered_cargo_graph_widgets[] = {
 
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                          STR_018B_CLOSE_WINDOW},
 
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   525,     0,    13, STR_7050_UNITS_OF_CARGO_DELIVERED, STR_018C_WINDOW_TITLE_DRAG_THIS},
 
@@ -567,51 +561,47 @@ void ShowDeliveredCargoGraph(void)
 
/* PERFORMANCE HISTORY */
 
/***********************/
 

	
 
static void PerformanceHistoryWndProc(Window *w, WindowEvent *e)
 
{
 
	switch (e->event) {
 
	case WE_PAINT: {
 
		GraphDrawer gd;
 
		const Player* p;
 
		int i,j;
 
		int numd;
 
		case WE_PAINT: {
 
			GraphDrawer gd;
 
			const Player* p;
 

	
 
			DrawWindowWidgets(w);
 

	
 
		DrawWindowWidgets(w);
 
			gd.left = 2;
 
			gd.top = 18;
 
			gd.height = 200;
 
			gd.has_negative_values = false;
 
			gd.format_str_y_axis = STR_7024;
 
			SetupGraphDrawerForPlayers(&gd);
 

	
 
		gd.left = 2;
 
		gd.top = 18;
 
		gd.height = 200;
 
		gd.has_negative_values = false;
 
		gd.format_str_y_axis = STR_7024;
 
		SetupGraphDrawerForPlayers(&gd);
 
			int numd = 0;
 
			FOR_ALL_PLAYERS(p) {
 
				if (p->is_active) {
 
					gd.colors[numd] = _colour_gradient[p->player_color][6];
 
					for (int j = gd.num_on_x_axis, i = 0; --j >= 0;) {
 
						gd.cost[numd][i] = (j >= p->num_valid_stat_ent) ? INVALID_DATAPOINT : p->old_economy[j].performance_history;
 
						i++;
 
					}
 
				}
 
				numd++;
 
			}
 

	
 
		numd = 0;
 
		FOR_ALL_PLAYERS(p) {
 
			if (p->is_active) {
 
				gd.colors[numd] = _colour_gradient[p->player_color][6];
 
				for (j = gd.num_on_x_axis, i = 0; --j >= 0;) {
 
					gd.cost[numd][i] = (j >= p->num_valid_stat_ent) ? INVALID_DATAPOINT : p->old_economy[j].performance_history;
 
					i++;
 
				}
 
			}
 
			numd++;
 
			gd.num_dataset = numd;
 

	
 
			DrawGraph(&gd);
 
			break;
 
		}
 

	
 
		gd.num_dataset = numd;
 

	
 
		DrawGraph(&gd);
 
		break;
 
	}
 

	
 
	case WE_CLICK:
 
		if (e->we.click.widget == 2)
 
			ShowGraphLegend();
 
		if (e->we.click.widget == 3)
 
			ShowPerformanceRatingDetail();
 
		break;
 
		case WE_CLICK:
 
			if (e->we.click.widget == 2) ShowGraphLegend();
 
			if (e->we.click.widget == 3) ShowPerformanceRatingDetail();
 
			break;
 
	}
 
}
 

	
 
static const Widget _performance_history_widgets[] = {
 
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                             STR_018B_CLOSE_WINDOW},
 
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   475,     0,    13, STR_7051_COMPANY_PERFORMANCE_RATINGS, STR_018C_WINDOW_TITLE_DRAG_THIS},
 
@@ -640,49 +630,46 @@ void ShowPerformanceHistoryGraph(void)
 
/* COMPANY VALUE */
 
/*****************/
 

	
 
static void CompanyValueGraphWndProc(Window *w, WindowEvent *e)
 
{
 
	switch (e->event) {
 
	case WE_PAINT: {
 
		GraphDrawer gd;
 
		const Player* p;
 
		int i,j;
 
		int numd;
 
		case WE_PAINT: {
 
			GraphDrawer gd;
 
			const Player* p;
 

	
 
			DrawWindowWidgets(w);
 

	
 
		DrawWindowWidgets(w);
 
			gd.left = 2;
 
			gd.top = 18;
 
			gd.height = 200;
 
			gd.has_negative_values = false;
 
			gd.format_str_y_axis = STR_CURRCOMPACT;
 
			SetupGraphDrawerForPlayers(&gd);
 

	
 
		gd.left = 2;
 
		gd.top = 18;
 
		gd.height = 200;
 
		gd.has_negative_values = false;
 
		gd.format_str_y_axis = STR_CURRCOMPACT;
 
		SetupGraphDrawerForPlayers(&gd);
 
			int numd = 0;
 
			FOR_ALL_PLAYERS(p) {
 
				if (p->is_active) {
 
					gd.colors[numd] = _colour_gradient[p->player_color][6];
 
					for (int j = gd.num_on_x_axis, i = 0; --j >= 0;) {
 
						gd.cost[numd][i] = (j >= p->num_valid_stat_ent) ? INVALID_DATAPOINT : p->old_economy[j].company_value;
 
						i++;
 
					}
 
				}
 
				numd++;
 
			}
 

	
 
		numd = 0;
 
		FOR_ALL_PLAYERS(p) {
 
			if (p->is_active) {
 
				gd.colors[numd] = _colour_gradient[p->player_color][6];
 
				for (j = gd.num_on_x_axis, i = 0; --j >= 0;) {
 
					gd.cost[numd][i] = (j >= p->num_valid_stat_ent) ? INVALID_DATAPOINT : p->old_economy[j].company_value;
 
					i++;
 
				}
 
			}
 
			numd++;
 
			gd.num_dataset = numd;
 

	
 
			DrawGraph(&gd);
 
			break;
 
		}
 

	
 
		gd.num_dataset = numd;
 

	
 
		DrawGraph(&gd);
 
		break;
 
	}
 

	
 
	case WE_CLICK:
 
		if (e->we.click.widget == 2)
 
			ShowGraphLegend();
 
		break;
 
		case WE_CLICK:
 
			if (e->we.click.widget == 2) ShowGraphLegend();
 
			break;
 
	}
 
}
 

	
 
static const Widget _company_value_graph_widgets[] = {
 
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                STR_018B_CLOSE_WINDOW},
 
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   525,     0,    13, STR_7052_COMPANY_VALUES, STR_018C_WINDOW_TITLE_DRAG_THIS},
 
@@ -710,77 +697,77 @@ void ShowCompanyValueGraph(void)
 
/* PAYMENT RATES */
 
/*****************/
 

	
 
static void CargoPaymentRatesWndProc(Window *w, WindowEvent *e)
 
{
 
	switch (e->event) {
 
	case WE_PAINT: {
 
		int j, x, y;
 
		uint i = 0;
 
		GraphDrawer gd;
 
		case WE_PAINT: {
 
			GraphDrawer gd;
 

	
 
		DrawWindowWidgets(w);
 
			DrawWindowWidgets(w);
 

	
 
		x = 495;
 
		y = 24;
 
			int x = 495;
 
			int y = 24;
 

	
 
		gd.excluded_data = _legend_excluded_cargo;
 
		gd.left = 2;
 
		gd.top = 24;
 
		gd.height = w->height - 38;
 
		gd.has_negative_values = false;
 
		gd.format_str_y_axis = STR_CURRCOMPACT;
 
		gd.num_on_x_axis = 20;
 
		gd.num_vert_lines = 20;
 
		gd.month = 0xFF;
 
		gd.x_values_start     = 10;
 
		gd.x_values_increment = 10;
 
			gd.excluded_data = _legend_excluded_cargo;
 
			gd.left = 2;
 
			gd.top = 24;
 
			gd.height = w->height - 38;
 
			gd.has_negative_values = false;
 
			gd.format_str_y_axis = STR_CURRCOMPACT;
 
			gd.num_on_x_axis = 20;
 
			gd.num_vert_lines = 20;
 
			gd.month = 0xFF;
 
			gd.x_values_start     = 10;
 
			gd.x_values_increment = 10;
 

	
 
		for (CargoID c = 0; c != NUM_CARGO; c++) {
 
			const CargoSpec *cs = GetCargo(c);
 
			if (!cs->IsValid()) continue;
 
			uint i = 0;
 
			for (CargoID c = 0; c != NUM_CARGO; c++) {
 
				const CargoSpec *cs = GetCargo(c);
 
				if (!cs->IsValid()) continue;
 

	
 
			/* Only draw labels for widgets that exist. If the widget doesn't
 
			 * exist then the local player has used the climate cheat or
 
			 * changed the NewGRF configuration with this window open. */
 
			if (i + 3 < w->widget_count) {
 
				/* Since the buttons have no text, no images,
 
				 * both the text and the colored box have to be manually painted.
 
				 * clk_dif will move one pixel down and one pixel to the right
 
				 * when the button is clicked */
 
				byte clk_dif = IsWindowWidgetLowered(w, i + 3) ? 1 : 0;
 
				/* Only draw labels for widgets that exist. If the widget doesn't
 
				 * exist then the local player has used the climate cheat or
 
				 * changed the NewGRF configuration with this window open. */
 
				if (i + 3 < w->widget_count) {
 
					/* Since the buttons have no text, no images,
 
					 * both the text and the colored box have to be manually painted.
 
					 * clk_dif will move one pixel down and one pixel to the right
 
					 * when the button is clicked */
 
					byte clk_dif = IsWindowWidgetLowered(w, i + 3) ? 1 : 0;
 

	
 
				GfxFillRect(x + clk_dif, y + clk_dif, x + 8 + clk_dif, y + 5 + clk_dif, 0);
 
				GfxFillRect(x + 1 + clk_dif, y + 1 + clk_dif, x + 7 + clk_dif, y + 4 + clk_dif, cs->legend_colour);
 
				SetDParam(0, cs->name);
 
				DrawString(x + 14 + clk_dif, y + clk_dif, STR_7065, 0);
 
				y += 8;
 
			}
 
					GfxFillRect(x + clk_dif, y + clk_dif, x + 8 + clk_dif, y + 5 + clk_dif, 0);
 
					GfxFillRect(x + 1 + clk_dif, y + 1 + clk_dif, x + 7 + clk_dif, y + 4 + clk_dif, cs->legend_colour);
 
					SetDParam(0, cs->name);
 
					DrawString(x + 14 + clk_dif, y + clk_dif, STR_7065, 0);
 
					y += 8;
 
				}
 

	
 
			gd.colors[i] = cs->legend_colour;
 
			for (j = 0; j != 20; j++) {
 
				gd.cost[i][j] = GetTransportedGoodsIncome(10, 20, j * 6 + 6, c);
 
			}
 
				gd.colors[i] = cs->legend_colour;
 
				for (uint j = 0; j != 20; j++) {
 
					gd.cost[i][j] = GetTransportedGoodsIncome(10, 20, j * 6 + 6, c);
 
				}
 

	
 
			i++;
 
		}
 
		gd.num_dataset = i;
 
				i++;
 
			}
 
			gd.num_dataset = i;
 

	
 
		DrawGraph(&gd);
 
			DrawGraph(&gd);
 

	
 
		DrawString(2 + 46, 24 + gd.height + 7, STR_7062_DAYS_IN_TRANSIT, 0);
 
		DrawString(2 + 84, 24 - 9, STR_7063_PAYMENT_FOR_DELIVERING, 0);
 
	} break;
 
			DrawString(2 + 46, 24 + gd.height + 7, STR_7062_DAYS_IN_TRANSIT, 0);
 
			DrawString(2 + 84, 24 - 9, STR_7063_PAYMENT_FOR_DELIVERING, 0);
 
			break;
 
		}
 

	
 
	case WE_CLICK: {
 
		if (e->we.click.widget >= 3 && e->we.click.widget < (int)w->widget_count) {
 
			TOGGLEBIT(_legend_excluded_cargo, e->we.click.widget - 3);
 
			ToggleWidgetLoweredState(w, e->we.click.widget);
 
			SetWindowDirty(w);
 
		}
 
	} break;
 
		case WE_CLICK:
 
			if (e->we.click.widget >= 3) {
 
				TOGGLEBIT(_legend_excluded_cargo, e->we.click.widget - 3);
 
				ToggleWidgetLoweredState(w, e->we.click.widget);
 
				SetWindowDirty(w);
 
			}
 
			break;
 
	}
 
}
 

	
 
static const Widget _cargo_payment_rates_widgets[] = {
 
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                     STR_018B_CLOSE_WINDOW},
 
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   567,     0,    13, STR_7061_CARGO_PAYMENT_RATES, STR_018C_WINDOW_TITLE_DRAG_THIS},
 
@@ -873,23 +860,21 @@ static int CDECL PerfHistComp(const void
 
static void CompanyLeagueWndProc(Window *w, WindowEvent *e)
 
{
 
	switch (e->event) {
 
		case WE_PAINT: {
 
			const Player* plist[MAX_PLAYERS];
 
			const Player* p;
 
			uint pl_num;
 
			uint i;
 

	
 
			DrawWindowWidgets(w);
 

	
 
			pl_num = 0;
 
			uint pl_num = 0;
 
			FOR_ALL_PLAYERS(p) if (p->is_active) plist[pl_num++] = p;
 

	
 
			qsort((void*)plist, pl_num, sizeof(*plist), PerfHistComp);
 

	
 
			for (i = 0; i != pl_num; i++) {
 
			for (uint i = 0; i != pl_num; i++) {
 
				p = plist[i];
 
				SetDParam(0, i + STR_01AC_1ST);
 
				SetDParam(1, p->name_1);
 
				SetDParam(2, p->name_2);
 
				SetDParam(3, GetPlayerNameString(p->index, 4));
 
				SetDParam(5, GetPerformanceTitleFromValue(p->old_economy[1].performance_history));
 
@@ -1080,17 +1065,16 @@ static void PerformanceRatingDetailWndPr
 
					SetWindowDirty(w);
 
				}
 
			}
 
			break;
 

	
 
		case WE_CREATE: {
 
			PlayerID i;
 
			Player *p2;
 

	
 
			/* Disable the players who are not active */
 
			for (i = PLAYER_FIRST; i < MAX_PLAYERS; i++) {
 
			for (PlayerID i = PLAYER_FIRST; i < MAX_PLAYERS; i++) {
 
				SetWindowWidgetDisabledState(w, i + 13, !GetPlayer(i)->is_active);
 
			}
 
			/* Update all player stats with the current data
 
			 * (this is because _score_info is not saved to a savegame) */
 
			FOR_ALL_PLAYERS(p2) {
 
				if (p2->is_active) UpdateCompanyRatingAndValue(p2, false);
 
@@ -1102,13 +1086,13 @@ static void PerformanceRatingDetailWndPr
 
			if (_performance_rating_detail_player != INVALID_PLAYER) LowerWindowWidget(w, _performance_rating_detail_player + 13);
 
			SetWindowDirty(w);
 

	
 
			break;
 
		}
 

	
 
		case WE_TICK: {
 
		case WE_TICK:
 
			/* Update the player score every 5 days */
 
			if (--w->custom[0] == 0) {
 
				w->custom[0] = DAY_TICKS;
 
				if (--w->custom[1] == 0) {
 
					Player *p2;
 

	
 
@@ -1119,13 +1103,12 @@ static void PerformanceRatingDetailWndPr
 
					}
 
					SetWindowDirty(w);
 
				}
 
			}
 

	
 
			break;
 
		}
 
	}
 
}
 

	
 
static const Widget _performance_rating_detail_widgets[] = {
 
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,               STR_018B_CLOSE_WINDOW},
 
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   298,     0,    13, STR_PERFORMANCE_DETAIL, STR_018C_WINDOW_TITLE_DRAG_THIS},
0 comments (0 inline, 0 general)