Changeset - r13626:6736aab66c51
[Not reviewed]
master
0 2 0
peter1138 - 15 years ago 2009-11-18 10:09:22
peter1138@openttd.org
(svn r18160) -Codechange: The hyphen character may not line up in all fonts, so draw
the Y-axis ticks manually.
2 files changed with 4 insertions and 3 deletions:
0 comments (0 inline, 0 general)
src/graph_gui.cpp
Show inline comments
 
@@ -261,25 +261,25 @@ protected:
 

	
 
		/* the colours and cost array of GraphDrawer must accomodate
 
		 * both values for cargo and companies. So if any are higher, quit */
 
		assert_compile(GRAPH_MAX_DATASETS >= (int)NUM_CARGO && GRAPH_MAX_DATASETS >= (int)MAX_COMPANIES);
 
		assert(this->num_vert_lines > 0);
 

	
 
		byte grid_colour = _colour_gradient[COLOUR_GREY][4];
 

	
 
		/* Rect r will be adjusted to contain just the graph, with labels being
 
		 * placed outside the area. */
 
		r.top    += 5 + GetCharacterHeight(FS_SMALL) / 2;
 
		r.bottom -= (this->month == 0xFF ? 1 : 3) * GetCharacterHeight(FS_SMALL) + 4;
 
		r.left   += 5;
 
		r.left   += 9;
 
		r.right  -= 5;
 

	
 
		/* Start of with a highest_value of twice the height of the graph in pixels.
 
		 * It's a bit arbitrary, but it makes the cargo payment graph look a little
 
		 * nicer, and prevents division by zero when calculating where the datapoint
 
		 * should be drawn. */
 
		highest_value = r.bottom - r.top + 1;
 
		if (!this->has_negative_values) highest_value *= 2;
 
		highest_value = GetHighestValue(highest_value);
 

	
 
		/* Get width for Y labels */
 
		int label_width = GetYLabelWidth(highest_value);
 
@@ -303,24 +303,25 @@ protected:
 
		/* Don't draw the first line, as that's where the axis will be. */
 
		x = r.left + x_sep;
 

	
 
		for (int i = 0; i < this->num_vert_lines; i++) {
 
			GfxFillRect(x, r.top, x, r.bottom, grid_colour);
 
			x += x_sep;
 
		}
 

	
 
		/* Draw the horizontal grid lines. */
 
		y = r.bottom;
 

	
 
		for (int i = 0; i < GRAPH_NUM_LINES_Y; i++) {
 
			GfxFillRect(r.left - 3, y, r.left - 1, y, GRAPH_AXIS_LINE_COLOUR);
 
			GfxFillRect(r.left, y, r.right, y, grid_colour);
 
			y -= y_sep;
 
		}
 

	
 
		/* Draw the y axis. */
 
		GfxFillRect(r.left, r.top, r.left, r.bottom, GRAPH_AXIS_LINE_COLOUR);
 

	
 
		/* Draw the x axis. */
 
		y = x_axis_offset + r.top;
 
		GfxFillRect(r.left, y, r.right, y, GRAPH_AXIS_LINE_COLOUR);
 

	
 
		/* Find the largest value that will be drawn. */
 
@@ -334,25 +335,25 @@ protected:
 
		int64 y_label = highest_value;
 
		int64 y_label_separation = highest_value / (GRAPH_NUM_LINES_Y - 1);
 

	
 
		/* If there are negative values, the graph goes from highest_value to
 
		 * -highest_value, not highest_value to 0. */
 
		if (this->has_negative_values) y_label_separation *= 2;
 

	
 
		y = r.top - GetCharacterHeight(FS_SMALL) / 2;
 

	
 
		for (int i = 0; i < GRAPH_NUM_LINES_Y; i++) {
 
			SetDParam(0, this->format_str_y_axis);
 
			SetDParam(1, y_label);
 
			DrawString(r.left - label_width, r.left, y, STR_GRAPH_Y_LABEL, graph_axis_label_colour, SA_RIGHT);
 
			DrawString(r.left - label_width - 4, r.left - 4, y, STR_GRAPH_Y_LABEL, graph_axis_label_colour, SA_RIGHT);
 

	
 
			y_label -= y_label_separation;
 
			y += y_sep;
 
		}
 

	
 
		/* draw strings on the x axis */
 
		if (this->month != 0xFF) {
 
			x = r.left;
 
			y = r.bottom + 2;
 
			byte month = this->month;
 
			Year year  = this->year;
 
			for (int i = 0; i < this->num_on_x_axis; i++) {
src/lang/english.txt
Show inline comments
 
@@ -497,25 +497,25 @@ STR_MONTH_JUL                           
 
STR_MONTH_AUG                                                   :August
 
STR_MONTH_SEP                                                   :September
 
STR_MONTH_OCT                                                   :October
 
STR_MONTH_NOV                                                   :November
 
STR_MONTH_DEC                                                   :December
 
############ range for months ends
 

	
 
# Graph window
 
STR_GRAPH_KEY_BUTTON                                            :{BLACK}Key
 
STR_GRAPH_KEY_TOOLTIP                                           :{BLACK}Show key to graphs
 
STR_GRAPH_X_LABEL_MONTH                                         :{TINYFONT}{STRING}{} {STRING}
 
STR_GRAPH_X_LABEL_MONTH_YEAR                                    :{TINYFONT}{STRING}{} {STRING}{}{NUM}
 
STR_GRAPH_Y_LABEL                                               :{TINYFONT}{STRING2}-
 
STR_GRAPH_Y_LABEL                                               :{TINYFONT}{STRING2}
 
STR_GRAPH_Y_LABEL_NUMBER                                        :{TINYFONT}{COMMA}
 

	
 
STR_GRAPH_OPERATING_PROFIT_CAPTION                              :{WHITE}Operating Profit Graph
 
STR_GRAPH_INCOME_CAPTION                                        :{WHITE}Income Graph
 
STR_GRAPH_CARGO_DELIVERED_CAPTION                               :{WHITE}Units of cargo delivered
 
STR_GRAPH_COMPANY_PERFORMANCE_RATINGS_CAPTION                   :{WHITE}Company performance ratings (maximum rating=1000)
 
STR_GRAPH_COMPANY_VALUES_CAPTION                                :{WHITE}Company values
 

	
 
STR_GRAPH_CARGO_PAYMENT_RATES_CAPTION                           :{WHITE}Cargo Payment Rates
 
STR_GRAPH_CARGO_PAYMENT_RATES_X_LABEL                           :{TINYFONT}{BLACK}Days in transit
 
STR_GRAPH_CARGO_PAYMENT_RATES_TITLE                             :{TINYFONT}{BLACK}Payment for delivering 10 units (or 10,000 litres) of cargo a distance of 20 squares
 
STR_GRAPH_CARGO_PAYMENT_TOGGLE_CARGO                            :{BLACK}Toggle graph for cargo type on/off
0 comments (0 inline, 0 general)