summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormaedhros <maedhros@openttd.org>2007-01-22 16:26:45 +0000
committermaedhros <maedhros@openttd.org>2007-01-22 16:26:45 +0000
commit7ce4df0ee7c63a5a12c643cfdf2cc35f2f3657a6 (patch)
treea7b443ea51923a11f9d58e895a44feef44951f88
parent89bf1d627bbd6cc3fcb01ec02ef70fedcc2c05f8 (diff)
downloadopenttd-7ce4df0ee7c63a5a12c643cfdf2cc35f2f3657a6.tar.xz
(svn r8350) -Codechange: [Graphs] Use DrawStringCentered instead of a hardcoded offset to make the string appear centred.
-rw-r--r--src/graph_gui.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/graph_gui.cpp b/src/graph_gui.cpp
index 6f0bc8d1f..ccc945a33 100644
--- a/src/graph_gui.cpp
+++ b/src/graph_gui.cpp
@@ -182,14 +182,15 @@ static void DrawGraph(const GraphDrawer *gw)
x += GRAPH_X_POSITION_SEPARATION;
}
} else {
- /* Add 8 to make the string appear centred between the lines. */
- x = gw->left + GRAPH_X_POSITION_BEGINNING + 8;
+ /* Draw the label under the data point rather than on the grid line. */
+ x = gw->left + GRAPH_X_POSITION_BEGINNING + (GRAPH_X_POSITION_SEPARATION / 2) + 1;
y = gw->top + gw->height + 1;
uint16 label = gw->x_values_start;
for (int i = 0; i < gw->num_on_x_axis; i++) {
SetDParam(0, label);
- DrawString(x, y, STR_01CB, GRAPH_AXIS_LABEL_COLOUR);
+ DrawStringCentered(x, y, STR_01CB, GRAPH_AXIS_LABEL_COLOUR);
+
label += gw->x_values_increment;
x += GRAPH_X_POSITION_SEPARATION;
}