src/graph_gui.cpp
changeset 5771 1b62f1c3b266
parent 5768 dded34549c8c
child 5776 d36a554d7ccd
equal deleted inserted replaced
5770:2ddb043a2c61 5771:1b62f1c3b266
    31 
    31 
    32 typedef struct GraphDrawer {
    32 typedef struct GraphDrawer {
    33 	uint sel; // bitmask of the players *excluded* (e.g. 11111111 means that no players are shown)
    33 	uint sel; // bitmask of the players *excluded* (e.g. 11111111 means that no players are shown)
    34 	byte num_dataset;
    34 	byte num_dataset;
    35 	byte num_on_x_axis;
    35 	byte num_on_x_axis;
       
    36 	bool include_neg;
       
    37 	byte num_vert_lines;
       
    38 
       
    39 	/* The starting month and year that values are plotted against. If month is
       
    40 	 * 0xFF, use x_values_start and x_values_increment below instead. */
    36 	byte month;
    41 	byte month;
    37 	Year year;
    42 	Year year;
    38 	bool include_neg;
    43 
    39 	byte num_vert_lines;
    44 	/* These values are used if the graph is being plotted against values
    40 	uint16 unk61A;
    45 	 * rather than the dates specified by month and year. */
    41 	uint16 unk61C;
    46 	uint16 x_values_start;
       
    47 	uint16 x_values_increment;
       
    48 
    42 	int left, top;
    49 	int left, top;
    43 	uint height;
    50 	uint height;
    44 	StringID format_str_y_axis;
    51 	StringID format_str_y_axis;
    45 	byte colors[GRAPH_MAX_DATASETS];
    52 	byte colors[GRAPH_MAX_DATASETS];
    46 	int64 cost[GRAPH_MAX_DATASETS][24]; // last 2 years
    53 	int64 cost[GRAPH_MAX_DATASETS][24]; // last 2 years
   169 			x += 22;
   176 			x += 22;
   170 		} while (--i);
   177 		} while (--i);
   171 	} else {
   178 	} else {
   172 		x = gw->left + 52;
   179 		x = gw->left + 52;
   173 		y = gw->top + gw->height + 1;
   180 		y = gw->top + gw->height + 1;
   174 		j = gw->unk61A;
   181 		uint16 label = gw->x_values_start;
   175 		i = gw->num_on_x_axis;assert(i>0);
   182 
   176 		do {
   183 		for (int i = 0; i < gw->num_on_x_axis; i++) {
   177 			SetDParam(0, j);
   184 			SetDParam(0, label);
   178 			DrawString(x, y, STR_01CB, GRAPH_AXIS_LABEL_COLOUR);
   185 			DrawString(x, y, STR_01CB, GRAPH_AXIS_LABEL_COLOUR);
   179 			j += gw->unk61C;
   186 			label += gw->x_values_increment;
   180 			x += 22;
   187 			x += 22;
   181 		} while (--i);
   188 		}
   182 	}
   189 	}
   183 
   190 
   184 	/* draw lines and dots */
   191 	/* draw lines and dots */
   185 	i = 0;
   192 	i = 0;
   186 	row_ptr = gw->cost[0];
   193 	row_ptr = gw->cost[0];
   710 		gd.format_str_y_axis = STR_CURRCOMPACT;
   717 		gd.format_str_y_axis = STR_CURRCOMPACT;
   711 		gd.num_dataset = NUM_CARGO;
   718 		gd.num_dataset = NUM_CARGO;
   712 		gd.num_on_x_axis = 20;
   719 		gd.num_on_x_axis = 20;
   713 		gd.num_vert_lines = 20;
   720 		gd.num_vert_lines = 20;
   714 		gd.month = 0xFF;
   721 		gd.month = 0xFF;
   715 		gd.unk61A = 10;
   722 		gd.x_values_start     = 10;
   716 		gd.unk61C = 10;
   723 		gd.x_values_increment = 10;
   717 
   724 
   718 		for (i = 0; i != NUM_CARGO; i++) {
   725 		for (i = 0; i != NUM_CARGO; i++) {
   719 			/* Since the buttons have no text, no images,
   726 			/* Since the buttons have no text, no images,
   720 			 * both the text and the colored box have to be manually painted.
   727 			 * both the text and the colored box have to be manually painted.
   721 			 * clk_dif will move one pixel down and one pixel to the right
   728 			 * clk_dif will move one pixel down and one pixel to the right