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 44 insertions and 61 deletions:
0 comments (0 inline, 0 general)
src/graph_gui.cpp
Show inline comments
 
@@ -246,24 +246,23 @@ static void DrawGraph(const GraphDrawer 
 

	
 
static void GraphLegendWndProc(Window *w, WindowEvent *e)
 
{
 
	const Player* p;
 

	
 
	switch (e->event) {
 
	case WE_CREATE: {
 
		uint i;
 
		for (i = 3; i < w->widget_count; i++) {
 
		case WE_CREATE:
 
			for (uint 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) {
 
				if (p->is_active) continue;
 

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

	
 
		DrawWindowWidgets(w);
 

	
 
		FOR_ALL_PLAYERS(p) {
 
@@ -277,9 +276,11 @@ static void GraphLegendWndProc(Window *w
 
			DrawString(21, 17 + p->index * 12, STR_7021, HASBIT(_legend_excluded_players, p->index) ? 0x10 : 0xC);
 
		}
 
		break;
 
		}
 

	
 
	case WE_CLICK:
 
		if (IS_INT_INSIDE(e->we.click.widget, 3, 11)) {
 
			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);
 
@@ -288,7 +289,6 @@ static void GraphLegendWndProc(Window *w
 
			InvalidateWindow(WC_DELIVERED_CARGO, 0);
 
			InvalidateWindow(WC_PERFORMANCE_HISTORY, 0);
 
			InvalidateWindow(WC_COMPANY_VALUE, 0);
 
		}
 
		break;
 
	}
 
}
 
@@ -362,8 +362,6 @@ static void OperatingProfitWndProc(Windo
 
	case WE_PAINT: {
 
		GraphDrawer gd;
 
		const Player* p;
 
		int i,j;
 
		int numd;
 

	
 
		DrawWindowWidgets(w);
 

	
 
@@ -375,11 +373,11 @@ static void OperatingProfitWndProc(Windo
 

	
 
		SetupGraphDrawerForPlayers(&gd);
 

	
 
		numd = 0;
 
			int 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;) {
 
					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++;
 
				}
 
@@ -390,10 +388,12 @@ static void OperatingProfitWndProc(Windo
 
		gd.num_dataset = numd;
 

	
 
		DrawGraph(&gd);
 
	}	break;
 
			break;
 
		}
 

	
 
	case WE_CLICK:
 
		if (e->we.click.widget == 2) /* Clicked on Legend */
 
			ShowGraphLegend();
 
			/* Clicked on legend? */
 
			if (e->we.click.widget == 2) ShowGraphLegend();
 
		break;
 
	}
 
}
 
@@ -433,8 +433,6 @@ static void IncomeGraphWndProc(Window *w
 
	case WE_PAINT: {
 
		GraphDrawer gd;
 
		const Player* p;
 
		int i,j;
 
		int numd;
 

	
 
		DrawWindowWidgets(w);
 

	
 
@@ -445,11 +443,11 @@ static void IncomeGraphWndProc(Window *w
 
		gd.format_str_y_axis = STR_CURRCOMPACT;
 
		SetupGraphDrawerForPlayers(&gd);
 

	
 
		numd = 0;
 
			int 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;) {
 
					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++;
 
				}
 
@@ -464,8 +462,7 @@ static void IncomeGraphWndProc(Window *w
 
	}
 

	
 
	case WE_CLICK:
 
		if (e->we.click.widget == 2)
 
			ShowGraphLegend();
 
			if (e->we.click.widget == 2) ShowGraphLegend();
 
		break;
 
	}
 
}
 
@@ -503,8 +500,6 @@ static void DeliveredCargoGraphWndProc(W
 
	case WE_PAINT: {
 
		GraphDrawer gd;
 
		const Player* p;
 
		int i,j;
 
		int numd;
 

	
 
		DrawWindowWidgets(w);
 

	
 
@@ -515,11 +510,11 @@ static void DeliveredCargoGraphWndProc(W
 
		gd.format_str_y_axis = STR_7024;
 
		SetupGraphDrawerForPlayers(&gd);
 

	
 
		numd = 0;
 
			int 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;) {
 
					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++;
 
				}
 
@@ -534,8 +529,7 @@ static void DeliveredCargoGraphWndProc(W
 
	}
 

	
 
	case WE_CLICK:
 
		if (e->we.click.widget == 2)
 
			ShowGraphLegend();
 
			if (e->we.click.widget == 2) ShowGraphLegend();
 
		break;
 
	}
 
}
 
@@ -573,8 +567,6 @@ static void PerformanceHistoryWndProc(Wi
 
	case WE_PAINT: {
 
		GraphDrawer gd;
 
		const Player* p;
 
		int i,j;
 
		int numd;
 

	
 
		DrawWindowWidgets(w);
 

	
 
@@ -585,11 +577,11 @@ static void PerformanceHistoryWndProc(Wi
 
		gd.format_str_y_axis = STR_7024;
 
		SetupGraphDrawerForPlayers(&gd);
 

	
 
		numd = 0;
 
			int 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;) {
 
					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++;
 
				}
 
@@ -604,10 +596,8 @@ static void PerformanceHistoryWndProc(Wi
 
	}
 

	
 
	case WE_CLICK:
 
		if (e->we.click.widget == 2)
 
			ShowGraphLegend();
 
		if (e->we.click.widget == 3)
 
			ShowPerformanceRatingDetail();
 
			if (e->we.click.widget == 2) ShowGraphLegend();
 
			if (e->we.click.widget == 3) ShowPerformanceRatingDetail();
 
		break;
 
	}
 
}
 
@@ -646,8 +636,6 @@ static void CompanyValueGraphWndProc(Win
 
	case WE_PAINT: {
 
		GraphDrawer gd;
 
		const Player* p;
 
		int i,j;
 
		int numd;
 

	
 
		DrawWindowWidgets(w);
 

	
 
@@ -658,11 +646,11 @@ static void CompanyValueGraphWndProc(Win
 
		gd.format_str_y_axis = STR_CURRCOMPACT;
 
		SetupGraphDrawerForPlayers(&gd);
 

	
 
		numd = 0;
 
			int 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;) {
 
					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++;
 
				}
 
@@ -677,8 +665,7 @@ static void CompanyValueGraphWndProc(Win
 
	}
 

	
 
	case WE_CLICK:
 
		if (e->we.click.widget == 2)
 
			ShowGraphLegend();
 
			if (e->we.click.widget == 2) ShowGraphLegend();
 
		break;
 
	}
 
}
 
@@ -714,14 +701,12 @@ static void CargoPaymentRatesWndProc(Win
 
{
 
	switch (e->event) {
 
	case WE_PAINT: {
 
		int j, x, y;
 
		uint i = 0;
 
		GraphDrawer gd;
 

	
 
		DrawWindowWidgets(w);
 

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

	
 
		gd.excluded_data = _legend_excluded_cargo;
 
		gd.left = 2;
 
@@ -735,6 +720,7 @@ static void CargoPaymentRatesWndProc(Win
 
		gd.x_values_start     = 10;
 
		gd.x_values_increment = 10;
 

	
 
			uint i = 0;
 
		for (CargoID c = 0; c != NUM_CARGO; c++) {
 
			const CargoSpec *cs = GetCargo(c);
 
			if (!cs->IsValid()) continue;
 
@@ -757,7 +743,7 @@ static void CargoPaymentRatesWndProc(Win
 
			}
 

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

	
 
@@ -769,15 +755,16 @@ static void CargoPaymentRatesWndProc(Win
 

	
 
		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;
 
			break;
 
		}
 

	
 
	case WE_CLICK: {
 
		if (e->we.click.widget >= 3 && e->we.click.widget < (int)w->widget_count) {
 
		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;
 
			break;
 
	}
 
}
 

	
 
@@ -876,17 +863,15 @@ static void CompanyLeagueWndProc(Window 
 
		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);
 
@@ -1083,11 +1068,10 @@ static void PerformanceRatingDetailWndPr
 
			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
 
@@ -1105,7 +1089,7 @@ static void PerformanceRatingDetailWndPr
 
			break;
 
		}
 

	
 
		case WE_TICK: {
 
		case WE_TICK:
 
			/* Update the player score every 5 days */
 
			if (--w->custom[0] == 0) {
 
				w->custom[0] = DAY_TICKS;
 
@@ -1124,7 +1108,6 @@ static void PerformanceRatingDetailWndPr
 
			break;
 
		}
 
	}
 
}
 

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