comparison src/graph_gui.cpp @ 7824:7ae5bda4e8dd draft

(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call. Patch heavily based on BiBB's work (FS#1383)
author belugas <belugas@openttd.org>
date Sun, 04 Nov 2007 00:08:57 +0000
parents b66a3cb83e69
children ff1975ced735
comparison
equal deleted inserted replaced
7823:a15c8666b08f 7824:7ae5bda4e8dd
26 /* GENERIC GRAPH DRAWER */ 26 /* GENERIC GRAPH DRAWER */
27 /************************/ 27 /************************/
28 28
29 enum { 29 enum {
30 GRAPH_MAX_DATASETS = 32, 30 GRAPH_MAX_DATASETS = 32,
31 GRAPH_AXIS_LABEL_COLOUR = 16, 31 GRAPH_AXIS_LABEL_COLOUR = TC_BLACK,
32 GRAPH_AXIS_LINE_COLOUR = 215, 32 GRAPH_AXIS_LINE_COLOUR = 215,
33 33
34 GRAPH_X_POSITION_BEGINNING = 44, ///< Start the graph 44 pixels from gw->left 34 GRAPH_X_POSITION_BEGINNING = 44, ///< Start the graph 44 pixels from gw->left
35 GRAPH_X_POSITION_SEPARATION = 22, ///< There are 22 pixels between each X value 35 GRAPH_X_POSITION_SEPARATION = 22, ///< There are 22 pixels between each X value
36 36
271 271
272 DrawPlayerIcon(p->index, 4, 18 + p->index * 12); 272 DrawPlayerIcon(p->index, 4, 18 + p->index * 12);
273 273
274 SetDParam(0, p->index); 274 SetDParam(0, p->index);
275 SetDParam(1, p->index); 275 SetDParam(1, p->index);
276 DrawString(21, 17 + p->index * 12, STR_7021, HASBIT(_legend_excluded_players, p->index) ? 0x10 : 0xC); 276 DrawString(21, 17 + p->index * 12, STR_7021, HASBIT(_legend_excluded_players, p->index) ? TC_BLACK : TC_WHITE);
277 } 277 }
278 break; 278 break;
279 } 279 }
280 280
281 case WE_CLICK: 281 case WE_CLICK:
736 byte clk_dif = IsWindowWidgetLowered(w, i + 3) ? 1 : 0; 736 byte clk_dif = IsWindowWidgetLowered(w, i + 3) ? 1 : 0;
737 737
738 GfxFillRect(x + clk_dif, y + clk_dif, x + 8 + clk_dif, y + 5 + clk_dif, 0); 738 GfxFillRect(x + clk_dif, y + clk_dif, x + 8 + clk_dif, y + 5 + clk_dif, 0);
739 GfxFillRect(x + 1 + clk_dif, y + 1 + clk_dif, x + 7 + clk_dif, y + 4 + clk_dif, cs->legend_colour); 739 GfxFillRect(x + 1 + clk_dif, y + 1 + clk_dif, x + 7 + clk_dif, y + 4 + clk_dif, cs->legend_colour);
740 SetDParam(0, cs->name); 740 SetDParam(0, cs->name);
741 DrawString(x + 14 + clk_dif, y + clk_dif, STR_7065, 0); 741 DrawString(x + 14 + clk_dif, y + clk_dif, STR_7065, TC_FROMSTRING);
742 y += 8; 742 y += 8;
743 } 743 }
744 744
745 gd.colors[i] = cs->legend_colour; 745 gd.colors[i] = cs->legend_colour;
746 for (uint j = 0; j != 20; j++) { 746 for (uint j = 0; j != 20; j++) {
751 } 751 }
752 gd.num_dataset = i; 752 gd.num_dataset = i;
753 753
754 DrawGraph(&gd); 754 DrawGraph(&gd);
755 755
756 DrawString(2 + 46, 24 + gd.height + 7, STR_7062_DAYS_IN_TRANSIT, 0); 756 DrawString(2 + 46, 24 + gd.height + 7, STR_7062_DAYS_IN_TRANSIT, TC_FROMSTRING);
757 DrawString(2 + 84, 24 - 9, STR_7063_PAYMENT_FOR_DELIVERING, 0); 757 DrawString(2 + 84, 24 - 9, STR_7063_PAYMENT_FOR_DELIVERING, TC_FROMSTRING);
758 break; 758 break;
759 } 759 }
760 760
761 case WE_CLICK: 761 case WE_CLICK:
762 if (e->we.click.widget >= 3) { 762 if (e->we.click.widget >= 3) {
877 SetDParam(0, i + STR_01AC_1ST); 877 SetDParam(0, i + STR_01AC_1ST);
878 SetDParam(1, p->index); 878 SetDParam(1, p->index);
879 SetDParam(2, p->index); 879 SetDParam(2, p->index);
880 SetDParam(3, GetPerformanceTitleFromValue(p->old_economy[1].performance_history)); 880 SetDParam(3, GetPerformanceTitleFromValue(p->old_economy[1].performance_history));
881 881
882 DrawString(2, 15 + i * 10, i == 0 ? STR_7054 : STR_7055, 0); 882 DrawString(2, 15 + i * 10, i == 0 ? STR_7054 : STR_7055, TC_FROMSTRING);
883 DrawPlayerIcon(p->index, 27, 16 + i * 10); 883 DrawPlayerIcon(p->index, 27, 16 + i * 10);
884 } 884 }
885 885
886 break; 886 break;
887 } 887 }
997 score = SCORE_MAX; 997 score = SCORE_MAX;
998 } else { 998 } else {
999 total_score += score; 999 total_score += score;
1000 } 1000 }
1001 1001
1002 DrawString(7, y, STR_PERFORMANCE_DETAIL_VEHICLES + i, 0); 1002 DrawString(7, y, STR_PERFORMANCE_DETAIL_VEHICLES + i, TC_FROMSTRING);
1003 1003
1004 /* Draw the score */ 1004 /* Draw the score */
1005 SetDParam(0, score); 1005 SetDParam(0, score);
1006 DrawStringRightAligned(107, y, SET_PERFORMANCE_DETAIL_INT, 0); 1006 DrawStringRightAligned(107, y, SET_PERFORMANCE_DETAIL_INT, TC_FROMSTRING);
1007 1007
1008 /* Calculate the %-bar */ 1008 /* Calculate the %-bar */
1009 x = clamp(val, 0, needed) * 50 / needed; 1009 x = clamp(val, 0, needed) * 50 / needed;
1010 1010
1011 /* SCORE_LOAN is inversed */ 1011 /* SCORE_LOAN is inversed */
1021 /* SCORE_LOAN is inversed */ 1021 /* SCORE_LOAN is inversed */
1022 if (val < 0 && i == SCORE_LOAN) x = 0; 1022 if (val < 0 && i == SCORE_LOAN) x = 0;
1023 1023
1024 /* Draw it */ 1024 /* Draw it */
1025 SetDParam(0, x); 1025 SetDParam(0, x);
1026 DrawStringCentered(137, y, STR_PERFORMANCE_DETAIL_PERCENT, 0); 1026 DrawStringCentered(137, y, STR_PERFORMANCE_DETAIL_PERCENT, TC_FROMSTRING);
1027 1027
1028 /* SCORE_LOAN is inversed */ 1028 /* SCORE_LOAN is inversed */
1029 if (i == SCORE_LOAN) val = needed - val; 1029 if (i == SCORE_LOAN) val = needed - val;
1030 1030
1031 /* Draw the amount we have against what is needed 1031 /* Draw the amount we have against what is needed
1036 case SCORE_MIN_PROFIT: 1036 case SCORE_MIN_PROFIT:
1037 case SCORE_MIN_INCOME: 1037 case SCORE_MIN_INCOME:
1038 case SCORE_MAX_INCOME: 1038 case SCORE_MAX_INCOME:
1039 case SCORE_MONEY: 1039 case SCORE_MONEY:
1040 case SCORE_LOAN: 1040 case SCORE_LOAN:
1041 DrawString(167, y, STR_PERFORMANCE_DETAIL_AMOUNT_CURRENCY, 0); 1041 DrawString(167, y, STR_PERFORMANCE_DETAIL_AMOUNT_CURRENCY, TC_FROMSTRING);
1042 break; 1042 break;
1043 default: 1043 default:
1044 DrawString(167, y, STR_PERFORMANCE_DETAIL_AMOUNT_INT, 0); 1044 DrawString(167, y, STR_PERFORMANCE_DETAIL_AMOUNT_INT, TC_FROMSTRING);
1045 } 1045 }
1046 } 1046 }
1047 1047
1048 break; 1048 break;
1049 } 1049 }